summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArno <arno@disconnect.de>2018-04-03 09:11:25 +0200
committerArno <arno@disconnect.de>2018-04-03 09:11:25 +0200
commit0d2eb533f18dbd2330f5bd48b6a154a3c87b84d2 (patch)
tree6f471c93aabda83662934f30218cb658f9e30efa
parentbac6fe431150bb5706fe0fb349e753b8fe08c12e (diff)
downloadSheMov-0d2eb533f18dbd2330f5bd48b6a154a3c87b84d2.tar.gz
SheMov-0d2eb533f18dbd2330f5bd48b6a154a3c87b84d2.tar.bz2
SheMov-0d2eb533f18dbd2330f5bd48b6a154a3c87b84d2.zip
Add a menu with global actions to SmGlobals
Use it in the toolbar for FSWidge and hide the menuBar. Change Helper::icon to accept different foreground colors and wether to draw the ellipse.
-rw-r--r--fswidget.cpp15
-rw-r--r--helper.cpp8
-rw-r--r--helper.h2
-rw-r--r--shemov.cpp88
-rw-r--r--smglobals.h4
5 files changed, 73 insertions, 44 deletions
diff --git a/fswidget.cpp b/fswidget.cpp
index 117193e..a6073cc 100644
--- a/fswidget.cpp
+++ b/fswidget.cpp
@@ -21,6 +21,7 @@
#include "fswidget.h"
#include "helper.h"
+#include "smglobals.h"
#include "newmoviewizard.h"
#include "newpicsdialog.h"
#include "fsproxy.h"
@@ -75,10 +76,8 @@ void FSWidget::setupWidget(){
QAction *previewA = new QAction(QIcon(":/snapshot.png"), tr("Preview..."), this);
connect(previewA, &QAction::triggered, this, &FSWidget::preview);
toolbar->addAction(previewA);
- QAction *configA = new QAction(QIcon(":/chastity_belt.png"), tr("Configure"), this);
- connect(configA, &QAction::triggered, this, &FSWidget::needConfig);
toolbar->addSeparator();
- toolbar->addAction(configA);
+ toolbar->addAction(SmGlobals::instance()->globalAction());
QAction *playSelectedA = new QAction(QIcon(":/spreadingpants.png"), tr("Play selected"), this);
connect(playSelectedA, &QAction::triggered, [=] { playSelected(1, QString()); });
playSelectedA->setShortcut(Qt::Key_Return);
@@ -103,8 +102,8 @@ void FSWidget::setupWidget(){
unselectAllA->setShortcut(tr("CTRL+k"));
unselectAllA->setData(FSView::InvisibleAction);
- QIcon plusIcon = Helper::icon(QColor(255,85,255), '+');
- QIcon minusIcon = Helper::icon(QColor(255,85,255), '-');
+ QIcon plusIcon = Helper::icon(QColor(255,85,255), Qt::white, '+', true, true);
+ QIcon minusIcon = Helper::icon(QColor(255,85,255), Qt::white, '-', true, true);
QLabel *dirL = new QLabel(tr("Dir"));
mDirCB = new QComboBox;
mDirCB->setSizeAdjustPolicy(QComboBox::AdjustToContents);
@@ -269,9 +268,9 @@ void FSWidget::gatherData(const QString &curDir){
QStandardItem *root = mModel->invisibleRootItem();
QMimeDatabase mimedb;
mModel->setHorizontalHeaderLabels(QStringList() << tr("Name") << tr("MIME") << tr("Size") << tr("Duration") << tr("MD5") << tr("Presence"));
- QIcon videoIcon = Helper::icon(QColor(255,85,255), 'M');
- QIcon imageIcon = Helper::icon(QColor(255,85,255), 'P');
- QIcon otherIcon = Helper::icon(QColor(255,85,255), 'O');
+ QIcon videoIcon = Helper::icon(QColor(255,85,255), Qt::white, true, true, 'M');
+ QIcon imageIcon = Helper::icon(QColor(255,85,255), Qt::white, true, true, 'P');
+ QIcon otherIcon = Helper::icon(QColor(255,85,255), Qt::white, true, true, 'O');
QBrush blackBrush(Qt::black);
QBrush greenBrush(Qt::darkGreen);
QBrush blueBrush(Qt::darkBlue);
diff --git a/helper.cpp b/helper.cpp
index 5e52bb2..d9a2856 100644
--- a/helper.cpp
+++ b/helper.cpp
@@ -433,7 +433,7 @@ namespace Helper {
return retval;
}
- const QIcon icon(const QColor &bg, const QChar c, bool bold){
+ const QIcon icon(const QColor &bg, const QColor &fg, const QChar c, bool bold, bool drawEllipse){
QImage img(32, 32, QImage::Format_ARGB32);
img.fill(QColor(0, 0, 0, 0));
QPainter *p = new QPainter(&img);
@@ -444,8 +444,10 @@ namespace Helper {
QFont f("courier new");
f.setPixelSize(30);
f.setBold(bold);
- p->setPen(Qt::white);
- p->drawEllipse(img.rect());
+ p->setPen(fg);
+ if(drawEllipse){
+ p->drawEllipse(img.rect());
+ }
p->setFont(f);
p->drawText(img.rect(), Qt::AlignCenter, c);
delete p;
diff --git a/helper.h b/helper.h
index c5e53d0..a3f0f3e 100644
--- a/helper.h
+++ b/helper.h
@@ -50,7 +50,7 @@ namespace Helper {
QImage snapshot(const QString &path, int where);
QVariant picSize(const QString &path);
PicData convertArchivefileToPng(PicData data);
- const QIcon icon(const QColor &bg, const QChar c, bool bold = true);
+ const QIcon icon(const QColor &bg, const QColor &fg, const QChar c, bool bold, bool drawEllipse);
QAction *createSeparator(QWidget *parent);
class Duration {
public:
diff --git a/shemov.cpp b/shemov.cpp
index 4af3a72..f0ea30b 100644
--- a/shemov.cpp
+++ b/shemov.cpp
@@ -50,6 +50,56 @@ SheMov::SheMov(QWidget *parent, Qt::WindowFlags flags) : QMainWindow(parent, fla
qApp->processEvents();
(void) SmGlobals::instance();
+ mAnalyzeActorsA = new QAction(tr("Actors..."), this);
+ connect(mAnalyzeActorsA, &QAction::triggered, this, &SheMov::analyzeActors);
+ mAnalyzeGenresA = new QAction(tr("Genres..."), this);
+ connect(mAnalyzeGenresA, &QAction::triggered, this, &SheMov::analyzeGenres);
+ mAnalyzeSeriesA = new QAction(tr("Series..."), this);
+ connect(mAnalyzeSeriesA, &QAction::triggered, this, &SheMov::analyzeSeries);
+ mAnalyzePartsA = new QAction(tr("Series Parts..."), this);
+ connect(mAnalyzePartsA, &QAction::triggered, this, &SheMov::analyzeParts);
+ mConsistencyA = new QAction(tr("Check consisteny..."), this);
+ connect(mConsistencyA, &QAction::triggered, this, &SheMov::checkConsistency);
+ /*mSearchDialogA = new QAction(tr("Search..."), this);
+ mSearchDialogA->setShortcut(tr("CTRL+f"));
+ connect(mSearchDialogA, &QAction::triggered, mSearchDialog, &SearchDialog::show);*/
+ mQuitA = new QAction(tr("Quit"), this);
+ mQuitA->setShortcut(tr("CTRL+q"));
+ connect(mQuitA, &QAction::triggered, qApp, &QApplication::closeAllWindows);
+ mConfigA = new QAction(QIcon(":/chastity_belt.png"), tr("Configure..."), this);
+ connect(mConfigA, &QAction::triggered, this, &SheMov::configure);
+ QString aboutLabel = QString(tr("About %1...")).arg(qApp->applicationName());
+ mAboutShemovA = new QAction(aboutLabel, this);
+ connect(mAboutShemovA, &QAction::triggered, this, &SheMov::aboutShemov);
+ mAboutQtA = new QAction(tr("About Qt..."), this);
+ connect(mAboutQtA, &QAction::triggered, qApp, &QApplication::aboutQt);
+ mStatisticsA = new QAction(tr("Some statistics..."), this);
+ connect(mStatisticsA, &QAction::triggered, this, &SheMov::showStatistics);
+
+ //global menu
+ QAction *globalMenuA = new QAction(Helper::icon(QColor(0, 0, 0, 0), Qt::black, QChar(0x26A4), true, false), tr("Global"), this);
+ QMenu *globalMenu = new QMenu;
+ globalMenu->addAction(mConsistencyA);
+ globalMenu->addSeparator();
+ QMenu *analyzeMenu = new QMenu;
+ analyzeMenu->addAction(mAnalyzeActorsA);
+ analyzeMenu->addAction(mAnalyzeGenresA);
+ analyzeMenu->addAction(mAnalyzePartsA);
+ analyzeMenu->addAction(mAnalyzeSeriesA);
+ QAction *analyzeMenuA = new QAction(tr("Analyze"), this);
+ analyzeMenuA->setMenu(analyzeMenu);
+ globalMenu->addAction(analyzeMenuA);
+ globalMenu->addSeparator();
+ globalMenu->addAction(mConfigA);
+ globalMenu->addAction(mStatisticsA);
+ globalMenu->addSeparator();
+ globalMenu->addAction(mAboutQtA);
+ globalMenu->addAction(mAboutShemovA);
+ globalMenu->addSeparator();
+ globalMenu->addAction(mQuitA);
+ globalMenuA->setMenu(globalMenu);
+ SmGlobals::instance()->setGlobalAction(globalMenuA);
+
//FileSystemWidget + TabWidget
splash.showMessage(tr("Constructing Filemanager..."), Qt::AlignHCenter, Qt::yellow);
qApp->processEvents();
@@ -170,6 +220,11 @@ void SheMov::configure(){
}
void SheMov::tabChanged(int newTab){
+ if(newTab == FileManager){
+ menuBar()->setVisible(false);
+ }else{
+ menuBar()->setVisible(true);
+ }
mEditPicMenuA->setVisible(newTab == Pictures);
mViewPicMenuA->setVisible(newTab == Pictures);
mArchiveViewMenuA->setVisible(newTab == Movies);
@@ -322,27 +377,6 @@ void SheMov::createStatusbar(){
}
void SheMov::createActions(){
- mConsistencyA = new QAction(tr("Check consisteny..."), this);
- connect(mConsistencyA, &QAction::triggered, this, &SheMov::checkConsistency);
- mSearchDialogA = new QAction(tr("Search..."), this);
- mSearchDialogA->setShortcut(tr("CTRL+f"));
- connect(mSearchDialogA, &QAction::triggered, mSearchDialog, &SearchDialog::show);
-
- //connnect
- mQuitA = new QAction(tr("Quit"), this);
- mQuitA->setShortcut(tr("CTRL+q"));
- connect(mQuitA, &QAction::triggered, qApp, &QApplication::closeAllWindows);
- mConfigA = new QAction(QIcon(":/chastity_belt.png"), tr("Configure..."), this);
- connect(mConfigA, &QAction::triggered, this, &SheMov::configure);
-
- //Help menu
- QString aboutLabel = QString(tr("About %1...")).arg(qApp->applicationName());
- mAboutShemovA = new QAction(aboutLabel, this);
- connect(mAboutShemovA, &QAction::triggered, this, &SheMov::aboutShemov);
- mAboutQtA = new QAction(tr("About Qt..."), this);
- connect(mAboutQtA, &QAction::triggered, qApp, &QApplication::aboutQt);
- mStatisticsA = new QAction(tr("Some statistics..."), this);
- connect(mStatisticsA, &QAction::triggered, this, &SheMov::showStatistics);
//headers
mPicsTreeHeaderGroup = new QActionGroup(this);
@@ -550,17 +584,7 @@ void SheMov::createActions(){
// db analyzer dialogs
// analyze actors
- mAnalyzeActorsA = new QAction(tr("Actors..."), this);
- connect(mAnalyzeActorsA, &QAction::triggered, this, &SheMov::analyzeActors);
- // analyze genres
- mAnalyzeGenresA = new QAction(tr("Genres..."), this);
- connect(mAnalyzeGenresA, &QAction::triggered, this, &SheMov::analyzeGenres);
- // analyze series
- mAnalyzeSeriesA = new QAction(tr("Series..."), this);
- connect(mAnalyzeSeriesA, &QAction::triggered, this, &SheMov::analyzeSeries);
- // anaylze series parts
- mAnalyzePartsA = new QAction(tr("Series Parts..."), this);
- connect(mAnalyzePartsA, &QAction::triggered, this, &SheMov::analyzeParts);
+
//don't add actions with checkable(true) unless you know what you're doing!
mPicActionGroup = new QActionGroup(this);
diff --git a/smglobals.h b/smglobals.h
index 0ac20ac..c4eb6c3 100644
--- a/smglobals.h
+++ b/smglobals.h
@@ -18,6 +18,7 @@ class PictureViewer2;
class QPixmap;
class SeriesTreeWidget;
class ArchiveController;
+class QAction;
// this was: 4707319808 - 20 * 1024 *1024
#define DVDSIZE 4686348288
@@ -44,6 +45,8 @@ class SmGlobals : public QObject {
QHash<int, QString> filetypeMap() const { return mFiletypeMap; }
void registerWidget(const QString &name, QWidget *w);
QWidget *getRegisteredWidget(const QString &name);
+ void setGlobalAction(QAction *a) { mGlobalActions = a; }
+ QAction *globalAction() { return mGlobalActions; }
QStringList reencReasons() const { return mReencReasons; }
void setReencReasons(const QStringList reasons);
@@ -61,6 +64,7 @@ class SmGlobals : public QObject {
QHash<int, QString> mFiletypeMap;
QHash<QString, QWidget*> mWidgets;
QStringList mReencReasons;
+ QAction *mGlobalActions;
};
#endif