Example #1
0
    def __init__(self, parent, cmd):
        QtWidgets.QWidget.__init__(self, parent, Qt.Window)
        self.setMinimumSize(400, 500)
        self.cmd = cmd

        self.model = QtGui.QStandardItemModel(self)
        self.proxy_model = QtCoreModels.QSortFilterProxyModel(self)
        self.proxy_model.setSourceModel(self.model)

        self.setWindowTitle('PyMOL Advanced Settings')
        layout = QtWidgets.QVBoxLayout(self)
        self.setLayout(layout)
        self.filter_le = QtWidgets.QLineEdit(self)
        layout.addWidget(self.filter_le)
        self.filter_le.setPlaceholderText("Filter")
        self.filter_le.textChanged.connect(self.proxy_model.setFilterRegExp)

        self.populateData()

        self.table = QtWidgets.QTableView(self)
        self.table.setModel(self.proxy_model)
        layout.addWidget(self.table)

        self.formatTable()

        self.model.itemChanged.connect(self.itemChanged)
Example #2
0
        def __init__(self):
            QtWidgets.QWidget.__init__(self, parent, Qt.Window)
            self.setMinimumSize(400, 500)
            self.setWindowTitle('Register File Extensions')

            self.model = QtGui.QStandardItemModel(self)

            layout = QtWidgets.QVBoxLayout(self)
            self.setLayout(layout)

            label = QtWidgets.QLabel(
                "Select file types to register them with PyMOL", self)
            layout.addWidget(label)

            alluserslayout = QtWidgets.QHBoxLayout()
            alluserslayout.setObjectName("alluserslayout")
            layout.addLayout(alluserslayout)

            buttonlayout = QtWidgets.QHBoxLayout()
            buttonlayout.setObjectName("buttonlayout")
            layout.addLayout(buttonlayout)

            self.table = QtWidgets.QTableView(self)
            self.table.setModel(self.model)
            layout.addWidget(self.table)

            button = QtWidgets.QPushButton("Register Recommended (*)", self)
            buttonlayout.addWidget(button)
            button.pressed.connect(self.setRecommended)

            button = QtWidgets.QPushButton("Register All", self)
            buttonlayout.addWidget(button)
            button.pressed.connect(self.setAll)

            button = QtWidgets.QPushButton("Clear", self)
            button.setToolTip("Clean up Registry")
            buttonlayout.addWidget(button)
            button.pressed.connect(self.clear)

            if isAdmin():
                r0 = QtWidgets.QRadioButton("Only for me")
                r0.setToolTip("HKEY_CURRENT_USER registry branch")
                r0.setChecked(True)
                r1 = QtWidgets.QRadioButton("For all users")
                r1.setToolTip("HKEY_LOCAL_MACHINE registry branch")
                allusersgroup = QtWidgets.QButtonGroup(self)
                allusersgroup.addButton(r0)
                allusersgroup.addButton(r1)
                allusersgroup.buttonClicked.connect(self.populateData)
                alluserslayout.addWidget(r0)
                alluserslayout.addWidget(r1)
                alluserslayout.addStretch()
                self.allusersbutton = r1
            else:
                self.allusersbutton = None

            self.finalize_timer = QtCore.QTimer()
            self.finalize_timer.setSingleShot(True)
            self.finalize_timer.setInterval(500)
            self.finalize_timer.timeout.connect(finalize)

            self.populateData()

            # keep reference to window, otherwise Qt will auto-close it
            self._self_ref = self
    def build_panel_elements(self, parent):
        '''
        Responsible for creating all panel elements in order and adding them to the layout.
        '''
        self.create_new_form = parent.load_form("create_shortcut", None)
        self.help_form = parent.load_form("help_shortcut", None)
        self.confirm_change = parent.load_form("change_confirm", None)

        self.model = QtGui.QStandardItemModel(self)
        self.proxy_model = QtCoreModels.QSortFilterProxyModel(self)
        self.proxy_model.setSourceModel(self.model)
        self.proxy_model.setFilterCaseSensitivity(Qt.CaseInsensitive)
        self.proxy_model.setFilterKeyColumn(-1)

        self.setWindowTitle('Keyboard Shortcut Menu')
        layout = QtWidgets.QVBoxLayout(self)
        self.setLayout(layout)

        # Create layout for filter bar and refresh button
        top_layout = QtWidgets.QGridLayout()
        layout.addLayout(top_layout)

        # Filter
        self.filter_le = QtWidgets.QLineEdit(self)
        top_layout.addWidget(self.filter_le)
        self.filter_le.setPlaceholderText("Filter")
        self.filter_le.textChanged.connect(self.proxy_model.setFilterRegExp)

        self.refresh_button = QtWidgets.QPushButton(self)
        self.refresh_button.resize(26, 26)
        top_layout.addWidget(self.refresh_button, 0, 1)
        # themed icons only available by default on X11
        if self.refresh_button.icon().isNull():
            self.refresh_button.setIcon(QtGui.QIcon(
                os.path.expandvars('$PYMOL_DATA/pmg_qt/icons/refresh.svg')))
        self.refresh_button.setToolTip(
            "Refresh the table to reflect any external changes")
        self.refresh_button.clicked.connect(self.refresh_populate)

        # Table
        self.table = QtWidgets.QTableView(self)
        self.table.setModel(self.proxy_model)
        layout.addWidget(self.table)
        self.intial_populate()
        self.formatTable()

        # Add layout for buttons
        button_layout = QtWidgets.QGridLayout()
        layout.addLayout(button_layout)

        # Buttons
        self.create_new_button = QtWidgets.QPushButton(self)
        button_layout.addWidget(self.create_new_button, 0, 0)
        self.create_new_button.setText("Create New")
        self.create_new_button.setToolTip(
            "Add a key binding that does not currently appear on the table")
        self.create_new_button.clicked.connect(
            lambda: self.create_new_form._dialog.show())

        self.delete_selected_button = QtWidgets.QPushButton(self)
        button_layout.addWidget(self.delete_selected_button, 0, 1)
        self.delete_selected_button.setText("Delete Selected")
        self.delete_selected_button.setToolTip(
            "Unbind selected key bindings and remove any that have been created")
        self.delete_selected_button.clicked.connect(self.delete_selected)
        self.delete_selected_button.setEnabled(False)

        self.reset_selected_button = QtWidgets.QPushButton(self)
        button_layout.addWidget(self.reset_selected_button, 0, 2)
        self.reset_selected_button.setText("Reset Selected")
        self.reset_selected_button.setToolTip(
            "Restore selected key bindings to their default values")
        self.reset_selected_button.clicked.connect(self.reset_selected)
        self.reset_selected_button.setEnabled(False)

        self.reset_all_button = QtWidgets.QPushButton(self)
        button_layout.addWidget(self.reset_all_button, 0, 3)
        self.reset_all_button.setText("Reset All")
        self.reset_all_button.setToolTip(
            "Restore all key bindings to their default values and remove any that have been created")
        self.reset_all_button.clicked.connect(self.reset_all_default)

        self.save_button = QtWidgets.QPushButton(self)
        button_layout.addWidget(self.save_button, 0, 4)
        self.save_button.setText("Save")
        self.save_button.setToolTip(
            "Save the current key bindings to be loaded automatically when opening PyMOL")
        self.save_button.clicked.connect(self.shortcut_manager.save_shortcuts)

        # Ensuring that confirmed key and binding remain in scope
        self.confirm_new_key = ''
        self.confirm_new_binding = ''

        # Connect create new and confirm menus
        self.create_new_shortcut_menu_connect()
        self.confirm_menu_connect()

        self.model.itemChanged.connect(self.itemChanged)