summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArno <arno@disconnect.de>2016-11-11 10:25:53 +0100
committerArno <arno@disconnect.de>2016-11-11 10:25:53 +0100
commit57c8d4751f2a6e4ab0cd675c269cd950e4f270be (patch)
tree06dba7cf00be8bfcf18bea764957b843edb4a85e
parentd44cada7cd8eee4a0967da2649a8332bdb12346f (diff)
downloadSheMov-57c8d4751f2a6e4ab0cd675c269cd950e4f270be.tar.gz
SheMov-57c8d4751f2a6e4ab0cd675c269cd950e4f270be.tar.bz2
SheMov-57c8d4751f2a6e4ab0cd675c269cd950e4f270be.zip
Hook up Actions for RandomTab
Create edit and context menus.
-rw-r--r--randomtab.cpp48
-rw-r--r--randomtab.h34
-rw-r--r--shemov.cpp6
-rw-r--r--shemov.h5
4 files changed, 88 insertions, 5 deletions
diff --git a/randomtab.cpp b/randomtab.cpp
index 835a750..7b0dd59 100644
--- a/randomtab.cpp
+++ b/randomtab.cpp
@@ -18,7 +18,6 @@
#include <QStandardItemModel>
#include <QStandardItem>
#include <QModelIndex>
-#include <QTreeView>
#include <QSortFilterProxyModel>
#include <QSqlQuery>
#include <QDateTime>
@@ -27,6 +26,9 @@
#include <QSettings>
#include <QDirIterator>
#include <QProcess>
+#include <QAction>
+#include <QMenu>
+#include <QContextMenuEvent>
#include <algorithm>
#include <random>
@@ -42,6 +44,8 @@ RandomTab::RandomTab(QWidget *parent) : QWidget(parent) {
mActorModel = new QStandardItemModel(this);
setupModels();
setupGui();
+ setupActions();
+ mFileView->setContextMenu(mContextMenu);
clearAll();
readSettings();
mValidDvds = validDvdNos();
@@ -106,7 +110,7 @@ void RandomTab::setupGui(){
QGroupBox *playBox = new QGroupBox(tr("Play"));
mPlayAll = new QPushButton(QIcon(":/gaping_ass.png"), tr("Play All"));
connect(mPlayAll, SIGNAL(clicked()), this, SLOT(playAll()));
- mPlaySelected = new QPushButton(QIcon(":/chastity_belt.png"), tr("Play Selected"));
+ mPlaySelected = new QPushButton(QIcon(":/big_ass.png"), tr("Play Selected"));
connect(mPlaySelected, SIGNAL(clicked()), this, SLOT(playSelected()));
QVBoxLayout *playL = new QVBoxLayout;
playL->addWidget(mPlaySelected);
@@ -123,7 +127,7 @@ void RandomTab::setupGui(){
lwL->addStretch();
leftWidget->setLayout(lwL);
- mFileView = new QTreeView;
+ mFileView = new RandomFileView;
mFileView->setAlternatingRowColors(true);
mFileView->setRootIsDecorated(false);
mFileView->setSelectionMode(QAbstractItemView::ExtendedSelection);
@@ -153,6 +157,38 @@ void RandomTab::setupGui(){
setLayout(mainLayout);
}
+void RandomTab::setupActions(){
+ mPlayAllA = new QAction(QIcon(":/gaping_ass.png"), tr("Play All"), this);
+ connect(mPlayAllA, SIGNAL(triggered()), this, SLOT(playAll()));
+ mPlaySelectedA = new QAction(QIcon(":/big_ass.png"), tr("Play Selected"), this);
+ connect(mPlaySelectedA, SIGNAL(triggered()), this, SLOT(playSelected()));
+ mRefreshA = new QAction(QIcon(":/refresh.png"), tr("Refresh"));
+ connect(mRefreshA, SIGNAL(triggered()), this, SLOT(refreshComboboxes()));
+ mClearA = new QAction(QIcon(":/delete.png"), tr("Clear"), this);
+ connect(mClearA, SIGNAL(triggered()), this, SLOT(clearAll()));
+ mGoA = new QAction(QIcon(":/huge_bra.png"), tr("Select"), this);
+ connect(mGoA, SIGNAL(triggered()), this, SLOT(select()));
+ mConfigureA = new QAction(QIcon(":/chastity_belt.png"), tr("Configure..."), this);
+ connect(mConfigureA, SIGNAL(triggered()), this, SIGNAL(configure()));
+ mFileView->actions() << mPlayAllA << mPlaySelectedA << mRefreshA << mClearA << mGoA << mConfigureA;
+
+ mContextMenu = new QMenu(this);
+ mContextMenu->addAction(mPlaySelectedA);
+ mContextMenu->addAction(mPlayAllA);
+ mContextMenu->addSeparator();
+ mContextMenu->addAction(mGoA);
+
+ mEditMenu = new QMenu(tr("&Edit"), this);
+ mEditMenu->addAction(mPlaySelectedA);
+ mEditMenu->addAction(mPlayAllA);
+ mEditMenu->addSeparator();
+ mEditMenu->addAction(mRefreshA);
+ mEditMenu->addAction(mClearA);
+ mEditMenu->addAction(mGoA);
+ mEditMenu->addSeparator();
+ mEditMenu->addAction(mConfigureA);
+}
+
void RandomTab::writeSettings(){
QSettings s;
QStringList selGenres;
@@ -430,3 +466,9 @@ void RandomTab::logMessage(const QString &msg){
QString msg1 = QString("[%1] %2").arg(now.toString()).arg(msg);
mLog->append(msg1);
}
+
+RandomFileView::RandomFileView(QWidget *parent) : QTreeView(parent) {}
+
+void RandomFileView::contextMenuEvent(QContextMenuEvent *e){
+ mCtxMenu->exec(e->globalPos());
+}
diff --git a/randomtab.h b/randomtab.h
index 3f400e8..15ef087 100644
--- a/randomtab.h
+++ b/randomtab.h
@@ -11,6 +11,7 @@
#include <QWidget>
#include <QSqlDatabase>
#include <QVector>
+#include <QTreeView>
class QComboBox;
class QPushButton;
@@ -19,6 +20,10 @@ class QSortFilterProxyModel;
class QStandardItemModel;
class QLineEdit;
class QTextEdit;
+class QAction;
+class QMenu;
+class QContextMenuEvent;
+class RandomFileView;
class RandomTab : public QWidget {
Q_OBJECT
@@ -28,6 +33,8 @@ class RandomTab : public QWidget {
enum { ColumnCount = 6 };
explicit RandomTab(QWidget *parent = 0);
virtual ~RandomTab();
+ const QMenu *contextMenu() const { return mContextMenu; }
+ QMenu *editMenu() { return mEditMenu; }
public slots:
void setupModels();
@@ -39,8 +46,12 @@ class RandomTab : public QWidget {
void play(const QStringList &files);
void logMessage(const QString &msg);
+ signals:
+ void configure();
+
private:
void setupGui();
+ void setupActions();
void writeSettings();
void readSettings();
QStringList validDvdNos();
@@ -58,7 +69,7 @@ class RandomTab : public QWidget {
QPushButton *mRefresh;
QPushButton *mPlaySelected;
QPushButton *mPlayAll;
- QTreeView *mFileView;
+ RandomFileView *mFileView;
QTextEdit *mLog;
QStandardItemModel *mFileModel;
QStandardItemModel *mGenreModel;
@@ -66,6 +77,27 @@ class RandomTab : public QWidget {
QSortFilterProxyModel *mFileProxy;
QSqlDatabase mDb;
QStringList mValidDvds;
+ QAction *mPlaySelectedA;
+ QAction *mPlayAllA;
+ QAction *mClearA;
+ QAction *mRefreshA;
+ QAction *mGoA;
+ QAction *mConfigureA;
+ QMenu *mContextMenu;
+ QMenu *mEditMenu;
+};
+
+class RandomFileView : public QTreeView {
+ Q_OBJECT
+ public:
+ explicit RandomFileView(QWidget *parent = 0);
+ void setContextMenu(QMenu *menu) { mCtxMenu = menu; }
+
+ protected:
+ virtual void contextMenuEvent(QContextMenuEvent *e);
+
+ private:
+ QMenu *mCtxMenu;
};
#endif // RANDOMTAB_H
diff --git a/shemov.cpp b/shemov.cpp
index 27c3345..9804e94 100644
--- a/shemov.cpp
+++ b/shemov.cpp
@@ -94,6 +94,7 @@ SheMov::SheMov(QWidget *parent, Qt::WindowFlags flags) : QMainWindow(parent, fla
splash.showMessage(tr("Creating Random Browser..."), Qt::AlignHCenter, Qt::yellow);
qApp->processEvents();
mRandomTab = new RandomTab;
+ connect(mRandomTab, SIGNAL(configure()), this, SLOT(configure()));
mTab->addTab(mRandomTab, tr("Random"));
//newmoviewizard + dbanalyzer + newpicsdialog + searchdialog
@@ -205,6 +206,7 @@ void SheMov::tabChanged(int newTab){
mNewPicsA->setEnabled(newTab == FileManager);
mNewMovieWizardA->setEnabled(newTab == FileManager);
mArchiveBrowserViewMenuA->setVisible(newTab == ArchiveBrowserTab);
+ mRandomEditMenuA->setVisible(newTab == RandomDisp);
statusbarMessage(QString());
ArchiveController *c = SmGlobals::instance()->archiveController();
switch(newTab){
@@ -940,6 +942,10 @@ void SheMov::createMenus(){
mArchiveEditMenu->addMenu(archiveTreeM);
mArchiveEditMenu->addMenu(archiveFilesM);
+
+ // Random
+ mRandomEditMenu = mRandomTab->editMenu();
+ mRandomEditMenuA = menuBar()->insertMenu(mArchiveMenuA, mRandomEditMenu);
}
void SheMov::createOpenWithMenuFS(){
diff --git a/shemov.h b/shemov.h
index fed0ce9..7420bbe 100644
--- a/shemov.h
+++ b/shemov.h
@@ -29,7 +29,7 @@ class SheMov : public QMainWindow {
Q_OBJECT
public:
SheMov(QWidget *parent = 0, Qt::WindowFlags flags = 0);
- enum TabNum { FileManager = 0, Movies = 1, Pictures = 2, ArchiveBrowserTab = 3 };
+ enum TabNum { FileManager = 0, Movies = 1, Pictures = 2, ArchiveBrowserTab = 3, RandomDisp = 4 };
virtual ~SheMov() {}
protected:
@@ -200,12 +200,15 @@ class SheMov : public QMainWindow {
QMenu *mPicViewMenu;
QMenu *mArchiveViewMenu;
QMenu *mArchiveBrowserViewMenu;
+ QMenu *mRandomEditMenu;
QAction *mEditFSMenuA;
QAction *mEditPicMenuA;
QAction *mViewFSMenuA;
QAction *mViewPicMenuA;
QAction *mArchiveViewMenuA;
+ QAction *mRandomEditMenuA;
+
//widgets + dialogs
QTabWidget *mTab;
FilesystemWidget *mFSWidget;