79 , m_page(new QWidget(this))
85 KGuiItem::assign(
m_textEditorWidget.buttons->button(QDialogButtonBox::Save), KStandardGuiItem::save());
86 KGuiItem::assign(
m_textEditorWidget.buttons->button(QDialogButtonBox::Cancel), KStandardGuiItem::cancel());
91 KConfigGroup cg(KSharedConfig::openConfig(),
"SvgTextTool");
96 if (cg.hasKey(
"WindowState")) {
97 QByteArray state = cg.readEntry(
"State", QByteArray());
99 restoreState(QByteArray::fromBase64(state));
101 if (cg.hasKey(
"Geometry")) {
102 QByteArray ba = cg.readEntry(
"Geometry", QByteArray());
103 restoreGeometry(QByteArray::fromBase64(ba));
107 QRect desk = QGuiApplication::screens().at(scnum)->availableGeometry();
109 quint32 x = desk.x();
110 quint32 y = desk.y();
113 const int deskWidth = desk.width();
114 w = (deskWidth / 3) * 2;
115 h = (desk.height() / 3) * 2;
116 x += (desk.width() - w) / 2;
117 y += (desk.height() - h) / 2;
120 setGeometry(geometry().x(), geometry().y(), w, h);
124 setAcceptDrops(
true);
127 setUnifiedTitleAndToolBarOnMac(
true);
129 setTabPosition(Qt::AllDockWidgetAreas, QTabWidget::North);
132 m_textEditorWidget.svgTextEdit->setFont(QFontDatabase().systemFont(QFontDatabase::FixedFont));
223 findDialog.setWindowTitle(i18n(
"Find Text"));
224 QFormLayout *layout =
new QFormLayout(&findDialog);
225 QLineEdit *lnSearchKey =
new QLineEdit();
226 layout->addRow(i18n(
"Find:"), lnSearchKey);
227 QDialogButtonBox *
buttons =
new QDialogButtonBox(QDialogButtonBox::Ok|QDialogButtonBox::Cancel);
230 KGuiItem::assign(
buttons->button(QDialogButtonBox::Ok), KStandardGuiItem::ok());
231 KGuiItem::assign(
buttons->button(QDialogButtonBox::Cancel), KStandardGuiItem::cancel());
233 connect(
buttons, SIGNAL(accepted()), &findDialog, SLOT(accept()));
234 connect(
buttons, SIGNAL(rejected()), &findDialog, SLOT(reject()));
236 if (findDialog.exec() == QDialog::Accepted) {
265 findDialog.setWindowTitle(i18n(
"Find and Replace all"));
266 QFormLayout *layout =
new QFormLayout(&findDialog);
267 QLineEdit *lnSearchKey =
new QLineEdit();
268 QLineEdit *lnReplaceKey =
new QLineEdit();
269 layout->addRow(i18n(
"Find:"), lnSearchKey);
270 QDialogButtonBox *
buttons =
new QDialogButtonBox(QDialogButtonBox::Ok|QDialogButtonBox::Cancel);
271 layout->addRow(i18n(
"Replace:"), lnReplaceKey);
274 KGuiItem::assign(
buttons->button(QDialogButtonBox::Ok), KStandardGuiItem::ok());
275 KGuiItem::assign(
buttons->button(QDialogButtonBox::Cancel), KStandardGuiItem::cancel());
277 connect(
buttons, SIGNAL(accepted()), &findDialog, SLOT(accept()));
278 connect(
buttons, SIGNAL(rejected()), &findDialog, SLOT(reject()));
280 if (findDialog.exec() == QDialog::Accepted) {
281 QString search = lnSearchKey->text();
282 QString
replace = lnReplaceKey->text();
284 cursor.movePosition(QTextCursor::Start);
308 Ui_WdgSvgTextSettings textSettings;
309 QWidget *settingsPage =
new QWidget(&settingsDialog);
311 textSettings.setupUi(settingsPage);
314 KConfigGroup cfg(KSharedConfig::openConfig(),
"SvgTextTool");
316 QColor background = cfg.readEntry(
"colorEditorBackground", qApp->palette().window().color());
317 textSettings.colorEditorBackground->setColor(background);
318 textSettings.colorEditorForeground->setColor(cfg.readEntry(
"colorEditorForeground", qApp->palette().text().color()));
320 textSettings.colorKeyword->setColor(cfg.readEntry(
"colorKeyword", QColor(background.value() < 100 ? Qt::cyan : Qt::blue)));
321 textSettings.chkBoldKeyword->setChecked(cfg.readEntry(
"BoldKeyword",
true));
322 textSettings.chkItalicKeyword->setChecked(cfg.readEntry(
"ItalicKeyword",
false));
324 textSettings.colorElement->setColor(cfg.readEntry(
"colorElement", QColor(background.value() < 100 ? Qt::magenta : Qt::darkMagenta)));
325 textSettings.chkBoldElement->setChecked(cfg.readEntry(
"BoldElement",
true));
326 textSettings.chkItalicElement->setChecked(cfg.readEntry(
"ItalicElement",
false));
328 textSettings.colorAttribute->setColor(cfg.readEntry(
"colorAttribute", QColor(background.value() < 100 ? Qt::green : Qt::darkGreen)));
329 textSettings.chkBoldAttribute->setChecked(cfg.readEntry(
"BoldAttribute",
true));
330 textSettings.chkItalicAttribute->setChecked(cfg.readEntry(
"ItalicAttribute",
true));
332 textSettings.colorValue->setColor(cfg.readEntry(
"colorValue", QColor(background.value() < 100 ? Qt::red: Qt::darkRed)));
333 textSettings.chkBoldValue->setChecked(cfg.readEntry(
"BoldValue",
true));
334 textSettings.chkItalicValue->setChecked(cfg.readEntry(
"ItalicValue",
false));
336 textSettings.colorComment->setColor(cfg.readEntry(
"colorComment", QColor(background.value() < 100 ? Qt::lightGray : Qt::gray)));
337 textSettings.chkBoldComment->setChecked(cfg.readEntry(
"BoldComment",
false));
338 textSettings.chkItalicComment->setChecked(cfg.readEntry(
"ItalicComment",
false));
341 if (settingsDialog.exec() == QDialog::Accepted) {
343 cfg.writeEntry(
"colorEditorBackground", textSettings.colorEditorBackground->color());
344 cfg.writeEntry(
"colorEditorForeground", textSettings.colorEditorForeground->color());
346 cfg.writeEntry(
"colorKeyword", textSettings.colorKeyword->color());
347 cfg.writeEntry(
"BoldKeyword", textSettings.chkBoldKeyword->isChecked());
348 cfg.writeEntry(
"ItalicKeyWord", textSettings.chkItalicKeyword->isChecked());
350 cfg.writeEntry(
"colorElement", textSettings.colorElement->color());
351 cfg.writeEntry(
"BoldElement", textSettings.chkBoldElement->isChecked());
352 cfg.writeEntry(
"ItalicElement", textSettings.chkItalicElement->isChecked());
354 cfg.writeEntry(
"colorAttribute", textSettings.colorAttribute->color());
355 cfg.writeEntry(
"BoldAttribute", textSettings.chkBoldAttribute->isChecked());
356 cfg.writeEntry(
"ItalicAttribute", textSettings.chkItalicAttribute->isChecked());
358 cfg.writeEntry(
"colorValue", textSettings.colorValue->color());
359 cfg.writeEntry(
"BoldValue", textSettings.chkBoldValue->isChecked());
360 cfg.writeEntry(
"ItalicValue", textSettings.chkItalicValue->isChecked());
362 cfg.writeEntry(
"colorComment", textSettings.colorComment->color());
363 cfg.writeEntry(
"BoldComment", textSettings.chkBoldComment->isChecked());
364 cfg.writeEntry(
"ItalicComment", textSettings.chkItalicComment->isChecked());
406 KConfigGroup cfg(KSharedConfig::openConfig(),
"SvgTextTool");
408 m_page->setUpdatesEnabled(
false);
414 QColor background = cfg.readEntry(
"colorEditorBackground", qApp->palette().window().color());
415 palette.setBrush(QPalette::Active, QPalette::Window, QBrush(background));
416 m_textEditorWidget.svgStylesEdit->setStyleSheet(QString(
"background-color:%1").arg(background.name()));
417 m_textEditorWidget.svgTextEdit->setStyleSheet(QString(
"background-color:%1").arg(background.name()));
419 QColor foreground = cfg.readEntry(
"colorEditorForeground", qApp->palette().text().color());
420 palette.setBrush(QPalette::Active, QPalette::Text, QBrush(foreground));
422 m_page->setUpdatesEnabled(
true);
bool convertToSvg(QString *svgText, QString *stylesText)
void setModified(bool modified)
QAction * createAction(const QString &name, const char *member)
SvgTextEditor(QWidget *parent=0, Qt::WindowFlags f=Qt::WindowFlags())
bool eventFilter(QObject *watched, QEvent *event) override
BasicXMLSyntaxHighlighter * m_syntaxHighlighter
void dialogButtonClicked(QAbstractButton *button)
QList< QAction * > m_svgTextActions
void textUpdated(KoSvgTextShape *shape, const QString &svg, const QString &defs)
void setInitialShape(KoSvgTextShape *shape)
void wheelEvent(QWheelEvent *event) override
Ui_WdgSvgTextEditor m_textEditorWidget