Exemplo n.º 1
0
def main():
    import sys

    app = QApplication(sys.argv)
    QApplication.setOrganizationName('Akond Lab')
    QApplication.setOrganizationDomain('akond.com')
    QApplication.setApplicationName('WD Wrapper')
    QApplication.setApplicationVersion(__version__)

    tcl = CommandLineSettings()
    parser = QCommandLineParser()
    result = tcl.parseCommandLine(parser)
    if result.result == CommandLineParseResult.CommandLineError:
        print(result.errorMessage, "\n\n", parser.helpText(), file=sys.stderr)
        return 1
    elif result.result == CommandLineParseResult.CommandLineVersionRequested:
        print(QCoreApplication.applicationName(),
              QCoreApplication.applicationVersion(), "\n")
        return 0
    elif result.result == CommandLineParseResult.CommandLineHelpRequested:
        parser.showHelp()
        return 0

    mainWin = MainWindow()
    # mainWin.resize(800, 600)   # now in config, see: MainWindow.readWindowSettings
    mainWin.show()

    sys.exit(app.exec_())
Exemplo n.º 2
0
    def __get_sqlite_name(self) -> str:
        """Create the name for the SqliteDB.

        Therefor combine the Qt Application Defs:
        QStandardPaths.DataLocation + QtCoreApplication.applicationName + .sqlite3

        * *on Mac is this*
            `~/Library/Application Support/io.jmuelbert.github/jmbde/jmbde.sqlite3`
        * *on Linux this*
            `~/.local/share/<APPNAME>/jmbde.sqlite3`
        * *on Windows is this*
            `C:/Users/<USER>/AppData/Local/<APPNAME>/jmbde.sqlite3`

        Returns:
            The connection string fot the sqlite database.
        """
        db_data_path = QStandardPaths.writableLocation(
            QStandardPaths.DataLocation)

        self.log.info("The Database: {}".format(db_data_path))

        write_dir = QDir(db_data_path)
        if not write_dir.mkpath("."):
            self.log.error("Failed to create writable directory")

        if not write_dir.exists():
            write_dir.mkpath(db_data_path)

        # Ensure that we have a writable location on all devices.
        filename = "{}/{}.sqlite3".format(write_dir.absolutePath(),
                                          QCoreApplication.applicationName())

        return filename
Exemplo n.º 3
0
    def __init__(self, parent=None):
        super(TypingWindow, self).__init__(parent=parent)

        # TODO: Implement themes system
        self.config = {
            'error_color': QColor(255, 190, 190),
            'done_color': QColor(190, 255, 190),
            'secondary_color': QColor(230, 230, 230),
            'background_color': QColor(255, 255, 255),
            'primary_color': QColor(34, 34, 34),
            'dictionary': english_words_set
        }

        self.setupWindow()
        self.settings = QSettings(QCoreApplication.applicationName(),
                                  parent=self)
        self.reset()
Exemplo n.º 4
0
 def setTitle(self):
     p = ' - ' + os.path.basename(self.path) if self.path else ''
     self.setWindowTitle(QCoreApplication.applicationName() + ' ' + QCoreApplication.applicationVersion() + p)