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 setTabPosition(Qt::AllDockWidgetAreas, QTabWidget::North);
127
129 m_textEditorWidget.svgTextEdit->setFont(QFontDatabase().systemFont(QFontDatabase::FixedFont));
130
132 // If we have customized the toolbars, load that first
133 setLocalXMLFile(KoResourcePaths::locateLocal("data", "svgtexttool.xmlgui"));
134 setXMLFile(":/kxmlgui5/svgtexttool.xmlgui");
135
136 guiFactory()->addClient(this);
137
139
140}
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(), 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 142 of file SvgTextEditor.cpp.

143{
144 KConfigGroup g(KSharedConfig::openConfig(), "SvgTextTool");
145 QByteArray ba = saveState();
146 g.writeEntry("windowState", ba.toBase64());
147 ba = saveGeometry();
148 g.writeEntry("Geometry", ba.toBase64());
149}
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 401 of file SvgTextEditor.cpp.

402{
403 KConfigGroup cfg(KSharedConfig::openConfig(), "SvgTextTool");
404
405 m_page->setUpdatesEnabled(false);
406
408
409 QPalette palette = m_textEditorWidget.svgTextEdit->palette();
410
411 QColor background = cfg.readEntry("colorEditorBackground", qApp->palette().window().color());
412 palette.setBrush(QPalette::Active, QPalette::Window, QBrush(background));
413 m_textEditorWidget.svgStylesEdit->setStyleSheet(QString("background-color:%1").arg(background.name()));
414 m_textEditorWidget.svgTextEdit->setStyleSheet(QString("background-color:%1").arg(background.name()));
415
416 QColor foreground = cfg.readEntry("colorEditorForeground", qApp->palette().text().color());
417 palette.setBrush(QPalette::Active, QPalette::Text, QBrush(foreground));
418
419 m_page->setUpdatesEnabled(true);
420}
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 195 of file SvgTextEditor.cpp.

196{
197 m_currentEditor->copy();
198}
QTextEdit * m_currentEditor

References m_currentEditor.

◆ createAction()

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

Definition at line 422 of file SvgTextEditor.cpp.

423{
424 QAction *action = new QAction(this);
426 actionRegistry->propertizeAction(name, action);
427
429 QObject::connect(action, SIGNAL(triggered(bool)), this, member);
430 return action;
431}
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 434 of file SvgTextEditor.cpp.

435{
436 // File: new, open, save, save as, close
439
440 // Edit
443 KStandardAction::cut(this, SLOT(cut()), actionCollection());
452
453 // View
454 // WISH: we cannot zoom-in/out in rech-text mode
457
458 Q_FOREACH(QAction *action, m_svgTextActions) {
459 action->setEnabled(true);
460 }
461
462 // Settings
463 // do not add settings action to m_richTextActions list,
464 // it should always be active, regardless of which editor mode is used.
465 // otherwise we can lock the user out of being able to change
466 // editor mode, if user changes to SVG only mode.
467 createAction("svg_settings", SLOT(setSettings()));
468}
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 190 of file SvgTextEditor.cpp.

191{
192 m_currentEditor->cut();
193}

References m_currentEditor.

◆ deselect

void SvgTextEditor::deselect ( )
privateslot

Definition at line 210 of file SvgTextEditor.cpp.

211{
212 QTextCursor cursor(m_currentEditor->textCursor());
213 cursor.clearSelection();
214 m_currentEditor->setTextCursor(cursor);
215}

References m_currentEditor.

◆ dialogButtonClicked

void SvgTextEditor::dialogButtonClicked ( QAbstractButton * button)
privateslot

Definition at line 382 of file SvgTextEditor.cpp.

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

References button(), and m_textEditorWidget.

◆ eventFilter()

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

Definition at line 475 of file SvgTextEditor.cpp.

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

References KXmlGuiWindow::event().

◆ find

void SvgTextEditor::find ( )
privateslot

Definition at line 217 of file SvgTextEditor.cpp.

218{
219 QDialog findDialog;
220 findDialog.setWindowTitle(i18n("Find Text"));
221 QFormLayout *layout = new QFormLayout(&findDialog);
222 QLineEdit *lnSearchKey = new QLineEdit();
223 layout->addRow(i18n("Find:"), lnSearchKey);
224 QDialogButtonBox *buttons = new QDialogButtonBox(QDialogButtonBox::Ok|QDialogButtonBox::Cancel);
225 layout->addWidget(buttons);
226
227 KGuiItem::assign(buttons->button(QDialogButtonBox::Ok), KStandardGuiItem::ok());
228 KGuiItem::assign(buttons->button(QDialogButtonBox::Cancel), KStandardGuiItem::cancel());
229
230 connect(buttons, SIGNAL(accepted()), &findDialog, SLOT(accept()));
231 connect(buttons, SIGNAL(rejected()), &findDialog, SLOT(reject()));
232
233 if (findDialog.exec() == QDialog::Accepted) {
234 m_searchKey = lnSearchKey->text();
236 }
237}
QString m_searchKey
QString buttons(const T &ev)

References buttons(), m_currentEditor, and m_searchKey.

◆ findNext

void SvgTextEditor::findNext ( )
privateslot

Definition at line 239 of file SvgTextEditor.cpp.

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

References m_currentEditor, and m_searchKey.

◆ findPrev

void SvgTextEditor::findPrev ( )
privateslot

Definition at line 249 of file SvgTextEditor.cpp.

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

References m_currentEditor, and m_searchKey.

◆ paste

void SvgTextEditor::paste ( )
privateslot

Definition at line 200 of file SvgTextEditor.cpp.

201{
202 m_currentEditor->paste();
203}

References m_currentEditor.

◆ redo

void SvgTextEditor::redo ( )
privateslot

Definition at line 185 of file SvgTextEditor.cpp.

186{
187 m_currentEditor->redo();
188}

References m_currentEditor.

◆ replace

void SvgTextEditor::replace ( )
privateslot

Definition at line 259 of file SvgTextEditor.cpp.

260{
261 QDialog findDialog;
262 findDialog.setWindowTitle(i18n("Find and Replace all"));
263 QFormLayout *layout = new QFormLayout(&findDialog);
264 QLineEdit *lnSearchKey = new QLineEdit();
265 QLineEdit *lnReplaceKey = new QLineEdit();
266 layout->addRow(i18n("Find:"), lnSearchKey);
267 QDialogButtonBox *buttons = new QDialogButtonBox(QDialogButtonBox::Ok|QDialogButtonBox::Cancel);
268 layout->addRow(i18n("Replace:"), lnReplaceKey);
269 layout->addWidget(buttons);
270
271 KGuiItem::assign(buttons->button(QDialogButtonBox::Ok), KStandardGuiItem::ok());
272 KGuiItem::assign(buttons->button(QDialogButtonBox::Cancel), KStandardGuiItem::cancel());
273
274 connect(buttons, SIGNAL(accepted()), &findDialog, SLOT(accept()));
275 connect(buttons, SIGNAL(rejected()), &findDialog, SLOT(reject()));
276
277 if (findDialog.exec() == QDialog::Accepted) {
278 QString search = lnSearchKey->text();
279 QString replace = lnReplaceKey->text();
280 QTextCursor cursor(m_currentEditor->textCursor());
281 cursor.movePosition(QTextCursor::Start);
282 m_currentEditor->setTextCursor(cursor);
283 while(m_currentEditor->find(search)) {
284 m_currentEditor->textCursor().removeSelectedText();
285 m_currentEditor->textCursor().insertText(replace);
286 }
287
288 }
289}

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

◆ save

void SvgTextEditor::save ( )
privateslot

Definition at line 172 of file SvgTextEditor.cpp.

173{
174 if (m_shape) {
175 Q_EMIT textUpdated(m_shape, m_textEditorWidget.svgTextEdit->document()->toPlainText(), m_textEditorWidget.svgStylesEdit->document()->toPlainText());
176 m_textEditorWidget.svgTextEdit->document()->setModified(false);
177 }
178}
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 205 of file SvgTextEditor.cpp.

206{
207 m_currentEditor->selectAll();
208}

References m_currentEditor.

◆ setInitialShape()

void SvgTextEditor::setInitialShape ( KoSvgTextShape * shape)

Definition at line 152 of file SvgTextEditor.cpp.

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

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

◆ setModified

void SvgTextEditor::setModified ( bool modified)
privateslot

Definition at line 368 of file SvgTextEditor.cpp.

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

References m_textEditorWidget.

◆ setSettings

void SvgTextEditor::setSettings ( )
privateslot

Definition at line 302 of file SvgTextEditor.cpp.

303{
304 KoDialog settingsDialog(this);
305 Ui_WdgSvgTextSettings textSettings;
306 QWidget *settingsPage = new QWidget(&settingsDialog);
307 settingsDialog.setMainWidget(settingsPage);
308 textSettings.setupUi(settingsPage);
309
310 // get the settings and initialize the dialog
311 KConfigGroup cfg(KSharedConfig::openConfig(), "SvgTextTool");
312
313 QColor background = cfg.readEntry("colorEditorBackground", qApp->palette().window().color());
314 textSettings.colorEditorBackground->setColor(background);
315 textSettings.colorEditorForeground->setColor(cfg.readEntry("colorEditorForeground", qApp->palette().text().color()));
316
317 textSettings.colorKeyword->setColor(cfg.readEntry("colorKeyword", QColor(background.value() < 100 ? Qt::cyan : Qt::blue)));
318 textSettings.chkBoldKeyword->setChecked(cfg.readEntry("BoldKeyword", true));
319 textSettings.chkItalicKeyword->setChecked(cfg.readEntry("ItalicKeyword", false));
320
321 textSettings.colorElement->setColor(cfg.readEntry("colorElement", QColor(background.value() < 100 ? Qt::magenta : Qt::darkMagenta)));
322 textSettings.chkBoldElement->setChecked(cfg.readEntry("BoldElement", true));
323 textSettings.chkItalicElement->setChecked(cfg.readEntry("ItalicElement", false));
324
325 textSettings.colorAttribute->setColor(cfg.readEntry("colorAttribute", QColor(background.value() < 100 ? Qt::green : Qt::darkGreen)));
326 textSettings.chkBoldAttribute->setChecked(cfg.readEntry("BoldAttribute", true));
327 textSettings.chkItalicAttribute->setChecked(cfg.readEntry("ItalicAttribute", true));
328
329 textSettings.colorValue->setColor(cfg.readEntry("colorValue", QColor(background.value() < 100 ? Qt::red: Qt::darkRed)));
330 textSettings.chkBoldValue->setChecked(cfg.readEntry("BoldValue", true));
331 textSettings.chkItalicValue->setChecked(cfg.readEntry("ItalicValue", false));
332
333 textSettings.colorComment->setColor(cfg.readEntry("colorComment", QColor(background.value() < 100 ? Qt::lightGray : Qt::gray)));
334 textSettings.chkBoldComment->setChecked(cfg.readEntry("BoldComment", false));
335 textSettings.chkItalicComment->setChecked(cfg.readEntry("ItalicComment", false));
336
337 settingsDialog.setButtons(KoDialog::Ok | KoDialog::Cancel);
338 if (settingsDialog.exec() == QDialog::Accepted) {
339
340 cfg.writeEntry("colorEditorBackground", textSettings.colorEditorBackground->color());
341 cfg.writeEntry("colorEditorForeground", textSettings.colorEditorForeground->color());
342
343 cfg.writeEntry("colorKeyword", textSettings.colorKeyword->color());
344 cfg.writeEntry("BoldKeyword", textSettings.chkBoldKeyword->isChecked());
345 cfg.writeEntry("ItalicKeyWord", textSettings.chkItalicKeyword->isChecked());
346
347 cfg.writeEntry("colorElement", textSettings.colorElement->color());
348 cfg.writeEntry("BoldElement", textSettings.chkBoldElement->isChecked());
349 cfg.writeEntry("ItalicElement", textSettings.chkItalicElement->isChecked());
350
351 cfg.writeEntry("colorAttribute", textSettings.colorAttribute->color());
352 cfg.writeEntry("BoldAttribute", textSettings.chkBoldAttribute->isChecked());
353 cfg.writeEntry("ItalicAttribute", textSettings.chkItalicAttribute->isChecked());
354
355 cfg.writeEntry("colorValue", textSettings.colorValue->color());
356 cfg.writeEntry("BoldValue", textSettings.chkBoldValue->isChecked());
357 cfg.writeEntry("ItalicValue", textSettings.chkItalicValue->isChecked());
358
359 cfg.writeEntry("colorComment", textSettings.colorComment->color());
360 cfg.writeEntry("BoldComment", textSettings.chkBoldComment->isChecked());
361 cfg.writeEntry("ItalicComment", textSettings.chkItalicComment->isChecked());
362
364 }
365}
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 469 of file SvgTextEditor.cpp.

470{
471 close();
472 Q_EMIT textEditorClosed();
473}
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 180 of file SvgTextEditor.cpp.

181{
182 m_currentEditor->undo();
183}

References m_currentEditor.

◆ wheelEvent()

void SvgTextEditor::wheelEvent ( QWheelEvent * event)
overrideprotected

Definition at line 391 of file SvgTextEditor.cpp.

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

References KXmlGuiWindow::event(), and m_textEditorWidget.

◆ zoomIn

void SvgTextEditor::zoomIn ( )
privateslot

Definition at line 297 of file SvgTextEditor.cpp.

298{
299 m_currentEditor->zoomIn();
300}

References m_currentEditor.

◆ zoomOut

void SvgTextEditor::zoomOut ( )
privateslot

Definition at line 292 of file SvgTextEditor.cpp.

293{
294 m_currentEditor->zoomOut();
295}

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: