forked from len0rd/rockbox
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
This commit is contained in:
parent
fb09d6354c
commit
a8bb62e6e2
3 changed files with 48 additions and 2 deletions
|
@ -163,6 +163,8 @@ void EditorWindow::setupUI()
|
||||||
deviceDock->setWidget(deviceConfig);
|
deviceDock->setWidget(deviceConfig);
|
||||||
deviceDock->setFloating(true);
|
deviceDock->setFloating(true);
|
||||||
deviceDock->hide();
|
deviceDock->hide();
|
||||||
|
|
||||||
|
shiftTab(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorWindow::setupMenus()
|
void EditorWindow::setupMenus()
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
|
|
||||||
FindReplaceDialog::FindReplaceDialog(QWidget *parent) :
|
FindReplaceDialog::FindReplaceDialog(QWidget *parent) :
|
||||||
QDialog(parent),
|
QDialog(parent),
|
||||||
ui(new Ui::FindReplaceDialog), editor(0)
|
ui(new Ui::FindReplaceDialog), editor(0), textFound()
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
setupUI();
|
setupUI();
|
||||||
|
@ -77,7 +77,50 @@ void FindReplaceDialog::find()
|
||||||
if(!editor)
|
if(!editor)
|
||||||
return;
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -53,6 +53,7 @@ private:
|
||||||
Ui::FindReplaceDialog *ui;
|
Ui::FindReplaceDialog *ui;
|
||||||
|
|
||||||
QPlainTextEdit* editor;
|
QPlainTextEdit* editor;
|
||||||
|
QTextCursor textFound;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // FINDREPLACEDIALOG_H
|
#endif // FINDREPLACEDIALOG_H
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue