- Initial GUI: Main window with two tabs, torrent file open dialog.
[qtrapids] / src / gui / MainWindow.cpp
index bbd5433..7412e5b 100644 (file)
  *   Free Software Foundation, Inc.,                                       *
  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
  ***************************************************************************/
+
+
+#include <QDebug>
+
+
+#include <QToolBar>
+#include <QAction>
+#include <QFileDialog>
+
+#include "DownloadView.h"
+#include "SeedView.h"
+
 #include "MainWindow.h"
 
+
+
 MainWindow::MainWindow()
 {
+       
+       tabWidget_ = new QTabWidget();
+       
+       /// @todo Exception handling
+       dlView_ = new DownloadView(this);
+       seedView_ = new SeedView(this);
+       
+       tabWidget_->addTab(dlView_, "Downloads");
+       tabWidget_->addTab(seedView_, "Seeds");
+       
+       // Tab widget as central widget.
+       setCentralWidget(tabWidget_);
+       
+       QToolBar *toolBar = new QToolBar();
+       toolBar->addAction("Open");
+       
+       addToolBar(Qt::TopToolBarArea, toolBar);
+       
+       connect(toolBar, SIGNAL(actionTriggered(QAction*)), this, SLOT(handleToolBarAction(QAction*)));
+       
 }
 
 
@@ -29,3 +63,16 @@ MainWindow::~MainWindow()
 }
 
 
+void MainWindow::handleToolBarAction(QAction* action)
+{
+       
+       if (action->text() == "Open") {
+               QFileDialog *dialog = new QFileDialog( this, "Open torrent file", QString(), tr("Torrent files (*.torrent)"));
+               dialog->setFileMode(QFileDialog::ExistingFile);
+               dialog->show();
+       } else {
+       }
+
+
+}
+