Krita Source Code Documentation
Loading...
Searching...
No Matches
SvgTextEditor Class Reference

#include <SvgTextEditor.h>

+ Inheritance diagram for SvgTextEditor:

Classes

class  Private
 

Signals

void textEditorClosed ()
 
void textUpdated (KoSvgTextShape *shape, const QString &svg, const QString &defs)
 

Public Member Functions

void setInitialShape (KoSvgTextShape *shape)
 
 SvgTextEditor (QWidget *parent=0, Qt::WindowFlags f=Qt::WindowFlags())
 
 ~SvgTextEditor ()
 
- Public Member Functions inherited from KXmlGuiWindow
void applyMainWindowSettings (const KConfigGroup &config) override
 
void createGUI (const QString &xmlfile=QString())
 
void createStandardStatusBarAction ()
 
void finalizeGUI (bool force)
 
void finalizeGUI (KisKXMLGUIClient *client) override
 
virtual KisKXMLGUIFactoryguiFactory ()
 
bool isHelpMenuEnabled () const
 
bool isStandardToolBarMenuEnabled () const
 
 KXmlGuiWindow (QWidget *parent=0, Qt::WindowFlags f=Qt::WindowFlags())
 
void setHelpMenuEnabled (bool showHelpMenu=true)
 
void setStandardToolBarMenuEnabled (bool enable)
 
void setupGUI (const QSize &defaultSize, StandardWindowOptions options=Default, const QString &xmlfile=QString())
 
void setupGUI (StandardWindowOptions options=Default, const QString &xmlfile=QString())
 
void setupToolbarMenuActions ()
 
QAction * toolBarMenuAction ()
 
 ~KXmlGuiWindow () override
 Destructor.
 
- Public Member Functions inherited from KisKMainWindow
KConfigGroup autoSaveConfigGroup () const
 
QString autoSaveGroup () const
 
bool autoSaveSettings () const
 
QString dbusName () const
 
bool hasMenuBar ()
 
 KisKMainWindow (QWidget *parent=0, Qt::WindowFlags f=Qt::WindowFlags())
 
void resetAutoSaveSettings ()
 
bool restore (int number, bool show=true)
 
void saveMainWindowSettings (KConfigGroup &config)
 
void setAutoSaveSettings (const KConfigGroup &group, bool saveWindowSize=true)
 
void setAutoSaveSettings (const QString &groupName=QLatin1String("MainWindow"), bool saveWindowSize=true)
 
KisToolBartoolBar (const QString &name=QString())
 
QList< KisToolBar * > toolBars () const
 
 ~KisKMainWindow () override
 Destructor.
 
- Public Member Functions inherited from KisKXMLGUIBuilder
KisKXMLGUIClientbuilderClient () const
 
virtual QStringList containerTags () const
 
virtual QWidget * createContainer (QWidget *parent, int index, const QDomElement &element, QAction *&containerAction)
 
virtual QAction * createCustomElement (QWidget *parent, int index, const QDomElement &element)
 
virtual QStringList customTags () const
 
 KisKXMLGUIBuilder (QWidget *widget)
 
virtual void removeContainer (QWidget *container, QWidget *parent, QDomElement &element, QAction *containerAction)
 
virtual void removeCustomElement (QWidget *parent, QAction *action)
 
void setBuilderClient (KisKXMLGUIClient *client)
 
QWidget * widget ()
 
virtual ~KisKXMLGUIBuilder ()
 
- Public Member Functions inherited from KisKXMLGUIClient
QAction * action (const char *name) const
 
virtual QAction * action (const QDomElement &element) const
 
virtual KisKActionCollectionactionCollection () const
 
void addStateActionDisabled (const QString &state, const QString &action)
 
void addStateActionEnabled (const QString &state, const QString &action)
 
void beginXMLPlug (QWidget *)
 
QList< KisKXMLGUIClient * > childClients ()
 
KisKXMLGUIBuilderclientBuilder () const
 
virtual QString componentName () const
 
virtual QDomDocument domDocument () const
 
void endXMLPlug ()
 
KisKXMLGUIFactoryfactory () const
 
StateChange getActionsToChangeForState (const QString &state)
 
void insertChildClient (KisKXMLGUIClient *child)
 
 KisKXMLGUIClient ()
 
 KisKXMLGUIClient (KisKXMLGUIClient *parent)
 
virtual QString localXMLFile () const
 
KisKXMLGUIClientparentClient () const
 
void plugActionList (const QString &name, const QList< QAction * > &actionList)
 
void prepareXMLUnplug (QWidget *)
 
void reloadXML ()
 
void removeChildClient (KisKXMLGUIClient *child)
 
void replaceXMLFile (const QString &xmlfile, const QString &localxmlfile, bool merge=false)
 
void setClientBuilder (KisKXMLGUIBuilder *builder)
 
void setFactory (KisKXMLGUIFactory *factory)
 
void setXMLGUIBuildDocument (const QDomDocument &doc)
 
void unplugActionList (const QString &name)
 
virtual QString xmlFile () const
 
QDomDocument xmlguiBuildDocument () const
 
virtual ~KisKXMLGUIClient ()
 

Protected Member Functions

bool eventFilter (QObject *watched, QEvent *event) override
 
void wheelEvent (QWheelEvent *event) override
 
- Protected Member Functions inherited from KXmlGuiWindow
bool event (QEvent *event) override
 
- Protected Member Functions inherited from KisKMainWindow
void closeEvent (QCloseEvent *) override
 
bool event (QEvent *event) override
 
 KisKMainWindow (KisKMainWindowPrivate &dd, QWidget *parent, Qt::WindowFlags f)
 
virtual bool queryClose ()
 
virtual void readGlobalProperties (KConfig *sessionConfig)
 
virtual void readProperties (const KConfigGroup &)
 
bool readPropertiesInternal (KConfig *, int)
 
virtual void saveGlobalProperties (KConfig *sessionConfig)
 
virtual void saveProperties (KConfigGroup &)
 
void savePropertiesInternal (KConfig *, int)
 
bool settingsDirty () const
 
virtual bool windowsLayoutSavingAllowed () const
 
- Protected Member Functions inherited from KisKXMLGUIBuilder
virtual void virtual_hook (int id, void *data)
 
- Protected Member Functions inherited from KisKXMLGUIClient
void loadStandardsXmlFile ()
 
virtual void setComponentName (const QString &componentName, const QString &componentDisplayName)
 
void setDOMDocument (const QDomDocument &document, bool merge=false)
 
void setLocalXMLFile (const QString &file)
 
void setXML (const QString &document, bool merge=false)
 
void setXMLFile (const QString &file, bool merge=false, bool setXMLDoc=true)
 
virtual void stateChanged (const QString &newstate, ReverseStateChange reverse=StateNoReverse)
 
virtual void virtual_hook (int id, void *data)
 

Private Slots

void copy ()
 
void cut ()
 
void deselect ()
 
void dialogButtonClicked (QAbstractButton *button)
 
void find ()
 
void findNext ()
 
void findPrev ()
 
void paste ()
 
void redo ()
 
void replace ()
 
void save ()
 
void selectAll ()
 
void setModified (bool modified)
 
void setSettings ()
 
void slotCloseEditor ()
 
void undo ()
 
void zoomIn ()
 
void zoomOut ()
 

Private Member Functions

void applySettings ()
 
QAction * createAction (const QString &name, const char *member)
 
void createActions ()
 

Private Attributes

QScopedPointer< Privated
 
QTextEdit * m_currentEditor {0}
 
QWidget * m_page {0}
 
QString m_searchKey
 
KoSvgTextShapem_shape {0}
 
QList< QAction * > m_svgTextActions
 
BasicXMLSyntaxHighlighterm_syntaxHighlighter
 
Ui_WdgSvgTextEditor m_textEditorWidget
 

Additional Inherited Members

- Public Types inherited from KXmlGuiWindow
enum  StandardWindowOption {
  ToolBar = 1 , Keys = 2 , StatusBar = 4 , Save = 8 ,
  Create = 16 , Default = ToolBar | Keys | StatusBar | Save | Create
}
 
- Public Types inherited from KisKXMLGUIClient
enum  ReverseStateChange { StateNoReverse , StateReverse }
 
- Public Slots inherited from KXmlGuiWindow
virtual void configureToolbars ()
 
virtual void slotStateChanged (const QString &newstate)
 
void slotStateChanged (const QString &newstate, bool reverse)
 
- Public Slots inherited from KisKMainWindow
void appHelpActivated (void)
 
void setSettingsDirty ()
 
- Static Public Member Functions inherited from KisKMainWindow
static bool canBeRestored (int number)
 
static const QString classNameOfToplevel (int number)
 
static QList< KisKMainWindow * > memberList ()
 
- Static Public Member Functions inherited from KisKXMLGUIClient
static QString findMostRecentXMLFile (const QStringList &files, QString &doc)
 
- Protected Slots inherited from KXmlGuiWindow
virtual void saveNewToolbarConfig ()
 
- Protected Slots inherited from KisKMainWindow
void saveAutoSaveSettings ()
 
- Static Protected Member Functions inherited from KisKXMLGUIClient
static QString standardsXmlFileLocation ()
 
- Protected Attributes inherited from KisKMainWindow
KisKMainWindowPrivate *const k_ptr
 
- Properties inherited from KXmlGuiWindow
QString autoSaveGroup
 
bool autoSaveSettings
 
bool hasMenuBar
 
bool standardToolBarMenuEnabled
 
- Properties inherited from KisKMainWindow
QString autoSaveGroup
 
bool autoSaveSettings
 
bool hasMenuBar
 

Detailed Description

Definition at line 26 of file SvgTextEditor.h.

Constructor & Destructor Documentation

◆ SvgTextEditor()

SvgTextEditor::SvgTextEditor ( QWidget * parent = 0,
Qt::WindowFlags f = Qt::WindowFlags() )

Definition at line 77 of file SvgTextEditor.cpp.

78 : KXmlGuiWindow(parent, flags)
79 , m_page(new QWidget(this))
80 , d(new Private())
81{
83 setCentralWidget(m_page);
84
85 KGuiItem::assign(m_textEditorWidget.buttons->button(QDialogButtonBox::Save), KStandardGuiItem::save());
86 KGuiItem::assign(m_textEditorWidget.buttons->button(QDialogButtonBox::Cancel), KStandardGuiItem::cancel());
87 connect(m_textEditorWidget.buttons, SIGNAL(accepted()), this, SLOT(save()));
88 connect(m_textEditorWidget.buttons, SIGNAL(rejected()), this, SLOT(slotCloseEditor()));
89 connect(m_textEditorWidget.buttons, SIGNAL(clicked(QAbstractButton*)), this, SLOT(dialogButtonClicked(QAbstractButton*)));
90
91 KConfigGroup cg(KSharedConfig::openConfig(), "SvgTextTool");
92 actionCollection()->setConfigGroup("SvgTextTool");
93 actionCollection()->setComponentName("svgtexttool");
94 actionCollection()->setComponentDisplayName(i18n("Text Tool"));
95
96 if (cg.hasKey("WindowState")) {
97 QByteArray state = cg.readEntry("State", QByteArray());
98 // One day will need to load the version number, but for now, assume 0
99 restoreState(QByteArray::fromBase64(state));
100 }
101 if (cg.hasKey("Geometry")) {
102 QByteArray ba = cg.readEntry("Geometry", QByteArray());
103 restoreGeometry(QByteArray::fromBase64(ba));
104 }
105 else {
106 const int scnum = KisPortingUtils::getScreenNumberForWidget(QApplication::activeWindow());
107 QRect desk = QGuiApplication::screens().at(scnum)->availableGeometry();
108
109 quint32 x = desk.x();
110 quint32 y = desk.y();
111 quint32 w = 0;
112 quint32 h = 0;
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;
118
119 move(x,y);
120 setGeometry(geometry().x(), geometry().y(), w, h);
121
122 }
123
124 setAcceptDrops(true);
125 //setStandardToolBarMenuEnabled(true);
126#ifdef Q_OS_MACOS
127 setUnifiedTitleAndToolBarOnMac(true);
128#endif
129 setTabPosition(Qt::AllDockWidgetAreas, QTabWidget::North);
130
132 m_textEditorWidget.svgTextEdit->setFont(QFontDatabase().systemFont(QFontDatabase::FixedFont));
133
135 // If we have customized the toolbars, load that first
136 setLocalXMLFile(KoResourcePaths::locateLocal("data", "svgtexttool.xmlgui"));
137 setXMLFile(":/kxmlgui5/svgtexttool.xmlgui");
138
139 guiFactory()->addClient(this);
140
142
143}
connect(this, SIGNAL(optionsChanged()), this, SLOT(saveOptions()))
virtual KisKXMLGUIFactory * guiFactory()
KXmlGuiWindow(QWidget *parent=0, Qt::WindowFlags f=Qt::WindowFlags())
void setComponentDisplayName(const QString &displayName)
void setConfigGroup(const QString &group)
void setComponentName(const QString &componentName)
void setLocalXMLFile(const QString &file)
void setXMLFile(const QString &file, bool merge=false, bool setXMLDoc=true)
virtual KisKActionCollection * actionCollection() const
void addClient(KisKXMLGUIClient *client)
static QString locateLocal(const QString &type, const QString &filename, bool createDir=false)
BasicXMLSyntaxHighlighter * m_syntaxHighlighter
void dialogButtonClicked(QAbstractButton *button)
QScopedPointer< Private > d
QWidget * m_page
Ui_WdgSvgTextEditor m_textEditorWidget
KRITAWIDGETUTILS_EXPORT void restoreState(QWidget *parent, const QString &dialogName, const QMap< QString, QVariant > &defaults=QMap< QString, QVariant >())
restoreState restores the state of the dialog
int getScreenNumberForWidget(const QWidget *w)

References KisKXMLGUIClient::actionCollection(), KisKXMLGUIFactory::addClient(), applySettings(), connect(), createActions(), dialogButtonClicked(), KisPortingUtils::getScreenNumberForWidget(), KXmlGuiWindow::guiFactory(), KoResourcePaths::locateLocal(), m_page, m_syntaxHighlighter, m_textEditorWidget, save(), KisKActionCollection::setComponentDisplayName(), KisKActionCollection::setComponentName(), KisKActionCollection::setConfigGroup(), KisKXMLGUIClient::setLocalXMLFile(), KisKXMLGUIClient::setXMLFile(), and slotCloseEditor().

◆ ~SvgTextEditor()

SvgTextEditor::~SvgTextEditor ( )

Definition at line 145 of file SvgTextEditor.cpp.

146{
147 KConfigGroup g(KSharedConfig::openConfig(), "SvgTextTool");
148 QByteArray ba = saveState();
149 g.writeEntry("windowState", ba.toBase64());
150 ba = saveGeometry();
151 g.writeEntry("Geometry", ba.toBase64());
152}
KRITAWIDGETUTILS_EXPORT void saveState(QWidget *parent, const QString &dialogName)
saveState saves the state for the specified widgets

Member Function Documentation

◆ applySettings()

void SvgTextEditor::applySettings ( )
private

Definition at line 404 of file SvgTextEditor.cpp.

405{
406 KConfigGroup cfg(KSharedConfig::openConfig(), "SvgTextTool");
407
408 m_page->setUpdatesEnabled(false);
409
411
412 QPalette palette = m_textEditorWidget.svgTextEdit->palette();
413
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()));
418
419 QColor foreground = cfg.readEntry("colorEditorForeground", qApp->palette().text().color());
420 palette.setBrush(QPalette::Active, QPalette::Text, QBrush(foreground));
421
422 m_page->setUpdatesEnabled(true);
423}
rgba palette[MAX_PALETTE]
Definition palette.c:35

References m_page, m_syntaxHighlighter, m_textEditorWidget, palette, and BasicXMLSyntaxHighlighter::setFormats().

◆ copy

void SvgTextEditor::copy ( )
privateslot

Definition at line 198 of file SvgTextEditor.cpp.

199{
200 m_currentEditor->copy();
201}
QTextEdit * m_currentEditor

References m_currentEditor.

◆ createAction()

QAction * SvgTextEditor::createAction ( const QString & name,
const char * member )
private

Definition at line 425 of file SvgTextEditor.cpp.

426{
427 QAction *action = new QAction(this);
429 actionRegistry->propertizeAction(name, action);
430
432 QObject::connect(action, SIGNAL(triggered(bool)), this, member);
433 return action;
434}
bool propertizeAction(const QString &name, QAction *a)
static KisActionRegistry * instance()
Q_INVOKABLE QAction * addAction(const QString &name, QAction *action)
QAction * action(const char *name) const

References KisKXMLGUIClient::action(), KisKXMLGUIClient::actionCollection(), KisKActionCollection::addAction(), KisActionRegistry::instance(), and KisActionRegistry::propertizeAction().

◆ createActions()

void SvgTextEditor::createActions ( )
private

Definition at line 437 of file SvgTextEditor.cpp.

438{
439 // File: new, open, save, save as, close
442
443 // Edit
446 KStandardAction::cut(this, SLOT(cut()), actionCollection());
455
456 // View
457 // WISH: we cannot zoom-in/out in rech-text mode
460
461 Q_FOREACH(QAction *action, m_svgTextActions) {
462 action->setEnabled(true);
463 }
464
465 // Settings
466 // do not add settings action to m_richTextActions list,
467 // it should always be active, regardless of which editor mode is used.
468 // otherwise we can lock the user out of being able to change
469 // editor mode, if user changes to SVG only mode.
470 createAction("svg_settings", SLOT(setSettings()));
471}
QAction * createAction(const QString &name, const char *member)
QList< QAction * > m_svgTextActions
QAction * replace(const QObject *recvr, const char *slot, QObject *parent)
QAction * deselect(const QObject *recvr, const char *slot, QObject *parent)
QAction * findNext(const QObject *recvr, const char *slot, QObject *parent)
QAction * redo(const QObject *recvr, const char *slot, QObject *parent)
QAction * undo(const QObject *recvr, const char *slot, QObject *parent)
QAction * zoomOut(const QObject *recvr, const char *slot, QObject *parent)
QAction * close(const QObject *recvr, const char *slot, QObject *parent)
QAction * copy(const QObject *recvr, const char *slot, QObject *parent)
QAction * selectAll(const QObject *recvr, const char *slot, QObject *parent)
QAction * save(const QObject *recvr, const char *slot, QObject *parent)
QAction * paste(const QObject *recvr, const char *slot, QObject *parent)
QAction * zoomIn(const QObject *recvr, const char *slot, QObject *parent)
QAction * cut(const QObject *recvr, const char *slot, QObject *parent)
QAction * find(const QObject *recvr, const char *slot, QObject *parent)
QAction * findPrev(const QObject *recvr, const char *slot, QObject *parent)

References KisKXMLGUIClient::action(), KisKXMLGUIClient::actionCollection(), KStandardAction::close(), copy(), KStandardAction::copy(), createAction(), cut(), KStandardAction::cut(), deselect(), KStandardAction::deselect(), find(), KStandardAction::find(), findNext(), KStandardAction::findNext(), findPrev(), KStandardAction::findPrev(), m_svgTextActions, paste(), KStandardAction::paste(), redo(), KStandardAction::redo(), replace(), KStandardAction::replace(), save(), KStandardAction::save(), selectAll(), KStandardAction::selectAll(), setSettings(), slotCloseEditor(), undo(), KStandardAction::undo(), zoomIn(), KStandardAction::zoomIn(), zoomOut(), and KStandardAction::zoomOut().

◆ cut

void SvgTextEditor::cut ( )
privateslot

Definition at line 193 of file SvgTextEditor.cpp.

194{
195 m_currentEditor->cut();
196}

References m_currentEditor.

◆ deselect

void SvgTextEditor::deselect ( )
privateslot

Definition at line 213 of file SvgTextEditor.cpp.

214{
215 QTextCursor cursor(m_currentEditor->textCursor());
216 cursor.clearSelection();
217 m_currentEditor->setTextCursor(cursor);
218}

References m_currentEditor.

◆ dialogButtonClicked

void SvgTextEditor::dialogButtonClicked ( QAbstractButton * button)
privateslot

Definition at line 385 of file SvgTextEditor.cpp.

386{
387 if (m_textEditorWidget.buttons->standardButton(button) == QDialogButtonBox::Discard) {
388 if (QMessageBox::warning(this, i18nc("@title:window", "Krita"), i18n("You have modified the text. Discard changes?"), QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) {
389 close();
390 }
391 }
392}
QString button(const QWheelEvent &ev)

References button(), and m_textEditorWidget.

◆ eventFilter()

bool SvgTextEditor::eventFilter ( QObject * watched,
QEvent * event )
overrideprotected

Definition at line 478 of file SvgTextEditor.cpp.

479{
480 if (event->type() == QEvent::KeyPress || event->type() == QEvent::KeyRelease) {
481 QKeyEvent *const keyEvent = static_cast<QKeyEvent *>(event);
482 if ((keyEvent->key() == Qt::Key_Enter || keyEvent->key() == Qt::Key_Return)
483 && (keyEvent->modifiers() & Qt::ShiftModifier)) {
484 // Disable soft line breaks
485 return true;
486 }
487 }
488 return false;
489 return KXmlGuiWindow::eventFilter(watched, event);
490}
bool event(QEvent *event) override

References KXmlGuiWindow::event().

◆ find

void SvgTextEditor::find ( )
privateslot

Definition at line 220 of file SvgTextEditor.cpp.

221{
222 QDialog findDialog;
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);
228 layout->addWidget(buttons);
229
230 KGuiItem::assign(buttons->button(QDialogButtonBox::Ok), KStandardGuiItem::ok());
231 KGuiItem::assign(buttons->button(QDialogButtonBox::Cancel), KStandardGuiItem::cancel());
232
233 connect(buttons, SIGNAL(accepted()), &findDialog, SLOT(accept()));
234 connect(buttons, SIGNAL(rejected()), &findDialog, SLOT(reject()));
235
236 if (findDialog.exec() == QDialog::Accepted) {
237 m_searchKey = lnSearchKey->text();
239 }
240}
QString m_searchKey
QString buttons(const T &ev)

References buttons(), connect(), m_currentEditor, and m_searchKey.

◆ findNext

void SvgTextEditor::findNext ( )
privateslot

Definition at line 242 of file SvgTextEditor.cpp.

243{
244 if (!m_currentEditor->find(m_searchKey)) {
245 QTextCursor cursor(m_currentEditor->textCursor());
246 cursor.movePosition(QTextCursor::Start);
247 m_currentEditor->setTextCursor(cursor);
249 }
250}

References m_currentEditor, and m_searchKey.

◆ findPrev

void SvgTextEditor::findPrev ( )
privateslot

Definition at line 252 of file SvgTextEditor.cpp.

253{
254 if (!m_currentEditor->find(m_searchKey,QTextDocument::FindBackward)) {
255 QTextCursor cursor(m_currentEditor->textCursor());
256 cursor.movePosition(QTextCursor::End);
257 m_currentEditor->setTextCursor(cursor);
258 m_currentEditor->find(m_searchKey,QTextDocument::FindBackward);
259 }
260}

References m_currentEditor, and m_searchKey.

◆ paste

void SvgTextEditor::paste ( )
privateslot

Definition at line 203 of file SvgTextEditor.cpp.

204{
205 m_currentEditor->paste();
206}

References m_currentEditor.

◆ redo

void SvgTextEditor::redo ( )
privateslot

Definition at line 188 of file SvgTextEditor.cpp.

189{
190 m_currentEditor->redo();
191}

References m_currentEditor.

◆ replace

void SvgTextEditor::replace ( )
privateslot

Definition at line 262 of file SvgTextEditor.cpp.

263{
264 QDialog findDialog;
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);
272 layout->addWidget(buttons);
273
274 KGuiItem::assign(buttons->button(QDialogButtonBox::Ok), KStandardGuiItem::ok());
275 KGuiItem::assign(buttons->button(QDialogButtonBox::Cancel), KStandardGuiItem::cancel());
276
277 connect(buttons, SIGNAL(accepted()), &findDialog, SLOT(accept()));
278 connect(buttons, SIGNAL(rejected()), &findDialog, SLOT(reject()));
279
280 if (findDialog.exec() == QDialog::Accepted) {
281 QString search = lnSearchKey->text();
282 QString replace = lnReplaceKey->text();
283 QTextCursor cursor(m_currentEditor->textCursor());
284 cursor.movePosition(QTextCursor::Start);
285 m_currentEditor->setTextCursor(cursor);
286 while(m_currentEditor->find(search)) {
287 m_currentEditor->textCursor().removeSelectedText();
288 m_currentEditor->textCursor().insertText(replace);
289 }
290
291 }
292}

References buttons(), connect(), m_currentEditor, and replace().

◆ save

void SvgTextEditor::save ( )
privateslot

Definition at line 175 of file SvgTextEditor.cpp.

176{
177 if (m_shape) {
178 Q_EMIT textUpdated(m_shape, m_textEditorWidget.svgTextEdit->document()->toPlainText(), m_textEditorWidget.svgStylesEdit->document()->toPlainText());
179 m_textEditorWidget.svgTextEdit->document()->setModified(false);
180 }
181}
KoSvgTextShape * m_shape
void textUpdated(KoSvgTextShape *shape, const QString &svg, const QString &defs)

References m_shape, m_textEditorWidget, and textUpdated().

◆ selectAll

void SvgTextEditor::selectAll ( )
privateslot

Definition at line 208 of file SvgTextEditor.cpp.

209{
210 m_currentEditor->selectAll();
211}

References m_currentEditor.

◆ setInitialShape()

void SvgTextEditor::setInitialShape ( KoSvgTextShape * shape)

Definition at line 155 of file SvgTextEditor.cpp.

156{
157 m_shape = shape;
158 if (m_shape) {
160
161 QString svg;
162 QString styles;
163
164 if (converter.convertToSvg(&svg, &styles)) {
165 m_textEditorWidget.svgTextEdit->setPlainText(svg);
166 m_textEditorWidget.svgStylesEdit->setPlainText(styles);
167 m_textEditorWidget.svgTextEdit->document()->setModified(false);
168 }
169 else {
170 QMessageBox::warning(this, i18n("Conversion failed"), "Could not get svg text from the shape:\n" + converter.errors().join('\n') + "\n" + converter.warnings().join('\n'));
171 }
172 }
173}

References KoSvgTextShapeMarkupConverter::convertToSvg(), KoSvgTextShapeMarkupConverter::errors(), m_shape, m_textEditorWidget, and KoSvgTextShapeMarkupConverter::warnings().

◆ setModified

void SvgTextEditor::setModified ( bool modified)
privateslot

Definition at line 371 of file SvgTextEditor.cpp.

372{
373 if (modified) {
374 m_textEditorWidget.buttons->setStandardButtons(QDialogButtonBox::Save | QDialogButtonBox::Discard);
375 KGuiItem::assign(m_textEditorWidget.buttons->button(QDialogButtonBox::Save), KStandardGuiItem::save());
376 KGuiItem::assign(m_textEditorWidget.buttons->button(QDialogButtonBox::Discard), KStandardGuiItem::discard());
377 }
378 else {
379 m_textEditorWidget.buttons->setStandardButtons(QDialogButtonBox::Save | QDialogButtonBox::Close);
380 KGuiItem::assign(m_textEditorWidget.buttons->button(QDialogButtonBox::Save), KStandardGuiItem::save());
381 KGuiItem::assign(m_textEditorWidget.buttons->button(QDialogButtonBox::Close), KStandardGuiItem::close());
382 }
383}

References m_textEditorWidget.

◆ setSettings

void SvgTextEditor::setSettings ( )
privateslot

Definition at line 305 of file SvgTextEditor.cpp.

306{
307 KoDialog settingsDialog(this);
308 Ui_WdgSvgTextSettings textSettings;
309 QWidget *settingsPage = new QWidget(&settingsDialog);
310 settingsDialog.setMainWidget(settingsPage);
311 textSettings.setupUi(settingsPage);
312
313 // get the settings and initialize the dialog
314 KConfigGroup cfg(KSharedConfig::openConfig(), "SvgTextTool");
315
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()));
319
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));
323
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));
327
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));
331
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));
335
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));
339
340 settingsDialog.setButtons(KoDialog::Ok | KoDialog::Cancel);
341 if (settingsDialog.exec() == QDialog::Accepted) {
342
343 cfg.writeEntry("colorEditorBackground", textSettings.colorEditorBackground->color());
344 cfg.writeEntry("colorEditorForeground", textSettings.colorEditorForeground->color());
345
346 cfg.writeEntry("colorKeyword", textSettings.colorKeyword->color());
347 cfg.writeEntry("BoldKeyword", textSettings.chkBoldKeyword->isChecked());
348 cfg.writeEntry("ItalicKeyWord", textSettings.chkItalicKeyword->isChecked());
349
350 cfg.writeEntry("colorElement", textSettings.colorElement->color());
351 cfg.writeEntry("BoldElement", textSettings.chkBoldElement->isChecked());
352 cfg.writeEntry("ItalicElement", textSettings.chkItalicElement->isChecked());
353
354 cfg.writeEntry("colorAttribute", textSettings.colorAttribute->color());
355 cfg.writeEntry("BoldAttribute", textSettings.chkBoldAttribute->isChecked());
356 cfg.writeEntry("ItalicAttribute", textSettings.chkItalicAttribute->isChecked());
357
358 cfg.writeEntry("colorValue", textSettings.colorValue->color());
359 cfg.writeEntry("BoldValue", textSettings.chkBoldValue->isChecked());
360 cfg.writeEntry("ItalicValue", textSettings.chkItalicValue->isChecked());
361
362 cfg.writeEntry("colorComment", textSettings.colorComment->color());
363 cfg.writeEntry("BoldComment", textSettings.chkBoldComment->isChecked());
364 cfg.writeEntry("ItalicComment", textSettings.chkItalicComment->isChecked());
365
367 }
368}
A dialog base class with standard buttons and predefined layouts.
Definition KoDialog.h:116
@ Ok
Show Ok button. (this button accept()s the dialog; result set to QDialog::Accepted)
Definition KoDialog.h:127
@ Cancel
Show Cancel-button. (this button reject()s the dialog; result set to QDialog::Rejected)
Definition KoDialog.h:130

References applySettings(), KoDialog::Cancel, KoDialog::Ok, KoDialog::setButtons(), and KoDialog::setMainWidget().

◆ slotCloseEditor

void SvgTextEditor::slotCloseEditor ( )
privateslot

Definition at line 472 of file SvgTextEditor.cpp.

473{
474 close();
475 Q_EMIT textEditorClosed();
476}
void textEditorClosed()

References textEditorClosed().

◆ textEditorClosed

void SvgTextEditor::textEditorClosed ( )
signal

◆ textUpdated

void SvgTextEditor::textUpdated ( KoSvgTextShape * shape,
const QString & svg,
const QString & defs )
signal

◆ undo

void SvgTextEditor::undo ( )
privateslot

Definition at line 183 of file SvgTextEditor.cpp.

184{
185 m_currentEditor->undo();
186}

References m_currentEditor.

◆ wheelEvent()

void SvgTextEditor::wheelEvent ( QWheelEvent * event)
overrideprotected

Definition at line 394 of file SvgTextEditor.cpp.

395{
396 if (event->modifiers() & Qt::ControlModifier) {
397 int numDegrees = event->angleDelta().y() / 8;
398 int numSteps = numDegrees / 7;
399 m_textEditorWidget.svgTextEdit->zoomOut(numSteps);
400 event->accept();
401 }
402}

References KXmlGuiWindow::event(), and m_textEditorWidget.

◆ zoomIn

void SvgTextEditor::zoomIn ( )
privateslot

Definition at line 300 of file SvgTextEditor.cpp.

301{
302 m_currentEditor->zoomIn();
303}

References m_currentEditor.

◆ zoomOut

void SvgTextEditor::zoomOut ( )
privateslot

Definition at line 295 of file SvgTextEditor.cpp.

296{
297 m_currentEditor->zoomOut();
298}

References m_currentEditor.

Member Data Documentation

◆ d

QScopedPointer<Private> SvgTextEditor::d
private

Definition at line 90 of file SvgTextEditor.h.

◆ m_currentEditor

QTextEdit* SvgTextEditor::m_currentEditor {0}
private

Definition at line 80 of file SvgTextEditor.h.

80{0};

◆ m_page

QWidget* SvgTextEditor::m_page {0}
private

Definition at line 81 of file SvgTextEditor.h.

81{0};

◆ m_searchKey

QString SvgTextEditor::m_searchKey
private

Definition at line 87 of file SvgTextEditor.h.

◆ m_shape

KoSvgTextShape* SvgTextEditor::m_shape {0}
private

Definition at line 84 of file SvgTextEditor.h.

84{0};

◆ m_svgTextActions

QList<QAction*> SvgTextEditor::m_svgTextActions
private

Definition at line 82 of file SvgTextEditor.h.

◆ m_syntaxHighlighter

BasicXMLSyntaxHighlighter* SvgTextEditor::m_syntaxHighlighter
private

Definition at line 85 of file SvgTextEditor.h.

◆ m_textEditorWidget

Ui_WdgSvgTextEditor SvgTextEditor::m_textEditorWidget
private

Definition at line 79 of file SvgTextEditor.h.


The documentation for this class was generated from the following files: