diff options
-rw-r--r-- | fswidget.cpp | 9 | ||||
-rw-r--r-- | fswidget.h | 4 | ||||
-rw-r--r-- | helper.cpp | 7 | ||||
-rw-r--r-- | helper.h | 1 |
4 files changed, 21 insertions, 0 deletions
diff --git a/fswidget.cpp b/fswidget.cpp index 1932c10..fb78a1f 100644 --- a/fswidget.cpp +++ b/fswidget.cpp @@ -13,6 +13,7 @@ #include <QJsonObject> #include <QSqlDatabase> #include <QElapsedTimer> +#include <QMenu> #include <QSettings> #include <QApplication> @@ -103,6 +104,8 @@ void FSWidget::setupWidget(){ mProxy->setSourceModel(mModel); mFileView->setModel(mProxy); + addActions(QList<QAction*>() << backA << forwardA << Helper::createSeparator(this) << refreshA); + QVBoxLayout *mainLayout = new QVBoxLayout; mainLayout->addLayout(topWL); mainLayout->addWidget(mFileView); @@ -115,6 +118,12 @@ FSWidget::~FSWidget(){ writeSettings(); } +void FSWidget::contextMenuEvent(QContextMenuEvent *e){ + QMenu contextMenu(this); + contextMenu.addActions(actions()); + contextMenu.exec(e->globalPos()); +} + void FSWidget::readSettings(){ QSettings s; QStringList dirs = s.value("fs/dirs").toStringList(); @@ -8,6 +8,7 @@ class QComboBox; class QTreeView; class QStandardItemModel; class QSortFilterProxyModel; +class QContextMenuEvent; class FSWidget : public QWidget { Q_OBJECT @@ -15,6 +16,9 @@ class FSWidget : public QWidget { explicit FSWidget(QWidget *parent = nullptr); ~FSWidget(); + protected: + virtual void contextMenuEvent(QContextMenuEvent *e); + public slots: void readSettings(); void writeSettings(); @@ -29,6 +29,7 @@ #include <QRegularExpression> #include <QSqlDatabase> #include <QSqlQuery> +#include <QAction> #include <stdio.h> @@ -450,4 +451,10 @@ namespace Helper { delete p; return QIcon(QPixmap::fromImage(img)); } + + QAction *createSeparator(QWidget *parent){ + QAction *retval = new QAction(parent); + retval->setSeparator(true); + return retval; + } } @@ -51,6 +51,7 @@ namespace Helper { QVariant picSize(const QString &path); PicData convertArchivefileToPng(PicData data); const QIcon icon(const QColor &bg, const QChar c, bool bold = true); + QAction *createSeparator(QWidget *parent); class Duration { public: Duration(); |