From 1e14ae6748f271265dd719ac0766a2da3501a21f Mon Sep 17 00:00:00 2001 From: Arno Date: Sat, 17 Mar 2012 15:15:53 +0100 Subject: Add keyboard actions to PictureViewer2 Never, ever forget: QVariant() casts to a valid int! Again, this was a tough one, but maybe I shouldn't drink and program. PictureViewer2 reacts to Escape and Space. Escape hides it and stops the slide timer, Space activates the slide timer. --- pictureviewer2.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'pictureviewer2.h') diff --git a/pictureviewer2.h b/pictureviewer2.h index 6126930..e18fc18 100644 --- a/pictureviewer2.h +++ b/pictureviewer2.h @@ -27,6 +27,7 @@ typedef QList > PicDataList; class PictureViewer2 : public QGraphicsView { Q_OBJECT public: + enum AssocActions { SlideAction, HideAction }; explicit PictureViewer2(QWidget *parent = 0); void addFiles(const PicDataList &files, bool clear = true); void setFile(const PicData &file); @@ -35,14 +36,17 @@ class PictureViewer2 : public QGraphicsView { public slots: void next(); void previous(); - void slide(); + void slide(bool); void readSettings(); void writeSettings(); void shuffle(); + void initActions(); protected: virtual void wheelEvent(QWheelEvent *event); virtual void contextMenuEvent(QContextMenuEvent *e); + virtual void keyPressEvent(QKeyEvent *e); + virtual void hideEvent(QHideEvent *); private slots: void showFile(const PicData &data); @@ -63,6 +67,8 @@ class PictureViewer2 : public QGraphicsView { bool mUseGradient; QColor mBgColor; QPointF mInfoPos; + QAction *mSlideA; + QAction *mHideA; }; class PictureViewer2FileinfoItem : public QGraphicsItem { -- cgit v1.2.3-70-g09d2