From 1f933bc7fa0d6ef8391d6847ad2db2fdc6c2e842 Mon Sep 17 00:00:00 2001 From: rhetr Date: Sat, 30 Mar 2013 21:12:45 -0700 Subject: [PATCH 1/3] clone-project patch --- resources/16x16/edit-copy.png | Bin 0 -> 475 bytes resources/resources.qrc | 1 + resources/ui/claudia.ui | 88 +++++++++++++++++++++++----------- src/claudia.py | 41 ++++++++++++++++ 4 files changed, 101 insertions(+), 29 deletions(-) create mode 100644 resources/16x16/edit-copy.png diff --git a/resources/16x16/edit-copy.png b/resources/16x16/edit-copy.png new file mode 100644 index 0000000000000000000000000000000000000000..ccd4343ab65eba14e8632c02752569557c290ef8 GIT binary patch literal 475 zcmV<10VMv3P)Au3&6lO|_~BWUY&HwdPcM%+JUGgiyv^>ncQ-qh z6NaiH48sD!3V%ACmg)e|?RFs|u*q_SR;yJIgwZoZ1nqXaGMhAm++T1JY?1{*P|#Fn z@cI@y$yS{+17H)2$EVI`dVX=HB7!K2N(7xw zXFY<`KG((dLh~d4YoMx7O@~Uq3RPsaN(0X`^WkVv1E9GLfRqSAfLhOf{Q;}q;e~30 R#C`w(002ovPDHLkV1hX>yRZNN literal 0 HcmV?d00001 diff --git a/resources/resources.qrc b/resources/resources.qrc index f85d56ca..1b982a2c 100644 --- a/resources/resources.qrc +++ b/resources/resources.qrc @@ -19,6 +19,7 @@ 16x16/document-save.png 16x16/document-save-as.png 16x16/edit-clear.png + 16x16/edit-copy.png 16x16/edit-delete.png 16x16/edit-rename.png 16x16/list-add.png diff --git a/resources/ui/claudia.ui b/resources/ui/claudia.ui index 73f8529d..af6a2046 100644 --- a/resources/ui/claudia.ui +++ b/resources/ui/claudia.ui @@ -6,7 +6,7 @@ 0 0 - 877 + 982 566 @@ -167,8 +167,8 @@ Project - - + + @@ -188,7 +188,7 @@ - + @@ -208,7 +208,7 @@ - + @@ -228,7 +228,7 @@ - + @@ -248,6 +248,26 @@ + + + + + 23 + 16777215 + + + + Clone Project + + + + + + + :/16x16/edit-copy.png:/16x16/edit-copy.png + + + @@ -769,8 +789,8 @@ 0 0 - 877 - 19 + 982 + 25 @@ -825,27 +845,6 @@ - - - &Project - - - - Load Project - - - - :/16x16/document-open.png:/16x16/document-open.png - - - - - - - - - - &Application @@ -919,6 +918,28 @@ + + + &Project + + + + Load Project + + + + :/16x16/document-open.png:/16x16/document-open.png + + + + + + + + + + + @@ -1431,6 +1452,15 @@ Export Hardware Ports... + + + + :/16x16/edit-copy.png:/16x16/edit-copy.png + + + Clone Project + + diff --git a/src/claudia.py b/src/claudia.py index b21200cf..611ae804 100755 --- a/src/claudia.py +++ b/src/claudia.py @@ -20,6 +20,7 @@ # Imports (Global) from time import ctime +import shutil from PyQt4.QtCore import QPointF from PyQt4.QtGui import QAction, QApplication, QVBoxLayout, QTableWidgetItem, QTreeWidgetItem @@ -314,6 +315,7 @@ def done(self, r): class ProjectNameW(QDialog, ui_claudia_projectname.Ui_ProjectNameW): NEW = 1 SAVE_AS = 2 + CLONE = 3 def __init__(self, parent, mode, proj_folder, path="", name=""): QDialog.__init__(self, parent) @@ -328,6 +330,11 @@ def __init__(self, parent, mode, proj_folder, path="", name=""): self.le_path.setText(path) self.le_name.setText(name) self.checkText(path, name) + elif mode == self.CLONE: + self.setWindowTitle(self.tr("Clone project")) + self.le_path.setText(path) + self.le_name.setText(name) + self.checkText(path, name) self.m_proj_folder = proj_folder @@ -622,12 +629,14 @@ def __init__(self, parent=None): self.ui.menu_project_load.setIcon(getIcon("document-open")) self.ui.act_project_save.setIcon(getIcon("document-save")) self.ui.act_project_save_as.setIcon(getIcon("document-save-as")) + self.ui.act_project_clone.setIcon(getIcon("edit-copy")) self.ui.act_project_unload.setIcon(getIcon("window-close")) self.ui.act_project_properties.setIcon(getIcon("edit-rename")) self.ui.b_project_new.setIcon(getIcon("document-new")) self.ui.b_project_load.setIcon(getIcon("document-open")) self.ui.b_project_save.setIcon(getIcon("document-save")) self.ui.b_project_save_as.setIcon(getIcon("document-save-as")) + self.ui.b_project_clone.setIcon(getIcon("edit-copy")) self.ui.act_app_add_new.setIcon(getIcon("list-add")) self.ui.act_app_run_custom.setIcon(getIcon("system-run")) @@ -806,12 +815,14 @@ def __init__(self, parent=None): self.connect(self.ui.act_project_new, SIGNAL("triggered()"), SLOT("slot_project_new()")) self.connect(self.ui.act_project_save, SIGNAL("triggered()"), SLOT("slot_project_save()")) self.connect(self.ui.act_project_save_as, SIGNAL("triggered()"), SLOT("slot_project_save_as()")) + self.connect(self.ui.act_project_clone, SIGNAL("triggered()"), SLOT("slot_project_clone()")) self.connect(self.ui.act_project_unload, SIGNAL("triggered()"), SLOT("slot_project_unload()")) self.connect(self.ui.act_project_properties, SIGNAL("triggered()"), SLOT("slot_project_properties()")) self.connect(self.ui.b_project_new, SIGNAL("clicked()"), SLOT("slot_project_new()")) self.connect(self.ui.b_project_load, SIGNAL("clicked()"), SLOT("slot_project_load()")) self.connect(self.ui.b_project_save, SIGNAL("clicked()"), SLOT("slot_project_save()")) self.connect(self.ui.b_project_save_as, SIGNAL("clicked()"), SLOT("slot_project_save_as()")) + self.connect(self.ui.b_project_clone, SIGNAL("clicked()"), SLOT("slot_project_clone()")) self.connect(self.ui.menu_project_load, SIGNAL("aboutToShow()"), SLOT("slot_updateMenuProjectList()")) self.connect(self.ui.act_app_add_new, SIGNAL("triggered()"), SLOT("slot_app_add_new()")) @@ -1710,6 +1721,27 @@ def slot_project_save_as(self): else: self.slot_project_new() + @pyqtSlot() + def slot_project_clone(self): + project_graph_version, project_properties = gDBus.ladish_room.GetProjectProperties() + + if len(project_properties) > 0: + path = str(project_properties['dir']) + name = str(project_properties['name']) + dialog = ProjectNameW(self, ProjectNameW.CLONE, self.fSavedSettings["Main/DefaultProjectFolder"], path, name) + + if dialog.exec_(): + if os.listdir(dialog.ret_project_path): + shutil.move(dialog.ret_project_path, dialog.ret_project_path+"_old") + else: + os.rmdir(dialog.ret_project_path) + shutil.copytree(path, dialog.ret_project_path) + gDBus.ladish_room.SaveProject(dialog.ret_project_path, dialog.ret_project_name) + + else: + self.slot_project_new() + + @pyqtSlot() def slot_project_unload(self): gDBus.ladish_room.UnloadProject() @@ -1809,10 +1841,12 @@ def slot_checkCurrentRoom(self): has_project = bool(len(project_properties) > 0) self.ui.act_project_save.setEnabled(has_project) self.ui.act_project_save_as.setEnabled(has_project) + self.ui.act_project_clone.setEnabled(has_project) self.ui.act_project_unload.setEnabled(has_project) self.ui.act_project_properties.setEnabled(has_project) self.ui.b_project_save.setEnabled(has_project) self.ui.b_project_save_as.setEnabled(has_project) + self.ui.b_project_clone.setEnabled(has_project) self.ui.menu_Application.setEnabled(has_project) else: @@ -1944,6 +1978,7 @@ def slot_showAppListCustomMenu(self): cMenu.addMenu(self.ui.menu_project_load) act_x_save = cMenu.addAction(self.tr("Save Project")) act_x_save_as = cMenu.addAction(self.tr("Save Project As...")) + act_x_clone = cMenu.addAction(self.tr("Clone Project")) act_x_unload = cMenu.addAction(self.tr("Unload Project")) cMenu.addSeparator() act_x_properties = cMenu.addAction(self.tr("Project Properties...")) @@ -1955,6 +1990,7 @@ def slot_showAppListCustomMenu(self): act_x_new.setIcon(QIcon.fromTheme("document-new", QIcon(":/16x16/document-new.png"))) act_x_save.setIcon(QIcon.fromTheme("document-save", QIcon(":/16x16/document-save.png"))) act_x_save_as.setIcon(QIcon.fromTheme("document-save-as", QIcon(":/16x16/document-save-as.png"))) + act_x_clone.setIcon(QIcon.fromTheme("edit-copy", QIcon(":/16x16/edit-copy.png"))) act_x_unload.setIcon(QIcon.fromTheme("window-close", QIcon(":/16x16/dialog-close.png"))) act_x_properties.setIcon(QIcon.fromTheme("edit-rename", QIcon(":/16x16/edit-rename.png"))) act_x_delete_room.setIcon(QIcon.fromTheme("edit-delete", QIcon(":/16x16/edit-delete.png"))) @@ -1967,6 +2003,7 @@ def slot_showAppListCustomMenu(self): act_x_run_custom.setEnabled(False) act_x_save.setEnabled(False) act_x_save_as.setEnabled(False) + act_x_clone.setEnabled(False) act_x_unload.setEnabled(False) act_x_properties.setEnabled(False) @@ -2013,6 +2050,8 @@ def slot_showAppListCustomMenu(self): self.slot_project_save() elif act_x_sel == act_x_save_as: self.slot_project_save_as() + elif act_x_sel == act_x_clone: + self.slot_project_clone() elif act_x_sel == act_x_unload: self.slot_project_unload() elif act_x_sel == act_x_properties: @@ -2314,10 +2353,12 @@ def slot_DBusProjectPropertiesChanged(self, path, name): self.ui.act_project_save.setEnabled(has_project) self.ui.act_project_save_as.setEnabled(has_project) + self.ui.act_project_clone.setEnabled(has_project) self.ui.act_project_unload.setEnabled(has_project) self.ui.act_project_properties.setEnabled(has_project) self.ui.b_project_save.setEnabled(has_project) self.ui.b_project_save_as.setEnabled(has_project) + self.ui.b_project_clone.setEnabled(has_project) self.ui.menu_Application.setEnabled(has_project) if path == "/org/ladish/Studio": From 3bd1e3e64354ac59ea5b1f1d7dafadcc972b3898 Mon Sep 17 00:00:00 2001 From: rhetr Date: Sat, 30 Mar 2013 22:17:17 -0700 Subject: [PATCH 2/3] changed grid back to horizontal --- resources/ui/claudia.ui | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/resources/ui/claudia.ui b/resources/ui/claudia.ui index af6a2046..129cb9bf 100644 --- a/resources/ui/claudia.ui +++ b/resources/ui/claudia.ui @@ -167,8 +167,8 @@ Project - - + + @@ -188,7 +188,7 @@ - + @@ -208,7 +208,7 @@ - + @@ -228,7 +228,7 @@ - + @@ -248,7 +248,7 @@ - + From 1702d529aa5453e6d0bcbe1f8f2a974337e7b47f Mon Sep 17 00:00:00 2001 From: rhetr Date: Sat, 30 Mar 2013 22:37:44 -0700 Subject: [PATCH 3/3] moved menu_Project back --- resources/ui/claudia.ui | 50 ++++++++++++++++++++--------------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/resources/ui/claudia.ui b/resources/ui/claudia.ui index 129cb9bf..6ca55dfb 100644 --- a/resources/ui/claudia.ui +++ b/resources/ui/claudia.ui @@ -6,7 +6,7 @@ 0 0 - 982 + 877 566 @@ -789,8 +789,8 @@ 0 0 - 982 - 25 + 877 + 19 @@ -845,6 +845,28 @@ + + + &Project + + + + Load Project + + + + :/16x16/document-open.png:/16x16/document-open.png + + + + + + + + + + + &Application @@ -918,28 +940,6 @@ - - - &Project - - - - Load Project - - - - :/16x16/document-open.png:/16x16/document-open.png - - - - - - - - - - -