diff options
author | Ken Moore <moorekou@gmail.com> | 2016-04-25 13:08:12 -0400 |
---|---|---|
committer | Ken Moore <moorekou@gmail.com> | 2016-04-25 13:08:12 -0400 |
commit | ed5ecf7ea7a482b4649e66ecb35fbc60af680684 (patch) | |
tree | acc0fa17d228259e847f55c678db9fb0a9b50f0c /src-qt5/core/lumina-desktop/SystemWindow.cpp | |
parent | Merge branch 'master' of github.com:pcbsd/lumina (diff) | |
download | lumina-ed5ecf7ea7a482b4649e66ecb35fbc60af680684.tar.gz lumina-ed5ecf7ea7a482b4649e66ecb35fbc60af680684.tar.bz2 lumina-ed5ecf7ea7a482b4649e66ecb35fbc60af680684.zip |
Rearrange the Lumina source tree quite a bit:
Now the utilites are arranged by category (core, core-utils, desktop-utils), so all the -utils may be excluded by a package system (or turned into separate packages) as needed.
Diffstat (limited to 'src-qt5/core/lumina-desktop/SystemWindow.cpp')
-rw-r--r-- | src-qt5/core/lumina-desktop/SystemWindow.cpp | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/src-qt5/core/lumina-desktop/SystemWindow.cpp b/src-qt5/core/lumina-desktop/SystemWindow.cpp new file mode 100644 index 00000000..74538404 --- /dev/null +++ b/src-qt5/core/lumina-desktop/SystemWindow.cpp @@ -0,0 +1,84 @@ +#include "SystemWindow.h" +#include "ui_SystemWindow.h" + +#include "LSession.h" +#include <LuminaOS.h> +#include <QPoint> +#include <QCursor> +#include <QDebug> +#include <QProcess> +#include <QDesktopWidget> + +SystemWindow::SystemWindow() : QDialog(), ui(new Ui::SystemWindow){ + ui->setupUi(this); //load the designer file + //Setup the window flags + this->setWindowFlags( Qt::Tool | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint); + //Setup the icons based on the current theme + ui->tool_logout->setIcon( LXDG::findIcon("system-log-out","") ); + ui->tool_restart->setIcon( LXDG::findIcon("system-reboot","") ); + ui->tool_shutdown->setIcon( LXDG::findIcon("system-shutdown","") ); + ui->tool_suspend->setIcon( LXDG::findIcon("system-suspend","") ); + ui->push_cancel->setIcon( LXDG::findIcon("dialog-cancel","") ); + ui->push_lock->setIcon( LXDG::findIcon("system-lock-screen","") ); + //Connect the signals/slots + connect(ui->tool_logout, SIGNAL(clicked()), this, SLOT(sysLogout()) ); + connect(ui->tool_restart, SIGNAL(clicked()), this, SLOT(sysRestart()) ); + connect(ui->tool_shutdown, SIGNAL(clicked()), this, SLOT(sysShutdown()) ); + 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 buttons if necessary + updateWindow(); + ui->tool_suspend->setVisible(LOS::systemCanSuspend()); //does not change with time - just do a single check + connect(QApplication::instance(), SIGNAL(LocaleChanged()), this, SLOT(updateWindow()) ); + connect(QApplication::instance(), SIGNAL(IconThemeChanged()), this, SLOT(updateWindow()) ); +} + +SystemWindow::~SystemWindow(){ + +} + +void SystemWindow::updateWindow(){ + //Disable the shutdown/restart buttons if necessary + ui->retranslateUi(this); + 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()) ); +} + +void SystemWindow::sysRestart(){ + this->hide(); + LSession::processEvents(); + QTimer::singleShot(0, LSession::handle(), SLOT(StartReboot()) ); +} + +void SystemWindow::sysShutdown(){ + this->hide(); + LSession::processEvents(); + QTimer::singleShot(0, LSession::handle(), SLOT(StartShutdown()) ); +} + +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(); +} + +void SystemWindow::sysLock(){ + this->hide(); + LSession::processEvents(); + qDebug() << "Locking the desktop..."; + QProcess::startDetached("xscreensaver-command -lock"); +} |