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. 3
      TODO
  3. 49
      src/options.ui
  4. 28
      src/options_imp.cpp
  5. 7
      src/options_imp.h

1
Changelog

@ -10,6 +10,7 @@ @@ -10,6 +10,7 @@
- FEATURE: Improved a lot the torrent creation module
- FEATURE: Allow to set upload/download limit per torrent (right click)
- 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
- COSMETIC: Redesigned torrent properties a little
- COSMETIC: Redesigned options a little

3
TODO

@ -47,4 +47,5 @@ @@ -47,4 +47,5 @@
- Improve ratio display / calculation / saving / per torrent...
- 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
- 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 @@ @@ -62,7 +62,7 @@
<enum>QTabWidget::Rounded</enum>
</property>
<property name="currentIndex" >
<number>1</number>
<number>0</number>
</property>
<property name="iconSize" >
<size>
@ -1640,55 +1640,18 @@ @@ -1640,55 +1640,18 @@
<number>6</number>
</property>
<item>
<spacer>
<widget class="QDialogButtonBox" name="buttonBox" >
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" >
<size>
<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 name="standardButtons" >
<set>QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::NoButton|QDialogButtonBox::Ok</set>
</property>
<property name="text" >
<string>Apply</string>
<property name="centerButtons" >
<bool>true</bool>
</property>
</widget>
</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>
</item>
</layout>

28
src/options_imp.cpp

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

7
src/options_imp.h

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

Loading…
Cancel
Save