38 #include "hbformatdialog.h" |
38 #include "hbformatdialog.h" |
39 |
39 |
40 #include <hbabstractedit.h> |
40 #include <hbabstractedit.h> |
41 #include <hbpushbutton.h> |
41 #include <hbpushbutton.h> |
42 #include <hbcolordialog.h> |
42 #include <hbcolordialog.h> |
|
43 #include <hbcolorscheme.h> |
43 |
44 |
44 #include <QSharedData> |
45 #include <QSharedData> |
45 #include <QTextCursor> |
46 #include <QTextCursor> |
46 #include <QPainter> |
47 #include <QPainter> |
47 |
48 |
48 HbFormatDialogPrivate::HbFormatDialogPrivate() : |
49 HbFormatDialogPrivate::HbFormatDialogPrivate() : editor(0) |
49 editor(0) |
|
50 {} |
50 {} |
51 |
51 |
52 HbFormatDialogPrivate::~HbFormatDialogPrivate() |
52 HbFormatDialogPrivate::~HbFormatDialogPrivate() |
53 {} |
53 {} |
54 |
54 |
76 { |
76 { |
77 Q_Q(HbFormatDialog); |
77 Q_Q(HbFormatDialog); |
78 QTextCursor cursor = editor->textCursor(); |
78 QTextCursor cursor = editor->textCursor(); |
79 QTextCharFormat fmt = cursor.charFormat(); |
79 QTextCharFormat fmt = cursor.charFormat(); |
80 QColor color = fmt.foreground().color(); |
80 QColor color = fmt.foreground().color(); |
81 HbColorDialog dialog; |
81 QList<QColor> defaultColors; |
82 dialog.setInitialColor(color); |
82 HbColorDialog::getColor(defaultColors, color, q, SLOT(_q_colorSelected(const QColor &))); |
83 color = dialog.getColor(); |
83 } |
|
84 |
|
85 void HbFormatDialogPrivate::_q_colorSelected(const QColor &color) |
|
86 { |
|
87 Q_Q(HbFormatDialog); |
|
88 QTextCursor cursor = editor->textCursor(); |
|
89 QTextCharFormat fmt = cursor.charFormat(); |
84 if (!color.isValid()) |
90 if (!color.isValid()) |
85 return; |
91 return; |
86 fmt.setForeground(color); |
92 fmt.setForeground(color); |
87 q->mergeCharFormat(fmt); |
93 q->mergeCharFormat(fmt); |
88 colorChanged(color); |
94 colorChanged(color); |
89 } |
95 } |
90 |
96 |
91 void HbFormatDialogPrivate::colorChanged(const QColor &color) |
97 void HbFormatDialogPrivate::colorChanged(const QColor &color) |
92 { |
98 { |
93 HbIcon icon("qtg_graf_colorpicker_filled"); |
99 HbIcon icon("qtg_graf_colorpicker_filled"); |
|
100 icon.setFlags(HbIcon::Colorized); |
|
101 icon.setColor(HbColorScheme::color("qtc_button_normal")); |
94 HbIcon maskIcon("qtg_graf_colorpicker_mask"); |
102 HbIcon maskIcon("qtg_graf_colorpicker_mask"); |
95 QPixmap maskPixmap = maskIcon.pixmap(); |
103 QPixmap maskPixmap = maskIcon.pixmap(); |
96 QPainter mp(&maskPixmap); |
104 QPainter mp(&maskPixmap); |
97 mp.setCompositionMode(QPainter::CompositionMode_SourceIn); |
105 mp.setCompositionMode(QPainter::CompositionMode_SourceIn); |
98 mp.fillRect(maskPixmap.rect(),color); |
106 mp.fillRect(maskPixmap.rect(),color); |
99 mp.setCompositionMode(QPainter::CompositionMode_DestinationOver); |
107 mp.setCompositionMode(QPainter::CompositionMode_DestinationOver); |
100 icon.paint(&mp,maskPixmap.rect()); |
108 icon.paint(&mp,maskPixmap.rect()); |
101 mp.end(); |
109 mp.end(); |