diff options
author | Robert Bieber <robby@bieberphoto.com> | 2010-07-03 06:08:59 +0000 |
---|---|---|
committer | Robert Bieber <robby@bieberphoto.com> | 2010-07-03 06:08:59 +0000 |
commit | fb09d6354c0b6badb449f532f40af9a8037377a3 (patch) | |
tree | efe8844d87a8dec2239a7f88ca161583ebd6c869 | |
parent | 4b321649a8bf3879a33051e63f250985b97007e3 (diff) | |
download | rockbox-fb09d6354c0b6badb449f532f40af9a8037377a3.tar.gz rockbox-fb09d6354c0b6badb449f532f40af9a8037377a3.zip |
Theme Editor: Removed some old debug code in skindocument.cpp, began implementing a new find/replace dialog, due to licensing issues
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27252 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | utils/themeeditor/findreplace/findreplacedialog.cpp | 64 | ||||
-rw-r--r-- | utils/themeeditor/findreplace/findreplacedialog.h | 80 | ||||
-rw-r--r-- | utils/themeeditor/findreplace/findreplacedialog.ui | 32 | ||||
-rw-r--r-- | utils/themeeditor/findreplace/findreplaceform.cpp | 222 | ||||
-rw-r--r-- | utils/themeeditor/findreplace/findreplaceform.h | 153 | ||||
-rw-r--r-- | utils/themeeditor/findreplace/findreplaceform.ui | 204 | ||||
-rw-r--r-- | utils/themeeditor/gui/findreplacedialog.cpp | 101 | ||||
-rw-r--r-- | utils/themeeditor/gui/findreplacedialog.h | 58 | ||||
-rw-r--r-- | utils/themeeditor/gui/findreplacedialog.ui | 147 | ||||
-rw-r--r-- | utils/themeeditor/gui/skindocument.cpp | 2 | ||||
-rw-r--r-- | utils/themeeditor/themeeditor.pro | 14 |
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 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * This file has been copied from Lorenzo Bettini, with minor modifications - * made available under the LGPL version 3, as the original file was licensed - * - **************************************************************************** - * - * Copyright (C) 2009 Lorenzo Bettini <http://www.lorenzobettini.it> - * See COPYING file that comes with this distribution - */ - -#include "findreplacedialog.h" -#include "ui_findreplacedialog.h" - -FindReplaceDialog::FindReplaceDialog(QWidget *parent) : - QDialog(parent), - ui(new Ui::FindReplaceDialog) -{ - ui->setupUi(this); -} - -FindReplaceDialog::~FindReplaceDialog() -{ - delete ui; -} - -void FindReplaceDialog::changeEvent(QEvent *e) -{ - QDialog::changeEvent(e); - switch (e->type()) { - case QEvent::LanguageChange: - ui->retranslateUi(this); - break; - default: - break; - } -} - -void FindReplaceDialog::setTextEdit(QPlainTextEdit *textEdit) { - ui->findReplaceForm->setTextEdit(textEdit); -} - -void FindReplaceDialog::writeSettings(QSettings &settings, const QString &prefix) { - ui->findReplaceForm->writeSettings(settings, prefix); -} - -void FindReplaceDialog::readSettings(QSettings &settings, const QString &prefix) { - ui->findReplaceForm->readSettings(settings, prefix); -} - -void FindReplaceDialog::findNext() { - ui->findReplaceForm->findNext(); -} - -void FindReplaceDialog::findPrev() { - ui->findReplaceForm->findPrev(); -} 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 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * This file has been copied from Lorenzo Bettini, with minor modifications - * made available under the LGPL version 3, as the original file was licensed - * - **************************************************************************** - * - * Copyright (C) 2009 Lorenzo Bettini <http://www.lorenzobettini.it> - * See COPYING file that comes with this distribution - */ - -#ifndef FINDREPLACEDIALOG_H -#define FINDREPLACEDIALOG_H - -#include <QDialog> -#include <QPlainTextEdit> - -namespace Ui { - class FindReplaceDialog; -} - -class QTextEdit; -class QSettings; - -/** - * A find/replace dialog. - * - * It relies on a FindReplaceForm object (see that class for the functionalities provided). - */ -class FindReplaceDialog : public QDialog { - Q_OBJECT -public: - FindReplaceDialog(QWidget *parent = 0); - virtual ~FindReplaceDialog(); - - /** - * Associates the text editor where to perform the search - * @param textEdit - */ - void setTextEdit(QPlainTextEdit *textEdit); - - /** - * Writes the state of the form to the passed settings. - * @param settings - * @param prefix the prefix to insert in the settings - */ - virtual void writeSettings(QSettings &settings, const QString &prefix = "FindReplaceDialog"); - - /** - * Reads the state of the form from the passed settings. - * @param settings - * @param prefix the prefix to look for in the settings - */ - virtual void readSettings(QSettings &settings, const QString &prefix = "FindReplaceDialog"); - -public slots: - /** - * Finds the next occurrence - */ - void findNext(); - - /** - * Finds the previous occurrence - */ - void findPrev(); - -protected: - void changeEvent(QEvent *e); - - Ui::FindReplaceDialog *ui; -}; - -#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 @@ -<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>FindReplaceDialog</class>
- <widget class="QDialog" name="FindReplaceDialog">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>342</width>
- <height>140</height>
- </rect>
- </property>
- <property name="windowTitle">
- <string>Find/Replace</string>
- </property>
- <layout class="QGridLayout" name="gridLayout">
- <item row="0" column="0">
- <widget class="FindReplaceForm" name="findReplaceForm" native="true"/>
- </item>
- </layout>
- </widget>
- <customwidgets>
- <customwidget>
- <class>FindReplaceForm</class>
- <extends>QWidget</extends>
- <header location="global">findreplaceform.h</header>
- <container>1</container>
- </customwidget>
- </customwidgets>
- <resources/>
- <connections/>
-</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 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * This file has been copied from Lorenzo Bettini, with minor modifications - * made available under the LGPL version 3, as the original file was licensed - * - **************************************************************************** - * - * Copyright (C) 2009 Lorenzo Bettini <http://www.lorenzobettini.it> - * See COPYING file that comes with this distribution - */ - -#include <QtGui> -#include <QTextEdit> -#include <QRegExp> -#include <QSettings> - -#include "findreplaceform.h" -#include "ui_findreplaceform.h" - -#define TEXT_TO_FIND "textToFind" -#define TEXT_TO_REPLACE "textToReplace" -#define DOWN_RADIO "downRadio" -#define UP_RADIO "upRadio" -#define CASE_CHECK "caseCheck" -#define WHOLE_CHECK "wholeCheck" -#define REGEXP_CHECK "regexpCheck" - -FindReplaceForm::FindReplaceForm(QWidget *parent) : - QWidget(parent), - ui(new Ui::FindReplaceForm), textEdit(0) -{ - ui->setupUi(this); - - ui->errorLabel->setText(""); - - connect(ui->textToFind, SIGNAL(textChanged(QString)), this, SLOT(textToFindChanged())); - connect(ui->textToFind, SIGNAL(textChanged(QString)), this, SLOT(validateRegExp(QString))); - - connect(ui->regexCheckBox, SIGNAL(toggled(bool)), this, SLOT(regexpSelected(bool))); - - connect(ui->findButton, SIGNAL(clicked()), this, SLOT(find())); - connect(ui->closeButton, SIGNAL(clicked()), parent, SLOT(close())); - - connect(ui->replaceButton, SIGNAL(clicked()), this, SLOT(replace())); - connect(ui->replaceAllButton, SIGNAL(clicked()), this, SLOT(replaceAll())); -} - -FindReplaceForm::~FindReplaceForm() -{ - delete ui; -} - -void FindReplaceForm::hideReplaceWidgets() { - ui->replaceLabel->setVisible(false); - ui->textToReplace->setVisible(false); - ui->replaceButton->setVisible(false); - ui->replaceAllButton->setVisible(false); -} - -void FindReplaceForm::setTextEdit(QPlainTextEdit *textEdit_) { - textEdit = textEdit_; - connect(textEdit, SIGNAL(copyAvailable(bool)), ui->replaceButton, SLOT(setEnabled(bool))); - connect(textEdit, SIGNAL(copyAvailable(bool)), ui->replaceAllButton, SLOT(setEnabled(bool))); -} - -void FindReplaceForm::changeEvent(QEvent *e) -{ - QWidget::changeEvent(e); - switch (e->type()) { - case QEvent::LanguageChange: - ui->retranslateUi(this); - break; - default: - break; - } -} - -void FindReplaceForm::textToFindChanged() { - ui->findButton->setEnabled(ui->textToFind->text().size() > 0); -} - -void FindReplaceForm::regexpSelected(bool sel) { - if (sel) - validateRegExp(ui->textToFind->text()); - else - validateRegExp(""); -} - -void FindReplaceForm::validateRegExp(const QString &text) { - if (!ui->regexCheckBox->isChecked() || text.size() == 0) { - ui->errorLabel->setText(""); - return; // nothing to validate - } - - QRegExp reg(text, - (ui->caseCheckBox->isChecked() ? Qt::CaseSensitive : Qt::CaseInsensitive)); - - if (reg.isValid()) { - showError(""); - } else { - showError(reg.errorString()); - } -} - -void FindReplaceForm::showError(const QString &error) { - if (error == "") { - ui->errorLabel->setText(""); - } else { - ui->errorLabel->setText("<span style=\" font-weight:600; color:#ff0000;\">" + - error + - "</span>"); - } -} - -void FindReplaceForm::showMessage(const QString &message) { - if (message == "") { - ui->errorLabel->setText(""); - } else { - ui->errorLabel->setText("<span style=\" font-weight:600; color:green;\">" + - message + - "</span>"); - } -} - -void FindReplaceForm::find() { - find(ui->downRadioButton->isChecked()); -} - -void FindReplaceForm::find(bool next) { - if (!textEdit) - return; // TODO: show some warning? - - // backward search - bool back = !next; - - const QString &toSearch = ui->textToFind->text(); - - bool result = false; - - QTextDocument::FindFlags flags; - - if (back) - flags |= QTextDocument::FindBackward; - if (ui->caseCheckBox->isChecked()) - flags |= QTextDocument::FindCaseSensitively; - if (ui->wholeCheckBox->isChecked()) - flags |= QTextDocument::FindWholeWords; - - if (ui->regexCheckBox->isChecked()) { - QRegExp reg(toSearch, - (ui->caseCheckBox->isChecked() ? Qt::CaseSensitive : Qt::CaseInsensitive)); - - qDebug() << "searching for regexp: " << reg.pattern(); - - textCursor = textEdit->document()->find(reg, textCursor, flags); - textEdit->setTextCursor(textCursor); - result = (!textCursor.isNull()); - } else { - qDebug() << "searching for: " << toSearch; - - result = textEdit->find(toSearch, flags); - } - - if (result) { - showError(""); - } else { - showError(tr("no match found")); - // move to the beginning of the document for the next find - textCursor.setPosition(0); - textEdit->setTextCursor(textCursor); - } -} - -void FindReplaceForm::replace() { - if (!textEdit->textCursor().hasSelection()) { - find(); - } else { - textEdit->textCursor().insertText(ui->textToReplace->text()); - find(); - } -} - -void FindReplaceForm::replaceAll() { - int i=0; - while (textEdit->textCursor().hasSelection()){ - textEdit->textCursor().insertText(ui->textToReplace->text()); - find(); - i++; - } - showMessage(tr("Replaced %1 occurrence(s)").arg(i)); -} - -void FindReplaceForm::writeSettings(QSettings &settings, const QString &prefix) { - settings.beginGroup(prefix); - settings.setValue(TEXT_TO_FIND, ui->textToFind->text()); - settings.setValue(TEXT_TO_REPLACE, ui->textToReplace->text()); - settings.setValue(DOWN_RADIO, ui->downRadioButton->isChecked()); - settings.setValue(UP_RADIO, ui->upRadioButton->isChecked()); - settings.setValue(CASE_CHECK, ui->caseCheckBox->isChecked()); - settings.setValue(WHOLE_CHECK, ui->wholeCheckBox->isChecked()); - settings.setValue(REGEXP_CHECK, ui->regexCheckBox->isChecked()); - settings.endGroup(); -} - -void FindReplaceForm::readSettings(QSettings &settings, const QString &prefix) { - settings.beginGroup(prefix); - ui->textToFind->setText(settings.value(TEXT_TO_FIND, "").toString()); - ui->textToReplace->setText(settings.value(TEXT_TO_REPLACE, "").toString()); - ui->downRadioButton->setChecked(settings.value(DOWN_RADIO, true).toBool()); - ui->upRadioButton->setChecked(settings.value(UP_RADIO, false).toBool()); - ui->caseCheckBox->setChecked(settings.value(CASE_CHECK, false).toBool()); - ui->wholeCheckBox->setChecked(settings.value(WHOLE_CHECK, false).toBool()); - ui->regexCheckBox->setChecked(settings.value(REGEXP_CHECK, false).toBool()); - settings.endGroup(); -} 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 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * This file has been copied from Lorenzo Bettini, with minor modifications - * made available under the LGPL version 3, as the original file was licensed - * - **************************************************************************** - * - * Copyright (C) 2009 Lorenzo Bettini <http://www.lorenzobettini.it> - * See COPYING file that comes with this distribution - */ - -#ifndef FINDREPLACEFORM_H -#define FINDREPLACEFORM_H - -#include <QWidget> -#include <QTextCursor> -#include <QPlainTextEdit> - -namespace Ui { - class FindReplaceForm; -} - -class QTextEdit; -class QSettings; - -/** - * The form for the find/replace dialog. The form presents the typical - * widgets you find in standard find/replace dialogs, and it acts on a QTextEdit. - * - * \image html Screenshot-FindReplace.png - * - * You need to set the QTextEdit explicitly, using the method setTextEdit(QTextEdit *textEdit). - * - * For instance - * \code - * m_findReplaceDialog = new FindReplaceDialog(this); - * m_findReplaceDialog->setModal(false); - * m_findReplaceDialog->setTextEdit(ui->textEdit); - * \endcode - * - * The find functionalities is available even if the find dialog is not shown: if something - * to search for was already specified, the application can call the methods findNext() and - * findPrev() (e.g., by connecting them to menu items). - * - * In case a regular expression is used as the search term, the form also checks whether the - * expression is a valid regular expression (You may want to take a look at the syntax of regular expressions: - * http://doc.trolltech.com/qregexp.html). - * - * The form provides also functionalities to save and restore its state using a QSettings object (i.e., - * the last word searched for, the options of the form, etc.) via the methods writeSettings() - * and readSettings(). - * - * You can take a look at the \ref examples page. - */ -class FindReplaceForm : public QWidget { - Q_OBJECT -public: - FindReplaceForm(QWidget *parent = 0); - virtual ~FindReplaceForm(); - - /** - * Associates the text editor where to perform the search - * @param textEdit_ - */ - void setTextEdit(QPlainTextEdit *textEdit_); - - /// hides replace widgets from the form - void hideReplaceWidgets(); - - /** - * Writes the state of the form to the passed settings. - * @param settings - * @param prefix the prefix to insert in the settings - */ - virtual void writeSettings(QSettings &settings, const QString &prefix = "FindReplaceDialog"); - - /** - * Reads the state of the form from the passed settings. - * @param settings - * @param prefix the prefix to look for in the settings - */ - virtual void readSettings(QSettings &settings, const QString &prefix = "FindReplaceDialog"); - -public slots: - /** - * performs the find task - * @param down whether to find the next or the previous - * occurrence - */ - void find(bool down); - - /** - * Finds the next occurrence - */ - void find(); - - /** - * Finds the next occurrence - */ - void findNext() { find(true); } - - /** - * Finds the previous occurrence - */ - void findPrev() { find(false); } - - /** - * Replaces the found occurrences and goes to the next occurrence - */ - void replace(); - - /** - * Replaces all the found occurrences - */ - void replaceAll(); - -protected: - void changeEvent(QEvent *e); - - /// shows an error in the dialog - void showError(const QString &error); - - /// shows a message in the dialog - void showMessage(const QString &message); - -protected slots: - /// when the text edit contents changed - void textToFindChanged(); - - /// checks whether the passed text is a valid regexp - void validateRegExp(const QString &text); - - /// the regexp checkbox was selected - void regexpSelected(bool sel); - -protected: - Ui::FindReplaceForm *ui; - - /// for searching into the text - QTextCursor textCursor; - - /// the text editor (possibly) associated with this form - QPlainTextEdit *textEdit; -}; - -#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 @@ -<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>FindReplaceForm</class>
- <widget class="QWidget" name="FindReplaceForm">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>483</width>
- <height>288</height>
- </rect>
- </property>
- <property name="windowTitle">
- <string>Form</string>
- </property>
- <layout class="QGridLayout" name="gridLayout">
- <item row="0" column="0">
- <layout class="QVBoxLayout" name="verticalLayout_5">
- <item>
- <layout class="QVBoxLayout" name="verticalLayout_2">
- <item>
- <layout class="QGridLayout" name="gridLayout_3">
- <item row="0" column="0">
- <widget class="QLabel" name="label">
- <property name="text">
- <string>&Find:</string>
- </property>
- <property name="buddy">
- <cstring>textToFind</cstring>
- </property>
- </widget>
- </item>
- <item row="0" column="1">
- <widget class="QLineEdit" name="textToFind"/>
- </item>
- <item row="1" column="0">
- <widget class="QLabel" name="replaceLabel">
- <property name="text">
- <string>R&eplace with:</string>
- </property>
- <property name="buddy">
- <cstring>textToReplace</cstring>
- </property>
- </widget>
- </item>
- <item row="1" column="1">
- <widget class="QLineEdit" name="textToReplace"/>
- </item>
- </layout>
- </item>
- </layout>
- </item>
- <item>
- <widget class="QLabel" name="errorLabel">
- <property name="text">
- <string>errorLabel</string>
- </property>
- </widget>
- </item>
- <item>
- <layout class="QHBoxLayout" name="horizontalLayout">
- <item>
- <widget class="QGroupBox" name="groupBox">
- <property name="title">
- <string>D&irection</string>
- </property>
- <layout class="QVBoxLayout" name="verticalLayout_3">
- <item>
- <widget class="QRadioButton" name="downRadioButton">
- <property name="text">
- <string>&Down</string>
- </property>
- <property name="checked">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QRadioButton" name="upRadioButton">
- <property name="text">
- <string>&Up</string>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- </item>
- <item>
- <widget class="QGroupBox" name="groupBox_2">
- <property name="title">
- <string>&Options</string>
- </property>
- <layout class="QVBoxLayout" name="verticalLayout_4">
- <item>
- <widget class="QCheckBox" name="caseCheckBox">
- <property name="text">
- <string>&Case sensitive</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QCheckBox" name="wholeCheckBox">
- <property name="text">
- <string>&Whole words only</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QCheckBox" name="regexCheckBox">
- <property name="toolTip">
- <string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
-<html><head><meta name="qrichtext" content="1" /><style type="text/css">
-p, li { white-space: pre-wrap; }
-</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;">
-<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">whether the text to search should be interpreted as a regular expression.</p>
-<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></p>
-<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">You may want to take a look at the syntax of regular expressions:</p>
-<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a href="http://doc.trolltech.com/qregexp.html"><span style=" text-decoration: underline; color:#0000ff;">http://doc.trolltech.com/qregexp.html</span></a></p></body></html></string>
- </property>
- <property name="text">
- <string>R&egular Expression</string>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- </item>
- </layout>
- </item>
- </layout>
- </item>
- <item row="0" column="1">
- <layout class="QVBoxLayout" name="verticalLayout">
- <property name="leftMargin">
- <number>10</number>
- </property>
- <item>
- <widget class="QPushButton" name="findButton">
- <property name="enabled">
- <bool>false</bool>
- </property>
- <property name="text">
- <string>&Find</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QPushButton" name="closeButton">
- <property name="text">
- <string>&Close</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QPushButton" name="replaceButton">
- <property name="enabled">
- <bool>false</bool>
- </property>
- <property name="text">
- <string>&Replace</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QPushButton" name="replaceAllButton">
- <property name="enabled">
- <bool>false</bool>
- </property>
- <property name="text">
- <string>Replace &All</string>
- </property>
- </widget>
- </item>
- <item>
- <spacer name="verticalSpacer">
- <property name="orientation">
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>20</width>
- <height>40</height>
- </size>
- </property>
- </spacer>
- </item>
- </layout>
- </item>
- </layout>
- </widget>
- <tabstops>
- <tabstop>textToFind</tabstop>
- <tabstop>textToReplace</tabstop>
- <tabstop>downRadioButton</tabstop>
- <tabstop>upRadioButton</tabstop>
- <tabstop>caseCheckBox</tabstop>
- <tabstop>wholeCheckBox</tabstop>
- <tabstop>regexCheckBox</tabstop>
- <tabstop>findButton</tabstop>
- <tabstop>closeButton</tabstop>
- </tabstops>
- <resources/>
- <connections/>
-</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 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2010 Robert Bieber + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#include "findreplacedialog.h" +#include "ui_findreplacedialog.h" + +#include <QTextBlock> + +FindReplaceDialog::FindReplaceDialog(QWidget *parent) : + QDialog(parent), + ui(new Ui::FindReplaceDialog), editor(0) +{ + ui->setupUi(this); + setupUI(); +} + +FindReplaceDialog::~FindReplaceDialog() +{ + delete ui; +} + +void FindReplaceDialog::changeEvent(QEvent *e) +{ + QDialog::changeEvent(e); + switch (e->type()) { + case QEvent::LanguageChange: + ui->retranslateUi(this); + break; + default: + break; + } +} + +void FindReplaceDialog::closeEvent(QCloseEvent* event) +{ + ui->statusLabel->setText(""); + event->accept(); +} + +void FindReplaceDialog::setupUI() +{ + QObject::connect(ui->findButton, SIGNAL(pressed()), + this, SLOT(find())); + QObject::connect(ui->replaceButton, SIGNAL(pressed()), + this, SLOT(replace())); + QObject::connect(ui->replaceAllButton, SIGNAL(pressed()), + this, SLOT(replaceAll())); + QObject::connect(ui->closeButton, SIGNAL(pressed()), + this, SLOT(close())); + QObject::connect(ui->findBox, SIGNAL(textChanged(QString)), + this, SLOT(textChanged())); + + textChanged(); +} + +void FindReplaceDialog::find() +{ + + if(!editor) + return; + + editor->setTextCursor(editor->document()->find(ui->findBox->text())); + +} + +void FindReplaceDialog::replace() +{ + +} + +void FindReplaceDialog::replaceAll() +{ + +} + +void FindReplaceDialog::textChanged() +{ + bool enabled = ui->findBox->text() != ""; + + ui->findButton->setEnabled(enabled); + ui->replaceButton->setEnabled(enabled); + ui->replaceAllButton->setEnabled(enabled); +} 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 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2010 Robert Bieber + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#ifndef FINDREPLACEDIALOG_H +#define FINDREPLACEDIALOG_H + +#include <QDialog> +#include <QPlainTextEdit> + +namespace Ui { + class FindReplaceDialog; +} + +class FindReplaceDialog : public QDialog { + Q_OBJECT +public: + FindReplaceDialog(QWidget *parent = 0); + virtual ~FindReplaceDialog(); + + void setTextEdit(QPlainTextEdit* editor){ this->editor = editor; } + +protected: + void changeEvent(QEvent *e); + void closeEvent(QCloseEvent* event); + +private slots: + void find(); + void replace(); + void replaceAll(); + void textChanged(); + +private: + void setupUI(); + + Ui::FindReplaceDialog *ui; + + QPlainTextEdit* editor; +}; + +#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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>FindReplaceDialog</class> + <widget class="QDialog" name="FindReplaceDialog"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>450</width> + <height>200</height> + </rect> + </property> + <property name="windowTitle"> + <string>Find/Replace</string> + </property> + <property name="windowIcon"> + <iconset resource="../resources.qrc"> + <normaloff>:/resources/windowicon.png</normaloff>:/resources/windowicon.png</iconset> + </property> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <layout class="QVBoxLayout" name="verticalLayout_2"> + <item> + <layout class="QFormLayout" name="formLayout"> + <item row="0" column="0"> + <widget class="QLabel" name="label"> + <property name="text"> + <string>Find:</string> + </property> + <property name="buddy"> + <cstring>findBox</cstring> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="QLineEdit" name="findBox"/> + </item> + <item row="1" column="0"> + <widget class="QLabel" name="label_2"> + <property name="text"> + <string>Replace:</string> + </property> + <property name="buddy"> + <cstring>replaceBox</cstring> + </property> + </widget> + </item> + <item row="1" column="1"> + <widget class="QLineEdit" name="replaceBox"/> + </item> + </layout> + </item> + <item> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <widget class="QLabel" name="statusLabel"> + <property name="text"> + <string/> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="caseBox"> + <property name="text"> + <string>Match Case</string> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="backwardsBox"> + <property name="text"> + <string>Search Backwards</string> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="wrapBox"> + <property name="text"> + <string>Wrap Around</string> + </property> + </widget> + </item> + </layout> + </item> + </layout> + </item> + <item> + <layout class="QVBoxLayout" name="verticalLayout_3"> + <item> + <widget class="QPushButton" name="findButton"> + <property name="text"> + <string>Find</string> + </property> + <property name="shortcut"> + <string>Ctrl+F</string> + </property> + <property name="default"> + <bool>true</bool> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="replaceButton"> + <property name="text"> + <string>Replace</string> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="replaceAllButton"> + <property name="text"> + <string>Replace All</string> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="closeButton"> + <property name="text"> + <string>Close</string> + </property> + <property name="shortcut"> + <string>Esc</string> + </property> + </widget> + </item> + <item> + <spacer name="verticalSpacer"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>40</height> + </size> + </property> + </spacer> + </item> + </layout> + </item> + </layout> + </widget> + <resources> + <include location="../resources.qrc"/> + </resources> + <connections/> +</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 @@ #include <iostream> +#include <QDebug> + SkinDocument::SkinDocument(QLabel* statusLabel, ProjectModel* project, DeviceState* device, QWidget *parent) :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,) INCLUDEPATH += gui INCLUDEPATH += models INCLUDEPATH += graphics -INCLUDEPATH += findreplace # Stuff for the parse lib libskin_parser.commands = @$(MAKE) \ @@ -42,10 +41,9 @@ HEADERS += models/parsetreemodel.h \ graphics/rbimage.h \ graphics/rbfont.h \ gui/devicestate.h \ - findreplace/findreplaceform.h \ - findreplace/findreplacedialog.h \ graphics/rbalbumart.h \ - graphics/rbprogressbar.h + graphics/rbprogressbar.h \ + gui/findreplacedialog.h SOURCES += main.cpp \ models/parsetreemodel.cpp \ models/parsetreenode.cpp \ @@ -63,10 +61,9 @@ SOURCES += main.cpp \ graphics/rbimage.cpp \ graphics/rbfont.cpp \ gui/devicestate.cpp \ - findreplace/findreplaceform.cpp \ - findreplace/findreplacedialog.cpp \ graphics/rbalbumart.cpp \ - graphics/rbprogressbar.cpp + graphics/rbprogressbar.cpp \ + gui/findreplacedialog.cpp OTHER_FILES += README \ resources/windowicon.png \ resources/appicon.xcf \ @@ -81,6 +78,5 @@ FORMS += gui/editorwindow.ui \ gui/preferencesdialog.ui \ gui/configdocument.ui \ gui/skinviewer.ui \ - findreplace/findreplaceform.ui \ - findreplace/findreplacedialog.ui + gui/findreplacedialog.ui RESOURCES += resources.qrc |