Krita Source Code Documentation
Loading...
Searching...
No Matches
KarbonCalligraphyOptionWidget.h
Go to the documentation of this file.
1/* This file is part of the KDE project
2 SPDX-FileCopyrightText: 2008 Fela Winkelmolen <fela.kde@gmail.com>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#ifndef KARBONCALLIGRAPHYOPTIONWIDGET_H
8#define KARBONCALLIGRAPHYOPTIONWIDGET_H
9
10#include <QWidget>
11#include <QMap>
12
13class KComboBox;
14class QCheckBox;
15class QDoubleSpinBox;
16class QToolButton;
18
19class KarbonCalligraphyOptionWidget : public QWidget
20{
21 Q_OBJECT
22public:
25
26 // emits all signals with the appropriate values
27 // called once the signals are connected inside KarbonCalligraphyTool
28 // to make sure all parameters are uptodate
29 void emitAll();
30
31Q_SIGNALS:
32 // all the following signals Q_EMIT user friendly values, not the internal
33 // values which are instead computed directly by KarbonCalligraphyTool
34 void usePathChanged(bool);
36 void useAngleChanged(bool);
37 void widthChanged(double);
38 void thinningChanged(double);
39 void angleChanged(int);
40 void fixationChanged(double);
41 void capsChanged(double);
42 void massChanged(double);
43 void dragChanged(double);
44
45public Q_SLOTS:
46 // needed for the shortcuts
47 void increaseWidth();
48 void decreaseWidth();
49 void increaseAngle();
50 void decreaseAngle();
51
52private Q_SLOTS:
53 void loadProfile(const QString &name);
54 void toggleUseAngle(bool checked);
56 void saveProfileAs();
57 void removeProfile();
58
59 void setUsePathEnabled(bool enabled);
60
61 void on_m_angleBox_angleChanged(qreal angle);
62
63private:
64 // TODO: maybe make it a hash?? <QString, QVariant>
65 // is it needed al all??
66 struct Profile {
67 QString name;
68 int index; // index in the config file
69 bool usePath;
72 qreal width;
73 qreal thinning;
74 int angle;
75 qreal fixation;
76 qreal caps;
77 qreal mass;
78 qreal drag;
79 };
80
81 // convenience functions:
82
83 // connects signals and slots
84 void createConnections();
85
86 // if they aren't already added adds the default profiles
87 // called by the ctor
88 void addDefaultProfiles();
89
90 // load the profiles from the configuration file
91 void loadProfiles();
92
93 // loads the profile set as current profile in the configuration file
94 void loadCurrentProfile();
95
96 // save a new profile using the values of the input boxes
97 // if a profile with the same name already exists it will be overwritten
98 void saveProfile(const QString &name);
99
100 // removes the profile from the configuration file, from profiles
101 // and from the combobox.
102 // if the profile doesn't exist the function does nothing
103 void removeProfile(const QString &name);
104
105 // returns the position inside profiles of a certain profile
106 // returns -1 if the profile is not found
107 int profilePosition(const QString &profileName);
108
109private:
110 typedef QMap<QString, Profile *> ProfileMap;
112
113 KComboBox *m_comboBox;
114 QCheckBox *m_usePath;
115 QCheckBox *m_usePressure;
116 QCheckBox *m_useAngle;
117 QDoubleSpinBox *m_widthBox;
118 QDoubleSpinBox *m_thinningBox;
120 QDoubleSpinBox *m_capsBox;
121 QDoubleSpinBox *m_fixationBox;
122 QDoubleSpinBox *m_massBox;
123 QDoubleSpinBox *m_dragBox;
124
125 QToolButton *m_saveButton;
126 QToolButton *m_removeButton;
127
128 // when true updateCurrentProfile() doesn't do anything
130};
131
132#endif // KARBONCALLIGRAPHYOPTIONWIDGET_H
int profilePosition(const QString &profileName)
A widget with several options to select an angle.