summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Rettberg2017-06-23 16:51:40 +0200
committerSimon Rettberg2017-06-23 16:51:40 +0200
commit59ee61ad830149b348221231708e05c2acba8467 (patch)
tree668d138234a3c828e2870dfe39ff4250659de962
parent[server] Only block screen saver from running when first client connects (diff)
downloadpvs2-59ee61ad830149b348221231708e05c2acba8467.tar.gz
pvs2-59ee61ad830149b348221231708e05c2acba8467.tar.xz
pvs2-59ee61ad830149b348221231708e05c2acba8467.zip
[client] Delay showBar by 750ms
Implements #3164
-rw-r--r--src/client/toolbar/toolbar.cpp65
-rw-r--r--src/client/toolbar/toolbar.h3
2 files changed, 45 insertions, 23 deletions
diff --git a/src/client/toolbar/toolbar.cpp b/src/client/toolbar/toolbar.cpp
index 19c44cc..47f246f 100644
--- a/src/client/toolbar/toolbar.cpp
+++ b/src/client/toolbar/toolbar.cpp
@@ -29,7 +29,7 @@
* widget is deleted when its parent is deleted.
*/
Toolbar::Toolbar(const QByteArray sessionName, QWidget *parent)
- : QWidget(parent), _hideTimer(this), _blinkTimer(this), _beWatchedEye(":eye")
+ : QWidget(parent), _showTimer(this), _hideTimer(this), _blinkTimer(this), _beWatchedEye(":eye")
{
qDebug() << "sessionName - constructor";
init();
@@ -48,7 +48,7 @@ Toolbar::Toolbar(const QByteArray sessionName, QWidget *parent)
* widget is deleted when its parent is deleted.
*/
Toolbar::Toolbar(const bool autoConnect, QWidget *parent)
- : QWidget(parent), _hideTimer(this), _blinkTimer(this), _beWatchedEye(":eye")
+ : QWidget(parent), _showTimer(this), _hideTimer(this), _blinkTimer(this), _beWatchedEye(":eye")
{
qDebug() << "auto - constructor!";
init();
@@ -74,7 +74,7 @@ Toolbar::Toolbar(const bool autoConnect, QWidget *parent)
* widget is deleted when its parent is deleted.
*/
Toolbar::Toolbar(QWidget *parent)
- : QWidget(parent), _hideTimer(this), _blinkTimer(this), _beWatchedEye(":eye")
+ : QWidget(parent), _showTimer(this), _hideTimer(this), _blinkTimer(this), _beWatchedEye(":eye")
{
init();
}
@@ -97,7 +97,6 @@ void Toolbar::init()
setAttribute(Qt::WA_AlwaysShowToolTips);
setAttribute(Qt::WA_QuitOnClose, false);
setAttribute(Qt::WA_DeleteOnClose, false);
-
/* Create the VNC Window */
_vnc = new VncWindow(NULL);
@@ -136,10 +135,14 @@ void Toolbar::init()
const QRect primaryScreen = desktop.screenGeometry();
move(primaryScreen.left() + (primaryScreen.width() - this->width()) / 2 , primaryScreen.top());
- /* Setup hide timer */
+ /* Setup show & hide timer */
+ _showTimer.setInterval(750);
+ _showTimer.setSingleShot(true);
+ connect(&_showTimer, SIGNAL(timeout()), this, SLOT(showBar()));
_hideTimer.setInterval(500);
_hideTimer.setSingleShot(true);
connect(&_hideTimer, SIGNAL(timeout()), this, SLOT(hideBar()));
+
setVisible(true);
activateWindow();
_hideTimer.start(); // initially show PVS and hide later
@@ -178,7 +181,7 @@ void Toolbar::initMenu()
_acnQuit->setVisible(allow);
// Connect the signals
- connect(_menu, SIGNAL(aboutToHide()), this, SLOT(hideBar()));
+ connect(_menu, SIGNAL(aboutToHide()), this, SLOT(delayedHideBar()));
connect(_acnConnect, SIGNAL(triggered()), clientApp->connectWindow(), SLOT(doShow()));
connect(_acnDisconnect, SIGNAL(triggered()), clientApp->connectWindow(), SLOT(DoDisconnect()));
connect(_acnInformation, SIGNAL(triggered()), this, SLOT(showInformationDialog()));
@@ -226,7 +229,7 @@ Toolbar::~Toolbar()
*/
void Toolbar::leaveEvent(QEvent* e)
{
- _hideTimer.start();
+ delayedHideBar();
QWidget::leaveEvent(e);
}
@@ -239,8 +242,7 @@ void Toolbar::leaveEvent(QEvent* e)
*/
void Toolbar::enterEvent(QEvent* e)
{
- _hideTimer.stop();
- showBar();
+ delayedShowBar();
QWidget::enterEvent(e);
}
@@ -352,7 +354,7 @@ void Toolbar::onVncServerIsRunning(int port)
_ui->icon_cam->setPixmap(QPixmap());
_ui->lblStatus->setStyleSheet("color:green");
_ui->lblStatus->setText(tr("Online"));
- hideBar();
+ delayedHideBar();
}
}
@@ -372,7 +374,7 @@ void Toolbar::onDisconnected(ServerConnection* connection)
this->_acnDisconnect->setEnabled(false);
_ui->btnAttention->setVisible(false);
onBtnAttention();
- _hideTimer.start();
+ delayedHideBar();
QTimer::singleShot(1, this, SLOT(updateButtonVisibility()));
}
@@ -417,24 +419,50 @@ void Toolbar::onServerAttentionChanged(const bool on)
if (on) {
showBar();
} else {
- hideBar();
+ delayedHideBar();
}
}
-/***************************************************************************//**
+/**
* This slot hides the toolbar. Places the toolbar hidden behind the edge of the
* screen just showing 2 pixels.
*/
void Toolbar::hideBar()
{
// Don't hide window if any menu is open or VNC Server is running from this client.
- if (_menu->isVisible() || _ui->btnAttention->isChecked() || VncServer::instance()->isVncServerRunning())
+ if (_menu->isVisible() || _ui->btnAttention->isChecked() || VncServer::instance()->isVncServerRunning() || this->underMouse())
return;
const QDesktopWidget desktop;
const QRect primaryScreen = desktop.screenGeometry();
move(x(), primaryScreen.top() + 2 - height());
}
+void Toolbar::delayedHideBar()
+{
+ _showTimer.stop();
+ if (!_hideTimer.isActive()) {
+ _hideTimer.start();
+ }
+}
+
+/**
+ * This slot shows the toolbar. Used after a hideBar().
+ */
+void Toolbar::showBar()
+{
+ const QDesktopWidget desktop;
+ const QRect primaryScreen = desktop.screenGeometry();
+ move(x(), primaryScreen.top());
+}
+
+void Toolbar::delayedShowBar()
+{
+ _hideTimer.stop();
+ if (!_showTimer.isActive()) {
+ _showTimer.start();
+ }
+}
+
/***************************************************************************//**
* @brief Toolbar::showAboutDialog
*/
@@ -459,15 +487,6 @@ void Toolbar::showInformationDialog()
InformationDialog* d = new InformationDialog();
d->exec();
}
-/***************************************************************************//**
- * This slot shows the toolbar. Used after a hideBar().
- */
-void Toolbar::showBar()
-{
- const QDesktopWidget desktop;
- const QRect primaryScreen = desktop.screenGeometry();
- move(x(), primaryScreen.top());
-}
void Toolbar::onBtnAttention()
{
diff --git a/src/client/toolbar/toolbar.h b/src/client/toolbar/toolbar.h
index 1804d0a..47f385c 100644
--- a/src/client/toolbar/toolbar.h
+++ b/src/client/toolbar/toolbar.h
@@ -45,6 +45,7 @@ private:
QAction *_acnInformation;
QAction *_acnAbout;
QAction *_acnQuit;
+ QTimer _showTimer;
QTimer _hideTimer;
QTimer _blinkTimer;
VncWindow *_vnc;
@@ -74,6 +75,8 @@ private slots:
void cameraBlink();
void showBar();
void hideBar();
+ void delayedShowBar();
+ void delayedHideBar();
void showAboutDialog();
void showInformationDialog();
void enableLockBtn();