- Added PreferencesDialog with settings saving and reading.
authorlvaatamoinen <lassi.vaatamoinen@ixonos.com>
Thu, 22 Oct 2009 13:36:53 +0000 (13:36 +0000)
committerlvaatamoinen <lassi.vaatamoinen@ixonos.com>
Thu, 22 Oct 2009 13:36:53 +0000 (13:36 +0000)
- Torrent can now be added to torrent session

git-svn-id: file:///svnroot/qtrapids/trunk@12 42ac0dd5-4c8c-4c71-bb3e-ecdfe252ffda

13 files changed:
qtrapids.kdevelop
src/engine/AlertWaiterThread.cpp
src/engine/AlertWaiterThread.h
src/engine/QBittorrentSession.cpp
src/engine/QBittorrentSession.h
src/engine/QTorrentHandle.cpp
src/engine/QTorrentHandle.h
src/gui/MainWindow.cpp
src/gui/MainWindow.h
src/gui/PreferencesDialog.cpp [new file with mode: 0644]
src/gui/PreferencesDialog.h [new file with mode: 0644]
src/gui/gui.pro
src/gui/main.cpp

index 7e98567..cc9549c 100644 (file)
@@ -14,8 +14,8 @@
     <projectname>qtrapids</projectname>
     <projectdirectory>.</projectdirectory>
     <absoluteprojectpath>false</absoluteprojectpath>
     <projectname>qtrapids</projectname>
     <projectdirectory>.</projectdirectory>
     <absoluteprojectpath>false</absoluteprojectpath>
-    <description></description>
-    <defaultencoding></defaultencoding>
+    <description/>
+    <defaultencoding/>
   </general>
   <kdevfileview>
     <groups>
   </general>
   <kdevfileview>
     <groups>
@@ -67,7 +67,7 @@
       <includePaths>.;</includePaths>
     </codecompletion>
     <creategettersetter>
       <includePaths>.;</includePaths>
     </codecompletion>
     <creategettersetter>
-      <prefixGet></prefixGet>
+      <prefixGet/>
       <prefixSet>set</prefixSet>
       <prefixVariable>m_,_</prefixVariable>
       <parameterName>theValue</parameterName>
       <prefixSet>set</prefixSet>
       <prefixVariable>m_,_</prefixVariable>
       <parameterName>theValue</parameterName>
   </kdevdoctreeview>
   <kdevdebugger>
     <general>
   </kdevdoctreeview>
   <kdevdebugger>
     <general>
-      <dbgshell></dbgshell>
+      <dbgshell/>
       <breakpoints/>
       <programargs/>
       <gdbpath>/usr/bin/gdb</gdbpath>
       <breakonloadinglibs>true</breakonloadinglibs>
       <separatetty>false</separatetty>
       <floatingtoolbar>false</floatingtoolbar>
       <breakpoints/>
       <programargs/>
       <gdbpath>/usr/bin/gdb</gdbpath>
       <breakonloadinglibs>true</breakonloadinglibs>
       <separatetty>false</separatetty>
       <floatingtoolbar>false</floatingtoolbar>
-      <configGdbScript></configGdbScript>
-      <runShellScript></runShellScript>
-      <runGdbScript></runGdbScript>
+      <configGdbScript/>
+      <runShellScript/>
+      <runGdbScript/>
       <raiseGDBOnStart>false</raiseGDBOnStart>
     </general>
     <display>
       <raiseGDBOnStart>false</raiseGDBOnStart>
     </general>
     <display>
   <kdevtrollproject>
     <run>
       <mainprogram>/home/vaatala/Projects/qtrapids/trunk/bin/qtrapids</mainprogram>
   <kdevtrollproject>
     <run>
       <mainprogram>/home/vaatala/Projects/qtrapids/trunk/bin/qtrapids</mainprogram>
-      <programargs></programargs>
+      <programargs/>
       <directoryradio>executable</directoryradio>
       <directoryradio>executable</directoryradio>
-      <globaldebugarguments></globaldebugarguments>
+      <globaldebugarguments/>
       <globalcwd>/home/vaatala/Projects/qtrapids/trunk/bin</globalcwd>
       <useglobalprogram>true</useglobalprogram>
       <terminal>false</terminal>
       <globalcwd>/home/vaatala/Projects/qtrapids/trunk/bin</globalcwd>
       <useglobalprogram>true</useglobalprogram>
       <terminal>false</terminal>
       <runmultiplejobs>false</runmultiplejobs>
       <numberofjobs>1</numberofjobs>
       <dontact>false</dontact>
       <runmultiplejobs>false</runmultiplejobs>
       <numberofjobs>1</numberofjobs>
       <dontact>false</dontact>
-      <makebin></makebin>
+      <makebin/>
       <prio>0</prio>
       <envvars/>
     </make>
       <prio>0</prio>
       <envvars/>
     </make>
index 9b6e741..b5d6e95 100644 (file)
@@ -41,17 +41,29 @@ AlertWaiterThread::~AlertWaiterThread()
 }
 
 
 }
 
 
+void AlertWaiterThread::allAlerts(bool enable)
+{
+       // If all enabled, set all alert cateogries:
+       if (enable) {
+               btSession_->set_alert_mask(libtorrent::alert::all_categories);
+       } else {
+               // Otherwise set to default, which is only error notifications.
+               btSession_->set_alert_mask(libtorrent::alert::error_notification);
+       }
+}
+
+
 void AlertWaiterThread::run()
 {
        TorrentAlert const *alertTemp = NULL;
        while (true)
        {
                qDebug() << "AlertWaiter running";
 void AlertWaiterThread::run()
 {
        TorrentAlert const *alertTemp = NULL;
        while (true)
        {
                qDebug() << "AlertWaiter running";
-               // wait_for_alert() returns libtorrent alert. 
+               // wait_for_alert() call blocks. Returns libtorrent alert. 
                // Returns NULL, if no alerts in timeout period.
                alertTemp = btSession_->wait_for_alert(ALERT_WAIT_TIMEOUT);
                emit alert(alertTemp);
                // Returns NULL, if no alerts in timeout period.
                alertTemp = btSession_->wait_for_alert(ALERT_WAIT_TIMEOUT);
                emit alert(alertTemp);
+               // 2000 us = 2ms. Gives main thread time to handle alert signal.
+               usleep(2000); 
        }
 }
        }
 }
-
-
index 0a2209a..6ab719e 100644 (file)
@@ -36,6 +36,8 @@ class AlertWaiterThread : public QThread
 
     virtual ~AlertWaiterThread();
 
 
     virtual ~AlertWaiterThread();
 
+               void allAlerts(bool enable = true);
+               
                virtual void run(); // Overridden from QThread
                
        signals:
                virtual void run(); // Overridden from QThread
                
        signals:
index 4cefcec..e0d6c5c 100644 (file)
@@ -30,6 +30,7 @@ QBittorrentSession::QBittorrentSession(QObject *parent):
                alertWaiter_(NULL)
 {
        alertWaiter_ = new AlertWaiterThread(&btSession_, this);
                alertWaiter_(NULL)
 {
        alertWaiter_ = new AlertWaiterThread(&btSession_, this);
+       alertWaiter_->allAlerts();
        connect(alertWaiter_, SIGNAL(alert(TorrentAlert const*)), this, SLOT(on_alert(TorrentAlert const*)));
        alertWaiter_->start();
 }
        connect(alertWaiter_, SIGNAL(alert(TorrentAlert const*)), this, SLOT(on_alert(TorrentAlert const*)));
        alertWaiter_->start();
 }
@@ -44,15 +45,23 @@ QTorrentHandle QBittorrentSession::addTorrent(AddTorrentParams const& params)
 {
        // Delegate to Libtorrent and return QTorrentHandle.
        QTorrentHandle handle(btSession_.add_torrent(params));
 {
        // Delegate to Libtorrent and return QTorrentHandle.
        QTorrentHandle handle(btSession_.add_torrent(params));
+       qDebug() << "Is valid: " << handle.isValid();
        return handle;
 }
 
 
 // ========================== SLOTS ==============================
        return handle;
 }
 
 
 // ========================== SLOTS ==============================
-void QBittorrentSession::on_alert(TorrentAlert const *al)
+void QBittorrentSession::on_alert(TorrentAlert const *al) 
+               //NOTE: al parameter not necessarily needed here, as we pop_alert() now!
 {
 {
+       
        qDebug() << "QBittorrentSession:on_alert(" << al << ")";
        qDebug() << "QBittorrentSession:on_alert(" << al << ")";
-       emit alert(al);
+//     if (al)
+//             qDebug() << "on_alert():" << QString::fromStdString(al->message());
+       
+       
+       std::auto_ptr<TorrentAlert> alertPtr = btSession_.pop_alert();
+       emit alert(alertPtr);
 }
 
 
 }
 
 
index 82665b4..a6b6ac2 100644 (file)
 #ifndef QBITTORRENTSESSION_H
 #define QBITTORRENTSESSION_H
 
 #ifndef QBITTORRENTSESSION_H
 #define QBITTORRENTSESSION_H
 
+#include <memory>
+
 #include <QObject>
 
 #include <libtorrent/session.hpp>
 #include <QObject>
 
 #include <libtorrent/session.hpp>
+#include <libtorrent/torrent_info.hpp>
 
 #include "QTorrentHandle.h"
 
 
 #include "QTorrentHandle.h"
 
@@ -49,7 +52,7 @@ class QBittorrentSession : public QObject {
                QTorrentHandle addTorrent(AddTorrentParams const& params);
                
        signals:
                QTorrentHandle addTorrent(AddTorrentParams const& params);
                
        signals:
-               void alert(TorrentAlert const *al);
+               void alert(std::auto_ptr<TorrentAlert> al);
                
        private slots:
                void on_alert(TorrentAlert const *al);
                
        private slots:
                void on_alert(TorrentAlert const *al);
index 2b87b78..1be0bf1 100644 (file)
  *   Free Software Foundation, Inc.,                                       *
  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
  ***************************************************************************/
  *   Free Software Foundation, Inc.,                                       *
  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
  ***************************************************************************/
+#include <QDebug>
+
 #include "QTorrentHandle.h"
 
 QTorrentHandle::QTorrentHandle(libtorrent::torrent_handle handle) : 
 #include "QTorrentHandle.h"
 
 QTorrentHandle::QTorrentHandle(libtorrent::torrent_handle handle) : 
-               torrentHandle(handle)
+               torrentHandle_(handle)
 {
 }
 
 {
 }
 
@@ -29,4 +31,9 @@ QTorrentHandle::~QTorrentHandle()
 {
 }
 
 {
 }
 
+bool QTorrentHandle::isValid() const
+{
+       return torrentHandle_.is_valid();
+}
+
 
 
index f4238c8..14d969b 100644 (file)
@@ -34,10 +34,11 @@ class QTorrentHandle
                QTorrentHandle(libtorrent::torrent_handle handle);
     ~QTorrentHandle();
                
                QTorrentHandle(libtorrent::torrent_handle handle);
     ~QTorrentHandle();
                
+               bool isValid() const;
                
        private:
                QTorrentHandle(); // Prevent default construct.
                
        private:
                QTorrentHandle(); // Prevent default construct.
-               libtorrent::torrent_handle torrentHandle;
+               libtorrent::torrent_handle torrentHandle_;
                
 };
 
                
 };
 
index f5e6036..972e89a 100644 (file)
@@ -29,6 +29,7 @@
 
 #include "DownloadView.h"
 #include "SeedView.h"
 
 #include "DownloadView.h"
 #include "SeedView.h"
+#include "PreferencesDialog.h"
 
 #include "MainWindow.h"
 
 
 #include "MainWindow.h"
 
@@ -47,6 +48,8 @@ MainWindow::MainWindow():
        tabWidget_(NULL),
        dlView_(NULL),
        seedView_(NULL),
        tabWidget_(NULL),
        dlView_(NULL),
        seedView_(NULL),
+       preferencesDialog_(NULL),
+       settings_(),                                                                     
        btSession_()                                    
 {
        // MENUBAR 
        btSession_()                                    
 {
        // MENUBAR 
@@ -57,6 +60,9 @@ MainWindow::MainWindow():
        QAction *openAction = tempMenu->addAction(tr("&Open"));
        QAction *quitAction = tempMenu->addAction(tr("&Quit"));
        
        QAction *openAction = tempMenu->addAction(tr("&Open"));
        QAction *quitAction = tempMenu->addAction(tr("&Quit"));
        
+       tempMenu = menuBar->addMenu(tr("&Settings"));
+       QAction *preferencesAction = tempMenu->addAction(tr("&Preferences"));
+       
        tempMenu = menuBar->addMenu(tr("&Help"));
        QAction *aboutAction = tempMenu->addAction(tr("&About"));
        QAction *aboutQtAction = tempMenu->addAction(tr("About &Qt"));
        tempMenu = menuBar->addMenu(tr("&Help"));
        QAction *aboutAction = tempMenu->addAction(tr("&About"));
        QAction *aboutQtAction = tempMenu->addAction(tr("About &Qt"));
@@ -64,10 +70,10 @@ MainWindow::MainWindow():
                setMenuBar(menuBar);
        connect(openAction, SIGNAL(triggered()), this, SLOT(on_openAction_clicked()));
        connect(quitAction, SIGNAL(triggered()), this, SLOT(on_quitAction_clicked()));
                setMenuBar(menuBar);
        connect(openAction, SIGNAL(triggered()), this, SLOT(on_openAction_clicked()));
        connect(quitAction, SIGNAL(triggered()), this, SLOT(on_quitAction_clicked()));
+       connect(preferencesAction, SIGNAL(triggered()), this, SLOT(on_preferencesAction_clicked()));
        connect(aboutAction, SIGNAL(triggered()), this, SLOT(on_aboutAction_clicked()));
        connect(aboutQtAction, SIGNAL(triggered()), this, SLOT(on_aboutQtAction_clicked()));
        
        connect(aboutAction, SIGNAL(triggered()), this, SLOT(on_aboutAction_clicked()));
        connect(aboutQtAction, SIGNAL(triggered()), this, SLOT(on_aboutQtAction_clicked()));
        
-       
        // TABWIDGET (central widget)
        tabWidget_ = new QTabWidget();
        
        // TABWIDGET (central widget)
        tabWidget_ = new QTabWidget();
        
@@ -112,6 +118,15 @@ void MainWindow::on_quitAction_clicked()
        close();
 }
 
        close();
 }
 
+void MainWindow::on_preferencesAction_clicked()
+{
+       if (!preferencesDialog_) {
+               preferencesDialog_ = new PreferencesDialog(this);
+       }
+       preferencesDialog_->show();
+       preferencesDialog_->raise();
+       preferencesDialog_->activateWindow();
+}
 
 void MainWindow::on_aboutAction_clicked()
 {
 
 void MainWindow::on_aboutAction_clicked()
 {
@@ -142,12 +157,12 @@ void MainWindow::on_torrentFileSelected(const QString& file)
        }
        
        // Otherwise add torrent
        }
        
        // Otherwise add torrent
-       /*      
        // For params, see: http://www.rasterbar.com/products/libtorrent/manual.html#add-torrent
        AddTorrentParams addParams;
        // For params, see: http://www.rasterbar.com/products/libtorrent/manual.html#add-torrent
        AddTorrentParams addParams;
-       addParams.ti = torrent_info(boost::filesystem::path const& filename);
-       addParams.save_path = "/home/vaatala/Downloads"; // The only mandatory parameter, rest are optional.
+       boost::intrusive_ptr<libtorrent::torrent_info> tiTmp = 
+                       new libtorrent::torrent_info(boost::filesystem::path(file.toStdString()));
+       addParams.ti = tiTmp;
+       addParams.save_path = boost::filesystem::path(settings_.value("download/directory").toString().toStdString()); // The only mandatory parameter, rest are optional.
        //addParams.storage_mode = libtorrent::storage_mode_allocate;
        //addParams.storage_mode = libtorrent::storage_mode_allocate;
-       btSession_.addTorrent();
-       */
+       btSession_.addTorrent(addParams);
 }
 }
index 1b1155e..e64dfc1 100644 (file)
 #define MAINWINDOW_H
 
 #include <QMainWindow>
 #define MAINWINDOW_H
 
 #include <QMainWindow>
+#include <QSettings>
 
 #include "QBittorrentSession.h"
 
 class QTabWidget;
 class DownloadView;
 class SeedView;
 
 #include "QBittorrentSession.h"
 
 class QTabWidget;
 class DownloadView;
 class SeedView;
-
+class PreferencesDialog;
 
 /**
        @author Lassi Väätämöinen <lassi.vaatamoinen@ixonos.com>
 
 /**
        @author Lassi Väätämöinen <lassi.vaatamoinen@ixonos.com>
@@ -44,6 +45,7 @@ class MainWindow : public QMainWindow {
        private slots:
                void on_openAction_clicked();
                void on_quitAction_clicked();
        private slots:
                void on_openAction_clicked();
                void on_quitAction_clicked();
+               void on_preferencesAction_clicked();
                void on_aboutAction_clicked();
                void on_aboutQtAction_clicked();
                void handleToolBarAction(QAction* action);
                void on_aboutAction_clicked();
                void on_aboutQtAction_clicked();
                void handleToolBarAction(QAction* action);
@@ -53,6 +55,8 @@ class MainWindow : public QMainWindow {
                QTabWidget *tabWidget_;
                DownloadView *dlView_;
                SeedView *seedView_;
                QTabWidget *tabWidget_;
                DownloadView *dlView_;
                SeedView *seedView_;
+               PreferencesDialog *preferencesDialog_;
+               QSettings settings_;
                
                QBittorrentSession btSession_;
                
                
                QBittorrentSession btSession_;
                
diff --git a/src/gui/PreferencesDialog.cpp b/src/gui/PreferencesDialog.cpp
new file mode 100644 (file)
index 0000000..9ee381b
--- /dev/null
@@ -0,0 +1,143 @@
+/***************************************************************************
+ *   Copyright (C) 2009 by Lassi Väätämöinen   *
+ *   lassi.vaatamoinen@ixonos.com   *
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) any later version.                                   *
+ *                                                                         *
+ *   This program is distributed in the hope that it will be useful,       *
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ *   GNU General Public License for more details.                          *
+ *                                                                         *
+ *   You should have received a copy of the GNU General Public License     *
+ *   along with this program; if not, write to the                         *
+ *   Free Software Foundation, Inc.,                                       *
+ *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+ ***************************************************************************/
+#include <QDebug>
+#include <QBoxLayout>
+#include <QLineEdit>
+#include <QLabel>
+#include <QPushButton>
+#include <QDialogButtonBox>
+#include <QAbstractButton>
+#include <QFileDialog>
+
+#include "PreferencesDialog.h"
+
+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); 
+       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()));
+       
+       
+       dialogButtons_ = new QDialogButtonBox(this);
+       dialogButtons_->setStandardButtons(QDialogButtonBox::Ok
+                                                                                                                                                       | QDialogButtonBox::Apply 
+                                                                                                                                                       | QDialogButtonBox::Cancel);
+       
+       verticalBox->addWidget(dialogButtons_);
+       
+       connect(dialogButtons_, SIGNAL(clicked(QAbstractButton*)),
+                                       this, SLOT(on_buttonClicked(QAbstractButton*)));
+       
+       // Set saved preference values to fields.
+       ReadSettings();
+       
+}
+
+
+PreferencesDialog::~PreferencesDialog()
+{
+}
+
+// ======================== SLOTS ========================
+void PreferencesDialog::on_browseDirButtonClicked()
+{
+       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&)));
+       
+       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;
+       }
+}
+
+void PreferencesDialog::on_downloadDirectorySelected(const QString& directory)
+{
+       qDebug() << "PreferencesDialog::on_downloadDirectorySelected(): " << directory;
+       // Torrent filename empty, do nothing.
+       if (directory == "") 
+               return;
+       
+       dirLineEdit_->insert(directory);
+       
+       /// @todo check that user has privileges to write to this directory.
+}
+
+
+// ========================= Private functions ==========================
+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.
+}
+
+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.
+}
+
diff --git a/src/gui/PreferencesDialog.h b/src/gui/PreferencesDialog.h
new file mode 100644 (file)
index 0000000..c368ea0
--- /dev/null
@@ -0,0 +1,59 @@
+/***************************************************************************
+ *   Copyright (C) 2009 by Lassi Väätämöinen   *
+ *   lassi.vaatamoinen@ixonos.com   *
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) any later version.                                   *
+ *                                                                         *
+ *   This program is distributed in the hope that it will be useful,       *
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ *   GNU General Public License for more details.                          *
+ *                                                                         *
+ *   You should have received a copy of the GNU General Public License     *
+ *   along with this program; if not, write to the                         *
+ *   Free Software Foundation, Inc.,                                       *
+ *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+ ***************************************************************************/
+#ifndef PREFERENCESDIALOG_H
+#define PREFERENCESDIALOG_H
+
+#include <QDialog>
+#include <QSettings>
+
+
+class QAbstractButton;
+class QLineEdit;
+class QDialogButtonBox;
+
+/**
+       @author Lassi Väätämöinen <lassi.vaatamoinen@ixonos.com>
+*/
+class PreferencesDialog : public QDialog
+{
+       
+       Q_OBJECT
+               
+       public:
+    PreferencesDialog(QWidget* parent = 0, Qt::WindowFlags f = 0);
+
+    ~PreferencesDialog();
+
+       private slots:
+               void on_browseDirButtonClicked();
+               void on_buttonClicked(QAbstractButton* button);
+               void on_downloadDirectorySelected(const QString& directory);
+               
+       private:
+               QLineEdit *dirLineEdit_;
+               QDialogButtonBox *dialogButtons_;
+               QSettings settings_;
+               
+               // Private functions:
+               void WriteSettings();
+               void ReadSettings();
+};
+
+#endif
index daa701a..9c23ca1 100644 (file)
@@ -1,10 +1,12 @@
 SOURCES += DownloadView.cpp \
 MainWindow.cpp \
 SeedView.cpp \
 SOURCES += DownloadView.cpp \
 MainWindow.cpp \
 SeedView.cpp \
- main.cpp
+ main.cpp \
+ PreferencesDialog.cpp
 HEADERS += DownloadView.h \
 MainWindow.h \
 HEADERS += DownloadView.h \
 MainWindow.h \
-SeedView.h
+SeedView.h \
+ PreferencesDialog.h
 TEMPLATE = app
 
 TARGET = qtrapids
 TEMPLATE = app
 
 TARGET = qtrapids
index 25426e8..2538271 100644 (file)
 int main(int argc, char *argv[])
 {
        
 int main(int argc, char *argv[])
 {
        
+       QCoreApplication::setOrganizationName("Ixonos");
+       QCoreApplication::setOrganizationDomain("ixonos.com");
+       QCoreApplication::setApplicationName("QtRapids");
        
        
-     // Q_INIT_RESOURCE(application);
+  // Q_INIT_RESOURCE(application);
        QApplication app(argc, argv);
        MainWindow *mainWindow = new MainWindow();
        mainWindow->show();
        QApplication app(argc, argv);
        MainWindow *mainWindow = new MainWindow();
        mainWindow->show();