summaryrefslogtreecommitdiffstats
path: root/torrentwidget.cpp
diff options
context:
space:
mode:
authorArno <arno@disconnect.de>2016-09-05 02:57:54 +0200
committerArno <arno@disconnect.de>2016-09-05 02:57:54 +0200
commit2e65f581c67d75a2355de4c3906c0d862e0a9ab0 (patch)
treec13885aedde18c80155e41771aafbade6079efc3 /torrentwidget.cpp
parent31847fb5125a60d8f54853f96205836790271ca3 (diff)
downloadShemovCleaner-2e65f581c67d75a2355de4c3906c0d862e0a9ab0.tar.gz
ShemovCleaner-2e65f581c67d75a2355de4c3906c0d862e0a9ab0.tar.bz2
ShemovCleaner-2e65f581c67d75a2355de4c3906c0d862e0a9ab0.zip
Make actions local
Define actions in their respective Widgets instead of MainWindow and fix the menus and toolbars accordingly.
Diffstat (limited to 'torrentwidget.cpp')
-rw-r--r--torrentwidget.cpp62
1 files changed, 60 insertions, 2 deletions
diff --git a/torrentwidget.cpp b/torrentwidget.cpp
index a6cb2f4..f4619f1 100644
--- a/torrentwidget.cpp
+++ b/torrentwidget.cpp
@@ -22,12 +22,11 @@
#include <QClipboard>
#include <QApplication>
-#include <QDebug>
-
#include "torrentwidget.h"
#include "filesorter.h"
#include "torrentparser.h"
#include "torrentdisplay.h"
+#include "globals.h"
TorrentWidget::TorrentWidget(QWidget *parent) : QWidget(parent), mExt("*.torrent") {
setupGui();
@@ -85,9 +84,62 @@ void TorrentWidget::setupGui(){
mTorrentDisplay = new TorrentDisplay(this);
connect(mFileView->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), this, SLOT(fileSelectionChanged(QItemSelection,QItemSelection)));
+ createActions();
connect(mFileView, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(torrentInfo()));
}
+void TorrentWidget::createActions(){
+ mRefreshA = new QAction(QIcon(":/refresh.png"), tr("Refresh"), this);
+ mRefreshA->setShortcut(tr("CTRL+R"));
+ connect(mRefreshA, SIGNAL(triggered()), this, SLOT(gatherData()));
+ mDeleteA = new QAction(QIcon(":/delete.png"), tr("Delete..."), this);
+ mDeleteA->setShortcut(Qt::Key_Delete);
+ connect(mDeleteA, SIGNAL(triggered()), this, SLOT(deleteFiles()));
+ mMoveA = new QAction(QIcon(":/diaper.png"), tr("Move..."), this);
+ mMoveA->setShortcut(tr("CTRL+M"));
+ connect(mMoveA, SIGNAL(triggered()), this, SLOT(moveFiles()));
+ mTorrentInfoA = new QAction(QIcon(":/huge_bra.png"), tr("Torrent Info..."), this);
+ mTorrentInfoA->setShortcut(Qt::Key_Return);
+ connect(mTorrentInfoA, SIGNAL(triggered()), this, SLOT(torrentInfo()));
+ mSelDirA = new QAction(QIcon(":/folder.png"), tr("Select folder..."), this);
+ mSelDirA->setShortcut(tr("CTRL+O"));
+ connect(mSelDirA, SIGNAL(triggered()), this, SLOT(selectDir()));
+ mCopyFnToClipA = new QAction(QIcon(":/edit-copy.png"), tr("Filename to Clip"), this);
+ mCopyFnToClipA->setShortcut(tr("CTRL+C"));
+ connect(mCopyFnToClipA, SIGNAL(triggered()), this, SLOT(copyToClipboard()));
+
+ QMenu *fileMenu = new QMenu(tr("&File"));
+ fileMenu->addAction(mSelDirA);
+ fileMenu->addAction(mRefreshA);
+ fileMenu->addSeparator();
+ fileMenu->addAction(Globals::instance()->action(Globals::QuitAction));
+
+ QMenu *editMenu = new QMenu(tr("&Edit"));
+ editMenu->addAction(mCopyFnToClipA);
+ editMenu->addAction(mMoveA);
+ editMenu->addAction(mDeleteA);
+ editMenu->addSeparator();
+ editMenu->addAction(mTorrentInfoA);
+ editMenu->addSeparator();
+ editMenu->addAction(Globals::instance()->action(Globals::ConfigAction));
+
+ mMenuBar->addMenu(fileMenu);
+ mMenuBar->addMenu(editMenu);
+
+ mToolBar->addAction(mRefreshA);
+ mToolBar->addAction(mSelDirA);
+ mToolBar->addAction(createSeparator());
+ mToolBar->addAction(mCopyFnToClipA);
+ mToolBar->addAction(mMoveA);
+ mToolBar->addAction(mDeleteA);
+ mToolBar->addAction(createSeparator());
+ mToolBar->addAction(mTorrentInfoA);
+ mToolBar->addAction(createSeparator());
+ mToolBar->addAction(Globals::instance()->action(Globals::ConfigAction));
+
+ addActions(QList<QAction*>() << mRefreshA << mSelDirA << createSeparator() << mCopyFnToClipA << mMoveA << mDeleteA << createSeparator() << mTorrentInfoA);
+}
+
void TorrentWidget::gatherData(){
QSqlDatabase db = QSqlDatabase::database("shemovdb");
if(!db.isOpen()){
@@ -257,6 +309,12 @@ void TorrentWidget::writeSettings(){
s.setValue("searchdir", mDir->text());
}
+QAction *TorrentWidget::createSeparator(){
+ QAction *retval = new QAction(this);
+ retval->setSeparator(true);
+ return retval;
+}
+
void TorrentWidget::readHeaderData(){
QSettings s;
QByteArray headers = s.value("fileheaders").toByteArray();