コード例 #1
0
    def _on_open_settings(self):
        """Open settings dialog.

        Prior to opening dialog, the global hot key is unbinded and then binded 
        in case user changes it. The model view is updated to reflect changes 
        in lines to display and if word wrap is enabled.
        """
        # Windows allow's the user to open extra settings dialogs from system
        # tray menu even though dialog is modal
        try:
            self.key_binder.unbind(settings.get_global_hot_key())
        except AttributeError:
            return None

        # PreviewDialog(self) so it opens at main window
        settings_dialog = dialogs.SettingsDialog(self)
        settings_dialog.exec_()

        self.setCursor(QtCore.Qt.BusyCursor)

        # Attempt to set new hot key
        self._set_hot_key()

        # Update scroll bars and refresh view
        set_word_wrap = settings.get_word_wrap()
        self.main_widget.view_main.set_horiz_scrollbar(set_word_wrap)
        self.main_widget.model_main.select()

        self.unsetCursor()
コード例 #2
0
ファイル: dialogs.py プロジェクト: scottwernervt/clipmanager
    def __init__(self, parent=None):
        super(HotKeyEdit, self).__init__(parent)
        self.parent = parent

        self.setValidator(ConvertUpperCase(self))
        self.setText(settings.get_global_hot_key())
        # self.setSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed)
        self.setToolTip('Press one key at a time.\nPress ESCAPE to clear.')
        self.setFixedWidth(130)
コード例 #3
0
ファイル: dialogs.py プロジェクト: scottwernervt/clipmanager
    def insert_win_key(self):
        """Insert <SUPER> into key combo box for Windows machines.

        Windows captures <SUPER> key being pressed so we cannot capture it.
        """
        if self.super_check.isChecked():
            self.key_combo_edit.clear()
            self.key_combo_edit.setText('<Super>')
        else:
            self.key_combo_edit.setText(settings.get_global_hot_key())
コード例 #4
0
    def _set_hot_key(self):
        """Helper function to bind global hot key to OS specific binder class.

        If binding fails then display a message in system tray notification 
        tray.
        """
        hotkey = settings.get_global_hot_key()  # <CTRL><ALT>H
        if not self.key_binder.bind(hotkey, self._on_toggle_window):
            title = 'Global Hot Key'
            message = 'Failed to bind global hot key %s.' % hotkey
            self.tray_icon.showMessage(title, message, 
                                       icon=QtGui.QSystemTrayIcon.Warning,
                                       msecs=10000)

        del hotkey
コード例 #5
0
    def clean_up(self):
        """Perform actions before exiting the application.

        Following actions are performed before exit: unbind global hot key, 
        save window position and size, submit all changes to model, and close 
        database connection.
        """
        logging.debug('Unbinding global hot key.')
        self.key_binder.unbind(settings.get_global_hot_key())

        logging.debug('Saving window size and position.')
        settings.set_window_pos(self.pos())
        settings.set_window_size(self.size())
        settings.sync()

        logging.debug('Submitting changes to model.')
        self.main_widget.model_main.submitAll()
        
        logging.debug('Closing model.')
        self.db.close()