mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2024-11-25 10:46:15 +03:00
Rename enum
Change identifier from ShutdownAction to ShutdownDialogAction Change enum value from None to Exit
This commit is contained in:
parent
d3fb46663c
commit
6a11056b60
7 changed files with 29 additions and 29 deletions
|
@ -97,7 +97,7 @@ Application::Application(const QString &id, int &argc, char **argv)
|
|||
: BaseApplication(id, argc, argv)
|
||||
, m_running(false)
|
||||
#ifndef DISABLE_GUI
|
||||
, m_shutdownAct(ShutdownAction::None)
|
||||
, m_shutdownAct(ShutdownDialogAction::Exit)
|
||||
#endif
|
||||
{
|
||||
Logger::initInstance();
|
||||
|
@ -298,15 +298,15 @@ void Application::allTorrentsFinished()
|
|||
bool shutdown = pref->shutdownWhenDownloadsComplete();
|
||||
|
||||
// Confirm shutdown
|
||||
ShutdownAction action = ShutdownAction::None;
|
||||
ShutdownDialogAction action = ShutdownDialogAction::Exit;
|
||||
if (suspend)
|
||||
action = ShutdownAction::Suspend;
|
||||
action = ShutdownDialogAction::Suspend;
|
||||
else if (hibernate)
|
||||
action = ShutdownAction::Hibernate;
|
||||
action = ShutdownDialogAction::Hibernate;
|
||||
else if (shutdown)
|
||||
action = ShutdownAction::Shutdown;
|
||||
action = ShutdownDialogAction::Shutdown;
|
||||
|
||||
if ((action == ShutdownAction::None) && (!pref->dontConfirmAutoExit())) {
|
||||
if ((action == ShutdownDialogAction::Exit) && (!pref->dontConfirmAutoExit())) {
|
||||
if (!ShutdownConfirmDlg::askForConfirmation(action))
|
||||
return;
|
||||
}
|
||||
|
@ -604,7 +604,7 @@ void Application::cleanup()
|
|||
shutdownBRDestroy((HWND)m_window->effectiveWinId());
|
||||
#endif // Q_OS_WIN
|
||||
delete m_window;
|
||||
if (m_shutdownAct != ShutdownAction::None) {
|
||||
if (m_shutdownAct != ShutdownDialogAction::Exit) {
|
||||
qDebug() << "Sending computer shutdown/suspend/hibernate signal...";
|
||||
Utils::Misc::shutdownComputer(m_shutdownAct);
|
||||
}
|
||||
|
|
|
@ -114,7 +114,7 @@ private:
|
|||
|
||||
#ifndef DISABLE_GUI
|
||||
QPointer<MainWindow> m_window;
|
||||
ShutdownAction m_shutdownAct;
|
||||
ShutdownDialogAction m_shutdownAct;
|
||||
#endif
|
||||
|
||||
#ifndef DISABLE_WEBUI
|
||||
|
|
|
@ -33,9 +33,9 @@
|
|||
|
||||
const qlonglong MAX_ETA = 8640000;
|
||||
|
||||
enum class ShutdownAction
|
||||
enum class ShutdownDialogAction
|
||||
{
|
||||
None,
|
||||
Exit,
|
||||
Shutdown,
|
||||
Suspend,
|
||||
Hibernate
|
||||
|
|
|
@ -92,16 +92,16 @@ static struct { const char *source; const char *comment; } units[] = {
|
|||
};
|
||||
|
||||
#ifndef DISABLE_GUI
|
||||
void Utils::Misc::shutdownComputer(ShutdownAction action)
|
||||
void Utils::Misc::shutdownComputer(const ShutdownDialogAction &action)
|
||||
{
|
||||
#if (defined(Q_OS_UNIX) && !defined(Q_OS_MAC)) && defined(QT_DBUS_LIB)
|
||||
// Use dbus to power off / suspend the system
|
||||
if (action != ShutdownAction::Shutdown) {
|
||||
if (action != ShutdownDialogAction::Shutdown) {
|
||||
// Some recent systems use systemd's logind
|
||||
QDBusInterface login1Iface("org.freedesktop.login1", "/org/freedesktop/login1",
|
||||
"org.freedesktop.login1.Manager", QDBusConnection::systemBus());
|
||||
if (login1Iface.isValid()) {
|
||||
if (action == ShutdownAction::Suspend)
|
||||
if (action == ShutdownDialogAction::Suspend)
|
||||
login1Iface.call("Suspend", false);
|
||||
else
|
||||
login1Iface.call("Hibernate", false);
|
||||
|
@ -111,7 +111,7 @@ void Utils::Misc::shutdownComputer(ShutdownAction action)
|
|||
QDBusInterface upowerIface("org.freedesktop.UPower", "/org/freedesktop/UPower",
|
||||
"org.freedesktop.UPower", QDBusConnection::systemBus());
|
||||
if (upowerIface.isValid()) {
|
||||
if (action == ShutdownAction::Suspend)
|
||||
if (action == ShutdownDialogAction::Suspend)
|
||||
upowerIface.call("Suspend");
|
||||
else
|
||||
upowerIface.call("Hibernate");
|
||||
|
@ -121,7 +121,7 @@ void Utils::Misc::shutdownComputer(ShutdownAction action)
|
|||
QDBusInterface halIface("org.freedesktop.Hal", "/org/freedesktop/Hal/devices/computer",
|
||||
"org.freedesktop.Hal.Device.SystemPowerManagement",
|
||||
QDBusConnection::systemBus());
|
||||
if (action == ShutdownAction::Suspend)
|
||||
if (action == ShutdownDialogAction::Suspend)
|
||||
halIface.call("Suspend", 5);
|
||||
else
|
||||
halIface.call("Hibernate");
|
||||
|
@ -150,7 +150,7 @@ void Utils::Misc::shutdownComputer(ShutdownAction action)
|
|||
#endif
|
||||
#ifdef Q_OS_MAC
|
||||
AEEventID EventToSend;
|
||||
if (action != ShutdownAction::Shutdown)
|
||||
if (action != ShutdownDialogAction::Shutdown)
|
||||
EventToSend = kAESleep;
|
||||
else
|
||||
EventToSend = kAEShutDown;
|
||||
|
@ -203,9 +203,9 @@ void Utils::Misc::shutdownComputer(ShutdownAction action)
|
|||
if (GetLastError() != ERROR_SUCCESS)
|
||||
return;
|
||||
|
||||
if (action == ShutdownAction::Suspend)
|
||||
if (action == ShutdownDialogAction::Suspend)
|
||||
SetSuspendState(false, false, false);
|
||||
else if (action == ShutdownAction::Hibernate)
|
||||
else if (action == ShutdownDialogAction::Hibernate)
|
||||
SetSuspendState(true, false, false);
|
||||
else
|
||||
InitiateSystemShutdownA(0, QCoreApplication::translate("misc", "qBittorrent will shutdown the computer now because all downloads are complete.").toLocal8Bit().data(), 10, true, false);
|
||||
|
|
|
@ -68,7 +68,7 @@ namespace Utils
|
|||
bool isUrl(const QString &s);
|
||||
|
||||
#ifndef DISABLE_GUI
|
||||
void shutdownComputer(ShutdownAction action);
|
||||
void shutdownComputer(const ShutdownDialogAction &action);
|
||||
// Get screen center
|
||||
QPoint screenCenter(QWidget *win);
|
||||
QSize smallIconSize();
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
#include "base/utils/misc.h"
|
||||
|
||||
|
||||
ShutdownConfirmDlg::ShutdownConfirmDlg(const ShutdownAction &action)
|
||||
ShutdownConfirmDlg::ShutdownConfirmDlg(const ShutdownDialogAction &action)
|
||||
: ui(new Ui::confirmShutdownDlg)
|
||||
, m_timeout(15)
|
||||
, m_action(action)
|
||||
|
@ -53,7 +53,7 @@ ShutdownConfirmDlg::ShutdownConfirmDlg(const ShutdownAction &action)
|
|||
QIcon warningIcon(style()->standardIcon(QStyle::SP_MessageBoxWarning));
|
||||
ui->warningLabel->setPixmap(warningIcon.pixmap(32));
|
||||
|
||||
if (m_action == ShutdownAction::None)
|
||||
if (m_action == ShutdownDialogAction::Exit)
|
||||
ui->neverShowAgainCheckbox->setVisible(true);
|
||||
else
|
||||
ui->neverShowAgainCheckbox->setVisible(false);
|
||||
|
@ -82,7 +82,7 @@ void ShutdownConfirmDlg::showEvent(QShowEvent *event)
|
|||
m_timer.start();
|
||||
}
|
||||
|
||||
bool ShutdownConfirmDlg::askForConfirmation(const ShutdownAction &action)
|
||||
bool ShutdownConfirmDlg::askForConfirmation(const ShutdownDialogAction &action)
|
||||
{
|
||||
ShutdownConfirmDlg dlg(action);
|
||||
return (dlg.exec() == QDialog::Accepted);
|
||||
|
@ -109,25 +109,25 @@ void ShutdownConfirmDlg::initText()
|
|||
QPushButton *okButton = ui->buttonBox->button(QDialogButtonBox::Ok);
|
||||
|
||||
switch (m_action) {
|
||||
case ShutdownAction::None:
|
||||
case ShutdownDialogAction::Exit:
|
||||
m_msg = tr("qBittorrent will now exit.");
|
||||
|
||||
okButton->setText(tr("E&xit Now"));
|
||||
setWindowTitle(tr("Exit confirmation"));
|
||||
break;
|
||||
case ShutdownAction::Shutdown:
|
||||
case ShutdownDialogAction::Shutdown:
|
||||
m_msg = tr("The computer is going to shutdown.");
|
||||
|
||||
okButton->setText(tr("&Shutdown Now"));
|
||||
setWindowTitle(tr("Shutdown confirmation"));
|
||||
break;
|
||||
case ShutdownAction::Suspend:
|
||||
case ShutdownDialogAction::Suspend:
|
||||
m_msg = tr("The computer is going to enter suspend mode.");
|
||||
|
||||
okButton->setText(tr("&Suspend Now"));
|
||||
setWindowTitle(tr("Suspend confirmation"));
|
||||
break;
|
||||
case ShutdownAction::Hibernate:
|
||||
case ShutdownDialogAction::Hibernate:
|
||||
m_msg = tr("The computer is going to enter hibernation mode.");
|
||||
|
||||
okButton->setText(tr("&Hibernate Now"));
|
||||
|
|
|
@ -45,10 +45,10 @@ class ShutdownConfirmDlg: public QDialog
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ShutdownConfirmDlg(const ShutdownAction &action);
|
||||
ShutdownConfirmDlg(const ShutdownDialogAction &action);
|
||||
~ShutdownConfirmDlg();
|
||||
|
||||
static bool askForConfirmation(const ShutdownAction &action);
|
||||
static bool askForConfirmation(const ShutdownDialogAction &action);
|
||||
|
||||
protected:
|
||||
void showEvent(QShowEvent *event) override;
|
||||
|
@ -66,7 +66,7 @@ private:
|
|||
Ui::confirmShutdownDlg *ui;
|
||||
QTimer m_timer;
|
||||
int m_timeout;
|
||||
ShutdownAction m_action;
|
||||
ShutdownDialogAction m_action;
|
||||
QString m_msg;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue