Browse Source

Started preferences simplifying

adaptive-webui-19844
Christophe Dumez 15 years ago
parent
commit
e71f144c40
  1. 25
      src/GUI.cpp
  2. 7
      src/options_imp.cpp
  3. 1
      src/options_imp.h
  4. 5
      src/preferences.h
  5. 45
      src/ui/options.ui

25
src/GUI.cpp

@ -548,24 +548,30 @@ void GUI::closeEvent(QCloseEvent *e) {
const bool goToSystrayOnExit = settings.value(QString::fromUtf8("Preferences/General/CloseToTray"), false).toBool(); const bool goToSystrayOnExit = settings.value(QString::fromUtf8("Preferences/General/CloseToTray"), false).toBool();
if(!force_exit && systrayIcon && goToSystrayOnExit && !this->isHidden()) { if(!force_exit && systrayIcon && goToSystrayOnExit && !this->isHidden()) {
hide(); hide();
//e->ignore();
e->accept(); e->accept();
return; return;
} }
if(settings.value(QString::fromUtf8("Preferences/General/ExitConfirm"), true).toBool() && BTSession->hasActiveTorrents()) { if(settings.value(QString::fromUtf8("Preferences/General/ExitConfirm"), true).toBool() && BTSession->hasActiveTorrents()) {
show();
if(!isMaximized())
showNormal();
if(e->spontaneous() || force_exit) { if(e->spontaneous() || force_exit) {
if(QMessageBox::question(this, if(!isVisible())
tr("Are you sure you want to quit?")+QString::fromUtf8(" -- ")+tr("qBittorrent"), show();
tr("Some files are currently transferring.\nAre you sure you want to quit qBittorrent?"), QMessageBox confirmBox(QMessageBox::Question, tr("Are you sure you want to quit?")+QString::fromUtf8(" -- ")+tr("qBittorrent"),
tr("&Yes"), tr("&No"), tr("Some files are currently transferring.\nAre you sure you want to quit qBittorrent?"));
QString(), 0, 1)) { QPushButton *noBtn = confirmBox.addButton(tr("No"), QMessageBox::NoRole);
QPushButton *yesBtn = confirmBox.addButton(tr("Yes"), QMessageBox::YesRole);
QPushButton *alwaysBtn = confirmBox.addButton(tr("Always"), QMessageBox::YesRole);
confirmBox.setDefaultButton(yesBtn);
confirmBox.exec();
if(!confirmBox.clickedButton() || confirmBox.clickedButton() == noBtn) {
// Cancel exit
e->ignore(); e->ignore();
force_exit = false; force_exit = false;
return; return;
} }
if(confirmBox.clickedButton() == alwaysBtn) {
// Remember choice
Preferences::setConfirmOnExit(false);
}
} }
} }
hide(); hide();
@ -580,7 +586,6 @@ void GUI::closeEvent(QCloseEvent *e) {
qApp->exit(); qApp->exit();
} }
// Display window to create a torrent // Display window to create a torrent
void GUI::on_actionCreate_torrent_triggered() { void GUI::on_actionCreate_torrent_triggered() {
if(createTorrentDlg) { if(createTorrentDlg) {

7
src/options_imp.cpp

@ -193,7 +193,6 @@ options_imp::options_imp(QWidget *parent):QDialog(parent){
// General tab // General tab
connect(comboI18n, SIGNAL(currentIndexChanged(int)), this, SLOT(enableApplyButton())); connect(comboI18n, SIGNAL(currentIndexChanged(int)), this, SLOT(enableApplyButton()));
connect(comboStyle, SIGNAL(currentIndexChanged(int)), this, SLOT(enableApplyButton())); connect(comboStyle, SIGNAL(currentIndexChanged(int)), this, SLOT(enableApplyButton()));
connect(checkConfirmExit, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton()));
connect(checkSpeedInTitle, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton())); connect(checkSpeedInTitle, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton()));
connect(checkAltRowColors, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton())); connect(checkAltRowColors, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton()));
connect(checkNoSystray, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton())); connect(checkNoSystray, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton()));
@ -386,7 +385,6 @@ void options_imp::saveOptions(){
settings.beginGroup("General"); settings.beginGroup("General");
settings.setValue(QString::fromUtf8("Locale"), getLocale()); settings.setValue(QString::fromUtf8("Locale"), getLocale());
settings.setValue(QString::fromUtf8("Style"), getStyle()); settings.setValue(QString::fromUtf8("Style"), getStyle());
settings.setValue(QString::fromUtf8("ExitConfirm"), confirmOnExit());
settings.setValue(QString::fromUtf8("SpeedInTitleBar"), speedInTitleBar()); settings.setValue(QString::fromUtf8("SpeedInTitleBar"), speedInTitleBar());
settings.setValue(QString::fromUtf8("AlternatingRowColors"), checkAltRowColors->isChecked()); settings.setValue(QString::fromUtf8("AlternatingRowColors"), checkAltRowColors->isChecked());
settings.setValue(QString::fromUtf8("SystrayEnabled"), systrayIntegration()); settings.setValue(QString::fromUtf8("SystrayEnabled"), systrayIntegration());
@ -617,7 +615,6 @@ void options_imp::loadOptions(){
// General preferences // General preferences
setLocale(Preferences::getLocale()); setLocale(Preferences::getLocale());
setStyle(Preferences::getStyle()); setStyle(Preferences::getStyle());
checkConfirmExit->setChecked(Preferences::confirmOnExit());
checkSpeedInTitle->setChecked(Preferences::speedInTitleBar()); checkSpeedInTitle->setChecked(Preferences::speedInTitleBar());
checkAltRowColors->setChecked(Preferences::useAlternatingRowColors()); checkAltRowColors->setChecked(Preferences::useAlternatingRowColors());
checkNoSystray->setChecked(!Preferences::systrayIntegration()); checkNoSystray->setChecked(!Preferences::systrayIntegration());
@ -982,10 +979,6 @@ bool options_imp::closeToTray() const{
return checkCloseToSystray->isChecked(); return checkCloseToSystray->isChecked();
} }
bool options_imp::confirmOnExit() const{
return checkConfirmExit->isChecked();
}
bool options_imp::isQueueingSystemEnabled() const { bool options_imp::isQueueingSystemEnabled() const {
return checkEnableQueueing->isChecked(); return checkEnableQueueing->isChecked();
} }

1
src/options_imp.h

@ -67,7 +67,6 @@ protected:
// General options // General options
QString getLocale() const; QString getLocale() const;
QString getStyle() const; QString getStyle() const;
bool confirmOnExit() const;
bool speedInTitleBar() const; bool speedInTitleBar() const;
bool systrayIntegration() const; bool systrayIntegration() const;
bool minimizeToTray() const; bool minimizeToTray() const;

5
src/preferences.h

@ -87,6 +87,11 @@ public:
settings.setValue(QString::fromUtf8("Preferences/General/DeleteTorrentsFilesAsDefault"), del); settings.setValue(QString::fromUtf8("Preferences/General/DeleteTorrentsFilesAsDefault"), del);
} }
static void setConfirmOnExit(bool confirm) {
QSettings settings("qBittorrent", "qBittorrent");
settings.setValue(QString::fromUtf8("Preferences/General/ExitConfirm"), confirm);
}
static bool confirmOnExit() { static bool confirmOnExit() {
QSettings settings("qBittorrent", "qBittorrent"); QSettings settings("qBittorrent", "qBittorrent");
return settings.value(QString::fromUtf8("Preferences/General/ExitConfirm"), true).toBool(); return settings.value(QString::fromUtf8("Preferences/General/ExitConfirm"), true).toBool();

45
src/ui/options.ui

@ -242,7 +242,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>506</width> <width>506</width>
<height>571</height> <height>543</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_9"> <layout class="QVBoxLayout" name="verticalLayout_9">
@ -335,16 +335,6 @@
</item> </item>
</layout> </layout>
</item> </item>
<item>
<widget class="QCheckBox" name="checkConfirmExit">
<property name="text">
<string>Ask for confirmation on exit when download list is not empty</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item> <item>
<widget class="QCheckBox" name="checkDisplayToolbar"> <widget class="QCheckBox" name="checkDisplayToolbar">
<property name="text"> <property name="text">
@ -571,7 +561,7 @@ QGroupBox {
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>
<y>-298</y> <y>0</y>
<width>632</width> <width>632</width>
<height>686</height> <height>686</height>
</rect> </rect>
@ -1116,8 +1106,8 @@ QGroupBox {
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>524</width> <width>447</width>
<height>398</height> <height>288</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_28"> <layout class="QVBoxLayout" name="verticalLayout_28">
@ -1361,8 +1351,8 @@ QGroupBox {
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>524</width> <width>364</width>
<height>406</height> <height>328</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_33"> <layout class="QVBoxLayout" name="verticalLayout_33">
@ -1776,7 +1766,7 @@ QGroupBox {
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>506</width> <width>459</width>
<height>407</height> <height>407</height>
</rect> </rect>
</property> </property>
@ -2193,8 +2183,8 @@ QGroupBox {
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>524</width> <width>475</width>
<height>406</height> <height>308</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_16"> <layout class="QVBoxLayout" name="verticalLayout_16">
@ -2627,8 +2617,8 @@ QGroupBox {
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>524</width> <width>287</width>
<height>406</height> <height>124</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_21"> <layout class="QVBoxLayout" name="verticalLayout_21">
@ -2724,8 +2714,8 @@ QGroupBox {
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>524</width> <width>213</width>
<height>406</height> <height>221</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_23"> <layout class="QVBoxLayout" name="verticalLayout_23">
@ -2891,8 +2881,8 @@ QGroupBox {
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>524</width> <width>445</width>
<height>406</height> <height>192</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_24"> <layout class="QVBoxLayout" name="verticalLayout_24">
@ -3066,8 +3056,8 @@ QGroupBox {
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>524</width> <width>98</width>
<height>406</height> <height>28</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_36"/> <layout class="QVBoxLayout" name="verticalLayout_36"/>
@ -3115,7 +3105,6 @@ QGroupBox {
<tabstop>tabOption</tabstop> <tabstop>tabOption</tabstop>
<tabstop>comboI18n</tabstop> <tabstop>comboI18n</tabstop>
<tabstop>comboStyle</tabstop> <tabstop>comboStyle</tabstop>
<tabstop>checkConfirmExit</tabstop>
<tabstop>checkSpeedInTitle</tabstop> <tabstop>checkSpeedInTitle</tabstop>
<tabstop>checkNoSystray</tabstop> <tabstop>checkNoSystray</tabstop>
<tabstop>checkCloseToSystray</tabstop> <tabstop>checkCloseToSystray</tabstop>

Loading…
Cancel
Save