X-Git-Url: http://vcs.maemo.org/git/?a=blobdiff_plain;f=src%2Fgui%2FMainWindow.cpp;h=884ced03a3b00801cb86406af5ff60a9f6b10ff0;hb=5032546701da06d7307fc543d74be93e5319c350;hp=7eca355e91c578f101d42086a0a3cf873b030046;hpb=d843508b9e84901695a6f72152d5366ebd957ad6;p=qtrapids diff --git a/src/gui/MainWindow.cpp b/src/gui/MainWindow.cpp index 7eca355..884ced0 100644 --- a/src/gui/MainWindow.cpp +++ b/src/gui/MainWindow.cpp @@ -27,7 +27,7 @@ #include #include #include - +#include #include "DownloadView.h" #include "SeedView.h" @@ -160,11 +160,38 @@ void MainWindow::addMenuItem(QWidget* widget, PluginWidgetType type) { } +bool MainWindow::eventRequest(QVariant param, PluginRequest req) +{ + if (req == qtrapids::PluginHostInterface::OPEN_FILE) { + QString sourceFile = param.toString(); + + // Get the source files name from the full path: + QFileInfo fInfo(sourceFile); + QString targetFile = fInfo.fileName(); + targetFile = settings_.value("download/directory").toString() + targetFile; + + // Copy temoporary file to Downloads directory... + if (!QFile::copy(sourceFile, targetFile)) { + qDebug() << "File copying failed"; + return false; + } else { + // If copying was successful, remove the original temporary file. + QFile::remove(sourceFile); + } + + // ...and start the torrent: + on_torrentFileSelected(targetFile); + } + + return true; +} + + //=========================== PRIVATE ================================ void MainWindow::LoadPlugins() { - /// @todo get plugin directory from settings or go through multiple diectories + /// @todo get plugin directory from settings or go through multiple directories /// Now we only check the application directory pluginsDir_ = QDir(qApp->applicationDirPath()); pluginsDir_.cd("plugins"); @@ -207,7 +234,6 @@ void MainWindow::on_openAction_clicked() dialog->setFileMode(QFileDialog::ExistingFile); connect(dialog, SIGNAL(fileSelected(const QString&)), this, SLOT(on_torrentFileSelected(const QString&))); dialog->show(); - } void MainWindow::on_removeAction_clicked()