Esempio n. 1
0
    def showContextMenu(self, pos: QPoint) -> None:
        mods = self.getSelectedMods()
        if not mods:
            return
        menu = QMenu(self)
        actionOpen = menu.addAction('&Open Directory')
        actionOpen.setIcon(
            QIcon(str(getRuntimePath('resources/icons/open-folder.ico'))))
        actionOpen.triggered.connect(lambda: [
            util.openDirectory(self.modmodel.getModPath(mod))  # type: ignore
            for mod in mods
        ])
        menu.addSeparator()
        actionEnable = menu.addAction('&Enable')
        actionEnable.triggered.connect(
            lambda: [asyncio.create_task(self.enableSelectedMods(True))])
        actionEnable.setEnabled(not all(mod.enabled for mod in mods))
        actionDisable = menu.addAction('&Disable')
        actionDisable.triggered.connect(
            lambda: [asyncio.create_task(self.enableSelectedMods(False))])
        actionDisable.setEnabled(not all(not mod.enabled for mod in mods))
        menu.addSeparator()
        actionUninstall = menu.addAction('&Uninstall')
        actionUninstall.triggered.connect(
            lambda: [asyncio.create_task(self.deleteSelectedMods())])
        menu.addSeparator()
        actionOpenNexus = menu.addAction('Open &Nexus Mods page')
        actionOpenNexus.setIcon(
            QIcon(str(getRuntimePath('resources/icons/browse.ico'))))
        actionOpenNexus.triggered.connect(lambda: [
            QDesktopServices.openUrl(
                QUrl(f'https://www.nexusmods.com/witcher3/mods/{modid}'))
            for modid in {mod.modid
                          for mod in mods if mod.modid > 0}
        ])
        actionOpenNexus.setEnabled(not all(mod.modid <= 0 for mod in mods))

        menu.popup(self.viewport().mapToGlobal(pos))
def launch_module_help():
    QDesktopServices.openUrl(help_url("qtwidgets-index"))
def launch_help(widget):
    """Launch a widget's help page"""
    url = help_url(class_name(widget).lower())
    QDesktopServices.openUrl(url)
Esempio n. 4
0
 def launch(self):
     QDesktopServices.openUrl(QUrl.fromLocalFile(self.fileName))
Esempio n. 5
0
def open_file_url(url):
    QDesktopServices.openUrl(QUrl("file:///" + url))
Esempio n. 6
0
def helpDocs(context):
    docPath = os.path.join(os.path.dirname(__file__), "documentation")
    URLPath = pathlib.Path(os.path.join(docPath, "Manual.html")).as_uri()
    QDesktopServices.openUrl(URLPath)
 def Sl_on_double_click(self):
     file_path = QUrl.fromUserInput(self.path)
     QDesktopServices.openUrl(file_path)
Esempio n. 8
0
    server = QWebSocketServer("QWebChannel Standalone Example Server",
                              QWebSocketServer.NonSecureMode)
    if not server.listen(QHostAddress.LocalHost, 12345):
        print("Failed to open web socket server.")
        sys.exit(-1)

    # wrap WebSocket clients in QWebChannelAbstractTransport objects
    clientWrapper = WebSocketClientWrapper(server)

    # setup the channel
    channel = QWebChannel()
    clientWrapper.clientConnected.connect(channel.connectTo)

    # setup the UI
    dialog = Dialog()

    # setup the core and publish it to the QWebChannel
    core = Core(dialog)
    channel.registerObject("core", core)

    # open a browser window with the client HTML page
    url = QUrl.fromLocalFile(cur_dir + "/index.html")
    QDesktopServices.openUrl(url)

    message = "Initialization complete, opening browser at {}.".format(
              url.toDisplayString())
    dialog.displayMessage(message)
    dialog.show()

    sys.exit(app.exec_())
 def open_file(file):
     QDesktopServices.openUrl(QUrl.fromLocalFile(file))
Esempio n. 10
0
 def browseSnippets(self):
     url = QUrl.fromLocalFile(snippetPath)
     QDesktopServices.openUrl(url)
Esempio n. 11
0
 def Sl_show_path_button_clicked(self) -> None:
     path = QUrl.fromUserInput(self.env_settings.value("sync_path"))
     QDesktopServices.openUrl(path)
Esempio n. 12
0
 def OpenUrl2(self):
     QDesktopServices.openUrl(
         QUrl("https://github.com/tonquer/waifu2x-vulkan"))
Esempio n. 13
0
    def setupMenu(self) -> None:
        self.setMenuBar(QMenuBar(self))
        settings = QSettings()

        # mods menu

        menuMods: QMenu = self.menuBar().addMenu('&Mods')

        downIcon = QIcon(str(getRuntimePath('resources/icons/down.ico')))
        gearIcon = QIcon(str(getRuntimePath('resources/icons/gear.ico')))
        dirsIcon = QIcon(str(
            getRuntimePath('resources/icons/open-folder.ico')))
        colrIcon = QIcon(
            str(getRuntimePath('resources/icons/color-circle.ico')))
        smilIcon = QIcon(str(getRuntimePath('resources/icons/smile.ico')))

        actionAddModFromFile = menuMods.addAction('&Add Mods')
        actionAddModFromFile.triggered.connect(self.showAddModFromFileDialog)
        actionAddModFromFolder = menuMods.addAction('Add u&npacked Mod')
        actionAddModFromFolder.triggered.connect(
            self.showAddModFromFolderDialog)
        actionDownloadMod = menuMods.addAction('&Download Mod')
        actionDownloadMod.setIcon(downIcon)
        actionDownloadMod.triggered.connect(self.showDownloadModDialog)

        menuMods.addSeparator()
        actionGetInfo = menuMods.addAction('Update Mod de&tails')
        actionGetInfo.setIcon(downIcon)
        actionGetInfo.triggered.connect(self.showGetInfoDialog)
        actionGetUpdates = menuMods.addAction('Check for Mod &updates')
        actionGetUpdates.setIcon(downIcon)
        actionGetUpdates.triggered.connect(self.showGetUpdatesDialog)

        menuMods.addSeparator()
        actionExport = menuMods.addAction('&Export Modlist')
        actionExport.triggered.connect(self.showExportDialog)

        menuMods.aboutToShow.connect(lambda: [
            actionDownloadMod.setDisabled(not str(settings.value('nexusAPIKey'))),
            actionGetInfo.setDisabled(
                not str(settings.value('nexusAPIKey')) or \
                not len(self.model) or \
                not self.mainwidget.modlist.selectionModel().hasSelection()),
            actionGetUpdates.setDisabled(
                not str(settings.value('nexusAPIKey')) or \
                not len(self.model) or \
                not self.mainwidget.modlist.selectionModel().hasSelection()),
            actionExport.setDisabled(not len(self.model))
        ])

        # view menu

        menuView: QMenu = self.menuBar().addMenu('&View')

        showSummary = menuView.addAction('Show &Summary')
        showSummary.setCheckable(True)
        showSummary.setChecked(settings.value('showSummary', 'True') == 'True')
        showSummary.triggered.connect(lambda checked: [
            settings.setValue('showSummary', str(checked)),
            self.mainwidget.summary.setVisible(checked)
        ])
        menuView.addSeparator()

        toggleHighlightNewest = menuView.addAction('Highlight &Newest')
        toggleHighlightNewest.setCheckable(True)
        toggleHighlightNewest.setChecked(
            settings.value('highlightNewest', 'True') == 'True')
        toggleHighlightNewest.triggered.connect(lambda checked: [
            settings.setValue('highlightNewest', str(checked)),
            self.model.updateCallbacks.fire(self.model)
        ])
        iconHighlightNewest = QPixmap(256, 256)
        iconHighlightNewest.fill(Qt.transparent)
        painter = QPainter(iconHighlightNewest)
        painter.setBrush(QBrush(QColor(222, 255, 222)))
        painter.drawEllipse(10, 10, 236, 236)
        toggleHighlightNewest.setIcon(QIcon(iconHighlightNewest))
        painter.end()

        toggleHighlightRecent = menuView.addAction('Highlight &Recent')
        toggleHighlightRecent.setCheckable(True)
        toggleHighlightRecent.setChecked(
            settings.value('highlightRecent', 'True') == 'True')
        toggleHighlightRecent.triggered.connect(lambda checked: [
            settings.setValue('highlightRecent', str(checked)),
            self.model.updateCallbacks.fire(self.model)
        ])
        iconHighlightRecent = QPixmap(256, 256)
        iconHighlightRecent.fill(Qt.transparent)
        painter = QPainter(iconHighlightRecent)
        painter.setBrush(QBrush(QColor(222, 226, 255)))
        painter.drawEllipse(10, 10, 236, 236)
        toggleHighlightRecent.setIcon(QIcon(iconHighlightRecent))
        painter.end()

        toggleHighlightUnmanaged = menuView.addAction('Highlight &Unmanaged')
        toggleHighlightUnmanaged.setCheckable(True)
        toggleHighlightUnmanaged.setChecked(
            settings.value('highlightUnmanaged', 'True') == 'True')
        toggleHighlightUnmanaged.triggered.connect(lambda checked: [
            settings.setValue('highlightUnmanaged', str(checked)),
            self.model.updateCallbacks.fire(self.model)
        ])
        iconHighlightUnmanaged = QPixmap(256, 256)
        iconHighlightUnmanaged.fill(Qt.transparent)
        painter = QPainter(iconHighlightUnmanaged)
        painter.setBrush(QBrush(QColor(250, 220, 220)))
        painter.drawEllipse(10, 10, 236, 236)
        toggleHighlightUnmanaged.setIcon(QIcon(iconHighlightUnmanaged))
        painter.end()

        toggleHighlightDisabled = menuView.addAction('Highlight &Disabled')
        toggleHighlightDisabled.setCheckable(True)
        toggleHighlightDisabled.setChecked(
            settings.value('highlightDisabled', 'True') == 'True')
        toggleHighlightDisabled.triggered.connect(lambda checked: [
            settings.setValue('highlightDisabled', str(checked)),
            self.model.updateCallbacks.fire(self.model)
        ])
        iconHighlightDisabled = QPixmap(256, 256)
        iconHighlightDisabled.fill(Qt.transparent)
        painter = QPainter(iconHighlightDisabled)
        painter.setBrush(QBrush(QColor(230, 230, 230)))
        painter.drawEllipse(10, 10, 236, 236)
        toggleHighlightDisabled.setIcon(QIcon(iconHighlightDisabled))
        painter.end()

        menuView.addSeparator()
        toggleColors = menuView.addAction('&Colored Icons')
        toggleColors.setCheckable(True)
        toggleColors.setChecked(settings.value('iconColors', 'True') == 'True')
        toggleColors.triggered.connect(lambda checked: [
            settings.setValue('iconColors', str(checked)),
            self.mainwidget.modlist.listmodel.setIcons(),
            self.model.updateCallbacks.fire(self.model)
        ])
        toggleColors.setIcon(colrIcon)

        menuView.addSeparator()
        toggleCompact = menuView.addAction('Compact &Mode')
        toggleCompact.setCheckable(True)
        toggleCompact.setChecked(
            settings.value('compactMode', 'False') == 'True')
        toggleCompact.triggered.connect(lambda checked: [
            settings.setValue('compactMode', str(checked)),
            self.mainwidget.modlist.setSectionSize(checked)
        ])

        # settings menu

        menuSettings: QMenu = self.menuBar().addMenu('&Tools')
        actionSettings = menuSettings.addAction('&Settings')
        actionSettings.setIcon(gearIcon)
        actionSettings.triggered.connect(self.showSettingsDialog)

        menuSettings.addSeparator()
        actionOpenGameDirectory = menuSettings.addAction(
            'Open &Game directory')
        actionOpenGameDirectory.setIcon(dirsIcon)
        actionOpenGameDirectory.triggered.connect(
            lambda: util.openDirectory(self.model.gamepath))
        actionOpenConfigDirectory = menuSettings.addAction(
            'Open &Config directory')
        actionOpenConfigDirectory.setIcon(dirsIcon)
        actionOpenConfigDirectory.triggered.connect(
            lambda: util.openDirectory(self.model.configpath))

        # info menu

        menuInfo: QMenu = self.menuBar().addMenu('&Info')

        actionFeedback = menuInfo.addAction('Send &Feedback')
        actionFeedback.setIcon(smilIcon)
        actionFeedback.triggered.connect(
            lambda: QDesktopServices.openUrl(QUrl(w3modmanager.URL_ISSUES)))
        menuInfo.addSeparator()
        actionAbout = menuInfo.addAction('&About')
        actionAbout.setIcon(QIcon.fromTheme('document-open'))
        actionAbout.triggered.connect(self.showAboutDialog)
Esempio n. 14
0
 def previewInput(self, item: QListWidgetItem):
     QDesktopServices.openUrl(
         QUrl.fromLocalFile(str(self._input_folder / item.text())))