X-Git-Url: http://git.maemo.org/git/?p=qtrapids;a=blobdiff_plain;f=src%2Fclient%2FPreferencesDialog.cpp;h=e541e909ede6a006d40242b4739806b5278eb172;hp=3742c41d70a3852eca5d9f84269b9f262858c7b5;hb=4fda70ff265b1a5a1f37597f57253272a2b22fbf;hpb=2acb66424c20ea4ddd481b37e4b4dcee3acde632 diff --git a/src/client/PreferencesDialog.cpp b/src/client/PreferencesDialog.cpp index 3742c41..e541e90 100644 --- a/src/client/PreferencesDialog.cpp +++ b/src/client/PreferencesDialog.cpp @@ -29,42 +29,42 @@ #include "PreferencesDialog.h" PreferencesDialog::PreferencesDialog(QWidget* parent, Qt::WindowFlags f) : - QDialog(parent, f), // Superclass - dirLineEdit_(NULL), - dialogButtons_(NULL), - settings_() + QDialog(parent, f), // Superclass + dirLineEdit_(NULL), + dialogButtons_(NULL), + settings_() { - setWindowTitle("Preferences"); + setWindowTitle("Preferences"); - QBoxLayout *verticalBox = new QBoxLayout(QBoxLayout::TopToBottom); - QBoxLayout *horizontalBox1 = new QBoxLayout(QBoxLayout::LeftToRight); - setLayout(verticalBox); - verticalBox->addLayout(horizontalBox1); + QBoxLayout *verticalBox = new QBoxLayout(QBoxLayout::TopToBottom); + QBoxLayout *horizontalBox1 = new QBoxLayout(QBoxLayout::LeftToRight); + setLayout(verticalBox); + verticalBox->addLayout(horizontalBox1); - QLabel *dirLabel = new QLabel(tr("Download directory: ")); - dirLineEdit_ = new QLineEdit(this); - QPushButton *browseDirButton = new QPushButton(tr("Browse..")); + QLabel *dirLabel = new QLabel(tr("Download directory: ")); + dirLineEdit_ = new QLineEdit(this); + QPushButton *browseDirButton = new QPushButton(tr("Browse..")); - horizontalBox1->addWidget(dirLabel); - horizontalBox1->addWidget(dirLineEdit_); - horizontalBox1->addWidget(browseDirButton); + horizontalBox1->addWidget(dirLabel); + horizontalBox1->addWidget(dirLineEdit_); + horizontalBox1->addWidget(browseDirButton); - connect(browseDirButton, SIGNAL(clicked()), - this, SLOT(on_browseDirButtonClicked())); + connect(browseDirButton, SIGNAL(clicked()), + this, SLOT(on_browseDirButtonClicked())); - dialogButtons_ = new QDialogButtonBox(this); - dialogButtons_->setStandardButtons(QDialogButtonBox::Ok - | QDialogButtonBox::Apply - | QDialogButtonBox::Cancel); + dialogButtons_ = new QDialogButtonBox(this); + dialogButtons_->setStandardButtons(QDialogButtonBox::Ok + | QDialogButtonBox::Apply + | QDialogButtonBox::Cancel); - verticalBox->addWidget(dialogButtons_); + verticalBox->addWidget(dialogButtons_); - connect(dialogButtons_, SIGNAL(clicked(QAbstractButton*)), - this, SLOT(on_buttonClicked(QAbstractButton*))); + connect(dialogButtons_, SIGNAL(clicked(QAbstractButton*)), + this, SLOT(on_buttonClicked(QAbstractButton*))); - // Set saved preference values to fields. - ReadSettings(); + // Set saved preference values to fields. + ReadSettings(); } @@ -76,68 +76,67 @@ PreferencesDialog::~PreferencesDialog() // ======================== SLOTS ======================== void PreferencesDialog::on_browseDirButtonClicked() { - QFileDialog *dialog - = new QFileDialog(this, "Download directory", - QString(), tr("Torrent files (*.torrent)")); + QFileDialog *dialog + = new QFileDialog(this, "Download directory", + QString(), tr("Torrent files (*.torrent)")); - dialog->setFileMode(QFileDialog::Directory); - dialog->setOption(QFileDialog::ShowDirsOnly, true); + dialog->setFileMode(QFileDialog::Directory); + dialog->setOption(QFileDialog::ShowDirsOnly, true); - connect(dialog, SIGNAL(fileSelected(const QString&)), - this, SLOT(on_downloadDirectorySelected(const QString&))); + connect(dialog, SIGNAL(fileSelected(const QString&)), + this, SLOT(on_downloadDirectorySelected(const QString&))); - dialog->show(); + dialog->show(); } void PreferencesDialog::on_buttonClicked(QAbstractButton* button) { - switch (dialogButtons_->buttonRole ( button ) ) - { - case QDialogButtonBox::AcceptRole : - qDebug() << "PreferencesDialog: OK"; - WriteSettings(); - close(); - break; - case QDialogButtonBox::ApplyRole : - qDebug() << "PreferencesDialog: APPLY"; - WriteSettings(); - break; - case QDialogButtonBox::RejectRole : - qDebug() << "PreferencesDialog: CANCEL"; - close(); - break; - default: - return; - } + switch (dialogButtons_->buttonRole ( button ) ) { + case QDialogButtonBox::AcceptRole : + qDebug() << "PreferencesDialog: OK"; + WriteSettings(); + close(); + break; + case QDialogButtonBox::ApplyRole : + qDebug() << "PreferencesDialog: APPLY"; + WriteSettings(); + break; + case QDialogButtonBox::RejectRole : + qDebug() << "PreferencesDialog: CANCEL"; + close(); + break; + default: + return; + } } void PreferencesDialog::on_downloadDirectorySelected(const QString& directory) { - qDebug() << "PreferencesDialog::on_downloadDirectorySelected(): " << directory; - // Torrent filename empty, do nothing. - if (directory == "") - return; + qDebug() << "PreferencesDialog::on_downloadDirectorySelected(): " << directory; + // Torrent filename empty, do nothing. + if (directory == "") + return; - dirLineEdit_->insert(directory); + dirLineEdit_->insert(directory); - /// @todo check that user has privileges to write to this directory. + /// @todo check that user has privileges to write to this directory. } // ========================= Private functions ========================== void PreferencesDialog::WriteSettings() { - settings_.setValue("download/directory", dirLineEdit_->text()); + settings_.setValue("download/directory", dirLineEdit_->text()); - // NOTE: We might need to call QSettigns::sync() here to instantly write settings. - // settings are written also by QSettings() destructor and by event loop at regular interval. + // NOTE: We might need to call QSettigns::sync() here to instantly write settings. + // settings are written also by QSettings() destructor and by event loop at regular interval. } void PreferencesDialog::ReadSettings() { - dirLineEdit_->insert(settings_.value("download/directory").toString()); + dirLineEdit_->insert(settings_.value("download/directory").toString()); - // NOTE: We might need to call QSettigns::sync() here to instantly write settings. - // settings are written also by QSettings() destructor and by event loop at regular interval. + // NOTE: We might need to call QSettigns::sync() here to instantly write settings. + // settings are written also by QSettings() destructor and by event loop at regular interval. }