widgets/coloredit.h

Sun, 09 Apr 2023 15:59:08 +0300

author
Teemu Piippo <teemu.s.piippo@gmail.com>
date
Sun, 09 Apr 2023 15:59:08 +0300
changeset 362
e1d646a4cbd8
parent 348
98776f54a8d0
permissions
-rw-r--r--

Extracted the state of the program into a MainState structure, and extracted local functions of main() into static functions.
I was planning to make the core logic and state of the program into a Main class, which would be a QObject that would
have lots of signals and slots, but it looks like this works even without it

39
caac957e9834 Main color is now configurable
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1 #pragma once
caac957e9834 Main color is now configurable
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
2 #include <QPushButton>
344
a24da8de2a3b Changed color button to a line edit+button combination
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 257
diff changeset
3 #include <QLineEdit>
39
caac957e9834 Main color is now configurable
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
4
caac957e9834 Main color is now configurable
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
5 /**
caac957e9834 Main color is now configurable
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
6 * @brief A button that can be used to select a color
caac957e9834 Main color is now configurable
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
7 */
347
5c655cc006de Rename ColorButton -> ColorEdit
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 344
diff changeset
8 class ColorEdit : public QWidget
39
caac957e9834 Main color is now configurable
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
9 {
256
c6f5de03dc0f Move color button into widgets lib
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 39
diff changeset
10 Q_OBJECT
c6f5de03dc0f Move color button into widgets lib
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 39
diff changeset
11 Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged)
344
a24da8de2a3b Changed color button to a line edit+button combination
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 257
diff changeset
12 QLineEdit* lineEdit;
a24da8de2a3b Changed color button to a line edit+button combination
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 257
diff changeset
13 QPushButton* button;
39
caac957e9834 Main color is now configurable
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
14 public:
347
5c655cc006de Rename ColorButton -> ColorEdit
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 344
diff changeset
15 ColorEdit(const QColor& color = {}, QWidget* parent = nullptr);
5c655cc006de Rename ColorButton -> ColorEdit
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 344
diff changeset
16 ColorEdit(QWidget* parent = nullptr);
344
a24da8de2a3b Changed color button to a line edit+button combination
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 257
diff changeset
17 QColor color() const;
256
c6f5de03dc0f Move color button into widgets lib
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 39
diff changeset
18 Q_SLOT void setColor(const QColor& color);
c6f5de03dc0f Move color button into widgets lib
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 39
diff changeset
19 Q_SIGNAL void colorChanged(const QColor& color);
39
caac957e9834 Main color is now configurable
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
20 };

mercurial