summaryrefslogtreecommitdiff
path: root/utils/themeeditor/gui
diff options
context:
space:
mode:
Diffstat (limited to 'utils/themeeditor/gui')
-rw-r--r--utils/themeeditor/gui/findreplacedialog.cpp159
-rw-r--r--utils/themeeditor/gui/findreplacedialog.h59
-rw-r--r--utils/themeeditor/gui/findreplacedialog.ui147
3 files changed, 0 insertions, 365 deletions
diff --git a/utils/themeeditor/gui/findreplacedialog.cpp b/utils/themeeditor/gui/findreplacedialog.cpp
deleted file mode 100644
index 2a6161189e..0000000000
--- a/utils/themeeditor/gui/findreplacedialog.cpp
+++ /dev/null
@@ -1,159 +0,0 @@
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), textFound()
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(clicked()),
61 this, SLOT(find()));
62 QObject::connect(ui->replaceButton, SIGNAL(clicked()),
63 this, SLOT(replace()));
64 QObject::connect(ui->replaceAllButton, SIGNAL(clicked()),
65 this, SLOT(replaceAll()));
66 QObject::connect(ui->closeButton, SIGNAL(clicked()),
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 QTextDocument::FindFlags flags = 0;
81 if(ui->caseBox->isChecked())
82 flags |= QTextDocument::FindCaseSensitively;
83 if(ui->backwardsBox->isChecked())
84 flags |= QTextDocument::FindBackward;
85
86 QTextCursor start = textFound.isNull() ? editor->textCursor() : textFound;
87
88 textFound = editor->document()->find(ui->findBox->text(), start, flags);
89
90 if(textFound.isNull() && ui->wrapBox->isChecked())
91 {
92 if(ui->backwardsBox->isChecked())
93 {
94 textFound = editor->document()
95 ->find(ui->findBox->text(),
96 editor->document()->toPlainText().length(),
97 flags);
98 }
99 else
100 {
101 textFound = editor->document()->find(ui->findBox->text(), 0, flags);
102 }
103 }
104
105 QPalette newPal;
106 if(!textFound.isNull())
107 {
108 newPal.setColor(QPalette::Foreground, QColor(0, 150, 0));
109 ui->statusLabel->setPalette(newPal);
110 ui->statusLabel->setText(tr("Match Found"));
111 editor->setTextCursor(textFound);
112 }
113 else
114 {
115 newPal.setColor(QPalette::Foreground, Qt::red);
116 ui->statusLabel->setPalette(newPal);
117 ui->statusLabel->setText(tr("Match Not Found"));
118 editor->setTextCursor(start);
119 }
120
121}
122
123void FindReplaceDialog::replace()
124{
125 if(textFound.isNull())
126 find();
127
128 if(textFound.isNull())
129 return;
130
131 editor->setTextCursor(textFound);
132 editor->insertPlainText(ui->replaceBox->text());
133 textFound = QTextCursor();
134}
135
136void FindReplaceDialog::replaceAll()
137{
138
139 do
140 {
141 if(!textFound.isNull())
142 {
143 editor->setTextCursor(textFound);
144 editor->insertPlainText(ui->replaceBox->text());
145 }
146
147 find();
148 }while(!textFound.isNull());
149
150}
151
152void FindReplaceDialog::textChanged()
153{
154 bool enabled = ui->findBox->text() != "";
155
156 ui->findButton->setEnabled(enabled);
157 ui->replaceButton->setEnabled(enabled);
158 ui->replaceAllButton->setEnabled(enabled);
159}
diff --git a/utils/themeeditor/gui/findreplacedialog.h b/utils/themeeditor/gui/findreplacedialog.h
deleted file mode 100644
index 009a077d8b..0000000000
--- a/utils/themeeditor/gui/findreplacedialog.h
+++ /dev/null
@@ -1,59 +0,0 @@
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 QTextCursor textFound;
57};
58
59#endif // FINDREPLACEDIALOG_H
diff --git a/utils/themeeditor/gui/findreplacedialog.ui b/utils/themeeditor/gui/findreplacedialog.ui
deleted file mode 100644
index 5641181a61..0000000000
--- a/utils/themeeditor/gui/findreplacedialog.ui
+++ /dev/null
@@ -1,147 +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>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 <widget class="QLabel" name="statusLabel">
55 <property name="text">
56 <string/>
57 </property>
58 </widget>
59 </item>
60 <item>
61 <layout class="QVBoxLayout" name="verticalLayout">
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>