diff --git a/CHANGELOG.md b/CHANGELOG.md index b2fc1ba0..d112575c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,12 +7,16 @@ en-US: - Add Python scripting engine for scripting feature [#31](https://github.com/QQxiaoming/quardCRT/pull/31) - Add the feature of selecting end-of-line sequence - Add logging information to the status bar +- Add emphasized color border to the activated session in split screen mode +- Fix the issue that clicking the new tab button in split screen mode may not create the session correctly or be located under the wrong tab group zh-CN: - 为脚本功能添加Python脚本引擎 [#31](https://github.com/QQxiaoming/quardCRT/pull/31) - 增加选择行尾序列功能 - 增加状态栏日志信息 +- 分屏模式下激活的会话增加强调色边框 +- 修复分屏模式下某些情况点击新标签按钮会话未正确创建或位于错误的标签页组下 ## [[V0.4.8](https://github.com/QQxiaoming/quardCRT/releases/tag/V0.4.8)] - 2024-07-26 diff --git a/docs/changelog.md b/docs/changelog.md index bc1c816c..fd165ed8 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -7,6 +7,8 @@ - Add Python scripting engine for scripting feature [#31](https://github.com/QQxiaoming/quardCRT/pull/31) - Add the feature of selecting end-of-line sequence - Add logging information to the status bar +- Add emphasized color border to the activated session in split screen mode +- Fix the issue that clicking the new tab button in split screen mode may not create the session correctly or be located under the wrong tab group ## [[V0.4.8](https://github.com/QQxiaoming/quardCRT/releases/tag/V0.4.8)] - 2024-07-26 diff --git a/src/mainwidgetgroup.cpp b/src/mainwidgetgroup.cpp index bc926a3d..2becda0d 100644 --- a/src/mainwidgetgroup.cpp +++ b/src/mainwidgetgroup.cpp @@ -18,14 +18,15 @@ * along with this program; if not, see . */ #include +#include #include "mainwidgetgroup.h" #include "sessionswindow.h" MainWidgetGroup::MainWidgetGroup(Type type, QWidget *parent) - : QObject(parent), m_type(type) + : QWidget(parent), m_type(type) { - splitter = new QSplitter(Qt::Vertical, parent); + splitter = new QSplitter(Qt::Vertical,parent); sessionTab = new SessionTab(parent); QWidget *widget = new QWidget(parent); widget->setLayout(new QVBoxLayout(widget)); @@ -39,9 +40,31 @@ MainWidgetGroup::MainWidgetGroup(Type type, QWidget *parent) splitter->setCollapsible(0,false); splitter->setCollapsible(1,true); splitter->setSizes(QList() << 1 << 0); + + QVBoxLayout *layout = new QVBoxLayout(this); + setLayout(layout); + layout->setContentsMargins(2,2,2,2); + layout->setSpacing(0); + layout->addWidget(splitter); } MainWidgetGroup::~MainWidgetGroup() { } +void MainWidgetGroup::setActive(bool enable) { + hasActive = enable; + update(); +} + +void MainWidgetGroup::paintEvent(QPaintEvent *event) { + if (hasActive) { + QPalette palette; + QPainter painter(this); + painter.setPen(palette.color(QPalette::Active, QPalette::Highlight)); + QRect rect = contentsRect(); + rect.adjust(1, 1, -1, -1); + painter.drawRect(rect); + } + QWidget::paintEvent(event); +} diff --git a/src/mainwidgetgroup.h b/src/mainwidgetgroup.h index 09da2616..e0d59c6a 100644 --- a/src/mainwidgetgroup.h +++ b/src/mainwidgetgroup.h @@ -20,12 +20,12 @@ #ifndef MAINWIDGETGROUP_H #define MAINWIDGETGROUP_H -#include #include +#include #include "commandwidget.h" #include "sessiontab.h" -class MainWidgetGroup: public QObject +class MainWidgetGroup: public QWidget { Q_OBJECT public: @@ -35,14 +35,18 @@ class MainWidgetGroup: public QObject }; MainWidgetGroup(Type type, QWidget *parent = nullptr); ~MainWidgetGroup(); - + void setActive(bool enable); Type type() const { return m_type; } +protected: + void paintEvent(QPaintEvent *event) override; + public: QSplitter *splitter; SessionTab *sessionTab; CommandWidget *commandWidget; Type m_type; + bool hasActive = false; }; #endif // MAINWIDGETGROUP_H diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 8bc45627..520c7c66 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -112,30 +112,30 @@ CentralWidget::CentralWidget(QString dir, StartupUIMode mode, QLocale lang, bool splitterV11 = new QSplitter(Qt::Horizontal,this); splitterV11->setHandleWidth(1); mainWidgetGroupList.append(new MainWidgetGroup(MainWidgetGroup::EMBEDDED,this)); - splitterV1->addWidget(mainWidgetGroupList.at(0)->splitter); + splitterV1->addWidget(mainWidgetGroupList.at(0)); mainWidgetGroupList.append(new MainWidgetGroup(MainWidgetGroup::EMBEDDED,this)); - splitterV2->addWidget(mainWidgetGroupList.at(1)->splitter); + splitterV2->addWidget(mainWidgetGroupList.at(1)); mainWidgetGroupList.append(new MainWidgetGroup(MainWidgetGroup::EMBEDDED,this)); - splitterV1->addWidget(mainWidgetGroupList.at(2)->splitter); + splitterV1->addWidget(mainWidgetGroupList.at(2)); mainWidgetGroupList.append(new MainWidgetGroup(MainWidgetGroup::EMBEDDED,this)); - splitterV2->addWidget(mainWidgetGroupList.at(3)->splitter); + splitterV2->addWidget(mainWidgetGroupList.at(3)); mainWidgetGroupList.append(new MainWidgetGroup(MainWidgetGroup::EMBEDDED,this)); - splitterV11->addWidget(mainWidgetGroupList.at(4)->splitter); + splitterV11->addWidget(mainWidgetGroupList.at(4)); mainWidgetGroupList.append(new MainWidgetGroup(MainWidgetGroup::EMBEDDED,this)); - splitterV11->addWidget(mainWidgetGroupList.at(5)->splitter); + splitterV11->addWidget(mainWidgetGroupList.at(5)); mainWidgetGroupList.append(new MainWidgetGroup(MainWidgetGroup::EMBEDDED,this)); - splitter->addWidget(mainWidgetGroupList.at(6)->splitter); + splitter->addWidget(mainWidgetGroupList.at(6)); splitterV1->addWidget(splitterV11); splitterV1->setVisible(true); splitterV2->setVisible(false); splitterV11->setVisible(false); - mainWidgetGroupList.at(0)->splitter->setVisible(true); - mainWidgetGroupList.at(1)->splitter->setVisible(false); - mainWidgetGroupList.at(2)->splitter->setVisible(false); - mainWidgetGroupList.at(3)->splitter->setVisible(false); - mainWidgetGroupList.at(4)->splitter->setVisible(false); - mainWidgetGroupList.at(5)->splitter->setVisible(false); - mainWidgetGroupList.at(6)->splitter->setVisible(false); + mainWidgetGroupList.at(0)->setVisible(true); + mainWidgetGroupList.at(1)->setVisible(false); + mainWidgetGroupList.at(2)->setVisible(false); + mainWidgetGroupList.at(3)->setVisible(false); + mainWidgetGroupList.at(4)->setVisible(false); + mainWidgetGroupList.at(5)->setVisible(false); + mainWidgetGroupList.at(6)->setVisible(false); currentLayout = 0; notifictionWidget = new NotifictionWidget(this); @@ -313,6 +313,19 @@ CentralWidget::CentralWidget(QString dir, StartupUIMode mode, QLocale lang, bool }); foreach(MainWidgetGroup *mainWidgetGroup, mainWidgetGroupList) { connect(mainWidgetGroup->sessionTab,&FancyTabWidget::tabAddRequested,this,[=](){ + QWidget *widget = findCurrentFocusWidget(); + if(widget != nullptr) { + if(mainWidgetGroup->sessionTab->indexOf(widget)<0) { + int index = mainWidgetGroup->sessionTab->count(); + QWidget *widget = mainWidgetGroup->sessionTab->widget(index); + widget->setFocus(); + } + } else { + int index = mainWidgetGroup->sessionTab->count(); + QWidget *widget = mainWidgetGroup->sessionTab->widget(index); + widget->setFocus(); + } + int mode = globalOptionsWindow->getNewTabMode(); switch(mode) { case 0: @@ -323,7 +336,7 @@ CentralWidget::CentralWidget(QString dir, StartupUIMode mode, QLocale lang, bool cloneSessionAction->trigger(); break; case 2: - QWidget *widget = findCurrentFocusWidget(); + widget = findCurrentFocusWidget(); if(widget != nullptr) { SessionsWindow *sessionsWindow = widget->property("session").value(); if(SessionsWindow::LocalShell == sessionsWindow->getSessionType()) { @@ -341,7 +354,11 @@ CentralWidget::CentralWidget(QString dir, StartupUIMode mode, QLocale lang, bool connect(mainWidgetGroup->sessionTab,&SessionTab::currentChanged,this,[=](int index){ int currentTabNum = 0; foreach(MainWidgetGroup *group, mainWidgetGroupList) { - currentTabNum += group->sessionTab->count(); + int num = group->sessionTab->count(); + if(num == 0) { + group->setActive(false); + } + currentTabNum += num; } setSessionClassActionEnable(currentTabNum != 0); if(index > 0) { @@ -1296,7 +1313,7 @@ void CentralWidget::floatingWindow(MainWidgetGroup *g, int index) { mainWidgetGroupList.append(group); int newGroup = mainWidgetGroupList.count()-1; moveToAnotherTab(mainWidgetGroupList.indexOf(g),newGroup,index); - dialog->layout()->addWidget(group->splitter); + dialog->layout()->addWidget(group); group->sessionTab->setTabBarHidden(true); group->sessionTab->setAddTabButtonHidden(true); dialog->setWindowTitle(group->sessionTab->tabTitle(1)); @@ -1475,7 +1492,7 @@ MainWidgetGroup* CentralWidget::findCurrentFocusGroup(bool forceFind) { if(mainWidgetGroup->type() != MainWidgetGroup::EMBEDDED) { continue; } - if(mainWidgetGroup->splitter->size().width() == 0) { + if(mainWidgetGroup->size().width() == 0) { continue; } if(mainWidgetGroup->sessionTab->currentWidget()->hasFocus()) { @@ -1486,7 +1503,7 @@ MainWidgetGroup* CentralWidget::findCurrentFocusGroup(bool forceFind) { if(mainWidgetGroup->type() != MainWidgetGroup::EMBEDDED) { continue; } - if(mainWidgetGroup->splitter->size().width() == 0) { + if(mainWidgetGroup->size().width() == 0) { continue; } if(mainWidgetGroup->sessionTab->count() != 0) { @@ -1498,7 +1515,7 @@ MainWidgetGroup* CentralWidget::findCurrentFocusGroup(bool forceFind) { if(mainWidgetGroup->type() != MainWidgetGroup::EMBEDDED) { continue; } - if(mainWidgetGroup->splitter->size().width() != 0) { + if(mainWidgetGroup->size().width() != 0) { return mainWidgetGroup; } } @@ -2896,106 +2913,109 @@ void CentralWidget::menuAndToolBarConnectSignals(void) { splitterV1->setVisible(true); splitterV2->setVisible(false); splitterV11->setVisible(false); - mainWidgetGroupList.at(0)->splitter->setVisible(true); - mainWidgetGroupList.at(1)->splitter->setVisible(false); - mainWidgetGroupList.at(2)->splitter->setVisible(false); - mainWidgetGroupList.at(3)->splitter->setVisible(false); - mainWidgetGroupList.at(4)->splitter->setVisible(false); - mainWidgetGroupList.at(5)->splitter->setVisible(false); - mainWidgetGroupList.at(6)->splitter->setVisible(false); + mainWidgetGroupList.at(0)->setVisible(true); + mainWidgetGroupList.at(1)->setVisible(false); + mainWidgetGroupList.at(2)->setVisible(false); + mainWidgetGroupList.at(3)->setVisible(false); + mainWidgetGroupList.at(4)->setVisible(false); + mainWidgetGroupList.at(5)->setVisible(false); + mainWidgetGroupList.at(6)->setVisible(false); enabledSyncSplitterMoved = false; } else if(action == twoColumnsLayoutAction) { currentLayout = 1; splitterV1->setVisible(true); splitterV2->setVisible(true); splitterV11->setVisible(false); - mainWidgetGroupList.at(0)->splitter->setVisible(true); - mainWidgetGroupList.at(1)->splitter->setVisible(true); - mainWidgetGroupList.at(2)->splitter->setVisible(false); - mainWidgetGroupList.at(3)->splitter->setVisible(false); - mainWidgetGroupList.at(4)->splitter->setVisible(false); - mainWidgetGroupList.at(5)->splitter->setVisible(false); - mainWidgetGroupList.at(6)->splitter->setVisible(false); + mainWidgetGroupList.at(0)->setVisible(true); + mainWidgetGroupList.at(1)->setVisible(true); + mainWidgetGroupList.at(2)->setVisible(false); + mainWidgetGroupList.at(3)->setVisible(false); + mainWidgetGroupList.at(4)->setVisible(false); + mainWidgetGroupList.at(5)->setVisible(false); + mainWidgetGroupList.at(6)->setVisible(false); enabledSyncSplitterMoved = false; } else if(action == threeColumnsLayoutAction) { currentLayout = 2; splitterV1->setVisible(true); splitterV2->setVisible(true); splitterV11->setVisible(false); - mainWidgetGroupList.at(0)->splitter->setVisible(true); - mainWidgetGroupList.at(1)->splitter->setVisible(true); - mainWidgetGroupList.at(2)->splitter->setVisible(false); - mainWidgetGroupList.at(3)->splitter->setVisible(false); - mainWidgetGroupList.at(4)->splitter->setVisible(false); - mainWidgetGroupList.at(5)->splitter->setVisible(false); - mainWidgetGroupList.at(6)->splitter->setVisible(true); + mainWidgetGroupList.at(0)->setVisible(true); + mainWidgetGroupList.at(1)->setVisible(true); + mainWidgetGroupList.at(2)->setVisible(false); + mainWidgetGroupList.at(3)->setVisible(false); + mainWidgetGroupList.at(4)->setVisible(false); + mainWidgetGroupList.at(5)->setVisible(false); + mainWidgetGroupList.at(6)->setVisible(true); enabledSyncSplitterMoved = false; } else if(action == twoRowsLayoutAction) { currentLayout = 3; splitterV1->setVisible(true); splitterV2->setVisible(false); splitterV11->setVisible(false); - mainWidgetGroupList.at(0)->splitter->setVisible(true); - mainWidgetGroupList.at(1)->splitter->setVisible(false); - mainWidgetGroupList.at(2)->splitter->setVisible(true); - mainWidgetGroupList.at(3)->splitter->setVisible(false); - mainWidgetGroupList.at(4)->splitter->setVisible(false); - mainWidgetGroupList.at(5)->splitter->setVisible(false); - mainWidgetGroupList.at(6)->splitter->setVisible(false); + mainWidgetGroupList.at(0)->setVisible(true); + mainWidgetGroupList.at(1)->setVisible(false); + mainWidgetGroupList.at(2)->setVisible(true); + mainWidgetGroupList.at(3)->setVisible(false); + mainWidgetGroupList.at(4)->setVisible(false); + mainWidgetGroupList.at(5)->setVisible(false); + mainWidgetGroupList.at(6)->setVisible(false); enabledSyncSplitterMoved = false; } else if(action == threeRowsLayoutAction) { currentLayout = 4; splitterV1->setVisible(true); splitterV2->setVisible(false); splitterV11->setVisible(true); - mainWidgetGroupList.at(0)->splitter->setVisible(true); - mainWidgetGroupList.at(1)->splitter->setVisible(false); - mainWidgetGroupList.at(2)->splitter->setVisible(true); - mainWidgetGroupList.at(3)->splitter->setVisible(false); - mainWidgetGroupList.at(4)->splitter->setVisible(true); - mainWidgetGroupList.at(5)->splitter->setVisible(false); - mainWidgetGroupList.at(6)->splitter->setVisible(false); + mainWidgetGroupList.at(0)->setVisible(true); + mainWidgetGroupList.at(1)->setVisible(false); + mainWidgetGroupList.at(2)->setVisible(true); + mainWidgetGroupList.at(3)->setVisible(false); + mainWidgetGroupList.at(4)->setVisible(true); + mainWidgetGroupList.at(5)->setVisible(false); + mainWidgetGroupList.at(6)->setVisible(false); enabledSyncSplitterMoved = false; } else if(action == gridLayoutAction) { currentLayout = 5; splitterV1->setVisible(true); splitterV2->setVisible(true); splitterV11->setVisible(false); - mainWidgetGroupList.at(0)->splitter->setVisible(true); - mainWidgetGroupList.at(1)->splitter->setVisible(true); - mainWidgetGroupList.at(2)->splitter->setVisible(true); - mainWidgetGroupList.at(3)->splitter->setVisible(true); - mainWidgetGroupList.at(4)->splitter->setVisible(false); - mainWidgetGroupList.at(5)->splitter->setVisible(false); - mainWidgetGroupList.at(6)->splitter->setVisible(false); + mainWidgetGroupList.at(0)->setVisible(true); + mainWidgetGroupList.at(1)->setVisible(true); + mainWidgetGroupList.at(2)->setVisible(true); + mainWidgetGroupList.at(3)->setVisible(true); + mainWidgetGroupList.at(4)->setVisible(false); + mainWidgetGroupList.at(5)->setVisible(false); + mainWidgetGroupList.at(6)->setVisible(false); enabledSyncSplitterMoved = true; } else if(action == twoRowsRightLayoutAction) { currentLayout = 6; splitterV1->setVisible(true); splitterV2->setVisible(true); splitterV11->setVisible(false); - mainWidgetGroupList.at(0)->splitter->setVisible(true); - mainWidgetGroupList.at(1)->splitter->setVisible(true); - mainWidgetGroupList.at(2)->splitter->setVisible(false); - mainWidgetGroupList.at(3)->splitter->setVisible(true); - mainWidgetGroupList.at(4)->splitter->setVisible(false); - mainWidgetGroupList.at(5)->splitter->setVisible(false); - mainWidgetGroupList.at(6)->splitter->setVisible(false); + mainWidgetGroupList.at(0)->setVisible(true); + mainWidgetGroupList.at(1)->setVisible(true); + mainWidgetGroupList.at(2)->setVisible(false); + mainWidgetGroupList.at(3)->setVisible(true); + mainWidgetGroupList.at(4)->setVisible(false); + mainWidgetGroupList.at(5)->setVisible(false); + mainWidgetGroupList.at(6)->setVisible(false); enabledSyncSplitterMoved = false; } else if(action == twoColumnsBottomLayoutAction) { currentLayout = 7; splitterV1->setVisible(true); splitterV2->setVisible(false); splitterV11->setVisible(true); - mainWidgetGroupList.at(0)->splitter->setVisible(true); - mainWidgetGroupList.at(1)->splitter->setVisible(false); - mainWidgetGroupList.at(2)->splitter->setVisible(false); - mainWidgetGroupList.at(3)->splitter->setVisible(false); - mainWidgetGroupList.at(4)->splitter->setVisible(true); - mainWidgetGroupList.at(5)->splitter->setVisible(true); - mainWidgetGroupList.at(6)->splitter->setVisible(false); + mainWidgetGroupList.at(0)->setVisible(true); + mainWidgetGroupList.at(1)->setVisible(false); + mainWidgetGroupList.at(2)->setVisible(false); + mainWidgetGroupList.at(3)->setVisible(false); + mainWidgetGroupList.at(4)->setVisible(true); + mainWidgetGroupList.at(5)->setVisible(true); + mainWidgetGroupList.at(6)->setVisible(false); enabledSyncSplitterMoved = false; } + foreach(MainWidgetGroup *group, mainWidgetGroupList) { + group->setActive(false); + } movetabWhenLayoutChange(oldLayout,currentLayout); }); connect(flipLayoutAction,&QAction::triggered,this,[=](){ @@ -3607,6 +3627,22 @@ void CentralWidget::setGlobalOptions(SessionsWindow *window) { connect(window,&SessionsWindow::requestReconnect,this,[=](void){ reconnectSession(window); }); + connect(window,&SessionsWindow::termGetFocus,this,[=](void){ + foreach(MainWidgetGroup *group, mainWidgetGroupList) { + if(group->sessionTab->indexOf(window->getMainWidget())>=0) { + group->setActive(true && (currentLayout!=0)); + break; + } + } + }); + connect(window,&SessionsWindow::termLostFocus,this,[=](void){ + foreach(MainWidgetGroup *group, mainWidgetGroupList) { + if(group->sessionTab->indexOf(window->getMainWidget())>=0) { + group->setActive(false); + break; + } + } + }); } void CentralWidget::restoreSessionToSessionManager(void) diff --git a/src/sessionswindow/sessionswindow.cpp b/src/sessionswindow/sessionswindow.cpp index 2d93e9ab..81c1a562 100644 --- a/src/sessionswindow/sessionswindow.cpp +++ b/src/sessionswindow/sessionswindow.cpp @@ -442,6 +442,8 @@ SessionsWindow::SessionsWindow(SessionType tp, QWidget *parent) if(type != VNC) { connect(term, &QTermWidget::titleChanged, this, &SessionsWindow::titleChanged); + connect(term, &QTermWidget::termGetFocus, this, &SessionsWindow::termGetFocus); + connect(term, &QTermWidget::termLostFocus, this, &SessionsWindow::termLostFocus); connect(term, &QTermWidget::dupDisplayOutput, this, [&](const char *data, int size){ saveLog(data, size); writeReceiveASCIIFile(data, size); @@ -612,7 +614,11 @@ SessionsWindow::~SessionsWindow() { delete telnet; } if(serialPort) { - if(serialPort->isOpen()) serialPort->close(); + if (serialPort->isOpen()) { + serialPort->clear(); + serialPort->waitForBytesWritten(1000); + serialPort->close(); + } delete serialPort; delete serialMonitor; } diff --git a/src/sessionswindow/sessionswindow.h b/src/sessionswindow/sessionswindow.h index c80d6f0e..d54aa69f 100644 --- a/src/sessionswindow/sessionswindow.h +++ b/src/sessionswindow/sessionswindow.h @@ -409,7 +409,9 @@ class SessionsWindow : public QObject void waitForStringFinished(const QString &str, int matchIndex); void broadCastSendData(const QByteArray &data); void requestReconnect(void); - + void termGetFocus(); + void termLostFocus(); + private: int saveLog(const char *data, int size); int saveRawLog(const char *data, int size);