summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorrahulp132020-02-16 22:56:59 +0530
committerrahulp132020-02-16 22:56:59 +0530
commit453c2dab78f81046fcbd42034a86c4e759a0ff68 (patch)
tree1e52dc08cfb0a86666372421d90502976715f35c /src
parent3e27f0dcb8555e1708497b48ad251e93fed93b6e (diff)
downloadeSim-453c2dab78f81046fcbd42034a86c4e759a0ff68.tar.gz
eSim-453c2dab78f81046fcbd42034a86c4e759a0ff68.tar.bz2
eSim-453c2dab78f81046fcbd42034a86c4e759a0ff68.zip
workspace functionality
Diffstat (limited to 'src')
-rw-r--r--src/configuration/Appconfig.py24
-rw-r--r--src/frontEnd/Application.py34
-rw-r--r--src/frontEnd/ProjectExplorer.py8
-rw-r--r--src/frontEnd/Workspace.py54
-rw-r--r--src/projManagement/newProject.py2
-rw-r--r--src/projManagement/openProject.py2
6 files changed, 106 insertions, 18 deletions
diff --git a/src/configuration/Appconfig.py b/src/configuration/Appconfig.py
index 9958f819..dfe4363f 100644
--- a/src/configuration/Appconfig.py
+++ b/src/configuration/Appconfig.py
@@ -34,7 +34,16 @@ class Appconfig(QtGui.QWidget):
"""
# Home directory
- home = os.path.join(os.path.expanduser("~"), "eSim-Workspace")
+ try:
+ file = open(os.path.join(
+ os.path.expanduser("~"), ".esim/workspace.txt"), 'r'
+ )
+ workspace_check, home = file.readline().split(' ', 1)
+ file.close()
+ except IOError:
+ home = os.path.join(os.path.expanduser("~"), "eSim-Workspace")
+ workspace_check = 0
+
default_workspace = {"workspace": home}
# Current Project detail
current_project = {"ProjectName": None}
@@ -44,12 +53,15 @@ class Appconfig(QtGui.QWidget):
workspace_text = "eSim stores your project in a folder called "
workspace_text += "eSim-Workspace. You can choose a different "
workspace_text += "workspace folder to use for this session."
+
procThread_list = []
- proc_dict = {}
- # holds the pids of all external windows corresponds to the current project
+ proc_dict = {} # hold pids of all external windows of the current project
dock_dict = {} # holds all dockwidgets
- dictPath = os.path.join(os.path.expanduser("~"), ".projectExplorer.txt")
- noteArea = {}
+ dictPath = {"path": os.path.join(
+ default_workspace["workspace"], ".projectExplorer.txt")
+ }
+
+ noteArea = {"Note" : []}
parser_esim = SafeConfigParser()
parser_esim.read(
@@ -76,7 +88,7 @@ class Appconfig(QtGui.QWidget):
print(str(e))
try:
- project_explorer = json.load(open(dictPath))
+ project_explorer = json.load(open(dictPath["path"]))
except BaseException:
project_explorer = {}
process_obj = []
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)
diff --git a/src/projManagement/newProject.py b/src/projManagement/newProject.py
index b04dbd10..8382883d 100644
--- a/src/projManagement/newProject.py
+++ b/src/projManagement/newProject.py
@@ -111,7 +111,7 @@ class NewProjectInfo(QtGui.QWidget):
json.dump(
self.obj_appconfig.project_explorer, open(
- self.obj_appconfig.dictPath, 'w'))
+ self.obj_appconfig.dictPath["path"], 'w'))
return self.projDir, newprojlist
elif self.reply == "CHECKEXIST":
diff --git a/src/projManagement/openProject.py b/src/projManagement/openProject.py
index 504bb473..507105ab 100644
--- a/src/projManagement/openProject.py
+++ b/src/projManagement/openProject.py
@@ -63,7 +63,7 @@ class OpenProjectInfo(QtGui.QWidget):
self.obj_Appconfig.project_explorer[dirs] = filelist
json.dump(
self.obj_Appconfig.project_explorer, open(
- self.obj_Appconfig.dictPath, 'w'))
+ self.obj_Appconfig.dictPath["path"], 'w'))
self.obj_Appconfig.print_info('Open Project called')
self.obj_Appconfig.print_info('Current Project is ' + self.projDir)
return dirs, filelist