mirror of
https://github.com/LorenEteval/Furious.git
synced 2026-10-03 12:28:00 +03:00
Move test actions to the home context menu
Signed-off-by: Loren Eteval <loren.eteval@proton.me>
This commit is contained in:
@@ -908,7 +908,6 @@ class ServerTableView(
|
||||
QtCore.Qt.Key.Key_M,
|
||||
),
|
||||
),
|
||||
AppQSeparator(),
|
||||
AppQAction(
|
||||
_('Clear Test Results'),
|
||||
callback=lambda: self.clearSelectedItemTestResult(),
|
||||
@@ -917,7 +916,6 @@ class ServerTableView(
|
||||
QtCore.Qt.Key.Key_R,
|
||||
),
|
||||
),
|
||||
AppQSeparator(),
|
||||
AppQAction(
|
||||
_('Stop All Tests'),
|
||||
callback=self.profileTestManager.cancelAll,
|
||||
@@ -959,6 +957,8 @@ class ServerTableView(
|
||||
),
|
||||
),
|
||||
AppQSeparator(),
|
||||
*self.testActions,
|
||||
AppQSeparator(),
|
||||
self.advancedActionRef,
|
||||
AppQSeparator(),
|
||||
AppQAction(
|
||||
@@ -989,7 +989,6 @@ class ServerTableView(
|
||||
|
||||
self._registerActionShortcuts(self.contextMenu.actions())
|
||||
self._registerActionShortcuts(self.importActions)
|
||||
self._registerActionShortcuts(self.testActions)
|
||||
|
||||
self.setContextMenuPolicy(QtCore.Qt.ContextMenuPolicy.CustomContextMenu)
|
||||
self.customContextMenuRequested.connect(self.handleCustomContextMenuRequested)
|
||||
|
||||
@@ -721,14 +721,6 @@ class HomePage(Mixins.QTranslatable, QMainWindow):
|
||||
)
|
||||
self.importButton.setEnabled(bool(self.userServersQTableWidget.importActions))
|
||||
|
||||
self.testMenu = AppQMenu(*self.userServersQTableWidget.testActions, parent=self)
|
||||
self.testButton = AppQMenuPushButton(
|
||||
_('Tests'),
|
||||
icon=bootstrapIcon('graph-up.svg'),
|
||||
popupMenu=self.testMenu,
|
||||
parent=self,
|
||||
)
|
||||
|
||||
self.setContextMenuPolicy(QtCore.Qt.ContextMenuPolicy.NoContextMenu)
|
||||
|
||||
# TODO: Custom status tip
|
||||
@@ -824,7 +816,6 @@ class HomePage(Mixins.QTranslatable, QMainWindow):
|
||||
self.actionLayout.setSpacing(8)
|
||||
self.actionLayout.addWidget(self.serverButton)
|
||||
self.actionLayout.addWidget(self.importButton)
|
||||
self.actionLayout.addWidget(self.testButton)
|
||||
self.actionLayout.addStretch(1)
|
||||
self.actionLayout.addWidget(self.subscriptionFilterComboBox)
|
||||
|
||||
|
||||
@@ -1110,37 +1110,43 @@ class SharedSettingsQtWorkflowTest(unittest.TestCase):
|
||||
for action in table.testActions
|
||||
if isinstance(action, AppQAction)
|
||||
]
|
||||
menuActions = [
|
||||
action
|
||||
for action in home.testMenu.actions()
|
||||
if not action.isSeparator()
|
||||
contextActions = table.contextMenu.actions()
|
||||
firstTestIndex = contextActions.index(testActions[0])
|
||||
testSection = contextActions[
|
||||
firstTestIndex : firstTestIndex + len(table.testActions)
|
||||
]
|
||||
|
||||
self.assertEqual(len(testActions), 5)
|
||||
self.assertEqual(menuActions, testActions)
|
||||
self.assertEqual(
|
||||
[action for action in testSection if not action.isSeparator()],
|
||||
testActions,
|
||||
)
|
||||
self.assertEqual(
|
||||
[
|
||||
None if action.isSeparator() else action.text()
|
||||
for action in home.testMenu.actions()
|
||||
for action in testSection
|
||||
],
|
||||
[
|
||||
'Test Ping Latency',
|
||||
'Test Tcping Latency',
|
||||
'Test Download Speed',
|
||||
None,
|
||||
'Clear Test Results',
|
||||
None,
|
||||
'Stop All Tests',
|
||||
],
|
||||
)
|
||||
self.assertTrue(testActions[-1].icon().isNull())
|
||||
self.assertFalse(home.testButton.icon().isNull())
|
||||
self.assertFalse(hasattr(home, 'testButton'))
|
||||
self.assertFalse(hasattr(home, 'testMenu'))
|
||||
self.assertTrue(contextActions[firstTestIndex - 1].isSeparator())
|
||||
|
||||
afterTests = firstTestIndex + len(testSection)
|
||||
self.assertTrue(contextActions[afterTests].isSeparator())
|
||||
self.assertIs(
|
||||
contextActions[afterTests + 1], table.advancedActionRef
|
||||
)
|
||||
|
||||
for testAction in testActions:
|
||||
self.assertNotIn(
|
||||
testAction,
|
||||
home.userServersQTableWidget.contextMenu.actions(),
|
||||
)
|
||||
self.assertEqual(contextActions.count(testAction), 1)
|
||||
|
||||
table.setFocus()
|
||||
processQtEvents()
|
||||
@@ -1163,8 +1169,8 @@ class SharedSettingsQtWorkflowTest(unittest.TestCase):
|
||||
manager._latencyScheduler, 'cancelAll'
|
||||
) as cancel:
|
||||
table = home.userServersQTableWidget
|
||||
menu = home.testMenu
|
||||
QTest.mouseClick(home.testButton, QtCore.Qt.LeftButton)
|
||||
menu = table.contextMenu
|
||||
menu.popup(table.viewport().mapToGlobal(QtCore.QPoint(10, 10)))
|
||||
processQtEvents()
|
||||
menu.setActiveAction(table.testActions[-1])
|
||||
QTest.keyClick(menu, QtCore.Qt.Key_Return)
|
||||
|
||||
Reference in New Issue
Block a user