Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Change "leave"-button in razor-lightdm-greeter to a menu button. Fix #…

  • Loading branch information...
commit 5cce12f31dc0267095174371dc8d607a603ae8f1 1 parent c1e73bc
@surlykke surlykke authored
View
22 libraries/razorqt/powermanager.cpp
@@ -77,8 +77,9 @@ class MessageBox: public QMessageBox
}
};
-PowerManager::PowerManager(QObject * parent)
- : QObject(parent)
+PowerManager::PowerManager(QObject * parent, bool skipWarning)
+ : QObject(parent),
+ m_skipWarning(skipWarning)
{
libTranslate("librazorqt");
m_power = new RazorPower(this);
@@ -140,8 +141,9 @@ QList<QAction*> PowerManager::availableActions()
void PowerManager::suspend()
{
- if (MessageBox::question(tr("Razor Session Suspend"),
- tr("Do you want to really suspend your computer?<p>Suspends the computer into a low power state. System state is not preserved if the power is lost.")))
+ if (m_skipWarning ||
+ MessageBox::question(tr("Razor Session Suspend"),
+ tr("Do you want to really suspend your computer?<p>Suspends the computer into a low power state. System state is not preserved if the power is lost.")))
{
m_power->suspend();
}
@@ -149,7 +151,8 @@ void PowerManager::suspend()
void PowerManager::hibernate()
{
- if (MessageBox::question(tr("Razor Session Hibernate"),
+ if (m_skipWarning ||
+ MessageBox::question(tr("Razor Session Hibernate"),
tr("Do you want to really hibernate your computer?<p>Hibernates the computer into a low power state. System state is preserved if the power is lost.")))
{
m_power->hibernate();
@@ -158,7 +161,8 @@ void PowerManager::hibernate()
void PowerManager::reboot()
{
- if (MessageBox::question(tr("Razor Session Reboot"),
+ if (m_skipWarning ||
+ MessageBox::question(tr("Razor Session Reboot"),
tr("Do you want to really restart your computer? All unsaved work will be lost...")))
{
m_power->reboot();
@@ -167,7 +171,8 @@ void PowerManager::reboot()
void PowerManager::shutdown()
{
- if (MessageBox::question(tr("Razor Session Shutdown"),
+ if (m_skipWarning ||
+ MessageBox::question(tr("Razor Session Shutdown"),
tr("Do you want to really switch off your computer? All unsaved work will be lost...")))
{
m_power->shutdown();
@@ -176,7 +181,8 @@ void PowerManager::shutdown()
void PowerManager::logout()
{
- if (MessageBox::question(tr("Razor Session Logout"),
+ if (m_skipWarning ||
+ MessageBox::question(tr("Razor Session Logout"),
tr("Do you want to really logout? All unsaved work will be lost...")))
{
m_power->logout();
View
6 libraries/razorqt/powermanager.h
@@ -40,7 +40,7 @@ class PowerManager : public QObject
Q_OBJECT
public:
- PowerManager(QObject * parent);
+ PowerManager(QObject * parent, bool skipWarning = false);
~PowerManager();
QList<QAction*> availableActions();
@@ -53,8 +53,12 @@ public slots:
// razor session
void logout();
+public:
+ bool skipWarning() const { return m_skipWarning; }
+
private:
RazorPower * m_power;
+ bool m_skipWarning;
private slots:
void hibernateFailed();
View
24 razorqt-lightdm-greeter/loginform.cpp
@@ -25,6 +25,7 @@
#include "loginform.h"
#include "ui_loginform.h"
+
#include <QtCore/QDebug>
#include <QtGui/QCompleter>
#include <QtCore/QAbstractListModel>
@@ -43,7 +44,7 @@ LoginForm::LoginForm(QWidget *parent) :
ui(new Ui::LoginForm),
m_Greeter(),
m_LoginData(&m_Greeter),
- m_razorPowerProcess(),
+ m_powerManager(this, true),
m_otherUserComboIndex(-1)
{
if (!m_Greeter.connectSync())
@@ -115,7 +116,6 @@ void LoginForm::setupConnections()
connect(ui->otherUserInput, SIGNAL(editingFinished()), this, SLOT(otherUserEditingFinished()));
connect(ui->loginButton, SIGNAL(clicked(bool)), this, SLOT(loginClicked()));
connect(ui->leaveButton, SIGNAL(clicked()), this, SLOT(leaveClicked()));
- connect(&m_razorPowerProcess, SIGNAL(finished(int)), this, SLOT(razorPowerFinished()));
connect(&m_Greeter, SIGNAL(showPrompt(QString,QLightDM::Greeter::PromptType)),
@@ -126,6 +126,14 @@ void LoginForm::setupConnections()
void LoginForm::initializeControls()
{
+ QMenu* leaveMenu = new QMenu(this);
+ ui->leaveButton->setMenu(leaveMenu);
+
+ foreach (QAction *action, m_powerManager.availableActions())
+ {
+ leaveMenu->addAction(action);
+ }
+
qDebug() << "showManualLoginHint:" << m_Greeter.showManualLoginHint();
ui->sessionCombo->setCurrentIndex(m_LoginData.suggestedSession());
@@ -207,18 +215,6 @@ void LoginForm::loginClicked()
ui->passwordInput->setEnabled(false);
}
-void LoginForm::leaveClicked()
-{
- qDebug() << "leave";
- m_razorPowerProcess.start("razor-power");
- setEnabled(false);
-}
-
-void LoginForm::razorPowerFinished()
-{
- setEnabled(true);
-}
-
void LoginForm::onPrompt(QString prompt, QLightDM::Greeter::PromptType promptType)
{
qDebug() << "onPrompt";
View
7 razorqt-lightdm-greeter/loginform.h
@@ -32,6 +32,7 @@
#include <QtGui/QKeyEvent>
#include <QGraphicsOpacityEffect>
#include "logindata.h"
+#include "powermanager.h"
namespace Ui {
class LoginForm;
@@ -51,8 +52,6 @@ public slots:
void userComboCurrentIndexChanged();
void otherUserEditingFinished();
void loginClicked();
- void leaveClicked();
- void razorPowerFinished();
void onPrompt(QString prompt, QLightDM::Greeter::PromptType promptType);
@@ -69,8 +68,8 @@ public slots:
Ui::LoginForm *ui;
QLightDM::Greeter m_Greeter;
LoginData m_LoginData;
- QProcess m_razorPowerProcess;
-
+ PowerManager m_powerManager;
+
int m_otherUserComboIndex;
QString m_user;
};
Please sign in to comment.
Something went wrong with that request. Please try again.