summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
Diffstat (limited to 'utils')
-rw-r--r--utils/themeeditor/findreplace/findreplacedialog.cpp64
-rw-r--r--utils/themeeditor/findreplace/findreplacedialog.h80
-rw-r--r--utils/themeeditor/findreplace/findreplacedialog.ui32
-rw-r--r--utils/themeeditor/findreplace/findreplaceform.cpp222
-rw-r--r--utils/themeeditor/findreplace/findreplaceform.h153
-rw-r--r--utils/themeeditor/findreplace/findreplaceform.ui204
-rw-r--r--utils/themeeditor/gui/findreplacedialog.cpp101
-rw-r--r--utils/themeeditor/gui/findreplacedialog.h58
-rw-r--r--utils/themeeditor/gui/findreplacedialog.ui147
-rw-r--r--utils/themeeditor/gui/skindocument.cpp2
-rw-r--r--utils/themeeditor/themeeditor.pro14
11 files changed, 313 insertions, 764 deletions
diff --git a/utils/themeeditor/findreplace/findreplacedialog.cpp b/utils/themeeditor/findreplace/findreplacedialog.cpp
deleted file mode 100644
index 547ad236e5..0000000000
--- a/utils/themeeditor/findreplace/findreplacedialog.cpp
+++ /dev/null
@@ -1,64 +0,0 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * This file has been copied from Lorenzo Bettini, with minor modifications
11 * made available under the LGPL version 3, as the original file was licensed
12 *
13 ****************************************************************************
14 *
15 * Copyright (C) 2009 Lorenzo Bettini <http://www.lorenzobettini.it>
16 * See COPYING file that comes with this distribution
17 */
18
19#include "findreplacedialog.h"
20#include "ui_findreplacedialog.h"
21
22FindReplaceDialog::FindReplaceDialog(QWidget *parent) :
23 QDialog(parent),
24 ui(new Ui::FindReplaceDialog)
25{
26 ui->setupUi(this);
27}
28
29FindReplaceDialog::~FindReplaceDialog()
30{
31 delete ui;
32}
33
34void FindReplaceDialog::changeEvent(QEvent *e)
35{
36 QDialog::changeEvent(e);
37 switch (e->type()) {
38 case QEvent::LanguageChange:
39 ui->retranslateUi(this);
40 break;
41 default:
42 break;
43 }
44}
45
46void FindReplaceDialog::setTextEdit(QPlainTextEdit *textEdit) {
47 ui->findReplaceForm->setTextEdit(textEdit);
48}
49
50void FindReplaceDialog::writeSettings(QSettings &settings, const QString &prefix) {
51 ui->findReplaceForm->writeSettings(settings, prefix);
52}
53
54void FindReplaceDialog::readSettings(QSettings &settings, const QString &prefix) {
55 ui->findReplaceForm->readSettings(settings, prefix);
56}
57
58void FindReplaceDialog::findNext() {
59 ui->findReplaceForm->findNext();
60}
61
62void FindReplaceDialog::findPrev() {
63 ui->findReplaceForm->findPrev();
64}
diff --git a/utils/themeeditor/findreplace/findreplacedialog.h b/utils/themeeditor/findreplace/findreplacedialog.h
deleted file mode 100644
index c3f2539113..0000000000
--- a/utils/themeeditor/findreplace/findreplacedialog.h
+++ /dev/null
@@ -1,80 +0,0 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * This file has been copied from Lorenzo Bettini, with minor modifications
11 * made available under the LGPL version 3, as the original file was licensed
12 *
13 ****************************************************************************
14 *
15 * Copyright (C) 2009 Lorenzo Bettini <http://www.lorenzobettini.it>
16 * See COPYING file that comes with this distribution
17 */
18
19#ifndef FINDREPLACEDIALOG_H
20#define FINDREPLACEDIALOG_H
21
22#include <QDialog>
23#include <QPlainTextEdit>
24
25namespace Ui {
26 class FindReplaceDialog;
27}
28
29class QTextEdit;
30class QSettings;
31
32/**
33 * A find/replace dialog.
34 *
35 * It relies on a FindReplaceForm object (see that class for the functionalities provided).
36 */
37class FindReplaceDialog : public QDialog {
38 Q_OBJECT
39public:
40 FindReplaceDialog(QWidget *parent = 0);
41 virtual ~FindReplaceDialog();
42
43 /**
44 * Associates the text editor where to perform the search
45 * @param textEdit
46 */
47 void setTextEdit(QPlainTextEdit *textEdit);
48
49 /**
50 * Writes the state of the form to the passed settings.
51 * @param settings
52 * @param prefix the prefix to insert in the settings
53 */
54 virtual void writeSettings(QSettings &settings, const QString &prefix = "FindReplaceDialog");
55
56 /**
57 * Reads the state of the form from the passed settings.
58 * @param settings
59 * @param prefix the prefix to look for in the settings
60 */
61 virtual void readSettings(QSettings &settings, const QString &prefix = "FindReplaceDialog");
62
63public slots:
64 /**
65 * Finds the next occurrence
66 */
67 void findNext();
68
69 /**
70 * Finds the previous occurrence
71 */
72 void findPrev();
73
74protected:
75 void changeEvent(QEvent *e);
76
77 Ui::FindReplaceDialog *ui;
78};
79
80#endif // FINDREPLACEDIALOG_H
diff --git a/utils/themeeditor/findreplace/findreplacedialog.ui b/utils/themeeditor/findreplace/findreplacedialog.ui
deleted file mode 100644
index 74984b3070..0000000000
--- a/utils/themeeditor/findreplace/findreplacedialog.ui
+++ /dev/null
@@ -1,32 +0,0 @@
1<?xml version="1.0" encoding="UTF-8"?>
2<ui version="4.0">
3 <class>FindReplaceDialog</class>
4 <widget class="QDialog" name="FindReplaceDialog">
5 <property name="geometry">
6 <rect>
7 <x>0</x>
8 <y>0</y>
9 <width>342</width>
10 <height>140</height>
11 </rect>
12 </property>
13 <property name="windowTitle">
14 <string>Find/Replace</string>
15 </property>
16 <layout class="QGridLayout" name="gridLayout">
17 <item row="0" column="0">
18 <widget class="FindReplaceForm" name="findReplaceForm" native="true"/>
19 </item>
20 </layout>
21 </widget>
22 <customwidgets>
23 <customwidget>
24 <class>FindReplaceForm</class>
25 <extends>QWidget</extends>
26 <header location="global">findreplaceform.h</header>
27 <container>1</container>
28 </customwidget>
29 </customwidgets>
30 <resources/>
31 <connections/>
32</ui>
diff --git a/utils/themeeditor/findreplace/findreplaceform.cpp b/utils/themeeditor/findreplace/findreplaceform.cpp
deleted file mode 100644
index cd2700f033..0000000000
--- a/utils/themeeditor/findreplace/findreplaceform.cpp
+++ /dev/null
@@ -1,222 +0,0 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * This file has been copied from Lorenzo Bettini, with minor modifications
11 * made available under the LGPL version 3, as the original file was licensed
12 *
13 ****************************************************************************
14 *
15 * Copyright (C) 2009 Lorenzo Bettini <http://www.lorenzobettini.it>
16 * See COPYING file that comes with this distribution
17 */
18
19#include <QtGui>
20#include <QTextEdit>
21#include <QRegExp>
22#include <QSettings>
23
24#include "findreplaceform.h"
25#include "ui_findreplaceform.h"
26
27#define TEXT_TO_FIND "textToFind"
28#define TEXT_TO_REPLACE "textToReplace"
29#define DOWN_RADIO "downRadio"
30#define UP_RADIO "upRadio"
31#define CASE_CHECK "caseCheck"
32#define WHOLE_CHECK "wholeCheck"
33#define REGEXP_CHECK "regexpCheck"
34
35FindReplaceForm::FindReplaceForm(QWidget *parent) :
36 QWidget(parent),
37 ui(new Ui::FindReplaceForm), textEdit(0)
38{
39 ui->setupUi(this);
40
41 ui->errorLabel->setText("");
42
43 connect(ui->textToFind, SIGNAL(textChanged(QString)), this, SLOT(textToFindChanged()));
44 connect(ui->textToFind, SIGNAL(textChanged(QString)), this, SLOT(validateRegExp(QString)));
45
46 connect(ui->regexCheckBox, SIGNAL(toggled(bool)), this, SLOT(regexpSelected(bool)));
47
48 connect(ui->findButton, SIGNAL(clicked()), this, SLOT(find()));
49 connect(ui->closeButton, SIGNAL(clicked()), parent, SLOT(close()));
50
51 connect(ui->replaceButton, SIGNAL(clicked()), this, SLOT(replace()));
52 connect(ui->replaceAllButton, SIGNAL(clicked()), this, SLOT(replaceAll()));
53}
54
55FindReplaceForm::~FindReplaceForm()
56{
57 delete ui;
58}
59
60void FindReplaceForm::hideReplaceWidgets() {
61 ui->replaceLabel->setVisible(false);
62 ui->textToReplace->setVisible(false);
63 ui->replaceButton->setVisible(false);
64 ui->replaceAllButton->setVisible(false);
65}
66
67void FindReplaceForm::setTextEdit(QPlainTextEdit *textEdit_) {
68 textEdit = textEdit_;
69 connect(textEdit, SIGNAL(copyAvailable(bool)), ui->replaceButton, SLOT(setEnabled(bool)));
70 connect(textEdit, SIGNAL(copyAvailable(bool)), ui->replaceAllButton, SLOT(setEnabled(bool)));
71}
72
73void FindReplaceForm::changeEvent(QEvent *e)
74{
75 QWidget::changeEvent(e);
76 switch (e->type()) {
77 case QEvent::LanguageChange:
78 ui->retranslateUi(this);
79 break;
80 default:
81 break;
82 }
83}
84
85void FindReplaceForm::textToFindChanged() {
86 ui->findButton->setEnabled(ui->textToFind->text().size() > 0);
87}
88
89void FindReplaceForm::regexpSelected(bool sel) {
90 if (sel)
91 validateRegExp(ui->textToFind->text());
92 else
93 validateRegExp("");
94}
95
96void FindReplaceForm::validateRegExp(const QString &text) {
97 if (!ui->regexCheckBox->isChecked() || text.size() == 0) {
98 ui->errorLabel->setText("");
99 return; // nothing to validate
100 }
101
102 QRegExp reg(text,
103 (ui->caseCheckBox->isChecked() ? Qt::CaseSensitive : Qt::CaseInsensitive));
104
105 if (reg.isValid()) {
106 showError("");
107 } else {
108 showError(reg.errorString());
109 }
110}
111
112void FindReplaceForm::showError(const QString &error) {
113 if (error == "") {
114 ui->errorLabel->setText("");
115 } else {
116 ui->errorLabel->setText("<span style=\" font-weight:600; color:#ff0000;\">" +
117 error +
118 "</span>");
119 }
120}
121
122void FindReplaceForm::showMessage(const QString &message) {
123 if (message == "") {
124 ui->errorLabel->setText("");
125 } else {
126 ui->errorLabel->setText("<span style=\" font-weight:600; color:green;\">" +
127 message +
128 "</span>");
129 }
130}
131
132void FindReplaceForm::find() {
133 find(ui->downRadioButton->isChecked());
134}
135
136void FindReplaceForm::find(bool next) {
137 if (!textEdit)
138 return; // TODO: show some warning?
139
140 // backward search
141 bool back = !next;
142
143 const QString &toSearch = ui->textToFind->text();
144
145 bool result = false;
146
147 QTextDocument::FindFlags flags;
148
149 if (back)
150 flags |= QTextDocument::FindBackward;
151 if (ui->caseCheckBox->isChecked())
152 flags |= QTextDocument::FindCaseSensitively;
153 if (ui->wholeCheckBox->isChecked())
154 flags |= QTextDocument::FindWholeWords;
155
156 if (ui->regexCheckBox->isChecked()) {
157 QRegExp reg(toSearch,
158 (ui->caseCheckBox->isChecked() ? Qt::CaseSensitive : Qt::CaseInsensitive));
159
160 qDebug() << "searching for regexp: " << reg.pattern();
161
162 textCursor = textEdit->document()->find(reg, textCursor, flags);
163 textEdit->setTextCursor(textCursor);
164 result = (!textCursor.isNull());
165 } else {
166 qDebug() << "searching for: " << toSearch;
167
168 result = textEdit->find(toSearch, flags);
169 }
170
171 if (result) {
172 showError("");
173 } else {
174 showError(tr("no match found"));
175 // move to the beginning of the document for the next find
176 textCursor.setPosition(0);
177 textEdit->setTextCursor(textCursor);
178 }
179}
180
181void FindReplaceForm::replace() {
182 if (!textEdit->textCursor().hasSelection()) {
183 find();
184 } else {
185 textEdit->textCursor().insertText(ui->textToReplace->text());
186 find();
187 }
188}
189
190void FindReplaceForm::replaceAll() {
191 int i=0;
192 while (textEdit->textCursor().hasSelection()){
193 textEdit->textCursor().insertText(ui->textToReplace->text());
194 find();
195 i++;
196 }
197 showMessage(tr("Replaced %1 occurrence(s)").arg(i));
198}
199
200void FindReplaceForm::writeSettings(QSettings &settings, const QString &prefix) {
201 settings.beginGroup(prefix);
202 settings.setValue(TEXT_TO_FIND, ui->textToFind->text());
203 settings.setValue(TEXT_TO_REPLACE, ui->textToReplace->text());
204 settings.setValue(DOWN_RADIO, ui->downRadioButton->isChecked());
205 settings.setValue(UP_RADIO, ui->upRadioButton->isChecked());
206 settings.setValue(CASE_CHECK, ui->caseCheckBox->isChecked());
207 settings.setValue(WHOLE_CHECK, ui->wholeCheckBox->isChecked());
208 settings.setValue(REGEXP_CHECK, ui->regexCheckBox->isChecked());
209 settings.endGroup();
210}
211
212void FindReplaceForm::readSettings(QSettings &settings, const QString &prefix) {
213 settings.beginGroup(prefix);
214 ui->textToFind->setText(settings.value(TEXT_TO_FIND, "").toString());
215 ui->textToReplace->setText(settings.value(TEXT_TO_REPLACE, "").toString());
216 ui->downRadioButton->setChecked(settings.value(DOWN_RADIO, true).toBool());
217 ui->upRadioButton->setChecked(settings.value(UP_RADIO, false).toBool());
218 ui->caseCheckBox->setChecked(settings.value(CASE_CHECK, false).toBool());
219 ui->wholeCheckBox->setChecked(settings.value(WHOLE_CHECK, false).toBool());
220 ui->regexCheckBox->setChecked(settings.value(REGEXP_CHECK, false).toBool());
221 settings.endGroup();
222}
diff --git a/utils/themeeditor/findreplace/findreplaceform.h b/utils/themeeditor/findreplace/findreplaceform.h
deleted file mode 100644
index f18052b793..0000000000
--- a/utils/themeeditor/findreplace/findreplaceform.h
+++ /dev/null
@@ -1,153 +0,0 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * This file has been copied from Lorenzo Bettini, with minor modifications
11 * made available under the LGPL version 3, as the original file was licensed
12 *
13 ****************************************************************************
14 *
15 * Copyright (C) 2009 Lorenzo Bettini <http://www.lorenzobettini.it>
16 * See COPYING file that comes with this distribution
17 */
18
19#ifndef FINDREPLACEFORM_H
20#define FINDREPLACEFORM_H
21
22#include <QWidget>
23#include <QTextCursor>
24#include <QPlainTextEdit>
25
26namespace Ui {
27 class FindReplaceForm;
28}
29
30class QTextEdit;
31class QSettings;
32
33/**
34 * The form for the find/replace dialog. The form presents the typical
35 * widgets you find in standard find/replace dialogs, and it acts on a QTextEdit.
36 *
37 * \image html Screenshot-FindReplace.png
38 *
39 * You need to set the QTextEdit explicitly, using the method setTextEdit(QTextEdit *textEdit).
40 *
41 * For instance
42 * \code
43 * m_findReplaceDialog = new FindReplaceDialog(this);
44 * m_findReplaceDialog->setModal(false);
45 * m_findReplaceDialog->setTextEdit(ui->textEdit);
46 * \endcode
47 *
48 * The find functionalities is available even if the find dialog is not shown: if something
49 * to search for was already specified, the application can call the methods findNext() and
50 * findPrev() (e.g., by connecting them to menu items).
51 *
52 * In case a regular expression is used as the search term, the form also checks whether the
53 * expression is a valid regular expression (You may want to take a look at the syntax of regular expressions:
54 * http://doc.trolltech.com/qregexp.html).
55 *
56 * The form provides also functionalities to save and restore its state using a QSettings object (i.e.,
57 * the last word searched for, the options of the form, etc.) via the methods writeSettings()
58 * and readSettings().
59 *
60 * You can take a look at the \ref examples page.
61 */
62class FindReplaceForm : public QWidget {
63 Q_OBJECT
64public:
65 FindReplaceForm(QWidget *parent = 0);
66 virtual ~FindReplaceForm();
67
68 /**
69 * Associates the text editor where to perform the search
70 * @param textEdit_
71 */
72 void setTextEdit(QPlainTextEdit *textEdit_);
73
74 /// hides replace widgets from the form
75 void hideReplaceWidgets();
76
77 /**
78 * Writes the state of the form to the passed settings.
79 * @param settings
80 * @param prefix the prefix to insert in the settings
81 */
82 virtual void writeSettings(QSettings &settings, const QString &prefix = "FindReplaceDialog");
83
84 /**
85 * Reads the state of the form from the passed settings.
86 * @param settings
87 * @param prefix the prefix to look for in the settings
88 */
89 virtual void readSettings(QSettings &settings, const QString &prefix = "FindReplaceDialog");
90
91public slots:
92 /**
93 * performs the find task
94 * @param down whether to find the next or the previous
95 * occurrence
96 */
97 void find(bool down);
98
99 /**
100 * Finds the next occurrence
101 */
102 void find();
103
104 /**
105 * Finds the next occurrence
106 */
107 void findNext() { find(true); }
108
109 /**
110 * Finds the previous occurrence
111 */
112 void findPrev() { find(false); }
113
114 /**
115 * Replaces the found occurrences and goes to the next occurrence
116 */
117 void replace();
118
119 /**
120 * Replaces all the found occurrences
121 */
122 void replaceAll();
123
124protected:
125 void changeEvent(QEvent *e);
126
127 /// shows an error in the dialog
128 void showError(const QString &error);
129
130 /// shows a message in the dialog
131 void showMessage(const QString &message);
132
133protected slots:
134 /// when the text edit contents changed
135 void textToFindChanged();
136
137 /// checks whether the passed text is a valid regexp
138 void validateRegExp(const QString &text);
139
140 /// the regexp checkbox was selected
141 void regexpSelected(bool sel);
142
143protected:
144 Ui::FindReplaceForm *ui;
145
146 /// for searching into the text
147 QTextCursor textCursor;
148
149 /// the text editor (possibly) associated with this form
150 QPlainTextEdit *textEdit;
151};
152
153#endif // FINDREPLACEFORM_H
diff --git a/utils/themeeditor/findreplace/findreplaceform.ui b/utils/themeeditor/findreplace/findreplaceform.ui
deleted file mode 100644
index acc055ca88..0000000000
--- a/utils/themeeditor/findreplace/findreplaceform.ui
+++ /dev/null
@@ -1,204 +0,0 @@
1<?xml version="1.0" encoding="UTF-8"?>
2<ui version="4.0">
3 <class>FindReplaceForm</class>
4 <widget class="QWidget" name="FindReplaceForm">
5 <property name="geometry">
6 <rect>
7 <x>0</x>
8 <y>0</y>
9 <width>483</width>
10 <height>288</height>
11 </rect>
12 </property>
13 <property name="windowTitle">
14 <string>Form</string>
15 </property>
16 <layout class="QGridLayout" name="gridLayout">
17 <item row="0" column="0">
18 <layout class="QVBoxLayout" name="verticalLayout_5">
19 <item>
20 <layout class="QVBoxLayout" name="verticalLayout_2">
21 <item>
22 <layout class="QGridLayout" name="gridLayout_3">
23 <item row="0" column="0">
24 <widget class="QLabel" name="label">
25 <property name="text">
26 <string>&amp;Find:</string>
27 </property>
28 <property name="buddy">
29 <cstring>textToFind</cstring>
30 </property>
31 </widget>
32 </item>
33 <item row="0" column="1">
34 <widget class="QLineEdit" name="textToFind"/>
35 </item>
36 <item row="1" column="0">
37 <widget class="QLabel" name="replaceLabel">
38 <property name="text">
39 <string>R&amp;eplace with:</string>
40 </property>
41 <property name="buddy">
42 <cstring>textToReplace</cstring>
43 </property>
44 </widget>
45 </item>
46 <item row="1" column="1">
47 <widget class="QLineEdit" name="textToReplace"/>
48 </item>
49 </layout>
50 </item>
51 </layout>
52 </item>
53 <item>
54 <widget class="QLabel" name="errorLabel">
55 <property name="text">
56 <string>errorLabel</string>
57 </property>
58 </widget>
59 </item>
60 <item>
61 <layout class="QHBoxLayout" name="horizontalLayout">
62 <item>
63 <widget class="QGroupBox" name="groupBox">
64 <property name="title">
65 <string>D&amp;irection</string>
66 </property>
67 <layout class="QVBoxLayout" name="verticalLayout_3">
68 <item>
69 <widget class="QRadioButton" name="downRadioButton">
70 <property name="text">
71 <string>&amp;Down</string>
72 </property>
73 <property name="checked">
74 <bool>true</bool>
75 </property>
76 </widget>
77 </item>
78 <item>
79 <widget class="QRadioButton" name="upRadioButton">
80 <property name="text">
81 <string>&amp;Up</string>
82 </property>
83 </widget>
84 </item>
85 </layout>
86 </widget>
87 </item>
88 <item>
89 <widget class="QGroupBox" name="groupBox_2">
90 <property name="title">
91 <string>&amp;Options</string>
92 </property>
93 <layout class="QVBoxLayout" name="verticalLayout_4">
94 <item>
95 <widget class="QCheckBox" name="caseCheckBox">
96 <property name="text">
97 <string>&amp;Case sensitive</string>
98 </property>
99 </widget>
100 </item>
101 <item>
102 <widget class="QCheckBox" name="wholeCheckBox">
103 <property name="text">
104 <string>&amp;Whole words only</string>
105 </property>
106 </widget>
107 </item>
108 <item>
109 <widget class="QCheckBox" name="regexCheckBox">
110 <property name="toolTip">
111 <string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
112&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
113p, li { white-space: pre-wrap; }
114&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;&quot;&gt;
115&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;whether the text to search should be interpreted as a regular expression.&lt;/p&gt;
116&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;/p&gt;
117&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;You may want to take a look at the syntax of regular expressions:&lt;/p&gt;
118&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;a href=&quot;http://doc.trolltech.com/qregexp.html&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;http://doc.trolltech.com/qregexp.html&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
119 </property>
120 <property name="text">
121 <string>R&amp;egular Expression</string>
122 </property>
123 </widget>
124 </item>
125 </layout>
126 </widget>
127 </item>
128 </layout>
129 </item>
130 </layout>
131 </item>
132 <item row="0" column="1">
133 <layout class="QVBoxLayout" name="verticalLayout">
134 <property name="leftMargin">
135 <number>10</number>
136 </property>
137 <item>
138 <widget class="QPushButton" name="findButton">
139 <property name="enabled">
140 <bool>false</bool>
141 </property>
142 <property name="text">
143 <string>&amp;Find</string>
144 </property>
145 </widget>
146 </item>
147 <item>
148 <widget class="QPushButton" name="closeButton">
149 <property name="text">
150 <string>&amp;Close</string>
151 </property>
152 </widget>
153 </item>
154 <item>
155 <widget class="QPushButton" name="replaceButton">
156 <property name="enabled">
157 <bool>false</bool>
158 </property>
159 <property name="text">
160 <string>&amp;Replace</string>
161 </property>
162 </widget>
163 </item>
164 <item>
165 <widget class="QPushButton" name="replaceAllButton">
166 <property name="enabled">
167 <bool>false</bool>
168 </property>
169 <property name="text">
170 <string>Replace &amp;All</string>
171 </property>
172 </widget>
173 </item>
174 <item>
175 <spacer name="verticalSpacer">
176 <property name="orientation">
177 <enum>Qt::Vertical</enum>
178 </property>
179 <property name="sizeHint" stdset="0">
180 <size>
181 <width>20</width>
182 <height>40</height>
183 </size>
184 </property>
185 </spacer>
186 </item>
187 </layout>
188 </item>
189 </layout>
190 </widget>
191 <tabstops>
192 <tabstop>textToFind</tabstop>
193 <tabstop>textToReplace</tabstop>
194 <tabstop>downRadioButton</tabstop>
195 <tabstop>upRadioButton</tabstop>
196 <tabstop>caseCheckBox</tabstop>
197 <tabstop>wholeCheckBox</tabstop>
198 <tabstop>regexCheckBox</tabstop>
199 <tabstop>findButton</tabstop>
200 <tabstop>closeButton</tabstop>
201 </tabstops>
202 <resources/>
203 <connections/>
204</ui>
diff --git a/utils/themeeditor/gui/findreplacedialog.cpp b/utils/themeeditor/gui/findreplacedialog.cpp
new file mode 100644
index 0000000000..234c6f6886
--- /dev/null
+++ b/utils/themeeditor/gui/findreplacedialog.cpp
@@ -0,0 +1,101 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2010 Robert Bieber
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21
22#include "findreplacedialog.h"
23#include "ui_findreplacedialog.h"
24
25#include <QTextBlock>
26
27FindReplaceDialog::FindReplaceDialog(QWidget *parent) :
28 QDialog(parent),
29 ui(new Ui::FindReplaceDialog), editor(0)
30{
31 ui->setupUi(this);
32 setupUI();
33}
34
35FindReplaceDialog::~FindReplaceDialog()
36{
37 delete ui;
38}
39
40void FindReplaceDialog::changeEvent(QEvent *e)
41{
42 QDialog::changeEvent(e);
43 switch (e->type()) {
44 case QEvent::LanguageChange:
45 ui->retranslateUi(this);
46 break;
47 default:
48 break;
49 }
50}
51
52void FindReplaceDialog::closeEvent(QCloseEvent* event)
53{
54 ui->statusLabel->setText("");
55 event->accept();
56}
57
58void FindReplaceDialog::setupUI()
59{
60 QObject::connect(ui->findButton, SIGNAL(pressed()),
61 this, SLOT(find()));
62 QObject::connect(ui->replaceButton, SIGNAL(pressed()),
63 this, SLOT(replace()));
64 QObject::connect(ui->replaceAllButton, SIGNAL(pressed()),
65 this, SLOT(replaceAll()));
66 QObject::connect(ui->closeButton, SIGNAL(pressed()),
67 this, SLOT(close()));
68 QObject::connect(ui->findBox, SIGNAL(textChanged(QString)),
69 this, SLOT(textChanged()));
70
71 textChanged();
72}
73
74void FindReplaceDialog::find()
75{
76
77 if(!editor)
78 return;
79
80 editor->setTextCursor(editor->document()->find(ui->findBox->text()));
81
82}
83
84void FindReplaceDialog::replace()
85{
86
87}
88
89void FindReplaceDialog::replaceAll()
90{
91
92}
93
94void FindReplaceDialog::textChanged()
95{
96 bool enabled = ui->findBox->text() != "";
97
98 ui->findButton->setEnabled(enabled);
99 ui->replaceButton->setEnabled(enabled);
100 ui->replaceAllButton->setEnabled(enabled);
101}
diff --git a/utils/themeeditor/gui/findreplacedialog.h b/utils/themeeditor/gui/findreplacedialog.h
new file mode 100644
index 0000000000..793094a5fe
--- /dev/null
+++ b/utils/themeeditor/gui/findreplacedialog.h
@@ -0,0 +1,58 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2010 Robert Bieber
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21
22#ifndef FINDREPLACEDIALOG_H
23#define FINDREPLACEDIALOG_H
24
25#include <QDialog>
26#include <QPlainTextEdit>
27
28namespace Ui {
29 class FindReplaceDialog;
30}
31
32class FindReplaceDialog : public QDialog {
33 Q_OBJECT
34public:
35 FindReplaceDialog(QWidget *parent = 0);
36 virtual ~FindReplaceDialog();
37
38 void setTextEdit(QPlainTextEdit* editor){ this->editor = editor; }
39
40protected:
41 void changeEvent(QEvent *e);
42 void closeEvent(QCloseEvent* event);
43
44private slots:
45 void find();
46 void replace();
47 void replaceAll();
48 void textChanged();
49
50private:
51 void setupUI();
52
53 Ui::FindReplaceDialog *ui;
54
55 QPlainTextEdit* editor;
56};
57
58#endif // FINDREPLACEDIALOG_H
diff --git a/utils/themeeditor/gui/findreplacedialog.ui b/utils/themeeditor/gui/findreplacedialog.ui
new file mode 100644
index 0000000000..1c4510788f
--- /dev/null
+++ b/utils/themeeditor/gui/findreplacedialog.ui
@@ -0,0 +1,147 @@
1<?xml version="1.0" encoding="UTF-8"?>
2<ui version="4.0">
3 <class>FindReplaceDialog</class>
4 <widget class="QDialog" name="FindReplaceDialog">
5 <property name="geometry">
6 <rect>
7 <x>0</x>
8 <y>0</y>
9 <width>450</width>
10 <height>200</height>
11 </rect>
12 </property>
13 <property name="windowTitle">
14 <string>Find/Replace</string>
15 </property>
16 <property name="windowIcon">
17 <iconset resource="../resources.qrc">
18 <normaloff>:/resources/windowicon.png</normaloff>:/resources/windowicon.png</iconset>
19 </property>
20 <layout class="QHBoxLayout" name="horizontalLayout">
21 <item>
22 <layout class="QVBoxLayout" name="verticalLayout_2">
23 <item>
24 <layout class="QFormLayout" name="formLayout">
25 <item row="0" column="0">
26 <widget class="QLabel" name="label">
27 <property name="text">
28 <string>Find:</string>
29 </property>
30 <property name="buddy">
31 <cstring>findBox</cstring>
32 </property>
33 </widget>
34 </item>
35 <item row="0" column="1">
36 <widget class="QLineEdit" name="findBox"/>
37 </item>
38 <item row="1" column="0">
39 <widget class="QLabel" name="label_2">
40 <property name="text">
41 <string>Replace:</string>
42 </property>
43 <property name="buddy">
44 <cstring>replaceBox</cstring>
45 </property>
46 </widget>
47 </item>
48 <item row="1" column="1">
49 <widget class="QLineEdit" name="replaceBox"/>
50 </item>
51 </layout>
52 </item>
53 <item>
54 <layout class="QVBoxLayout" name="verticalLayout">
55 <item>
56 <widget class="QLabel" name="statusLabel">
57 <property name="text">
58 <string/>
59 </property>
60 </widget>
61 </item>
62 <item>
63 <widget class="QCheckBox" name="caseBox">
64 <property name="text">
65 <string>Match Case</string>
66 </property>
67 </widget>
68 </item>
69 <item>
70 <widget class="QCheckBox" name="backwardsBox">
71 <property name="text">
72 <string>Search Backwards</string>
73 </property>
74 </widget>
75 </item>
76 <item>
77 <widget class="QCheckBox" name="wrapBox">
78 <property name="text">
79 <string>Wrap Around</string>
80 </property>
81 </widget>
82 </item>
83 </layout>
84 </item>
85 </layout>
86 </item>
87 <item>
88 <layout class="QVBoxLayout" name="verticalLayout_3">
89 <item>
90 <widget class="QPushButton" name="findButton">
91 <property name="text">
92 <string>Find</string>
93 </property>
94 <property name="shortcut">
95 <string>Ctrl+F</string>
96 </property>
97 <property name="default">
98 <bool>true</bool>
99 </property>
100 </widget>
101 </item>
102 <item>
103 <widget class="QPushButton" name="replaceButton">
104 <property name="text">
105 <string>Replace</string>
106 </property>
107 </widget>
108 </item>
109 <item>
110 <widget class="QPushButton" name="replaceAllButton">
111 <property name="text">
112 <string>Replace All</string>
113 </property>
114 </widget>
115 </item>
116 <item>
117 <widget class="QPushButton" name="closeButton">
118 <property name="text">
119 <string>Close</string>
120 </property>
121 <property name="shortcut">
122 <string>Esc</string>
123 </property>
124 </widget>
125 </item>
126 <item>
127 <spacer name="verticalSpacer">
128 <property name="orientation">
129 <enum>Qt::Vertical</enum>
130 </property>
131 <property name="sizeHint" stdset="0">
132 <size>
133 <width>20</width>
134 <height>40</height>
135 </size>
136 </property>
137 </spacer>
138 </item>
139 </layout>
140 </item>
141 </layout>
142 </widget>
143 <resources>
144 <include location="../resources.qrc"/>
145 </resources>
146 <connections/>
147</ui>
diff --git a/utils/themeeditor/gui/skindocument.cpp b/utils/themeeditor/gui/skindocument.cpp
index 28e5297b48..9a381a9589 100644
--- a/utils/themeeditor/gui/skindocument.cpp
+++ b/utils/themeeditor/gui/skindocument.cpp
@@ -29,6 +29,8 @@
29 29
30#include <iostream> 30#include <iostream>
31 31
32#include <QDebug>
33
32SkinDocument::SkinDocument(QLabel* statusLabel, ProjectModel* project, 34SkinDocument::SkinDocument(QLabel* statusLabel, ProjectModel* project,
33 DeviceState* device, QWidget *parent) 35 DeviceState* device, QWidget *parent)
34 :TabContent(parent), statusLabel(statusLabel), 36 :TabContent(parent), statusLabel(statusLabel),
diff --git a/utils/themeeditor/themeeditor.pro b/utils/themeeditor/themeeditor.pro
index 14fa73cc7d..4241598566 100644
--- a/utils/themeeditor/themeeditor.pro
+++ b/utils/themeeditor/themeeditor.pro
@@ -11,7 +11,6 @@ RBBASE_DIR = $$replace(RBBASE_DIR,/utils/themeeditor,)
11INCLUDEPATH += gui 11INCLUDEPATH += gui
12INCLUDEPATH += models 12INCLUDEPATH += models
13INCLUDEPATH += graphics 13INCLUDEPATH += graphics
14INCLUDEPATH += findreplace
15 14
16# Stuff for the parse lib 15# Stuff for the parse lib
17libskin_parser.commands = @$(MAKE) \ 16libskin_parser.commands = @$(MAKE) \
@@ -42,10 +41,9 @@ HEADERS += models/parsetreemodel.h \
42 graphics/rbimage.h \ 41 graphics/rbimage.h \
43 graphics/rbfont.h \ 42 graphics/rbfont.h \
44 gui/devicestate.h \ 43 gui/devicestate.h \
45 findreplace/findreplaceform.h \
46 findreplace/findreplacedialog.h \
47 graphics/rbalbumart.h \ 44 graphics/rbalbumart.h \
48 graphics/rbprogressbar.h 45 graphics/rbprogressbar.h \
46 gui/findreplacedialog.h
49SOURCES += main.cpp \ 47SOURCES += main.cpp \
50 models/parsetreemodel.cpp \ 48 models/parsetreemodel.cpp \
51 models/parsetreenode.cpp \ 49 models/parsetreenode.cpp \
@@ -63,10 +61,9 @@ SOURCES += main.cpp \
63 graphics/rbimage.cpp \ 61 graphics/rbimage.cpp \
64 graphics/rbfont.cpp \ 62 graphics/rbfont.cpp \
65 gui/devicestate.cpp \ 63 gui/devicestate.cpp \
66 findreplace/findreplaceform.cpp \
67 findreplace/findreplacedialog.cpp \
68 graphics/rbalbumart.cpp \ 64 graphics/rbalbumart.cpp \
69 graphics/rbprogressbar.cpp 65 graphics/rbprogressbar.cpp \
66 gui/findreplacedialog.cpp
70OTHER_FILES += README \ 67OTHER_FILES += README \
71 resources/windowicon.png \ 68 resources/windowicon.png \
72 resources/appicon.xcf \ 69 resources/appicon.xcf \
@@ -81,6 +78,5 @@ FORMS += gui/editorwindow.ui \
81 gui/preferencesdialog.ui \ 78 gui/preferencesdialog.ui \
82 gui/configdocument.ui \ 79 gui/configdocument.ui \
83 gui/skinviewer.ui \ 80 gui/skinviewer.ui \
84 findreplace/findreplaceform.ui \ 81 gui/findreplacedialog.ui
85 findreplace/findreplacedialog.ui
86RESOURCES += resources.qrc 82RESOURCES += resources.qrc