Skip to content
This repository was archived by the owner on Aug 21, 2023. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added resources/16x16/edit-copy.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions resources/resources.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
<file>16x16/document-save.png</file>
<file>16x16/document-save-as.png</file>
<file>16x16/edit-clear.png</file>
<file>16x16/edit-copy.png</file>
<file>16x16/edit-delete.png</file>
<file>16x16/edit-rename.png</file>
<file>16x16/list-add.png</file>
Expand Down
30 changes: 30 additions & 0 deletions resources/ui/claudia.ui
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,26 @@
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="b_project_clone">
<property name="maximumSize">
<size>
<width>23</width>
<height>16777215</height>
</size>
</property>
<property name="toolTip">
<string>Clone Project</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../resources.qrc">
<normaloff>:/16x16/edit-copy.png</normaloff>:/16x16/edit-copy.png</iconset>
</property>
</widget>
</item>
</layout>
</widget>
</item>
Expand Down Expand Up @@ -842,6 +862,7 @@
<addaction name="menu_project_load"/>
<addaction name="act_project_save"/>
<addaction name="act_project_save_as"/>
<addaction name="act_project_clone"/>
<addaction name="act_project_unload"/>
<addaction name="separator"/>
<addaction name="act_project_properties"/>
Expand Down Expand Up @@ -1431,6 +1452,15 @@
<string>Export Hardware Ports...</string>
</property>
</action>
<action name="act_project_clone">
<property name="icon">
<iconset resource="../resources.qrc">
<normaloff>:/16x16/edit-copy.png</normaloff>:/16x16/edit-copy.png</iconset>
</property>
<property name="text">
<string>Clone Project</string>
</property>
</action>
</widget>
<customwidgets>
<customwidget>
Expand Down
41 changes: 41 additions & 0 deletions src/claudia.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)
Expand All @@ -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

Expand Down Expand Up @@ -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"))
Expand Down Expand Up @@ -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()"))
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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..."))
Expand All @@ -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")))
Expand All @@ -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)

Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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":
Expand Down