137 d->buttonColor = new HbPushButton(container); |
137 d->buttonColor = new HbPushButton(container); |
138 connect(d->buttonColor, SIGNAL(clicked()), SLOT(_q_setColor())); |
138 connect(d->buttonColor, SIGNAL(clicked()), SLOT(_q_setColor())); |
139 d->layout->addItem(d->buttonColor, 0, 3, 1, 1); |
139 d->layout->addItem(d->buttonColor, 0, 3, 1, 1); |
140 |
140 |
141 d->buttonAlignLeft = new HbPushButton(container); |
141 d->buttonAlignLeft = new HbPushButton(container); |
142 d->buttonAlignLeft->setIcon(HbIcon("qtg_mono_text_align_left.svg")); |
142 d->buttonAlignLeft->setIcon(HbIcon("qtg_mono_text_align_left")); |
143 d->buttonAlignLeft->setCheckable(true); |
143 d->buttonAlignLeft->setCheckable(true); |
144 connect(d->buttonAlignLeft, SIGNAL(toggled(bool)), SLOT(setAlignmentLeft(bool))); |
144 connect(d->buttonAlignLeft, SIGNAL(toggled(bool)), SLOT(setAlignmentLeft(bool))); |
145 connect(d->buttonAlignLeft, SIGNAL(toggled(bool)), SLOT(_q_setAlignment(bool))); |
145 connect(d->buttonAlignLeft, SIGNAL(toggled(bool)), SLOT(_q_setAlignment(bool))); |
146 d->layout->addItem(d->buttonAlignLeft, 1, 0); |
146 d->layout->addItem(d->buttonAlignLeft, 1, 0); |
147 |
147 |
148 d->buttonAlignCenter = new HbPushButton(container); |
148 d->buttonAlignCenter = new HbPushButton(container); |
149 d->buttonAlignCenter->setIcon(HbIcon("qtg_mono_text_align_center.svg")); |
149 d->buttonAlignCenter->setIcon(HbIcon("qtg_mono_text_align_center")); |
150 d->buttonAlignCenter->setCheckable(true); |
150 d->buttonAlignCenter->setCheckable(true); |
151 connect(d->buttonAlignCenter, SIGNAL(toggled(bool)), SLOT(setAlignmentCenter(bool))); |
151 connect(d->buttonAlignCenter, SIGNAL(toggled(bool)), SLOT(setAlignmentCenter(bool))); |
152 connect(d->buttonAlignCenter, SIGNAL(toggled(bool)), SLOT(_q_setAlignment(bool))); |
152 connect(d->buttonAlignCenter, SIGNAL(toggled(bool)), SLOT(_q_setAlignment(bool))); |
153 d->layout->addItem(d->buttonAlignCenter, 1, 1); |
153 d->layout->addItem(d->buttonAlignCenter, 1, 1); |
154 |
154 |
155 d->buttonAlignRight = new HbPushButton(container); |
155 d->buttonAlignRight = new HbPushButton(container); |
156 d->buttonAlignRight->setIcon(HbIcon("qtg_mono_text_align_right.svg")); |
156 d->buttonAlignRight->setIcon(HbIcon("qtg_mono_text_align_right")); |
157 d->buttonAlignRight->setCheckable(true); |
157 d->buttonAlignRight->setCheckable(true); |
158 connect(d->buttonAlignRight, SIGNAL(toggled(bool)), SLOT(setAlignmentRight(bool))); |
158 connect(d->buttonAlignRight, SIGNAL(toggled(bool)), SLOT(setAlignmentRight(bool))); |
159 connect(d->buttonAlignRight, SIGNAL(toggled(bool)), SLOT(_q_setAlignment(bool))); |
159 connect(d->buttonAlignRight, SIGNAL(toggled(bool)), SLOT(_q_setAlignment(bool))); |
160 d->layout->addItem(d->buttonAlignRight, 1, 2); |
160 d->layout->addItem(d->buttonAlignRight, 1, 2); |
161 |
161 |
162 d->buttonAlignJustify = new HbPushButton(container); |
162 d->buttonAlignJustify = new HbPushButton(container); |
163 d->buttonAlignJustify->setIcon(HbIcon("qtg_mono_text_align_justify.svg")); |
163 d->buttonAlignJustify->setIcon(HbIcon("qtg_mono_text_align_justify")); |
164 d->buttonAlignJustify->setCheckable(true); |
164 d->buttonAlignJustify->setCheckable(true); |
165 connect(d->buttonAlignJustify, SIGNAL(toggled(bool)), SLOT(setAlignmentJustify(bool))); |
165 connect(d->buttonAlignJustify, SIGNAL(toggled(bool)), SLOT(setAlignmentJustify(bool))); |
166 connect(d->buttonAlignJustify, SIGNAL(toggled(bool)), SLOT(_q_setAlignment(bool))); |
166 connect(d->buttonAlignJustify, SIGNAL(toggled(bool)), SLOT(_q_setAlignment(bool))); |
167 d->layout->addItem(d->buttonAlignJustify, 1, 3); |
167 d->layout->addItem(d->buttonAlignJustify, 1, 3); |
168 |
168 |
169 d->buttonBold = new HbPushButton(container); |
169 d->buttonBold = new HbPushButton(container); |
170 d->buttonBold->setIcon(HbIcon("qtg_mono_bold.svg")); |
170 d->buttonBold->setIcon(HbIcon("qtg_mono_bold")); |
171 d->buttonBold->setCheckable(true); |
171 d->buttonBold->setCheckable(true); |
172 connect(d->buttonBold, SIGNAL(toggled(bool)), SLOT(setStyleBold(bool))); |
172 connect(d->buttonBold, SIGNAL(toggled(bool)), SLOT(setStyleBold(bool))); |
173 d->layout->addItem(d->buttonBold, 2, 0); |
173 d->layout->addItem(d->buttonBold, 2, 0); |
174 |
174 |
175 d->buttonItalic = new HbPushButton(container); |
175 d->buttonItalic = new HbPushButton(container); |
176 d->buttonItalic->setIcon(HbIcon("qtg_mono_italic.svg")); |
176 d->buttonItalic->setIcon(HbIcon("qtg_mono_italic")); |
177 d->buttonItalic->setCheckable(true); |
177 d->buttonItalic->setCheckable(true); |
178 connect(d->buttonItalic, SIGNAL(toggled(bool)), SLOT(setStyleItalic(bool))); |
178 connect(d->buttonItalic, SIGNAL(toggled(bool)), SLOT(setStyleItalic(bool))); |
179 d->layout->addItem(d->buttonItalic, 2, 1); |
179 d->layout->addItem(d->buttonItalic, 2, 1); |
180 |
180 |
181 d->buttonUnderline = new HbPushButton(container); |
181 d->buttonUnderline = new HbPushButton(container); |
182 d->buttonUnderline->setIcon(HbIcon("qtg_mono_underline.svg")); |
182 d->buttonUnderline->setIcon(HbIcon("qtg_mono_underline")); |
183 d->buttonUnderline->setCheckable(true); |
183 d->buttonUnderline->setCheckable(true); |
184 connect(d->buttonUnderline, SIGNAL(toggled(bool)), SLOT(setStyleUnderline(bool))); |
184 connect(d->buttonUnderline, SIGNAL(toggled(bool)), SLOT(setStyleUnderline(bool))); |
185 d->layout->addItem(d->buttonUnderline, 2, 2); |
185 d->layout->addItem(d->buttonUnderline, 2, 2); |
186 |
186 |
187 d->buttonBullet = new HbPushButton(container); |
187 d->buttonBullet = new HbPushButton(container); |
188 d->buttonBullet->setIcon(HbIcon("qtg_mono_bullet.svg")); |
188 d->buttonBullet->setIcon(HbIcon("qtg_mono_bullet")); |
189 d->buttonBullet->setCheckable(true); |
189 d->buttonBullet->setCheckable(true); |
190 connect(d->buttonBullet, SIGNAL(toggled(bool)), SLOT(setStyleBullet(bool))); |
190 connect(d->buttonBullet, SIGNAL(toggled(bool)), SLOT(setStyleBullet(bool))); |
191 d->layout->addItem(d->buttonBullet, 2, 3); |
191 d->layout->addItem(d->buttonBullet, 2, 3); |
192 |
192 |
193 container->setLayout(d->layout); |
193 container->setLayout(d->layout); |
260 int position = cursor.position(); |
259 int position = cursor.position(); |
261 QChar currentChar = cursor.document()->characterAt(position); |
260 QChar currentChar = cursor.document()->characterAt(position); |
262 cursor.select(QTextCursor::WordUnderCursor); |
261 cursor.select(QTextCursor::WordUnderCursor); |
263 int selectionStart = cursor.selectionStart(); |
262 int selectionStart = cursor.selectionStart(); |
264 int selectionEnd = cursor.selectionEnd(); |
263 int selectionEnd = cursor.selectionEnd(); |
265 if (position == selectionStart || position == selectionEnd || currentChar.isSpace()) { |
264 if (position == selectionStart || position == selectionEnd || currentChar.isSpace()) { |
266 HbAbstractEditPrivate::d_ptr(d->editor)->nextCharCursor.mergeCharFormat(format); |
265 HbAbstractEditPrivate::d_ptr(d->editor)->nextCharCursor.mergeCharFormat(format); |
267 } else { |
266 } else { |
268 cursor.mergeCharFormat(format); |
267 cursor.mergeCharFormat(format); |
269 } |
268 } |
270 } |
269 } |
|
270 } |
|
271 |
|
272 /*! |
|
273 Gets current character color, which can be either default or user changed. |
|
274 */ |
|
275 QColor HbFormatDialog::currentCharColor() const |
|
276 { |
|
277 Q_D(const HbFormatDialog); |
|
278 |
|
279 if (!d->editor) return QColor().convertTo(QColor::Invalid); |
|
280 QTextCharFormat format = d->editor->textCursor().charFormat(); |
|
281 QVariant property = format.property(QTextFormat::ForegroundBrush); |
|
282 bool isBrush = (property.userType() == QVariant::Brush); |
|
283 QColor color = format.colorProperty(QTextFormat::ForegroundBrush); |
|
284 QColor foregoundColor = format.foreground().color(); |
|
285 QColor defaultColor = d->editor->palette().color(QPalette::Text); |
|
286 return (isBrush && !color.isValid()) ? foregoundColor : defaultColor; |
271 } |
287 } |
272 |
288 |
273 /*! |
289 /*! |
274 Sets font size as \a size for a selection, word under cursor or new chars after cursor position |
290 Sets font size as \a size for a selection, word under cursor or new chars after cursor position |
275 */ |
291 */ |