#include <QFileDialog>
#include <QMessageBox>
#include <QApplication>
-
+#include <QPluginLoader>
#include "DownloadView.h"
#include "SeedView.h"
{
}
+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");
dialog->setFileMode(QFileDialog::ExistingFile);
connect(dialog, SIGNAL(fileSelected(const QString&)), this, SLOT(on_torrentFileSelected(const QString&)));
dialog->show();
-
}
void MainWindow::on_removeAction_clicked()