diff options
author | Arno <arno@disconnect.de> | 2016-08-28 07:28:15 +0200 |
---|---|---|
committer | Arno <arno@disconnect.de> | 2016-08-28 07:28:15 +0200 |
commit | 8203bdcbdbc8c121831db0d197a89842b7178f59 (patch) | |
tree | 8a693c8c11e3265e08ed6d74c35a76ee991f8e12 | |
parent | 32afa2c28aabe862bfca44dba24083ffd7db6721 (diff) | |
download | ShemovCleaner-8203bdcbdbc8c121831db0d197a89842b7178f59.tar.gz ShemovCleaner-8203bdcbdbc8c121831db0d197a89842b7178f59.tar.bz2 ShemovCleaner-8203bdcbdbc8c121831db0d197a89842b7178f59.zip |
Added copyToClipboard where applicable
-rw-r--r-- | edit-copy.png | bin | 0 -> 1055 bytes | |||
-rw-r--r-- | shemovcleaner.cpp | 20 | ||||
-rw-r--r-- | shemovcleaner.h | 2 | ||||
-rw-r--r-- | shemovcleaner.qrc | 1 | ||||
-rw-r--r-- | torrentdisplay.cpp | 18 | ||||
-rw-r--r-- | torrentdisplay.h | 7 | ||||
-rw-r--r-- | torrentwidget.cpp | 8 | ||||
-rw-r--r-- | torrentwidget.h | 2 |
8 files changed, 55 insertions, 3 deletions
diff --git a/edit-copy.png b/edit-copy.png Binary files differnew file mode 100644 index 0000000..210c07a --- /dev/null +++ b/edit-copy.png diff --git a/shemovcleaner.cpp b/shemovcleaner.cpp index ec9d6e4..e6147c9 100644 --- a/shemovcleaner.cpp +++ b/shemovcleaner.cpp @@ -9,9 +9,11 @@ #include <QSettings> #include <QSqlDatabase> #include <QMessageBox> +#include <QTreeView> #include "shemovcleaner.h" #include "torrentwidget.h" +#include "torrentdisplay.h" #include "configurationwidget.h" ShemovCleaner::ShemovCleaner(QWidget *parent, Qt::WindowFlags f) : QMainWindow(parent, f) { @@ -74,7 +76,11 @@ void ShemovCleaner::createActions(){ connect(mTorInfoA, SIGNAL(triggered()), mTorrentTab, SLOT(torrentInfo())); mTorDirA = new QAction(QIcon(":/folder.png"), tr("Select folder..."), this); connect(mTorDirA, SIGNAL(triggered()), mTorrentTab, SLOT(selectDir())); + mFnThisCopyToClipA = new QAction(QIcon(":/edit-copy.png"), tr("Copy"), this); + connect(mFnThisCopyToClipA, SIGNAL(triggered()), mTorrentTab, SLOT(copyToClipboard())); + mTorrentTab->toolBar()->addAction(mTorRefreshA); + mTorrentTab->toolBar()->addAction(mFnThisCopyToClipA); mTorrentTab->toolBar()->addSeparator(); mTorrentTab->toolBar()->addAction(mTorDirA); mTorrentTab->toolBar()->addAction(mTorMoveA); @@ -90,8 +96,15 @@ void ShemovCleaner::createActions(){ torFileM->addAction(quitA); mTorrentTab->menuBar()->addMenu(torFileM); QMenu *torEditM = new QMenu(tr("Edit")); - torEditM->addAction(mTorDeleteA); + torEditM->addAction(mTorInfoA); + torEditM->addSeparator(); + torEditM->addAction(mTorRefreshA); + torEditM->addAction(mFnThisCopyToClipA); + torEditM->addSeparator(); torEditM->addAction(mTorMoveA); + torEditM->addAction(mTorDeleteA); + torEditM->addSeparator(); + torEditM->addAction(mTorDirA); torEditM->addSeparator(); torEditM->addAction(configA); torEditM->addSeparator(); @@ -100,11 +113,16 @@ void ShemovCleaner::createActions(){ mTorrentTab->addAction(mTorInfoA); mTorrentTab->addAction(createSeparator()); mTorrentTab->addAction(mTorRefreshA); + mTorrentTab->addAction(mFnThisCopyToClipA); mTorrentTab->addAction(createSeparator()); mTorrentTab->addAction(mTorMoveA); mTorrentTab->addAction(mTorDeleteA); mTorrentTab->addAction(createSeparator()); mTorrentTab->addAction(mTorDirA); + + mTorCopyToClipA = new QAction(QIcon(":/edit-copy.png"), tr("Copy"), this); + connect(mTorCopyToClipA, SIGNAL(triggered()), mTorrentTab->torrentDisplay(), SLOT(copyToClipboard())); + mTorrentTab->torrentDisplay()->addAction(mTorCopyToClipA); } void ShemovCleaner::openDatabase(){ diff --git a/shemovcleaner.h b/shemovcleaner.h index d709858..ccbdd63 100644 --- a/shemovcleaner.h +++ b/shemovcleaner.h @@ -31,6 +31,8 @@ class ShemovCleaner : public QMainWindow { QAction *mTorMoveA; QAction *mTorInfoA; QAction *mTorDirA; + QAction *mTorCopyToClipA; + QAction *mFnThisCopyToClipA; }; #endif // SHEMOVCLEANER_H diff --git a/shemovcleaner.qrc b/shemovcleaner.qrc index 26b21fe..e1145d4 100644 --- a/shemovcleaner.qrc +++ b/shemovcleaner.qrc @@ -9,5 +9,6 @@ <file>folder.png</file> <file>refresh.png</file> <file>chastity_belt.png</file> + <file>edit-copy.png</file> </qresource> </RCC> diff --git a/torrentdisplay.cpp b/torrentdisplay.cpp index 11b98b5..3a1664b 100644 --- a/torrentdisplay.cpp +++ b/torrentdisplay.cpp @@ -9,6 +9,10 @@ #include <QPushButton> #include <QLabel> #include <QDateTime> +#include <QClipboard> +#include <QApplication> +#include <QMenu> +#include <QContextMenuEvent> #include "torrentdisplay.h" @@ -79,8 +83,6 @@ TorrentDisplay::TorrentDisplay(QWidget *parent, Qt::WindowFlags f) : QDialog(par setWindowTitle(tr("Torrent Info")); } -#include <QDebug> - void TorrentDisplay::setData(const QList<QVariant> data, const QString &filename) { if(data.isEmpty()){ return; @@ -137,6 +139,18 @@ void TorrentDisplay::setData(const QList<QVariant> data, const QString &filename } } +void TorrentDisplay::copyToClipboard(){ + QModelIndex idx = mFileView->selectionModel()->currentIndex(); + QClipboard *clip = QApplication::clipboard(); + clip->setText(idx.data().toString()); +} + +void TorrentDisplay::contextMenuEvent(QContextMenuEvent *e){ + QMenu contextMenu(this); + contextMenu.addActions(actions()); + contextMenu.exec(e->globalPos()); +} + void TorrentDisplay::setMulti(const QVariantHash &data, const QString &filename){ QStandardItem *root = mFileModel->invisibleRootItem(); QStandardItem *torrentItem = new QStandardItem(filename); diff --git a/torrentdisplay.h b/torrentdisplay.h index 4aa01bf..221f0af 100644 --- a/torrentdisplay.h +++ b/torrentdisplay.h @@ -13,6 +13,13 @@ class TorrentDisplay : public QDialog { public: explicit TorrentDisplay(QWidget *parent = 0, Qt::WindowFlags f = 0); void setData(const QList<QVariant> data, const QString &filename); + QTreeView *fileView() { return mFileView; } + + public slots: + void copyToClipboard(); + + protected: + virtual void contextMenuEvent(QContextMenuEvent *e); private slots: void setMulti(const QVariantHash &data, const QString &filename); diff --git a/torrentwidget.cpp b/torrentwidget.cpp index 656870e..a6cb2f4 100644 --- a/torrentwidget.cpp +++ b/torrentwidget.cpp @@ -19,6 +19,8 @@ #include <QRegularExpression> #include <QToolBar> #include <QMenuBar> +#include <QClipboard> +#include <QApplication> #include <QDebug> @@ -229,6 +231,12 @@ void TorrentWidget::selectDir(){ gatherData(); } +void TorrentWidget::copyToClipboard(){ + QModelIndex cur = mFileView->selectionModel()->currentIndex(); + QClipboard *clip = QApplication::clipboard(); + clip->setText(cur.data().toString()); +} + void TorrentWidget::fileSelectionChanged(const QItemSelection &selected, const QItemSelection &deselected){ Q_UNUSED(selected); Q_UNUSED(deselected); diff --git a/torrentwidget.h b/torrentwidget.h index b1f33bb..5b1852c 100644 --- a/torrentwidget.h +++ b/torrentwidget.h @@ -22,6 +22,7 @@ class TorrentWidget : public QWidget { TorrentWidget(QWidget *parent = 0); QToolBar *toolBar() { return mToolBar; } QMenuBar *menuBar() { return mMenuBar; } + TorrentDisplay *torrentDisplay() { return mTorrentDisplay; } ~TorrentWidget(); signals: @@ -30,6 +31,7 @@ class TorrentWidget : public QWidget { public slots: void selectDir(); + void copyToClipboard(); void gatherData(); void deleteFiles(); void moveFiles(); |