Example #1
0
 def logout(self):
     self.close()
     # This is a model dialog, if we exec it before we close MainWindow
     # MainWindow won't close
     from LoginWindow import LoginWindow
     wecase_login = LoginWindow(allow_auto_login=False)
     wecase_login.exec_()
Example #2
0
 def logout(self):
     self.close()
     # This is a model dialog, if we exec it before we close MainWindow
     # MainWindow won't close
     from LoginWindow import LoginWindow
     wecase_login = LoginWindow(allow_auto_login=False)
     wecase_login.exec_()
Example #3
0
 def first_login(self):
     #定义一个登录框的对象
     my = LoginWindow(self.db)
     # 在主窗口中连接信号和槽,把登录框的信号连接到MainWindow的username_Label上
     my.mySignal.connect(self.getDialogSignal)
     #激活登录窗口
     my.exec_()
     #完成后返回主窗口,对任务列表进行过滤
     self.setTableModel()
     self.setFilder()
Example #4
0
 def on_login_PushButton_clicked(self):
     #切换子线程
     self.checkRTMSThread.stop()
     #定义一个登录框的对象
     my = LoginWindow(self.db)
     # 在主窗口中连接信号和槽,把登录框的信号连接到MainWindow的username_Label上
     my.mySignal.connect(self.getDialogSignal)
     #激活登录窗口
     my.exec_()
     #完成后返回主窗口,对任务列表进行过滤
     self.setTableModel()
     self.setFilder()
     #激活子线程
     self.RTMSThred()
Example #5
0
    def __init__(self):
        super().__init__()
        self.title = "TitanBox-Client"
        self.left = 10
        self.top = 10
        self.width = 640
        self.height = 400

        label = QLabel(self)
        pixmap = QPixmap('background.jpg')
        label.resize(pixmap.width(), pixmap.height())
        label.setPixmap(pixmap)

        self.login = QPushButton("Login", self)
        self.login.setStyleSheet("background-color: #AED6F1")
        self.login.resize(160, 40)
        self.login.move(220, 180)
        self.login.clicked.connect(self.login_clicked)

        self.register = QPushButton("Register", self)
        self.register.setStyleSheet("background-color: #AED6F1")
        self.register.resize(160, 40)
        self.register.move(220, 240)
        self.register.clicked.connect(self.register_clicked)

        self.initUI()
Example #6
0
 def collectionModeEvent(self, event):
     collection_name = self.collection_mode.get()
     music_list = self.get_music_list(collection_name)
     if music_list["status"] in [401, 704]:
         LoginWindow()
     elif music_list["status"] == 200:
         self.updateListBox(music_list)
Example #7
0
    def config_window(self):
        # 垂直布局
        self.verticalLayout = QtWidgets.QVBoxLayout(self.centralwidget)
        self.verticalLayout.setObjectName("verticalLayout")

        # 分隔主窗口 上按钮, 下图片
        self.splitter = QtWidgets.QSplitter(self.centralwidget)
        self.splitter.setOrientation(QtCore.Qt.Vertical)
        self.splitter.setObjectName("splitter")

        # 外层竖向弹簧
        self.verticalLayout.addWidget(self.splitter)

        self.login_window = LoginWindow()
        self.soft_keybord = SoftKeyBoard()
        self.splitter.addWidget(self.login_window)  # 弹簧上面
Example #8
0
 def myMine(self, event):
     status = getUserInformation()
     if status["status"] == 200 and not getMyWindowOpen():
         setMyWindowOpen(True)
         MyWindow()
     elif status["status"] in [704, 401]:
         if not getLoginWindowOpen():
             setLoginWindowOpen(True)
             LoginWindow()
Example #9
0
 def updateListBox(self, music_list):
     if music_list["status"] == 200:
         self.t1.delete(0, END)
         if music_list["music"]:
             for music in music_list["music"]:
                 self.t1.insert(0, music)
         else:
             self.t1.insert(0, "这个收藏夹啥都没有 (° ~ °)")
     elif music_list["status"] == 704:
         self.t1.delete(0, END)
         self.t1.insert(0, "请先登录")
         LoginWindow()
Example #10
0
 def play(self, event):
     if self.now_play_mp3["text"].split(":")[0] != "正在加载":
         MainWindow.__PlayClick = True
         status = getUserInformation()
         if status["status"] == 200 or self.collection_mode.get() != "本地音乐":
             num = self.t1.curselection()  # 获得用户所选的下表位
             music_name = self.t1.get(num)  # 根据下标得到mp3的名字
             self.playMusic(music_name)
             collection_name = self.collection_mode.get()
             MainWindow.__PlayingMusicList = self.get_music_list(collection_name)["music"]
         elif status["status"] == 704:
             LoginWindow()
Example #11
0
    def __init__ (self, **kwargs):
        ZillaWindow.__init__(self, kwargs)
        FocusPanel.__init__(self, kwargs)

        area1 = TextArea()
        area1.setText("Zakładka 1")

        area2 = TextArea()
        area2.setText("Zakładka 2")

        area3 = TextArea()
        area3.setText("Zakładka 2")

        tabs = TabPanel()
        tabs.add(area2, tabText="Gra nr 1")
        tabs.add(area1, tabText="Pokój gier")
        tabs.add(area3, tabText="Pokój gier")

        self.add (tabs)

        lwindow = LoginWindow(centered=True)
        lwindow.setPopupPosition (100, 100)
        lwindow.show()
Example #12
0
class Home(QMainWindow):
    def __init__(self):
        super().__init__()
        self.title = "TitanBox-Client"
        self.left = 10
        self.top = 10
        self.width = 640
        self.height = 400

        label = QLabel(self)
        pixmap = QPixmap('background.jpg')
        label.resize(pixmap.width(), pixmap.height())
        label.setPixmap(pixmap)

        self.login = QPushButton("Login", self)
        self.login.setStyleSheet("background-color: #AED6F1")
        self.login.resize(160, 40)
        self.login.move(220, 180)
        self.login.clicked.connect(self.login_clicked)

        self.register = QPushButton("Register", self)
        self.register.setStyleSheet("background-color: #AED6F1")
        self.register.resize(160, 40)
        self.register.move(220, 240)
        self.register.clicked.connect(self.register_clicked)

        self.initUI()

    def initUI(self):
        self.setWindowTitle(self.title)
        self.setGeometry(self.left, self.top, self.width, self.height)

    def login_clicked(self):
        from LoginWindow import LoginWindow
        self.login = LoginWindow()
        self.login.show()
        self.close()

    def register_clicked(self):
        from RegisterWindow import RegisterWindow
        self.register = RegisterWindow()
        self.register.show()

        self.close()
Example #13
0
    def __init__(self, **kwargs):
        ZillaWindow.__init__(self, kwargs)
        FocusPanel.__init__(self, kwargs)

        area1 = TextArea()
        area1.setText("Zakładka 1")

        area2 = TextArea()
        area2.setText("Zakładka 2")

        area3 = TextArea()
        area3.setText("Zakładka 2")

        tabs = TabPanel()
        tabs.add(area2, tabText="Gra nr 1")
        tabs.add(area1, tabText="Pokój gier")
        tabs.add(area3, tabText="Pokój gier")

        self.add(tabs)

        lwindow = LoginWindow(centered=True)
        lwindow.setPopupPosition(100, 100)
        lwindow.show()
Example #14
0
    def __init__(self,
                 on_success=lambda *a, **k: None,
                 autologin_override=None):
        # Signing off respawns Digsby with "--noautologin" so that we don't
        # quickly log back in.
        self.allow_autologin = sys.opts.autologin
        self.cancelling = False
        self.on_success = on_success

        self._datastore = datastore.LoginInfo()
        self._profile = sentinel

        profiles, profile = identities(), None
        if profiles:
            profile = last_identity() or profiles[0]
            username = profile.name
            position = profile.get('pos', DEFAULT_SPLASH_POS)
        else:
            username = ''
            position = DEFAULT_SPLASH_POS

        bitmaps = cgui.LoginWindowBitmaps()
        bitmaps.logo = wx.Bitmap(res('digsbybig.png'))
        bitmaps.help = wx.Bitmap(res('skins/default/help.png'))
        bitmaps.settings = wx.Bitmap(res('AppDefaults', 'gear.png'))
        bitmaps.language = wx.Bitmap(
            res('skins/default/serviceicons/widget_trans.png'))

        revision_string = ' '.join(
            str(x)
            for x in (getattr(sys, 'REVISION', ''), getattr(sys, 'TAG', ''),
                      getattr(sys, 'BRAND', '')))

        show_languages = False
        self.window = LoginWindow(None, position, bitmaps,
                                  str(revision_string), show_languages,
                                  profiles)
        self.bind_events()

        try:
            self._set_frame_icon()
        except Exception:
            print_exc()

        cgui.FitInMonitors(self.window)

        status_message = ''

        if not status_message:
            if not self.have_shown_updated and sys.opts.updated:
                status_message = _('Update Successful')
                LoginController.have_shown_updated = True

        self.set_status(status_message)

        if profile:
            self.apply_info(profile)

        # don't allow autologin if the password is empty
        if not profile or not profile.get('password', ''):
            autologin_override = False

        self._init_state(autologin_override)

        @wx.CallAfter
        def doselection():
            un_textbox = self.window.FindWindowById(LoginWindow.USERNAME)
            un_textbox.SetFocus()

        self.setup_languages()
Example #15
0
class LoginController(object):
    '''
    Shows and interacts with the login window (see LoginWindow.cpp)
    '''

    have_shown_updated = False

    def __init__(self,
                 on_success=lambda *a, **k: None,
                 autologin_override=None):
        # Signing off respawns Digsby with "--noautologin" so that we don't
        # quickly log back in.
        self.allow_autologin = sys.opts.autologin
        self.cancelling = False
        self.on_success = on_success

        self._datastore = datastore.LoginInfo()
        self._profile = sentinel

        profiles, profile = identities(), None
        if profiles:
            profile = last_identity() or profiles[0]
            username = profile.name
            position = profile.get('pos', DEFAULT_SPLASH_POS)
        else:
            username = ''
            position = DEFAULT_SPLASH_POS

        bitmaps = cgui.LoginWindowBitmaps()
        bitmaps.logo = wx.Bitmap(res('digsbybig.png'))
        bitmaps.help = wx.Bitmap(res('skins/default/help.png'))
        bitmaps.settings = wx.Bitmap(res('AppDefaults', 'gear.png'))
        bitmaps.language = wx.Bitmap(
            res('skins/default/serviceicons/widget_trans.png'))

        revision_string = ' '.join(
            str(x)
            for x in (getattr(sys, 'REVISION', ''), getattr(sys, 'TAG', ''),
                      getattr(sys, 'BRAND', '')))

        show_languages = False
        self.window = LoginWindow(None, position, bitmaps,
                                  str(revision_string), show_languages,
                                  profiles)
        self.bind_events()

        try:
            self._set_frame_icon()
        except Exception:
            print_exc()

        cgui.FitInMonitors(self.window)

        status_message = ''

        if not status_message:
            if not self.have_shown_updated and sys.opts.updated:
                status_message = _('Update Successful')
                LoginController.have_shown_updated = True

        self.set_status(status_message)

        if profile:
            self.apply_info(profile)

        # don't allow autologin if the password is empty
        if not profile or not profile.get('password', ''):
            autologin_override = False

        self._init_state(autologin_override)

        @wx.CallAfter
        def doselection():
            un_textbox = self.window.FindWindowById(LoginWindow.USERNAME)
            un_textbox.SetFocus()

        self.setup_languages()

    def setup_languages(self):
        choice = self.window.LanguageChoice
        if choice is None:
            return

        languages = [
            p.name for p in wx.GetApp().plugins
            if p.__class__.__name__ == 'LangPluginLoader'
        ]

        with choice.Frozen():
            choice.Clear()
            for lang in languages:
                choice.Append(lang)
            if languages:
                choice.SetSelection(0)

    def _set_frame_icon(self):
        wx.Log.SetActiveTarget(wx.LogStderr())
        wx.Log.EnableLogging(False)
        self.window.SetIcons(icon_bundle())
        wx.Log.EnableLogging(True)

    def ShowWindow(self):
        self.window.Show()
        self.window.Raise()

    def DestroyWindow(self):
        import digsbyprofile
        try:
            if digsbyprofile.profile and getattr(
                    digsbyprofile.profile, 'connection', None) is not None:
                digsbyprofile.profile.connection.remove_observer(
                    self.OnStatusChange, 'state')
            self.window.Hide()
        finally:
            self.window.Destroy()

    def bind_events(self):
        bind = self.window.Bind
        bind(wx.EVT_CHECKBOX, self.OnCheck)
        #bind(wx.EVT_TEXT,  self.OnText)
        bind(wx.EVT_CHOICE, self.OnChoice)
        bind(wx.EVT_BUTTON, self.OnButton, id=wx.ID_OK)
        bind(wx.EVT_BUTTON, self.OnHelpButton, id=LoginWindow.HELPBUTTON)
        bind(wx.EVT_BUTTON, self.OnCreateProfile, id=LoginWindow.CREATEPROFILE)
        bind(wx.EVT_HYPERLINK, self.OnPWLink, id=LoginWindow.FORGOTPASSWORD)
        bind(wx.EVT_HYPERLINK, show_conn_settings, id=LoginWindow.CONNSETTINGS)
        bind(wx.EVT_CLOSE, self.OnClose)
        bind(wx.EVT_CHOICE, self.OnLanguage, id=LoginWindow.LANGUAGE)

    def OnLanguage(self, e):
        import main
        main.set_language(['', 'en_LT'][e.Int])
        self.window.UpdateUIStrings()

    def _init_state(self, autologin_override):
        # Call some events to get the initial state set properly
        self.OnCheck(None)
        self.OnText(None)

        # Click the login button if we're auto logging in
        if self._should_autologin(autologin_override):

            # make sure the window has had a chance to paint itself before autologin
            def paint():
                self.window.Refresh()
                self.window.Update()

            wx.CallAfter(paint)

            wx.CallAfter(self.signin)

    def _should_autologin(self, autologin_override):
        # autologin_override is None (ignore), True or False

        if not self.allow_autologin:
            return False

        if autologin_override is not None and not autologin_override:
            return False

        if not self.window.GetAutoLogin() or (autologin_override is not None
                                              and not autologin_override):
            return False

        return True

    def disconnect_prof(self):
        import digsbyprofile as d
        if d.profile:
            from AsyncoreThread import call_later
            call_later(d.profile.disconnect)
            if d.profile is self._profile:
                self.unwatch_profile(d.profile)

    def OnClose(self, evt):
        sys.util_allowed = True
        self.window.Hide()
        self.cleanup()
        wx.CallAfter(self.exit)

    def cleanup(self):
        try:
            self.disconnect_prof()
            self.save_info()
        except Exception:
            print_exc()

    def exit(self):
        try:
            self.DestroyWindow()
        except:
            print_exc()

        wx.GetApp().DigsbyCleanupAndQuit()

    def watch_profile(self, p):
        if self._profile is not sentinel:
            self.unwatch_profile(self._profile)
        self._profile = p

    def unwatch_profile(self, p=None):
        if p is None:
            p = self._profile

        if p is self._profile:
            self._profile = sentinel

    def OnButton(self, evt):
        self.signin()

    def signin(self):
        # Set the label early if we're about to import the rest of Digsby,
        # because it may take awhile with a cold cache.
        my_id = identity(self._get_window_username())
        my_id.password = self.window.GetPassword()
        hooks.first('digsby.identity.activate',
                    my_id,
                    raise_hook_exceptions=True)

        if not 'digsbyprofile' in sys.modules:
            sys.util_allowed = True
            self.set_status(_('Loading...'))
            self.window.EnableControls(False, SIGN_IN, False)
            self.window.Update()
            from M2Crypto import m2  #yeah, we're actually Loading...
            m2.rand_bytes(
                16)  #just in case this chunk of dll isn't in memory, preload
        import digsbyprofile
        if (digsbyprofile.profile and digsbyprofile.profile.is_connected):
            self.window.EnableControls(True, SIGN_IN, True)
            self.disconnect_prof()
            self.cancelling = True
        else:
            self.login()

    def login(self):
        good_data, reason = validate_data(self.get_info().values()[0])
        if not good_data:
            self.set_status(_(reason))
            self.window.EnableControls(True, SIGN_IN, True)
            self.window.Update()
            return

        self.set_status(_('Connecting...'))
        self.window.EnableControls(False, SIGN_IN)
        self.window.Update()

        #self.save_info()

        #info = self.allinfo[self._get_window_username()]
        info = self.get_info()[self._get_window_username()]

        def myfunc():
            import digsby

            try:
                self.cancelling = False
                self.on_success(info)
                import digsbyprofile
                self.watch_profile(digsbyprofile.profile)
            except digsby.DigsbyLoginError:
                # this will NEVER happen. need to switch to using callbacks?!
                self.set_status(_('Login error!'))
                self.window.EnableControls(True, SIGN_IN, True)
                return
            else:
                import digsbyprofile
                if digsbyprofile.profile and getattr(
                        digsbyprofile.profile, 'connection', None) is not None:
                    conn, cb = digsbyprofile.profile.connection, self.OnStatusChange
                    conn.add_observer(cb, 'state')

        wx.CallAfter(myfunc)

    def OnChoice(self, evt):
        evt.Skip()

        last_choice = getattr(self, '_last_choice', 0)

        i = evt.Int
        length = len(evt.EventObject.Items)

        print 'LAST WUT', evt.EventObject.GetCurrentSelection()

        if i == length - 3:
            # the ----- line. do nothing
            self.window.FindWindowById(
                LoginWindow.USERNAME).SetSelection(last_choice)
        elif i == length - 2:
            # Add Profile
            evt.Skip(False)
            if not self.OnCreateProfile():
                self.window.FindWindowById(
                    LoginWindow.USERNAME).SetSelection(last_choice)

        elif i == length - 1:
            username = self.window.FindWindowById(
                LoginWindow.USERNAME).GetItems()[last_choice]
            identity_obj = identity(username)
            if identity_obj is None:
                return

            identity_obj.password = self.window.GetPassword()

            if wx.OK == wx.MessageBox(
                    _('Are you sure you want to delete profile "%s"?' %
                      username), _('Remove Profile'), wx.OK | wx.CANCEL):

                import digsby.digsbylocal as digsbylocal
                try:
                    hooks.first('digsby.identity.delete',
                                username,
                                raise_hook_exceptions=True)
                except digsbylocal.InvalidPassword:
                    wx.MessageBox(
                        _('Please enter the correct password to delete "%s".' %
                          username), _('Remove Profile'))
                    self.window.FindWindowById(
                        LoginWindow.USERNAME).SetSelection(last_choice)
                else:
                    self.window.set_profiles(identities())
                    self._last_choice = 0
                    self.window.FindWindowById(
                        LoginWindow.PASSWORD).SetValue('')
                    self.window.panel.Layout()
                    self.window.Layout()

            else:
                self.window.FindWindowById(
                    LoginWindow.USERNAME).SetSelection(last_choice)

        else:
            self._last_choice = i
            print 'LAST CHOICE', i
            self.window.FindWindowById(LoginWindow.PASSWORD).SetValue('')

    def OnText(self, evt):
        self._ontextcount = getattr(self, '_ontextcount', 0) + 1
        if getattr(self, "_in_on_text", False):
            return evt.Skip()
        else:
            self._in_on_text = True

        try:
            if evt is not None:
                evt.Skip()

            window = self.window

            if not hasattr(self, 'allinfo'):
                return

            if evt and evt.Id == LoginWindow.USERNAME:
                if self.allinfo.get(self._get_window_username(),
                                    None) is not None:
                    self.apply_info(self.allinfo[self._get_window_username()],
                                    set_username=False)
                else:
                    window.SetPassword('')

            enabled = bool(self._get_window_username()
                           and window.GetPassword())

            window.FindWindowById(wx.ID_OK).Enable(enabled)
        finally:
            self._in_on_text = False

    def OnCheck(self, evt):
        if not self.window.GetSaveInfo():
            self.window.SetAutoLogin(False)

        if evt and evt.GetId() == LoginWindow.SAVEPASSWORD and evt.GetInt(
        ) and getattr(sys, 'is_portable', False):
            if not self.do_portable_security_warning():
                self.window.SetAutoLogin(False)
                self.window.FindWindowById(
                    LoginWindow.SAVEPASSWORD).Value = False
                self.save_info()
                return

        if evt and evt.GetId() in (LoginWindow.SAVEPASSWORD,
                                   LoginWindow.AUTOLOGIN):
            self.save_info()

    def do_portable_security_warning(self):
        security_warning_hdr = _(
            "Your password will be saved on your portable device.")
        security_warning_q = _(
            "Anyone with access to this device will be able to log into your Digsby account. "
            "Are you sure you want to save your password?")

        security_msg = u'%s\n\n%s' % (security_warning_hdr, security_warning_q)

        dlg = wx.MessageDialog(self.window, security_msg,
                               _("Security Information"),
                               wx.ICON_EXCLAMATION | wx.YES_NO)

        response = dlg.ShowModal()

        return response == wx.ID_YES

    def OnPWLink(self, evt):
        dlg = wx.MessageDialog(
            None,
            _("For security, your password is not saved anywhere. "
              "If you forget it, there is no way to decrypt the "
              "account information for that profile. You'll need "
              "to remove the profile, create a new one, and add "
              "your accounts back."), _('Forgotten password'), wx.OK)

        dlg.ShowModal()

    def OnHelpButton(self, evt=None):
        wx.LaunchDefaultBrowser('http://wiki.digsby.com')

    def OnCreateProfile(self, evt=None):
        from gui.profiledialog import ProfileDialog

        # show a profile dialog
        dialog = ProfileDialog(self.window)
        self.profile_dialog = dialog
        dialog.CenterOnParent()

        res = dialog.ShowModal()

        if res != wx.ID_OK: return

        # create the identity
        username, password = dialog.GetUsername(), dialog.GetPassword()
        assert username and password

        if dialog.is_new_profile:
            hooks.first('digsby.identity.create', username, password)
        else:
            hooks.first('digsby.identity.get', username, password)

        self.window.set_profiles(identities(), username, password)
        self._last_choice = self.window.FindWindowById(
            LoginWindow.USERNAME).GetSelection()
        self.window.panel.Layout()
        self.window.Layout()

        return True

    def OnStatusChange(self, src, attr, old, new):
        assert attr == 'state'
        wx.CallAfter(self.OnStatusChanged, src, attr, old, new)

    def OnStatusChanged(self, src, attr, old, new):

        if wx.IsDestroyed(self.window):
            log.warning(
                "Warning: splash screen is Destroyed but still getting notified."
            )
            return

        if self.cancelling and new != src.Statuses.OFFLINE:
            src.disconnect()

        if new in (src.Statuses.CONNECTING, src.Statuses.AUTHENTICATING,
                   src.Statuses.SYNC_PREFS, src.Statuses.AUTHORIZED):
            self.window.EnableControls(False, SIGN_IN, False)

        def f():
            if self.cancelling or new == src.Statuses.OFFLINE:

                if self.cancelling:
                    self.set_status('')
                else:
                    self.set_status(_(src.offline_reason))
                self.window.EnableControls(True, SIGN_IN, True)
            else:
                self.window.EnableControls(False, SIGN_IN)
                self.set_status(_(new))

        wx.CallAfter(f)

    def set_status(self, label, window_title=None, do_conn_error=False):
        '''
        Changes the main label and the window title.

        If not window title is given, it is set to be the same as the label.
        '''
        assert IsMainThread()

        conn_fail_message = _('Failed to Connect')

        self.window.SetStatus(label, window_title or '')

        if label == _('Authentication Error') and not getattr(
                self, 'auth_error_fired', False):
            self.auth_error_fired = True
            line1 = _(
                'Please make sure you have entered your Digsby username and password correctly.'
            )
            line2 = _(
                'If you need an account or forgot your password, use the links on the login screen.'
            )
            wx.MessageBox(u'%s\n%s' % (line1, line2),
                          _('Authentication Error'))
        if do_conn_error:
            #TODO: fix protocol states.
            if label == conn_fail_message and not getattr(
                    self, 'connect_error_fired', False):
                self.connect_error_fired = True
                wx.MessageBox(
                    _('Please check your Internet connection and make sure a firewall isn\'t blocking Digsby.\n'
                      'If you connect to the Internet through a proxy server,\n'
                      'click the "Connection Settings" link to set up the proxy.\n'
                      'If you are still unable to connect, email [email protected] for technical support.'
                      ), _('Failed to Connect'))

    def _get_window_username(self):
        return self.window.GetUsername().strip()

    def get_info(self):
        assert IsMainThread()
        find = self.window.FindWindowById

        window = self.window
        username = self._get_window_username()

        info_dict = dict(username=username,
                         password=window.GetPassword(),
                         save=window.GetSaveInfo(),
                         autologin=window.GetAutoLogin())

        return {username: info_dict}

    def apply_info(self, info, set_username=True):
        w = self.window
        if set_username:
            w.SetUsername(info.name)
        w.SetPassword(info.password or '')
        w.SetSaveInfo(info.get('save', False))
        w.SetAutoLogin(info.get('autologin', False))

    def set_username(self, username):
        self.window.SetUsername(username)

    def set_password(self, password):
        self.window.SetPassword(password)

    def save_info(self):
        username = self._get_window_username()
        if not username or username == u'------------------------------':
            return

        userinfo = self.get_info()
        profile = identity(username)

        for k in ('save', 'autologin'):
            profile.set(k, userinfo[username][k])

        if userinfo[username].get('save'):
            profile.set('saved_password', userinfo[username]['password'])
        else:
            profile.set('saved_password', '')

    def proto_error(self, exc):
        import digsby

        msgbox = None

        if exc is None:
            message = _('Failed to Connect')
        else:
            try:
                raise exc
            except digsby.DigsbyLoginError:
                if exc.reason == 'auth':
                    message = _('Authentication Error')
                elif exc.reason == 'connlost':
                    message = _('Connection Lost')
                else:
                    message = _('Failed to Connect')

                if exc.reason == 'server':
                    msgbox = _(
                        "We are upgrading Digsby. Please try connecting again in a few minutes."
                    )
                elif exc.reason == 'client':
                    msgbox = _(
                        'Could not contact remote server. Check your network configuration.'
                    )

            except Exception:
                print_exc()
                message = _("Failed to Connect")

        self.set_status(message, do_conn_error=True)
        self.window.EnableControls(True, SIGN_IN, True)
        self.disconnect_prof()

        if msgbox is not None:
            wx.MessageBox(msgbox, message)
Example #16
0
class My_MainWindow(QMainWindow):
    def setupUi(self, MainWindow):
        MainWindow.setObjectName("MainWindow")
        self.centralwidget = QtWidgets.QWidget(MainWindow)
        self.centralwidget.setObjectName("centralwidget")
        MainWindow.setCentralWidget(self.centralwidget)
        self.retranslateUi(MainWindow)
        QtCore.QMetaObject.connectSlotsByName(MainWindow)

        self.config_window()
        self.set_slot_func()

        # 接受信号关闭LoginWindow
        self.c = CustomSignal()
        c.close_login.connect(MainWindow.hide)  #

        # 设置配置文件
        self.soft_keybord.set_log(log)
        self.login_window.set_log(log)

    def retranslateUi(self, MainWindow):
        _translate = QtCore.QCoreApplication.translate
        MainWindow.setWindowTitle(_translate("MainWindow", "Hello World!"))

    def config_window(self):
        # 垂直布局
        self.verticalLayout = QtWidgets.QVBoxLayout(self.centralwidget)
        self.verticalLayout.setObjectName("verticalLayout")

        # 分隔主窗口 上按钮, 下图片
        self.splitter = QtWidgets.QSplitter(self.centralwidget)
        self.splitter.setOrientation(QtCore.Qt.Vertical)
        self.splitter.setObjectName("splitter")

        # 外层竖向弹簧
        self.verticalLayout.addWidget(self.splitter)

        self.login_window = LoginWindow()
        self.soft_keybord = SoftKeyBoard()
        self.splitter.addWidget(self.login_window)  # 弹簧上面

    def set_slot_func(self):
        """ 配置槽函数 """
        # 登录窗口与键盘联动
        self.login_window.btn_keyboard.clicked.connect(
            self.slot_switch_keyboard)
        self.soft_keybord.signal_send_text.connect(self.slot_recive_key)

        self.switch_keybord = False  # 控制键盘的开启

    def slot_switch_keyboard(self):
        """ 显示关闭软键盘 """
        self.switch_keybord = not self.switch_keybord
        if not self.switch_keybord:
            self.splitter.widget(1).setParent(None)
        else:
            self.splitter.insertWidget(1, self.soft_keybord)

        # 显示光标
        self.login_window.now_editline.setFocus()

    def processing_func_key(self, text):
        """ 处理功能键 """
        if text == 'up':
            self.login_window.focusPreviousChild()

        elif text == 'down':
            self.login_window.focusNextChild()

        elif text == 'left':
            self.login_window.now_editline.cursorBackward(False, 1)

        elif text == 'right':
            self.login_window.now_editline.cursorForward(False, 1)

        elif text == 'backspace':
            self.login_window.now_editline.backspace()

        elif text == 'enter':
            if self.login_window.btn_keyboard.hasFocus():  # 隐藏键盘
                # ~ self.slot_switch_keyboard()
                pass

            elif self.login_window.btn_login.hasFocus():  # 登录
                self.login_window.slot_btn_login_clicked()

            elif self.login_window.btn_regist.hasFocus():  # 注册
                self.login_window.slot_btn_regist_clicked()

            elif self.login_window.le_user.hasFocus():  # 在用户框时进入密码框
                self.login_window.focusNextChild()

            elif self.login_window.le_passwd.hasFocus():  # 在密码框时登录
                self.login_window.focusNextChild()
                self.login_window.slot_btn_login_clicked()

        elif text == 'clear':
            self.login_window.now_editline.clear()

    def slot_recive_key(self, text):
        """ 接收键盘发来的信息, 并发送到相应输入框 """
        if len(text) == 1:  # 非功能键
            self.login_window.now_editline.insert(text)
        else:
            self.processing_func_key(text)
Example #17
0
class LoginController(object):
    '''
    Shows and interacts with the login window (see LoginWindow.cpp)
    '''

    have_shown_updated = False

    def __init__(self, on_success=lambda *a, **k: None, autologin_override = None):
        # Signing off respawns Digsby with "--noautologin" so that we don't
        # quickly log back in.
        self.allow_autologin = sys.opts.autologin
        self.cancelling = False
        self.on_success = on_success

        self._datastore = datastore.LoginInfo()
        self._profile = sentinel

        profiles, profile = identities(), None
        if profiles:
            profile = last_identity() or profiles[0]
            username = profile.name
            position = profile.get('pos', DEFAULT_SPLASH_POS)
        else:
            username = ''
            position = DEFAULT_SPLASH_POS

        bitmaps = cgui.LoginWindowBitmaps()
        bitmaps.logo = wx.Bitmap(res('digsbybig.png'))
        bitmaps.help = wx.Bitmap(res('skins/default/help.png'))
        bitmaps.settings = wx.Bitmap(res('AppDefaults', 'gear.png'))
        bitmaps.language = wx.Bitmap(res('skins/default/serviceicons/widget_trans.png'))

        revision_string  = ' '.join(str(x) for x in (getattr(sys, 'REVISION', ''),
                                                     getattr(sys, 'TAG', ''),
                                                     getattr(sys, 'BRAND', '')))

        show_languages = False
        self.window = LoginWindow(None, position, bitmaps, str(revision_string), show_languages, profiles)
        self.bind_events()

        try:
            self._set_frame_icon()
        except Exception:
            print_exc()

        cgui.FitInMonitors(self.window)

        status_message = ''

        if not status_message:
            if not self.have_shown_updated and sys.opts.updated:
                status_message = _('Update Successful')
                LoginController.have_shown_updated = True

        self.set_status(status_message)

        if profile:
            self.apply_info(profile)

        # don't allow autologin if the password is empty
        if not profile or not profile.get('password', ''):
            autologin_override = False

        self._init_state(autologin_override)

        @wx.CallAfter
        def doselection():
            un_textbox = self.window.FindWindowById(LoginWindow.USERNAME)
            un_textbox.SetFocus()

        self.setup_languages()

    def setup_languages(self):
        choice = self.window.LanguageChoice
        if choice is None:
            return

        languages = [p.name for p in wx.GetApp().plugins if p.__class__.__name__ == 'LangPluginLoader']

        with choice.Frozen():
            choice.Clear()
            for lang in languages:
                choice.Append(lang)
            if languages:
                choice.SetSelection(0)

    def _set_frame_icon(self):
        wx.Log.SetActiveTarget(wx.LogStderr())
        wx.Log.EnableLogging(False)
        self.window.SetIcons(icon_bundle())
        wx.Log.EnableLogging(True)

    def ShowWindow(self):
        self.window.Show()
        self.window.Raise()

    def DestroyWindow(self):
        import digsbyprofile
        try:
            if digsbyprofile.profile and getattr(digsbyprofile.profile, 'connection', None) is not None:
                digsbyprofile.profile.connection.remove_observer(self.OnStatusChange, 'state')
            self.window.Hide()
        finally:
            self.window.Destroy()

    def bind_events(self):
        bind = self.window.Bind
        bind(wx.EVT_CHECKBOX, self.OnCheck)
        #bind(wx.EVT_TEXT,  self.OnText)
        bind(wx.EVT_CHOICE, self.OnChoice)
        bind(wx.EVT_BUTTON, self.OnButton,          id=wx.ID_OK)
        bind(wx.EVT_BUTTON, self.OnHelpButton,      id=LoginWindow.HELPBUTTON)
        bind(wx.EVT_BUTTON, self.OnCreateProfile,   id=LoginWindow.CREATEPROFILE)
        bind(wx.EVT_HYPERLINK, self.OnPWLink,       id=LoginWindow.FORGOTPASSWORD)
        bind(wx.EVT_HYPERLINK, show_conn_settings,  id=LoginWindow.CONNSETTINGS)
        bind(wx.EVT_CLOSE, self.OnClose)
        bind(wx.EVT_CHOICE, self.OnLanguage,        id=LoginWindow.LANGUAGE)

    def OnLanguage(self, e):
        import main
        main.set_language(['', 'en_LT'][e.Int])
        self.window.UpdateUIStrings()

    def _init_state(self, autologin_override):
        # Call some events to get the initial state set properly
        self.OnCheck(None)
        self.OnText(None)

        # Click the login button if we're auto logging in
        if self._should_autologin(autologin_override):

            # make sure the window has had a chance to paint itself before autologin
            def paint():
                self.window.Refresh()
                self.window.Update()
            wx.CallAfter(paint)

            wx.CallAfter(self.signin)

    def _should_autologin(self, autologin_override):
        # autologin_override is None (ignore), True or False

        if not self.allow_autologin:
            return False

        if autologin_override is not None and not autologin_override:
            return False

        if not self.window.GetAutoLogin() or (autologin_override is not None and not autologin_override):
            return False

        return True

    def disconnect_prof(self):
        import digsbyprofile as d
        if d.profile:
            from AsyncoreThread import call_later
            call_later(d.profile.disconnect)
            if d.profile is self._profile:
                self.unwatch_profile(d.profile)

    def OnClose(self, evt):
        sys.util_allowed = True
        self.window.Hide()
        self.cleanup()
        wx.CallAfter(self.exit)

    def cleanup(self):
        try:
            self.disconnect_prof()
            self.save_info()
        except Exception:
            print_exc()

    def exit(self):
        try:
            self.DestroyWindow()
        except:
            print_exc()

        wx.GetApp().DigsbyCleanupAndQuit()

    def watch_profile(self, p):
        if self._profile is not sentinel:
            self.unwatch_profile(self._profile)
        self._profile = p

    def unwatch_profile(self, p=None):
        if p is None:
            p = self._profile

        if p is self._profile:
            self._profile = sentinel

    def OnButton(self, evt):
        self.signin()

    def signin(self):
        # Set the label early if we're about to import the rest of Digsby,
        # because it may take awhile with a cold cache.
        my_id = identity(self._get_window_username())
        my_id.password = self.window.GetPassword()
        hooks.first('digsby.identity.activate', my_id, raise_hook_exceptions = True)

        if not 'digsbyprofile' in sys.modules:
            sys.util_allowed = True
            self.set_status(_('Loading...'))
            self.window.EnableControls(False, SIGN_IN, False)
            self.window.Update()
            from M2Crypto import m2 #yeah, we're actually Loading...
            m2.rand_bytes(16)       #just in case this chunk of dll isn't in memory, preload
        import digsbyprofile
        if (digsbyprofile.profile and digsbyprofile.profile.is_connected):
            self.window.EnableControls(True, SIGN_IN, True)
            self.disconnect_prof()
            self.cancelling = True
        else:
            self.login()

    def login(self):
        good_data, reason = validate_data(self.get_info().values()[0])
        if not good_data:
            self.set_status(_(reason))
            self.window.EnableControls(True, SIGN_IN, True)
            self.window.Update()
            return

        self.set_status(_('Connecting...'))
        self.window.EnableControls(False, SIGN_IN)
        self.window.Update()

        #self.save_info()

        #info = self.allinfo[self._get_window_username()]
        info = self.get_info()[self._get_window_username()]

        def myfunc():
            import digsby

            try:
                self.cancelling = False
                self.on_success(info)
                import digsbyprofile
                self.watch_profile(digsbyprofile.profile)
            except digsby.DigsbyLoginError:
                # this will NEVER happen. need to switch to using callbacks?!
                self.set_status(_('Login error!'))
                self.window.EnableControls(True, SIGN_IN, True)
                return
            else:
                import digsbyprofile
                if digsbyprofile.profile and getattr(digsbyprofile.profile, 'connection', None) is not None:
                    conn, cb = digsbyprofile.profile.connection, self.OnStatusChange
                    conn.add_observer(cb, 'state')

        wx.CallAfter(myfunc)

    def OnChoice(self, evt):
        evt.Skip()

        last_choice = getattr(self, '_last_choice', 0)

        i = evt.Int
        length = len(evt.EventObject.Items)

        print 'LAST WUT', evt.EventObject.GetCurrentSelection()

        if i == length - 3:
            # the ----- line. do nothing
            self.window.FindWindowById(LoginWindow.USERNAME).SetSelection(last_choice)
        elif i == length - 2:
            # Add Profile
            evt.Skip(False)
            if not self.OnCreateProfile():
                self.window.FindWindowById(LoginWindow.USERNAME).SetSelection(last_choice)

        elif i == length - 1:
            username = self.window.FindWindowById(LoginWindow.USERNAME).GetItems()[last_choice]
            identity_obj = identity(username)
            if identity_obj is None:
                return

            identity_obj.password = self.window.GetPassword()

            if wx.OK == wx.MessageBox(
                _('Are you sure you want to delete profile "%s"?' % username),
                _('Remove Profile'), wx.OK | wx.CANCEL):

                import digsby.digsbylocal as digsbylocal
                try:
                    hooks.first('digsby.identity.delete', username,
                                raise_hook_exceptions=True)
                except digsbylocal.InvalidPassword:
                    wx.MessageBox(_('Please enter the correct password to delete "%s".' % username),
                                  _('Remove Profile'))
                    self.window.FindWindowById(LoginWindow.USERNAME).SetSelection(last_choice)
                else:
                    self.window.set_profiles(identities())
                    self._last_choice = 0
                    self.window.FindWindowById(LoginWindow.PASSWORD).SetValue('')
                    self.window.panel.Layout()
                    self.window.Layout()

            else:
                self.window.FindWindowById(LoginWindow.USERNAME).SetSelection(last_choice)

        else:
            self._last_choice = i
            print 'LAST CHOICE', i
            self.window.FindWindowById(LoginWindow.PASSWORD).SetValue('')

    def OnText(self, evt):
        self._ontextcount = getattr(self, '_ontextcount', 0) + 1
        if getattr(self, "_in_on_text", False):
            return evt.Skip()
        else:
            self._in_on_text = True

        try:
            if evt is not None:
                evt.Skip()

            window = self.window

            if not hasattr(self, 'allinfo'):
                return

            if evt and evt.Id == LoginWindow.USERNAME:
                if self.allinfo.get(self._get_window_username(), None) is not None:
                    self.apply_info(self.allinfo[self._get_window_username()], set_username = False)
                else:
                    window.SetPassword('')

            enabled = bool(self._get_window_username() and window.GetPassword())

            window.FindWindowById(wx.ID_OK).Enable(enabled)
        finally:
            self._in_on_text = False

    def OnCheck(self, evt):
        if not self.window.GetSaveInfo():
            self.window.SetAutoLogin(False)

        if evt and evt.GetId() == LoginWindow.SAVEPASSWORD and evt.GetInt() and getattr(sys, 'is_portable', False):
            if not self.do_portable_security_warning():
                self.window.SetAutoLogin(False)
                self.window.FindWindowById(LoginWindow.SAVEPASSWORD).Value = False
                self.save_info()
                return

        if evt and evt.GetId() in (LoginWindow.SAVEPASSWORD, LoginWindow.AUTOLOGIN):
            self.save_info()

    def do_portable_security_warning(self):
        security_warning_hdr = _("Your password will be saved on your portable device.")
        security_warning_q = _("Anyone with access to this device will be able to log into your Digsby account. "
                               "Are you sure you want to save your password?")

        security_msg = u'%s\n\n%s' % (security_warning_hdr, security_warning_q)

        dlg = wx.MessageDialog(self.window, security_msg, _("Security Information"), wx.ICON_EXCLAMATION | wx.YES_NO)

        response = dlg.ShowModal()

        return response == wx.ID_YES

    def OnPWLink(self, evt):
        dlg = wx.MessageDialog(
            None,
            _("For security, your password is not saved anywhere. "
              "If you forget it, there is no way to decrypt the "
              "account information for that profile. You'll need "
              "to remove the profile, create a new one, and add "
              "your accounts back."),
            _('Forgotten password'),
            wx.OK)

        dlg.ShowModal()

    def OnHelpButton(self, evt = None):
        wx.LaunchDefaultBrowser('http://wiki.digsby.com')

    def OnCreateProfile(self, evt=None):
        from gui.profiledialog import ProfileDialog

        # show a profile dialog
        dialog = ProfileDialog(self.window)
        self.profile_dialog = dialog
        dialog.CenterOnParent()

        res = dialog.ShowModal()

        if res != wx.ID_OK: return

        # create the identity
        username, password = dialog.GetUsername(), dialog.GetPassword()
        assert username and password

        if dialog.is_new_profile:
            hooks.first('digsby.identity.create', username, password)
        else:
            hooks.first('digsby.identity.get', username, password)

        self.window.set_profiles(identities(), username, password)
        self._last_choice = self.window.FindWindowById(LoginWindow.USERNAME).GetSelection()
        self.window.panel.Layout()
        self.window.Layout()

        return True

    def OnStatusChange(self, src, attr, old, new):
        assert attr == 'state'
        wx.CallAfter(self.OnStatusChanged, src, attr, old, new)

    def OnStatusChanged(self, src, attr, old, new):

        if wx.IsDestroyed(self.window):
            log.warning("Warning: splash screen is Destroyed but still getting notified.")
            return

        if self.cancelling and new != src.Statuses.OFFLINE:
            src.disconnect()

        if new in (src.Statuses.CONNECTING, src.Statuses.AUTHENTICATING, src.Statuses.SYNC_PREFS, src.Statuses.AUTHORIZED):
            self.window.EnableControls(False, SIGN_IN, False)

        def f():
            if self.cancelling or new == src.Statuses.OFFLINE:

                if self.cancelling:
                    self.set_status('')
                else:
                    self.set_status(_(src.offline_reason))
                self.window.EnableControls(True, SIGN_IN, True)
            else:
                self.window.EnableControls(False, SIGN_IN)
                self.set_status(_(new))

        wx.CallAfter(f)

    def set_status(self, label, window_title = None, do_conn_error=False):
        '''
        Changes the main label and the window title.

        If not window title is given, it is set to be the same as the label.
        '''
        assert IsMainThread()

        conn_fail_message = _('Failed to Connect')

        self.window.SetStatus(label, window_title or '')

        if label == _('Authentication Error') and not getattr(self, 'auth_error_fired', False):
            self.auth_error_fired = True
            line1 = _('Please make sure you have entered your Digsby username and password correctly.')
            line2 = _('If you need an account or forgot your password, use the links on the login screen.')
            wx.MessageBox(u'%s\n%s' % (line1, line2), _('Authentication Error'))
        if do_conn_error:
            #TODO: fix protocol states.
            if label == conn_fail_message and not getattr(self, 'connect_error_fired', False):
                self.connect_error_fired = True
                wx.MessageBox(_('Please check your Internet connection and make sure a firewall isn\'t blocking Digsby.\n'
                                'If you connect to the Internet through a proxy server,\n'
                                'click the "Connection Settings" link to set up the proxy.\n'
                                'If you are still unable to connect, email [email protected] for technical support.'),
                              _('Failed to Connect'))

    def _get_window_username(self):
        return self.window.GetUsername().strip()

    def get_info(self):
        assert IsMainThread()
        find = self.window.FindWindowById

        window = self.window
        username = self._get_window_username()

        info_dict = dict(
            username=username,
            password=window.GetPassword(),
            save=window.GetSaveInfo(),
            autologin=window.GetAutoLogin()
        )

        return {username: info_dict}

    def apply_info(self, info, set_username=True):
        w = self.window
        if set_username:
            w.SetUsername(info.name)
        w.SetPassword(info.password or '')
        w.SetSaveInfo(info.get('save', False))
        w.SetAutoLogin(info.get('autologin', False))

    def set_username(self, username):
        self.window.SetUsername(username)

    def set_password(self, password):
        self.window.SetPassword(password)

    def save_info(self):
        username = self._get_window_username()
        if not username or username == u'------------------------------':
            return

        userinfo = self.get_info()
        profile = identity(username)

        for k in ('save', 'autologin'):
            profile.set(k, userinfo[username][k])

        if userinfo[username].get('save'):
            profile.set('saved_password', userinfo[username]['password'])
        else:
            profile.set('saved_password', '')

    def proto_error(self, exc):
        import digsby

        msgbox = None

        if exc is None:
            message = _('Failed to Connect')
        else:
            try:
                raise exc
            except digsby.DigsbyLoginError:
                if exc.reason == 'auth':
                    message = _('Authentication Error')
                elif exc.reason == 'connlost':
                    message = _('Connection Lost')
                else:
                    message = _('Failed to Connect')

                if exc.reason == 'server':
                    msgbox = _("We are upgrading Digsby. Please try connecting again in a few minutes.")
                elif exc.reason == 'client':
                    msgbox = _('Could not contact remote server. Check your network configuration.')

            except Exception:
                print_exc()
                message = _("Failed to Connect")

        self.set_status(message, do_conn_error=True)
        self.window.EnableControls(True, SIGN_IN, True)
        self.disconnect_prof()

        if msgbox is not None:
            wx.MessageBox(msgbox, message)
Example #18
0
    def __init__(self, on_success=lambda *a, **k: None, autologin_override = None):
        # Signing off respawns Digsby with "--noautologin" so that we don't
        # quickly log back in.
        self.allow_autologin = sys.opts.autologin
        self.cancelling = False
        self.on_success = on_success

        self._datastore = datastore.LoginInfo()
        self._profile = sentinel

        profiles, profile = identities(), None
        if profiles:
            profile = last_identity() or profiles[0]
            username = profile.name
            position = profile.get('pos', DEFAULT_SPLASH_POS)
        else:
            username = ''
            position = DEFAULT_SPLASH_POS

        bitmaps = cgui.LoginWindowBitmaps()
        bitmaps.logo = wx.Bitmap(res('digsbybig.png'))
        bitmaps.help = wx.Bitmap(res('skins/default/help.png'))
        bitmaps.settings = wx.Bitmap(res('AppDefaults', 'gear.png'))
        bitmaps.language = wx.Bitmap(res('skins/default/serviceicons/widget_trans.png'))

        revision_string  = ' '.join(str(x) for x in (getattr(sys, 'REVISION', ''),
                                                     getattr(sys, 'TAG', ''),
                                                     getattr(sys, 'BRAND', '')))

        show_languages = False
        self.window = LoginWindow(None, position, bitmaps, str(revision_string), show_languages, profiles)
        self.bind_events()

        try:
            self._set_frame_icon()
        except Exception:
            print_exc()

        cgui.FitInMonitors(self.window)

        status_message = ''

        if not status_message:
            if not self.have_shown_updated and sys.opts.updated:
                status_message = _('Update Successful')
                LoginController.have_shown_updated = True

        self.set_status(status_message)

        if profile:
            self.apply_info(profile)

        # don't allow autologin if the password is empty
        if not profile or not profile.get('password', ''):
            autologin_override = False

        self._init_state(autologin_override)

        @wx.CallAfter
        def doselection():
            un_textbox = self.window.FindWindowById(LoginWindow.USERNAME)
            un_textbox.SetFocus()

        self.setup_languages()
Example #19
0
 def login_clicked(self):
     from LoginWindow import LoginWindow
     self.login = LoginWindow()
     self.login.show()
     self.close()
 def launchLoginWindow(self):
     """Launches login window when employee mode is selected."""
     self.login_top_lvl = tk.Toplevel(self.master)
     self.login_window = LoginWindow(self)
Example #21
0
 def show_login(self, username):
     self.login = LoginWindow(self.database, username)
     self.login.switchNewUser.connect(self.show_userRegister)
     self.login.switchNewBusiness.connect(self.show_businessRegistration)
     self.login.switchDashboard.connect(self.show_dashboard)
     self.login.window.show()
Example #22
0
	def open_login_window(self):
		login_window = LoginWindow()
		login_window.setWindowFlags(login_window.windowFlags() | QtCore.Qt.CustomizeWindowHint)
		login_window.setWindowFlags(login_window.windowFlags() & ~QtCore.Qt.WindowCloseButtonHint)
		login_window.exec()
		self.check_user()
Example #23
0
import sys
from PyQt5.QtWidgets import QApplication
from LoginWindow import LoginWindow
"""
Запуск процесса авторизции пользователя
"""

app = QApplication(sys.argv)
ex = LoginWindow()
ex.open()
sys.exit(app.exec_())
Example #24
0
import sys
from PyQt5.QtWidgets import QMainWindow, QSystemTrayIcon, QApplication, QWidget, QPushButton, QAction, QLineEdit, QMessageBox, QDesktopWidget, QLabel, QMenu
from PyQt5.QtGui import QIcon, QPixmap
from PyQt5.QtCore import Qt, pyqtSlot
from LoginWindow import LoginWindow

app = QApplication(sys.argv)

trayIcon = QSystemTrayIcon(QIcon("logox64.png"), parent=app)
trayIcon.setToolTip("Ayche Calendar")
trayIcon.show()

menu = QMenu()
exitAction = menu.addAction('Exit')
exitAction.triggered.connect(app.quit)

trayIcon.setContextMenu(menu)

window = LoginWindow()
window.show()

app.exec_()
Example #25
0
        messagebox.showerror(title='错误', message='密码为空')
        return
    if key == keycheck:
        key = gen_md5(key)
        flag = client.check_register(user, key)
        if flag == '0':
            messagebox.showinfo(title="提示", message="注册成功")
            reg_back()
        elif flag == '1':
            messagebox.showerror(title="错误", message="该账号已被占用")
        else:
            messagebox.showerror(title="错误", message="注册错误")
    else:
        messagebox.showerror(title="错误", message="两次密码输入不同")


def register():  #注册按钮绑定的函数
    login_window.close()
    global reg_window
    reg_window = RegWindow(reg_back, reg_check)  #括号里传入的是上面定义的函数
    reg_window.show()


divide = ('---------------------')  #分割线
init()
inform_val = []
login_window = LoginWindow(login, register,
                           close_login_window)  # 创建登录窗口 括号里传入三个上面定义的函数
client = Client()  #建立客户端socket
login_window.show()
Example #26
0
def main():
    global client, login_window
    client = SocketClient(ip, port)
    login_window = LoginWindow(login, register, close_login_window)
    login_window.show()
Example #27
0
 def showLoginWindow(self):
     global login_ui
     login_ui = LoginWindow(ex)
     login_ui.show()
     self.close()
Example #28
0
import wx
import sys

sys.path.insert(0, 'model')
sys.path.insert(0, 'view')

from LoginWindow import LoginWindow

if __name__ == "__main__":
    if len(sys.argv) == 2 and sys.argv[1] == 'server':
        import Connection.CentralServer
    else:
        nullLog = wx.LogNull()
        app = wx.App(False)
        LoginWindow()
        app.MainLoop()
        sys.exit(1)
Example #29
0
 def startLogin(self, id, realName, status, lastLogin):
     self.loginWindow = LoginWindow(self, id, realName, status, lastLogin)
     self.loginWindow.logoutButton.clicked.connect(self.exitLogin)
     self.cardReaderThread.changeParent(self.loginWindow)
     self.central_widget.addWidget(self.loginWindow)
     self.central_widget.setCurrentWidget(self.loginWindow)