Some work about adaptive color scheme for Web UI (PR #19901)
http://[316:c51a:62a3:8b9::4]/d4708/qBittorrent/src/branch/adaptive-webui
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
147 lines
4.4 KiB
147 lines
4.4 KiB
10 years ago
|
/*
|
||
10 years ago
|
* Bittorrent Client using Qt and libtorrent.
|
||
10 years ago
|
* Copyright (C) 2011 Christophe Dumez
|
||
|
* Copyright (C) 2014 sledgehammer999
|
||
|
*
|
||
|
* This program is free software; you can redistribute it and/or
|
||
|
* modify it under the terms of the GNU General Public License
|
||
|
* as published by the Free Software Foundation; either version 2
|
||
|
* of the License, or (at your option) any later version.
|
||
|
*
|
||
|
* This program is distributed in the hope that it will be useful,
|
||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
|
* GNU General Public License for more details.
|
||
|
*
|
||
|
* You should have received a copy of the GNU General Public License
|
||
|
* along with this program; if not, write to the Free Software
|
||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||
|
*
|
||
|
* In addition, as a special exception, the copyright holders give permission to
|
||
|
* link this program with the OpenSSL project's "OpenSSL" library (or with
|
||
|
* modified versions of it that use the same license as the "OpenSSL" library),
|
||
|
* and distribute the linked executables. You must obey the GNU General Public
|
||
|
* License in all respects for all of the code used other than "OpenSSL". If you
|
||
|
* modify file(s), you may extend this exception to your version of the file(s),
|
||
|
* but you are not obligated to do so. If you do not wish to do so, delete this
|
||
|
* exception statement from your version.
|
||
|
*
|
||
|
* Contact : chris@qbittorrent.org
|
||
|
* Contact : hammered999@gmail.com
|
||
|
*/
|
||
|
|
||
9 years ago
|
#include "shutdownconfirmdlg.h"
|
||
|
#include "ui_shutdownconfirmdlg.h"
|
||
9 years ago
|
|
||
9 years ago
|
#include <QStyle>
|
||
|
#include <QIcon>
|
||
|
#include <QDialogButtonBox>
|
||
10 years ago
|
#include <QPushButton>
|
||
10 years ago
|
|
||
9 years ago
|
#include "base/preferences.h"
|
||
9 years ago
|
#include "base/utils/misc.h"
|
||
9 years ago
|
|
||
|
|
||
9 years ago
|
ShutdownConfirmDlg::ShutdownConfirmDlg(const ShutdownDialogAction &action)
|
||
9 years ago
|
: ui(new Ui::confirmShutdownDlg)
|
||
10 years ago
|
, m_timeout(15)
|
||
|
, m_action(action)
|
||
|
{
|
||
9 years ago
|
ui->setupUi(this);
|
||
|
|
||
9 years ago
|
initText();
|
||
9 years ago
|
QIcon warningIcon(style()->standardIcon(QStyle::SP_MessageBoxWarning));
|
||
|
ui->warningLabel->setPixmap(warningIcon.pixmap(32));
|
||
9 years ago
|
|
||
9 years ago
|
if (m_action == ShutdownDialogAction::Exit)
|
||
9 years ago
|
ui->neverShowAgainCheckbox->setVisible(true);
|
||
|
else
|
||
9 years ago
|
ui->neverShowAgainCheckbox->setVisible(false);
|
||
9 years ago
|
|
||
10 years ago
|
// Cancel Button
|
||
9 years ago
|
QPushButton *cancelButton = ui->buttonBox->button(QDialogButtonBox::Cancel);
|
||
|
cancelButton->setFocus();
|
||
9 years ago
|
cancelButton->setDefault(true);
|
||
9 years ago
|
|
||
10 years ago
|
// Always on top
|
||
9 years ago
|
setWindowFlags(windowFlags() | Qt::WindowStaysOnTopHint);
|
||
9 years ago
|
move(Utils::Misc::screenCenter(this));
|
||
|
|
||
10 years ago
|
m_timer.setInterval(1000); // 1sec
|
||
9 years ago
|
connect(&m_timer, SIGNAL(timeout()), this, SLOT(updateSeconds()));
|
||
9 years ago
|
}
|
||
|
|
||
9 years ago
|
ShutdownConfirmDlg::~ShutdownConfirmDlg()
|
||
|
{
|
||
9 years ago
|
delete ui;
|
||
9 years ago
|
}
|
||
|
|
||
10 years ago
|
void ShutdownConfirmDlg::showEvent(QShowEvent *event)
|
||
|
{
|
||
9 years ago
|
QDialog::showEvent(event);
|
||
10 years ago
|
m_timer.start();
|
||
10 years ago
|
}
|
||
|
|
||
9 years ago
|
bool ShutdownConfirmDlg::askForConfirmation(const ShutdownDialogAction &action)
|
||
10 years ago
|
{
|
||
10 years ago
|
ShutdownConfirmDlg dlg(action);
|
||
9 years ago
|
return (dlg.exec() == QDialog::Accepted);
|
||
10 years ago
|
}
|
||
10 years ago
|
|
||
10 years ago
|
void ShutdownConfirmDlg::updateSeconds()
|
||
|
{
|
||
|
--m_timeout;
|
||
10 years ago
|
updateText();
|
||
10 years ago
|
if (m_timeout == 0) {
|
||
|
m_timer.stop();
|
||
10 years ago
|
accept();
|
||
|
}
|
||
10 years ago
|
}
|
||
|
|
||
9 years ago
|
void ShutdownConfirmDlg::accept()
|
||
9 years ago
|
{
|
||
9 years ago
|
Preferences::instance()->setDontConfirmAutoExit(ui->neverShowAgainCheckbox->isChecked());
|
||
|
QDialog::accept();
|
||
9 years ago
|
}
|
||
|
|
||
9 years ago
|
void ShutdownConfirmDlg::initText()
|
||
10 years ago
|
{
|
||
9 years ago
|
QPushButton *okButton = ui->buttonBox->button(QDialogButtonBox::Ok);
|
||
10 years ago
|
|
||
10 years ago
|
switch (m_action) {
|
||
9 years ago
|
case ShutdownDialogAction::Exit:
|
||
9 years ago
|
m_msg = tr("qBittorrent will now exit.");
|
||
9 years ago
|
|
||
|
okButton->setText(tr("E&xit Now"));
|
||
|
setWindowTitle(tr("Exit confirmation"));
|
||
10 years ago
|
break;
|
||
9 years ago
|
case ShutdownDialogAction::Shutdown:
|
||
9 years ago
|
m_msg = tr("The computer is going to shutdown.");
|
||
9 years ago
|
|
||
|
okButton->setText(tr("&Shutdown Now"));
|
||
|
setWindowTitle(tr("Shutdown confirmation"));
|
||
10 years ago
|
break;
|
||
9 years ago
|
case ShutdownDialogAction::Suspend:
|
||
9 years ago
|
m_msg = tr("The computer is going to enter suspend mode.");
|
||
9 years ago
|
|
||
|
okButton->setText(tr("&Suspend Now"));
|
||
|
setWindowTitle(tr("Suspend confirmation"));
|
||
10 years ago
|
break;
|
||
9 years ago
|
case ShutdownDialogAction::Hibernate:
|
||
9 years ago
|
m_msg = tr("The computer is going to enter hibernation mode.");
|
||
9 years ago
|
|
||
|
okButton->setText(tr("&Hibernate Now"));
|
||
|
setWindowTitle(tr("Hibernate confirmation"));
|
||
10 years ago
|
break;
|
||
|
}
|
||
10 years ago
|
|
||
9 years ago
|
m_msg += "\n";
|
||
|
updateText();
|
||
|
}
|
||
|
|
||
|
void ShutdownConfirmDlg::updateText()
|
||
|
{
|
||
|
QString t = tr("You can cancel the action within %1 seconds.").arg(QString::number(m_timeout)) + "\n";
|
||
|
ui->shutdownText->setText(m_msg + t);
|
||
10 years ago
|
}
|