コード例 #1
0
ファイル: __main__.py プロジェクト: Tydus/vidcutter
def main():
    if hasattr(Qt, 'AA_EnableHighDpiScaling'):
        QCoreApplication.setAttribute(Qt.AA_EnableHighDpiScaling, True)
    if hasattr(Qt, 'AA_Use96Dpi'):
        QCoreApplication.setAttribute(Qt.AA_Use96Dpi, True)
    if hasattr(Qt, 'AA_ShareOpenGLContexts'):
        QCoreApplication.setAttribute(Qt.AA_ShareOpenGLContexts, True)

    if sys.platform == 'darwin':
        QApplication.setStyle('Fusion')

    app = QApplication(sys.argv)
    app.setApplicationName('VidCutter Special HD Ver.')
    app.setApplicationVersion(MainWindow.get_version())
    app.setOrganizationDomain('ozmartians.com')
    app.setQuitOnLastWindowClosed(True)

    win = MainWindow()
    exit_code = app.exec_()
    if exit_code == MainWindow.EXIT_CODE_REBOOT:
        if sys.platform == 'win32':
            if hasattr(win.cutter, 'mpvWidget'):
                win.close()
            QProcess.startDetached('"%s"' % qApp.applicationFilePath())
        else:
            os.execl(sys.executable, sys.executable, *sys.argv)
    sys.exit(exit_code)
コード例 #2
0
    def _database_downloaded(self, branch, progress, reply):
        """
        Called when the file has been downloaded.

        :param branch: the branch
        :param progress: the progress dialog
        :param reply: the reply from the server
        """
        # Close the progress dialog
        self._on_progress(progress, 1, 1)

        # Get the absolute path of the file
        appPath = QCoreApplication.applicationFilePath()
        appName = QFileInfo(appPath).fileName()
        fileExt = 'i64' if '64' in appName else 'idb'
        fileName = '%s_%s.%s' % (branch.repo, branch.name, fileExt)
        filePath = local_resource('files', fileName)

        # Write the packet content to disk
        with open(filePath, 'wb') as outputFile:
            outputFile.write(reply.content)
        logger.info("Saved file %s" % fileName)

        # Save the old database
        database = ida_loader.get_path(ida_loader.PATH_TYPE_IDB)
        if database:
            ida_loader.save_database(database, ida_loader.DBFL_KILL)
        # Save the current state
        self._plugin.core.save_state(True, database)
        # Open the new database
        QProcess.startDetached(qApp.applicationFilePath(), [filePath])
        qApp.quit()  # https://forum.hex-rays.com/viewtopic.php?f=8&t=4294
コード例 #3
0
def main():
    if hasattr(Qt, 'AA_EnableHighDpiScaling'):
        QCoreApplication.setAttribute(Qt.AA_EnableHighDpiScaling, True)
    if hasattr(Qt, 'AA_Use96Dpi'):
        QCoreApplication.setAttribute(Qt.AA_Use96Dpi, True)
    if hasattr(Qt, 'AA_ShareOpenGLContexts'):
        QCoreApplication.setAttribute(Qt.AA_ShareOpenGLContexts, True)

    if sys.platform == 'darwin':
        QApplication.setStyle('Fusion')

    app = SingleApplication(vidcutter.__appid__, sys.argv)
    app.setApplicationName(vidcutter.__appname__)
    app.setApplicationVersion(vidcutter.__version__)
    app.setOrganizationDomain(vidcutter.__domain__)
    app.setQuitOnLastWindowClosed(True)

    stylename = qApp.style().objectName().lower()

    win = MainWindow()
    win.stylename = stylename
    app.setActivationWindow(win)
    app.messageReceived.connect(win.file_opener)
    app.aboutToQuit.connect(MainWindow.cleanup)

    exit_code = app.exec_()
    if exit_code == MainWindow.EXIT_CODE_REBOOT:
        if sys.platform == 'win32':
            if hasattr(win.cutter, 'mpvWidget'):
                win.close()
            QProcess.startDetached('"{}"'.format(qApp.applicationFilePath()))
        else:
            QProcess.startDetached(' '.join(sys.argv))
    sys.exit(exit_code)
コード例 #4
0
 def onUseChineseDialog(self):
     dialog = ChangeLanguage2Dialog(self)
     setConfValue("Lang", "zh_CN")
     if dialog.exec() == QDialog.Accepted:
         qApp.closeAllWindows()
         QProcess.startDetached(qApp.applicationFilePath(), [])
     else:
         dialog.close()
コード例 #5
0
def restart_real_live():
    """ 进程控制实现自动重启
    Notes:
    常用的有两种方式实现重启:
    1. 进程控制,退出当前进程,再通过 QProcess 启动一个新的进程
    2. 事件循环,退出应用程序,然后通过 Application 事件循环控制程序启动

    :return:
    """
    qApp.quit()
    p = QProcess
    p.startDetached(qApp.applicationFilePath())
コード例 #6
0
 def onUseChineseDialog(self):
     dialog = ChangeLanguage2Dialog(self)
     try:
         data = pickle.load(open("data", "rb"))
     except EOFError:
         mData = {"currLanguage": "en_US", "nextLanguage": "en_US"}
     else:
         mData = {
             "currLanguage": data["currLanguage"],
             "nextLanguage": "zh_CN"
         }
     pickle.dump(mData, open("data", "wb"))
     if dialog.exec() == QDialog.Accepted:
         qApp.closeAllWindows()
         QProcess.startDetached(qApp.applicationFilePath(), [])
     else:
         dialog.close()
コード例 #7
0
ファイル: actions.py プロジェクト: fcccode/IDAConnect
    def _database_downloaded(self, branch, progress, reply):
        """
        Called when the file has been downloaded.

        :param branch: the branch
        :param progress: the progress dialog
        :param reply: the reply from the server
        """
        # Close the progress dialog
        self._progress_callback(progress, 1, 1)

        # Get the absolute path of the file
        fileName = branch.uuid + ('.i64' if branch.bits == 64 else '.idb')
        filePath = local_resource('files', fileName)

        # Write the packet content to disk
        with open(filePath, 'wb') as outputFile:
            outputFile.write(reply.content)
        logger.info("Saved file %s" % fileName)

        # Show a success dialog
        # success = QMessageBox()
        # success.setIcon(QMessageBox.Information)
        # success.setStandardButtons(QMessageBox.Ok)
        # success.setText("Database successfully downloaded!")
        # success.setWindowTitle("Open from server")
        # iconPath = self._plugin.getResource('download.png')
        # success.setWindowIcon(QIcon(iconPath))
        # success.exec_()

        # Save the old database
        idbPath = idc.GetIdbPath()
        if idbPath:
            idc.save_database(idbPath, 0)
        # Save the current state
        self._plugin.core.save_state(idbPath)
        # Open the new database
        QProcess.startDetached(qApp.applicationFilePath(), [filePath])
        qApp.quit()  # FIXME: Find an alternative, if any
コード例 #8
0
    def restoreSettings(self):
        s = self.settings
        try:
            # 首测运行初始化 , 需要右键管理员身份运行
            appName = qApp.applicationFilePath().split(r"/")[-1] + ".lnk"
            startapp = QStandardPaths.standardLocations(
                QStandardPaths.DesktopLocation)[0]
            global target_path
            target_path = os.path.join(startapp, appName)

            # print(qApp.applicationFilePath(), target_path, )
            # create_to_StartUp(qApp.applicationFilePath(), target_path)
        except:
            import traceback
            print(traceback.format_exc())
        try:
            # 主窗体 尺寸位置
            self.restoreState(s.value("window_info/windowState"))
            self.restoreGeometry(s.value("window_info/geometry"))

        except:
            pass
コード例 #9
0
def main():
    qt_set_sequence_auto_mnemonic(False)

    if hasattr(Qt, 'AA_EnableHighDpiScaling'):
        QGuiApplication.setAttribute(Qt.AA_EnableHighDpiScaling, True)
    if hasattr(Qt, 'AA_Use96Dpi'):
        QGuiApplication.setAttribute(Qt.AA_Use96Dpi, True)
    if hasattr(Qt, 'AA_ShareOpenGLContexts'):
        fmt = QSurfaceFormat()
        fmt.setDepthBufferSize(24)
        QSurfaceFormat.setDefaultFormat(fmt)
        QGuiApplication.setAttribute(Qt.AA_ShareOpenGLContexts, True)

    # if sys.platform == 'darwin':
    #     qApp.setStyle('Fusion')

    app = SingleApplication(vidcutter.__appid__, sys.argv)
    app.setApplicationName(vidcutter.__appname__)
    app.setApplicationVersion(vidcutter.__version__)
    app.setDesktopFileName(vidcutter.__desktopid__)
    app.setOrganizationDomain(vidcutter.__domain__)
    app.setQuitOnLastWindowClosed(True)

    win = MainWindow()
    win.stylename = app.style().objectName().lower()
    app.setActivationWindow(win)
    app.messageReceived.connect(win.file_opener)
    app.aboutToQuit.connect(MainWindow.cleanup)

    exit_code = app.exec_()
    if exit_code == MainWindow.EXIT_CODE_REBOOT:
        if sys.platform == 'win32':
            if hasattr(win.cutter, 'mpvWidget'):
                win.close()
            QProcess.startDetached('"{}"'.format(qApp.applicationFilePath()))
        else:
            QProcess.startDetached(' '.join(sys.argv))
    sys.exit(exit_code)