Browse Source

Add buttons with the same functions as session chooser context menu

tags/v0.3.0
Nils 2 months ago
parent
commit
af2a3f6cc9
6 changed files with 113 additions and 7 deletions
  1. +1
    -0
      CHANGELOG
  2. +2
    -1
      engine/api.py
  3. +27
    -2
      qtgui/designer/mainwindow.py
  4. +52
    -2
      qtgui/designer/mainwindow.ui
  5. +3
    -2
      qtgui/designer/newsession.py
  6. +28
    -0
      qtgui/sessiontreecontroller.py

+ 1
- 0
CHANGELOG View File

@@ -1,5 +1,6 @@
2021-07-08 Version 0.3
Remove "Quick" mode. As it turns out "Full" mode is quick enough. Port convenience features to full mode.
Add button in session chooser for alternative access to context menu options


2021-01-15 Version 0.2.1

+ 2
- 1
engine/api.py View File

@@ -28,6 +28,7 @@ import datetime

#Our Modules
from engine.start import PATHS
from engine.config import METADATA #includes METADATA only. No other environmental setup is executed.

from .nsmservercontrol import NsmServerControl
from .watcher import Watcher
@@ -258,7 +259,7 @@ def getUnfilteredExecutables()->list:
#No project running
#There is no callback for _sessionsChanged because we poll that in the event loop.

def sessionNewTimestampe():
def sessionNewTimestamped():
"""convenience function. Create a new session without requiring a name and add
suggested infrastructure clients"""
nsmExecutables = getNsmExecutables() #type set, cached, very fast.

+ 27
- 2
qtgui/designer/mainwindow.py View File

@@ -14,7 +14,7 @@ from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
MainWindow.resize(953, 763)
MainWindow.resize(953, 737)
self.centralwidget = QtWidgets.QWidget(MainWindow)
self.centralwidget.setObjectName("centralwidget")
self.verticalLayout = QtWidgets.QVBoxLayout(self.centralwidget)
@@ -51,9 +51,29 @@ class Ui_MainWindow(object):
self.button_new_session = QtWidgets.QPushButton(self.widget)
self.button_new_session.setObjectName("button_new_session")
self.verticalLayout_3.addWidget(self.button_new_session)
self.button_new_quick_session = QtWidgets.QPushButton(self.widget)
self.button_new_quick_session.setObjectName("button_new_quick_session")
self.verticalLayout_3.addWidget(self.button_new_quick_session)
self.button_load_selected_session = QtWidgets.QPushButton(self.widget)
self.button_load_selected_session.setEnabled(False)
self.button_load_selected_session.setObjectName("button_load_selected_session")
self.verticalLayout_3.addWidget(self.button_load_selected_session)
self.button_rename_selected_session = QtWidgets.QPushButton(self.widget)
self.button_rename_selected_session.setEnabled(False)
self.button_rename_selected_session.setObjectName("button_rename_selected_session")
self.verticalLayout_3.addWidget(self.button_rename_selected_session)
self.button_copy_selected_session = QtWidgets.QPushButton(self.widget)
self.button_copy_selected_session.setEnabled(False)
self.button_copy_selected_session.setObjectName("button_copy_selected_session")
self.verticalLayout_3.addWidget(self.button_copy_selected_session)
self.button_delete_selected_session = QtWidgets.QPushButton(self.widget)
self.button_delete_selected_session.setEnabled(False)
self.button_delete_selected_session.setObjectName("button_delete_selected_session")
self.verticalLayout_3.addWidget(self.button_delete_selected_session)
self.button_remove_lock_selected_session = QtWidgets.QPushButton(self.widget)
self.button_remove_lock_selected_session.setEnabled(False)
self.button_remove_lock_selected_session.setObjectName("button_remove_lock_selected_session")
self.verticalLayout_3.addWidget(self.button_remove_lock_selected_session)
self.checkBoxNested = QtWidgets.QCheckBox(self.widget)
self.checkBoxNested.setChecked(True)
self.checkBoxNested.setObjectName("checkBoxNested")
@@ -256,14 +276,19 @@ class Ui_MainWindow(object):
self.retranslateUi(MainWindow)
self.mainPageSwitcher.setCurrentIndex(0)
self.tabbyCat.setCurrentIndex(0)
self.detailedStackedWidget.setCurrentIndex(1)
self.detailedStackedWidget.setCurrentIndex(0)
QtCore.QMetaObject.connectSlotsByName(MainWindow)

def retranslateUi(self, MainWindow):
_translate = QtCore.QCoreApplication.translate
MainWindow.setWindowTitle(_translate("MainWindow", "Agordejo"))
self.button_new_session.setText(_translate("MainWindow", "New"))
self.button_new_quick_session.setText(_translate("MainWindow", "Quick New"))
self.button_load_selected_session.setText(_translate("MainWindow", "Load Selected"))
self.button_rename_selected_session.setText(_translate("MainWindow", "Rename Selected"))
self.button_copy_selected_session.setText(_translate("MainWindow", "Copy Selected"))
self.button_delete_selected_session.setText(_translate("MainWindow", "Delete Selected"))
self.button_remove_lock_selected_session.setText(_translate("MainWindow", "Remove Lock"))
self.checkBoxNested.setText(_translate("MainWindow", "Tree View"))
self.session_programs.setTitle(_translate("MainWindow", "Double-click to load program"))
self.session_loaded.setTitle(_translate("MainWindow", "In current session"))

+ 52
- 2
qtgui/designer/mainwindow.ui View File

@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>953</width>
<height>763</height>
<height>737</height>
</rect>
</property>
<property name="windowTitle">
@@ -68,7 +68,7 @@
<item>
<widget class="QStackedWidget" name="detailedStackedWidget">
<property name="currentIndex">
<number>1</number>
<number>0</number>
</property>
<widget class="QWidget" name="stack_no_session">
<layout class="QHBoxLayout" name="l_2">
@@ -97,13 +97,63 @@
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="button_new_quick_session">
<property name="text">
<string>Quick New</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="button_load_selected_session">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Load Selected</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="button_rename_selected_session">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Rename Selected</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="button_copy_selected_session">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Copy Selected</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="button_delete_selected_session">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Delete Selected</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="button_remove_lock_selected_session">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Remove Lock</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBoxNested">
<property name="text">

+ 3
- 2
qtgui/designer/newsession.py View File

@@ -2,9 +2,10 @@

# Form implementation generated from reading ui file 'newsession.ui'
#
# Created by: PyQt5 UI code generator 5.14.1
# Created by: PyQt5 UI code generator 5.15.4
#
# WARNING! All changes made in this file will be lost!
# WARNING: Any manual changes made to this file will be lost when pyuic5 is
# run again. Do not edit this file unless you know what you are doing.


from PyQt5 import QtCore, QtGui, QtWidgets

+ 28
- 0
qtgui/sessiontreecontroller.py View File

@@ -62,6 +62,9 @@ class SessionItem(QtWidgets.QTreeWidgetItem):
entry["numberOfClients"] = 3
entry["hasSymlinks"] = True
entry["parents"] = []

Also:
entry["locked"] = True
"""

allItems = {} #nsmSessionName : SessionItem
@@ -165,12 +168,20 @@ class SessionTreeController(object):
api.callbacks.sessionLocked.append(self._reactCallback_sessionLocked)
api.callbacks.sessionFileChanged.append(self._reactCallback_sessionFileChanged)

self.treeWidget.currentItemChanged.connect(self._reactSelectionChanged) #click anywhere
self.treeWidget.itemDoubleClicked.connect(self._reactSignal_itemDoubleClicked)
self.treeWidget.customContextMenuRequested.connect(self.contextMenu)
self.treeWidget.model().layoutAboutToBeChanged.connect(self._reactSignal_rememberSorting)
#self.treeWidget.model().layoutChanged.connect(self._reactSignal_restoreSorting)
self.mainWindow.ui.button_new_session.clicked.connect(self._reactSignal_newSession)
self.mainWindow.ui.button_new_quick_session.clicked.connect(api.sessionNewTimestamped)

#The next ones are only available if a session item is currently selected. The connected lambda functions do not test for this, but we only enable the buttons when such an item is selected.
self.mainWindow.ui.button_load_selected_session.clicked.connect(self._reactSignal_openSelected)
self.mainWindow.ui.button_copy_selected_session.clicked.connect(lambda: self._askForCopyAndCopy(self.treeWidget.currentItem().sessionDict["nsmSessionName"]))
self.mainWindow.ui.button_rename_selected_session.clicked.connect(lambda: self._askForNameAndRenameSession(self.treeWidget.currentItem().sessionDict["nsmSessionName"]))
self.mainWindow.ui.button_delete_selected_session.clicked.connect(lambda: self.deleteSessionItem(self.treeWidget.currentItem()))
self.mainWindow.ui.button_remove_lock_selected_session.clicked.connect(lambda: api.sessionForceLiftLock(self.treeWidget.currentItem().sessionDict["nsmSessionName"]))

logger.info("Full View Session Chooser ready")

@@ -296,6 +307,23 @@ class SessionTreeController(object):

#GUI Signals

def _reactSelectionChanged(self, item, previous):
"""User clicks on an entry in the session chooser, or in the empty space.
in any case, the selection changes and we can decide if we activate/deactivate certain buttons"""

if not item or not type(item) is SessionItem or item.sessionDict["locked"] == True:
sessionSelectedState = False
else:
sessionSelectedState = True

print (self.treeWidget.currentItem())

self.mainWindow.ui.button_load_selected_session.setEnabled(sessionSelectedState)
self.mainWindow.ui.button_copy_selected_session.setEnabled(sessionSelectedState)
self.mainWindow.ui.button_rename_selected_session.setEnabled(sessionSelectedState)
self.mainWindow.ui.button_delete_selected_session.setEnabled(sessionSelectedState)
self.mainWindow.ui.button_remove_lock_selected_session.setEnabled(sessionSelectedState and item.sessionDict["locked"] == True)

def _reactSignal_itemDoubleClicked(self, item:QtWidgets.QTreeWidgetItem, column:int):
if not item.isDisabled() and type(item) is SessionItem:
api.sessionOpen(item.sessionDict["nsmSessionName"])

Loading…
Cancel
Save