Exemplo n.º 1
0
def getDataDir():
    if isOSX():
        return os.path.join(unicode(QDesktopServices.storageLocation(QDesktopServices.DataLocation)), "Pesterchum/")
    elif isLinux():
        return os.path.join(unicode(QDesktopServices.storageLocation(QDesktopServices.HomeLocation)), ".pesterchum/")
    else:
        return os.path.join(unicode(QDesktopServices.storageLocation(QDesktopServices.DataLocation)), "pesterchum/")
Exemplo n.º 2
0
 def on_player_finished(self, ret):
     if ret != 0:
         reply = QMessageBox.question(
             self, 'Player Crashed!', 'Open URL in browser?',
             QMessageBox.Yes | QMessageBox.No, QMessageBox.Yes)
         if reply == QMessageBox.Yes:
             QDesktopServices.openUrl(QUrl(self.player.url))
Exemplo n.º 3
0
 def openformfolder(self, url):
     """
     Open the form folder using the OS file manager.
     :param url:
     :return:
     """
     QDesktopServices.openUrl(QUrl.fromLocalFile(self.form.folder))
Exemplo n.º 4
0
 def on_update_finished(self, ret):
     if ret:
         reply = QMessageBox.question(
             self, 'New Version Available', 'Do you want to download new version?',
             QMessageBox.Yes | QMessageBox.No, QMessageBox.Yes)
         if reply == QMessageBox.Yes:
             QDesktopServices.openUrl(QUrl("http://crtaci.rs"))
Exemplo n.º 5
0
 def setup(self, parent=None, caption=str("Sélectionnez")) :
     self.setFileMode(self.ExistingFiles)
     icon = QtGui.QIcon()
     icon.addPixmap(QtGui.QPixmap(_fromUtf8("resources/PL128.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off)
     self.setWindowIcon(icon)
     mydir = str(os.environ['USERPROFILE'])
     thedir = QDir("C:/")
     self.setDirectory(thedir)
     url = []
     url.append(QUrl.fromLocalFile(QDesktopServices.storageLocation(QDesktopServices.DocumentsLocation)))
     url.append(QUrl.fromLocalFile(QDesktopServices.storageLocation(QDesktopServices.DesktopLocation)))
     url.append(QUrl.fromLocalFile(QDesktopServices.storageLocation(QDesktopServices.HomeLocation)))
     url.append(QUrl('file:'))
     self.setSidebarUrls(url)
     # self.setDirectory(mydir)
     self.setWindowModality(QtCore.Qt.ApplicationModal)
     MyFileDialog.setNameFilter(self, "Epub (*.epub)")
     self.setLabelText(self.LookIn, "Regarder dans :")
     self.setLabelText(self.FileName, "Fichier")
     self.setLabelText(self.FileType, "Type de fichier")
     self.setLabelText(self.Accept, "Ouvrir")
     self.setLabelText(self.Reject, "Annuler")
     self.setWindowTitle("Sélectionnez un ou plusieurs fichiers")
     self.setOption(self.DontUseNativeDialog, False)
     # self.setOption(self.DontResolveSymlinks, True)
     self.setOption(self.ShowDirsOnly, False)
     self.tree = self.findChild(QtGui.QTreeView)
     self.init_ui()
     self.filesSelected.connect(self.cur_change)
     self.filesSelected.connect(self.choose_file)
Exemplo n.º 6
0
 def send_email(self):
     url = u"mailto:%s?subject=%s&body=%s\n\n%s" % (
         settings.BUG_REPORT_EMAIL, 
         settings.BUG_REPORT_EMAIL_SUBJECT,
         unicode(self.report_text.toPlainText()),
         unicode(self.traceback_text.toPlainText()))
     QDesktopServices.openUrl(QUrl(url))
Exemplo n.º 7
0
 def open_map_features():
     """
     Open MapFeatures
     """
     desktop_service = QDesktopServices()
     desktop_service.openUrl(
         QUrl("http://wiki.openstreetmap.org/wiki/Mapfeatures"))
Exemplo n.º 8
0
    def linkClicked(self, qurl):
        '''three kinds of link:
            external uri: http/https
            page ref link:
            toc anchor link: #
        '''
        name = qurl.toString()
        http = re.compile('https?://')
        if http.match(name):                        # external uri
            QDesktopServices.openUrl(qurl)
            return

        self.load(qurl)
        name = name.replace('file://', '')
        name = name.replace(self.notePath, '').split('#')
        item = self.parent.notesTree.pageToItem(name[0])
        if not item or item == self.parent.notesTree.currentItem():
            return
        else:
            self.parent.notesTree.setCurrentItem(item)
            if len(name) > 1:
                link = "file://" + self.notePath + "/#" + name[1]
                self.load(QUrl(link))
            viewFrame = self.page().mainFrame()
            self.scrollPosition = viewFrame.scrollPosition()
Exemplo n.º 9
0
 def openLink(self, url):
     if url.toString() == "log":
         self.close()
         logDock =  iface.mainWindow().findChild(QDockWidget, 'MessageLog')
         logDock.show()
     else:
         QDesktopServices.openUrl(url)
 def _showHelp(self):
     help_path = os.path.join(
         PagLuxembourg.main.plugin_dir,
         'help',
         'user',
         'index.html')
     QDesktopServices.openUrl(QUrl('file:///' + help_path, QUrl.TolerantMode))
Exemplo n.º 11
0
 def gotoTatoeba(self):
     stIndex = self.getSentenceIndex()
     if stIndex == None:
         return
     iid = stIndex.sibling(stIndex.row(), 6).data().toString()
     url = QtCore.QUrl("http://tatoeba.org/eng/sentences/show/" + iid)
     QDesktopServices.openUrl(url)
Exemplo n.º 12
0
 def onHelp(self):
     helpPath = Utils.getHelpPath()
     if helpPath == '':
         url = QUrl("http://www.gdal.org/" + self.helpFileName)
     else:
         url = QUrl.fromLocalFile(helpPath + '/' + self.helpFileName)
     QDesktopServices.openUrl(url)
Exemplo n.º 13
0
Arquivo: tb.py Projeto: flupke/pyflu
def install_ext_editor_url_handler():
    """
    Install the URL handler that opens the external editor from traceback
    links.
    """
    QDesktopServices.setUrlHandler(ext_edit_protocol,
            dummy_receiver.open_external_editor)
    def select_output_file(self):
		if self.dlg.rbSTLASCII.isChecked() or self.dlg.rbSTLbinary.isChecked():
			filename = QFileDialog.getSaveFileName(self.dlg, "Select output file ", QDesktopServices.storageLocation(QDesktopServices.DocumentsLocation) , '*.stl')
			self.dlg.lineEdit.setText(filename)
		elif self.dlg.rbTXT.isChecked():
			filename = QFileDialog.getSaveFileName(self.dlg, "Select output file ", QDesktopServices.storageLocation(QDesktopServices.DocumentsLocation) , '*.txt')
			self.dlg.lineEdit.setText(filename)
Exemplo n.º 15
0
    def showOnCuzk(self):
        x = self.vfkBrowser.currentDefinitionPoint().first.split(".")[0]
        y = self.vfkBrowser.currentDefinitionPoint().second.split(".")[0]

        url = "http://nahlizenidokn.cuzk.cz/MapaIdentifikace.aspx?&x=-{}&y=-{}".format(
            y, x)
        QDesktopServices.openUrl(QUrl(url, QUrl.TolerantMode))
Exemplo n.º 16
0
    def onDoubleClick(self):
        currentItem = self.getView().currentItem()

        if currentItem is None:
            return

        # We don't want to make an API request when we're
        # hiding a directory's contents
        if currentItem.isDirectory():
#            if currentItem.isExpanded():
#                #currentItem.setExpanded(False)
            mainView = AppController.getInstance().getMainView()
            mainView.statusBar().showMessage(i18n.LABEL_BLOOPTREE_STATUS_BAR_REQUESTING_FILES)

            #self.hireWorker(self.addItems,currentItem)
            self.addItems(currentItem)
            #mainView.showStatusBarDefaultText()            
            return
        
        if currentItem == self.getRootItem():
            from models.mbu_config import meta
            QDesktopServices.openUrl(QUrl("http://" + meta['SERVER'] + "/" + AppController.getInstance().getUserProfile().getUsername()))
            return
        
        data = currentItem.getItemData()

        # If it's the MyBloop root item, return none
        if data is None:
            return

        if data.has_key('fileURL') and data['fileURL'] is not None:
            QDesktopServices.openUrl(QUrl(data['fileURL']))
Exemplo n.º 17
0
 def open_doc_overpass():
     """
     Open Overpass's documentation
     """
     url = "http://wiki.openstreetmap.org/wiki/Overpass_API/Language_Guide"
     desktop_service = QDesktopServices()
     desktop_service.openUrl(QUrl(url))
Exemplo n.º 18
0
    def onDictyExpressLink(self, link):
        if not self.data:
            return

        selectedIndexes = self.treeWidget.selectedIndexes()
        if not len(selectedIndexes):
            QMessageBox.information(
                self, "No gene ids selected",
                "Please select some genes and try again."
            )
            return
        model = self.treeWidget.model()
        mapToSource = model.mapToSource
        selectedRows = self.treeWidget.selectedIndexes()
        selectedRows = [mapToSource(index).row() for index in selectedRows]
        model = model.sourceModel()

        selectedGeneids = [self.row2geneinfo[row] for row in selectedRows]
        selectedIds = [self.geneinfo[i][0] for i in selectedGeneids]
        selectedIds = set(selectedIds)

        def fix(ddb):
            if ddb.startswith("DDB"):
                if not ddb.startswith("DDB_G"):
                    ddb = ddb.replace("DDB", "DDB_G")
                return ddb
            return None

        genes = [fix(gene) for gene in selectedIds if fix(gene)]
        url = str(link) % " ".join(genes)
        QDesktopServices.openUrl(QUrl(url))
Exemplo n.º 19
0
 def show_help(self):
     """Display application help to the user."""
     help_file = 'file:///%s/help/index.html' % self.plugin_builder_path
     # For testing path:
     #QMessageBox.information(None, 'Help File', help_file)
     # noinspection PyCallByClass,PyTypeChecker
     QDesktopServices.openUrl(QUrl(help_file))
Exemplo n.º 20
0
 def show_pos_pressed(self):
     if self.had_fix:
         google_str = self.last_ns + self.make_dd_dddddd(self.last_lat, True) + '+' + self.last_ew + self.make_dd_dddddd(self.last_long, True)
         QDesktopServices.openUrl(QUrl('https://maps.google.com/maps?q=' + google_str))
     else:
         # :-)
         QDesktopServices.openUrl(QUrl('http://www.google.com/moon/'))
Exemplo n.º 21
0
def onClick(url):
        String = unicode(url.toString())
	if String.startswith("py:"):
	        String = String[3:]
	        eval(String)
	else:
	        from PyQt4.QtGui import QDesktopServices
	        QDesktopServices.openUrl(QUrl(url))	
Exemplo n.º 22
0
def openFolder(path):
    import sys
    import subprocess
    
    if sys.platform == "win32":
        subprocess.Popen(["explorer", path.encode(sys.getfilesystemencoding())])
    else:
        QDesktopServices.openUrl(QUrl("file://" + path))
Exemplo n.º 23
0
 def openScriptFileExtEditor(self):
     tabWidget = self.tabEditorWidget.currentWidget()
     path = tabWidget.path
     import subprocess
     try:
         subprocess.Popen([os.environ['EDITOR'], path])
     except KeyError:
         QDesktopServices.openUrl(QUrl.fromLocalFile(path))
Exemplo n.º 24
0
 def _examine_backup(self):
     error = None
     try:
         filename = get_rename_plan_backup_filename()
         QDesktopServices.openUrl(QUrl.fromLocalFile(filename))
     except Exception as err:
         error = err
     finally:
         self._show_backup_decision(error)
Exemplo n.º 25
0
	def __Image_label__linkActivated(self, url):
		"""
		Defines the slot triggered by **Image_label** Widget when a link is clicked.

		:param url: Url to explore.
		:type url: QString
		"""

		QDesktopServices.openUrl(QUrl(url))
Exemplo n.º 26
0
	def __Open_Repository_pushButton__clicked(self, checked):
		"""
		This method is triggered when **Open_Repository_pushButton** Widget is clicked.

		:param checked: Checked state. ( Boolean )
		"""

		LOGGER.debug("> Opening url: '{0}'.".format(self.__repositoryUrl))
		QDesktopServices.openUrl(QUrl(QString(self.__repositoryUrl)))
Exemplo n.º 27
0
    def showhelp2(self):
		"""
        def showHTMLReport(title, html, data={}, parent=None):
            dialog = HtmlViewerDialog(title)
            dialog.showHTML(html, data)
            dialog.exec_()

        showHTMLReport("Help",contentHelp)"""
		QDesktopServices.openUrl(QUrl.fromLocalFile(self.pathHelp))
Exemplo n.º 28
0
    def openURL(self, url):
        from PyQt4.QtGui import QDesktopServices
        from PyQt4.QtCore import QUrl
        from ubiquity.misc import drop_privileges_save, regain_privileges_save

        # this nonsense is needed because kde doesn't want to be root
        drop_privileges_save()
        QDesktopServices.openUrl(QUrl(url))
        regain_privileges_save()
Exemplo n.º 29
0
 def _edit_ui_file(self):
     item = self.currentItem()
     if item.parent() is None:
         pathForFile = item.path
     else:
         pathForFile = os.path.join(item.path, item.text(0))
     pathForFile = "file://%s" % pathForFile
     #open the correct program to edit Qt UI files!
     QDesktopServices.openUrl(QUrl(pathForFile, QUrl.TolerantMode))
Exemplo n.º 30
0
def onClick(url):
        String = unicode(url.toString())
	if String.startswith("py:"):
	        String = String[3:]
	        from ui_menu import JxShowIn,JxShowOut
	        from export import JxAddo, JxDoNothing
	        eval(String)
	else:
	        from PyQt4.QtGui import QDesktopServices
	        QDesktopServices.openUrl(QUrl(url))
Exemplo n.º 31
0
    def run_sketch_line(network, ref):
        """
        Run an action with two values for sketchline

        @param network:network of the bus
        @type network:str
        @param ref:ref of the bus
        @type ref:str
        """

        network = unicode(network, "UTF-8")
        ref = unicode(ref, "UTF-8")

        if network == '' or ref == '':
            iface.messageBar().pushMessage(tr(
                "QuickOSM",
                u"Sorry man, this field is empty for this entity."),
                                           level=QgsMessageBar.WARNING,
                                           duration=7)
        else:
            var = QDesktopServices()
            url = "http://www.overpass-api.de/api/sketch-line?" \
                  "network=" + network + "&ref=" + ref
            var.openUrl(QUrl(url))
Exemplo n.º 32
0
 def editorEvent(self, event, model, option, index):
     if event.type() == QEvent.MouseButtonRelease and index.column() == 0 and index.flags() & Qt.ItemIsUserCheckable:
         toggled = Qt.Checked if model.data(index, Qt.CheckStateRole) == QVariant(Qt.Unchecked) else Qt.Unchecked
         return model.setData(index, toggled, Qt.CheckStateRole)
     __event = QItemDelegate(self).editorEvent(event, model, option, index)
     animate_requested = False
     if event.type() == QEvent.MouseButtonRelease and self.animatable:
         if self.rowAnimator.row == index.row():
             epos = event.pos()
             if self.rowAnimator.hoverLinkFilter.link_rect.contains(QPoint(epos.x(), epos.y() + 32)):
                 url = QUrl(model.data(index, HomepageRole).toString())
                 QDesktopServices.openUrl(url)
                 return __event
             elif self.rowAnimator.hoverLinkFilter.button_rect.contains(epos, True):
                 self.showPackageDetails(model, index)
                 return __event
         animate_requested = True
     elif event.type() == QEvent.KeyPress and self.animatable:
         # KeyCode 32 : Space key
         if event.key() == 32 and index.column() == index.model().columnCount() - 1:
             animate_requested = True
     if not unicode(model.data(index, DescriptionRole).toString()) == '' and animate_requested:
         self.rowAnimator.animate(index.row())
     return __event
Exemplo n.º 33
0
 def _saveKit(self):
     directory = self._scoreDirectory
     if directory is None:
         home = QDesktopServices.HomeLocation
         directory = unicode(QDesktopServices.storageLocation(home))
     fname = QFileDialog.getSaveFileName(parent=self,
                                         caption="Save DrumBurp kit",
                                         directory=directory,
                                         filter=_KIT_FILTER)
     if len(fname) == 0:
         return
     fname = unicode(fname)
     newKit, unused = self.getNewKit()
     DrumKitSerializer.DrumKitSerializer.saveKit(newKit, fname)
     QMessageBox.information(self, "Kit saved",
                             "Successfully saved drumkit")
Exemplo n.º 34
0
    def __init__(self, title='Plugin Editor', default_path=None, parent=None):
        QDockWidget.__init__(self, title, parent)
        self.setupUi()

        self.thread_manager = ThreadManager(self)
        try:
            self.rope_project = codeeditor.get_rope_project()
        except (IOError, AttributeError):  # Might happen when frozen
            self.rope_project = None

        data_path = QDesktopServices.storageLocation(
            QDesktopServices.DataLocation)
        self.default_path = default_path or os.getcwd()
        self.rope_temp_path = os.path.join(data_path, '.temp')
        self.tabs.currentChanged.connect(self._tab_changed)
        self.enter_completion = True
Exemplo n.º 35
0
 def _saveKit(self):
     directory = self._scoreDirectory
     if directory is None:
         home = QDesktopServices.HomeLocation
         directory = unicode(QDesktopServices.storageLocation(home))
     fname = QFileDialog.getSaveFileName(parent = self,
                                         caption = "Save DrumBurp kit",
                                         directory = directory,
                                         filter = _KIT_FILTER)
     if len(fname) == 0:
         return
     fname = unicode(fname)
     newKit, unused = self.getNewKit()
     with open(fname, 'w') as handle:
         indenter = fileUtils.Indenter(handle)
         newKit.write(indenter)
     QMessageBox.information(self, "Kit saved", "Successfully saved drumkit")
Exemplo n.º 36
0
 def _loadKit(self):
     directory = self._scoreDirectory
     if directory is None:
         home = QDesktopServices.HomeLocation
         directory = unicode(QDesktopServices.storageLocation(home))
     fname = QFileDialog.getOpenFileName(parent=self,
                                         caption="Load DrumBurp kit",
                                         directory=directory,
                                         filter=_KIT_FILTER)
     if len(fname) == 0:
         return
     newKit = DrumKitSerializer.DrumKitSerializer.loadKit(fname)
     self._currentKit = list(reversed(newKit))
     self._oldLines.clear()
     for drum in self._currentKit:
         self._oldLines[drum] = -1
     self._populate()
Exemplo n.º 37
0
    def __showMessage(self, message):
        if self.__msgwidget is not None:
            self.__msgwidget.hide()
            self.__msgwidget.deleteLater()
            self.__msgwidget = None

        if message is None:
            return

        buttons = MessageOverlayWidget.Ok | MessageOverlayWidget.Close
        if message.moreurl is not None:
            buttons |= MessageOverlayWidget.Help

        if message.icon is not None:
            icon = message.icon
        else:
            icon = Message.Information

        self.__msgwidget = MessageOverlayWidget(parent=self,
                                                text=message.text,
                                                icon=icon,
                                                wordWrap=True,
                                                standardButtons=buttons)

        btn = self.__msgwidget.button(MessageOverlayWidget.Ok)
        btn.setText("Ok, got it")

        self.__msgwidget.setStyleSheet("""
            MessageOverlayWidget {
                background: qlineargradient(
                    x1: 0, y1: 0, x2: 0, y2: 1,
                    stop:0 #666, stop:0.3 #6D6D6D, stop:1 #666)
            }
            MessageOverlayWidget QLabel#text-label {
                color: white;
            }""")

        if message.moreurl is not None:
            helpbutton = self.__msgwidget.button(MessageOverlayWidget.Help)
            helpbutton.setText("Learn more\N{HORIZONTAL ELLIPSIS}")
            self.__msgwidget.helpRequested.connect(
                lambda: QDesktopServices.openUrl(QUrl(message.moreurl)))

        self.__msgwidget.setWidget(self)
        self.__msgwidget.show()
Exemplo n.º 38
0
    def __init__(self, diskCacheEnabled, ignoreSslErrors, parent=None):
        QNetworkAccessManager.__init__(self, parent)

        self.m_ignoreSslErrors = ignoreSslErrors
        self.m_idCounter = 0
        self.m_ids = {}
        self.m_started = []

        self.finished.connect(self.handleFinished)

        if diskCacheEnabled:
            m_networkDiskCache = QNetworkDiskCache()
            m_networkDiskCache.setCacheDirectory(
                QDesktopServices.storageLocation(
                    QDesktopServices.CacheLocation))
            self.setCache(m_networkDiskCache)

        do_action('NetworkAccessManagerInit')
Exemplo n.º 39
0
 def initGui(self):
     self.actions['showSettings'] = QAction(
         QIcon(":/plugins/quickfinder/icons/settings.svg"),
         self.tr(u"&Settings"), self.iface.mainWindow())
     self.actions['showSettings'].triggered.connect(self.showSettings)
     self.iface.addPluginToMenu(self.name, self.actions['showSettings'])
     self.actions['help'] = QAction(
         QIcon(":/plugins/quickfinder/icons/help.svg"), self.tr("Help"),
         self.iface.mainWindow())
     self.actions['help'].triggered.connect(lambda: QDesktopServices(
     ).openUrl(QUrl("http://3nids.github.io/quickfinder")))
     self.iface.addPluginToMenu(self.name, self.actions['help'])
     self._initToolbar()
     self.rubber = QgsRubberBand(self.iface.mapCanvas())
     self.rubber.setColor(QColor(255, 255, 50, 200))
     self.rubber.setIcon(self.rubber.ICON_CIRCLE)
     self.rubber.setIconSize(15)
     self.rubber.setWidth(4)
     self.rubber.setBrushStyle(Qt.NoBrush)
Exemplo n.º 40
0
 def __init__(self):
     QObject.__init__(self)
     documentsLocation = QDesktopServices.storageLocation(
         QDesktopServices.DocumentsLocation)
     self.databaseFile = os.path.join(documentsLocation, "quickpanel.db")
     self._settings = _Settings(self.databaseFile)
     self.globalKey = GlobalKey()
     self.quickPanel = QuickPanel(self)
     self.actionConfigure = QAction(QIcon(":/images/configure.png"), \
             self.trUtf8("&Configure"), self)
     self.actionExit = QAction(QIcon(":/images/close.png"), \
             self.trUtf8("&Exit"), self)
     self.trayIcon = QSystemTrayIcon(QIcon(":/images/angelfish.png"))
     self.contextMenu = QMenu()
     self.contextMenu.addAction(self.actionConfigure)
     self.contextMenu.addAction(self.actionExit)
     self.trayIcon.setContextMenu(self.contextMenu)
     self.actionConfigure.triggered.connect(self.configure)
     self.actionExit.triggered.connect(self.exit)
     self.trayIcon.activated.connect(self.onTrayIconActivated)
Exemplo n.º 41
0
 def _loadKit(self):
     directory = self._scoreDirectory
     if directory is None:
         home = QDesktopServices.HomeLocation
         directory = unicode(QDesktopServices.storageLocation(home))
     fname = QFileDialog.getOpenFileName(parent = self,
                                         caption = "Load DrumBurp kit",
                                         directory = directory,
                                         filter = _KIT_FILTER)
     if len(fname) == 0:
         return
     with open(fname, 'rU') as handle:
         fileIterator = fileUtils.dbFileIterator(handle)
         newKit = DrumKit.DrumKit()
         newKit.read(fileIterator)
     self._currentKit = list(reversed(newKit))
     self._oldLines.clear()
     for drum in self._currentKit:
         self._oldLines[drum] = -1
     self._populate()
Exemplo n.º 42
0
 def initGui(self):
     # help
     self.helpAction = QAction(
         QIcon(":/plugins/plaingeometryeditor/icons/help.svg"), "Help",
         self.iface.mainWindow())
     self.helpAction.triggered.connect(lambda: QDesktopServices().openUrl(
         QUrl("http://3nids.github.io/plaingeometryeditor")))
     self.iface.addPluginToMenu("&Plain Geometry Editor", self.helpAction)
     # map tool action
     self.mapToolAction = QAction(
         QIcon(
             ":/plugins/plaingeometryeditor/icons/plaingeometryeditor.svg"),
         "Plain Geometry Editor", self.iface.mainWindow())
     self.mapToolAction.setCheckable(True)
     self.mapTool = IdentifyGeometry(self.mapCanvas)
     self.mapTool.geomIdentified.connect(self.editGeometry)
     self.mapTool.setAction(self.mapToolAction)
     self.mapToolAction.triggered.connect(self.setMapTool)
     self.iface.addToolBarIcon(self.mapToolAction)
     self.iface.addPluginToMenu("&Plain Geometry Editor",
                                self.mapToolAction)
Exemplo n.º 43
0
def readSetting(name):
    """Return stored setting value
    """
    settings = QSettings(configFile(), QSettings.IniFormat)
    # ByteArray
    if name in ('geometry', 'state', 'splitter_1Sizes', 'splitter_2Sizes'):
        return settings.value(name)
    elif name == 'images/input_dir':
        return str(settings.value(name,\
                              QDesktopServices.storageLocation(
                              QDesktopServices.DesktopLocation)).toString())
    elif name == 'images/last_filename':
        return str(settings.value(name, r'images/phototest.tif').toString())
    elif name == 'images/zoom_factor':
        return settings.value(name, QVariant(1.0)).toReal()[0]
    elif name == 'language':
        # default value 'eng'
        return str(settings.value(name, 'eng').toString())
    else:
        # Return name value as string or empty string if name does not exist
        return str(settings.value(name, "").toString())
Exemplo n.º 44
0
def openInBrowser(urlPath):
    """
    opens *urlPath* in browser, eg:

    .. pycon::
        emzed.utils.openInBrowser("http://emzed.biol.ethz.ch") !noexec

    """
    from PyQt4.QtGui import QDesktopServices
    from PyQt4.QtCore import QUrl
    import os.path

    url = QUrl(urlPath)
    scheme = url.scheme()
    if scheme not in ["http", "ftp", "mailto"]:
        # C:/ or something simiar:
        if os.path.splitdrive(urlPath)[0] != "":
            url = QUrl("file:///"+urlPath)
    ok = QDesktopServices.openUrl(url)
    if not ok:
        raise Exception("could not open '%s'" % url.toString())
Exemplo n.º 45
0
 def addMusic(self):
     if len(self.__list_music) < 1:
         is_empty = True
     else:
         is_empty = False
     sources = QFileDialog.getOpenFileNames(
         self.__main_window, "Select Music Files",
         QDesktopServices.storageLocation(QDesktopServices.MusicLocation))
     if not sources:
         return
     index = len(self.__list_music)
     for music_file in sources:
         media_source = Phonon.MediaSource(music_file)
         if not self.__is_existing(media_source):
             self.__list_music.append(media_source)
     if is_empty:
         self.__media_object.setCurrentSource(
             self.__list_music[len(self.__list_music) - 1])
     if index == len(self.__list_music):
         return
     if self.__list_music:
         self.__meta_information_resolver.setCurrentSource(
             self.__list_music[index])
Exemplo n.º 46
0
 def _getFileName(self):
     directory = self.filename
     if directory is None:
         suggestion = unicode(self.scoreScene.title)
         if len(suggestion) == 0:
             suggestion = "Untitled"
         suggestion = os.extsep.join([suggestion, "brp"])
         if len(self.recentFiles) > 0:
             directory = os.path.dirname(self.recentFiles[-1])
         else:
             home = QDesktopServices.HomeLocation
             directory = unicode(QDesktopServices.storageLocation(home))
         directory = os.path.join(directory, suggestion)
     if os.path.splitext(directory)[-1] == os.extsep + 'brp':
         directory = os.path.splitext(directory)[0]
     caption = "Choose a DrumBurp file to save"
     fname = QFileDialog.getSaveFileName(parent=self,
                                         caption=caption,
                                         directory=directory,
                                         filter="DrumBurp files (*.brp)")
     if len(fname) == 0:
         return False
     self.filename = unicode(fname)
     return True
Exemplo n.º 47
0
 def changeBackground(self):
     filename = QFileDialog.getOpenFileName(self, self.trUtf8("Change Background"), \
         QDesktopServices.storageLocation(QDesktopServices.PicturesLocation), \
         self.trUtf8("Image Files (*.png *.gif *.jpg *.jpeg *.bmp *.mng *ico)"))
     if filename == "":
         return
     image = QImage(filename)
     if image.isNull():
         QMessageBox.information(self, self.trUtf8("Change Background"), \
                 self.trUtf8("不能读取图像文件,请检查文件格式是否正确,或者图片是否已经损坏。"))
         return
     if image.width() < 800 or image.height() < 600:
         answer = QMessageBox.information(self, self.trUtf8("Change Background"), \
                 self.trUtf8("不建议设置小于800x600的图片作为背景图案。如果继续,可能会使快捷面板显示错乱。是否继续?"),
                 QMessageBox.Yes | QMessageBox.No,
                 QMessageBox.No)
         if answer == QMessageBox.No:
             return
     self._makeBackground(image)
     moveToCenter(self)
     self.canvas.positWidgets()
     self.update()
     with self.platform.getSettings() as settings:
         settings.setValue("background", filename)
Exemplo n.º 48
0
 def on_actionLoad_triggered(self):
     if not self.okToContinue():
         return
     caption = "Choose a DrumBurp file to open"
     directory = self.filename
     if len(self.recentFiles) > 0:
         directory = os.path.dirname(self.recentFiles[-1])
     else:
         loc = QDesktopServices.HomeLocation
         directory = QDesktopServices.storageLocation(loc)
     fname = QFileDialog.getOpenFileName(parent=self,
                                         caption=caption,
                                         directory=directory,
                                         filter="DrumBurp files (*.brp)")
     if len(fname) == 0:
         return
     if self.scoreScene.loadScore(fname):
         self._beatChanged(self.scoreScene.defaultCount)
         self.lilypondSize.setValue(self.scoreScene.score.lilysize)
         self.lilyPagesBox.setValue(self.scoreScene.score.lilypages)
         self.filename = unicode(fname)
         self.updateStatus("Successfully loaded %s" % self.filename)
         self.addToRecentFiles()
         self.updateRecentFiles()
Exemplo n.º 49
0
    def browse(self, startdir=None):
        """
        Open a file dialog and select a user specified file.
        """
        if startdir is None:
            if self.selected_file:
                startdir = os.path.dirname(self.selected_file)
            else:
                startdir = unicode(
                    QDesktopServices.storageLocation(
                        QDesktopServices.DocumentsLocation))

        def format_spec(format):
            ext_pattern = ", ".join(map("*{}".format, format.extensions))
            return "{} ({})".format(format.name, ext_pattern)

        formats = [format_spec(format) for format in FILEFORMATS]
        filters = ";;".join(formats + ["All files (*.*)"])

        path, selected_filter = QFileDialog.getOpenFileNameAndFilter(
            self, "Open Data File", startdir, filters)
        if path:
            path = unicode(path)
            if selected_filter in formats:
                filter_idx = formats.index(str(selected_filter))
                fformat = FILEFORMATS[filter_idx]
                loader = DEFAULT_ACTIONS[filter_idx]
                if fformat.extensions in ([".csv"], [".tsv"]):
                    loader = loader._replace(
                        params=loader_for_path(path).params)
            else:
                loader = None
            self.set_selected_file(path, loader=loader)
            return QDialog.Accepted
        else:
            return QDialog.Rejected
Exemplo n.º 50
0
 def initGui(self):
     # log layer chooser
     self.connectLayerAction = QAction(
         QIcon(":/plugins/postgres91plusauditor/icons/connect.png"),
         "Define logged actions table", self.iface.mainWindow())
     self.connectLayerAction.triggered.connect(self.showLogLayerChooser)
     self.iface.addPluginToMenu("&Postgres 91 plus Auditor",
                                self.connectLayerAction)
     # show history action
     self.auditAction = QAction(
         QIcon(":/plugins/postgres91plusauditor/icons/qaudit-64.png"),
         "Audit logged actions", self.iface.mainWindow())
     self.auditAction.triggered.connect(self.audit)
     self.iface.addToolBarIcon(self.auditAction)
     self.iface.addPluginToMenu("&Postgres 91 plus Auditor",
                                self.auditAction)
     # help action
     self.helpAction = QAction(
         QIcon(":/plugins/postgres91plusauditor/icons/help.png"), "Help",
         self.iface.mainWindow())
     self.helpAction.triggered.connect(lambda: QDesktopServices.openUrl(
         QUrl("http://3nids.github.io/postgres91plusauditor/")))
     self.iface.addPluginToMenu("&Postgres 91 plus Auditor",
                                self.helpAction)
Exemplo n.º 51
0
    def __init__(self):
        appdata = str(
            QDesktopServices.storageLocation(QDesktopServices.DataLocation))
        MusicGuruBase.__init__(self, appdata)
        ApplicationBase.__init__(self)
        if not op.exists(appdata):
            os.makedirs(appdata)
        logging.basicConfig(filename=op.join(appdata, 'debug.log'),
                            level=logging.WARNING)
        self.prefs = Preferences()
        self.prefs.load()
        self.selectedBoardItems = []
        self.selectedLocation = None
        self.mainWindow = MainWindow(app=self)
        self.locationsPanel = LocationsPanel(app=self)
        self.detailsPanel = DetailsPanel(app=self)
        self.ignoreBox = IgnoreBox(app=self)
        self.progress = Progress(self.mainWindow)
        self.aboutBox = AboutBox(self.mainWindow, self)

        self.connect(self.progress, SIGNAL('finished(QString)'),
                     self.jobFinished)
        self.connect(self, SIGNAL('applicationFinishedLaunching()'),
                     self.applicationFinishedLaunching)
Exemplo n.º 52
0
def getLocationInQt(locationType):
    """

    """
    from PyQt4.QtGui import QDesktopServices
    try:
        key = {
            "desktop": QDesktopServices.DesktopLocation,
            "documents": QDesktopServices.DocumentsLocation,
            "fonts": QDesktopServices.FontsLocation,
            "applications": QDesktopServices.ApplicationsLocation,
            "music": QDesktopServices.MusicLocation,
            "movies": QDesktopServices.MoviesLocation,
            "pictures": QDesktopServices.PicturesLocation,
            "temp": QDesktopServices.TempLocation,
            "home": QDesktopServices.HomeLocation,
            "data": QDesktopServices.DataLocation,
            "cache": QDesktopServices.CacheLocation,
        }[locationType]
    except KeyError:
        raise KeyError(
            u"Передан некорректный параметр в метод getLocationInQt(locationType)"
        )
    return unicode(QDesktopServices.storageLocation(key))
Exemplo n.º 53
0
 def _open_config_folder(self):
     QDesktopServices.openUrl(
         QUrl("file:///" + QDir.toNativeSeparators(sys.path[1])))
Exemplo n.º 54
0
 def __onLinkActivated(self, link_str):
     QDesktopServices.openUrl(QUrl.fromLocalFile(link_str))
Exemplo n.º 55
0
 def link(self, linkStr):
     QDesktopServices.openUrl(QUrl(linkStr))
Exemplo n.º 56
0
 def open_overpass_turbo():
     """
     Open Overpass Turbo
     """
     desktop_service = QDesktopServices()
     desktop_service.openUrl(QUrl("http://overpass-turbo.eu/"))
Exemplo n.º 57
0
 def onSTDMHome(self):
     """
     Load STDM home page using the system's default browser.
     """
     stdmURL = "http://www.stdm.gltn.net"
     QDesktopServices.openUrl(QUrl(stdmURL))
Exemplo n.º 58
0
 def help(self):
     QDesktopServices().openUrl(
         QUrl("https://github.com/3nids/intersectit/wiki"))
Exemplo n.º 59
0
)
from sqlalchemy.orm import (
    relationship,
    backref,
    sessionmaker
)


LOGGER = logging.getLogger('stdm')

# Maximum number of saved searches per column
MAX_SEARCH_HISTORY = 50

# SQLite file to store searches
SEARCH_HISTORY_FILE = QDesktopServices.storageLocation(
    QDesktopServices.HomeLocation
) + '/.stdm/search/history.db'

url = 'sqlite:///{0}'.format(SEARCH_HISTORY_FILE)
engine = create_engine(url, echo=False)
Base = declarative_base()


class SearchDataSource(Base):
    """
    Stores the names of the data source.
    """
    __tablename__ = 'cb_search_source'

    id = Column(Integer, primary_key=True)
    name = Column(String(100))
Exemplo n.º 60
0
 def onContactUs(self):
     """
     Load STDM contact page.
     """
     contactURL = "http://www.stdm.gltn.net/?page_id=291"
     QDesktopServices.openUrl(QUrl(contactURL))