Add recent SECNodes to Drop down menu
Fixes: #4686 Change-Id: I864e8dd407b23c8af0f0633d3be477e222df6c40 Reviewed-on: https://forge.frm2.tum.de/review/c/secop/frappy/+/30525 Tested-by: Jenkins Automated Tests <pedersen+jenkins@frm2.tum.de> Reviewed-by: Alexander Zaft <a.zaft@fz-juelich.de>
This commit is contained in:
parent
f1ea85bfa7
commit
244d84aa56
@ -24,7 +24,8 @@
|
||||
|
||||
import frappy.client
|
||||
from frappy.gui.qt import QInputDialog, QMainWindow, QMessageBox, QObject, \
|
||||
QTreeWidgetItem, pyqtSignal, pyqtSlot, QWidget, QSettings
|
||||
QTreeWidgetItem, pyqtSignal, pyqtSlot, QWidget, QSettings, QAction, \
|
||||
QShortcut, QKeySequence
|
||||
from frappy.gui.util import Value, Colors, loadUi
|
||||
from frappy.lib import formatExtendedTraceback
|
||||
from frappy.gui.logwindow import LogWindow
|
||||
@ -159,11 +160,14 @@ class MainWindow(QMainWindow):
|
||||
Colors._setPalette(self.palette())
|
||||
|
||||
self.toolBar.hide()
|
||||
self.buildRecentNodeMenu()
|
||||
self.recentNodesChanged.connect(self.buildRecentNodeMenu)
|
||||
|
||||
# what is which?
|
||||
self.tab = TearOffTabWidget(self, self, self, self)
|
||||
self.tab.setTabsClosable(True)
|
||||
self.tab.tabCloseRequested.connect(self._handleTabClose)
|
||||
self.shortcut = QShortcut(QKeySequence("Ctrl+W"), self, self.tab.close_current)
|
||||
self.setCentralWidget(self.tab)
|
||||
|
||||
self._nodes = {}
|
||||
@ -244,6 +248,22 @@ class MainWindow(QMainWindow):
|
||||
self.recentNodesChanged.emit()
|
||||
return nodename
|
||||
|
||||
def buildRecentNodeMenu(self):
|
||||
settings = QSettings()
|
||||
recent = settings.value('recent', [])
|
||||
menu = self.menuRecent_SECNodes
|
||||
for action in list(menu.actions()):
|
||||
if action.isSeparator():
|
||||
break
|
||||
menu.removeAction(action)
|
||||
# save reference so they are not deleted
|
||||
self.recentNodeActions = []
|
||||
for host in recent:
|
||||
a = QAction(host)
|
||||
a.triggered.connect(lambda _t, h=host: self._addNode(h))
|
||||
self.recentNodeActions.append(a)
|
||||
menu.insertActions(action, self.recentNodeActions)
|
||||
|
||||
def on_actionClear_triggered(self):
|
||||
"""clears recent SECNode menu"""
|
||||
settings = QSettings()
|
||||
|
@ -35,14 +35,15 @@ try:
|
||||
QRectF, QPoint, QByteArray, QEvent, QMimeData, QSettings
|
||||
from PyQt5.QtGui import QFont, QTextCursor, QFontMetrics, QColor, QBrush, \
|
||||
QPainter, QPolygonF, QPen, QIcon, QStandardItemModel, QStandardItem, \
|
||||
QPalette, QCursor, QDrag, QMouseEvent, QPixmap
|
||||
QPalette, QCursor, QDrag, QMouseEvent, QPixmap, QKeySequence
|
||||
from PyQt5.QtWidgets import QLabel, QWidget, QDialog, QLineEdit, QCheckBox, \
|
||||
QPushButton, QSizePolicy, QMainWindow, QMessageBox, QInputDialog, \
|
||||
QTreeWidgetItem, QApplication, QGroupBox, QSpinBox, QDoubleSpinBox, \
|
||||
QComboBox, QRadioButton, QVBoxLayout, QHBoxLayout, QGridLayout, \
|
||||
QScrollArea, QFrame, QTreeWidget, QFileDialog, QTabBar, QAction, QMenu,\
|
||||
QDialogButtonBox, QTextEdit, QSpacerItem, QTreeView, QStyle, \
|
||||
QStyleOptionTab, QStylePainter, QTabWidget, QToolButton, QPlainTextEdit
|
||||
QStyleOptionTab, QStylePainter, QTabWidget, QToolButton, QShortcut, \
|
||||
QPlainTextEdit
|
||||
|
||||
from xml.sax.saxutils import escape as toHtmlEscaped
|
||||
|
||||
|
@ -469,6 +469,9 @@ class TearOffTabWidget(QTabWidget):
|
||||
widget = parent
|
||||
return widget
|
||||
|
||||
def close_current(self):
|
||||
self.removeTab(self.currentIndex())
|
||||
|
||||
|
||||
class DetachedWindow(QMainWindow):
|
||||
|
||||
|
@ -29,8 +29,19 @@
|
||||
<property name="title">
|
||||
<string>File</string>
|
||||
</property>
|
||||
<addaction name="separator"/>
|
||||
<widget class="QMenu" name="menuRecent_SECNodes">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Recent SECNodes</string>
|
||||
</property>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionClear"/>
|
||||
</widget>
|
||||
<addaction name="actionAdd_SEC_node"/>
|
||||
<addaction name="menuRecent_SECNodes"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionExit"/>
|
||||
</widget>
|
||||
<widget class="QMenu" name="menuHelp">
|
||||
@ -70,13 +81,19 @@
|
||||
<normaloff>:/icons/connect</normaloff>:/icons/connect</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Add SEC node</string>
|
||||
<string>Open SECNode</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+O</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionExit">
|
||||
<property name="text">
|
||||
<string>Exit</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+Q</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionAbout">
|
||||
<property name="text">
|
||||
@ -112,6 +129,20 @@
|
||||
<string>Detailed View</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionClear">
|
||||
<property name="icon">
|
||||
<iconset resource="../../../resources/frappy-gui.qrc">
|
||||
<normaloff>:/icons/trash</normaloff>:/icons/trash</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Clear</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actiondjhfs">
|
||||
<property name="text">
|
||||
<string>djhfs</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="../../../resources/frappy-gui.qrc"/>
|
||||
|
Loading…
x
Reference in New Issue
Block a user