diff options
Diffstat (limited to 'randomtab.cpp')
-rw-r--r-- | randomtab.cpp | 48 |
1 files changed, 45 insertions, 3 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()); +} |