diff options
Diffstat (limited to 'utils/themeeditor/gui')
-rw-r--r-- | utils/themeeditor/gui/editorwindow.cpp | 121 | ||||
-rw-r--r-- | utils/themeeditor/gui/editorwindow.h | 14 | ||||
-rw-r--r-- | utils/themeeditor/gui/editorwindow.ui | 36 |
3 files changed, 170 insertions, 1 deletions
diff --git a/utils/themeeditor/gui/editorwindow.cpp b/utils/themeeditor/gui/editorwindow.cpp index f919224a2f..f76fd8e88b 100644 --- a/utils/themeeditor/gui/editorwindow.cpp +++ b/utils/themeeditor/gui/editorwindow.cpp | |||
@@ -36,6 +36,8 @@ | |||
36 | #include <QDir> | 36 | #include <QDir> |
37 | #include <QFile> | 37 | #include <QFile> |
38 | 38 | ||
39 | const int EditorWindow::numRecent = 5; | ||
40 | |||
39 | EditorWindow::EditorWindow(QWidget *parent) : | 41 | EditorWindow::EditorWindow(QWidget *parent) : |
40 | QMainWindow(parent), ui(new Ui::EditorWindow), parseTreeSelection(0) | 42 | QMainWindow(parent), ui(new Ui::EditorWindow), parseTreeSelection(0) |
41 | { | 43 | { |
@@ -56,6 +58,8 @@ EditorWindow::~EditorWindow() | |||
56 | delete project; | 58 | delete project; |
57 | delete deviceConfig; | 59 | delete deviceConfig; |
58 | delete deviceDock; | 60 | delete deviceDock; |
61 | delete timer; | ||
62 | delete timerDock; | ||
59 | 63 | ||
60 | RBFontCache::clearCache(); | 64 | RBFontCache::clearCache(); |
61 | RBTextCache::clearCache(); | 65 | RBTextCache::clearCache(); |
@@ -63,6 +67,8 @@ EditorWindow::~EditorWindow() | |||
63 | 67 | ||
64 | void EditorWindow::loadTabFromSkinFile(QString fileName) | 68 | void EditorWindow::loadTabFromSkinFile(QString fileName) |
65 | { | 69 | { |
70 | docToTop(fileName); | ||
71 | |||
66 | /* Checking to see if the file is already open */ | 72 | /* Checking to see if the file is already open */ |
67 | for(int i = 0; i < ui->editorTabs->count(); i++) | 73 | for(int i = 0; i < ui->editorTabs->count(); i++) |
68 | { | 74 | { |
@@ -114,6 +120,12 @@ void EditorWindow::loadSettings() | |||
114 | QSize size = settings.value("size").toSize(); | 120 | QSize size = settings.value("size").toSize(); |
115 | QPoint pos = settings.value("position").toPoint(); | 121 | QPoint pos = settings.value("position").toPoint(); |
116 | QByteArray state = settings.value("state").toByteArray(); | 122 | QByteArray state = settings.value("state").toByteArray(); |
123 | |||
124 | /* Recent docs/projects */ | ||
125 | recentDocs = settings.value("recentDocs", QStringList()).toStringList(); | ||
126 | recentProjects = settings.value("recentProjects", | ||
127 | QStringList()).toStringList(); | ||
128 | |||
117 | settings.endGroup(); | 129 | settings.endGroup(); |
118 | 130 | ||
119 | if(!(size.isNull() || pos.isNull() || state.isNull())) | 131 | if(!(size.isNull() || pos.isNull() || state.isNull())) |
@@ -135,6 +147,11 @@ void EditorWindow::saveSettings() | |||
135 | settings.setValue("position", pos()); | 147 | settings.setValue("position", pos()); |
136 | settings.setValue("size", size()); | 148 | settings.setValue("size", size()); |
137 | settings.setValue("state", saveState()); | 149 | settings.setValue("state", saveState()); |
150 | |||
151 | /* Saving recent docs/projects */ | ||
152 | settings.setValue("recentDocs", recentDocs); | ||
153 | settings.setValue("recentProjects", recentProjects); | ||
154 | |||
138 | settings.endGroup(); | 155 | settings.endGroup(); |
139 | } | 156 | } |
140 | 157 | ||
@@ -245,6 +262,30 @@ void EditorWindow::setupMenus() | |||
245 | this, SLOT(paste())); | 262 | this, SLOT(paste())); |
246 | QObject::connect(ui->actionFind_Replace, SIGNAL(triggered()), | 263 | QObject::connect(ui->actionFind_Replace, SIGNAL(triggered()), |
247 | this, SLOT(findReplace())); | 264 | this, SLOT(findReplace())); |
265 | |||
266 | /* Adding the recent docs/projects menus */ | ||
267 | for(int i = 0; i < numRecent; i++) | ||
268 | { | ||
269 | recentDocsMenu.append(new QAction(tr("Recent Doc"), | ||
270 | ui->menuRecent_Files)); | ||
271 | recentDocsMenu.last() | ||
272 | ->setShortcut(QKeySequence(tr("CTRL+") | ||
273 | + QString::number(i + 1))); | ||
274 | QObject::connect(recentDocsMenu.last(), SIGNAL(triggered()), | ||
275 | this, SLOT(openRecentFile())); | ||
276 | ui->menuRecent_Files->addAction(recentDocsMenu.last()); | ||
277 | |||
278 | |||
279 | recentProjectsMenu.append(new QAction(tr("Recent Project"), | ||
280 | ui->menuRecent_Projects)); | ||
281 | recentProjectsMenu.last() | ||
282 | ->setShortcut(QKeySequence(tr("CTRL+SHIFT+") + | ||
283 | QString::number(i + 1))); | ||
284 | QObject::connect(recentProjectsMenu.last(), SIGNAL(triggered()), | ||
285 | this, SLOT(openRecentProject())); | ||
286 | ui->menuRecent_Projects->addAction(recentProjectsMenu.last()); | ||
287 | } | ||
288 | refreshRecentMenus(); | ||
248 | } | 289 | } |
249 | 290 | ||
250 | void EditorWindow::addTab(TabContent *doc) | 291 | void EditorWindow::addTab(TabContent *doc) |
@@ -546,6 +587,16 @@ void EditorWindow::openProject() | |||
546 | 587 | ||
547 | } | 588 | } |
548 | 589 | ||
590 | void EditorWindow::openRecentFile() | ||
591 | { | ||
592 | loadTabFromSkinFile(dynamic_cast<QAction*>(QObject::sender())->text()); | ||
593 | } | ||
594 | |||
595 | void EditorWindow::openRecentProject() | ||
596 | { | ||
597 | loadProjectFile(dynamic_cast<QAction*>(QObject::sender())->text()); | ||
598 | } | ||
599 | |||
549 | void EditorWindow::configFileChanged(QString configFile) | 600 | void EditorWindow::configFileChanged(QString configFile) |
550 | { | 601 | { |
551 | 602 | ||
@@ -743,6 +794,8 @@ void EditorWindow::loadProjectFile(QString fileName) | |||
743 | 794 | ||
744 | if(QFile::exists(fileName)) | 795 | if(QFile::exists(fileName)) |
745 | { | 796 | { |
797 | projectToTop(fileName); | ||
798 | |||
746 | if(project) | 799 | if(project) |
747 | project->deleteLater(); | 800 | project->deleteLater(); |
748 | 801 | ||
@@ -816,3 +869,71 @@ void EditorWindow::createFile(QString filename, QString contents) | |||
816 | 869 | ||
817 | fout.close(); | 870 | fout.close(); |
818 | } | 871 | } |
872 | |||
873 | void EditorWindow::docToTop(QString file) | ||
874 | { | ||
875 | if(!QFile::exists(file)) | ||
876 | return; | ||
877 | |||
878 | int index = recentDocs.indexOf(file); | ||
879 | if(index == -1) | ||
880 | { | ||
881 | /* Bumping off the last file */ | ||
882 | if(recentDocs.count() >= numRecent) | ||
883 | recentDocs.removeLast(); | ||
884 | recentDocs.prepend(file); | ||
885 | } | ||
886 | else | ||
887 | { | ||
888 | /* Shuffling file to the top of the list */ | ||
889 | recentDocs.removeAt(index); | ||
890 | recentDocs.prepend(file); | ||
891 | } | ||
892 | |||
893 | refreshRecentMenus(); | ||
894 | } | ||
895 | |||
896 | void EditorWindow::projectToTop(QString file) | ||
897 | { | ||
898 | if(!QFile::exists(file)) | ||
899 | return; | ||
900 | |||
901 | int index = recentProjects.indexOf(file); | ||
902 | if(index == -1) | ||
903 | { | ||
904 | /* Bumping off the last project */ | ||
905 | if(recentProjects.count() >= numRecent) | ||
906 | recentProjects.removeLast(); | ||
907 | recentProjects.prepend(file); | ||
908 | } | ||
909 | else | ||
910 | { | ||
911 | /* Shuffling file to the top of the list */ | ||
912 | recentProjects.removeAt(index); | ||
913 | recentProjects.prepend(file); | ||
914 | } | ||
915 | |||
916 | refreshRecentMenus(); | ||
917 | } | ||
918 | |||
919 | void EditorWindow::refreshRecentMenus() | ||
920 | { | ||
921 | /* First hiding all the menu items */ | ||
922 | for(int i = 0; i < recentDocsMenu.count(); i++) | ||
923 | recentDocsMenu[i]->setVisible(false); | ||
924 | for(int i = 0; i < recentProjectsMenu.count(); i++) | ||
925 | recentProjectsMenu[i]->setVisible(false); | ||
926 | |||
927 | /* Then setting the text of and showing any available */ | ||
928 | for(int i = 0; i < recentDocs.count(); i++) | ||
929 | { | ||
930 | recentDocsMenu[i]->setText(recentDocs[i]); | ||
931 | recentDocsMenu[i]->setVisible(true); | ||
932 | } | ||
933 | |||
934 | for(int i = 0; i < recentProjects.count(); i++) | ||
935 | { | ||
936 | recentProjectsMenu[i]->setText(recentProjects[i]); | ||
937 | recentProjectsMenu[i]->setVisible(true); | ||
938 | } | ||
939 | } | ||
diff --git a/utils/themeeditor/gui/editorwindow.h b/utils/themeeditor/gui/editorwindow.h index 996ddcd40e..bd71c9a5dc 100644 --- a/utils/themeeditor/gui/editorwindow.h +++ b/utils/themeeditor/gui/editorwindow.h | |||
@@ -49,6 +49,8 @@ class EditorWindow : public QMainWindow | |||
49 | { | 49 | { |
50 | Q_OBJECT | 50 | Q_OBJECT |
51 | public: | 51 | public: |
52 | static const int numRecent; | ||
53 | |||
52 | EditorWindow(QWidget *parent = 0); | 54 | EditorWindow(QWidget *parent = 0); |
53 | virtual ~EditorWindow(); | 55 | virtual ~EditorWindow(); |
54 | 56 | ||
@@ -75,6 +77,8 @@ private slots: | |||
75 | void exportProject(); | 77 | void exportProject(); |
76 | void openFile(); | 78 | void openFile(); |
77 | void openProject(); | 79 | void openProject(); |
80 | void openRecentFile(); | ||
81 | void openRecentProject(); | ||
78 | void tabTitleChanged(QString title); | 82 | void tabTitleChanged(QString title); |
79 | void updateCurrent(); /* Generates code in the current tab */ | 83 | void updateCurrent(); /* Generates code in the current tab */ |
80 | void lineChanged(int line); /* Used for auto-expand */ | 84 | void lineChanged(int line); /* Used for auto-expand */ |
@@ -100,6 +104,11 @@ private: | |||
100 | void loadProjectFile(QString fileName); | 104 | void loadProjectFile(QString fileName); |
101 | static void createFile(QString filename, QString contents); | 105 | static void createFile(QString filename, QString contents); |
102 | 106 | ||
107 | /* Functions to manipulate the recent projects/documents menus */ | ||
108 | void docToTop(QString file); | ||
109 | void projectToTop(QString file); | ||
110 | void refreshRecentMenus(); | ||
111 | |||
103 | Ui::EditorWindow *ui; | 112 | Ui::EditorWindow *ui; |
104 | PreferencesDialog* prefs; | 113 | PreferencesDialog* prefs; |
105 | QLabel* parseStatus; | 114 | QLabel* parseStatus; |
@@ -110,6 +119,11 @@ private: | |||
110 | QDockWidget* deviceDock; | 119 | QDockWidget* deviceDock; |
111 | SkinTimer* timer; | 120 | SkinTimer* timer; |
112 | QDockWidget* timerDock; | 121 | QDockWidget* timerDock; |
122 | |||
123 | QStringList recentDocs; | ||
124 | QStringList recentProjects; | ||
125 | QList<QAction*> recentDocsMenu; | ||
126 | QList<QAction*> recentProjectsMenu; | ||
113 | }; | 127 | }; |
114 | 128 | ||
115 | #endif // EDITORWINDOW_H | 129 | #endif // EDITORWINDOW_H |
diff --git a/utils/themeeditor/gui/editorwindow.ui b/utils/themeeditor/gui/editorwindow.ui index edfdfe3d84..bd74e1369e 100644 --- a/utils/themeeditor/gui/editorwindow.ui +++ b/utils/themeeditor/gui/editorwindow.ui | |||
@@ -40,17 +40,29 @@ | |||
40 | <x>0</x> | 40 | <x>0</x> |
41 | <y>0</y> | 41 | <y>0</y> |
42 | <width>628</width> | 42 | <width>628</width> |
43 | <height>25</height> | 43 | <height>27</height> |
44 | </rect> | 44 | </rect> |
45 | </property> | 45 | </property> |
46 | <widget class="QMenu" name="menuFile"> | 46 | <widget class="QMenu" name="menuFile"> |
47 | <property name="title"> | 47 | <property name="title"> |
48 | <string>&File</string> | 48 | <string>&File</string> |
49 | </property> | 49 | </property> |
50 | <widget class="QMenu" name="menuRecent_Files"> | ||
51 | <property name="title"> | ||
52 | <string>Recent Files</string> | ||
53 | </property> | ||
54 | </widget> | ||
55 | <widget class="QMenu" name="menuRecent_Projects"> | ||
56 | <property name="title"> | ||
57 | <string>Recent Projects</string> | ||
58 | </property> | ||
59 | </widget> | ||
50 | <addaction name="actionNew_Document"/> | 60 | <addaction name="actionNew_Document"/> |
51 | <addaction name="actionNew_Project"/> | 61 | <addaction name="actionNew_Project"/> |
52 | <addaction name="actionOpen_Document"/> | 62 | <addaction name="actionOpen_Document"/> |
53 | <addaction name="actionOpen_Project"/> | 63 | <addaction name="actionOpen_Project"/> |
64 | <addaction name="menuRecent_Files"/> | ||
65 | <addaction name="menuRecent_Projects"/> | ||
54 | <addaction name="separator"/> | 66 | <addaction name="separator"/> |
55 | <addaction name="actionClose_Document"/> | 67 | <addaction name="actionClose_Document"/> |
56 | <addaction name="actionClose_Project"/> | 68 | <addaction name="actionClose_Project"/> |
@@ -407,6 +419,28 @@ | |||
407 | <string>Ctrl+Shift+X</string> | 419 | <string>Ctrl+Shift+X</string> |
408 | </property> | 420 | </property> |
409 | </action> | 421 | </action> |
422 | <action name="actionFiles"> | ||
423 | <property name="enabled"> | ||
424 | <bool>false</bool> | ||
425 | </property> | ||
426 | <property name="text"> | ||
427 | <string>Files</string> | ||
428 | </property> | ||
429 | <property name="visible"> | ||
430 | <bool>true</bool> | ||
431 | </property> | ||
432 | </action> | ||
433 | <action name="actionProjects"> | ||
434 | <property name="enabled"> | ||
435 | <bool>false</bool> | ||
436 | </property> | ||
437 | <property name="text"> | ||
438 | <string>Projects</string> | ||
439 | </property> | ||
440 | <property name="visible"> | ||
441 | <bool>true</bool> | ||
442 | </property> | ||
443 | </action> | ||
410 | </widget> | 444 | </widget> |
411 | <tabstops> | 445 | <tabstops> |
412 | <tabstop>projectTree</tabstop> | 446 | <tabstop>projectTree</tabstop> |