diff options
author | Ken Moore <ken@pcbsd.org> | 2015-04-28 10:40:48 -0400 |
---|---|---|
committer | Ken Moore <ken@pcbsd.org> | 2015-04-28 10:40:48 -0400 |
commit | 6d39518bed7e2cb8f135a78b1064855602e17767 (patch) | |
tree | 6f435af9f2c43f8dc035b8ded4c313e65d349784 /lumina-desktop | |
parent | Final fix for the new panel window-reactivation routine: only re-activate the... (diff) | |
download | lumina-6d39518bed7e2cb8f135a78b1064855602e17767.tar.gz lumina-6d39518bed7e2cb8f135a78b1064855602e17767.tar.bz2 lumina-6d39518bed7e2cb8f135a78b1064855602e17767.zip |
Update the system window a bit and how it is used in the session. Now there is only a single system window per session, and it is simply shown/hidden as necesary. This allow it to become visible *much* faster than creating the window from scratch every time.
Diffstat (limited to 'lumina-desktop')
-rw-r--r-- | lumina-desktop/LSession.cpp | 10 | ||||
-rw-r--r-- | lumina-desktop/LSession.h | 2 | ||||
-rw-r--r-- | lumina-desktop/SystemWindow.cpp | 39 | ||||
-rw-r--r-- | lumina-desktop/SystemWindow.h | 2 |
4 files changed, 34 insertions, 19 deletions
diff --git a/lumina-desktop/LSession.cpp b/lumina-desktop/LSession.cpp index 4ad6d1a1..9fbd01bf 100644 --- a/lumina-desktop/LSession.cpp +++ b/lumina-desktop/LSession.cpp @@ -41,6 +41,7 @@ LSession::LSession(int &argc, char ** argv) : QApplication(argc, argv){ //this->setAttribute(Qt::AA_UseHighDpiPixmaps); //allow pixmaps to be scaled up as well as down //this->setStyle( new MenuProxyStyle); //QMenu icon size override SystemTrayID = 0; VisualTrayID = 0; + sysWindow = 0; TrayDmgEvent = 0; TrayDmgError = 0; cleansession = true; @@ -111,6 +112,8 @@ void LSession::setupSession(){ appmenu = new AppMenu(); if(DEBUG){ qDebug() << " - Init SettingsMenu:" << timer->elapsed();} settingsmenu = new SettingsMenu(); + if(DEBUG){ qDebug() << " - Init SystemWindow:" << timer->elapsed();} + sysWindow = new SystemWindow(); //Now setup the system watcher for changes qDebug() << " - Initialize file system watcher"; @@ -495,8 +498,11 @@ QSettings* LSession::sessionSettings(){ } void LSession::systemWindow(){ - SystemWindow win; - win.exec(); + if(sysWindow==0){ sysWindow = new SystemWindow(); } + else{ sysWindow->updateWindow(); } + sysWindow->show(); + /*SystemWindow win; + win.exec();*/ LSession::processEvents(); } diff --git a/lumina-desktop/LSession.h b/lumina-desktop/LSession.h index 5baf72c4..cdd91899 100644 --- a/lumina-desktop/LSession.h +++ b/lumina-desktop/LSession.h @@ -95,9 +95,9 @@ private: //Internal variable for global usage AppMenu *appmenu; SettingsMenu *settingsmenu; + SystemWindow *sysWindow; QTranslator *currTranslator; QMediaPlayer *mediaObj; - //QThread *audioThread; QSettings *sessionsettings; bool cleansession; diff --git a/lumina-desktop/SystemWindow.cpp b/lumina-desktop/SystemWindow.cpp index 02de54b9..18e65291 100644 --- a/lumina-desktop/SystemWindow.cpp +++ b/lumina-desktop/SystemWindow.cpp @@ -27,48 +27,55 @@ SystemWindow::SystemWindow() : QDialog(), ui(new Ui::SystemWindow){ connect(ui->tool_suspend, SIGNAL(clicked()), this, SLOT(sysSuspend()) ); connect(ui->push_cancel, SIGNAL(clicked()), this, SLOT(sysCancel()) ); connect(ui->push_lock, SIGNAL(clicked()), this, SLOT(sysLock()) ); - //Disable the shutdown/restart buttons if necessary - if( !LOS::userHasShutdownAccess() ){ - ui->tool_restart->setEnabled(false); - ui->tool_shutdown->setEnabled(false); - - } - ui->tool_suspend->setVisible(LOS::systemCanSuspend()); - //Center this window on the screen - QPoint center = QApplication::desktop()->screenGeometry(QCursor::pos()).center(); //get the center of the current screen - this->move(center.x() - this->width()/2, center.y() - this->height()/2); - this->show(); + //Disable buttons if necessary + updateWindow(); + ui->tool_suspend->setVisible(LOS::systemCanSuspend()); //does not change with time - just do a single check } SystemWindow::~SystemWindow(){ } +void SystemWindow::updateWindow(){ + //Disable the shutdown/restart buttons if necessary + bool ok = LOS::userHasShutdownAccess(); + ui->tool_restart->setEnabled(ok); + ui->tool_shutdown->setEnabled(ok); + //Center this window on the current screen + QPoint center = QApplication::desktop()->screenGeometry(QCursor::pos()).center(); //get the center of the current screen + this->move(center.x() - this->width()/2, center.y() - this->height()/2); +} + void SystemWindow::sysLogout(){ + this->hide(); + LSession::processEvents(); QTimer::singleShot(0, LSession::handle(), SLOT(StartLogout()) ); - this->close(); } void SystemWindow::sysRestart(){ + this->hide(); + LSession::processEvents(); QTimer::singleShot(0, LSession::handle(), SLOT(StartReboot()) ); - this->close(); } void SystemWindow::sysShutdown(){ + this->hide(); + LSession::processEvents(); QTimer::singleShot(0, LSession::handle(), SLOT(StartShutdown()) ); - this->close(); } void SystemWindow::sysSuspend(){ + this->hide(); + LSession::processEvents(); //Make sure to lock the system first (otherwise anybody can access it again) LUtils::runCmd("xscreensaver-command -lock"); //Now suspend the system LOS::systemSuspend(); - this->close(); } void SystemWindow::sysLock(){ + this->hide(); + LSession::processEvents(); qDebug() << "Locking the desktop..."; QProcess::startDetached("xscreensaver-command -lock"); - this->close(); } diff --git a/lumina-desktop/SystemWindow.h b/lumina-desktop/SystemWindow.h index 4b1fab44..bf7a6b94 100644 --- a/lumina-desktop/SystemWindow.h +++ b/lumina-desktop/SystemWindow.h @@ -26,6 +26,8 @@ public: SystemWindow(); ~SystemWindow(); + void updateWindow(); + private: Ui::SystemWindow *ui; |