diff options
author | Robert Bieber <robby@bieberphoto.com> | 2010-06-26 07:59:23 +0000 |
---|---|---|
committer | Robert Bieber <robby@bieberphoto.com> | 2010-06-26 07:59:23 +0000 |
commit | be70fd89be787e2b24604f9ba785b87c1f8f1d22 (patch) | |
tree | 5b7ec98c48d2a5d2dc5078007142d2e92c09a8a2 /utils/themeeditor/gui | |
parent | 5300c7014d602c57fcae7f6619f5138d83ba33c0 (diff) | |
download | rockbox-be70fd89be787e2b24604f9ba785b87c1f8f1d22.tar.gz rockbox-be70fd89be787e2b24604f9ba785b87c1f8f1d22.zip |
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
Diffstat (limited to 'utils/themeeditor/gui')
-rw-r--r-- | utils/themeeditor/gui/editorwindow.cpp | 90 | ||||
-rw-r--r-- | utils/themeeditor/gui/editorwindow.h | 6 | ||||
-rw-r--r-- | utils/themeeditor/gui/editorwindow.ui | 62 | ||||
-rw-r--r-- | utils/themeeditor/gui/skindocument.cpp | 6 | ||||
-rw-r--r-- | utils/themeeditor/gui/skindocument.h | 8 |
5 files changed, 172 insertions, 0 deletions
diff --git a/utils/themeeditor/gui/editorwindow.cpp b/utils/themeeditor/gui/editorwindow.cpp index b778a1fba4..ea6c91f074 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<TabContent*>(ui->editorTabs->widget(i))->type() == + TabContent::Skin) + dynamic_cast<SkinDocument*>(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<TabContent*> + (ui->editorTabs->currentWidget()); + if(doc->type() == TabContent::Skin) + dynamic_cast<SkinDocument*>(doc)->getEditor()->undo(); +} + +void EditorWindow::redo() +{ + TabContent* doc = dynamic_cast<TabContent*> + (ui->editorTabs->currentWidget()); + if(doc->type() == TabContent::Skin) + dynamic_cast<SkinDocument*>(doc)->getEditor()->redo(); + +} + +void EditorWindow::cut() +{ + TabContent* doc = dynamic_cast<TabContent*> + (ui->editorTabs->currentWidget()); + if(doc->type() == TabContent::Skin) + dynamic_cast<SkinDocument*>(doc)->getEditor()->cut(); +} + +void EditorWindow::copy() +{ + TabContent* doc = dynamic_cast<TabContent*> + (ui->editorTabs->currentWidget()); + if(doc->type() == TabContent::Skin) + dynamic_cast<SkinDocument*>(doc)->getEditor()->copy(); +} + +void EditorWindow::paste() +{ + TabContent* doc = dynamic_cast<TabContent*> + (ui->editorTabs->currentWidget()); + if(doc->type() == TabContent::Skin) + dynamic_cast<SkinDocument*>(doc)->getEditor()->paste(); +} + +void EditorWindow::findReplace() +{ + TabContent* doc = dynamic_cast<TabContent*> + (ui->editorTabs->currentWidget()); + if(doc->type() == TabContent::Skin) + dynamic_cast<SkinDocument*>(doc)->showFind(); +} + + void EditorWindow::expandLine(ParseTreeModel* model, QModelIndex parent, int line) { diff --git a/utils/themeeditor/gui/editorwindow.h b/utils/themeeditor/gui/editorwindow.h index ab75cc54fa..6f30249e31 100644 --- a/utils/themeeditor/gui/editorwindow.h +++ b/utils/themeeditor/gui/editorwindow.h @@ -73,6 +73,12 @@ private slots: void tabTitleChanged(QString title); void updateCurrent(); /* Generates code in the current tab */ void lineChanged(int line); /* Used for auto-expand */ + void undo(); + void redo(); + void cut(); + void copy(); + void paste(); + void findReplace(); private: /* Setup functions */ diff --git a/utils/themeeditor/gui/editorwindow.ui b/utils/themeeditor/gui/editorwindow.ui index 2f84d384c8..707e24698c 100644 --- a/utils/themeeditor/gui/editorwindow.ui +++ b/utils/themeeditor/gui/editorwindow.ui @@ -70,7 +70,21 @@ <addaction name="separator"/> <addaction name="actionDevice_Configuration"/> </widget> + <widget class="QMenu" name="menuEdit"> + <property name="title"> + <string>&Edit</string> + </property> + <addaction name="actionUndo"/> + <addaction name="actionRedo"/> + <addaction name="separator"/> + <addaction name="actionCut"/> + <addaction name="actionCopy"/> + <addaction name="actionPaste"/> + <addaction name="separator"/> + <addaction name="actionFind_Replace"/> + </widget> <addaction name="menuFile"/> + <addaction name="menuEdit"/> <addaction name="menuView"/> </widget> <widget class="QStatusBar" name="statusbar"/> @@ -303,6 +317,54 @@ <string>Ctrl+D</string> </property> </action> + <action name="actionUndo"> + <property name="text"> + <string>&Undo</string> + </property> + <property name="shortcut"> + <string>Ctrl+Z</string> + </property> + </action> + <action name="actionRedo"> + <property name="text"> + <string>&Redo</string> + </property> + <property name="shortcut"> + <string>Ctrl+Shift+Z</string> + </property> + </action> + <action name="actionCut"> + <property name="text"> + <string>C&ut</string> + </property> + <property name="shortcut"> + <string>Ctrl+X</string> + </property> + </action> + <action name="actionCopy"> + <property name="text"> + <string>&Copy</string> + </property> + <property name="shortcut"> + <string>Ctrl+C</string> + </property> + </action> + <action name="actionPaste"> + <property name="text"> + <string>&Paste</string> + </property> + <property name="shortcut"> + <string>Ctrl+V</string> + </property> + </action> + <action name="actionFind_Replace"> + <property name="text"> + <string>&Find/Replace</string> + </property> + <property name="shortcut"> + <string>Ctrl+F</string> + </property> + </action> </widget> <tabstops> <tabstop>projectTree</tabstop> diff --git a/utils/themeeditor/gui/skindocument.cpp b/utils/themeeditor/gui/skindocument.cpp index 6863ff5a9d..f8206e1a26 100644 --- a/utils/themeeditor/gui/skindocument.cpp +++ b/utils/themeeditor/gui/skindocument.cpp @@ -151,6 +151,12 @@ void SkinDocument::setupUI() QObject::connect(device, SIGNAL(settingsChanged()), this, SLOT(deviceChanged())); + /* Attaching the find/replace dialog */ + findReplace = new FindReplaceDialog(this); + findReplace->setModal(false); + findReplace->setTextEdit(editor); + findReplace->hide(); + settingsChanged(); } diff --git a/utils/themeeditor/gui/skindocument.h b/utils/themeeditor/gui/skindocument.h index c6b36873f8..1713023779 100644 --- a/utils/themeeditor/gui/skindocument.h +++ b/utils/themeeditor/gui/skindocument.h @@ -27,6 +27,8 @@ #include <QHBoxLayout> #include <QGraphicsScene> +#include "findreplacedialog.h" + #include "skinhighlighter.h" #include "parsetreemodel.h" #include "preferencesdialog.h" @@ -61,6 +63,7 @@ public: QString file() const{ return fileName; } QString title() const{ return titleText; } QString getStatus(){ return parseStatus; } + CodeEditor* getEditor(){ return editor; } void genCode(){ editor->document()->setPlainText(model->genCode()); } void setProject(ProjectModel* project){ this->project = project; } @@ -73,6 +76,9 @@ public: QGraphicsScene* scene(){ return model->render(project, device, &fileName); } + void showFind(){ findReplace->show(); } + void hideFind(){ findReplace->hide(); } + signals: public slots: @@ -104,6 +110,8 @@ private: ProjectModel* project; DeviceState* device; + + FindReplaceDialog* findReplace; }; #endif // SKINDOCUMENT_H |