From a8bb62e6e290678f221a01bec7b24e6742366759 Mon Sep 17 00:00:00 2001 From: Robert Bieber Date: Sat, 3 Jul 2010 06:53:06 +0000 Subject: Theme Editor: Made irrelevant menu items disabled at startup, made wrap-around search work in the find/replace dialog git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27253 a1c6a512-1295-4272-9138-f99709370657 --- utils/themeeditor/gui/editorwindow.cpp | 2 ++ utils/themeeditor/gui/findreplacedialog.cpp | 47 +++++++++++++++++++++++++++-- utils/themeeditor/gui/findreplacedialog.h | 1 + 3 files changed, 48 insertions(+), 2 deletions(-) (limited to 'utils/themeeditor/gui') diff --git a/utils/themeeditor/gui/editorwindow.cpp b/utils/themeeditor/gui/editorwindow.cpp index 96f855242d..4c073b9e0b 100644 --- a/utils/themeeditor/gui/editorwindow.cpp +++ b/utils/themeeditor/gui/editorwindow.cpp @@ -163,6 +163,8 @@ void EditorWindow::setupUI() deviceDock->setWidget(deviceConfig); deviceDock->setFloating(true); deviceDock->hide(); + + shiftTab(-1); } void EditorWindow::setupMenus() diff --git a/utils/themeeditor/gui/findreplacedialog.cpp b/utils/themeeditor/gui/findreplacedialog.cpp index 234c6f6886..e2b8b9bc43 100644 --- a/utils/themeeditor/gui/findreplacedialog.cpp +++ b/utils/themeeditor/gui/findreplacedialog.cpp @@ -26,7 +26,7 @@ FindReplaceDialog::FindReplaceDialog(QWidget *parent) : QDialog(parent), - ui(new Ui::FindReplaceDialog), editor(0) + ui(new Ui::FindReplaceDialog), editor(0), textFound() { ui->setupUi(this); setupUI(); @@ -77,7 +77,50 @@ void FindReplaceDialog::find() if(!editor) return; - editor->setTextCursor(editor->document()->find(ui->findBox->text())); + /* Figuring out the range to search in */ + int begin = editor->textCursor().selectionStart(); + int end = editor->textCursor().selectionEnd(); + + QTextDocument::FindFlags flags = 0; + if(ui->caseBox->isChecked()) + flags |= QTextDocument::FindCaseSensitively; + if(ui->backwardsBox->isChecked()) + flags |= QTextDocument::FindBackward; + + QTextCursor start = textFound.isNull() ? editor->textCursor() : textFound; + + textFound = editor->document()->find(ui->findBox->text(), start, flags); + + if(textFound.isNull() && ui->wrapBox->isChecked()) + { + if(ui->backwardsBox->isChecked()) + { + textFound = editor->document() + ->find(ui->findBox->text(), + editor->document()->toPlainText().length(), + flags); + } + else + { + textFound = editor->document()->find(ui->findBox->text(), 0, flags); + } + } + + QPalette newPal; + if(!textFound.isNull()) + { + newPal.setColor(QPalette::Foreground, QColor(150, 255, 150)); + ui->statusLabel->setPalette(newPal); + ui->statusLabel->setText(tr("Match Found")); + editor->setTextCursor(textFound); + } + else + { + newPal.setColor(QPalette::Foreground, Qt::red); + ui->statusLabel->setPalette(newPal); + ui->statusLabel->setText(tr("Match Not Found")); + editor->setTextCursor(start); + } } diff --git a/utils/themeeditor/gui/findreplacedialog.h b/utils/themeeditor/gui/findreplacedialog.h index 793094a5fe..009a077d8b 100644 --- a/utils/themeeditor/gui/findreplacedialog.h +++ b/utils/themeeditor/gui/findreplacedialog.h @@ -53,6 +53,7 @@ private: Ui::FindReplaceDialog *ui; QPlainTextEdit* editor; + QTextCursor textFound; }; #endif // FINDREPLACEDIALOG_H -- cgit v1.2.3