summaryrefslogtreecommitdiffstats
path: root/examples/widgets/mainwindows/mainwindow/colorswatch.h
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@theqtcompany.com>2015-07-17 10:41:44 +0200
committerFriedemann Kleint <Friedemann.Kleint@theqtcompany.com>2015-07-17 14:15:11 +0000
commit2fe56e37ede40dc703a9c3c8eb240b80c9c00757 (patch)
treeaca858f6e085f23b254df4a7a08c0c10e9805f34 /examples/widgets/mainwindows/mainwindow/colorswatch.h
parent7f77d4fcd5534ec0973654e37c8ef189dce35778 (diff)
Polish the examples/widgets/mainwindows example.
- Introduce Qt 5 signals & slot syntax. - Replace QSignalMapper used for the corner/area actions by a by a functor. - Improve command line parsing. - Reorder class declarations. - Remove commented-out code. - Use QDialogButtonBox in dialogs. - Fix minor issues in code, use multi-argument version of QString::arg(), QDir::toNativeSeparators() to present file paths to the user, static method invocations. Change-Id: I865c56639c74135b59740797e9a9dfbfca2e72b6 Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
Diffstat (limited to 'examples/widgets/mainwindows/mainwindow/colorswatch.h')
-rw-r--r--examples/widgets/mainwindows/mainwindow/colorswatch.h80
1 files changed, 40 insertions, 40 deletions
diff --git a/examples/widgets/mainwindows/mainwindow/colorswatch.h b/examples/widgets/mainwindows/mainwindow/colorswatch.h
index 78f267c320..8827a7dca7 100644
--- a/examples/widgets/mainwindows/mainwindow/colorswatch.h
+++ b/examples/widgets/mainwindows/mainwindow/colorswatch.h
@@ -44,47 +44,15 @@ class ColorSwatch : public QDockWidget
{
Q_OBJECT
- QAction *closableAction;
- QAction *movableAction;
- QAction *floatableAction;
- QAction *floatingAction;
- QAction *verticalTitleBarAction;
-
- QActionGroup *allowedAreasActions;
- QAction *allowLeftAction;
- QAction *allowRightAction;
- QAction *allowTopAction;
- QAction *allowBottomAction;
-
- QActionGroup *areaActions;
- QAction *leftAction;
- QAction *rightAction;
- QAction *topAction;
- QAction *bottomAction;
-
- QAction *changeSizeHintsAction;
-
- QMenu *tabMenu;
- QMenu *splitHMenu;
- QMenu *splitVMenu;
-
- QAction *windowModifiedAction;
-
- QMainWindow *mainWindow;
-
public:
- explicit ColorSwatch(const QString &colorName, QMainWindow *parent = 0, Qt::WindowFlags flags = 0);
+ explicit ColorSwatch(const QString &colorName, QMainWindow *parent = Q_NULLPTR, Qt::WindowFlags flags = 0);
- QMenu *menu;
void setCustomSizeHint(const QSize &size);
+ QMenu *colorSwatchMenu() const { return menu; }
protected:
- virtual void contextMenuEvent(QContextMenuEvent *event) Q_DECL_OVERRIDE;
- virtual void resizeEvent(QResizeEvent *e) Q_DECL_OVERRIDE;
-
-private:
- void allow(Qt::DockWidgetArea area, bool allow);
- void place(Qt::DockWidgetArea area, bool place);
+ void contextMenuEvent(QContextMenuEvent *event) Q_DECL_OVERRIDE;
+ void resizeEvent(QResizeEvent *e) Q_DECL_OVERRIDE;
private slots:
void changeClosable(bool on);
@@ -106,25 +74,57 @@ private slots:
void splitInto(QAction *action);
void tabInto(QAction *action);
+
+private:
+ void allow(Qt::DockWidgetArea area, bool allow);
+ void place(Qt::DockWidgetArea area, bool place);
+
+ QAction *closableAction;
+ QAction *movableAction;
+ QAction *floatableAction;
+ QAction *floatingAction;
+ QAction *verticalTitleBarAction;
+
+ QActionGroup *allowedAreasActions;
+ QAction *allowLeftAction;
+ QAction *allowRightAction;
+ QAction *allowTopAction;
+ QAction *allowBottomAction;
+
+ QActionGroup *areaActions;
+ QAction *leftAction;
+ QAction *rightAction;
+ QAction *topAction;
+ QAction *bottomAction;
+
+ QMenu *tabMenu;
+ QMenu *splitHMenu;
+ QMenu *splitVMenu;
+ QMenu *menu;
+
+ QMainWindow *mainWindow;
};
class BlueTitleBar : public QWidget
{
Q_OBJECT
public:
- BlueTitleBar(QWidget *parent = 0);
+ explicit BlueTitleBar(QWidget *parent = Q_NULLPTR);
QSize sizeHint() const Q_DECL_OVERRIDE { return minimumSizeHint(); }
QSize minimumSizeHint() const Q_DECL_OVERRIDE;
+
protected:
void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE;
void mouseReleaseEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
+
public slots:
void updateMask();
private:
- QPixmap leftPm, centerPm, rightPm;
+ const QPixmap leftPm;
+ const QPixmap centerPm;
+ const QPixmap rightPm;
};
-
-#endif
+#endif // COLORSWATCH_H