Quellcode durchsuchen

Add session context menu to unused areas of the full view tab for shorter mouse distances

tags/v0.1
Nils vor 1 Jahr
Ursprung
Commit
06cb38ff36
2 geänderte Dateien mit 25 neuen und 7 gelöschten Zeilen
  1. +13
    -0
      qtgui/mainwindow.py
  2. +12
    -7
      qtgui/opensessioncontroller.py

+ 13
- 0
qtgui/mainwindow.py Datei anzeigen

@@ -133,6 +133,7 @@ class MainWindow(QtWidgets.QMainWindow):
self.ui = Ui_MainWindow()
self.ui.setupUi(self)
self.fPalBlue = setPaletteAndFont(self.qtApp)
assert self.ui.tabbyCat.currentIndex() == 0, self.ui.tabbyCat.currentIndex() # this is critical. If you left the Qt Designer with the wrong tab open this is the error that happens. It will trigger the tab changed later that will go wrong because setup is not complete yet and you'll get AttributeError

self.ui.mainPageSwitcher.setCurrentIndex(0) #1 is messageLabel 0 is the tab widget

@@ -146,6 +147,13 @@ class MainWindow(QtWidgets.QMainWindow):
self.connectMenu()
self.recentlyOpenedSessions = RecentlyOpenedSessions()


#self.ui.stack_loaded_session is only visible when there is a loaded session and the full view tab is active
#we link the session context menu to the session menu menu.
self.ui.stack_loaded_session.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
self.ui.stack_loaded_session.customContextMenuRequested.connect(self.customContextMenu)
#Api Callbacks
api.callbacks.sessionClosed.append(self.reactCallback_sessionClosed)
api.callbacks.sessionOpenReady.append(self.reactCallback_sessionOpen)
@@ -369,6 +377,11 @@ class MainWindow(QtWidgets.QMainWindow):
if widget.success:
self.updateProgramDatabase()

def customContextMenu(self, qpoint):
pos = QtGui.QCursor.pos()
pos.setY(pos.y() + 5)
self.ui.menuSession.exec_(pos)

def storeWindowSettings(self):
"""Window state is not saved in the real save file. That would lead to portability problems
between computers, like different screens and resolutions.

+ 12
- 7
qtgui/opensessioncontroller.py Datei anzeigen

@@ -129,10 +129,12 @@ class ClientTable(object):
self.sortByColumn = 0 #by name
self.sortAscending = 0 # Qt::SortOrder which is 0 for ascending and 1 for descending
self.clientsTreeWidget = self.mainWindow.ui.loadedSessionClients
self.clientsTreeWidget.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
self.clientsTreeWidget.customContextMenuRequested.connect(self.clientsContextMenu)

self.clientsTreeWidget.setIconSize(iconSize)
self.clientsTreeWidget.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
self.clientsTreeWidget.setEditTriggers(QtWidgets.QAbstractItemView.NoEditTriggers) #We only allow explicit editing.
self.clientsTreeWidget.customContextMenuRequested.connect(self.clientsContextMenu)
self.clientsTreeWidgetColumns = ("reportedName", "label", "lastStatus", "visible", "dirty", "clientId") #basically an enum
self.clientHeaderLabels = [
QtCore.QCoreApplication.translate("OpenSession", "Name"),
@@ -177,17 +179,20 @@ class ClientTable(object):
self.clientsTreeWidget.clear()

def clientsContextMenu(self, qpoint):
"""Reuses the menubar menu"""
"""Reuses the menubar menus"""
pos = QtGui.QCursor.pos()
pos.setY(pos.y() + 5)
item = self.clientsTreeWidget.itemAt(qpoint)
if not type(item) is ClientItem:
if not type(item) is ClientItem:
self.mainWindow.ui.menuSession.exec_(pos)
return
if not item is self.clientsTreeWidget.currentItem():
#Some mouse combinations can lead to getting a different context menu than the clicked item.
self.clientsTreeWidget.setCurrentItem(item)

menu = self.mainWindow.ui.menuClientNameId
pos = QtGui.QCursor.pos()
pos.setY(pos.y() + 5)
menu = self.mainWindow.ui.menuClientNameId
menu.exec_(pos)



Laden…
Abbrechen
Speichern