Changeset View
Changeset View
Standalone View
Standalone View
src/widgets/colortoolwidget.cpp
Show All 16 Lines | |||||
17 | * You should have received a copy of the GNU General Public License * | 17 | * You should have received a copy of the GNU General Public License * | ||
18 | * along with this program; if not, write to the * | 18 | * along with this program; if not, write to the * | ||
19 | * Free Software Foundation, Inc., * | 19 | * Free Software Foundation, Inc., * | ||
20 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * | 20 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * | ||
21 | *********************************************************************************/ | 21 | *********************************************************************************/ | ||
22 | 22 | | |||
23 | #include "colortoolwidget.h" | 23 | #include "colortoolwidget.h" | ||
24 | 24 | | |||
25 | #include <QtGui/QMouseEvent> | 25 | #include <QMouseEvent> | ||
26 | #include <QtGui/QLayout> | 26 | #include <QLayout> | ||
27 | #include <QtGui/QLabel> | 27 | #include <QLabel> | ||
28 | #include <QtGui/QSlider> | 28 | #include <QSlider> | ||
29 | #include <QtGui/QGroupBox> | 29 | #include <QGroupBox> | ||
30 | #include <QtGui/QDesktopWidget> | 30 | #include <QDesktopWidget> | ||
31 | #include <QPushButton> | ||||
31 | 32 | | |||
32 | #include <KIcon> | | |||
33 | #include <KApplication> | 33 | #include <KApplication> | ||
34 | #include <KLocalizedString> | 34 | #include <KLocalizedString> | ||
35 | #include <KPushButton> | | |||
36 | #include <KColorPatch> | 35 | #include <KColorPatch> | ||
37 | 36 | | |||
38 | #ifdef Q_WS_X11 | 37 | #ifdef Q_WS_X11 | ||
39 | 38 | | |||
40 | #include <X11/Xlib.h> | 39 | #include <X11/Xlib.h> | ||
41 | #include <X11/Xutil.h> | 40 | #include <X11/Xutil.h> | ||
42 | #include <QX11Info> | 41 | #include <QX11Info> | ||
43 | #include <fixx11h.h> | 42 | #include <fixx11h.h> | ||
44 | 43 | | |||
45 | #include <QtGui/QCheckBox> | 44 | #include <QCheckBox> | ||
46 | 45 | | |||
47 | #include <KWindowSystem> | 46 | #include <KWindowSystem> | ||
48 | 47 | | |||
49 | class KCDPickerFilter: public QWidget | 48 | class KCDPickerFilter: public QWidget | ||
50 | { | 49 | { | ||
51 | public: | 50 | public: | ||
52 | KCDPickerFilter(QWidget* parent): QWidget(parent) {} | 51 | KCDPickerFilter(QWidget* parent): QWidget(parent) {} | ||
53 | 52 | | |||
Show All 23 Lines | 73 | { | |||
77 | //BEGIN Brightness settings | 76 | //BEGIN Brightness settings | ||
78 | 77 | | |||
79 | m_brightnessPercentage = new QLabel(i18n("Brightness"), this); | 78 | m_brightnessPercentage = new QLabel(i18n("Brightness"), this); | ||
80 | 79 | | |||
81 | m_brightnessSlider = new QSlider(this); | 80 | m_brightnessSlider = new QSlider(this); | ||
82 | m_brightnessSlider->setOrientation(Qt::Horizontal); | 81 | m_brightnessSlider->setOrientation(Qt::Horizontal); | ||
83 | m_brightnessSlider->setRange(0, 255); | 82 | m_brightnessSlider->setRange(0, 255); | ||
84 | 83 | | |||
85 | KPushButton *defaultBrightnessButton = new KPushButton(KGuiItem("", "edit-undo"), this); | 84 | QPushButton *defaultBrightnessButton = new QPushButton(this); | ||
85 | KGuiItem::assign(defaultBrightnessButton, KGuiItem("", "edit-undo")); | ||||
86 | defaultBrightnessButton->setToolTip(i18nc("color context: brightness", "Restore original brightness")); | 86 | defaultBrightnessButton->setToolTip(i18nc("color context: brightness", "Restore original brightness")); | ||
87 | 87 | | |||
88 | QHBoxLayout * brightnessLayout = new QHBoxLayout(); | 88 | QHBoxLayout * brightnessLayout = new QHBoxLayout(); | ||
89 | brightnessLayout->addWidget(m_brightnessPercentage); | 89 | brightnessLayout->addWidget(m_brightnessPercentage); | ||
90 | brightnessLayout->addStretch(1); | 90 | brightnessLayout->addStretch(1); | ||
91 | brightnessLayout->addWidget(m_brightnessSlider); | 91 | brightnessLayout->addWidget(m_brightnessSlider); | ||
92 | brightnessLayout->addWidget(defaultBrightnessButton); | 92 | brightnessLayout->addWidget(defaultBrightnessButton); | ||
93 | 93 | | |||
94 | connect(m_brightnessSlider, SIGNAL( valueChanged(int) ), SLOT( changeBrightnessValue(int) )); | 94 | connect(m_brightnessSlider, SIGNAL( valueChanged(int) ), SLOT( changeBrightnessValue(int) )); | ||
95 | connect(defaultBrightnessButton, SIGNAL( pressed () ), SLOT( setupDefaultBrightness() )); | 95 | connect(defaultBrightnessButton, SIGNAL( pressed () ), SLOT( setupDefaultBrightness() )); | ||
96 | 96 | | |||
97 | //END Brightness settings | 97 | //END Brightness settings | ||
98 | 98 | | |||
99 | //BEGIN Saturation settings | 99 | //BEGIN Saturation settings | ||
100 | 100 | | |||
101 | m_saturationPercentage = new QLabel(i18n("Saturation"), this); | 101 | m_saturationPercentage = new QLabel(i18n("Saturation"), this); | ||
102 | 102 | | |||
103 | m_saturationSlider = new QSlider(this); | 103 | m_saturationSlider = new QSlider(this); | ||
104 | m_saturationSlider->setOrientation(Qt::Horizontal); | 104 | m_saturationSlider->setOrientation(Qt::Horizontal); | ||
105 | m_saturationSlider->setRange(0, 255); | 105 | m_saturationSlider->setRange(0, 255); | ||
106 | 106 | | |||
107 | KPushButton *defaultSaturationButton = new KPushButton(KGuiItem("", "edit-undo"), this); | 107 | QPushButton *defaultSaturationButton = new QPushButton(this); | ||
108 | KGuiItem::assign(defaultSaturationButton, KGuiItem("", "edit-undo")); | ||||
108 | defaultSaturationButton->setToolTip(i18nc("color context: saturation of the color", "Restore original saturation")); | 109 | defaultSaturationButton->setToolTip(i18nc("color context: saturation of the color", "Restore original saturation")); | ||
109 | 110 | | |||
110 | QHBoxLayout * saturationLayout = new QHBoxLayout(); | 111 | QHBoxLayout * saturationLayout = new QHBoxLayout(); | ||
111 | saturationLayout->addWidget(m_saturationPercentage); | 112 | saturationLayout->addWidget(m_saturationPercentage); | ||
112 | saturationLayout->addStretch(1); | 113 | saturationLayout->addStretch(1); | ||
113 | saturationLayout->addWidget(m_saturationSlider); | 114 | saturationLayout->addWidget(m_saturationSlider); | ||
114 | saturationLayout->addWidget(defaultSaturationButton); | 115 | saturationLayout->addWidget(defaultSaturationButton); | ||
115 | 116 | | |||
116 | connect(m_saturationSlider, SIGNAL( valueChanged(int) ), SLOT( changeSaturationValue(int) )); | 117 | connect(m_saturationSlider, SIGNAL( valueChanged(int) ), SLOT( changeSaturationValue(int) )); | ||
117 | connect(defaultSaturationButton, SIGNAL( pressed () ), SLOT( setupDefaultSaturation() )); | 118 | connect(defaultSaturationButton, SIGNAL( pressed () ), SLOT( setupDefaultSaturation() )); | ||
118 | 119 | | |||
119 | //END Saturation settings | 120 | //END Saturation settings | ||
120 | 121 | | |||
121 | //BEGIN Extra color selectors settings | 122 | //BEGIN Extra color selectors settings | ||
122 | 123 | | |||
123 | QGroupBox * extraSelectorsBox = new QGroupBox(i18n("Color Selectors"), this); | 124 | QGroupBox * extraSelectorsBox = new QGroupBox(i18n("Color Selectors"), this); | ||
124 | 125 | | |||
125 | KPushButton * pickColorButton = new KPushButton(KIcon("color-picker"), i18n("Pick a Color"), extraSelectorsBox); | 126 | QPushButton * pickColorButton = new QPushButton(QIcon::fromTheme("color-picker"), i18n("Pick a Color"), extraSelectorsBox); | ||
126 | 127 | | |||
127 | QHBoxLayout * pickColorLayout = new QHBoxLayout(); | 128 | QHBoxLayout * pickColorLayout = new QHBoxLayout(); | ||
128 | pickColorLayout->addWidget(pickColorButton); | 129 | pickColorLayout->addWidget(pickColorButton); | ||
129 | 130 | | |||
130 | #ifdef Q_WS_X11 | 131 | #ifdef Q_WS_X11 | ||
131 | 132 | | |||
132 | if (KWindowSystem::compositingActive()) | 133 | if (KWindowSystem::compositingActive()) | ||
133 | { | 134 | { | ||
▲ Show 20 Lines • Show All 245 Lines • ▼ Show 20 Line(s) | 379 | #else | |||
379 | 380 | | |||
380 | QWidget *desktop = KApplication::desktop(); | 381 | QWidget *desktop = KApplication::desktop(); | ||
381 | QPixmap pm = QPixmap::grabWindow(desktop->winId(), p.x(), p.y(), 1, 1); | 382 | QPixmap pm = QPixmap::grabWindow(desktop->winId(), p.x(), p.y(), 1, 1); | ||
382 | QImage i = pm.toImage(); | 383 | QImage i = pm.toImage(); | ||
383 | return i.pixel(0, 0); | 384 | return i.pixel(0, 0); | ||
384 | 385 | | |||
385 | #endif | 386 | #endif | ||
386 | } | 387 | } | ||
387 | | ||||
388 | #include "colortoolwidget.moc" | |