Example #1
0
    def _init_widgets(self):
        layout = QtGui.QVBoxLayout()
        self.centralWidget().setLayout(layout)

        self._userid = QtGui.QLineEdit()
        # Value of the login prompt when it is empty and not focused.
        self._userid.setPlaceholderText(_('login@hostname'))
        # Help text for the login prompt.
        self._userid.setToolTip(_('Enter your unique userid.'))
        self._userid.returnPressed.connect(self.on_connect)
        self._userid.setText(conf.get(['accounts', 'default', 'userid']))
        layout.addWidget(self._userid)

        self._password = QtGui.QLineEdit()
        # Value of the password prompt when it is empty and not focused
        self._password.setPlaceholderText(_('password'))
        # Help text for the password prompt.
        self._password.setToolTip(_('The password for your Wididit account.'))
        self._password.setEchoMode(QtGui.QLineEdit.Password)
        self._password.returnPressed.connect(self.on_connect)
        self._password.setText(conf.get(['accounts', 'default', 'pass']))
        layout.addWidget(self._password)

        self._validate = QtGui.QPushButton(
                # Text of the button used to connect.
                _('Connect'),
                )
        layout.addWidget(self._validate)
        self._validate.clicked.connect(self.on_connect)
Example #2
0
    def _init_widgets(self):
        layout = QtGui.QVBoxLayout()
        self.centralWidget().setLayout(layout)

        self._userid = QtGui.QLineEdit()
        # Value of the login prompt when it is empty and not focused.
        self._userid.setPlaceholderText(_("login@hostname"))
        # Help text for the login prompt.
        self._userid.setToolTip(_("Enter your unique userid."))
        self._userid.returnPressed.connect(self.on_connect)
        self._userid.setText(conf.get(["accounts", "default", "userid"]))
        layout.addWidget(self._userid)

        self._password = QtGui.QLineEdit()
        # Value of the password prompt when it is empty and not focused
        self._password.setPlaceholderText(_("password"))
        # Help text for the password prompt.
        self._password.setToolTip(_("The password for your Wididit account."))
        self._password.setEchoMode(QtGui.QLineEdit.Password)
        self._password.returnPressed.connect(self.on_connect)
        self._password.setText(conf.get(["accounts", "default", "pass"]))
        layout.addWidget(self._password)

        self._validate = QtGui.QPushButton(
            # Text of the button used to connect.
            _("Connect")
        )
        layout.addWidget(self._validate)
        self._validate.clicked.connect(self.on_connect)
Example #3
0
 def new_opensearchtab():
     if id_ == 'showuser':
         userid, ok = QtGui.QInputDialog.getText(self,
                 # 'Show user' dialog title.
                 _('Show user'),
                 # 'Show user' dialog content.
                 _('What is the userid of the user you want to see?')
                 )
         if not ok: # User did not press the 'OK' button
             return
         self.showuser(str(userid))
Example #4
0
    def _init_toolbar(self):
        self._menus = {
                # File menu title.
                'file': self.menuBar().addMenu(_('&File')),
                # Tabs menu title.
                'tabs': self.menuBar().addMenu(_('&Tabs')),
                }
        self._menus.update({
                # Tab>Open search tab
                'opensearchtab': self._menus['tabs'].addMenu(_('Search')),
                # Tabs>Open/Close menu title.
                'openclosetab': self._menus['tabs'].addMenu(_('Open/Close')),
                })
        self._actions = {
                # Quit Wididit from the 'File' menu.
                'quit': QtGui.QAction(_('Quit'), self),
                'opensearchtab': {
                    # Open 'Show user' tab
                    'showuser': QtGui.QAction(_('Show user'), self),
                    },
                'openclosetab': {
                    # Open timeline tab.
                    'timeline': QtGui.QAction(_('Timeline'), self),
                    # Open 'All entries' tab.
                    'all': QtGui.QAction(_('All'), self),
                    # Open timeline tab.
                    'own': QtGui.QAction(_('Your entries'), self),
                    }
                }
        self._actions['quit'].triggered.connect(self.quit)
        self._menus['file'].addSeparator()
        self._menus['file'].addAction(self._actions['quit'])

        for name in ('timeline', 'all', 'own'):
            self._actions['openclosetab'][name].setCheckable(True)
            if name in self._tabs['main']:
                self._actions['openclosetab'][name].setChecked(True)
            self._actions['openclosetab'][name].toggled \
                    .connect(self.openclose_maintab_slot(name))
            self._menus['openclosetab'].addAction(
                    self._actions['openclosetab'][name])
        for name in ('showuser',):
            self._actions['opensearchtab'][name].triggered \
                    .connect(self.opensearchtab_slot(name))
            self._menus['opensearchtab'].addAction(
                    self._actions['opensearchtab'][name])
        self.centralWidget().tabCloseRequested.connect(self.closetab_slot)
Example #5
0
    def on_connect(self, event=None):
        log.debug('User clicked the authentication button. Validating '
                'creditentials...')
        userid = self._userid.text()
        password = self._password.text()
        valid = self._callback(userid, password)
        conf.set(['accounts', 'default', 'userid'], str(userid))
        conf.set(['accounts', 'default', 'pass'], str(password))
        if valid:
            log.info('Valid userid and password. Connected.')
            self._save_geometry()
            self.hide()
        else:
            log.info('Invalid userid or password. Asking authentication again.')

            dialog = QtGui.QMessageBox.critical(self,
                    # 'Login failed' dialog title.
                    _('Connot connect.'),
                    # 'Login failed' dialog content.
                    _('Invalid userid or password. Try again.'))
Example #6
0
    def on_connect(self, event=None):
        log.debug("User clicked the authentication button. Validating " "creditentials...")
        userid = self._userid.text()
        password = self._password.text()
        valid = self._callback(userid, password)
        conf.set(["accounts", "default", "userid"], str(userid))
        conf.set(["accounts", "default", "pass"], str(password))
        if valid:
            log.info("Valid userid and password. Connected.")
            self._save_geometry()
            self.hide()
        else:
            log.info("Invalid userid or password. Asking authentication again.")

            dialog = QtGui.QMessageBox.critical(
                self,
                # 'Login failed' dialog title.
                _("Connot connect."),
                # 'Login failed' dialog content.
                _("Invalid userid or password. Try again."),
            )
Example #7
0
 def openmaintab(self, id_, **kwargs):
     if id_ == 'timeline':
         # Title of tab containing the timeline.
         title = _('Timeline')
         entries = Entry.Query(get_people().server).shared(True).fetch()
         value = (ScrollableEntryListWidget(self, entries), title)
     elif id_ == 'all':
         # Title of tab containing all entries.
         title = _('All')
         entries = Entry.Query(get_people().server,
                 Entry.Query.MODE_ALL).fetch()
         value = (ScrollableEntryListWidget(self, entries), title)
     elif id_ == 'own':
         # Title of tab containing user's entries.
         title = _('Your entries')
         entries = Entry.Query(get_people().server,
                 Entry.Query.MODE_ALL).filterAuthor(get_people()) \
                 .fetch()
         value = (ScrollableEntryListWidget(self, entries), title)
         self.centralWidget().addTab(*value)
     self._tabs['main'][id_] = value
     self.centralWidget().addTab(*value)
Example #8
0
    def __init__(self, application):
        super(MainWindow, self).__init__()
        self._application = application

        log.debug('Spawning main window.')

        # Title of main window.
        self.setWindowTitle(_('Wididit'))
        self.setWindowIcon(get_qicon())

        self.setCentralWidget(QtGui.QTabWidget(self))
        self.centralWidget().setTabsClosable(True)
        self.centralWidget().setMovable(True)

        self._init_geometry()
        self._init_tabs()
        self._init_toolbar()
Example #9
0
    def __init__(self, callback):
        super(LoginWindow, self).__init__()
        self._callback = callback

        log.debug("Spawning login window.")

        # Title of login window.
        self.setWindowTitle(_("Connect to Wididit"))
        self.setWindowIcon(get_qicon())

        self.setCentralWidget(QtGui.QWidget())

        self._init_geometry()
        self._init_widgets()

        self.show()

        log.debug("Login window displayed.")
Example #10
0
    def __init__(self, callback):
        super(LoginWindow, self).__init__()
        self._callback = callback

        log.debug('Spawning login window.')

        # Title of login window.
        self.setWindowTitle(_('Connect to Wididit'))
        self.setWindowIcon(get_qicon())

        self.setCentralWidget(QtGui.QWidget())

        self._init_geometry()
        self._init_widgets()

        self.show()

        log.debug('Login window displayed.')
Example #11
0
 def showuser(self, people, raises=True):
     try:
         people = People.from_anything(people)
     except exceptions.PeopleNotInstanciable:
         if raises:
             dialog = QtGui.QMessageBox.critical(self,
                     # 'Invalid user' dialog title.
                     _('Cannot show user.'),
                     # 'Invalid user' dialog content.
                     _('The given userid is not valid. Try again.'))
         return
     except exceptions.Unreachable:
         if raises:
             dialog = QtGui.QMessageBox.critical(self,
                     # 'Invalid user' dialog title.
                     _('Cannot show user.'),
                     # 'Invalid user' dialog content.
                     _('The given userid does not exist. '
                       'The server hosting him might be down.'))
         return
     except exceptions.NotFound:
         if raises:
             dialog = QtGui.QMessageBox.critical(self,
                     # 'Invalid user' dialog title.
                     _('Cannot show user.'),
                     # 'Invalid user' dialog content.
                     _('This user does not exist on the server. '
                       'Check your input.'))
         return
     if people.userid not in self._tabs['showuser']:
         title = people.userid
         widget = PeopleWidget(self, people, with_entries=True)
         value = (widget, title)
         self._tabs['showuser'][people.userid] = value
         self.centralWidget().addTab(*value)
     self.centralWidget().setCurrentIndex(
             self.centralWidget().indexOf(
                 self._tabs['showuser'][people.userid][0]))