From 601377db046c78d238df01ba58ea15ded25fd6d0 Mon Sep 17 00:00:00 2001 From: John Wiseman Date: Wed, 4 Oct 2023 18:41:06 +0100 Subject: [PATCH] 0.0.0.68 --- QtTermTCP.cpp | 166 +++++++++++++++++++++++++++++++++++++---- QtTermTCP.h | 3 +- QtTermTCP.ini | 13 ++-- QtTermTCP.vcxproj.user | 8 +- release/moc_predefs.h | 11 +++ 5 files changed, 174 insertions(+), 27 deletions(-) create mode 100644 release/moc_predefs.h diff --git a/QtTermTCP.cpp b/QtTermTCP.cpp index 560b9b5..3edfb7b 100644 --- a/QtTermTCP.cpp +++ b/QtTermTCP.cpp @@ -1,6 +1,6 @@ // Qt Version of BPQTermTCP -#define VersionString "0.0.0.67" +#define VersionString "0.0.0.68" // .12 Save font weight @@ -76,6 +76,9 @@ // .67 Add config Yapp RX Size dialog July 2023 // Fix 63 port montoring +// .68 Remember last used host on restart Sept 2023 +// Add AutoConnect in Tabbed Mode + #define _CRT_SECURE_NO_WARNINGS @@ -438,6 +441,10 @@ QList _sessions; int TabType[10] = { Term, Term + Mon, Term, Term, Term, Term, Mon, Mon, Mon }; +int AutoConnect[10] = {0, 0 ,0, 0, 0, 0, 0, 0, 0, 0}; + +int currentHost[10] = {0, 0 ,0, 0, 0, 0, 0, 0, 0, 0}; + int listenPort = 8015; extern "C" int listenEnable; char listenCText[4096] = ""; @@ -1109,21 +1116,37 @@ QtTermTCP::QtTermTCP(QWidget *parent) : QMainWindow(parent) } else if (TermMode == Tabbed) { + Ui_ListenSession * Sess; + int index = 0; + tabWidget = new QTabWidget(this); + tabWidget->setContextMenuPolicy(Qt::CustomContextMenu); + + connect(tabWidget, SIGNAL(customContextMenuRequested(const QPoint &)), SLOT(showContextMenu(const QPoint &))); + ui.verticalLayout->addWidget(tabWidget); tabWidget->setTabPosition(QTabWidget::South); - newWindow(this, TabType[0], "Sess 1"); - newWindow(this, TabType[1], "Sess 2"); - newWindow(this, TabType[2], "Sess 3"); - newWindow(this, TabType[3], "Sess 4"); - newWindow(this, TabType[4], "Sess 5"); - newWindow(this, TabType[5], "Sess 6"); - newWindow(this, TabType[6], "Sess 7"); - newWindow(this, TabType[7], "Monitor"); - newWindow(this, TabType[8], "Monitor"); + Sess = newWindow(this, TabType[0], "Sess 1"); + Sess->CurrentHost = currentHost[index++]; + Sess = newWindow(this, TabType[1], "Sess 2"); + Sess->CurrentHost = currentHost[index++]; + Sess = newWindow(this, TabType[2], "Sess 3"); + Sess->CurrentHost = currentHost[index++]; + Sess = newWindow(this, TabType[3], "Sess 4"); + Sess->CurrentHost = currentHost[index++]; + Sess = newWindow(this, TabType[4], "Sess 5"); + Sess->CurrentHost = currentHost[index++]; + Sess = newWindow(this, TabType[5], "Sess 6"); + Sess->CurrentHost = currentHost[index++]; + Sess = newWindow(this, TabType[6], "Sess 7"); + Sess->CurrentHost = currentHost[index++]; + Sess = newWindow(this, TabType[7], "Monitor"); + Sess->CurrentHost = currentHost[index++]; + Sess = newWindow(this, TabType[8], "Monitor"); + Sess->CurrentHost = currentHost[index++]; ActiveSession = _sessions.at(0); @@ -1471,6 +1494,8 @@ QtTermTCP::QtTermTCP(QWidget *parent) : QMainWindow(parent) Ui_ListenSession * Sess = newWindow(this, singlemodeFormat); ActiveSession = Sess; + Sess->CurrentHost = currentHost[0]; + ui.verticalLayout->addWidget(Sess); connectMenu->setEnabled(true); @@ -1481,6 +1506,7 @@ QtTermTCP::QtTermTCP(QWidget *parent) : QMainWindow(parent) if (TermMode == MDI) { int n = atoi(sessionList); + int index = 0; char *p, *Context; char delim[] = "|"; @@ -1497,7 +1523,7 @@ QtTermTCP::QtTermTCP(QWidget *parent) : QMainWindow(parent) Ui_ListenSession * Sess = newWindow(this, type); - Sess->CurrentHost = host; + Sess->CurrentHost = currentHost[index++];; QRect r(leftx, topx, rightx - leftx, bottomx - topx); @@ -1531,8 +1557,89 @@ QtTermTCP::QtTermTCP(QWidget *parent) : QMainWindow(parent) memset(axMYCALL, 0, 7); ConvToAX25(MYCALL, axMYCALL); + + // Do any autoconnects + + for (int i = 0; i < _sessions.size(); ++i) + { + if (AutoConnect[i] > 0) + { + Ui_ListenSession * Sess = _sessions.at(i); + + Sess->clientSocket = new myTcpSocket(); + Sess->clientSocket->Sess = Sess; + + connect(Sess->clientSocket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(displayError(QAbstractSocket::SocketError))); + connect(Sess->clientSocket, SIGNAL(readyRead()), this, SLOT(readyRead())); + connect(Sess->clientSocket, SIGNAL(stateChanged(QAbstractSocket::SocketState)), this, SLOT(onSocketStateChanged(QAbstractSocket::SocketState))); + + Sess->clientSocket->connectToHost(&Host[Sess->CurrentHost][0], Port[Sess->CurrentHost]); + } + } + +} + +void QtTermTCP::showContextMenu(const QPoint &point) +{ + if (point.isNull()) + return; + + QTabBar* tabBar = tabWidget->tabBar(); + QRect Wrect = tabWidget->rect(); + QRect Brect = tabBar->rect(); + QPoint myPoint = point; + + int n = myPoint.y() - (Wrect.height() - Brect.height()); + + myPoint.setY(n); + +// QPoint tabBarPoint = mapTo(tabBar, point); + + int tabIndex = tabBar->tabAt(myPoint); + + QMenu menu(this); + + QAction * Act = new QAction("AutoConnect on load", this); + Act->setObjectName(QString::number(tabIndex)); + + menu.addAction(Act); + + Act->setCheckable(true); + + if (AutoConnect[tabIndex] <= 0) + Act->setChecked(false); + else + Act->setChecked(true); + + connect(Act, SIGNAL(triggered()), this, SLOT(autoConnectChecked())); + + QAction * selected_action = menu.exec(tabWidget->mapToGlobal(point)); + +} + +void QtTermTCP::autoConnectChecked() +{ + QAction * Act = static_cast(QObject::sender()); + QString Tab = Act->objectName(); + int tabNo = Tab.toInt(); + + tabWidget->setCurrentIndex(tabNo); + + Ui_ListenSession *Sess = (Ui_ListenSession *)tabWidget->currentWidget(); + int state = Act->isChecked(); + + if (state == 0) + AutoConnect[tabNo] = 0; + else + { + if (Sess->clientSocket) // Connected + AutoConnect[tabNo] = 1; + else + AutoConnect[tabNo] = 0; + } } + void QtTermTCP::setFonts() { windowMenu->menuAction()->setFont(*menufont); @@ -1578,13 +1685,16 @@ void QtTermTCP::doQuit() void QtTermTCP::onTEselectionChanged() { QTextEdit * x = static_cast(QObject::sender()); - x->copy(); + + if (isActiveWindow()) + x->copy(); } void QtTermTCP::onLEselectionChanged() { QLineEdit * x = static_cast(QObject::sender()); - x->copy(); + if (isActiveWindow()) + x->copy(); } void QtTermTCP::setVDMode() @@ -1963,6 +2073,8 @@ void QtTermTCP::Connect() if (i == _sessions.size()) return; + + currentHost[i] = SavedHost; } else if (TermMode == Tabbed) @@ -1978,6 +2090,8 @@ void QtTermTCP::Connect() Sess->CurrentHost = SavedHost; + currentHost[Sess->Tab] = SavedHost; + if (Act == actHost[16]) { // This runs the AGW Connection dialog @@ -3295,6 +3409,17 @@ void GetSettings() &TabType[0], &TabType[1], &TabType[2], &TabType[3], &TabType[4], &TabType[5], &TabType[6], &TabType[7], &TabType[8], &TabType[9]); + strcpy(Param, settings->value("AutoConnect", "0, 0 ,0, 0, 0, 0, 0, 0, 0, 0").toString().toUtf8()); + sscanf(Param, "%d %d %d %d %d %d %d %d %d %d", + &AutoConnect[0], &AutoConnect[1], &AutoConnect[2], &AutoConnect[3], &AutoConnect[4], + &AutoConnect[5], &AutoConnect[6], &AutoConnect[7], &AutoConnect[8], &AutoConnect[9]); + + strcpy(Param, settings->value("currentHost", "0, 0 ,0, 0, 0, 0, 0, 0, 0, 0").toString().toUtf8()); + sscanf(Param, "%d %d %d %d %d %d %d %d %d %d", + ¤tHost[0], ¤tHost[1], ¤tHost[2], ¤tHost[3], ¤tHost[4], + ¤tHost[5], ¤tHost[6], ¤tHost[7], ¤tHost[8], ¤tHost[9]); + + monBackground = settings->value("monBackground", QColor(255, 255, 255)).value(); monRxText = settings->value("monRxText", QColor(0, 0, 255)).value(); monTxText = settings->value("monTxText", QColor(255, 0, 0)).value(); @@ -3467,12 +3592,21 @@ extern "C" void SaveSettings() settings->setValue("VARAFM", VARAFM); settings->setValue("VARASAT", VARASAT); - sprintf(Param, "%d %d %d %d %d %d %d %d %d %d", TabType[0], TabType[1], TabType[2], TabType[3], TabType[4], TabType[5], TabType[6], TabType[7], TabType[8], TabType[9]); settings->setValue("TabType", Param); + sprintf(Param, "%d %d %d %d %d %d %d %d %d %d", + AutoConnect[0], AutoConnect[1], AutoConnect[2], AutoConnect[3], AutoConnect[4], AutoConnect[5], AutoConnect[6], AutoConnect[7], AutoConnect[8], AutoConnect[9]); + + settings->setValue("AutoConnect", Param); + + sprintf(Param, "%d %d %d %d %d %d %d %d %d %d", + currentHost[0], currentHost[1], currentHost[2], currentHost[3], currentHost[4], currentHost[5], currentHost[6], currentHost[7], currentHost[8], currentHost[9]); + + settings->setValue("currentHost", Param); + settings->setValue("monBackground", monBackground); settings->setValue("monRxText", monRxText); settings->setValue("monTxText", monTxText); @@ -4264,9 +4398,9 @@ void QtTermTCP::onSocketStateChanged(QAbstractSocket::SocketState socketState) else if (TermMode == Tabbed) { if (SessName[Sess->CurrentHost][0]) - tabWidget->setTabText(tabWidget->currentIndex(), SessName[Sess->CurrentHost]); + tabWidget->setTabText(Sess->Tab, SessName[Sess->CurrentHost]); else - tabWidget->setTabText(tabWidget->currentIndex(), Host[Sess->CurrentHost]); + tabWidget->setTabText(Sess->Tab, Host[Sess->CurrentHost]); } else if (TermMode == Single) this->setWindowTitle(Title); diff --git a/QtTermTCP.h b/QtTermTCP.h index c154c28..b75d0e1 100644 --- a/QtTermTCP.h +++ b/QtTermTCP.h @@ -143,7 +143,8 @@ private slots: void Connect(); void displayError(QAbstractSocket::SocketError socketError); void readyRead(); - + void showContextMenu(const QPoint & point); + void autoConnectChecked(); void LreturnPressed(Ui_ListenSession * LUI); void LDisconnect(Ui_ListenSession * LUI); void SetupHosts(); diff --git a/QtTermTCP.ini b/QtTermTCP.ini index 0a3358a..e30c210 100644 --- a/QtTermTCP.ini +++ b/QtTermTCP.ini @@ -1,10 +1,10 @@ [General] HostParams0=nottm.g8bpq.net|8011|gm8bpq|password|5 1 1 0 1 0 0 1\r|Pogo4 -geometry=@ByteArray(\x1\xd9\xd0\xcb\0\x3\0\0\0\0\0\x83\0\0\0\x1f\0\0\x4\x17\0\0\x2\xd6\0\0\0\x83\0\0\0\x1f\0\0\x4\x17\0\0\x2\xd6\0\0\0\0\0\0\0\0\x5\0\0\0\0\x83\0\0\0\x1f\0\0\x4\x17\0\0\x2\xd6) +geometry=@ByteArray(\x1\xd9\xd0\xcb\0\x3\0\0\0\0\0\xb6\0\0\0w\0\0\x4J\0\0\x3.\0\0\0\xb6\0\0\0w\0\0\x4J\0\0\x3.\0\0\0\0\0\0\0\0\x5\0\0\0\0\xb6\0\0\0w\0\0\x4J\0\0\x3.) HostParams1=192.168.1.63|8011|john|password||Pogo2 windowState=@ByteArray(\0\0\0\xff\0\0\0\0\xfd\0\0\0\0\0\0\x3\x95\0\0\x2\xa2\0\0\0\x4\0\0\0\x4\0\0\0\b\0\0\0\b\xfc\0\0\0\x1\0\0\0\x3\0\0\0\x1\0\0\0\x16\0m\0\x61\0i\0n\0T\0o\0o\0l\0\x62\0\x61\0r\0\0\0\0\0\xff\xff\xff\xff\0\0\0\0\0\0\0\0) -HostParams2=127.0.0.1|8011|john|password|c000000100000000 1 1 0 1 0 0 1\r| -HostParams3=192.168.1.44|8011|john|password|8000000000000002 1 1 1 1 0 0 1\r|Pogo4 +HostParams2=127.0.0.1|8011|john|password|1 1 1 0 1 0 0 1\r| +HostParams3=192.168.1.44|8011|john|password|1 1 1 0 1 0 0 1\r|Pogo4 HostParams4=127.0.0.1|8021|john|password|c000000100000006 1 1 0 1 0 0 1\r|LinBPQ HostParams5=192.168.1.14|8011|john|password|c00000010000002e 1 1 0 1 0 0 1\r| HostParams6=127.0.0.1|8121|john|password|3 1 1 0 1 0 0 1\r|CB @@ -24,7 +24,7 @@ Bells=1 StripLF=1 AlertBeep=1 ConnectBeep=1 -CurrentHost=5 +CurrentHost=3 2 3 2 0 0 0 0 0 0 YAPPPath= listenPort=8015 listenEnable=1 @@ -82,7 +82,6 @@ VARA2750=0 VARAHF=1 VARAFM=0 VARASAT=0 -TabType=1 3 1 1 1 1 1 2 2 0 monBackground=@Variant(\0\0\0\x43\x1\xff\xff\xff\xff\xff\xff\xff\xff\0\0) monRxText=@Variant(\0\0\0\x43\x1\xff\xff\0\0\0\0\xff\xff\0\0) monTxText=@Variant(\0\0\0\x43\x1\xff\xff\xff\xff\0\0\0\0\0\0) @@ -98,9 +97,11 @@ singlemodeFormat=3 FontFamily=Courier PointSize=10 Weight=50 -Sessions="1|1, 17, 40, 205, 625, 990|" +Sessions="4|1, 3, 57, 19, 633, 795|2, 2, 18, 42, 605, 833|1, 3, 20, 410, 611, 1201|3, 2, 32, 598, 623, 1389|" VARAInit="P2P SESSION,WINLINK SESSION" MaxRXSize=100000 +AutoConnect=1 1 1 0 0 0 0 0 0 0 +TabType=1 3 3 1 1 1 1 2 2 0 [AX25_A] Retries=10 diff --git a/QtTermTCP.vcxproj.user b/QtTermTCP.vcxproj.user index 235118b..0ccc4d8 100644 --- a/QtTermTCP.vcxproj.user +++ b/QtTermTCP.vcxproj.user @@ -8,15 +8,15 @@ 2022-05-19T07:28:58.9302359Z - 2023-07-16T07:55:42.3394911Z + 2023-08-17T19:39:18.4928536Z - 2023-07-16T07:55:42.4544961Z + 2023-08-17T19:39:18.5988572Z - 2023-07-16T07:55:41.8664763Z + 2023-08-17T19:39:18.2968480Z - 2023-07-16T07:55:42.1214867Z + 2023-08-17T19:39:18.3758517Z \ No newline at end of file diff --git a/release/moc_predefs.h b/release/moc_predefs.h new file mode 100644 index 0000000..4c9c0c7 --- /dev/null +++ b/release/moc_predefs.h @@ -0,0 +1,11 @@ +#define _MSC_EXTENSIONS +#define _INTEGRAL_MAX_BITS 64 +#define _MSC_VER 1916 +#define _MSC_FULL_VER 191627043 +#define _MSC_BUILD 0 +#define _WIN32 +#define _M_IX86 600 +#define _M_IX86_FP 2 +#define _CPPRTTI +#define _MT +#define _DLL