summaryrefslogtreecommitdiff
path: root/src/frontEnd
diff options
context:
space:
mode:
Diffstat (limited to 'src/frontEnd')
-rw-r--r--src/frontEnd/Application.py34
-rw-r--r--src/frontEnd/ProjectExplorer.py8
-rw-r--r--src/frontEnd/Workspace.py54
3 files changed, 86 insertions, 10 deletions
diff --git a/src/frontEnd/Application.py b/src/frontEnd/Application.py
index cd40214b..1b8a18c5 100644
--- a/src/frontEnd/Application.py
+++ b/src/frontEnd/Application.py
@@ -103,6 +103,13 @@ class Application(QtGui.QMainWindow):
self.closeproj.setShortcut('Ctrl+X')
self.closeproj.triggered.connect(self.close_project)
+ self.wrkspce = QtGui.QAction(
+ QtGui.QIcon('../../images/workspace.ico'),
+ '<b>Change Workspace</b>', self
+ )
+ self.wrkspce.setShortcut('Ctrl+W')
+ self.wrkspce.triggered.connect(self.change_workspace)
+
self.switchmode = None
self.validate_mode()
if self.online_flag == True:
@@ -135,6 +142,7 @@ class Application(QtGui.QMainWindow):
self.topToolbar.addAction(self.newproj)
self.topToolbar.addAction(self.openproj)
self.topToolbar.addAction(self.closeproj)
+ self.topToolbar.addAction(self.wrkspce)
self.topToolbar.addAction(self.switchmode)
self.topToolbar.addAction(self.helpfile)
@@ -332,6 +340,15 @@ class Application(QtGui.QMainWindow):
os.path.basename(current_project) + ' is Closed.'
)
+ def change_workspace(self):
+ """
+ This function call changes Workspace
+ """
+ print("Function : Change Workspace")
+ self.obj_workspace.returnWhetherClickedOrNot(self)
+ self.hide()
+ self.obj_workspace.show()
+
def validate_mode(self):
"""
This functions checks whether proper fp-lib-table* files are \
@@ -789,8 +806,21 @@ def main(args):
appView = Application()
appView.splash = splash
appView.obj_workspace.returnWhetherClickedOrNot(appView)
- appView.hide()
- appView.obj_workspace.show()
+
+ try:
+ file = open(os.path.join(
+ os.path.expanduser("~"),".esim/workspace.txt"), 'r'
+ )
+ work = int(file.read(1))
+ file.close()
+ except IOError:
+ work = 0
+ if work is not 0:
+ appView.obj_workspace.defaultWorkspace()
+ else:
+ appView.hide()
+ appView.obj_workspace.show()
+
sys.exit(app.exec_())
diff --git a/src/frontEnd/ProjectExplorer.py b/src/frontEnd/ProjectExplorer.py
index 54f0148f..4462c584 100644
--- a/src/frontEnd/ProjectExplorer.py
+++ b/src/frontEnd/ProjectExplorer.py
@@ -200,7 +200,7 @@ class ProjectExplorer(QtGui.QWidget):
del self.obj_appconfig.project_explorer[str(self.filePath)]
json.dump(self.obj_appconfig.project_explorer,
- open(self.obj_appconfig.dictPath, 'w'))
+ open(self.obj_appconfig.dictPath["path"], 'w'))
def refreshProject(self):
"""
@@ -224,7 +224,7 @@ class ProjectExplorer(QtGui.QWidget):
self.obj_appconfig.project_explorer[self.filePath] = filelistnew
json.dump(self.obj_appconfig.project_explorer,
- open(self.obj_appconfig.dictPath, 'w'))
+ open(self.obj_appconfig.dictPath["path"], 'w'))
def renameProject(self):
"""
@@ -246,7 +246,7 @@ class ProjectExplorer(QtGui.QWidget):
)
if ok and newBaseFileName:
print(newBaseFileName)
- print("==================")
+ print("=================")
newBaseFileName = str(newBaseFileName)
i = -1
@@ -314,7 +314,7 @@ class ProjectExplorer(QtGui.QWidget):
# save project_explorer dictionary on disk
json.dump(self.obj_appconfig.project_explorer, open(
- self.obj_appconfig.dictPath, 'w'))
+ self.obj_appconfig.dictPath["path"], 'w'))
# recreate project explorer tree
self.treewidget.clear()
diff --git a/src/frontEnd/Workspace.py b/src/frontEnd/Workspace.py
index 29be09fc..09092a69 100644
--- a/src/frontEnd/Workspace.py
+++ b/src/frontEnd/Workspace.py
@@ -20,6 +20,7 @@ from PyQt4 import QtCore, QtGui
from configuration.Appconfig import Appconfig
import time
import os
+import json
class Workspace(QtGui.QWidget):
@@ -62,13 +63,19 @@ class Workspace(QtGui.QWidget):
self.okbtn.clicked.connect(self.createWorkspace)
self.cancelbtn = QtGui.QPushButton('Cancel')
self.cancelbtn.clicked.connect(self.defaultWorkspace)
+
+ #Checkbox
+ self.chkbox = QtGui.QCheckBox('Set Default', self)
+ self.chkbox.setCheckState(int(self.obj_appconfig.workspace_check))
+
# Layout
self.grid.addWidget(self.note, 0, 0, 1, 15)
self.grid.addWidget(self.workspace_label, 2, 1)
self.grid.addWidget(self.workspace_loc, 2, 2, 2, 12)
self.grid.addWidget(self.browsebtn, 2, 14)
- self.grid.addWidget(self.okbtn, 4, 13)
- self.grid.addWidget(self.cancelbtn, 4, 14)
+ self.grid.addWidget(self.chkbox, 4, 2)
+ self.grid.addWidget(self.okbtn, 5, 13)
+ self.grid.addWidget(self.cancelbtn, 5, 14)
self.setGeometry(QtCore.QRect(500, 250, 400, 400))
self.setMaximumSize(4000, 200)
@@ -77,7 +84,6 @@ class Workspace(QtGui.QWidget):
self.note.setReadOnly(True)
self.setWindowIcon(QtGui.QIcon('../../images/logo.png'))
self.setLayout(self.grid)
- self.show()
def defaultWorkspace(self):
print("Default workspace selected : " +
@@ -87,6 +93,13 @@ class Workspace(QtGui.QWidget):
'Default workspace selected : ' +
self.obj_appconfig.default_workspace["workspace"])
self.close()
+
+ var_appView.obj_Mainview.obj_projectExplorer.treewidget.clear()
+ for parent, children in self.obj_appconfig.project_explorer.items():
+ var_appView.obj_Mainview.obj_projectExplorer.addTreeNode(
+ parent, children
+ )
+
var_appView.show()
time.sleep(1)
var_appView.splash.close()
@@ -102,6 +115,17 @@ class Workspace(QtGui.QWidget):
def createWorkspace(self):
print("Function : Create workspace")
+
+ self.obj_appconfig.workspace_check = self.chkbox.checkState()
+ print(self.workspace_loc.text())
+ file = open(os.path.join(
+ os.path.expanduser("~"), ".esim/workspace.txt"), 'w'
+ )
+ file.writelines(str(self.obj_appconfig.workspace_check) +
+ " " + self.workspace_loc.text()
+ )
+ file.close()
+
self.create_workspace = str(self.workspace_loc.text())
self.obj_appconfig.print_info('Workspace : ' + self.create_workspace)
# Checking if Workspace already exist or not
@@ -114,6 +138,27 @@ class Workspace(QtGui.QWidget):
= self.create_workspace
self.imp_var = 1
self.close()
+
+ self.obj_appconfig.dictPath["path"] = os.path.join(
+ self.obj_appconfig.default_workspace["workspace"],
+ ".projectExplorer.txt"
+ )
+
+ try:
+ self.obj_appconfig.project_explorer = json.load(
+ open(self.obj_appconfig.dictPath["path"])
+ )
+ except:
+ self.obj_appconfig.project_explorer = {}
+
+ Appconfig.project_explorer = self.obj_appconfig.project_explorer
+
+ var_appView.obj_Mainview.obj_projectExplorer.treewidget.clear()
+ for parent, children in self.obj_appconfig.project_explorer.items():
+ var_appView.obj_Mainview.obj_projectExplorer.addTreeNode(
+ parent, children
+ )
+
var_appView.show()
time.sleep(1)
var_appView.splash.close()
@@ -121,5 +166,6 @@ class Workspace(QtGui.QWidget):
def browseLocation(self):
print("Function : Browse Location")
self.workspace_directory = QtGui.QFileDialog.getExistingDirectory(
- self, "Browse Location", os.path.expanduser("~"))
+ self, "Browse Location", os.path.expanduser("~")
+ )
self.workspace_loc.setText(self.workspace_directory)