Commit 26ba728f authored by Dan Pascu's avatar Dan Pascu

Cleaned up some QAction related code

parent 7e121478
......@@ -709,9 +709,8 @@ class ServerToolsWindow(base_class, ui_class):
menu.clear()
for row in xrange(self.model.rowCount()):
account_info = self.model.data(self.model.index(row, 0), Qt.UserRole)
action = QAction(account_info.name, self)
action = menu.addAction(account_info.name)
action.setData(account_info.account)
menu.addAction(action)
def open_settings_page(self, account):
view = self.tab_widget.currentWidget()
......
......@@ -903,7 +903,6 @@ class VideoWidget(VideoSurface, ui_class):
self.mute_button.clicked.connect(self._SH_MuteButtonClicked)
self.hold_button.clicked.connect(self._SH_HoldButtonClicked)
self.close_button.clicked.connect(self._SH_CloseButtonClicked)
self.screenshots_folder_action.triggered.connect(self._SH_ScreenshotsFolderActionTriggered)
self.screenshot_button.customContextMenuRequested.connect(self._SH_ScreenshotButtonContextMenuRequested)
self.camera_preview.adjusted.connect(self._SH_CameraPreviewAdjusted)
self.detach_animation.finished.connect(self._SH_DetachAnimationFinished)
......@@ -999,7 +998,7 @@ class VideoWidget(VideoSurface, ui_class):
self.close_button.setIcon(close_icon)
self.screenshot_button_menu = QMenu(self)
self.screenshots_folder_action = self.screenshot_button_menu.addAction('Open screenshots folder')
self.screenshot_button_menu.addAction('Open screenshots folder', self._SH_ScreenshotsFolderActionTriggered)
@property
def interactive(self):
......@@ -1370,7 +1369,7 @@ class VideoWidget(VideoSurface, ui_class):
if not self.isFullScreen():
self.screenshot_button_menu.exec_(self.screenshot_button.mapToGlobal(pos))
def _SH_ScreenshotsFolderActionTriggered(self, pos):
def _SH_ScreenshotsFolderActionTriggered(self):
settings = BlinkSettings()
QDesktopServices.openUrl(QUrl.fromLocalFile(settings.screenshots_directory.normalized))
......
......@@ -4510,7 +4510,7 @@ class ContactURITableView(QTableView):
super(ContactURITableView, self).__init__(parent)
self.setItemDelegate(ContactURIDelegate(self))
self.context_menu = QMenu(self)
self.context_menu.addAction(QAction("Delete", self, triggered=self._AH_DeleteSelection))
self.context_menu.addAction("Delete", self._AH_DeleteSelection)
self.horizontalHeader().setSectionResizeMode(self.horizontalHeader().ResizeToContents)
def selectionChanged(self, selected, deselected):
......
......@@ -97,8 +97,8 @@ class MainWindow(base_class, ui_class):
self.system_tray_icon = QSystemTrayIcon(QIcon(Resources.get('icons/blink.png')), self)
self.system_tray_icon.activated.connect(self._SH_SystemTrayIconActivated)
menu = QMenu(self)
menu.addAction(QAction("Show", self, triggered=self._AH_SystemTrayShowWindow))
menu.addAction(QAction(QIcon(Resources.get('icons/application-exit.png')), "Quit", self, triggered=self._AH_QuitActionTriggered))
menu.addAction("Show", self._AH_SystemTrayShowWindow)
menu.addAction(QIcon(Resources.get('icons/application-exit.png')), "Quit", self._AH_QuitActionTriggered)
self.system_tray_icon.setContextMenu(menu)
self.system_tray_icon.show()
else:
......@@ -220,10 +220,8 @@ class MainWindow(base_class, ui_class):
self.alert_devices_group = QActionGroup(self)
self.video_devices_group = QActionGroup(self)
self.request_screen_action = QAction('Request screen', self, triggered=self._AH_RequestScreenActionTriggered)
self.share_my_screen_action = QAction('Share my screen', self, triggered=self._AH_ShareMyScreenActionTriggered)
self.screen_sharing_button.addAction(self.request_screen_action)
self.screen_sharing_button.addAction(self.share_my_screen_action)
self.screen_sharing_button.addAction(QAction('Request screen', self.screen_sharing_button, triggered=self._AH_RequestScreenActionTriggered))
self.screen_sharing_button.addAction(QAction('Share my screen', self.screen_sharing_button, triggered=self._AH_ShareMyScreenActionTriggered))
# adjust search box height depending on theme as the value set in designer isn't suited for all themes
search_box = self.search_box
......@@ -449,12 +447,12 @@ class MainWindow(base_class, ui_class):
contact, contact_uri = URIUtils.find_contact(action.entry.uri)
session_manager.create_session(contact, contact_uri, [StreamDescription('audio')], account=account) # TODO: memorize media type and use it? -Saul (not sure about history in/out -Dan)
def _AH_SystemTrayShowWindow(self, checked):
def _AH_SystemTrayShowWindow(self):
self.show()
self.raise_()
self.activateWindow()
def _AH_QuitActionTriggered(self, checked):
def _AH_QuitActionTriggered(self):
if self.system_tray_icon is not None:
self.system_tray_icon.hide()
QApplication.instance().quit()
......
......@@ -550,7 +550,6 @@ class ScreensharingWindow(base_class, ui_class):
self.fullscreen_action.triggered.connect(self._SH_FullscreenActionTriggered)
self.minimize_action.triggered.connect(self._SH_MinimizeActionTriggered)
self.close_action.triggered.connect(self._SH_CloseActionTriggered)
self.screenshots_folder_action.triggered.connect(self._SH_ScreenshotsFolderActionTriggered)
self.screenshot_button.customContextMenuRequested.connect(self._SH_ScreenshotButtonContextMenuRequested)
self.color_depth_button.currentIndexChanged[int].connect(self._SH_ColorDepthButtonCurrentIndexChanged)
self.fullscreen_toolbox.color_depth_button.currentIndexChanged[int].connect(self._SH_ColorDepthButtonCurrentIndexChanged)
......@@ -594,7 +593,7 @@ class ScreensharingWindow(base_class, ui_class):
self.color_depth_button.addItem('LowColor (8 bits)', LowColor)
self.screenshot_button_menu = QMenu(self)
self.screenshots_folder_action = self.screenshot_button_menu.addAction('Open screenshots folder')
self.screenshot_button_menu.addAction('Open screenshots folder', self._SH_ScreenshotsFolderActionTriggered)
def closeEvent(self, event):
super(ScreensharingWindow, self).closeEvent(event)
......@@ -656,7 +655,7 @@ class ScreensharingWindow(base_class, ui_class):
else:
self.screenshot_button_menu.exec_(self.screenshot_button.mapToGlobal(pos))
def _SH_ScreenshotsFolderActionTriggered(self, pos):
def _SH_ScreenshotsFolderActionTriggered(self):
settings = BlinkSettings()
QDesktopServices.openUrl(QUrl.fromLocalFile(settings.screenshots_directory.normalized))
......
......@@ -701,10 +701,9 @@ class AccountState(StateButton):
state = getattr(self, state_name)
except AttributeError:
continue
action = QAction(QIcon(state.icon), note, menu)
action = menu.addAction(QIcon(state.icon), note)
action.state = state
action.note = note
menu.addAction(action)
history = property(_get_history, _set_history)
del _get_history, _set_history
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment