Exemple #1
0
 def addUser(self, name: str, password: str):
     try:
         self._userList.addUser(name, password)
     except Exception as e:
         self._ui.showError(tr("Controller", "Error"), tr("Controller", str(e)))
         return False
     return True
Exemple #2
0
    def _initUI(self):
        self._font = QFont()
        self._font.setPointSize(12)
        self._grid = QVBoxLayout()

        self._form = QFormLayout()
        self._form.setSpacing(8)
        self._fields = {}

        self._addFilePickerField("steam_path",
                                 tr("SettingsForm", "Path to Steam"),
                                 "Steam (*steam*);;All Files(*)")

        self._grid.addLayout(self._form)

        buttonsContainer = QHBoxLayout()
        buttonsContainer.addStretch(1)
        self._saveButton = QPushButton(tr("SettingsForm", "Save"))
        self._saveButton.setFont(self._font)
        self._saveButton.clicked.connect(lambda e: self.submitForm())
        buttonsContainer.addWidget(self._saveButton)
        self._cancelButton = QPushButton(tr("SettingsForm", "Cancel"))
        self._cancelButton.setFont(self._font)
        self._cancelButton.clicked.connect(self.close)
        buttonsContainer.addWidget(self._cancelButton)
        self._grid.addLayout(buttonsContainer)

        self.setLayout(self._grid)
        self.setWindowTitle(tr("SettingsForm", "Settings"))
        self._resetGeometry()
Exemple #3
0
    def _initUI(self):
        grid = QFormLayout()
        grid.setSpacing(10)

        usernameLabel = QLabel(tr("NewUserForm", "Username"))
        usernameLabel.setFont(_font)
        self._usernameField = QLineEdit()
        self._usernameField.setFont(_font)
        grid.addRow(usernameLabel, self._usernameField)

        passwordLabel = QLabel(tr("NewUserForm", "Password"))
        passwordLabel.setFont(_font)
        self._passwordField = QLineEdit()
        self._passwordField.setFont(_font)
        self._passwordField.setEchoMode(QLineEdit.Password)
        grid.addRow(passwordLabel, self._passwordField)

        self._submitButton = QPushButton(tr("NewUserForm", "Submit"))
        self._submitButton.setFont(_font)
        self._submitButton.clicked.connect(lambda e: self.submitForm())
        self._submitButton.setAutoDefault(True)
        grid.addRow(self._submitButton)

        self._usernameField.returnPressed.connect(self._submitButton.click)
        self._passwordField.returnPressed.connect(self._submitButton.click)

        self.setLayout(grid)
        self.setWindowTitle(tr("NewUserForm", "New User"))
        self._resetGeometry()
Exemple #4
0
 def remove(self, event):
     selectedUser = self._userList.getSelectedUser()
     if selectedUser:
         result = self._controller.removeUser(selectedUser)
         if result:
             self._userList.removeUserByItem(self._userList.currentItem())
     else:
         self._ui.showWarning(tr("AppController", "Remove User"), tr("AppController", "No user selected"))
Exemple #5
0
 def removeUser(self, name: str):
     reply = self._ui.askQuestion(tr("Controller", "Remove User"), tr("Controller", "Are you sure you want to remove user '{0}'?").format(name))
     if reply:
         try:
             self._userList.removeUser(name)
         except Exception as e:
             self._ui.showError(tr("Controller", "Error"), str(e))
             return False
         return True
     else:
         return False
Exemple #6
0
 def submitForm(self):
     username = self._usernameField.text()
     password = self._passwordField.text()
     if not username or not password:
         QMessageBox.critical(
             self, tr("NewUserForm", "New User"),
             tr("NewUserForm", "Must enter username and password"),
             QMessageBox.Ok, QMessageBox.Ok)
         return
     self._submitted = True
     self.close()
     self.formSubmitted.emit(username, password)
Exemple #7
0
def guiInit():
    userList = UserList(usersConfFile())
    settings = Settings(settingsConfFile())

    mainWindow = MainWindowWidget()
    mainWindow.setWindowTitle(tr("guiInit", "Steam Fast Login"))

    ui = UserInteraction(mainWindow)
    controller = Controller(settings, userList, ui, ProcessRunner())

    userListWidget = UserListWidget()
    # Populate the list with any existing users
    for username in userList.users:
        userListWidget.addItem(username)
    userListWidget.userActivated.connect(controller.loginUser)
    mainWindow.addWidget_(userListWidget)

    actionContainer = ActionContainerWidget()

    appController = AppController(settings, ui, userListWidget,
                                  actionContainer, controller)

    mainWindow.addWidget_(actionContainer)

    # Must return the app controller or it gets GC'd
    return appController, mainWindow
Exemple #8
0
def main(argv=None):
    if argv is None:
        argv = sys.argv

    app = QApplication(argv)
    app.installTranslator(QTranslator())
    app.setApplicationName(tr("main", "Steam Fast Login"))
    appController, mainWindow = guiInit()
    mainWindow.show()

    return app.exec_()
Exemple #9
0
    def _addFilePickerField(self, code: str, label: str, fileFilter: str):
        labelWidget = QLabel(label)
        labelWidget.setFont(self._font)
        filePicker = QHBoxLayout()
        fieldWidget = QLineEdit()
        fieldWidget.setFont(self._font)
        filePicker.addWidget(fieldWidget)
        fileDialogOpener = QPushButton(QIcon.fromTheme("document-open"), "")
        fileDialogOpener.setFont(self._font)
        fileDialogOpener.setToolTip(tr("SettingsForm", "Pick"))
        filePicker.addWidget(fileDialogOpener)

        def chooseFile(event):
            filename, _ = QFileDialog.getOpenFileName(self, label,
                                                      path.expanduser("~"),
                                                      fileFilter)
            if filename:
                fieldWidget.setText(filename)

        fileDialogOpener.clicked.connect(chooseFile)
        self._form.addRow(labelWidget, filePicker)
        self._fields[code] = fieldWidget
Exemple #10
0
 def login(self, event):
     selectedUser = self._userList.getSelectedUser()
     if selectedUser:
         self._controller.loginUser(selectedUser)
     else:
         self._ui.showWarning(tr("AppController", "Login"), tr("AppController", "No user selected"))
Exemple #11
0
 def _initAppActions(self):
     self._actions.addButton(tr("AppController", "&Login"), self.login)
     self._actions.addButton(tr("AppController", "&Add"), self.add)
     self._actions.addButton(tr("AppController", "&Remove"), self.remove)
     self._actions.addButton(tr("AppController", "&Close Steam"), self.close)
     self._actions.addButton(tr("AppController", "&Settings"), self.settings)
Exemple #12
0
 def closeSteam(self):
     reply = self._ui.askQuestion(tr("Controller", "Close Steam"), tr("Controller", "Are you sure?"))
     if reply:
         self._processRunner.runAsync(self._getSteamCommand(), ("-shutdown",))