Changeset View
Changeset View
Standalone View
Standalone View
src/kexiutils/style/KexiStyle.h
- This file was added.
1 | /* This file is part of the KDE project | ||||
---|---|---|---|---|---|
2 | Copyright (C) 2016 Jarosław Staniek <staniek@kde.org> | ||||
3 | | ||||
4 | This library is free software; you can redistribute it and/or | ||||
5 | modify it under the terms of the GNU Library General Public | ||||
6 | License as published by the Free Software Foundation; either | ||||
7 | version 2 of the License, or (at your option) any later version. | ||||
8 | | ||||
9 | This library is distributed in the hope that it will be useful, | ||||
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||||
12 | Library General Public License for more details. | ||||
13 | | ||||
14 | You should have received a copy of the GNU Library General Public License | ||||
15 | along with this library; see the file COPYING.LIB. If not, write to | ||||
16 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||||
17 | * Boston, MA 02110-1301, USA. | ||||
18 | */ | ||||
19 | | ||||
20 | #ifndef KEXISTYLE_H | ||||
21 | #define KEXISTYLE_H | ||||
22 | | ||||
23 | #include <kexiutils_export.h> | ||||
24 | | ||||
25 | #include <KIconLoader> | ||||
26 | | ||||
27 | #include <QColor> | ||||
28 | #include <QMargins> | ||||
29 | | ||||
30 | class KLocalizedString; | ||||
31 | class KPropertyEditorView; | ||||
32 | class QComboBox; | ||||
33 | class QFont; | ||||
34 | class QFrame; | ||||
35 | class QGridLayout; | ||||
36 | class QIcon; | ||||
37 | class QLabel; | ||||
38 | class QLineEdit; | ||||
39 | class QModelIndex; | ||||
40 | class QPainter; | ||||
41 | class QPalette; | ||||
42 | class QRect; | ||||
43 | class QStyleOptionViewItem; | ||||
44 | class QVBoxLayout; | ||||
45 | class QWidget; | ||||
46 | | ||||
47 | //! Styled icon parameters | ||||
48 | class KEXIUTILS_EXPORT KexiStyledIconParameters { | ||||
49 | public: | ||||
50 | explicit KexiStyledIconParameters(KIconLoader::Context c = KIconLoader::Action) : context(c) | ||||
51 | { | ||||
52 | } | ||||
53 | //! Icon name | ||||
54 | QString name; | ||||
55 | //! Icon color, when used for normal mode (QIcon::Normal). | ||||
56 | //! If the value is valid, default color will be replaced with it. | ||||
57 | QColor color; | ||||
58 | //! Icon color, when used for selected mode (QIcon::Selected). | ||||
59 | //! If the value is valid, default color will be replaced with it. | ||||
60 | QColor selectedColor; | ||||
61 | //! Icon color, when used for disabled palette group (QPalette::Disabled). | ||||
62 | //! If the value is valid, default color will be replaced with it. | ||||
63 | QColor disabledColor; | ||||
64 | //! Icon context such as "actions" | ||||
65 | KIconLoader::Context context; | ||||
66 | }; | ||||
67 | | ||||
68 | //! Application style. | ||||
69 | //! @todo make it configurable? | ||||
70 | namespace KexiStyle | ||||
71 | { | ||||
72 | //! Setup style for this application. Called once after creating of application. | ||||
73 | //! @return false on error, then @a errorMessage is set | ||||
74 | KEXIUTILS_EXPORT bool setupApplication(KLocalizedString *errorMessage); | ||||
75 | | ||||
76 | //! Setup style for @a frame. By default flat style is set (QFrame::NoFrame). | ||||
77 | KEXIUTILS_EXPORT void setupFrame(QFrame *frame); | ||||
78 | | ||||
79 | //! Setup style for the global view mode selector widget (KexiGlobalViewModeSelector). | ||||
80 | //! By default setupFrame() is called to set flat style, minimal fonts are set | ||||
81 | //! and a bit darker version of alternativePalette(). | ||||
82 | KEXIUTILS_EXPORT void setupGlobalViewModeSelector(QFrame *selector); | ||||
83 | | ||||
84 | //! Overpaints entire global view mode selector. By default it paints a dark shadow an arrow | ||||
85 | //! for selected item. If @a selectedRect is not null, provides geometry of selected item. | ||||
86 | KEXIUTILS_EXPORT void overpaintGlobalViewModeSelector(QWidget *widget, QPainter *painter, | ||||
87 | const QRect &selectedRect, | ||||
88 | const QColor &arrowColor); | ||||
89 | | ||||
90 | //! Overpaints global view mode selector's item. By default does nothing. | ||||
91 | KEXIUTILS_EXPORT void overpaintModeSelectorItem(QPainter *painter, | ||||
92 | const QStyleOptionViewItem &option, | ||||
93 | const QModelIndex &index); | ||||
94 | | ||||
95 | //! @return alternative palette based on @a palette. | ||||
96 | //! By default it is dark one based on Breeze colors. | ||||
97 | KEXIUTILS_EXPORT QPalette alternativePalette(const QPalette &palette); | ||||
98 | | ||||
99 | //! @return palette dedicated for side bars, based on @a palette. | ||||
100 | //! By default it equal to alternativePalette(). | ||||
101 | KEXIUTILS_EXPORT QPalette sidebarsPalette(const QPalette &palette); | ||||
102 | | ||||
103 | //! Sets sidebarsPalette(). If it's nonstandard palette, | ||||
104 | //! QWidget::setAutoFillBackground(true) is also called for the widget. | ||||
105 | KEXIUTILS_EXPORT void setSidebarsPalette(QWidget *widget); | ||||
106 | | ||||
107 | //! @return font @a font adjusted to make it a title font. | ||||
108 | //! By default capitalization is set for the font. | ||||
109 | KEXIUTILS_EXPORT QFont titleFont(const QFont &font); | ||||
110 | | ||||
111 | //! @return styled dark icon @a iconName of context @a iconContext. Group can be "actions", etc. | ||||
112 | //! The same styled icon can be used with light and dark background. Filename for dark | ||||
113 | //! variants should have "@dark" suffix. If proper file does not exist, null icon is returned. | ||||
114 | //! KIconLoader::Any means KIconLoader::Action. | ||||
115 | KEXIUTILS_EXPORT QIcon darkIcon(const QString &iconName, | ||||
116 | KIconLoader::Context iconContext = KIconLoader::Action); | ||||
117 | | ||||
118 | KEXIUTILS_EXPORT QIcon icon(const KexiStyledIconParameters ¶meters); | ||||
119 | | ||||
120 | //! Style definition for property pane | ||||
121 | class KEXIUTILS_EXPORT PropertyPane { | ||||
122 | public: | ||||
123 | PropertyPane(); | ||||
124 | void setupEditor(KPropertyEditorView *view) const; | ||||
125 | QPalette sectionTitlePalette(const QPalette &palette) const; | ||||
126 | QPalette labelPalette(const QPalette &palette) const; | ||||
127 | QPalette warningLabelPalette(const QPalette &palette) const; | ||||
128 | QFont font() const; | ||||
129 | void alterLineEditStyle(QLineEdit *edit) const; | ||||
130 | void alterComboBoxStyle(QComboBox *combo) const; | ||||
131 | void alterTitleFont(QWidget *widget) const; | ||||
132 | Q_REQUIRED_RESULT QVBoxLayout* createVLayout(QWidget *widget) const; | ||||
133 | Q_REQUIRED_RESULT QGridLayout* createFormLayout(QVBoxLayout *parentLayout) const; | ||||
134 | Q_REQUIRED_RESULT QLabel* createLabel(const QString &labelText) const; | ||||
135 | Q_REQUIRED_RESULT QLabel* createWarningLabel(const QString &labelText) const; | ||||
136 | QLabel* createTitleLabel(const QString &title, QVBoxLayout *lyr) const; | ||||
137 | void addLabelAndWidget(const QString &labelText, QWidget *widget, QGridLayout *formLayout) const; | ||||
138 | void setFormLabelAndWidgetVisible(QWidget *widget, QGridLayout *formLayout, bool set) const; | ||||
139 | | ||||
140 | //! @return icon suitable for use in the property pane's background | ||||
141 | QIcon icon(const QString &iconName) const; | ||||
142 | | ||||
143 | const QMargins margins; | ||||
144 | const int verticalSpacing; | ||||
145 | const int sectionTitleIndent; | ||||
146 | const int horizontalSpacingAfterIcon; | ||||
147 | const int horizontalSpacingAfterLabel; | ||||
148 | private: | ||||
149 | Q_DISABLE_COPY(PropertyPane) | ||||
150 | }; | ||||
151 | | ||||
152 | KEXIUTILS_EXPORT const PropertyPane& propertyPane(); | ||||
153 | } | ||||
154 | | ||||
155 | #endif // KEXISTYLE_H |