From e4f0a0c307e7b3eb1ec820777a1d15e38826d8b0 Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Wed, 7 Dec 2016 13:12:27 -0500 Subject: Cleanup some more of the terminal functionality: 1) Auto-hide the window when it loses focus 2) Give the terminal widget focus when it is clicked on 3) When starting the PTY do one interaction with it programmatically to ensure it is *really* ready before the user starts using it. --- src-qt5/desktop-utils/lumina-terminal/TermWindow.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src-qt5/desktop-utils/lumina-terminal/TermWindow.cpp') diff --git a/src-qt5/desktop-utils/lumina-terminal/TermWindow.cpp b/src-qt5/desktop-utils/lumina-terminal/TermWindow.cpp index b400ac6e..783fc482 100644 --- a/src-qt5/desktop-utils/lumina-terminal/TermWindow.cpp +++ b/src-qt5/desktop-utils/lumina-terminal/TermWindow.cpp @@ -57,7 +57,7 @@ TermWindow::TermWindow(QSettings *set) : QWidget(0, Qt::Window | Qt::BypassWindo connect(closeS, SIGNAL(activated()), this, SLOT(CloseWindow()) ); connect(prevTabS, SIGNAL(activated()), this, SLOT(Prev_Tab()) ); connect(nextTabS, SIGNAL(activated()), this, SLOT(Next_Tab()) ); - + connect(QApplication::instance(), SIGNAL(applicationStateChanged(Qt::ApplicationState)), this, SLOT(activeStatusChanged()) ); //Now set the defaults screennum = 0; //default value setTopOfScreen(true); //default value @@ -282,6 +282,14 @@ void TermWindow::AnimFinished(){ animRunning = -1; //done } +void TermWindow::activeStatusChanged(){ + //Note: Qt 5.6.1 returns the opposite value for isActiveWindow() (12/7/16) + //qDebug() << "active status changed:" << this->isActiveWindow() << (this == QApplication::activeWindow()); + if(animRunning>=0){ return; } //ignore this event - already changing + if(!this->isActiveWindow() && !this->isVisible()){ ShowWindow(); } + else if(this->isActiveWindow() && this->isVisible()){ HideWindow(); } +} + // =================== // PROTECTED // =================== -- cgit From 0f18a11a64a6a112b5bf9e612c086da882f3c65f Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Wed, 7 Dec 2016 13:27:30 -0500 Subject: Disable the auto-hide on activation event - something weird is going on (probably due to the special flags on the terminal window). --- src-qt5/desktop-utils/lumina-terminal/TermWindow.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src-qt5/desktop-utils/lumina-terminal/TermWindow.cpp') diff --git a/src-qt5/desktop-utils/lumina-terminal/TermWindow.cpp b/src-qt5/desktop-utils/lumina-terminal/TermWindow.cpp index 783fc482..8ff3ecd1 100644 --- a/src-qt5/desktop-utils/lumina-terminal/TermWindow.cpp +++ b/src-qt5/desktop-utils/lumina-terminal/TermWindow.cpp @@ -286,8 +286,9 @@ void TermWindow::activeStatusChanged(){ //Note: Qt 5.6.1 returns the opposite value for isActiveWindow() (12/7/16) //qDebug() << "active status changed:" << this->isActiveWindow() << (this == QApplication::activeWindow()); if(animRunning>=0){ return; } //ignore this event - already changing - if(!this->isActiveWindow() && !this->isVisible()){ ShowWindow(); } - else if(this->isActiveWindow() && this->isVisible()){ HideWindow(); } + //if(!this->isActiveWindow() && !this->isVisible()){ ShowWindow(); } + //else if(this->isActiveWindow() this->isVisible()){ HideWindow(); } + //ReShowWindow(); } // =================== -- cgit From 0d3db8715c8668a0d5297ff8dc695ffd6dc3df62 Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Thu, 8 Dec 2016 09:32:29 -0500 Subject: Fix up the auto-hide functionality within the terminal when the term window loses focus. --- src-qt5/desktop-utils/lumina-terminal/TermWindow.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'src-qt5/desktop-utils/lumina-terminal/TermWindow.cpp') diff --git a/src-qt5/desktop-utils/lumina-terminal/TermWindow.cpp b/src-qt5/desktop-utils/lumina-terminal/TermWindow.cpp index 8ff3ecd1..15cfe047 100644 --- a/src-qt5/desktop-utils/lumina-terminal/TermWindow.cpp +++ b/src-qt5/desktop-utils/lumina-terminal/TermWindow.cpp @@ -36,6 +36,11 @@ TermWindow::TermWindow(QSettings *set) : QWidget(0, Qt::Window | Qt::BypassWindo ANIM = new QPropertyAnimation(this, "geometry", this); ANIM->setDuration(300); //1/3 second animation connect(ANIM, SIGNAL(finished()), this, SLOT(AnimFinished()) ); + activeTimer = new QTimer(this); + activeTimer->setInterval(50); + activeTimer->setSingleShot(true); + connect(activeTimer, SIGNAL(timeout()), this, SLOT(activeStatusChanged()) ); + connect(QApplication::instance(), SIGNAL(applicationStateChanged(Qt::ApplicationState)), activeTimer, SLOT(start()) ); //Create the keyboard shortcuts //hideS = new QShortcut(QKeySequence(Qt::Key_Escape),this); closeS = new QShortcut(QKeySequence(Qt::CTRL | Qt::Key_Q),this); @@ -57,7 +62,6 @@ TermWindow::TermWindow(QSettings *set) : QWidget(0, Qt::Window | Qt::BypassWindo connect(closeS, SIGNAL(activated()), this, SLOT(CloseWindow()) ); connect(prevTabS, SIGNAL(activated()), this, SLOT(Prev_Tab()) ); connect(nextTabS, SIGNAL(activated()), this, SLOT(Next_Tab()) ); - connect(QApplication::instance(), SIGNAL(applicationStateChanged(Qt::ApplicationState)), this, SLOT(activeStatusChanged()) ); //Now set the defaults screennum = 0; //default value setTopOfScreen(true); //default value @@ -283,12 +287,9 @@ void TermWindow::AnimFinished(){ } void TermWindow::activeStatusChanged(){ - //Note: Qt 5.6.1 returns the opposite value for isActiveWindow() (12/7/16) - //qDebug() << "active status changed:" << this->isActiveWindow() << (this == QApplication::activeWindow()); if(animRunning>=0){ return; } //ignore this event - already changing - //if(!this->isActiveWindow() && !this->isVisible()){ ShowWindow(); } - //else if(this->isActiveWindow() this->isVisible()){ HideWindow(); } - //ReShowWindow(); + QWidget *active = QApplication::activeWindow(); + if(active==0 && this->isVisible()){ HideWindow(); } } // =================== -- cgit