Example #1
0
 def initGui(self):
     self.action = QAction(QIcon(os.path.dirname(__file__) + '/button.png'),
                           'Convert CSV files from ODK Collect', self.main)
     self.action.setStatusTip('Convert CSV files from ODK Collect')
     self.action.triggered.connect(self.run)
     self.iface.addToolBarIcon(self.action)
Example #2
0
    def _init_ui(self):
        namesBox = gui.vBox(self.controlArea, "Names")

        hbox = gui.hBox(namesBox, margin=0, spacing=0)
        gui.lineEdit(hbox, self, "attr1", "Variable X: ",
                     controlWidth=80, orientation=Qt.Horizontal,
                     enterPlaceholder=True, callback=self._attr_name_changed)
        gui.separator(hbox, 18)
        hbox = gui.hBox(namesBox, margin=0, spacing=0)
        attr2 = gui.lineEdit(hbox, self, "attr2", "Variable Y: ",
                             controlWidth=80, orientation=Qt.Horizontal,
                             enterPlaceholder=True,
                             callback=self._attr_name_changed)
        gui.checkBox(hbox, self, "hasAttr2", '', disables=attr2,
                     labelWidth=0,
                     callback=self.set_dimensions)
        gui.separator(namesBox)

        gui.widgetLabel(namesBox, "Labels")
        self.classValuesView = listView = QListView(
            selectionMode=QListView.SingleSelection,
            sizePolicy=QSizePolicy(QSizePolicy.Ignored,
                                   QSizePolicy.Maximum)
        )
        listView.setModel(self.class_model)
        itemmodels.select_row(listView, 0)
        namesBox.layout().addWidget(listView)

        self.addClassLabel = QAction(
            "+", self,
            toolTip="Add new class label",
            triggered=self.add_new_class_label
        )

        self.removeClassLabel = QAction(
            unicodedata.lookup("MINUS SIGN"), self,
            toolTip="Remove selected class label",
            triggered=self.remove_selected_class_label
        )

        actionsWidget = itemmodels.ModelActionsWidget(
            [self.addClassLabel, self.removeClassLabel], self
        )
        actionsWidget.layout().addStretch(10)
        actionsWidget.layout().setSpacing(1)
        namesBox.layout().addWidget(actionsWidget)

        tBox = gui.vBox(self.controlArea, "Tools", addSpace=True)
        buttonBox = gui.hBox(tBox)
        toolsBox = gui.widgetBox(buttonBox, orientation=QtGui.QGridLayout())

        self.toolActions = QtGui.QActionGroup(self)
        self.toolActions.setExclusive(True)
        self.toolButtons = []

        for i, (name, tooltip, tool, icon) in enumerate(self.TOOLS):
            action = QAction(
                name, self,
                toolTip=tooltip,
                checkable=tool.checkable,
                icon=QIcon(icon),
            )
            action.triggered.connect(partial(self.set_current_tool, tool))

            button = QtGui.QToolButton(
                iconSize=QSize(24, 24),
                toolButtonStyle=Qt.ToolButtonTextUnderIcon,
                sizePolicy=QSizePolicy(QSizePolicy.MinimumExpanding,
                                       QSizePolicy.Fixed)
            )
            button.setDefaultAction(action)
            self.toolButtons.append((button, tool))

            toolsBox.layout().addWidget(button, i / 3, i % 3)
            self.toolActions.addAction(action)

        for column in range(3):
            toolsBox.layout().setColumnMinimumWidth(column, 10)
            toolsBox.layout().setColumnStretch(column, 1)

        undo = self.undo_stack.createUndoAction(self)
        redo = self.undo_stack.createRedoAction(self)

        undo.setShortcut(QtGui.QKeySequence.Undo)
        redo.setShortcut(QtGui.QKeySequence.Redo)

        self.addActions([undo, redo])

        gui.separator(tBox)
        indBox = gui.indentedBox(tBox, sep=8)
        form = QtGui.QFormLayout(
            formAlignment=Qt.AlignLeft,
            labelAlignment=Qt.AlignLeft,
            fieldGrowthPolicy=QtGui.QFormLayout.AllNonFixedFieldsGrow
        )
        indBox.layout().addLayout(form)
        slider = gui.hSlider(
            indBox, self, "brushRadius", minValue=1, maxValue=100,
            createLabel=False
        )
        form.addRow("Radius:", slider)

        slider = gui.hSlider(
            indBox, self, "density", None, minValue=1, maxValue=100,
            createLabel=False
        )

        form.addRow("Intensity:", slider)
        self.btResetToInput = gui.button(
            tBox, self, "Reset to Input Data", self.reset_to_input)
        self.btResetToInput.setDisabled(True)

        gui.rubber(self.controlArea)
        gui.auto_commit(self.left_side, self, "autocommit",
                        "Send")

        # main area GUI
        viewbox = PaintViewBox(enableMouse=False)
        self.plotview = pg.PlotWidget(background="w", viewBox=viewbox)
        self.plotview.sizeHint = lambda: QSize(200, 100)  # Minimum size for 1-d painting
        self.plot = self.plotview.getPlotItem()

        axis_color = self.palette().color(QtGui.QPalette.Text)
        axis_pen = QtGui.QPen(axis_color)

        tickfont = QtGui.QFont(self.font())
        tickfont.setPixelSize(max(int(tickfont.pixelSize() * 2 // 3), 11))

        axis = self.plot.getAxis("bottom")
        axis.setLabel(self.attr1)
        axis.setPen(axis_pen)
        axis.setTickFont(tickfont)

        axis = self.plot.getAxis("left")
        axis.setLabel(self.attr2)
        axis.setPen(axis_pen)
        axis.setTickFont(tickfont)
        if not self.hasAttr2:
            self.plot.hideAxis('left')

        self.plot.hideButtons()
        self.plot.setXRange(0, 1, padding=0.01)

        self.mainArea.layout().addWidget(self.plotview)

        # enable brush tool
        self.toolActions.actions()[0].setChecked(True)
        self.set_current_tool(self.TOOLS[0][2])

        self.set_dimensions()
Example #3
0
    def __init__(self, neditable):
        super(Editor, self).__init__()
        self._neditable = neditable

        # QScintilla Configuration
        self._configure_qscintilla()

        # Markers
        self.foldable_lines = []
        self.breakpoints = []
        self.bookmarks = []
        self._fold_expanded_marker = 1
        self._fold_collapsed_marker = 2
        self._bookmark_marker = 3
        self._breakpoint_marker = 4
        self.setMarginSensitivity(1, True)
        self.connect(self,
                     SIGNAL('marginClicked(int, int, Qt::KeyboardModifiers)'),
                     self.on_margin_clicked)
        color_fore = resources.get_color("FoldArea")
        # Marker Fold Expanded
        self.markerDefine(QsciScintilla.DownTriangle,
                          self._fold_expanded_marker)
        color = resources.get_color("FoldArrowExpanded")
        self.setMarkerBackgroundColor(QColor(color),
                                      self._fold_expanded_marker)
        self.setMarkerForegroundColor(QColor(color_fore),
                                      self._fold_expanded_marker)
        # Marker Fold Collapsed
        self.markerDefine(QsciScintilla.RightTriangle,
                          self._fold_collapsed_marker)
        color = resources.get_color("FoldArrowCollapsed")
        self.setMarkerBackgroundColor(QColor(color),
                                      self._fold_collapsed_marker)
        self.setMarkerForegroundColor(QColor(color_fore),
                                      self._fold_collapsed_marker)
        # Marker Breakpoint
        self.markerDefine(QsciScintilla.Circle, self._breakpoint_marker)
        self.setMarkerBackgroundColor(QColor(255, 11, 11),
                                      self._breakpoint_marker)
        self.setMarkerForegroundColor(QColor(color_fore),
                                      self._breakpoint_marker)
        # Marker Bookmark
        self.markerDefine(QsciScintilla.SmallRectangle, self._bookmark_marker)
        self.setMarkerBackgroundColor(QColor(10, 158, 227),
                                      self._bookmark_marker)
        self.setMarkerForegroundColor(QColor(color_fore),
                                      self._bookmark_marker)
        # Configure key bindings
        self._configure_keybindings()

        self.lexer = highlighter.get_lexer(self._neditable.extension())

        if self.lexer is not None:
            self.setLexer(self.lexer)

        #Config Editor
        self._mini = None
        if settings.SHOW_MINIMAP:
            self._load_minimap(settings.SHOW_MINIMAP)
        self._last_block_position = 0
        self.set_flags()
        #FIXME this lang should be guessed in the same form as lexer.
        self.lang = highlighter.get_lang(self._neditable.extension())
        self._cursor_line = self._cursor_index = -1
        self.__lines_count = 0
        self.pos_margin = 0
        self._indentation_guide = 0
        self._indent = 0
        self.__font = None
        self.__encoding = None

        #FIXME these should be language bound
        self.allows_less_indentation = ['else', 'elif', 'finally', 'except']
        self.set_font(settings.FONT)
        self._selected_word = ''
        self._patIsWord = re.compile('\w+')
        #Completer
        #self.completer = completer_widget.CodeCompletionWidget(self)
        #Dict functions for KeyPress
        self.preKeyPress = {
            Qt.Key_Backspace: self.__backspace,
            Qt.Key_Enter: self.__ignore_extended_line,
            Qt.Key_Return: self.__ignore_extended_line,
            #Qt.Key_Colon: self.__retreat_to_keywords,
            Qt.Key_BracketRight: self.__brace_completion,
            Qt.Key_BraceRight: self.__brace_completion,
            Qt.Key_ParenRight: self.__brace_completion,
            Qt.Key_Apostrophe: self.__quot_completion,
            Qt.Key_QuoteDbl: self.__quot_completion
        }

        self.postKeyPress = {
            Qt.Key_Enter: self.__auto_indent,
            Qt.Key_Return: self.__auto_indent,
            Qt.Key_BracketLeft: self.__complete_braces,
            Qt.Key_BraceLeft: self.__complete_braces,
            Qt.Key_ParenLeft: self.__complete_braces,
            Qt.Key_Apostrophe: self.__complete_quotes,
            Qt.Key_QuoteDbl: self.__complete_quotes
        }

        self.connect(self, SIGNAL("linesChanged()"), self._update_sidebar)
        self.connect(self, SIGNAL("blockCountChanged(int)"),
                     self._update_file_metadata)

        self.load_project_config()
        #Context Menu Options
        self.__actionFindOccurrences = QAction(self.tr("Find Usages"), self)
        self.connect(self.__actionFindOccurrences, SIGNAL("triggered()"),
                     self._find_occurrences)

        ninjaide = IDE.get_service('ide')
        self.connect(ninjaide,
                     SIGNAL("ns_preferences_editor_font(PyQt_PyObject)"),
                     self.set_font)
        self.connect(
            ninjaide,
            SIGNAL("ns_preferences_editor_showTabsAndSpaces(PyQt_PyObject)"),
            self.set_flags)
        #TODO: figure it out it doesn´t work if gets shown after init
        ##self.connect(ninjaide,
        ##SIGNAL("ns_preferences_editor_minimapShow(PyQt_PyObject)"),
        ##self._load_minimap)
        self.connect(ninjaide,
                     SIGNAL("ns_preferences_editor_indent(PyQt_PyObject)"),
                     self.load_project_config)
        self.connect(ninjaide,
                     SIGNAL("ns_preferences_editor_marginLine(PyQt_PyObject)"),
                     self._set_margin_line)
        self.connect(
            ninjaide,
            SIGNAL("ns_preferences_editor_showLineNumbers(PyQt_PyObject)"),
            self._show_line_numbers)
        #self.connect(
        #ninjaide,
        #SIGNAL("ns_preferences_editor_scheme(PyQt_PyObject)"),
        #self.restyle)
        #self.connect(
        #ninjaide,
        #SIGNAL("ns_preferences_editor_scheme(PyQt_PyObject)"),
        #lambda: self.restyle())

        self.additional_builtins = None
        # Set the editor after initialization
        if self._neditable.editor:
            self.setDocument(self._neditable.document)
        else:
            self._neditable.set_editor(self)

        if self._neditable.file_path in settings.BREAKPOINTS:
            self.breakpoints = settings.BREAKPOINTS[self._neditable.file_path]
        if self._neditable.file_path in settings.BOOKMARKS:
            self.bookmarks = settings.BOOKMARKS[self._neditable.file_path]
        # Add breakpoints
        for line in self.breakpoints:
            self.markerAdd(line, self._breakpoint_marker)
        # Add bookmarks
        for line in self.bookmarks:
            self.markerAdd(line, self._bookmark_marker)

        self.connect(self._neditable, SIGNAL("checkersUpdated(PyQt_PyObject)"),
                     self._highlight_checkers)
Example #4
0
    def addNewAction(self,
                     iconPath,
                     text,
                     callback=None,
                     enabled=True,
                     checkable=False,
                     addToMenu=True,
                     addToToolbar=True,
                     tip=None,
                     whatsThis=None,
                     parent=None):
        """Add a toolbar icon to the toolbar.

        :param iconPath: Path to the icon for this action. Can be a resource
            path (e.g. ':/plugins/foo/bar.png') or a normal file system path.
        :type iconPath: str

        :param text: Text that should be shown in menu items for this action.
        :type text: str

        :param callback: Function to be called when the action is triggered.
        :type callback: function

        :param enabled: A flag indicating if the action should be enabled
            by default. Defaults to True.
        :type enabled: bool

        :param checkable: A flag indicating if the action should be checkable
            by default. Defaults to False.
        :type chenckable: bool

        :param addToMenu: Flag indicating whether the action should also
            be added to the plugin menu. Defaults to True.
        :type addToMenu: bool

        :param addToToolbar: Flag indicating whether the action should also
            be added to the plugin toolbar. Defaults to True.
        :type addToToolbar: bool

        :param tip: Optional text to show in a popup when mouse pointer
            hovers over the action.
        :type tip: str

        :param whatsThis: Optional text to show in the status bar when the
            mouse pointer hovers over the action.

        :param parent: Parent widget for the new action. Defaults None.
        :type parent: QWidget

        :returns: The action that was created. Note that the action is also
            added to self._actions list.
        :rtype: QAction
        """

        if parent is None:
            parent = self.iface.mainWindow()
        action = QAction(QIcon(iconPath), text, parent)
        if tip is not None:
            action.setStatusTip(tip)
        if whatsThis is not None:
            action.setWhatsThis(whatsThis)

        if callback is not None:
            action.triggered.connect(callback)
        action.setEnabled(enabled)
        action.setCheckable(checkable)

        self.addAction(action, addToMenu, addToToolbar)
        return action
Example #5
0
    def __init__(self, parent=None):
        super(MainWidget,
              self).__init__(parent,
                             windowTitle='GithubRemote',
                             windowIcon=QIcon(image_path('git.png')),
                             geometry=QRect(300, 300, 600, 372))

        self.repo_pixmap = QPixmap(image_path('book_16.png'))
        self.big_repo_pixmap = QPixmap(image_path('book_32.png'))
        self.repo_fork_pixmap = QPixmap(image_path('book_fork_16.png'))
        self.star_pixmap = QPixmap(image_path('star_16.png'))
        self.big_star_pixmap = QPixmap(image_path('star_32.png'))
        self.fork_pixmap = QPixmap(image_path('fork_16.png'))
        self.eye_pixmap = QPixmap(image_path('eye_16.png'))

        self.github = None

        # Actions

        self.repoAddAction = QAction(QIcon(image_path('plus_48.png')),
                                     '&Add Repo',
                                     self,
                                     statusTip='Add a new repo')
        self.repoAddAction.triggered.connect(self.repoAdd)

        self.repoRemoveAction = QAction(QIcon(image_path('minus.png')),
                                        '&Remove Repo',
                                        self,
                                        statusTip='Remove repo')
        self.repoRemoveAction.triggered.connect(self.repoRemove)

        self.repoRefreshAction = QAction(QIcon(image_path('refresh.png')),
                                         'Refresh',
                                         self,
                                         statusTip='Refresh list of repos')
        self.repoRefreshAction.triggered.connect(self.reposRefresh)
        self.repoRefreshAction.triggered.connect(self.starsRefresh)

        self.addAccountAction = QAction('Add Account',
                                        self,
                                        statusTip='Add Account')
        self.addAccountAction.triggered.connect(self.addAccount)

        # userPushButton - Displays the current active username and
        # image on the top right of the toolbar.

        self.userButtonMenu = UserButtonMenu(32, 32)

        # ToolBar

        self.toolBar = self.addToolBar('Main')
        self.toolBar.setMovable(False)
        self.toolBar.setFloatable(False)
        spacer = QWidget()
        spacer.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        self.toolBar.addAction(self.repoAddAction)
        self.toolBar.addAction(self.repoRemoveAction)
        self.toolBar.addAction(self.repoRefreshAction)
        self.toolBar.addWidget(spacer)
        self.toolBar.addWidget(self.userButtonMenu)

        # Menu

        menuBar = self.menuBar()
        fileMenu = menuBar.addMenu('&File')
        actionMenu = menuBar.addMenu('&Action')
        fileMenu.addAction(self.addAccountAction)
        actionMenu.addAction(self.repoAddAction)
        actionMenu.addAction(self.repoRemoveAction)
        actionMenu.addAction(self.repoRefreshAction)

        # StatusBar

        statusBar = self.statusBar()
        self.setStatusBar(statusBar)

        # reposTableWidget - Displays a list of the users repositories

        self.reposTableWidget = QTableWidget(
            0,
            5,
            selectionBehavior=QAbstractItemView.SelectRows,
            selectionMode=QAbstractItemView.SingleSelection,
            editTriggers=QAbstractItemView.NoEditTriggers,
            itemSelectionChanged=self.actionsUpdate)
        self.reposTableWidget.horizontalHeader().setResizeMode(
            QHeaderView.ResizeToContents)
        self.reposTableWidget.horizontalHeader().setResizeMode(
            1, QHeaderView.Stretch)
        self.reposTableWidget.horizontalHeader().setVisible(False)
        self.reposTableWidget.verticalHeader().setVisible(False)
        self.reposTableWidget.setShowGrid(False)
        self.reposTableWidget.verticalHeader().setMinimumSectionSize(25)

        # repoTab - Layout
        reposTab = QWidget()
        reposTabLayout = QVBoxLayout(reposTab)
        reposTabLayout.addWidget(self.reposTableWidget)
        reposTab.setLayout(reposTabLayout)

        # starsTableWidget - Displays a list of the users repositories

        self.starsTableWidget = QTableWidget(
            0,
            5,
            selectionBehavior=QAbstractItemView.SelectRows,
            selectionMode=QAbstractItemView.SingleSelection,
            editTriggers=QAbstractItemView.NoEditTriggers,
            itemSelectionChanged=self.actionsUpdate)
        self.starsTableWidget.horizontalHeader().setResizeMode(
            QHeaderView.ResizeToContents)
        self.starsTableWidget.horizontalHeader().setResizeMode(
            1, QHeaderView.Stretch)
        self.starsTableWidget.horizontalHeader().setVisible(False)
        self.starsTableWidget.verticalHeader().setVisible(False)
        self.starsTableWidget.setShowGrid(False)
        self.starsTableWidget.verticalHeader().setMinimumSectionSize(25)

        # repoTab - Layout
        starsTab = QWidget()
        starsTabLayout = QVBoxLayout(starsTab)
        starsTabLayout.addWidget(self.starsTableWidget)
        starsTab.setLayout(starsTabLayout)

        # Tab Widget
        self.tabs = QTabWidget()
        self.tabs.setTabBar(FlippedTabBar(self))
        self.tabs.addTab(reposTab, QIcon(self.big_repo_pixmap), "repos")
        self.tabs.addTab(starsTab, QIcon(self.big_star_pixmap), "stars")
        self.tabs.setTabPosition(QTabWidget.West)

        # Layout

        self.setCentralWidget(self.tabs)
        self.actionsUpdate()
        self.show()

        # Update

        self.loadUserMenu()
        if self.activeUserAction:
            self.activeUserAction.setVisible(False)
        self.authenticate()
        self.actionsUpdate()
        self.reposRefresh()
        self.starsRefresh()
        self.updateImage()
Example #6
0
    def action(self):
        saveTemplateAct = QAction(QIcon(":/plugins/stdm/images/icons/save_tb.png"), \
                                  QApplication.translate("SaveTemplateConfig", "Save document template"),
                                  self.composerView())

        return saveTemplateAct
Example #7
0
    def action(self):
        manageTemplatesAct = QAction(QIcon(":/plugins/stdm/images/icons/manage_templates.png"), \
                                     QApplication.translate("ManageTemplatesConfig", "Manage document templates"),
                                     self.composerView())

        return manageTemplatesAct
Example #8
0
if (len(sys.argv) <= 1 or sys.argv[1] != "debug"):
    #I don't know how to redirect output to /dev/null so just make a tmp file until I figure out
    logfile = open("/dev/null", "w")
    sys.stdout = logfile

app = QApplication(sys.argv)
app.setQuitOnLastWindowClosed(True)
window = myMainWindow()
icon = QIcon(":/pics/pic.jpg")
window.setWindowIcon(icon)
window.setWindowTitle("Leopard Flower firewall")
window.show()

tray = QSystemTrayIcon(icon)
menu = QMenu()
actionShow = QAction("Show Leopard Flower", menu)
actionExit = QAction("Exit", menu)
menu.addAction(actionShow)
menu.addAction(actionExit)
tray.setContextMenu(menu)
tray.show()
actionShow.triggered.connect(window.show)
actionExit.triggered.connect(window.realQuit)

modelAll = QStandardItemModel()
modelAll.setHorizontalHeaderLabels(
    ("Name", "Process ID", "Permissions", "Full path", "Incoming allowed",
     "Outgoing allowed", "Incoming denied", "Outgoing denied"))
modelActive = QStandardItemModel()
modelActive.setHorizontalHeaderLabels(
    ("Name", "Process ID", "Permissions", "Full path", "Incoming allowed",
Example #9
0
 def addMenuItem(self):
     """ Adds hook to the the appropriate menu """
     QAction("Start speech control", self)
     self.initSphynx = initSphynx
Example #10
0
    def __init__(self):
        super(FreeseerApp, self).__init__()
        self.icon = QIcon()
        self.icon.addPixmap(QPixmap(_fromUtf8(":/freeseer/logo.png")), QIcon.Normal, QIcon.Off)
        self.setWindowIcon(self.icon)

        self.aboutDialog = AboutDialog()
        self.aboutDialog.setModal(True)

        #
        # Translator
        #
        self.app = QApplication.instance()
        self.current_language = None
        self.uiTranslator = QTranslator()
        self.uiTranslator.load(":/languages/tr_en_US.qm")
        self.app.installTranslator(self.uiTranslator)
        self.langActionGroup = QActionGroup(self)
        self.langActionGroup.setExclusive(True)
        QTextCodec.setCodecForTr(QTextCodec.codecForName('utf-8'))
        self.connect(self.langActionGroup, SIGNAL('triggered(QAction *)'), self.translate)
        # --- Translator

        #
        # Setup Menubar
        #
        self.menubar = self.menuBar()

        self.menubar.setGeometry(QRect(0, 0, 500, 50))
        self.menubar.setObjectName(_fromUtf8("menubar"))
        self.menuFile = QMenu(self.menubar)
        self.menuFile.setObjectName(_fromUtf8("menuFile"))
        self.menuLanguage = QMenu(self.menubar)
        self.menuLanguage.setObjectName(_fromUtf8("menuLanguage"))
        self.menuHelp = QMenu(self.menubar)
        self.menuHelp.setObjectName(_fromUtf8("menuHelp"))

        exitIcon = QIcon.fromTheme("application-exit")
        self.actionExit = QAction(self)
        self.actionExit.setShortcut("Ctrl+Q")
        self.actionExit.setObjectName(_fromUtf8("actionExit"))
        self.actionExit.setIcon(exitIcon)

        helpIcon = QIcon.fromTheme("help-contents")
        self.actionOnlineHelp = QAction(self)
        self.actionOnlineHelp.setObjectName(_fromUtf8("actionOnlineHelp"))
        self.actionOnlineHelp.setIcon(helpIcon)

        self.actionAbout = QAction(self)
        self.actionAbout.setObjectName(_fromUtf8("actionAbout"))
        self.actionAbout.setIcon(self.icon)

        # Actions
        self.menuFile.addAction(self.actionExit)
        self.menuHelp.addAction(self.actionAbout)
        self.menuHelp.addAction(self.actionOnlineHelp)
        self.menubar.addAction(self.menuFile.menuAction())
        self.menubar.addAction(self.menuLanguage.menuAction())
        self.menubar.addAction(self.menuHelp.menuAction())

        self.setupLanguageMenu()
        # --- End Menubar

        self.connect(self.actionExit, SIGNAL('triggered()'), self.close)
        self.connect(self.actionAbout, SIGNAL('triggered()'), self.aboutDialog.show)
        self.connect(self.actionOnlineHelp, SIGNAL('triggered()'), self.openOnlineHelp)

        self.retranslateFreeseerApp()
        self.aboutDialog.retranslate("en_US")
Example #11
0
    def createActions(self, parent):
        self.edit_cut_assign = QAction(parent)
        self.view_highlighting = QAction(parent)
        self.view_highlighting.setCheckable(True)
        self.view_goto_file_or_definition = QAction(parent)
        self.tools_indent_auto = QAction(parent)
        self.tools_indent_auto.setCheckable(True)
        self.tools_indent_indent = QAction(parent)
        self.tools_reformat = QAction(parent)
        self.tools_remove_trailing_whitespace = QAction(parent)
        self.tools_convert_ly = QAction(parent)
        self.tools_quick_remove_comments = QAction(parent)
        self.tools_quick_remove_articulations = QAction(parent)
        self.tools_quick_remove_ornaments = QAction(parent)
        self.tools_quick_remove_instrument_scripts = QAction(parent)
        self.tools_quick_remove_slurs = QAction(parent)
        self.tools_quick_remove_dynamics = QAction(parent)
        self.tools_quick_remove_fingerings = QAction(parent)
        self.tools_quick_remove_markup = QAction(parent)

        self.edit_cut_assign.setIcon(icons.get('edit-cut'))

        self.view_goto_file_or_definition.setShortcut(
            QKeySequence(Qt.ALT + Qt.Key_Return))
        self.edit_cut_assign.setShortcut(
            QKeySequence(Qt.SHIFT + Qt.CTRL + Qt.Key_X))
Example #12
0
    def __createLayout(self, scriptName, name, code, reportTime):
        " Creates the toolbar and layout "

        # Buttons
        self.__printButton = QAction(PixmapCache().getIcon('printer.png'),
                                     'Print', self)
        self.__printButton.triggered.connect(self.__onPrint)
        self.__printButton.setEnabled(False)
        self.__printButton.setVisible(False)

        self.__printPreviewButton = QAction(
            PixmapCache().getIcon('printpreview.png'), 'Print preview', self)
        self.__printPreviewButton.triggered.connect(self.__onPrintPreview)
        self.__printPreviewButton.setEnabled(False)
        self.__printPreviewButton.setVisible(False)

        # Zoom buttons
        self.__zoomInButton = QAction(PixmapCache().getIcon('zoomin.png'),
                                      'Zoom in (Ctrl+=)', self)
        self.__zoomInButton.triggered.connect(self.onZoomIn)

        self.__zoomOutButton = QAction(PixmapCache().getIcon('zoomout.png'),
                                       'Zoom out (Ctrl+-)', self)
        self.__zoomOutButton.triggered.connect(self.onZoomOut)

        self.__zoomResetButton = QAction(
            PixmapCache().getIcon('zoomreset.png'), 'Zoom reset (Ctrl+0)',
            self)
        self.__zoomResetButton.triggered.connect(self.onZoomReset)

        spacer = QWidget()
        spacer.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)

        # Toolbar
        toolbar = QToolBar(self)
        toolbar.setOrientation(Qt.Vertical)
        toolbar.setMovable(False)
        toolbar.setAllowedAreas(Qt.RightToolBarArea)
        toolbar.setIconSize(QSize(16, 16))
        toolbar.setFixedWidth(28)
        toolbar.setContentsMargins(0, 0, 0, 0)

        toolbar.addAction(self.__printPreviewButton)
        toolbar.addAction(self.__printButton)
        toolbar.addWidget(spacer)
        toolbar.addAction(self.__zoomInButton)
        toolbar.addAction(self.__zoomOutButton)
        toolbar.addAction(self.__zoomResetButton)

        summary = QLabel("<b>Script:</b> " + scriptName + "<br>"
                         "<b>Name:</b> " + name + "<br>"
                         "<b>Disassembled at:</b> " + reportTime)
        summary.setFrameStyle(QFrame.StyledPanel)
        summary.setAutoFillBackground(True)
        summaryPalette = summary.palette()
        summaryBackground = summaryPalette.color(QPalette.Background)
        summaryBackground.setRgb(min(summaryBackground.red() + 30, 255),
                                 min(summaryBackground.green() + 30, 255),
                                 min(summaryBackground.blue() + 30, 255))
        summaryPalette.setColor(QPalette.Background, summaryBackground)
        summary.setPalette(summaryPalette)

        self.__text = DisasmWidget(self)
        self.__text.setAcceptRichText(False)
        self.__text.setLineWrapMode(QTextEdit.NoWrap)
        self.__text.setFont(GlobalData().skin.nolexerFont)
        self.zoomTo(Settings().zoom)
        self.__text.setReadOnly(True)
        self.__text.setPlainText(code)

        vLayout = QVBoxLayout()
        vLayout.addWidget(summary)
        vLayout.addWidget(self.__text)

        hLayout = QHBoxLayout()
        hLayout.setContentsMargins(0, 0, 0, 0)
        hLayout.setSpacing(0)
        hLayout.addLayout(vLayout)
        hLayout.addWidget(toolbar)

        self.setLayout(hLayout)
        return
Example #13
0
    def __init__(self, filename, project):
        QPlainTextEdit.__init__(self)
        itab_item.ITabItem.__init__(self)
        #Config Editor
        self.set_flags()
        self.__lines_count = None

        self._sidebarWidget = sidebar_widget.SidebarWidget(self)
        if filename in settings.BREAKPOINTS:
            self._sidebarWidget._breakpoints = settings.BREAKPOINTS[filename]
        if filename in settings.BOOKMARKS:
            self._sidebarWidget._bookmarks = settings.BOOKMARKS[filename]
        self.pep8 = pep8_checker.Pep8Checker(self)
        self.errors = errors_checker.ErrorsChecker(self)

        self.textModified = False
        self.newDocument = True
        self.highlighter = None
        self.syncDocErrorsSignal = False
        self._selected_word = ''
        #Set editor style
        self.apply_editor_style()
        self.set_font(settings.FONT_FAMILY, settings.FONT_SIZE)
        #For Highlighting in document
        self.extraSelections = []
        self.wordSelection = []
        self._patIsWord = re.compile('\w+')
        #Brace matching
        self._braces = None
        self._mtime = None
        self.__encoding = None
        #Completer
        self.completer = completer_widget.CodeCompletionWidget(self)
        #Flag to dont bug the user when answer *the modification dialog*
        self.ask_if_externally_modified = False
        #Dict functions for KeyPress
        self.preKeyPress = {
            Qt.Key_Tab: self.__insert_indentation,
            Qt.Key_Backspace: self.__backspace,
            Qt.Key_Home: self.__home_pressed,
            Qt.Key_Enter: self.__ignore_extended_line,
            Qt.Key_Return: self.__ignore_extended_line,
            Qt.Key_BracketRight: self.__brace_completion,
            Qt.Key_BraceRight: self.__brace_completion,
            Qt.Key_ParenRight: self.__brace_completion,
            Qt.Key_Apostrophe: self.__quot_completion,
            Qt.Key_QuoteDbl: self.__quot_completion
        }

        self.postKeyPress = {
            Qt.Key_Enter: self.__auto_indent,
            Qt.Key_Return: self.__auto_indent,
            Qt.Key_BracketLeft: self.__complete_braces,
            Qt.Key_BraceLeft: self.__complete_braces,
            Qt.Key_ParenLeft: self.__complete_braces,
            Qt.Key_Apostrophe: self.__complete_quotes,
            Qt.Key_QuoteDbl: self.__complete_quotes
        }

        self.connect(self, SIGNAL("updateRequest(const QRect&, int)"),
                     self._sidebarWidget.update_area)
        self.connect(self, SIGNAL("undoAvailable(bool)"), self._file_saved)
        self.connect(self, SIGNAL("cursorPositionChanged()"),
                     self.highlight_current_line)
        self.connect(self.pep8, SIGNAL("finished()"), self.show_pep8_errors)
        self.connect(self.errors, SIGNAL("finished()"),
                     self.show_static_errors)
        self.connect(self, SIGNAL("blockCountChanged(int)"),
                     self._update_file_metadata)

        self._mini = None
        if settings.SHOW_MINIMAP:
            self._mini = minimap.MiniMap(self)
            self._mini.show()
            self.connect(self, SIGNAL("updateRequest(const QRect&, int)"),
                         self._mini.update_visible_area)
        #Set tab usage
        if settings.USE_TABS:
            self.set_tab_usage()

        #Context Menu Options
        self.__actionFindOccurrences = QAction(self.tr("Find Usages"), self)
        self.connect(self.__actionFindOccurrences, SIGNAL("triggered()"),
                     self._find_occurrences)
Example #14
0
    def registerDatabaseActions(self, mainWindow):
        action = QAction(
            QApplication.translate("DBManagerPlugin", "&Re-connect"), self)
        mainWindow.registerAction(
            action, QApplication.translate("DBManagerPlugin", "&Database"),
            self.reconnectActionSlot)

        if self.schemas() is not None:
            action = QAction(
                QApplication.translate("DBManagerPlugin", "&Create schema"),
                self)
            mainWindow.registerAction(
                action, QApplication.translate("DBManagerPlugin", "&Schema"),
                self.createSchemaActionSlot)
            action = QAction(
                QApplication.translate("DBManagerPlugin",
                                       "&Delete (empty) schema"), self)
            mainWindow.registerAction(
                action, QApplication.translate("DBManagerPlugin", "&Schema"),
                self.deleteSchemaActionSlot)

        action = QAction(
            QApplication.translate("DBManagerPlugin", "Delete selected item"),
            self)
        mainWindow.registerAction(action, None, self.deleteActionSlot)
        action.setShortcuts(QKeySequence.Delete)

        action = QAction(
            QIcon(":/db_manager/actions/create_table"),
            QApplication.translate("DBManagerPlugin", "&Create table"), self)
        mainWindow.registerAction(
            action, QApplication.translate("DBManagerPlugin", "&Table"),
            self.createTableActionSlot)
        action = QAction(
            QIcon(":/db_manager/actions/edit_table"),
            QApplication.translate("DBManagerPlugin", "&Edit table"), self)
        mainWindow.registerAction(
            action, QApplication.translate("DBManagerPlugin", "&Table"),
            self.editTableActionSlot)
        action = QAction(
            QIcon(":/db_manager/actions/del_table"),
            QApplication.translate("DBManagerPlugin", "&Delete table/view"),
            self)
        mainWindow.registerAction(
            action, QApplication.translate("DBManagerPlugin", "&Table"),
            self.deleteTableActionSlot)
        action = QAction(
            QApplication.translate("DBManagerPlugin", "&Empty table"), self)
        mainWindow.registerAction(
            action, QApplication.translate("DBManagerPlugin", "&Table"),
            self.emptyTableActionSlot)

        if self.schemas() is not None:
            action = QAction(
                QApplication.translate("DBManagerPlugin", "&Move to schema"),
                self)
            action.setMenu(QMenu(mainWindow))
            invoke_callback = lambda: mainWindow.invokeCallback(
                self.prepareMenuMoveTableToSchemaActionSlot)
            QObject.connect(action.menu(), SIGNAL("aboutToShow()"),
                            invoke_callback)
            mainWindow.registerAction(
                action, QApplication.translate("DBManagerPlugin", "&Table"))
Example #15
0
    def action(self):
        qrcode_act = QAction(QIcon(":/plugins/stdm/images/icons/qrcode.png"), \
                             QApplication.translate("QRCodeConfig", "Add QR Code"), self.composerView())

        return qrcode_act
Example #16
0
 def _add_spacer_to_menu(self):
     """Create a spacer to the menu to separate action groups."""
     separator = QAction(self.iface.mainWindow())
     separator.setSeparator(True)
     self.iface.addPluginToMenu(self.tr('InaSAFE'), separator)
Example #17
0
    def action(self):
        separatorAct = QAction(self.composerView())
        separatorAct.setSeparator(True)

        return separatorAct
Example #18
0
    def action(self):
        lineAct = QAction(QIcon(":/plugins/stdm/images/icons/line.png"), \
                          QApplication.translate("LineItemConfig", "Add line"), self.composerView())

        return lineAct
Example #19
0
    def action(self):
        openTemplateAct = QAction(QIcon(":/plugins/stdm/images/icons/open_file.png"), \
                                  QApplication.translate("OpenTemplateConfig", "Open document template"),
                                  self.composerView())

        return openTemplateAct
Example #20
0
    def action(self):
        dataLabelAct = QAction(QIcon(":/plugins/stdm/images/icons/db_field.png"), \
                               QApplication.translate("DataLabelConfig", "Add data label"), self.composerView())

        return dataLabelAct
Example #21
0
 def initialize(self, *args, **kwargs):
     " Init Main Class "
     super(Main, self).initialize(*args, **kwargs)
     self.locator.get_service("menuApp").add_action(
         QAction(QIcon.fromTheme("edit-select-all"),
                 "Create Setup.py",
                 self,
                 triggered=lambda: self.get_dialog()))
     self.dialog, self.group0 = QDialog(), QGroupBox()
     self.group0.setTitle(' Setup.py Creator ')
     self.pkgname, self.version = QLineEdit(), QDoubleSpinBox()
     self.urlproj, self.licence = QLineEdit('https://www.'), QLineEdit(
         'GPL')
     self.authors, self.emails = QLineEdit(
         getuser()), QLineEdit('@mail.com')
     self.descrip, self.button = QLineEdit(), QPushButton('Make Setup.py !')
     self.choices, self.indents = QComboBox(), QSpinBox()
     self.metada = QCheckBox('Use SheBang and Metadata')
     self.nosetest = QCheckBox('Use Nose Tests Framework integration')
     self.metada.setChecked(True)
     self.chckbx1 = QCheckBox('Copy output to ClipBoard when done')
     self.choices.addItems(
         ['from distutils.core import setup', 'import distutils.core'])
     self.indents.setValue(4)
     self.indents.setMaximum(8)
     self.indents.setMinimum(0)
     self.indents.setSingleStep(2)
     self.version.setValue(0.1)
     self.version.setMinimum(0.1)
     self.version.setDecimals(1)
     self.version.setSingleStep(0.1)
     self.button.setMinimumSize(400, 50)
     self.button.clicked.connect(self.make_setupy)
     glow = QGraphicsDropShadowEffect(self)
     glow.setOffset(0)
     glow.setBlurRadius(99)
     glow.setColor(QColor(99, 255, 255))
     self.button.setGraphicsEffect(glow)
     inf = QLabel(
         '''<a href="http://guide.python-distribute.org/future.html"
               ><center><i>INFO: This is Deprecated Legacy Packaging.</a>'''
     )
     inf.setTextInteractionFlags(Qt.LinksAccessibleByMouse)
     inf.setOpenExternalLinks(True)
     vboxg0 = QVBoxLayout(self.group0)
     for each_widget in (QLabel('<b>Package Name'), self.pkgname,
                         QLabel('<b>Version'),
                         self.version, QLabel('<b>URL'), self.urlproj,
                         QLabel('<b>Licence'), self.licence,
                         QLabel('<b>Author'), self.authors,
                         QLabel('<b>Mail'), self.emails,
                         QLabel('<b>Description'), self.descrip,
                         QLabel('<b>Imports'), self.choices,
                         QLabel('<b>Indentation Spaces '), self.indents,
                         self.metada, self.chckbx1, self.nosetest, inf,
                         QLabel('<center><small><i>{}'.format(HELPMSG)),
                         self.button):
         vboxg0.addWidget(each_widget)
         try:
             each_widget.setToolTip(each_widget.text())
         except:
             pass
     QVBoxLayout(self.dialog).addWidget(self.group0)
Example #22
0
    def action(self):
        tb_act = QAction(QIcon(":/plugins/stdm/images/icons/composer_table.png"), \
                         QApplication.translate("TableConfig", "Add attribute table"), self.composerView())

        return tb_act
Example #23
0
    def __init__(self, parent=None, signalManager=None):
        OWWidget.__init__(self, parent, signalManager, 'Python Script')

        self.inputs = [
            ("in_data", Orange.data.Table, self.setExampleTable, Default),
            ("in_distance", Orange.misc.SymMatrix, self.setDistanceMatrix,
             Default),
            ("in_learner", Orange.core.Learner, self.setLearner, Default),
            ("in_classifier", Orange.core.Classifier, self.setClassifier,
             Default), ("in_object", object, self.setObject)
        ]

        self.outputs = [("out_data", Orange.data.Table),
                        ("out_distance", Orange.misc.SymMatrix),
                        ("out_learner", Orange.core.Learner),
                        ("out_classifier", Orange.core.Classifier, Dynamic),
                        ("out_object", object, Dynamic)]

        self.in_data = None
        self.in_distance = None
        self.in_learner = None
        self.in_classifier = None
        self.in_object = None
        self.auto_execute = False

        self.codeFile = ''
        self.libraryListSource = [
            Script("Hello world", "print 'Hello world'\n")
        ]
        self.currentScriptIndex = 0
        self.splitterState = None
        self.loadSettings()

        for s in self.libraryListSource:
            s.flags = 0

        self._cachedDocuments = {}

        self.infoBox = OWGUI.widgetBox(self.controlArea, 'Info')
        OWGUI.label(
            self.infoBox, self,
            "<p>Execute python script.</p><p>Input variables:<ul><li> " + \
            "<li>".join(t[0] for t in self.inputs) + \
            "</ul></p><p>Output variables:<ul><li>" + \
            "<li>".join(t[0] for t in self.outputs) + \
            "</ul></p>"
        )

        self.libraryList = PyListModel([], self, flags=Qt.ItemIsSelectable | \
                                       Qt.ItemIsEnabled | Qt.ItemIsEditable)

        self.libraryList.wrap(self.libraryListSource)

        self.controlBox = OWGUI.widgetBox(self.controlArea, 'Library')
        self.controlBox.layout().setSpacing(1)

        self.libraryView = QListView()
        self.libraryView.setEditTriggers(QListView.DoubleClicked | \
                                         QListView.EditKeyPressed)
        self.libraryView.setSizePolicy(QSizePolicy.Ignored,
                                       QSizePolicy.Preferred)
        self.libraryView.setItemDelegate(ScriptItemDelegate(self))
        self.libraryView.setModel(self.libraryList)

        self.connect(
            self.libraryView.selectionModel(),
            SIGNAL("selectionChanged(QItemSelection, QItemSelection)"),
            self.onSelectedScriptChanged)
        self.controlBox.layout().addWidget(self.libraryView)

        w = ModelActionsWidget()

        self.addNewScriptAction = action = QAction("+", self)
        action.setToolTip("Add a new script to the library")
        self.connect(action, SIGNAL("triggered()"), self.onAddScript)
        w.addAction(action)

        self.removeAction = action = QAction("-", self)
        action.setToolTip("Remove script from library")
        self.connect(action, SIGNAL("triggered()"), self.onRemoveScript)
        w.addAction(action)

        action = QAction("Update", self)
        action.setToolTip("Save changes in the editor to library")
        action.setShortcut(QKeySequence(QKeySequence.Save))
        self.connect(action, SIGNAL("triggered()"),
                     self.commitChangesToLibrary)
        w.addAction(action)

        action = QAction("More", self)
        action.pyqtConfigure(toolTip="More actions")

        new_from_file = QAction("Import a script from a file", self)
        save_to_file = QAction("Save selected script to a file", self)
        save_to_file.setShortcut(QKeySequence(QKeySequence.SaveAs))

        self.connect(new_from_file, SIGNAL("triggered()"),
                     self.onAddScriptFromFile)
        self.connect(save_to_file, SIGNAL("triggered()"), self.saveScript)

        menu = QMenu(w)
        menu.addAction(new_from_file)
        menu.addAction(save_to_file)
        action.setMenu(menu)
        button = w.addAction(action)
        button.setPopupMode(QToolButton.InstantPopup)

        w.layout().setSpacing(1)

        self.controlBox.layout().addWidget(w)

        self.runBox = OWGUI.widgetBox(self.controlArea, 'Run')
        OWGUI.button(self.runBox, self, "Execute", callback=self.execute)
        OWGUI.checkBox(self.runBox,
                       self,
                       "auto_execute",
                       "Auto execute",
                       tooltip=("Run the script automatically whenever "
                                "the inputs to the widget change."))

        self.splitCanvas = QSplitter(Qt.Vertical, self.mainArea)
        self.mainArea.layout().addWidget(self.splitCanvas)

        self.defaultFont = defaultFont = \
            "Monaco" if sys.platform == "darwin" else "Courier"

        self.textBox = OWGUI.widgetBox(self, 'Python script')
        self.splitCanvas.addWidget(self.textBox)
        self.text = PythonScriptEditor(self)
        self.textBox.layout().addWidget(self.text)

        self.textBox.setAlignment(Qt.AlignVCenter)
        self.text.setTabStopWidth(4)

        self.connect(self.text, SIGNAL("modificationChanged(bool)"),
                     self.onModificationChanged)

        self.saveAction = action = QAction("&Save", self.text)
        action.setToolTip("Save script to file")
        action.setShortcut(QKeySequence(QKeySequence.Save))
        action.setShortcutContext(Qt.WidgetWithChildrenShortcut)
        self.connect(action, SIGNAL("triggered()"), self.saveScript)

        self.consoleBox = OWGUI.widgetBox(self, 'Console')
        self.splitCanvas.addWidget(self.consoleBox)
        self.console = PythonConsole(self.__dict__, self)
        self.consoleBox.layout().addWidget(self.console)
        self.console.document().setDefaultFont(QFont(defaultFont))
        self.consoleBox.setAlignment(Qt.AlignBottom)
        self.console.setTabStopWidth(4)

        self.openScript(self.codeFile)
        try:
            self.libraryView.selectionModel().select(
                self.libraryList.index(self.currentScriptIndex),
                QItemSelectionModel.ClearAndSelect)
        except Exception:
            pass

        self.splitCanvas.setSizes([2, 1])
        if self.splitterState is not None:
            self.splitCanvas.restoreState(QByteArray(self.splitterState))

        self.connect(self.splitCanvas, SIGNAL("splitterMoved(int, int)"),
                     self.onSpliterMoved)
        self.controlArea.layout().addStretch(1)
        self.resize(800, 600)
Example #24
0
    def action(self):
        mapAct = QAction(QIcon(":/plugins/stdm/images/icons/add_map.png"), \
                         QApplication.translate("MapConfig", "Add map"), self.composerView())

        return mapAct
Example #25
0
    def __init__(self):
        super().__init__()

        self.in_data = None
        self.in_distance = None
        self.in_learner = None
        self.in_classifier = None
        self.in_object_1 = None
        self.in_object_2 = None
        self.in_object_3 = None
        self.in_object_4 = None
        self.in_object_5 = None
        self.in_object_6 = None
        self.in_object_7 = None
        self.in_object_8 = None
        self.in_object_9 = None
        self.in_object_10 = None

        # MODIFIED BY LUCA REBUFFI 14/10/2014
        #self.auto_execute = False

        for s in self.libraryListSource:
            s.flags = 0

        self._cachedDocuments = {}

        self.infoBox = gui.widgetBox(self.controlArea, 'Info')
        gui.label(
            self.infoBox, self,
            "<p>Execute python script.</p><p>Input variables:<ul><li> " + \
            "<li>".join([self.inputs[0].name, ".",".",".", self.inputs[-1].name]) + \
            "</ul></p><p>Output variables:<ul><li>" + \
            "<li>".join(t.name for t in self.outputs) + \
            "</ul></p>"
        )

        self.optionBox = oasysgui.widgetBox(self.controlArea, 'Options')

        gui.comboBox(self.optionBox,
                     self,
                     "font_size",
                     label="Font Size",
                     labelWidth=120,
                     items=self.fonts,
                     sendSelectedValue=False,
                     orientation="horizontal",
                     callback=self.changeFont)

        self.libraryList = itemmodels.PyListModel(
            [],
            self,
            flags=Qt.ItemIsSelectable | Qt.ItemIsEnabled | Qt.ItemIsEditable)

        self.libraryList.wrap(self.libraryListSource)

        self.controlBox = gui.widgetBox(self.controlArea, 'Library')
        self.controlBox.layout().setSpacing(1)

        self.libraryView = QListView(
            editTriggers=QListView.DoubleClicked | QListView.EditKeyPressed,
            sizePolicy=QSizePolicy(QSizePolicy.Ignored, QSizePolicy.Preferred))
        self.libraryView.setItemDelegate(ScriptItemDelegate(self))
        self.libraryView.setModel(self.libraryList)

        self.libraryView.selectionModel().selectionChanged.connect(
            self.onSelectedScriptChanged)
        self.controlBox.layout().addWidget(self.libraryView)

        w = itemmodels.ModelActionsWidget()

        self.addNewScriptAction = action = QAction("+", self)
        action.setToolTip("Add a new script to the library")
        action.triggered.connect(self.onAddScript)
        w.addAction(action)

        action = QAction(unicodedata.lookup("MINUS SIGN"), self)
        action.setToolTip("Remove script from library")
        action.triggered.connect(self.onRemoveScript)
        w.addAction(action)

        action = QAction("Update", self)
        action.setToolTip("Save changes in the editor to library")
        action.setShortcut(QKeySequence(QKeySequence.Save))
        action.triggered.connect(self.commitChangesToLibrary)
        w.addAction(action)

        action = QAction("More", self, toolTip="More actions")

        new_from_file = QAction("Import a script from a file", self)
        save_to_file = QAction("Save selected script to a file", self)
        save_to_file.setShortcut(QKeySequence(QKeySequence.SaveAs))

        new_from_file.triggered.connect(self.onAddScriptFromFile)
        save_to_file.triggered.connect(self.saveScript)

        menu = QMenu(w)
        menu.addAction(new_from_file)
        menu.addAction(save_to_file)
        action.setMenu(menu)
        button = w.addAction(action)
        button.setPopupMode(QToolButton.InstantPopup)

        w.layout().setSpacing(1)

        self.controlBox.layout().addWidget(w)

        self.runBox = gui.widgetBox(self.controlArea, 'Run')
        gui.button(self.runBox, self, "Execute", callback=self.execute)
        gui.checkBox(self.runBox,
                     self,
                     "auto_execute",
                     "Auto execute",
                     tooltip="Run the script automatically whenever " +
                     "the inputs to the widget change.")

        self.splitCanvas = QSplitter(Qt.Vertical, self.mainArea)
        self.mainArea.layout().addWidget(self.splitCanvas)

        self.defaultFont = defaultFont = \
            "Monaco" if sys.platform == "darwin" else "Courier"

        self.textBox = gui.widgetBox(self, 'Python script')
        self.splitCanvas.addWidget(self.textBox)
        self.text = PythonScriptEditor(self)
        self.textBox.layout().addWidget(self.text)

        self.textBox.setAlignment(Qt.AlignVCenter)
        self.text.setTabStopWidth(4)

        self.text.modificationChanged[bool].connect(self.onModificationChanged)

        self.saveAction = action = QAction("&Save", self.text)
        action.setToolTip("Save script to file")
        action.setShortcut(QKeySequence(QKeySequence.Save))
        action.setShortcutContext(Qt.WidgetWithChildrenShortcut)
        action.triggered.connect(self.saveScript)

        self.consoleBox = gui.widgetBox(self, 'Console')
        self.splitCanvas.addWidget(self.consoleBox)
        self.console = PythonConsole(self.__dict__, self)
        self.consoleBox.layout().addWidget(self.console)
        self.console.document().setDefaultFont(QFont(defaultFont))
        self.consoleBox.setAlignment(Qt.AlignBottom)
        self.console.setTabStopWidth(4)

        select_row(self.libraryView, self.currentScriptIndex)

        self.splitCanvas.setSizes([2, 1])
        if self.splitterState is not None:
            self.splitCanvas.restoreState(QByteArray(self.splitterState))

        self.splitCanvas.splitterMoved[int, int].connect(self.onSpliterMoved)
        self.controlArea.layout().addStretch(1)
        self.resize(800, 600)

        self.changeFont()
Example #26
0
    def action(self):
        ph_act = QAction(QIcon(":/plugins/stdm/images/icons/photo_24.png"), \
                         QApplication.translate("PhotoConfig", "Add photo"), self.composerView())

        return ph_act
Example #27
0
    def __init__(self, parent=None):
        super(ViewDataToolsHistory, self).__init__(parent)

        # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        # DATATOOLS HISTORY WINDOWS:
        # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        self.setWindowTitle(ui_strings.DATATOOLS_HISTORY_TITLE)
        self._width = 700
        self._height = 380
        self._left_margin = 10
        self.resize(self._width, self._height)
        size_policy = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
        size_policy.setHorizontalStretch(0)
        size_policy.setVerticalStretch(0)
        size_policy.setHeightForWidth(self.sizePolicy().hasHeightForWidth())
        self.setSizePolicy(size_policy)
        self.setMinimumSize(QtCore.QSize(self._width, self._height))
        self.setMaximumSize(QtCore.QSize(self._width, self._height))
        self.setWindowIcon(QIcon(resources.ICON_LOGO))

        # central widget
        self.central_widget = QWidget(self)

        # toolbar
        # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        # add toolbar options
        self.export_action = QAction(QIcon(resources.ICON_EXPORT),
                                     'Export (Ctrl+E)', self)
        self.export_action.setShortcut('Ctrl+E')

        self.print_action = QAction(QIcon(resources.ICON_PRINT),
                                    'Print (Ctrl+P)', self)
        self.print_action.setShortcut('Ctrl+P')

        self.toolbar = self.addToolBar('Options')
        self.toolbar.addAction(self.export_action)
        self.toolbar.addAction(self.print_action)
        # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

        # group input files
        self.group_period = QGroupBox(self.central_widget)
        self.group_period.setGeometry(
            QtCore.QRect(self._left_margin, 10, 250, 50))
        self.group_period.setTitle(ui_strings.DATATOOLS_HISTORY_FILTER)

        # group by:
        self.group_group_by = QGroupBox(self.central_widget)
        self.group_group_by.setGeometry(QtCore.QRect(270, 10, 250, 50))
        self.group_group_by.setTitle(ui_strings.DATATOOLS_HISTORY_GROUP)

        # group by: errors
        self.rbtn_by_errors = QRadioButton(
            ui_strings.DATATOOLS_HISTORY_GROUP_ERROR, self.group_group_by)
        self.rbtn_by_errors.setGeometry(QtCore.QRect(10, 10, 80, 50))

        # group by: status
        #self.group_by_status = QRadioButton(ui_strings.DATATOOLS_HISTORY_GROUP_STATUS, self.group_group_by)
        #self.group_by_status.setGeometry(QtCore.QRect(100, 10, 80, 50))

        # group by: no group
        #self.group_by_no = QRadioButton(ui_strings.DATATOOLS_HISTORY_GROUP_NO, self.group_group_by)
        #self.group_by_no.setGeometry(QtCore.QRect(190, 10, 80, 50))

        # push button to update table
        #self.btn_view_group = QPushButton(self.group_group_by)
        #self.btn_view_group.setGeometry(QtCore.QRect(160, 20, 50, 20))
        #self.btn_view_group.setText(ui_strings.DATATOOLS_HISTORY_VIEW)

        # combobox periods
        self.cbo_period = QComboBox(self.group_period)
        self.cbo_period.setGeometry(
            QtCore.QRect(self._left_margin, 20, 130, 20))

        # push button to update table
        #self.btn_view = QPushButton(self.group_period)
        #self.btn_view.setGeometry(QtCore.QRect(160, 20, 50, 20))
        #self.btn_view.setText(ui_strings.DATATOOLS_HISTORY_VIEW)

        # table history
        self.tbl_uploads = QTableWidget(self.central_widget)
        self.tbl_uploads.setGeometry(
            QtCore.QRect(self._left_margin, 70, 680, 120))

        # chart
        self.plot_widget = PlotWidget(self.central_widget, 8, 2)
        self.plot_widget.setGeometry(
            QtCore.QRect(self._left_margin, 200, 680, 130))

        # records - "x records found"

        self.setCentralWidget(self.central_widget)
Example #28
0
    def action(self):
        chart_act = QAction(QIcon(":/plugins/stdm/images/icons/chart.png"), \
                            QApplication.translate("ChartConfig", "Add chart"), self.composerView())

        return chart_act
Example #29
0
    def add_action(self,
                   icon_path,
                   text,
                   callback,
                   enabled_flag=True,
                   add_to_menu=True,
                   add_to_toolbar=True,
                   status_tip=None,
                   whats_this=None,
                   parent=None):
        """Add a toolbar icon to the toolbar.

        :param icon_path: Path to the icon for this action. Can be a resource
            path (e.g. ':/plugins/foo/bar.png') or a normal file system path.
        :type icon_path: str

        :param text: Text that should be shown in menu items for this action.
        :type text: str

        :param callback: Function to be called when the action is triggered.
        :type callback: function

        :param enabled_flag: A flag indicating if the action should be enabled
            by default. Defaults to True.
        :type enabled_flag: bool

        :param add_to_menu: Flag indicating whether the action should also
            be added to the menu. Defaults to True.
        :type add_to_menu: bool

        :param add_to_toolbar: Flag indicating whether the action should also
            be added to the toolbar. Defaults to True.
        :type add_to_toolbar: bool

        :param status_tip: Optional text to show in a popup when mouse pointer
            hovers over the action.
        :type status_tip: str

        :param parent: Parent widget for the new action. Defaults None.
        :type parent: QWidget

        :param whats_this: Optional text to show in the status bar when the
            mouse pointer hovers over the action.

        :returns: The action that was created. Note that the action is also
            added to self.actions list.
        :rtype: QAction
        """

        icon = QIcon(icon_path)
        action = QAction(icon, text, parent)
        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 add_to_menu:
            self.iface.addPluginToMenu(self.menu, action)

        self.actions.append(action)

        return action
Example #30
0
    def __createRecentProjectsLayout(self):
        " Creates the bottom layout "
        self.headerFrame = QFrame()
        self.headerFrame.setFrameStyle(QFrame.StyledPanel)
        self.headerFrame.setAutoFillBackground(True)
        headerPalette = self.headerFrame.palette()
        headerBackground = headerPalette.color(QPalette.Background)
        headerBackground.setRgb(min(headerBackground.red() + 30, 255),
                                min(headerBackground.green() + 30, 255),
                                min(headerBackground.blue() + 30, 255))
        headerPalette.setColor(QPalette.Background, headerBackground)
        self.headerFrame.setPalette(headerPalette)
        self.headerFrame.setFixedHeight(24)

        recentProjectsLabel = QLabel()
        recentProjectsLabel.setText("Recent projects")

        expandingSpacer = QSpacerItem(10, 10, QSizePolicy.Expanding)

        self.__showHideButton = QToolButton()
        self.__showHideButton.setAutoRaise(True)
        self.__showHideButton.setIcon(getIcon('less.png'))
        self.__showHideButton.setFixedSize(20, 20)
        self.__showHideButton.setToolTip("Hide recent projects list")
        self.__showHideButton.setFocusPolicy(Qt.NoFocus)
        self.connect(self.__showHideButton, SIGNAL('clicked()'),
                     self.__onShowHide)

        headerLayout = QHBoxLayout()
        headerLayout.setContentsMargins(3, 0, 0, 0)
        headerLayout.addWidget(recentProjectsLabel)
        headerLayout.addSpacerItem(expandingSpacer)
        headerLayout.addWidget(self.__showHideButton)
        self.headerFrame.setLayout(headerLayout)

        # Toolbar part - buttons
        self.loadButton = QAction(getIcon('load.png'),
                                  'Load the highlighted project', self)
        self.connect(self.loadButton, SIGNAL("triggered()"),
                     self.__loadProject)
        self.propertiesButton = QAction(
            getIcon('smalli.png'), 'Show the highlighted project '
            'properties', self)
        self.connect(self.propertiesButton, SIGNAL("triggered()"),
                     self.__viewProperties)
        self.copyPrjPathButton = QAction(getIcon('copytoclipboard.png'),
                                         'Copy path to clipboard', self)
        self.connect(self.copyPrjPathButton, SIGNAL("triggered()"),
                     self.__prjPathToClipboard)
        spacer = QWidget()
        spacer.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        self.trashButton = QAction(getIcon('delitem.png'),
                                   'Remove selected (not from the disk)', self)
        self.connect(self.trashButton, SIGNAL("triggered()"),
                     self.__deleteProject)

        self.lowerToolbar = QToolBar()
        self.lowerToolbar.setMovable(False)
        self.lowerToolbar.setAllowedAreas(Qt.TopToolBarArea)
        self.lowerToolbar.setIconSize(QSize(16, 16))
        self.lowerToolbar.setFixedHeight(28)
        self.lowerToolbar.setContentsMargins(0, 0, 0, 0)
        self.lowerToolbar.addAction(self.loadButton)
        self.lowerToolbar.addAction(self.propertiesButton)
        self.lowerToolbar.addAction(self.copyPrjPathButton)
        self.lowerToolbar.addWidget(spacer)
        self.lowerToolbar.addAction(self.trashButton)

        self.projectsView = QTreeWidget()
        self.projectsView.setAlternatingRowColors(True)
        self.projectsView.setRootIsDecorated(False)
        self.projectsView.setItemsExpandable(False)
        self.projectsView.setSortingEnabled(True)
        self.projectsView.setItemDelegate(NoOutlineHeightDelegate(4))
        self.projectsView.setUniformRowHeights(True)

        self.__projectsHeaderItem = QTreeWidgetItem(
            ["", "Project", "Absolute path"])
        self.projectsView.setHeaderItem(self.__projectsHeaderItem)

        self.projectsView.header().setSortIndicator(1, Qt.AscendingOrder)
        self.connect(self.projectsView,
                     SIGNAL("itemActivated(QTreeWidgetItem *, int)"),
                     self.__projectActivated)
        self.connect(self.projectsView, SIGNAL("itemSelectionChanged()"),
                     self.__projectSelectionChanged)

        recentProjectsLayout = QVBoxLayout()
        recentProjectsLayout.setContentsMargins(0, 0, 0, 0)
        recentProjectsLayout.setSpacing(0)
        recentProjectsLayout.addWidget(self.headerFrame)
        recentProjectsLayout.addWidget(self.lowerToolbar)
        recentProjectsLayout.addWidget(self.projectsView)

        lowerContainer = QWidget()
        lowerContainer.setContentsMargins(0, 0, 0, 0)
        lowerContainer.setLayout(recentProjectsLayout)
        return lowerContainer