formatting is changed according to last astyle settings
[qtrapids] / src / gui / PreferencesDialog.cpp
index 9ee381b..e541e90 100644 (file)
 
 #include "PreferencesDialog.h"
 
-PreferencesDialog::PreferencesDialog(QWidget* parent, Qt::WindowFlags f) : 
-       QDialog(parent, f), // Superclass
-       dirLineEdit_(NULL),
-       dialogButtons_(NULL),
-       settings_()
+PreferencesDialog::PreferencesDialog(QWidget* parent, Qt::WindowFlags f) :
+               QDialog(parent, f), // Superclass
+               dirLineEdit_(NULL),
+               dialogButtons_(NULL),
+               settings_()
 {
        setWindowTitle("Preferences");
-       
+
        QBoxLayout *verticalBox = new QBoxLayout(QBoxLayout::TopToBottom);
        QBoxLayout *horizontalBox1 = new QBoxLayout(QBoxLayout::LeftToRight);
-       setLayout(verticalBox); 
+       setLayout(verticalBox);
        verticalBox->addLayout(horizontalBox1);
 
        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);
-       
+
        connect(browseDirButton, SIGNAL(clicked()),
-                                       this, SLOT(on_browseDirButtonClicked()));
-       
-       
+               this, SLOT(on_browseDirButtonClicked()));
+
+
        dialogButtons_ = new QDialogButtonBox(this);
        dialogButtons_->setStandardButtons(QDialogButtonBox::Ok
-                                                                                                                                                       | QDialogButtonBox::Apply 
-                                                                                                                                                       | QDialogButtonBox::Cancel);
-       
+                                          | QDialogButtonBox::Apply
+                                          | QDialogButtonBox::Cancel);
+
        verticalBox->addWidget(dialogButtons_);
-       
+
        connect(dialogButtons_, SIGNAL(clicked(QAbstractButton*)),
-                                       this, SLOT(on_buttonClicked(QAbstractButton*)));
-       
+               this, SLOT(on_buttonClicked(QAbstractButton*)));
+
        // Set saved preference values to fields.
        ReadSettings();
-       
+
 }
 
 
@@ -76,38 +76,37 @@ 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);
-       
+
        connect(dialog, SIGNAL(fileSelected(const QString&)),
-                                       this, SLOT(on_downloadDirectorySelected(const QString&)));
-       
+               this, SLOT(on_downloadDirectorySelected(const QString&)));
+
        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;
        }
 }
 
@@ -115,11 +114,11 @@ void PreferencesDialog::on_downloadDirectorySelected(const QString& directory)
 {
        qDebug() << "PreferencesDialog::on_downloadDirectorySelected(): " << directory;
        // Torrent filename empty, do nothing.
-       if (directory == "") 
+       if (directory == "")
                return;
-       
+
        dirLineEdit_->insert(directory);
-       
+
        /// @todo check that user has privileges to write to this directory.
 }
 
@@ -128,7 +127,7 @@ void PreferencesDialog::on_downloadDirectorySelected(const QString& directory)
 void PreferencesDialog::WriteSettings()
 {
        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.
 }
@@ -136,7 +135,7 @@ void PreferencesDialog::WriteSettings()
 void PreferencesDialog::ReadSettings()
 {
        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.
 }