#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\nAuthors:\nLassi Väätämöinen, lassi.vaatamoinen@ixonos.com"
- "\nDenis Zalevskiy, denis.zalewsky@ixonos.com"
- "\n\nIxonos Plc, Finland\n"));
+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\nAuthors:\nLassi Väätämöinen, lassi.vaatamoinen@ixonos.com"
+ "\nDenis Zalevskiy, denis.zalewsky@ixonos.com"
+ "\n\nIxonos Plc, Finland\n"));
// Consturctor
MainWindow::MainWindow():
// torrentHandles_(),
btSession_()
{
- // MENUBAR
- QMenuBar *menuBar = new QMenuBar();
- QMenu *tempMenu = NULL;
-
- tempMenu = menuBar->addMenu(tr("&File"));
- QAction *openAction = tempMenu->addAction(tr("&Open"));
- QAction *removeAction = tempMenu->addAction(tr("&Remove"));
- removeAction->setEnabled(false);
- 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"));
-
- setMenuBar(menuBar);
- connect(openAction, SIGNAL(triggered()), this, SLOT(on_openAction_clicked()));
- connect(removeAction, SIGNAL(triggered()), this, SLOT(on_removeAction_clicked()));
- connect(this, SIGNAL(itemSelected(bool)), removeAction, SLOT(setEnabled(bool)));
- 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()));
-
- // TABWIDGET (central widget)
- tabWidget_ = new QTabWidget();
- tabWidget_->setTabsClosable(true);
-
- /// @todo Exception handling
- dlView_ = new DownloadView(this);
- seedView_ = new SeedView(this);
- tabWidget_->addTab(dlView_, tr("Downloads"));
- tabWidget_->addTab(seedView_, tr("Seeds"));
- connect(dlView_, SIGNAL(itemSelectionChanged()), this,
- SLOT(on_downloadItemSelectionChanged()));
- connect(seedView_, SIGNAL(itemSelectionChanged()), this,
- SLOT(on_seedItemSelectionChanged()));
-
-
- // Tab widget as central widget.
- setCentralWidget(tabWidget_);
-
- // TOOLBAR
- QToolBar *toolBar = new QToolBar();
- toolBar->addAction(tr("Open"));
- removeAction = toolBar->addAction(tr("Remove"));
- removeAction->setEnabled(false);
- addToolBar(Qt::TopToolBarArea, toolBar);
-
- connect(this, SIGNAL(itemSelected(bool)), removeAction,
- SLOT(setEnabled(bool)));
- connect(toolBar, SIGNAL(actionTriggered(QAction*)), this,
- SLOT(handleToolBarAction(QAction*)));
-
- connect(&btSession_, SIGNAL(alert(std::auto_ptr<Alert>)),
- this, SLOT(on_alert(std::auto_ptr<Alert>)));
-
- LoadPlugins();
+ // MENUBAR
+ QMenuBar *menuBar = new QMenuBar();
+ QMenu *tempMenu = NULL;
+
+ tempMenu = menuBar->addMenu(tr("&File"));
+ QAction *openAction = tempMenu->addAction(tr("&Open"));
+ QAction *removeAction = tempMenu->addAction(tr("&Remove"));
+ removeAction->setEnabled(false);
+ 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"));
+
+ setMenuBar(menuBar);
+ connect(openAction, SIGNAL(triggered()), this, SLOT(on_openAction_clicked()));
+ connect(removeAction, SIGNAL(triggered()), this, SLOT(on_removeAction_clicked()));
+ connect(this, SIGNAL(itemSelected(bool)), removeAction, SLOT(setEnabled(bool)));
+ 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()));
+
+ // TABWIDGET (central widget)
+ tabWidget_ = new QTabWidget();
+ tabWidget_->setTabsClosable(true);
+
+ /// @todo Exception handling
+ dlView_ = new DownloadView(this);
+ seedView_ = new SeedView(this);
+ tabWidget_->addTab(dlView_, tr("Downloads"));
+ tabWidget_->addTab(seedView_, tr("Seeds"));
+ connect(dlView_, SIGNAL(itemSelectionChanged()), this,
+ SLOT(on_downloadItemSelectionChanged()));
+ connect(seedView_, SIGNAL(itemSelectionChanged()), this,
+ SLOT(on_seedItemSelectionChanged()));
+
+
+ // Tab widget as central widget.
+ setCentralWidget(tabWidget_);
+
+ // TOOLBAR
+ QToolBar *toolBar = new QToolBar();
+ toolBar->addAction(tr("Open"));
+ removeAction = toolBar->addAction(tr("Remove"));
+ removeAction->setEnabled(false);
+ addToolBar(Qt::TopToolBarArea, toolBar);
+
+ connect(this, SIGNAL(itemSelected(bool)), removeAction,
+ SLOT(setEnabled(bool)));
+ connect(toolBar, SIGNAL(actionTriggered(QAction*)), this,
+ SLOT(handleToolBarAction(QAction*)));
+
+ connect(&btSession_, SIGNAL(alert(std::auto_ptr<Alert>)),
+ this, SLOT(on_alert(std::auto_ptr<Alert>)));
+
+ LoadPlugins();
}
bool MainWindow::setGui(qtrapids::PluginInterface* from, QWidget* widget)
{
#ifdef QTRAPIDS_DEBUG
- qDebug() << "MainWindow::setGui():" << dlView_->currentItem();
+ qDebug() << "MainWindow::setGui():" << dlView_->currentItem();
#endif
- tabWidget_->addTab(widget, tr("Search"));
- return true;
+ tabWidget_->addTab(widget, tr("Search"));
+ return true;
}
/// @todo Add PluginInterface parameter check which plugin gives the widget to handle appropriately
void MainWindow::addPluginWidget(qtrapids::PluginInterface* from, QWidget* widget)
{
#ifdef QTRAPIDS_DEBUG
- qDebug() << "MainWindow::addPluginWidget():" << dlView_->currentItem();
+ qDebug() << "MainWindow::addPluginWidget():" << dlView_->currentItem();
#endif
-
- int index = tabWidget_->addTab(widget, tr("Test"));
- tabWidget_->setCurrentIndex(index);
- //layout_->addWidget(widget);
+
+ int index = tabWidget_->addTab(widget, tr("Test"));
+ tabWidget_->setCurrentIndex(index);
+ //layout_->addWidget(widget);
}
void MainWindow::addToolbar(qtrapids::PluginInterface* from, QWidget* widget)
void MainWindow::LoadPlugins()
{
- /// @todo get plugin directory from settings or go through multiple diectories
- /// Now we only check the application directory
- pluginsDir_ = QDir(qApp->applicationDirPath());
- pluginsDir_.cd("plugins");
- QStringList nameFilters;
- nameFilters << "*.so";
-
- foreach (QString fileName, pluginsDir_.entryList(nameFilters, QDir::Files)) {
- QPluginLoader pluginLoader(pluginsDir_.absoluteFilePath(fileName));
-
- if (!QLibrary::isLibrary(fileName)) {
- qDebug() << fileName << " not a library";
- }
-
- if (pluginLoader.load()) {
- qDebug() << "Plugin loaded: " << fileName;
- } else {
- qDebug() << "Plugin load failed: " << pluginLoader.errorString();
- }
-
- QObject *baseInstance = pluginLoader.instance();
- if (!baseInstance) {
- qDebug() << "Base instance = NULL.";
- }
-
- qtrapids::PluginInterface *plugin = qobject_cast<qtrapids::PluginInterface*>(baseInstance);
-
- if (!plugin) {
- qDebug() << "Cast failed.";
- } else {
- plugin->initialize(this);
- pluginFileNames_ += fileName;
- }
-
+ /// @todo get plugin directory from settings or go through multiple diectories
+ /// Now we only check the application directory
+ pluginsDir_ = QDir(qApp->applicationDirPath());
+ pluginsDir_.cd("plugins");
+ QStringList nameFilters;
+ nameFilters << "*.so";
+
+ foreach (QString fileName, pluginsDir_.entryList(nameFilters, QDir::Files))
+ {
+ QPluginLoader pluginLoader(pluginsDir_.absoluteFilePath(fileName));
+
+ if (!QLibrary::isLibrary(fileName))
+ {
+ qDebug() << fileName << " not a library";
+ }
+
+ if (pluginLoader.load())
+ {
+ qDebug() << "Plugin loaded: " << fileName;
+ }
+ else
+ {
+ qDebug() << "Plugin load failed: " << pluginLoader.errorString();
+ }
+
+ QObject *baseInstance = pluginLoader.instance();
+ if (!baseInstance)
+ {
+ qDebug() << "Base instance = NULL.";
+ }
+
+ qtrapids::PluginInterface *plugin = qobject_cast<qtrapids::PluginInterface*>(baseInstance);
+
+ if (!plugin)
+ {
+ qDebug() << "Cast failed.";
+ }
+ else
+ {
+ plugin->initialize(this);
+ pluginFileNames_ += fileName;
+ }
+
// QObject *plugin = pluginLoader.instance();
// if (plugin) {
// populateMenus(plugin);
// pluginFileNames += fileName;
// }
- }
-
- //pluginLoader_.setFileName("../libsearchplugin.so");
-
+ }
+
+ //pluginLoader_.setFileName("../libsearchplugin.so");
+
+
-
}