Browse Source

- Use a standard QDialogButtonBox in options for better systems integration

adaptive-webui-19844
Christophe Dumez 18 years ago
parent
commit
ab4ad0b114
  1. 1
      Changelog
  2. 1
      TODO
  3. 49
      src/options.ui
  4. 28
      src/options_imp.cpp
  5. 7
      src/options_imp.h

1
Changelog

@ -10,6 +10,7 @@
- FEATURE: Improved a lot the torrent creation module - FEATURE: Improved a lot the torrent creation module
- FEATURE: Allow to set upload/download limit per torrent (right click) - FEATURE: Allow to set upload/download limit per torrent (right click)
- FEATURE: Ask for exit confirmation only if download list is not empty - FEATURE: Ask for exit confirmation only if download list is not empty
- FEATURE: Better systems integration (buttons, dialogs...)
- BUGFIX: Window can now stay maximized on exit - BUGFIX: Window can now stay maximized on exit
- COSMETIC: Redesigned torrent properties a little - COSMETIC: Redesigned torrent properties a little
- COSMETIC: Redesigned options a little - COSMETIC: Redesigned options a little

1
TODO

@ -48,3 +48,4 @@
- Use buttonboxes when possible - Use buttonboxes when possible
- Display the sum of the size of the selected files in the torrent instead of the whole torrent size in download list - Display the sum of the size of the selected files in the torrent instead of the whole torrent size in download list
- Sorting in Download Status column should be smarter than just an alphabetical sort - Sorting in Download Status column should be smarter than just an alphabetical sort
- remove ETA from finished list

49
src/options.ui

@ -62,7 +62,7 @@
<enum>QTabWidget::Rounded</enum> <enum>QTabWidget::Rounded</enum>
</property> </property>
<property name="currentIndex" > <property name="currentIndex" >
<number>1</number> <number>0</number>
</property> </property>
<property name="iconSize" > <property name="iconSize" >
<size> <size>
@ -1640,55 +1640,18 @@
<number>6</number> <number>6</number>
</property> </property>
<item> <item>
<spacer> <widget class="QDialogButtonBox" name="buttonBox" >
<property name="orientation" > <property name="orientation" >
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="sizeHint" > <property name="standardButtons" >
<size> <set>QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::NoButton|QDialogButtonBox::Ok</set>
<width>81</width>
<height>31</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="okButton" >
<property name="text" >
<string>OK</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="cancelButton" >
<property name="text" >
<string>Cancel</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="applyButton" >
<property name="enabled" >
<bool>false</bool>
</property> </property>
<property name="text" > <property name="centerButtons" >
<string>Apply</string> <bool>true</bool>
</property> </property>
</widget> </widget>
</item> </item>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" >
<size>
<width>81</width>
<height>31</height>
</size>
</property>
</spacer>
</item>
</layout> </layout>
</item> </item>
</layout> </layout>

28
src/options_imp.cpp

@ -29,6 +29,7 @@
#include <QCleanlooksStyle> #include <QCleanlooksStyle>
#include <QMotifStyle> #include <QMotifStyle>
#include <QCDEStyle> #include <QCDEStyle>
#include <QDialogButtonBox>
#ifdef Q_WS_WIN #ifdef Q_WS_WIN
#include <QWindowsXPStyle> #include <QWindowsXPStyle>
#endif #endif
@ -45,6 +46,16 @@ options_imp::options_imp(QWidget *parent):QDialog(parent){
qDebug("-> Constructing Options"); qDebug("-> Constructing Options");
QString savePath; QString savePath;
setupUi(this); setupUi(this);
// Get apply button in button box
QList<QAbstractButton *> buttons = buttonBox->buttons();
QAbstractButton *button;
foreach(button, buttons){
if(buttonBox->buttonRole(button) == QDialogButtonBox::ApplyRole){
applyButton = button;
break;
}
}
connect(buttonBox, SIGNAL(clicked(QAbstractButton*)), this, SLOT(applySettings(QAbstractButton*)));
// Setting icons // Setting icons
tabOptions->setTabIcon(0, QIcon(QString::fromUtf8(":/Icons/connection.png"))); tabOptions->setTabIcon(0, QIcon(QString::fromUtf8(":/Icons/connection.png")));
tabOptions->setTabIcon(1, QIcon(QString::fromUtf8(":/Icons/style.png"))); tabOptions->setTabIcon(1, QIcon(QString::fromUtf8(":/Icons/style.png")));
@ -244,6 +255,7 @@ void options_imp::useStyle(){
} }
void options_imp::saveOptions(){ void options_imp::saveOptions(){
applyButton->setEnabled(false);
QSettings settings("qBittorrent", "qBittorrent"); QSettings settings("qBittorrent", "qBittorrent");
// Apply style // Apply style
useStyle(); useStyle();
@ -329,8 +341,6 @@ void options_imp::saveOptions(){
settings.setValue("Style", getStyle()); settings.setValue("Style", getStyle());
// End Options group // End Options group
settings.endGroup(); settings.endGroup();
// Disable apply Button
applyButton->setEnabled(false);
} }
bool options_imp::isFilteringEnabled() const{ bool options_imp::isFilteringEnabled() const{
@ -567,8 +577,6 @@ void options_imp::loadOptions(){
setStyle(settings.value("Style", QString()).toString()); setStyle(settings.value("Style", QString()).toString());
// End Options group // End Options group
settings.endGroup(); settings.endGroup();
// Disable apply Button
applyButton->setEnabled(false);
} }
void options_imp::systrayDisabled(int val){ void options_imp::systrayDisabled(int val){
@ -705,7 +713,7 @@ int options_imp::getMaxConnec() const{
} }
} }
void options_imp::on_okButton_clicked(){ void options_imp::on_buttonBox_accepted(){
if(applyButton->isEnabled()){ if(applyButton->isEnabled()){
saveOptions(); saveOptions();
applyButton->setEnabled(false); applyButton->setEnabled(false);
@ -718,9 +726,11 @@ void options_imp::on_okButton_clicked(){
} }
} }
void options_imp::on_applyButton_clicked(){ void options_imp::applySettings(QAbstractButton* button) {
saveOptions(); if(button == applyButton){
emit status_changed(tr("Options were saved successfully."), false); saveOptions();
emit status_changed(tr("Options were saved successfully."), false);
}
} }
void options_imp::closeEvent(QCloseEvent *e){ void options_imp::closeEvent(QCloseEvent *e){
@ -728,7 +738,7 @@ void options_imp::closeEvent(QCloseEvent *e){
e->accept(); e->accept();
} }
void options_imp::on_cancelButton_clicked(){ void options_imp::on_buttonBox_rejected(){
setAttribute(Qt::WA_DeleteOnClose); setAttribute(Qt::WA_DeleteOnClose);
reject(); reject();
} }

7
src/options_imp.h

@ -36,6 +36,7 @@ class options_imp : public QDialog, private Ui::Dialog{
QButtonGroup choiceLanguage; QButtonGroup choiceLanguage;
ip_filter filter; ip_filter filter;
QStringList locales; QStringList locales;
QAbstractButton *applyButton;
public: public:
// Contructor / Destructor // Contructor / Destructor
@ -83,10 +84,10 @@ class options_imp : public QDialog, private Ui::Dialog{
bool useSystrayIntegration() const; bool useSystrayIntegration() const;
protected slots: protected slots:
void on_okButton_clicked(); void on_buttonBox_accepted();
void closeEvent(QCloseEvent *e); void closeEvent(QCloseEvent *e);
void on_cancelButton_clicked(); void on_buttonBox_rejected();
void on_applyButton_clicked(); void applySettings(QAbstractButton* button);
void on_addFilterRange_clicked(); void on_addFilterRange_clicked();
void on_delFilterRange_clicked(); void on_delFilterRange_clicked();
void on_browse_button_scan_clicked(); void on_browse_button_scan_clicked();

Loading…
Cancel
Save