From be70fd89be787e2b24604f9ba785b87c1f8f1d22 Mon Sep 17 00:00:00 2001 From: Robert Bieber Date: Sat, 26 Jun 2010 07:59:23 +0000 Subject: Theme Editor: Added an edit menu with a find/replace function (copied from an LGPL library) git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27137 a1c6a512-1295-4272-9138-f99709370657 --- utils/themeeditor/gui/editorwindow.cpp | 90 ++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) (limited to 'utils/themeeditor/gui/editorwindow.cpp') diff --git a/utils/themeeditor/gui/editorwindow.cpp b/utils/themeeditor/gui/editorwindow.cpp index b778a1f..ea6c91f 100644 --- a/utils/themeeditor/gui/editorwindow.cpp +++ b/utils/themeeditor/gui/editorwindow.cpp @@ -200,6 +200,20 @@ void EditorWindow::setupMenus() QObject::connect(ui->actionOpen_Project, SIGNAL(triggered()), this, SLOT(openProject())); + + /* Connecting the edit menu */ + QObject::connect(ui->actionUndo, SIGNAL(triggered()), + this, SLOT(undo())); + QObject::connect(ui->actionRedo, SIGNAL(triggered()), + this, SLOT(redo())); + QObject::connect(ui->actionCut, SIGNAL(triggered()), + this, SLOT(cut())); + QObject::connect(ui->actionCopy, SIGNAL(triggered()), + this, SLOT(copy())); + QObject::connect(ui->actionPaste, SIGNAL(triggered()), + this, SLOT(paste())); + QObject::connect(ui->actionFind_Replace, SIGNAL(triggered()), + this, SLOT(findReplace())); } void EditorWindow::addTab(TabContent *doc) @@ -237,6 +251,12 @@ void EditorWindow::shiftTab(int index) ui->actionClose_Document->setEnabled(false); ui->actionToolbarSave->setEnabled(false); ui->fromTree->setEnabled(false); + ui->actionUndo->setEnabled(false); + ui->actionRedo->setEnabled(false); + ui->actionCut->setEnabled(false); + ui->actionCopy->setEnabled(false); + ui->actionPaste->setEnabled(false); + ui->actionFind_Replace->setEnabled(false); viewer->setScene(0); } else if(widget->type() == TabContent::Config) @@ -245,6 +265,12 @@ void EditorWindow::shiftTab(int index) ui->actionSave_Document_As->setEnabled(true); ui->actionClose_Document->setEnabled(true); ui->actionToolbarSave->setEnabled(true); + ui->actionUndo->setEnabled(false); + ui->actionRedo->setEnabled(false); + ui->actionCut->setEnabled(false); + ui->actionCopy->setEnabled(false); + ui->actionPaste->setEnabled(false); + ui->actionFind_Replace->setEnabled(false); viewer->setScene(0); } else if(widget->type() == TabContent::Skin) @@ -260,12 +286,26 @@ void EditorWindow::shiftTab(int index) ui->actionToolbarSave->setEnabled(true); ui->fromTree->setEnabled(true); + ui->actionUndo->setEnabled(true); + ui->actionRedo->setEnabled(true); + ui->actionCut->setEnabled(true); + ui->actionCopy->setEnabled(true); + ui->actionPaste->setEnabled(true); + ui->actionFind_Replace->setEnabled(true); + sizeColumns(); /* Syncing the preview */ viewer->setScene(doc->scene()); } + + /* Hiding all the find/replace dialogs */ + for(int i = 0; i < ui->editorTabs->count(); i++) + if(dynamic_cast(ui->editorTabs->widget(i))->type() == + TabContent::Skin) + dynamic_cast(ui->editorTabs->widget(i))->hideFind(); + } bool EditorWindow::closeTab(int index) @@ -469,6 +509,56 @@ void EditorWindow::lineChanged(int line) } +void EditorWindow::undo() +{ + TabContent* doc = dynamic_cast + (ui->editorTabs->currentWidget()); + if(doc->type() == TabContent::Skin) + dynamic_cast(doc)->getEditor()->undo(); +} + +void EditorWindow::redo() +{ + TabContent* doc = dynamic_cast + (ui->editorTabs->currentWidget()); + if(doc->type() == TabContent::Skin) + dynamic_cast(doc)->getEditor()->redo(); + +} + +void EditorWindow::cut() +{ + TabContent* doc = dynamic_cast + (ui->editorTabs->currentWidget()); + if(doc->type() == TabContent::Skin) + dynamic_cast(doc)->getEditor()->cut(); +} + +void EditorWindow::copy() +{ + TabContent* doc = dynamic_cast + (ui->editorTabs->currentWidget()); + if(doc->type() == TabContent::Skin) + dynamic_cast(doc)->getEditor()->copy(); +} + +void EditorWindow::paste() +{ + TabContent* doc = dynamic_cast + (ui->editorTabs->currentWidget()); + if(doc->type() == TabContent::Skin) + dynamic_cast(doc)->getEditor()->paste(); +} + +void EditorWindow::findReplace() +{ + TabContent* doc = dynamic_cast + (ui->editorTabs->currentWidget()); + if(doc->type() == TabContent::Skin) + dynamic_cast(doc)->showFind(); +} + + void EditorWindow::expandLine(ParseTreeModel* model, QModelIndex parent, int line) { -- cgit v1.1