Example #1
0
    def device_discovery(self, devs):
        group = QActionGroup(self._menu_devices, exclusive=True)

        for d in devs:
            node = QAction(d["name"], self._menu_devices, checkable=True)
            node.toggled.connect(self._inputdevice_selected)
            group.addAction(node)
            self._menu_devices.addAction(node)
            if (d["name"] == GuiConfig().get("input_device")):
                self._active_device = d["name"]
        if (len(self._active_device) == 0):
            self._active_device = self._menu_devices.actions()[0].text()

        device_config_mapping = GuiConfig().get("device_config_mapping")
        if (device_config_mapping):
            if (self._active_device in device_config_mapping.keys()):
                self._current_input_config = device_config_mapping[str(
                    self._active_device)]
            else:
                self._current_input_config = self._menu_mappings.actions(
                )[0].text()
        else:
            self._current_input_config = self._menu_mappings.actions()[0].text(
            )

        # Now we know what device to use and what mapping, trigger the events
        # to change the menus and start the input
        for c in self._menu_mappings.actions():
            c.setEnabled(True)
            if (c.text() == self._current_input_config):
                c.setChecked(True)

        for c in self._menu_devices.actions():
            if (c.text() == self._active_device):
                c.setChecked(True)
Example #2
0
def createActionGroup(parent):
    group = QActionGroup(parent)
    for enc, region in _ENCODINGNAMES:
        a = group.addAction('%s (%s)' % (region, enc))
        a.setCheckable(True)
        a.setData(enc)
    return group
Example #3
0
class FloatingToolBar(QToolBar):
    """
	A floating QToolBar with no border and is offset under its parent
	"""

    def __init__(self, name, parent):
        """
		parent: The parent of this toolbar.  Should be another toolbar
		"""
        QToolBar.__init__(self, name, parent)
        self.setMovable(False)
        self.setWindowFlags(Qt.Tool | Qt.FramelessWindowHint | Qt.X11BypassWindowManagerHint)
        self.setAllowedAreas(Qt.NoToolBarArea)
        self.actiongroup = QActionGroup(self)

    def addToActionGroup(self, action):
        self.actiongroup.addAction(action)

    def showToolbar(self, parentaction, defaultaction, toggled):
        if toggled:
            self.show()
            if defaultaction:
                defaultaction.toggle()
            widget = self.parent().widgetForAction(parentaction)
            x = self.parent().mapToGlobal(widget.pos()).x()
            y = self.parent().mapToGlobal(widget.pos()).y()
            newpoint = QPoint(x, y + self.parent().rect().height())
            # 			if self.orientation() == Qt.Vertical:
            # 				newpoint = QPoint(x, y + self.parent().rect().width())
            self.move(newpoint)
        else:
            action = self.actiongroup.checkedAction()
            if action:
                action.toggle()
            self.hide()
Example #4
0
    def change_layer_image_kind_menu(self, menu, lbox, selected_uuids, *args):
        current_kind = self.doc.prez_for_uuid(selected_uuids[0]).kind
        kind_menu = QMenu("Change Image Kind", menu)
        action_group = QActionGroup(menu, exclusive=True)
        actions = {}
        action_kinds = {}

        def _change_layers_image_kind(action, action_kinds=action_kinds):
            if not action.isChecked():
                # can't uncheck an image kind
                LOG.debug("Selected KIND action is not checked")
                return
            kind = action_kinds[action]
            return self.doc.change_layers_image_kind(selected_uuids, kind)

        for kind in [KIND.IMAGE, KIND.CONTOUR]:
            action = action_group.addAction(
                QAction(kind.name, menu, checkable=True))
            action_kinds[action] = kind
            action.setChecked(kind == current_kind)
            actions[action] = _change_layers_image_kind
            kind_menu.addAction(action)

        menu.addMenu(kind_menu)
        return actions
def setup_menu():
    u"""
    Add a submenu to a view menu.

    Add a submenu that lists the available extra classes to the view
    menu, creating that menu when neccessary
    """
    if extra_classes_list:
        try:
            mw.addon_view_menu
        except AttributeError:
            mw.addon_view_menu = QMenu(_(u"&View"), mw)
            mw.form.menubar.insertMenu(
                mw.form.menuTools.menuAction(), mw.addon_view_menu)
        mw.extra_class_submenu = QMenu(u"Mode (e&xtra class)", mw)
        mw.addon_view_menu.addMenu(mw.extra_class_submenu)
        action_group = QActionGroup(mw, exclusive=True)
        no_class_action = action_group.addAction(
            QAction('(none/standard)', mw, checkable=True))
        no_class_action.setChecked(True)
        mw.extra_class_submenu.addAction(no_class_action)
        mw.connect(no_class_action, SIGNAL("triggered()"),
                   lambda: set_extra_class(None))
        for ecd in extra_classes_list:
            nn_class_action = action_group.addAction(
                QAction(ecd['display'], mw, checkable=True))
            mw.extra_class_submenu.addAction(nn_class_action)
            mw.connect(nn_class_action, SIGNAL("triggered()"),
                       lambda ec=ecd['class']: set_extra_class(ec))
Example #6
0
    def __init__(self, parent):
        QtGui.QMainWindow.__init__(self, parent)

        self.workSpace = Workspace()

        #  get the status bar to show messages to the user
        self.statusbar = self.statusBar()
        self.statusbar.setSizeGripEnabled(False)

        # action groups of common actions for sound lab window
        self.play_record_actions        = QActionGroup(self)
        self.widgets_visibility_actions = QActionGroup(self)
        self.zoom_actions               = QActionGroup(self)
        self.tools_actions              = QActionGroup(self)
        self.save_images_actions        = QActionGroup(self)

        # play volume bar (disabled for now)
        self.volume_bar = QSlider(QtCore.Qt.Horizontal)
        self.volume_bar.setToolTip(self.tr(u"Volume bar for Play."))
        self.volume_bar.setMaximumWidth(100)
        self.volume_bar.setRange(0, 300)
        self.volume_bar.setValue(100)
        self.volume_bar.valueChanged.connect(self.change_volume)

        # text edit for the signal name on the toolbar
        self.signalNameLineEdit = QtGui.QLineEdit(self)
        self.signalNameLineEdit.setToolTip(self.tr(u"Signal name."))
        self.signalNameLineEdit.setSizePolicy(QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Minimum))

        self.signalPropertiesTextLabel = QtGui.QLabel(self)
        self.signalPropertiesTextLabel.setToolTip(self.tr(u"Signal properties."))
        self.signalPropertiesTextLabel.setAlignment(QtCore.Qt.AlignRight)
        self.signalPropertiesTextLabel.setSizePolicy(QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding,
                                                                       QtGui.QSizePolicy.Minimum))
Example #7
0
    def init_actions(self):
        """
        here we do extra setup for the window (mainly connect signals and slots)
        """

        # group action2D and action3D to make them mutually exclusive
        view_group = QActionGroup(self)
        view_group.addAction(self.action2D)
        view_group.addAction(self.action3D)
        # set 2D view by default
        self.action2D.setChecked(True)
        # connect view (re)set actions to functions
        self.action2D.toggled.connect(self.canvas.reset_view_2d)
        self.action3D.toggled.connect(self.canvas.reset_view_3d)
        self.actionReset.triggered.connect(self.canvas.reset_view)

        self.tool2d_explore_radio.toggled.connect(self.canvas.set_mode_explore)

        for radio2d in self.tab_2d.findChildren(QtGui.QRadioButton,
                                                QRegExp("tool2d.*")):
            self.tool2d_button_group.addButton(radio2d)
            radio2d.toggled.connect(self.tool2d_radio_toggled)

        # TODO: do the same for 3dtool buttons

        self.tool2d_operation_button.clicked.connect(self.perform_operation)

        self.tool3d_insert_shape_button.clicked.connect(
            self.open_insert_3d_shape_dialog)
Example #8
0
    def _set_up_tools_connections(self):
        """ Set up all connections for view menu. """


        self.connect(self.actionUnselect_All, SIGNAL("triggered()"),
                     self.canvas.clear_all_selected_cells)

        self.connect(self.actionCreate_Pattern_Repeat,
                     SIGNAL("triggered()"),
                     self.canvas.add_pattern_repeat)

        self.connect(self.actionCreate_Row_Repeat,
                     SIGNAL("triggered()"),
                     self.canvas.add_row_repeat)

        self.connect(self.actionApply_Color_to_Selection,
                     SIGNAL("triggered()"),
                     self.canvas.apply_color_to_selection)

        self.connect(self.actionAdd_Text, SIGNAL("triggered()"),
                     self.canvas.add_text_item)

        modeGroup = QActionGroup(self)
        modeGroup.addAction(self.actionHide_Selected_Cells)
        modeGroup.addAction(self.actionShow_Selected_Cells)
        modeGroup.addAction(self.actionCreate_Chart)

        self.connect(self.actionHide_Selected_Cells, SIGNAL("triggered()"),
                     partial(self.canvas.select_mode, canvas.HIDE_MODE))

        self.connect(self.actionShow_Selected_Cells, SIGNAL("triggered()"),
                     partial(self.canvas.select_mode, canvas.UNHIDE_MODE))

        self.connect(self.actionCreate_Chart, SIGNAL("triggered()"),
                     partial(self.canvas.select_mode, canvas.SELECTION_MODE))
Example #9
0
    def setupUi(self):
        super(MainWindow, self).setupUi(self)

        self.search_box.shortcut = QShortcut(self.search_box)
        self.search_box.shortcut.setKey('Ctrl+F')

        self.output_devices_group = QActionGroup(self)
        self.input_devices_group = QActionGroup(self)
        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)

        # adjust search box height depending on theme as the value set in designer isn't suited for all themes
        search_box = self.search_box
        option = QStyleOptionFrameV2()
        search_box.initStyleOption(option)
        frame_width = search_box.style().pixelMetric(QStyle.PM_DefaultFrameWidth, option, search_box)
        if frame_width < 4:
            search_box.setMinimumHeight(20 + 2*frame_width)

        # adjust the combo boxes for themes with too much padding (like the default theme on Ubuntu 10.04)
        option = QStyleOptionComboBox()
        self.identity.initStyleOption(option)
        wide_padding = self.identity.style().subControlRect(QStyle.CC_ComboBox, option, QStyle.SC_ComboBoxEditField, self.identity).height() < 10
        self.identity.setStyleSheet("""QComboBox { padding: 0px 4px 0px 4px; }""" if wide_padding else "")
Example #10
0
class FloatingToolBar(QToolBar):
    """
	A floating QToolBar with no border and is offset under its parent
	"""
    def __init__(self, name, parent):
        """
		parent: The parent of this toolbar.  Should be another toolbar
		"""
        QToolBar.__init__(self, name, parent)
        self.setMovable(False)
        self.setWindowFlags(Qt.Tool | Qt.FramelessWindowHint
                            | Qt.X11BypassWindowManagerHint)
        self.setAllowedAreas(Qt.NoToolBarArea)
        self.actiongroup = QActionGroup(self)

    def addToActionGroup(self, action):
        self.actiongroup.addAction(action)

    def showToolbar(self, parentaction, defaultaction, toggled):
        if toggled:
            self.show()
            if defaultaction:
                defaultaction.toggle()
            widget = self.parent().widgetForAction(parentaction)
            x = self.parent().mapToGlobal(widget.pos()).x()
            y = self.parent().mapToGlobal(widget.pos()).y()
            newpoint = QPoint(x, y + self.parent().rect().height())
            # 			if self.orientation() == Qt.Vertical:
            # 				newpoint = QPoint(x, y + self.parent().rect().width())
            self.move(newpoint)
        else:
            action = self.actiongroup.checkedAction()
            if action:
                action.toggle()
            self.hide()
    def device_discovery(self, devs):
        group = QActionGroup(self._menu_devices, exclusive=True)

        for d in devs:
            node = QAction(d["name"], self._menu_devices, checkable=True)
            node.toggled.connect(self._inputdevice_selected)
            group.addAction(node)
            self._menu_devices.addAction(node)
            if (d["name"] == GuiConfig().get("input_device")):
                self._active_device = d["name"]
        if (len(self._active_device) == 0):
            self._active_device = self._menu_devices.actions()[0].text()

        device_config_mapping = GuiConfig().get("device_config_mapping")
        if (device_config_mapping):
            if (self._active_device in device_config_mapping.keys()):
                self._current_input_config = device_config_mapping[
                    str(self._active_device)]
            else:
                self._current_input_config = self._menu_mappings.actions()[0].text()
        else:
            self._current_input_config = self._menu_mappings.actions()[0].text()

        # Now we know what device to use and what mapping, trigger the events
        # to change the menus and start the input
        for c in self._menu_mappings.actions():
            c.setEnabled(True)
            if (c.text() == self._current_input_config):
                c.setChecked(True)

        for c in self._menu_devices.actions():
            if (c.text() == self._active_device):
                c.setChecked(True)
Example #12
0
 def setupMenuBar(self):
    self.fileMenu = self.menuBar().addMenu("&File")
    self.dateFormatMenu = self.fileMenu.addMenu("&Date format")
    self.dateFormatGroup = QActionGroup(self)
    for f in self.dateFormats:
       action = QAction(f, self, checkable=True,
               triggered=self.changeDateFormat)
       self.dateFormatGroup.addAction(action)
       self.dateFormatMenu.addAction(action)
       if f == self.currentDateFormat:
          action.setChecked(True)
            
    self.fileMenu.addAction(self.printAction)
    self.fileMenu.addAction(self.exitAction)
    self.cellMenu = self.menuBar().addMenu("&Cell")
    self.cellMenu.addAction(self.cell_addAction)
    self.cellMenu.addAction(self.cell_subAction)
    self.cellMenu.addAction(self.cell_mulAction)
    self.cellMenu.addAction(self.cell_divAction)
    self.cellMenu.addAction(self.cell_sumAction)
    self.cellMenu.addSeparator()
    self.cellMenu.addAction(self.colorAction)
    self.cellMenu.addAction(self.fontAction)
    self.menuBar().addSeparator()
    self.aboutMenu = self.menuBar().addMenu("&Help")
    self.aboutMenu.addAction(self.aboutSpreadSheet)
Example #13
0
    def __init__(self, iface):
        self.iface = iface
        self.actions = []
        self.panels= []
        self.navtoolbar = self.iface.mapNavToolToolBar()
        self.mainwindow = self.iface.mainWindow()
        self.iface.projectRead.connect(self.projectOpened)
        self.iface.initializationCompleted.connect(self.setupUI)
        self.actionGroup = QActionGroup(self.mainwindow)
        self.actionGroup.setExclusive(True)
        self.menuGroup = QActionGroup(self.mainwindow)
        self.menuGroup.setExclusive(True)
                
        self.movetool = MoveTool(self.iface.mapCanvas(), [])
        self.infotool = InfoTool(self.iface.mapCanvas())
        self.infotool.infoResults.connect(self.showInfoResults)
        
        self.report = PopDownReport(self.iface.messageBar())
        
        self.dialogprovider = DialogProvider(iface.mapCanvas(), iface)
        self.dialogprovider.accepted.connect(self.clearToolRubberBand)
        self.dialogprovider.rejected.connect(self.clearToolRubberBand)
        
        self.edittool = EditTool(self.iface.mapCanvas(),[])
        self.edittool.finished.connect(self.openForm)
        self.edittool.featuresfound.connect(self.showFeatureSelection)

        self.infodock = InfoDock(self.iface.mainWindow())
        self.iface.addDockWidget(Qt.RightDockWidgetArea, self.infodock)
        self.infodock.hide()

        self.band = QgsRubberBand(self.iface.mapCanvas())
        self.band.setIconSize(20)
        self.band.setWidth(10)
        self.band.setColor(QColor(186, 93, 212, 76))
Example #14
0
	def __init__(self, name, parent):
		"""
		parent: The parent of this toolbar.  Should be another toolbar
		""" 
		QToolBar.__init__(self,name, parent)
		self.setMovable(False)
		self.setWindowFlags(Qt.Tool | Qt.FramelessWindowHint | Qt.X11BypassWindowManagerHint)
		self.setAllowedAreas(Qt.NoToolBarArea)
		self.actiongroup = QActionGroup(self)
Example #15
0
 def create_menu(self, menu_name, menu_actions):
     """ Creates a menu.  Groups them so you can only select one at a time. """
     menu_action_group = QActionGroup(self)
     menu_action_group.setExclusive(True)
     menubar = self.menuBar()
     menu = menubar.addMenu(menu_name)
     for action in menu_actions:
         menu_action_group.addAction(action)
         menu.addAction(action)
Example #16
0
class TrayContextMenu(QtGui.QMenu):
    instances = set()

    def __init__(self, trayIcon):
        """ trayIcon = the object with the methods to call
        """
        QtGui.QMenu.__init__(self)
        TrayContextMenu.instances.add(self)
        self.trayIcon = trayIcon
        self._buildMenu()

    def _buildMenu(self):
        self.framelessCheck = QtGui.QAction("Frameless Window",
                                            self,
                                            checkable=True)
        self.connect(self.framelessCheck, SIGNAL("triggered()"),
                     self.trayIcon.changeFrameless)
        self.addAction(self.framelessCheck)
        self.addSeparator()
        self.requestCheck = QtGui.QAction("Show status request notifications",
                                          self,
                                          checkable=True)
        self.requestCheck.setChecked(True)
        self.addAction(self.requestCheck)
        self.connect(self.requestCheck, SIGNAL("triggered()"),
                     self.trayIcon.switchRequest)
        self.alarmCheck = QtGui.QAction("Show alarm notifications",
                                        self,
                                        checkable=True)
        self.alarmCheck.setChecked(True)
        self.connect(self.alarmCheck, SIGNAL("triggered()"),
                     self.trayIcon.switchAlarm)
        self.addAction(self.alarmCheck)
        distanceMenu = self.addMenu("Alarm Distance")
        self.distanceGroup = QActionGroup(self)
        for i in range(0, 6):
            action = QAction("{0} Jumps".format(i), None, checkable=True)
            if i == 0:
                action.setChecked(True)
            action.alarmDistance = i
            self.connect(action, SIGNAL("triggered()"),
                         self.changeAlarmDistance)
            self.distanceGroup.addAction(action)
            distanceMenu.addAction(action)
        self.addMenu(distanceMenu)
        self.addSeparator()
        self.quitAction = QAction("Quit", self)
        self.connect(self.quitAction, SIGNAL("triggered()"),
                     self.trayIcon.quit)
        self.addAction(self.quitAction)

    def changeAlarmDistance(self):
        for action in self.distanceGroup.actions():
            if action.isChecked():
                self.trayIcon.alarmDistance = action.alarmDistance
                self.trayIcon.changeAlarmDistance()
    def __init__(self, snapLayer, parent=None):
        super(LayerSnappingAction, self).__init__(snapLayer, parent)

        self._toleranceAction = None  # LayerSnappingToleranceAction()
        self._avoidAction = None  # LayerSnappingAvoidIntersectionsAction()

        self._vertexAction = LayerSnappingTypeAction(snapLayer, Snapping.Vertex, self)
        self._segmentAction = LayerSnappingTypeAction(snapLayer, Snapping.Segment, self)
        self._vertexSegmentAction = LayerSnappingTypeAction(snapLayer, Snapping.VertexAndSegment, self)

        self._snappingTypeActionGroup = QActionGroup(self)
        self._snappingTypeActionGroup.addAction(self._vertexAction)
        self._snappingTypeActionGroup.addAction(self._segmentAction)
        self._snappingTypeActionGroup.addAction(self._vertexSegmentAction)

        self._toleranceAction = LayerSnappingToleranceAction(snapLayer, parent)

        self._pixelUnitsAction = LayerSnappingUnitAction(snapLayer, Snapping.Pixels, self)
        self._layerUnitsAction = LayerSnappingUnitAction(snapLayer, Snapping.LayerUnits, self)
        self._projectUnitsAction = LayerSnappingUnitAction(snapLayer, Snapping.ProjectUnits, self)

        self._unitTypeActionGroup = QActionGroup(self)
        self._unitTypeActionGroup.addAction(self._pixelUnitsAction)
        self._unitTypeActionGroup.addAction(self._layerUnitsAction)
        self._unitTypeActionGroup.addAction(self._projectUnitsAction)

        menu = ControlMenu(parent)
        menu.addActions(self._snappingTypeActionGroup.actions())
        menu.addSeparator()
        menu.addAction(self._toleranceAction)
        menu.addActions(self._unitTypeActionGroup.actions())
        if (isinstance(snapLayer, QgisInterface)
                or (isinstance(snapLayer, QgsVectorLayer) and snapLayer.geometryType() == QGis.Polygon)):
            self._avoidAction = LayerSnappingAvoidIntersectionsAction(snapLayer, self)
            menu.addSeparator()
            menu.addAction(self._avoidAction)
        self.setMenu(menu)

        self._refreshAction()

        # Make sure we catch changes in the main snapping dialog
        QgsProject.instance().snapSettingsChanged.connect(self._refreshAction)
        # If using current layer, make sure we update when it changes
        if self._iface:
            self._iface.legendInterface().currentLayerChanged.connect(self._refreshAction)
        # If any of the settings change then signal, but don't tell project as actions already have
        self.snappingEnabledChanged.connect(self.snapSettingsChanged)
        self._vertexAction.snappingTypeChanged.connect(self.snapSettingsChanged)
        self._segmentAction.snappingTypeChanged.connect(self.snapSettingsChanged)
        self._vertexSegmentAction.snappingTypeChanged.connect(self.snapSettingsChanged)
        self._toleranceAction.snappingToleranceChanged.connect(self.snapSettingsChanged)
        self._pixelUnitsAction.snappingUnitChanged.connect(self.snapSettingsChanged)
        self._layerUnitsAction.snappingUnitChanged.connect(self.snapSettingsChanged)
        self._projectUnitsAction.snappingUnitChanged.connect(self.snapSettingsChanged)
        if self._avoidAction:
            self._avoidAction.avoidIntersectionsChanged.connect(self.snapSettingsChanged)
Example #18
0
 def __init__(self, parent=None):
     super(FilterSetWidget, self).__init__(parent)
     self.setupUi(self)
     self._filterSetActionGroup = QActionGroup(self)
     self._filterSetActionGroup.addAction(self.saveFilterSetAction)
     self._filterSetActionGroup.addAction(self.reloadFilterSetAction)
     self._filterSetActionGroup.addAction(self.deleteFilterSetAction)
     self._filterSetActionGroup.addAction(self.exportFilterSetAction)
     self._filterSetMenu = QMenu(self)
     self._filterSetMenu.addActions(self._filterSetActionGroup.actions())
     self.filterSetTool.setMenu(self._filterSetMenu)
     self.filterSetTool.setDefaultAction(self.saveFilterSetAction)
Example #19
0
 def add_stations(self):
     self.stations = {}
     group = QActionGroup(self)
     group.setExclusive(True)
     for name in sorted(self.parent.stations.map.keys()):
         url = self.parent.stations.map[name]
         self.stations[name] = QAction(str(name), self)
         self.stations[name].setCheckable(True)
         self.stations[name].setActionGroup(group)
         self.stations[name].triggered.connect(
                 lambda _=0, st=(name, url):
                 self.parent.station_changed.emit(st))
         self.stations_menu.addAction(self.stations[name])
Example #20
0
 def createMenuBar(self):
     # set menu bar model
     self.mActionsModel = pActionsModel( self )
     self.menuBar().setModel( self.mActionsModel )
     
     # create menus and sub menus
     self.mActionsModel.addMenu( "mFile", self.tr( "&File" ) )
     self.mActionsModel.addMenu( "mEdit", self.tr( "&Edit" ) )
     self.mActionsModel.addMenu( "mView", self.tr( "&View" ) )
     self.mActionsModel.addMenu( "mView/mStyle", self.tr( "&Style" ) )
     self.mActionsModel.addMenu( "mView/mMode", self.tr( "&Mode" ) )
     self.mActionsModel.addMenu( "mView/mDockToolBarManager", self.tr( "&Dock ToolBar Manager" ) )
     self.mActionsModel.addMenu( "mView/mDockWidgets", self.tr( "Dock &Widgets" ) )
     
     # create actions
     aQuit = self.mActionsModel.addAction( "mFile/aQuit", self.tr( "&Quit" ) )
     
     aClassic = self.mActionsModel.addAction(
                     "mView/mMode/aShowClassic", self.tr( "Classic" ) )
     aClassic.setCheckable( True )
     
     aModern = self.mActionsModel.addAction(
                     "mView/mMode/aShowModern", self.tr( "Modern" ) )
     aModern.setCheckable( True )
     
     # style actions
     self.agStyles = pStylesActionGroup( self )
     self.agStyles.installInMenuBar( self.menuBar(), "mView/mStyle" )
     
     # action group
     agDockToolBarManagerMode = QActionGroup( self )
     agDockToolBarManagerMode.addAction( aClassic )
     agDockToolBarManagerMode.addAction( aModern )
     
     # add dock toolbar manager actions
     for dockToolBar in self.dockToolBarManager().dockToolBars():
         action = dockToolBar.toggleViewAction()
         self.mActionsModel.addAction(
             "mView/mDockToolBarManager/%s" % action.objectName() , action )
         
         action = dockToolBar.toggleExclusiveAction()
         self.mActionsModel.addAction(
             "mView/mDockToolBarManager/%s" % action.objectName(), action )
     
     # connections
     aQuit.triggered.connect(self.close)
     self.agStyles.styleSelected.connect(self.setCurrentStyle)
     self.dockToolBarManager().modeChanged.connect(
                         self.dockToolBarManagerModeChanged)
     aClassic.triggered.connect(self.dockToolBarManagerClassic)
     aModern.triggered.connect(self.dockToolBarManagerModern)
Example #21
0
    def setupUi(self):
        super(MainWindow, self).setupUi(self)

        self.search_box.shortcut = QShortcut(self.search_box)
        self.search_box.shortcut.setKey('Ctrl+F')

        self.output_devices_group = QActionGroup(self)
        self.input_devices_group = QActionGroup(self)
        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)

        # adjust search box height depending on theme as the value set in designer isn't suited for all themes
        search_box = self.search_box
        option = QStyleOptionFrameV2()
        search_box.initStyleOption(option)
        frame_width = search_box.style().pixelMetric(QStyle.PM_DefaultFrameWidth, option, search_box)
        if frame_width < 4:
            search_box.setMinimumHeight(20 + 2*frame_width)

        # adjust the combo boxes for themes with too much padding (like the default theme on Ubuntu 10.04)
        option = QStyleOptionComboBox()
        self.identity.initStyleOption(option)
        wide_padding = self.identity.style().subControlRect(QStyle.CC_ComboBox, option, QStyle.SC_ComboBoxEditField, self.identity).height() < 10
        self.identity.setStyleSheet("""QComboBox { padding: 0px 4px 0px 4px; }""" if wide_padding else "")
Example #22
0
class MainWindow(QMainWindow):
    def __init__(self):
        QMainWindow.__init__(self)
        self._create_actions()
        self._create_toolbar()
        self._canvas = Canvas()
        self._canvas.scale(16, 16)
        self.setCentralWidget(self._canvas)

    def _create_actions(self):
        self._delete_action = QAction("Delete", None)
        self._delete_action.setShortcuts(QKeySequence.Delete)
        self._delete_action.triggered.connect(self._delete)

        self._select_action = QAction("Select", None)
        self._select_action.setCheckable(True)
        self._select_action.triggered.connect(self._use_select_tool)

        self._pen_action = QAction("Pen", None)
        self._pen_action.setCheckable(True)
        self._pen_action.setChecked(True)
        self._pen_action.triggered.connect(self._use_pen_tool)

        self._new_shape_action = QAction("New Shape", None)
        self._new_shape_action.triggered.connect(self._new_shape)

        self._tool_group = QActionGroup(None)
        self._tool_group.addAction(self._select_action)
        self._tool_group.addAction(self._pen_action)

    def _create_toolbar(self):
        toolbar = self.addToolBar("Tools")
        toolbar.addAction(self._delete_action)
        toolbar.addAction(self._select_action)
        toolbar.addAction(self._pen_action)
        toolbar.addAction(self._new_shape_action)

    def _use_select_tool(self):
        self._canvas.use_tool(SelectTool)

    def _use_pen_tool(self):
        self._canvas.use_tool(PenTool)

    def _new_shape(self):
        self._canvas.new_shape()

    def _delete(self):
        self._canvas.delete_selection()
Example #23
0
 def set_menu_items(self, db, tag, names):
     """Some of the menus change their content dynamically in runtime.
        This method updates menu specified by 'tag' with the items
        given in 'names'.
     """
     menu, fb = self.dynamic_menus[tag]
     group = QActionGroup(self, exclusive=True)
     menu.clear()
     for name in names:
         action = QAction(name, self, checkable=True)
         action.setStatusTip('Select item')
         action.triggered.connect(partial(fb, self, db, name))
         a = group.addAction(action)
         menu.addAction(a)
         if db.selection[tag] == name:
             a.toggle()
Example #24
0
 def _buildMenu(self):
     self.framelessCheck = QtGui.QAction("Frameless Window", self, checkable=True)
     self.connect(self.framelessCheck, SIGNAL("triggered()"), self.trayIcon.changeFrameless)
     self.addAction(self.framelessCheck)
     self.addSeparator()
     self.requestCheck = QtGui.QAction("Show status request notifications", self, checkable=True)
     self.requestCheck.setChecked(True)
     self.addAction(self.requestCheck)
     self.connect(self.requestCheck, SIGNAL("triggered()"), self.trayIcon.switchRequest)
     self.alarmCheck = QtGui.QAction("Show alarm notifications", self, checkable=True)
     self.alarmCheck.setChecked(True)
     self.connect(self.alarmCheck, SIGNAL("triggered()"), self.trayIcon.switchAlarm)
     self.addAction(self.alarmCheck)
     distanceMenu = self.addMenu("Alarm Distance")
     self.distanceGroup = QActionGroup(self)
     for i in range(0, 6):
         action = QAction("{0} Jumps".format(i), None, checkable=True)
         if i == 0:
             action.setChecked(True)
         action.alarmDistance = i
         self.connect(action, SIGNAL("triggered()"), self.changeAlarmDistance)
         self.distanceGroup.addAction(action)
         distanceMenu.addAction(action)
     self.addMenu(distanceMenu)
     self.addSeparator()
     self.quitAction = QAction("Quit", self)
     self.connect(self.quitAction, SIGNAL("triggered()"), self.trayIcon.quit)
     self.addAction(self.quitAction)
Example #25
0
 def initModeMenu(self):
     self.modeGroup = QActionGroup(self)
     self.modeGroup.setExclusive(True)
     self.modeGroup.selected.connect(self.parent.setMode)
     self.action_Squirrel = QAction(Icons.nut, 'Squ', self.modeGroup)
     self.action_Squirrel.setCheckable(True)
     self.action_Emo = QAction(Icons.emo, 'Emo', self.modeGroup)
     self.action_Emo.setCheckable(True)
     self.action_And = QAction(Icons.android, 'Android', self.modeGroup)
     self.action_And.setCheckable(True)
     self.action_Ios = QAction(Icons.ios, 'ios', self.modeGroup)
     self.action_Ios.setCheckable(True)
     self.modeGroup.addAction(self.action_Squirrel)
     self.modeGroup.addAction(self.action_Emo)
     self.modeGroup.addAction(self.action_And)
     self.modeGroup.addAction(self.action_Ios)
     self.addActions(self.modeGroup.actions())
     if(config.mode() == 0):
         self.action_Squirrel.setChecked(True)
         self.action_Build.setEnabled(False)
         self.action_Run.setEnabled(False)
     elif(config.mode() == 1):
         self.action_Emo.setChecked(True)
         self.action_Build.setEnabled(True)
         self.action_Run.setEnabled(True)
     elif(config.mode() == 2):
         self.action_And.setChecked(True)
         self.action_Build.setEnabled(True)
         self.action_Run.setEnabled(True)
     elif(config.mode() == 3):
         self.action_Ios.setChecked(True)
         self.action_Build.setEnabled(False)
         self.action_Run.setEnabled(False)
Example #26
0
    def __init__(self, parent):
        super(XViewProfileToolBar, self).__init__(parent)

        # create custom properties
        self._editingEnabled = True
        self._viewWidget = None
        self._profileGroup = QActionGroup(self)

        # set the default options
        self.setIconSize(QSize(48, 48))
        self.setToolButtonStyle(Qt.ToolButtonTextUnderIcon)
        self.setContextMenuPolicy(Qt.CustomContextMenu)

        # create connections
        self.actionTriggered.connect(self.handleActionTrigger)
        self.customContextMenuRequested.connect(self.showProfileMenu)
Example #27
0
    def configureToolBarActionsGroups(self):
        """
        :return:
        """
        sep = QAction(self)
        sep.setSeparator(True)

        # region Segmentation and Transformations actions
        segm_transf_actions = QActionGroup(self)
        segm_transf_actions_list = [
            self.actionDetection, self.actionTwo_Dimensional_Graphs,
            self.actionDelete_Selected_Elements, self.actionDeselect_Elements,
            self.actionAddElement, self.actionParameter_Measurement, sep
        ]

        for act in segm_transf_actions_list:
            act.setActionGroup(segm_transf_actions)

        # endregion

        # add to the customizable sound lab toolbar first than the default actions
        # addActionGroup(actionGroup, name)
        self.toolBar.addActionGroup(segm_transf_actions,
                                    u"Segments and Parameters")

        # apply the common sound lab window toolbar actions
        SoundLabWindow.configureToolBarActionsGroups(self)
Example #28
0
    def initGui(self):
    
        self.action = QAction(QIcon(":/plugins/EjdexplInt/icons/icon.png"),self.tr(u'Activate EjdExplorer tool'),self.iface.mainWindow())
        self.action.setWhatsThis(u"Activate EjdExplorer tool")
        self.action.triggered.connect(self.run)
    
        self.tbmenu = QMenu()

        self.ag1 = QActionGroup(self.tbmenu,exclusive=True)
        self.acPol  = self.ag1.addAction(QAction(QIcon(':/plugins/EjdexplInt/icons/Icons8-Ios7-Maps-Polygon.ico'),self.tr(u'Draw polygon'),self.tbmenu,checkable=True))
        self.acLin  = self.ag1.addAction(QAction(QIcon(':/plugins/EjdexplInt/icons/Icons8-Ios7-Maps-Polyline.ico'),self.tr(u'Draw line'),self.tbmenu,checkable=True))
        self.acPnt  = self.ag1.addAction(QAction(QIcon(':/plugins/EjdexplInt/icons/Icons8-Ios7-Maps-Geo-Fence.ico'),self.tr(u'Draw point'),self.tbmenu,checkable=True))
        self.acAlay = self.ag1.addAction(QAction(QIcon(':/plugins/EjdexplInt/icons/Icons8-Ios7-Maps-Layers.ico'),self.tr(u'Active selection'),self.tbmenu,checkable=True))
        self.acPobj = self.ag1.addAction(QAction(QIcon(':/plugins/EjdexplInt/icons/Icons8-Ios7-Maps-Quest.ico'),self.tr(u'Previous object'),self.tbmenu,checkable=True))
        self.tbmenu.addActions(self.ag1.actions());
        self.acPol.setChecked(self.config['searchtool']==u'polygon')
        self.acLin.setChecked(self.config['searchtool']==u'line')
        self.acPnt.setChecked(self.config['searchtool']==u'point')
        self.acAlay.setChecked(self.config['searchtool']==u'selection')
        self.acPobj.setChecked(self.config['searchtool']==u'search')

        self.tbmenu.addSeparator()

        self.ag2 = QActionGroup(self.tbmenu,exclusive=True)
        self.acSingle = self.ag2.addAction(QAction(self.tr(u'Use single mode'),self.tbmenu,checkable=True))
        self.acBulk = self.ag2.addAction(QAction(self.tr(u'Use bulk mode'),self.tbmenu,checkable=True))
        self.acMerge = self.ag2.addAction(QAction(self.tr(u'Use merge mode'),self.tbmenu,checkable=True))
        self.tbmenu.addActions(self.ag2.actions());
        self.acSingle.setChecked(self.config['tabchoice']==u'single')
        self.acBulk.setChecked(self.config['tabchoice']==u'bulk')
        self.acMerge.setChecked(self.config['tabchoice']==u'merge')

        if self.config['old_behavior'] == 0:
            self.tbmenu.addSeparator()
            self.acClear = QAction(self.tr(u'Clear'),self.tbmenu,checkable=False)
            self.acClear.triggered.connect(self.clearSearch)    
            self.tbmenu.addAction(self.acClear)

        self.toolButton = QToolButton()
        self.toolButton.addAction(self.action)
        self.toolButton.setDefaultAction(self.action)
        self.toolButton.setMenu(self.tbmenu)
        self.toolButton.setPopupMode(QToolButton.MenuButtonPopup)
        self.iface.addToolBarWidget(self.toolButton)
        self.iface.addPluginToMenu(self.tr(u'Activate EjdExplorer tool'), self.action)

        self.ag1.triggered.connect(self.drawChanged)    
    def __init__(self, parent=None):
        super(ProjectSnappingAction, self).__init__(parent)
        self.setCheckable(True)

        self._currentAction = SnappingModeAction(Snapping.CurrentLayer, self)
        self._allAction = SnappingModeAction(Snapping.AllLayers, self)
        self._selectedAction = SnappingModeAction(Snapping.SelectedLayers, self)

        self._snappingModeActionGroup = QActionGroup(self)
        self._snappingModeActionGroup.addAction(self._currentAction)
        self._snappingModeActionGroup.addAction(self._allAction)
        self._snappingModeActionGroup.addAction(self._selectedAction)

        self._vertexAction = ProjectSnappingTypeAction(Snapping.Vertex, self)
        self._segmentAction = ProjectSnappingTypeAction(Snapping.Segment, self)
        self._vertexSegmentAction = ProjectSnappingTypeAction(Snapping.VertexAndSegment, self)

        self._snappingTypeActionGroup = QActionGroup(self)
        self._snappingTypeActionGroup.addAction(self._vertexAction)
        self._snappingTypeActionGroup.addAction(self._segmentAction)
        self._snappingTypeActionGroup.addAction(self._vertexSegmentAction)

        self._pixelUnitsAction = ProjectSnappingUnitAction(Snapping.Pixels, self)
        self._layerUnitsAction = ProjectSnappingUnitAction(Snapping.LayerUnits, self)
        self._projectUnitsAction = ProjectSnappingUnitAction(Snapping.ProjectUnits, self)

        self._unitTypeActionGroup = QActionGroup(self)
        self._unitTypeActionGroup.addAction(self._pixelUnitsAction)
        self._unitTypeActionGroup.addAction(self._layerUnitsAction)
        self._unitTypeActionGroup.addAction(self._projectUnitsAction)

        self._toleranceAction = ProjectSnappingToleranceAction(parent)

        menu = ControlMenu(parent)
        menu.addActions(self._snappingModeActionGroup.actions())
        menu.addSeparator()
        menu.addActions(self._snappingTypeActionGroup.actions())
        menu.addSeparator()
        menu.addAction(self._toleranceAction)
        menu.addActions(self._unitTypeActionGroup.actions())
        self.setMenu(menu)

        self._refreshAction()

        # Make sure we catch changes in the main snapping dialog
        QgsProject.instance().snapSettingsChanged.connect(self._refreshAction)
Example #30
0
    def __createLanguageOptions(self):
        """Creates the language selection in the menubar.
        """
        self.langGroup = QActionGroup(self)
        self.langGroup.setExclusive(True)
        self.langGroup.triggered['QAction*'].connect(self.languageChanged)

        for key, name in self.languages.iteritems():
            action = QAction(self)
            action.setCheckable(True)
            action.setData(key)
            action.setText(name[0])
            action.setStatusTip(name[1])
            action.setActionGroup(self.langGroup)
            self.menuLanguage.addAction(action)
            if key == self.currentLanguage:
                action.setChecked(True)
Example #31
0
 def setupToolbar(self):
     """
     Setup the toolbar (adds a drop-down button for program types)
     """
     # create program type group
     ag = QActionGroup(self)
     ag.addAction(self.actionProgram)
     ag.addAction(self.actionSubprogram)
     ag.triggered.connect(self.on_programType_triggered)
     self.programActionGroup = ag
     self.tb = QToolButton()
     self.tb.setToolTip("Select the compiler program type to make")
     self.tb.setMenu(self.menuProgramType)
     self.tb.setPopupMode(QToolButton.InstantPopup)
     self.tb.setText("Executable")
     self.toolBarCode.insertWidget(self.actionCompile, self.tb)
     self.toolBarCode.insertSeparator(self.actionCompile)
Example #32
0
class TrayContextMenu(QtGui.QMenu):
    instances = set()

    def __init__(self, trayIcon):
        """ trayIcon = the object with the methods to call
        """
        QtGui.QMenu.__init__(self)
        TrayContextMenu.instances.add(self)
        self.trayIcon = trayIcon
        self._buildMenu()

    def _buildMenu(self):
        self.framelessCheck = QtGui.QAction("Frameless Window", self, checkable=True)
        self.connect(self.framelessCheck, SIGNAL("triggered()"), self.trayIcon.changeFrameless)
        self.addAction(self.framelessCheck)
        self.addSeparator()
        self.requestCheck = QtGui.QAction("Show status request notifications", self, checkable=True)
        self.requestCheck.setChecked(True)
        self.addAction(self.requestCheck)
        self.connect(self.requestCheck, SIGNAL("triggered()"), self.trayIcon.switchRequest)
        self.alarmCheck = QtGui.QAction("Show alarm notifications", self, checkable=True)
        self.alarmCheck.setChecked(True)
        self.connect(self.alarmCheck, SIGNAL("triggered()"), self.trayIcon.switchAlarm)
        self.addAction(self.alarmCheck)
        distanceMenu = self.addMenu("Alarm Distance")
        self.distanceGroup = QActionGroup(self)
        for i in range(0, 6):
            action = QAction("{0} Jumps".format(i), None, checkable=True)
            if i == 0:
                action.setChecked(True)
            action.alarmDistance = i
            self.connect(action, SIGNAL("triggered()"), self.changeAlarmDistance)
            self.distanceGroup.addAction(action)
            distanceMenu.addAction(action)
        self.addMenu(distanceMenu)
        self.addSeparator()
        self.quitAction = QAction("Quit", self)
        self.connect(self.quitAction, SIGNAL("triggered()"), self.trayIcon.quit)
        self.addAction(self.quitAction)

    def changeAlarmDistance(self):
        for action in self.distanceGroup.actions():
            if action.isChecked():
                self.trayIcon.alarmDistance = action.alarmDistance
                self.trayIcon.changeAlarmDistance()
Example #33
0
class FilterSetWidget(QWidget, Ui_FilterSetWidget):
    def __init__(self, parent=None):
        super(FilterSetWidget, self).__init__(parent)
        self.setupUi(self)
        self._filterSetActionGroup = QActionGroup(self)
        self._filterSetActionGroup.addAction(self.saveFilterSetAction)
        self._filterSetActionGroup.addAction(self.reloadFilterSetAction)
        self._filterSetActionGroup.addAction(self.deleteFilterSetAction)
        self._filterSetActionGroup.addAction(self.exportFilterSetAction)
        self._filterSetMenu = QMenu(self)
        self._filterSetMenu.addActions(self._filterSetActionGroup.actions())
        self.filterSetTool.setMenu(self._filterSetMenu)
        self.filterSetTool.setDefaultAction(self.saveFilterSetAction)

    def setFilterSet(self, filterSet):
        self.setFilterSetKey(filterSet.key)
        if filterSet.source == 'ark':
            self.saveFilterSetAction.setEnabled(False)
            self.deleteFilterSetAction.setEnabled(False)
            self.filterSetTool.setDefaultAction(self.reloadFilterSetAction)
        else:
            self.saveFilterSetAction.setEnabled(True)
            self.deleteFilterSetAction.setEnabled(True)
            self.filterSetTool.setDefaultAction(self.saveFilterSetAction)

    def setFilterSetKey(self, key):
        self.filterSetCombo.setCurrentIndex(self.filterSetCombo.findData(key))

    def currentFilterSetKey(self):
        return self.filterSetCombo.itemData(self.filterSetCombo.currentIndex())

    def currentFilterSetName(self):
        return self.filterSetCombo.currentText()
class FilterSetWidget(QWidget, Ui_FilterSetWidget):

    def __init__(self, parent=None):
        super(FilterSetWidget, self).__init__(parent)
        self.setupUi(self)
        self._filterSetActionGroup = QActionGroup(self)
        self._filterSetActionGroup.addAction(self.saveFilterSetAction)
        self._filterSetActionGroup.addAction(self.reloadFilterSetAction)
        self._filterSetActionGroup.addAction(self.deleteFilterSetAction)
        self._filterSetActionGroup.addAction(self.exportFilterSetAction)
        self._filterSetMenu = QMenu(self)
        self._filterSetMenu.addActions(self._filterSetActionGroup.actions())
        self.filterSetTool.setMenu(self._filterSetMenu)
        self.filterSetTool.setDefaultAction(self.saveFilterSetAction)

    def setFilterSet(self, filterSet):
        self.setFilterSetKey(filterSet.key)
        if filterSet.source == 'ark':
            self.saveFilterSetAction.setEnabled(False)
            self.deleteFilterSetAction.setEnabled(False)
            self.filterSetTool.setDefaultAction(self.reloadFilterSetAction)
        else:
            self.saveFilterSetAction.setEnabled(True)
            self.deleteFilterSetAction.setEnabled(True)
            self.filterSetTool.setDefaultAction(self.saveFilterSetAction)

    def setFilterSetKey(self, key):
        self.filterSetCombo.setCurrentIndex(self.filterSetCombo.findData(key))

    def currentFilterSetKey(self):
        return self.filterSetCombo.itemData(self.filterSetCombo.currentIndex())

    def currentFilterSetName(self):
        return self.filterSetCombo.currentText()
Example #35
0
    def add_action(self,
                   icon_path,
                   text,
                   callback,
                   enabled_flag=True,
                   add_to_menu='toolbar',
                   add_to_toolbar=True,
                   status_tip=None,
                   whats_this=None,
                   isMenu=None,
                   checkable=None,
                   checked=None,
                   parent=None):

        if not parent:
            parent = self.iface.mainWindow()

        icon = QIcon(icon_path)
        if add_to_menu == 'toolbar':
            action = QAction(icon, text, parent)
        else:
            action = self.tools[add_to_menu].menu().addAction(text)
            action.setActionGroup(self.tools[add_to_menu].actionGroup)
            add_to_toolbar = False

        if checkable:
            action.setCheckable(True)
            if checked:
                action.setChecked(True)
            if callback:
                action.toggled.connect(callback)
        else:
            if callback:
                action.triggered.connect(callback)
        action.setEnabled(enabled_flag)

        if status_tip is not None:
            action.setStatusTip(status_tip)

        if whats_this is not None:
            action.setWhatsThis(whats_this)

        if add_to_toolbar:
            self.toolbar.addAction(action)

        if isMenu:
            newMenu = QMenu()
            action.setMenu(newMenu)
            newActionGroup = QActionGroup(newMenu)
            action.actionGroup = newActionGroup

        if add_to_menu == 'toolbar':
            self.iface.addPluginToMenu(self.menu, action)

        self.actions.append(action)

        return action
Example #36
0
    def __init__(self, name, parent):
        """
		parent: The parent of this toolbar.  Should be another toolbar
		"""
        QToolBar.__init__(self, name, parent)
        self.setMovable(False)
        self.setWindowFlags(Qt.Tool | Qt.FramelessWindowHint | Qt.X11BypassWindowManagerHint)
        self.setAllowedAreas(Qt.NoToolBarArea)
        self.actiongroup = QActionGroup(self)
Example #37
0
    def setupUi(self):
        super(MainWindow, self).setupUi(self)

        self.search_box.shortcut = QShortcut(self.search_box)
        self.search_box.shortcut.setKey('CTRL+F')

        self.output_devices_group = QActionGroup(self)
        self.input_devices_group = QActionGroup(self)
        self.alert_devices_group = QActionGroup(self)

        # adjust search box height depending on theme as the value set in designer isn't suited for all themes
        search_box = self.search_box
        option = QStyleOptionFrameV2()
        search_box.initStyleOption(option)
        frame_width = search_box.style().pixelMetric(QStyle.PM_DefaultFrameWidth, option, search_box)
        if frame_width < 4:
            search_box.setMinimumHeight(20 + 2*frame_width)

        # adjust status combo-box font size to fit the combo-box
        option = QStyleOptionComboBox()
        self.status.initStyleOption(option)
        frame_width = self.status.style().pixelMetric(QStyle.PM_DefaultFrameWidth, option, self.status)
        font = self.status.font()
        font.setFamily('Sans Serif')
        font.setPointSize(font.pointSize() - 1) # make it 1 point smaller then the default font size
        font_metrics = QFontMetrics(font)
        if font_metrics.height() > self.status.maximumHeight() - 2*frame_width:
            pixel_size = 11 - (frame_width - 2) # subtract 1 pixel for every frame pixel over 2 pixels
            font.setPixelSize(pixel_size)
        self.status.setFont(font)

        # adjust the combo boxes for themes with too much padding (like the default theme on Ubuntu 10.04)
        option = QStyleOptionComboBox()
        self.status.initStyleOption(option)
        font_metrics = self.status.fontMetrics()
        text_width = max(font_metrics.width(self.status.itemText(index)) for index in xrange(self.status.count()))
        frame_width = self.status.style().pixelMetric(QStyle.PM_ComboBoxFrameWidth, option, self.status)
        arrow_width = self.status.style().subControlRect(QStyle.CC_ComboBox, option, QStyle.SC_ComboBoxArrow, self.status).width()
        wide_padding = self.status.style().subControlRect(QStyle.CC_ComboBox, option, QStyle.SC_ComboBoxEditField, self.status).height() < 10
        self.status.setFixedWidth(text_width + arrow_width + 2*frame_width + 30) # 30? Don't ask.
        self.status.setStyleSheet("""QComboBox { padding: 0px 3px 0px 3px; }""" if wide_padding else "")
        self.identity.setStyleSheet("""QComboBox { padding: 0px 4px 0px 4px; }""" if wide_padding else "")
Example #38
0
    def __setupUi(self):
        layout = QVBoxLayout()
        layout.setContentsMargins(0, 0, 0, 0)

        # Scroll area for the contents.
        self.__scrollArea = \
                _ToolBoxScrollArea(self, objectName="toolbox-scroll-area")

        self.__scrollArea.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
        self.__scrollArea.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        self.__scrollArea.setSizePolicy(QSizePolicy.MinimumExpanding,
                                        QSizePolicy.MinimumExpanding)
        self.__scrollArea.setFrameStyle(QScrollArea.NoFrame)
        self.__scrollArea.setWidgetResizable(True)

        # A widget with all of the contents.
        # The tabs/contents are placed in the layout inside this widget
        self.__contents = QWidget(self.__scrollArea,
                                  objectName="toolbox-contents")

        # The layout where all the tab/pages are placed
        self.__contentsLayout = QVBoxLayout()
        self.__contentsLayout.setContentsMargins(0, 0, 0, 0)
        self.__contentsLayout.setSizeConstraint(QVBoxLayout.SetMinAndMaxSize)
        self.__contentsLayout.setSpacing(0)

        self.__contents.setLayout(self.__contentsLayout)

        self.__scrollArea.setWidget(self.__contents)

        layout.addWidget(self.__scrollArea)

        self.setLayout(layout)
        self.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.MinimumExpanding)

        self.__tabActionGroup = \
                QActionGroup(self, objectName="toolbox-tab-action-group")

        self.__tabActionGroup.setExclusive(self.__exclusive)

        self.__actionMapper = QSignalMapper(self)
        self.__actionMapper.mapped[QObject].connect(self.__onTabActionToogled)
 def loadPlugins(self):
     sys.path.append(os.curdir + os.sep + "plugins")
     plugins = QActionGroup(self)
     for s in os.listdir("plugins"):
         # TODO: check all errors
         if s.endswith(".py"):
             plugin = __import__(s[:-3])
             if plugin == "__init__":
                 continue
             if "pluginMain" in dir(plugin):
                 pluginClass = plugin.pluginMain()
                 name = pluginClass.GetName()
                 action = QAction(name, self)
                 action.setCheckable(False)
                 QObject.connect(action, SIGNAL("triggered()"), self.GenerateRequests)
                 plugins.addAction(action)
                 self.ui.menuGenerators.addAction(action)
                 self.generators[action] = pluginClass()
             else:
                 print("pluginMain not found in " + s)
Example #40
0
    def on_classifyBtn_clicked(self):
        """
        Slot documentation goes here.
        """
        # TODO: not implemented yet
        #raise NotImplementedError
        if self.showGroupBtn.isChecked():
            self.showGroupBtn.setChecked(False)
            self.on_showGroupBtn_clicked()
        if self.classifyMenu is None:
            self.classifyMenu = QMenu(self)
            subMenu = QMenu(self)
            subMenu.setTitle(u'地区板块')
            self.classifyMenuGroup = QActionGroup(self)
            for key in myGlobal.area2ids:
                if len(key) != 0:
                    action = MyAction(key, myGlobal.area2ids[key],
                                      self.changeIds, self)
                    subMenu.addAction(action)
                    self.classifyMenuGroup.addAction(action)
            self.classifyMenu.addMenu(subMenu)
            subMenu = QMenu(self)
            subMenu.setTitle(u'行业板块')
            for key in myGlobal.industry2ids:
                if len(key) != 0:
                    action = MyAction(key, myGlobal.industry2ids[key],
                                      self.changeIds, self)
                    subMenu.addAction(action)
                    self.classifyMenuGroup.addAction(action)
            self.classifyMenu.addMenu(subMenu)
            subMenu = MyMenu(u'向上版块', 'FLAG_UP', self, self.classifyMenuGroup)
            self.classifyMenu.addMenu(subMenu)
            subMenu = MyMenu(u'向下版块', 'FLAG_DOWN', self,
                             self.classifyMenuGroup)
            self.classifyMenu.addMenu(subMenu)

        self.classifyBtn.setChecked(True)
        pos = QPoint()
        pos.setX(0)
        pos.setY(-self.classifyMenu.sizeHint().height())
        self.classifyMenu.exec_(self.classifyBtn.mapToGlobal(pos))
 def loadPlugins(self):
     sys.path.append(os.curdir + os.sep + "plugins")
     plugins = QActionGroup(self)
     for s in os.listdir("plugins"):
         # TODO: check all errors
         if s.endswith(".py"):
             plugin = __import__(s[:-3])
             if plugin == "__init__":
                 continue
             if "pluginMain" in dir(plugin):
                 pluginClass = plugin.pluginMain()
                 name = pluginClass.GetName()
                 action = QAction(name, self)
                 action.setCheckable(False)
                 QObject.connect(action, SIGNAL("triggered()"),
                                 self.GenerateRequests)
                 plugins.addAction(action)
                 self.ui.menuGenerators.addAction(action)
                 self.generators[action] = pluginClass()
             else:
                 print("pluginMain not found in " + s)
Example #42
0
 def __init__( self, parent = None ):
     super(XSplitButton, self).__init__( parent )
     
     # define custom properties
     self._actionGroup   = QActionGroup(self)
     self._padding       = 5
     self._cornerRadius  = 10
     #self._currentAction = None
     self._checkable     = True
     
     # set default properties
     layout = QBoxLayout(QBoxLayout.LeftToRight)
     layout.setContentsMargins(0, 0, 0, 0)
     layout.setSpacing(0)
     self.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred)
     self.setLayout(layout)
     self.clear()
     
     # create connections
     self._actionGroup.hovered.connect(self.emitHovered)
     self._actionGroup.triggered.connect(self.emitTriggered)
 def __init__(self, parent=None):
     super(FilterSetWidget, self).__init__(parent)
     self.setupUi(self)
     self._filterSetActionGroup = QActionGroup(self)
     self._filterSetActionGroup.addAction(self.saveFilterSetAction)
     self._filterSetActionGroup.addAction(self.reloadFilterSetAction)
     self._filterSetActionGroup.addAction(self.deleteFilterSetAction)
     self._filterSetActionGroup.addAction(self.exportFilterSetAction)
     self._filterSetMenu = QMenu(self)
     self._filterSetMenu.addActions(self._filterSetActionGroup.actions())
     self.filterSetTool.setMenu(self._filterSetMenu)
     self.filterSetTool.setDefaultAction(self.saveFilterSetAction)
Example #44
0
    def setupUi(self):
        # Create the Playback object that will take care of the preview and
        # playback gui
        self.playback = Playback()
        self.pb_play.clicked.connect(self.playback.pb_play_clicked)
        self.scb_pos.sliderPressed.connect(self.playback.start_seeking)
        self.scb_pos.sliderReleased.connect(self.playback.seek)
        self.scb_pos.sliderMoved.connect(self.playback.slider_moved)

        # Create an action group for the language selection menu
        self.actngroup_language = QActionGroup(self.menu_lang)
        # Add all the language change actions
        self.actngroup_language.addAction(self.actn_lang_en_US)
        self.actngroup_language.addAction(self.actn_lang_pt_BR)
        # Connect the action to the handler
        self.actngroup_language.triggered.connect(self.actngroup_language_triggered)

        # Create an action group for the preview option
        self.actngroup_preview_source = QActionGroup(self.menu_preview_source)
        # Add all the preview source options
        self.actngroup_preview_source.addAction(self.actn_raw)
        self.actngroup_preview_source.addAction(self.actn_post_analysis)
        self.actngroup_preview_source.addAction(self.actn_filter_page)
        # Connect the action to the handler
        self.actngroup_preview_source.triggered.connect(self.actngroup_preview_source_triggered)

        # Connect the exit action to the close method
        self.actn_exit.triggered.connect(self.close)

        # The action that will let the user show the input plugin to be loaded
        self.actn_load_input_plugin.triggered.connect(self.prompt_input_plugin)

        self.pb_add_filter.clicked.connect(self.actn_add_filter.trigger)
        self.actn_add_filter.triggered.connect(self.prompt_filter_plugin)

        self.actn_load_analysis_plugin.triggered.connect(self.prompt_analysis_plugin)

        self.pb_loop.clicked.connect(self.set_loop)

        self.cb_filter_group.currentIndexChanged.connect(self.update_filter_page)
Example #45
0
 def _buildMenu(self):
     self.framelessCheck = QtGui.QAction("Frameless Window",
                                         self,
                                         checkable=True)
     self.connect(self.framelessCheck, SIGNAL("triggered()"),
                  self.trayIcon.changeFrameless)
     self.addAction(self.framelessCheck)
     self.addSeparator()
     self.requestCheck = QtGui.QAction("Show status request notifications",
                                       self,
                                       checkable=True)
     self.requestCheck.setChecked(True)
     self.addAction(self.requestCheck)
     self.connect(self.requestCheck, SIGNAL("triggered()"),
                  self.trayIcon.switchRequest)
     self.alarmCheck = QtGui.QAction("Show alarm notifications",
                                     self,
                                     checkable=True)
     self.alarmCheck.setChecked(True)
     self.connect(self.alarmCheck, SIGNAL("triggered()"),
                  self.trayIcon.switchAlarm)
     self.addAction(self.alarmCheck)
     distanceMenu = self.addMenu("Alarm Distance")
     self.distanceGroup = QActionGroup(self)
     for i in range(0, 6):
         action = QAction("{0} Jumps".format(i), None, checkable=True)
         if i == 0:
             action.setChecked(True)
         action.alarmDistance = i
         self.connect(action, SIGNAL("triggered()"),
                      self.changeAlarmDistance)
         self.distanceGroup.addAction(action)
         distanceMenu.addAction(action)
     self.addMenu(distanceMenu)
     self.addSeparator()
     self.quitAction = QAction("Quit", self)
     self.connect(self.quitAction, SIGNAL("triggered()"),
                  self.trayIcon.quit)
     self.addAction(self.quitAction)
Example #46
0
File: qmap.py Project: s-chand/qmap
 def __init__(self, iface):
     self.iface = iface
     self.actions = []
     self.panels= []
     self.navtoolbar = self.iface.mapNavToolToolBar()
     self.mainwindow = self.iface.mainWindow()
     self.iface.projectRead.connect(self.projectOpened)
     self.iface.initializationCompleted.connect(self.setupUI)
     self.actionGroup = QActionGroup(self.mainwindow)
     self.actionGroup.setExclusive(True)
     self.menuGroup = QActionGroup(self.mainwindow)
     self.menuGroup.setExclusive(True)
             
     self.movetool = MoveTool(self.iface.mapCanvas(), [])
     self.report = PopDownReport(self.iface.messageBar())
     
     self.dialogprovider = DialogProvider(iface.mapCanvas(), iface)
     self.dialogprovider.accepted.connect(self.clearToolRubberBand)
     self.dialogprovider.rejected.connect(self.clearToolRubberBand)
     
     self.edittool = EditTool(self.iface.mapCanvas(),[])
     self.edittool.finished.connect(self.openForm)
    def __init__(self, parent=None):
        super(ActionSettingsTool, self).__init__(parent)

        self._mapActionGroup = QActionGroup(self)
        self._noMapAction = self._addMapAction(MapAction.NoMapAction, 'No map action')
        self._zoomMapAction = self._addMapAction(MapAction.ZoomMap, 'Zoom map view')
        self._panMapAction = self._addMapAction(MapAction.PanMap, 'Pan map view')
        self._moveMapAction = self._addMapAction(MapAction.MoveMap, 'Move map view')
        self._moveMapAction.setChecked(True)

        self._filterActionGroup = QActionGroup(self)
        self._noFilterAction = self._addFilterAction(FilterAction.NoFilterAction, 'No filter action')
        self._includeFilterAction = self._addFilterAction(FilterAction.IncludeFilter, 'Add to filter')
        self._exclusiveFilterAction = self._addFilterAction(FilterAction.ExclusiveFilter, 'Exclusive filter')
        self._selectFilterAction = self._addFilterAction(FilterAction.SelectFilter, 'Add to selection')
        self._exclusiveSelectFilterAction = self._addFilterAction(
            FilterAction.ExclusiveSelectFilter, 'Exclusive selection')
        self._highlightFilterAction = self._addFilterAction(FilterAction.HighlightFilter, 'Add to highlight')
        self._exclusiveHighlightFilterAction = self._addFilterAction(
            FilterAction.ExclusiveHighlightFilter, 'Exclusive highlight')
        self._exclusiveHighlightFilterAction.setChecked(True)

        self._drawingActionGroup = QActionGroup(self)
        self._noDrawingAction = self._addDrawingAction(DrawingAction.NoDrawingAction, 'No drawing action')
        self._noDrawingAction.setChecked(True)
        self._loadDrawingsAction = self._addDrawingAction(DrawingAction.LoadDrawings, 'Load drawings')
        self._addDrawingsAction = self._addDrawingAction(DrawingAction.AddDrawings, 'Add drawings')

        self._settingsMenu = QMenu(self)
        self._settingsMenu.addActions(self._mapActionGroup.actions())
        self._settingsMenu.addSeparator()
        self._settingsMenu.addActions(self._filterActionGroup.actions())
        self._settingsMenu.addSeparator()
        self._settingsMenu.addActions(self._drawingActionGroup.actions())

        self._settingsAction = QAction(QIcon(':/plugins/ark/settings.svg'), "Action Settings", self)
        self._settingsAction.setMenu(self._settingsMenu)
        self.setDefaultAction(self._settingsAction)
        self.setPopupMode(QToolButton.InstantPopup)
Example #48
0
 def _load_toolbar(self):
     self._toolbar_items.clear()
     self.actionGroup = QActionGroup(self)
     self.actionGroup.setExclusive(True)
     for item in self.toolbar_settings:
         if item == 'separator':
             self._toolbar_items.addSeparator()
         else:
             action = self._toolbar_items.addAction(
                 self.toolbar_items[item][0], self.toolbar_items[item][1])
             action.setData(item)
             action.setCheckable(True)
             self.actionGroup.addAction(action)
Example #49
0
    def _combination_actions(self):
        tree = self.layerTree
        group = QActionGroup(tree)

        act = QAction("Union Combine", tree)
        act.setIcon(QIcon(':icons/glue_or.png'))
        act.setEnabled(False)
        act.setToolTip("Define new subset as union of selection")
        act.setShortcutContext(Qt.WidgetShortcut)
        act.triggered.connect(self._or_combine)
        group.addAction(act)
        tree.addAction(act)
        self._or_action = act

        act = QAction("Intersection Combine", tree)
        act.setIcon(QIcon(':icons/glue_and.png'))
        act.setEnabled(False)
        act.setToolTip("Define new subset as intersection of selection")
        act.triggered.connect(self._and_combine)
        act.setShortcutContext(Qt.WidgetShortcut)
        group.addAction(act)
        tree.addAction(act)
        self._and_action = act

        act = QAction("XOR Combine", tree)
        act.setIcon(QIcon(':icons/glue_xor.png'))
        act.setEnabled(False)
        act.setToolTip("Define new subset as non-intersection of selection")
        act.triggered.connect(self._xor_combine)
        act.setShortcutContext(Qt.WidgetShortcut)
        group.addAction(act)
        tree.addAction(act)
        self._xor_action = act

        act = QAction("Invert", tree)
        act.setIcon(QIcon(':icons/glue_not.png'))
        act.setEnabled(False)
        act.setToolTip("Invert current subset")
        act.triggered.connect(self._invert_subset)
        act.setShortcutContext(Qt.WidgetShortcut)
        group.addAction(act)
        tree.addAction(act)
        self._invert_action = act
Example #50
0
    def __init__(self, from_table, to_table, condition):
        QGraphicsLineItem.__init__(self)
        self.instances.append(self)

        # from/to table connections
        self.from_table = from_table
        self.to_table = to_table
        self.condition = condition
        from_table.table_move.connect(self.update_spring)
        to_table.table_move.connect(self.update_spring)

        # draw arrow
        self.arrow = ArrowPolygonItem(self)
        self.arrow.clicked.connect(self.change_settings)

        # set attributes
        pen = QPen()
        pen.setWidth(2)
        self.setPen(pen)

        self.update_spring()
        self.setZValue(-1)

        # setup configuration menu
        menu = QMenu()
        join_action = QAction('Join', menu)
        join_action.setCheckable(True)
        join_action.setChecked(True)
        outer_join_action = QAction('Outer Join', menu)
        outer_join_action.setCheckable(True)
        group = QActionGroup(menu)
        group.addAction(join_action)
        group.addAction(outer_join_action)
        menu.addAction(join_action)
        menu.addAction(outer_join_action)
        self.join_action = join_action
        self.outer_join_action = outer_join_action
        self.menu = menu
Example #51
0
    def addAction(self, action):
        """
        Adds the inputed action to this widget's action group.  This will auto-\
        create a new group if no group is already defined.
        
        :param      action | <QAction> || <str>
        
        :return     <QAction>
        """
        if (not isinstance(action, QAction)):
            action_name = str(action)
            action = QAction(action_name, self)
            action.setObjectName(action_name)

        action.setCheckable(True)

        if (not self._actionGroup):
            self._actionGroup = QActionGroup(self)
            action.setChecked(True)

        self._actionGroup.addAction(action)
        self.reset()
        return action
Example #52
0
 def create_menu(self, menu_name, menu_actions):
     """ Creates a menu.  Groups them so you can only select one at a time. """
     menu_action_group = QActionGroup(self)
     menu_action_group.setExclusive(True)
     menubar = self.menuBar()
     menu = menubar.addMenu(menu_name)
     for action in menu_actions:
         menu_action_group.addAction(action)
         menu.addAction(action)
Example #53
0
    def load_action(self,
                    action,
                    toolbar_area=QtCore.Qt.TopToolBarArea,
                    toolbar_visible=True):
        category = action.category
        if category not in self._menus:
            # add an empty menu to the menu bar
            self._menus[category] = self._menu_bar.addMenu(category)
            self.add_toolbar(category, toolbar_area, toolbar_visible)
        self._toolbars[category].addAction(action)
        self._menus[category].addAction(action)

        group = action.group
        if group is not None:
            if group not in self._actiongroups:
                self._actiongroups[group] = QActionGroup(self.win)
            self._actiongroups[group].addAction(action)
Example #54
0
 def __init__(self, mainwindow):
     super(SessionMenu, self).__init__(mainwindow)
     app.translateUI(self)
     mgr = manager.get(mainwindow)
     ac = mgr.actionCollection
     ag = self._actionGroup = QActionGroup(self)
     ag.setExclusive(True)
     ag.addAction(ac.session_none)
     ag.triggered.connect(self.slotSessionsAction)
     self.addAction(ac.session_new)
     self.addAction(ac.session_save)
     self.addSeparator()
     self.addAction(ac.session_manage)
     self.addSeparator()
     self.addAction(ac.session_none)
     self.addSeparator()
     self.aboutToShow.connect(self.populate)
Example #55
0
 def __init__(self, mainwindow):
     self.actionCollection = ac = Actions()
     actioncollectionmanager.manager(mainwindow).addActionCollection(ac)
     m = self.language_menu = QMenu()
     g = self.language_group = QActionGroup(None)
     for name in sorted(ly.pitch.pitchInfo.keys()):
         a = m.addAction(name.title())
         a.setObjectName(name)
         a.setCheckable(True)
         g.addAction(a)
     qutil.addAccelerators(m.actions())
     ac.pitch_language.setMenu(m)
     m.aboutToShow.connect(self.setLanguageMenu)
     g.triggered.connect(self.changeLanguage)
     ac.pitch_rel2abs.triggered.connect(self.rel2abs)
     ac.pitch_abs2rel.triggered.connect(self.abs2rel)
     ac.pitch_transpose.triggered.connect(self.transpose)
     ac.pitch_modal_transpose.triggered.connect(self.modalTranspose)
    def setActionsExclusive(self):

        # Build an action list from QGIS navigation toolbar
        actionList = self.iface.mapNavToolToolBar().actions()

        # Add actions from QGIS attributes toolbar (handling QWidgetActions)
        tmpActionList = self.iface.attributesToolBar().actions()
        for action in tmpActionList:
            if isinstance(action, QWidgetAction):
                actionList.extend( action.defaultWidget().actions() )
            else:
                actionList.append( action )
        # ... add other toolbars' action lists...

        # Build a group with actions from actionList and add your own action
        group = QActionGroup( self.iface.mainWindow() )
        group.setExclusive(True)
        for action in actionList:
            group.addAction( action )
        group.addAction( self.identifyParcelleAction )
    def __init__(self, parent=None):
        super(ProjectSnappingAction, self).__init__(parent)
        self.setCheckable(True)

        self._currentAction = SnappingModeAction(Snapping.CurrentLayer, self)
        self._allAction = SnappingModeAction(Snapping.AllLayers, self)
        self._selectedAction = SnappingModeAction(Snapping.SelectedLayers,
                                                  self)

        self._snappingModeActionGroup = QActionGroup(self)
        self._snappingModeActionGroup.addAction(self._currentAction)
        self._snappingModeActionGroup.addAction(self._allAction)
        self._snappingModeActionGroup.addAction(self._selectedAction)

        self._vertexAction = ProjectSnappingTypeAction(Snapping.Vertex, self)
        self._segmentAction = ProjectSnappingTypeAction(Snapping.Segment, self)
        self._vertexSegmentAction = ProjectSnappingTypeAction(
            Snapping.VertexAndSegment, self)

        self._snappingTypeActionGroup = QActionGroup(self)
        self._snappingTypeActionGroup.addAction(self._vertexAction)
        self._snappingTypeActionGroup.addAction(self._segmentAction)
        self._snappingTypeActionGroup.addAction(self._vertexSegmentAction)

        self._pixelUnitsAction = ProjectSnappingUnitAction(
            Snapping.Pixels, self)
        self._layerUnitsAction = ProjectSnappingUnitAction(
            Snapping.LayerUnits, self)
        self._projectUnitsAction = ProjectSnappingUnitAction(
            Snapping.ProjectUnits, self)

        self._unitTypeActionGroup = QActionGroup(self)
        self._unitTypeActionGroup.addAction(self._pixelUnitsAction)
        self._unitTypeActionGroup.addAction(self._layerUnitsAction)
        self._unitTypeActionGroup.addAction(self._projectUnitsAction)

        self._toleranceAction = ProjectSnappingToleranceAction(parent)

        menu = ControlMenu(parent)
        menu.addActions(self._snappingModeActionGroup.actions())
        menu.addSeparator()
        menu.addActions(self._snappingTypeActionGroup.actions())
        menu.addSeparator()
        menu.addAction(self._toleranceAction)
        menu.addActions(self._unitTypeActionGroup.actions())
        self.setMenu(menu)

        self._refreshAction()

        # Make sure we catch changes in the main snapping dialog
        QgsProject.instance().snapSettingsChanged.connect(self._refreshAction)