- Added AlertWaiter and QBittorentSession
[qtrapids] / src / gui / MainWindow.cpp
index 7412e5b..9615959 100644 (file)
 
 #include <QDebug>
 
-
+#include <QMenuBar>
 #include <QToolBar>
 #include <QAction>
 #include <QFileDialog>
+#include <QMessageBox>
 
 #include "DownloadView.h"
 #include "SeedView.h"
+#include "AlertWaiterThread.h"
 
 #include "MainWindow.h"
 
 
+const QString ABOUT_TEXT 
+       = QString(QObject::trUtf8("QtRapids, a simple BitTorrent client based on"
+               "\nQt and Libtorrent."
+               "\n\nURL: http://qtrapids.garage.maemo.org/"
+               "\n\nAuthor(s):\nLassi Väätämöinen, lassi.vaatamoinen@ixonos.com"
+               "\n\nIxonos Plc, Finland\n"));
+
+
 
-MainWindow::MainWindow()
+MainWindow::MainWindow():
+       QMainWindow(), // Superclass
+       tabWidget_(NULL),
+       dlView_(NULL),
+       seedView_(NULL)
 {
        
+       // MENUBAR 
+       QMenuBar *menuBar = new QMenuBar();
+       QMenu *tempMenu = NULL;
+       
+       tempMenu = menuBar->addMenu(tr("&File"));
+       tempMenu->addAction(tr("&Open"));
+       
+       tempMenu = menuBar->addMenu(tr("&Help"));
+       QAction *aboutAction = tempMenu->addAction(tr("&About"));
+       QAction *aboutQtAction = tempMenu->addAction(tr("About &Qt"));
+       
+       setMenuBar(menuBar);
+       connect(aboutAction, SIGNAL(triggered()), this, SLOT(on_aboutAction_clicked()));
+       connect(aboutQtAction, SIGNAL(triggered()), this, SLOT(on_aboutQtAction_clicked()));
+       
+       
+       // TABWIDGET (central widget)
        tabWidget_ = new QTabWidget();
        
        /// @todo Exception handling
        dlView_ = new DownloadView(this);
        seedView_ = new SeedView(this);
        
-       tabWidget_->addTab(dlView_, "Downloads");
-       tabWidget_->addTab(seedView_, "Seeds");
+       tabWidget_->addTab(dlView_, tr("Downloads"));
+       tabWidget_->addTab(seedView_, tr("Seeds"));
        
        // Tab widget as central widget.
        setCentralWidget(tabWidget_);
        
+       
+       // TOOLBAR
        QToolBar *toolBar = new QToolBar();
-       toolBar->addAction("Open");
+       toolBar->addAction(tr("Open"));
        
        addToolBar(Qt::TopToolBarArea, toolBar);
-       
        connect(toolBar, SIGNAL(actionTriggered(QAction*)), this, SLOT(handleToolBarAction(QAction*)));
        
+       alertWaiter_ = new AlertWaiterThread(this);
+       connect(alertWaiter_, SIGNAL(alert()), this, SLOT(on_alert()));
+       alertWaiter_->start();
 }
 
 
@@ -63,16 +98,28 @@ MainWindow::~MainWindow()
 }
 
 
+void MainWindow::on_aboutAction_clicked()
+{
+       QMessageBox::about(this, tr("About QtRapids"), ABOUT_TEXT); 
+}
+               
+void MainWindow::on_aboutQtAction_clicked()
+{
+       QMessageBox::aboutQt (this, tr("About Qt"));
+}
+
+
 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 {
        }
-
-
 }
 
+void MainWindow::on_alert()
+{
+       qDebug() << "MainWindow: got alert()";
+}