コード例 #1
0
ファイル: SignUp.py プロジェクト: CGFanTuan/damgteam
    def buttons_section(self):
        self.btnSection, btn_grid = GroupGrid()

        self.user_agree_checkBox = CheckBox(txt=USER_CHECK_REQUIRED)
        okBtn = Button({
            'txt': 'Create Account',
            'tt': 'Confirm to create an account',
            'cl': self.createBtnClicked
        })
        cancelBtn = Button({
            'txt':
            'Cancel',
            'tt':
            'Go back to Login stage',
            'cl':
            partial(self.signals.emit, 'showLayout', 'SignIn', 'SignIn')
        })
        quitBtn = Button({
            'txt': 'Quit',
            'tt': 'Quit the application',
            'cl': QApplication.quit
        })

        btn_grid.addWidget(self.user_agree_checkBox, 0, 0, 1, 6)
        btn_grid.addWidget(okBtn, 1, 0, 1, 2)
        btn_grid.addWidget(cancelBtn, 1, 2, 1, 2)
        btn_grid.addWidget(quitBtn, 1, 4, 1, 2)
コード例 #2
0
 def buildServerStatusCheckBoxes(self):
     self.serverCB = CheckBox('Server')
     self.onlineCB = CheckBox('Internet')
     self.modeCB = CheckBox('Mode')
     self.allConnectCB = CheckBox("All: ")
     self.allConnectCB.stateChanged.connect(self.allConnectStateChanged)
     for cb in [self.serverCB, self.onlineCB, self.modeCB, self.allConnectCB]:
         self.connectCBs.append(cb)
コード例 #3
0
 def buildMenuCheckBoxes(self):
     self.mnAppCB = CheckBox('&App')
     self.mnGoCB = CheckBox('&Go')
     self.mnOfficeCB = CheckBox('&Office')
     self.mnToolsCB = CheckBox('&Tools')
     self.mnDevCB = CheckBox('&Dev')
     self.mnLibCB = CheckBox('&Lib')
     self.mnHelpCB = CheckBox('&Help')
     self.allMenuCB = CheckBox('All: ')
     self.allMenuCB.stateChanged.connect(self.allMenuStateChanged)
     for cb in [self.mnAppCB, self.mnGoCB, self.mnOfficeCB, self.mnToolsCB, self.mnDevCB, self.mnLibCB,
                self.mnHelpCB, self.allMenuCB]:
         self.menuCBs.append(cb)
コード例 #4
0
ファイル: TopTab1.py プロジェクト: CGFanTuan/damgteam
    def __init__(self):
        super(TopTap1Filter, self).__init__()

        self.setTitle('Fillter')
        self.layout = GridLayout(self)
        self.setLayout(self.layout)

        self.overduedCB = CheckBox()
        self.urgentCB = CheckBox()
        self.safetyCB = CheckBox()
        self.allTabCheckBox = CheckBox()
        self.allTabCheckBox.stateChanged.connect(self.allTabCheckBoxStateChanged)

        odl = 0
        ugl = odl + 1
        stl = ugl + 1
        al = stl + 1

        self.layout.addWidget(Label({'txt': 'Overdued', 'sss': 'color: red'}), odl, 0, 1, 2)
        self.layout.addWidget(self.overduedCB, odl, 2, 1, 1)
        self.layout.addWidget(Label({'txt': 'Urgent', 'sss': 'color: orange'}), ugl, 0, 1, 2)
        self.layout.addWidget(self.urgentCB, ugl, 2, 1, 1)
        self.layout.addWidget(Label({'txt': 'Others', 'sss': 'color: green'}), stl, 0, 1, 2)
        self.layout.addWidget(self.safetyCB, stl, 2, 1, 1)
        self.layout.addWidget(Label({'txt': 'All'}), al, 0, 1, 2)
        self.layout.addWidget(self.allTabCheckBox, al, 2, 1, 1)
コード例 #5
0
 def buildToolBarCheckBoxes(self):
     self.tbTDCB = CheckBox("TD")
     self.tbVfxCB = CheckBox("VFX")
     self.tbArtCB = CheckBox("Art")
     self.tbTexCB = CheckBox("Tex")
     self.tbPostCB = CheckBox('Post')
     self.allToolBarCB = CheckBox("All: ")
     self.allToolBarCB.stateChanged.connect(self.allToolBarStateChanged)
     for cb in [self.tbTDCB, self.tbVfxCB, self.tbArtCB, self.tbTexCB, self.tbPostCB, self.allToolBarCB]:
         self.toolBarCBs.append(cb)
コード例 #6
0
    def __init__(self, parent=None):
        super(UpdatePage, self).__init__(parent)

        updateGroup         = GroupBox("Package selection")
        systemCheckBox      = CheckBox("Update system")
        appsCheckBox        = CheckBox("Update applications")
        docsCheckBox        = CheckBox("Update documentation")

        packageGroup        = GroupBox("Existing packages")

        packageList         = QListWidget()
        qtItem              = QListWidgetItem(packageList)
        qtItem.setText("Qt")

        qsaItem             = QListWidgetItem(packageList)
        qsaItem.setText("QSA")

        teamBuilderItem     = QListWidgetItem(packageList)
        teamBuilderItem.setText("Teambuilder")

        startUpdateButton   = Button({'txt':"Start update"})

        updateLayout        = VBoxLayout({'addWidget': [systemCheckBox, appsCheckBox, docsCheckBox]})
        # updateLayout.addWidget(systemCheckBox)
        # updateLayout.addWidget(appsCheckBox)
        # updateLayout.addWidget(docsCheckBox)
        updateGroup.setLayout(updateLayout)

        packageLayout       = QVBoxLayout()
        packageLayout.addWidget(packageList)
        packageGroup.setLayout(packageLayout)

        mainLayout          = QVBoxLayout()
        mainLayout.addWidget(updateGroup)
        mainLayout.addWidget(packageGroup)
        mainLayout.addSpacing(12)
        mainLayout.addWidget(startUpdateButton)
        mainLayout.addStretch(1)

        self.setLayout(mainLayout)
コード例 #7
0
    def buildUI(self):

        # self.buildHeaderCheckBoxes()

        self.buildBodyCheckBoxes()

        self.footerCB       = CheckBox('Footer')

        self.statusBarCB    = CheckBox("Status Bar")

        for cb in [self.statusBarCB, ]:
            self.statusCBs.append(cb)

        cbs = [self.toolBarCBs, self.menuCBs, self.connectCBs, self.notificationCBs, self.statusCBs, ]

        for i in range(len(cbs)):
            if i == 0:
                prefix = 'ToolBar'
            elif i == 1:
                prefix = 'Menu'
            elif i == 2:
                prefix = 'Network'
            elif i == 3:
                prefix = 'Notification'
            elif i == 4:
                prefix = 'StatusBar'
            else:
                prefix = 'NoDefine'

            for cb in cbs[i]:
                cb.key = '{0}_{1}_CheckBox_{2}'.format(self.parent.key, prefix, cb.text())
                cb._name = '{0} {1} Check Box: {2}'.format(self.parent.key, prefix, cb.text())

                cb.settings._settingEnable = True
                state = cb.getValue('checkState')
                if state is None:
                    state = True
                cb.setValue('checkState', state)
                cb.setChecked(str2bool(state))
                self.checkboxes.add(cb.key, cb)
コード例 #8
0
 def buildNotificationCheckBoxes(self):
     self.cpuCB = CheckBox('cpu')
     self.ramCB = CheckBox('ram')
     self.gpuCB = CheckBox('gpu')
     self.diskCB = CheckBox('disk')
     self.timeCB = CheckBox('clock')
     self.dateCB = CheckBox('date')
     self.allNotifiCB = CheckBox("All: ")
     self.allNotifiCB.stateChanged.connect(self.allNotifiStateChanged)
     for cb in [self.cpuCB, self.ramCB, self.gpuCB, self.diskCB, self.timeCB, self.dateCB, self.allNotifiCB]:
         self.notificationCBs.append(cb)
コード例 #9
0
ファイル: SignIn.py プロジェクト: CGFanTuan/damgteam
    def buildUI(self):

        loginGrp, loginGrid = GroupGrid('Sign in')

        self.userTF = LineEdit()
        self.pwTF = LineEdit({'fn': 'password'})
        self.userCB = CheckBox('Remember me?')

        forgot_pw_btn = Button({
            'txt':
            'Forgot your password?',
            'cl':
            partial(self.signals.emit, 'showLayout', 'ForgotPassword', 'show')
        })
        login_btn = Button({'txt': 'Log in', 'cl': self.signInClicked})
        cancel_btn = Button({'txt': 'Cancel', 'cl': QApplication.quit})

        signupGrp, signupGrid = GroupGrid('Sign up')
        signupBtn = Button({
            'txt':
            'Sign up',
            'cl':
            partial(self.signals.emit, 'showLayout', 'SignUp', 'show')
        })

        loginGrid.addWidget(usernameLabel, 0, 0, 1, 2)
        loginGrid.addWidget(passwordLabel, 1, 0, 1, 2)
        loginGrid.addWidget(self.userTF, 0, 2, 1, 4)
        loginGrid.addWidget(self.pwTF, 1, 2, 1, 4)
        loginGrid.addWidget(self.userCB, 2, 1, 1, 2)
        loginGrid.addWidget(login_btn, 2, 3, 1, 3)
        loginGrid.addWidget(forgot_pw_btn, 3, 0, 1, 3)
        loginGrid.addWidget(cancel_btn, 3, 3, 1, 3)

        signupGrid.addWidget(Label({'txt': SIGNUP}), 0, 0, 1, 6)
        signupGrid.addWidget(signupBtn, 1, 0, 1, 6)

        self.layout.addWidget(loginGrp, 0, 0, 1, 1)
        self.layout.addWidget(signupGrp, 1, 0, 1, 1)
コード例 #10
0
    def buildBodyCheckBoxes(self):
        self.buildNotificationCheckBoxes()
        self.bodyCB = CheckBox('Body')
        self.bodyCB.stateChanged.connect(self.bodyStateChanged)
        ntl = self.la
        bdl = ntl + 1
        self.addWidget(Label({'txt': 'Notification'}), ntl, 0, 1, 1)
        self.addWidget(self.allNotifiCB, ntl, 1, 1, 1)
        self.addWidget(self.cpuCB, ntl, 2, 1, 1)
        self.addWidget(self.ramCB, ntl, 3, 1, 1)
        self.addWidget(self.gpuCB, ntl, 4, 1, 1)
        self.addWidget(self.prjNameCB, ntl, 5, 1, 1)
        self.addWidget(self.dueDateCB, ntl, 6, 1, 1)
        self.addWidget(self.dueTimeCB, ntl, 7, 1, 1)
        self.addWidget(self.countdownCB, ntl, 8, 1, 1)
        self.addWidget(self.timeCB, ntl, 9, 1, 1)
        self.addWidget(self.dateCB, ntl, 10, 1, 1)
        self.addWidget(self.bodyCB, bdl, 0, 1, 1)

        self.la = bdl + 1
        return self.la
コード例 #11
0
    def buildHeaderCheckBoxes(self):
        self.buildToolBarCheckBoxes()
        self.buildMenuCheckBoxes()
        self.buildServerStatusCheckBoxes()
        self.headerCB = CheckBox('Header')
        self.headerCB.stateChanged.connect(self.headerStateChanged)

        mnl = self.la
        csl = mnl + 1
        tbl = csl + 1
        hdl = tbl + 1

        self.addWidget(Label({'txt': 'Menus'}), mnl, 0, 1, 1)
        self.addWidget(self.allMenuCB, mnl, 1, 1, 1)
        self.addWidget(self.mnAppCB, mnl, 2, 1, 1)
        self.addWidget(self.mnGoCB, mnl, 3, 1, 1)
        self.addWidget(self.mnOfficeCB, mnl, 4, 1, 1)
        self.addWidget(self.mnToolsCB, mnl, 5, 1, 1)
        self.addWidget(self.mnDevCB, mnl, 6, 1, 1)
        self.addWidget(self.mnLibCB, mnl, 7, 1, 1)
        self.addWidget(self.mnHelpCB, mnl, 8, 1, 1)

        self.addWidget(Label({'txt': 'Tool Bar: '}), tbl, 0, 1, 1)
        self.addWidget(self.allToolBarCB, tbl, 1, 1, 1)
        self.addWidget(self.tbTDCB, tbl, 2, 1, 1)
        self.addWidget(self.tbVfxCB, tbl, 3, 1, 1)
        self.addWidget(self.tbArtCB, tbl, 4, 1, 1)
        self.addWidget(self.tbTexCB, tbl, 5, 1, 1)
        self.addWidget(self.tbPostCB, tbl, 6, 1, 1)

        self.addWidget(Label({'txt': 'Connect Status'}), csl, 0, 1, 1)
        self.addWidget(self.allConnectCB, csl, 1, 1, 1)
        self.addWidget(self.serverCB, csl, 2, 1, 1)
        self.addWidget(self.onlineCB, csl, 3, 1, 1)
        self.addWidget(self.modeCB, csl, 4, 1, 1)

        self.addWidget(Label({'txt': 'Header'}), hdl, 0, 1, 1)
        self.addWidget(self.headerCB, hdl, 1, 1, 1)
コード例 #12
0
ファイル: SignIn.py プロジェクト: CGFanTuan/damgteam
class SignIn(Widget):

    key = 'SignIn'
    _login = False

    def __init__(self, parent=None):

        super(SignIn, self).__init__(parent)

        self.setWindowIcon(AppIcon(32, "SignIn"))
        self.setFixedSize(400, 300)
        self.setWindowTitle('Sign In')

        self.layout = GridLayout()
        self.buildUI()
        self.setLayout(self.layout)

    def buildUI(self):

        loginGrp, loginGrid = GroupGrid('Sign in')

        self.userTF = LineEdit()
        self.pwTF = LineEdit({'fn': 'password'})
        self.userCB = CheckBox('Remember me?')

        forgot_pw_btn = Button({
            'txt':
            'Forgot your password?',
            'cl':
            partial(self.signals.emit, 'showLayout', 'ForgotPassword', 'show')
        })
        login_btn = Button({'txt': 'Log in', 'cl': self.signInClicked})
        cancel_btn = Button({'txt': 'Cancel', 'cl': QApplication.quit})

        signupGrp, signupGrid = GroupGrid('Sign up')
        signupBtn = Button({
            'txt':
            'Sign up',
            'cl':
            partial(self.signals.emit, 'showLayout', 'SignUp', 'show')
        })

        loginGrid.addWidget(usernameLabel, 0, 0, 1, 2)
        loginGrid.addWidget(passwordLabel, 1, 0, 1, 2)
        loginGrid.addWidget(self.userTF, 0, 2, 1, 4)
        loginGrid.addWidget(self.pwTF, 1, 2, 1, 4)
        loginGrid.addWidget(self.userCB, 2, 1, 1, 2)
        loginGrid.addWidget(login_btn, 2, 3, 1, 3)
        loginGrid.addWidget(forgot_pw_btn, 3, 0, 1, 3)
        loginGrid.addWidget(cancel_btn, 3, 3, 1, 3)

        signupGrid.addWidget(Label({'txt': SIGNUP}), 0, 0, 1, 6)
        signupGrid.addWidget(signupBtn, 1, 0, 1, 6)

        self.layout.addWidget(loginGrp, 0, 0, 1, 1)
        self.layout.addWidget(signupGrp, 1, 0, 1, 1)

    def forgetPwClicked(self):
        if __name__ == '__main__':
            from ui.subUI.Funcs.ForgotPassword import ForgotPassword
            self.forgotPW = ForgotPassword()
            self.forgotPW.show()
        else:
            self.signals.showLayout('ForgotPassword', 'show')

    def signInClicked(self):
        username = str(self.userTF.text())
        pass_word = str(self.pwTF.text())

        if username == "" or username is None:
            MessageBox(self, 'Login Failed', 'critical', USER_BLANK)
            return
        elif pass_word == "" or pass_word is None:
            MessageBox(self, 'Login Failed', 'critical', PW_BLANK)
            return

        password = str(pass_word)

        r = requests.post(__localServerAutho__,
                          verify=False,
                          data={
                              'user': username,
                              'pwd': password
                          })

        if r.status_code == 200:
            for i in r.headers['set-cookie'].split(";"):
                if 'connect.sid=' in i:
                    cookie = i.split('connect.sid=')[-1]
                    break
                else:
                    cookie = "No value"
                    continue

            token = r.json()['token']
            check = self.userCB.checkState()

            RemoveDB("curUser")
            UpdateDB("curUser", [username, token, cookie, str2bool(check)])
            self.signals.emit('loginChanged', True)
        else:
            RemoveDB("curUser")
            MessageBox(self, 'Login Failed', 'critical', PW_WRONG)
            return

    def loginChanged(self, login):
        self._login = login

    @property
    def login(self):
        return self._login

    @login.setter
    def login(self, newVal):
        self._login = newVal
コード例 #13
0
    def __init__(self, parent=None):
        super(TaskDetails, self).__init__(parent)

        self.parent = parent
        self.addWidget(Label({'txt': 'Task Mode: '}), 0, 0, 1, 1)
        self.addWidget(Label({'txt': 'Task Type'}), 1, 0, 1, 1)

        self.individualMode = CheckBox('Individual')
        self.groupMode = CheckBox('Group')
        self.departmentMode = CheckBox('Department')

        self.individualMode.stateChanged.connect(self.individual)
        self.groupMode.stateChanged.connect(self.group)
        self.departmentMode.stateChanged.connect(self.department)

        self.researchType = CheckBox('Research')
        self.readingType = CheckBox('Reading')
        self.vfxType = CheckBox('VFX')
        self.researchType.stateChanged.connect(self.research)
        self.readingType.stateChanged.connect(self.reading)
        self.vfxType.stateChanged.connect(self.vfx)

        self.addWidget(self.individualMode, 0, 1, 1, 1)
        self.addWidget(self.groupMode, 0, 2, 1, 1)
        self.addWidget(self.departmentMode, 0, 3, 1, 1)
        self.addWidget(self.researchType, 1, 1, 1, 1)
        self.addWidget(self.readingType, 1, 2, 1, 1)
        self.addWidget(self.vfxType, 1, 3, 1, 1)

        self.taskDetails = PlainTextEdit()
        self.addWidget(self.taskDetails, 2, 0, 8, 8)
コード例 #14
0
class TaskDetails(GridLayout):

    key = 'TaskDetails'
    _taskMode = None
    _taskType = None

    def __init__(self, parent=None):
        super(TaskDetails, self).__init__(parent)

        self.parent = parent
        self.addWidget(Label({'txt': 'Task Mode: '}), 0, 0, 1, 1)
        self.addWidget(Label({'txt': 'Task Type'}), 1, 0, 1, 1)

        self.individualMode = CheckBox('Individual')
        self.groupMode = CheckBox('Group')
        self.departmentMode = CheckBox('Department')

        self.individualMode.stateChanged.connect(self.individual)
        self.groupMode.stateChanged.connect(self.group)
        self.departmentMode.stateChanged.connect(self.department)

        self.researchType = CheckBox('Research')
        self.readingType = CheckBox('Reading')
        self.vfxType = CheckBox('VFX')
        self.researchType.stateChanged.connect(self.research)
        self.readingType.stateChanged.connect(self.reading)
        self.vfxType.stateChanged.connect(self.vfx)

        self.addWidget(self.individualMode, 0, 1, 1, 1)
        self.addWidget(self.groupMode, 0, 2, 1, 1)
        self.addWidget(self.departmentMode, 0, 3, 1, 1)
        self.addWidget(self.researchType, 1, 1, 1, 1)
        self.addWidget(self.readingType, 1, 2, 1, 1)
        self.addWidget(self.vfxType, 1, 3, 1, 1)

        self.taskDetails = PlainTextEdit()
        self.addWidget(self.taskDetails, 2, 0, 8, 8)

    def individual(self, bool):
        if str2bool(bool):
            self.groupMode.setChecked(False)
            self.departmentMode.setChecked(False)
            self._taskMode = 'individual'

    def group(self, bool):
        if str2bool(bool):
            self.individualMode.setChecked(False)
            self.departmentMode.setChecked(False)
            self._taskMode = 'group'

    def department(self, bool):
        if str2bool(bool):
            self.individualMode.setChecked(False)
            self.groupMode.setChecked(False)
            self._taskMode = 'department'

    def research(self, bool):
        if str2bool(bool):
            self.readingType.setChecked(False)
            self.vfxType.setChecked(False)
            self._taskType = 'research'

    def reading(self, bool):
        if str2bool(bool):
            self.researchType.setChecked(False)
            self.vfxType.setChecked(False)
            self._taskType = 'reading'

    def vfx(self, bool):
        if str2bool(bool):
            self.researchType.setChecked(False)
            self.readingType.setChecked(False)
            self._taskType = 'vfx'

    @property
    def taskType(self):
        return self._taskType

    @taskType.setter
    def taskType(self, val):
        self._taskType = val

    @property
    def taskMode(self):
        return self._taskMode

    @taskMode.setter
    def taskMode(self, val):
        self._taskMode = val
コード例 #15
0
 def buildNotificationCheckBoxes(self):
     self.cpuCB = CheckBox('cpu')
     self.ramCB = CheckBox('ram')
     self.gpuCB = CheckBox('gpu')
     self.diskCB = CheckBox('disk')
     self.prjNameCB = CheckBox('Project Name')
     self.dueDateCB = CheckBox('Due Date')
     self.dueTimeCB = CheckBox('Due Time')
     self.countdownCB = CheckBox('Time Counting')
     self.timeCB = CheckBox('clock')
     self.dateCB = CheckBox('date')
     self.allNotifiCB = CheckBox("All: ")
     self.allNotifiCB.stateChanged.connect(self.allNotifiStateChanged)
     for cb in [self.cpuCB, self.ramCB, self.gpuCB, self.diskCB, self.prjNameCB, self.dueDateCB, self.dueTimeCB,
                self.countdownCB, self.timeCB, self.dateCB, self.allNotifiCB]:
         self.notificationCBs.append(cb)
コード例 #16
0
ファイル: SignUp.py プロジェクト: CGFanTuan/damgteam
class SignUp(Widget):

    key = 'SignUp'

    def __init__(self, parent=None):
        super(SignUp, self).__init__(parent)

        self.setWindowIcon(AppIcon(32, "SignUp"))

        self.layout = GridLayout()
        self.buildUI()
        self.setLayout(self.layout)

    def buildUI(self):
        self.avatar_section()
        self.account_section()
        self.profile_section()
        self.location_section()
        self.security_section()
        self.buttons_section()

        self.layout.addWidget(Label({'txt': "ALL FIELD ARE REQUIRED!!!"}), 0,
                              0, 1, 6)
        self.layout.addWidget(self.avaSection, 1, 0, 1, 2)
        self.layout.addWidget(self.accSection, 1, 2, 1, 4)
        self.layout.addWidget(self.prfSection, 2, 0, 1, 6)
        self.layout.addWidget(self.conSection, 3, 0, 1, 6)
        self.layout.addWidget(self.serSection, 4, 0, 1, 6)
        self.layout.addWidget(self.btnSection, 5, 0, 1, 6)

        self.applySetting()

    def avatar_section(self):
        self.avaSection, avatar_grid = GroupGrid("Avatar")

        self.userAvatar = Label({
            'pxm': 'default',
            'scc': True,
            'sfs': [100, 100]
        })

        set_avatarBtn = Button({
            'txt': 'Set Avatar',
            'tt': 'Choose a showLayout_new avatar',
            'cl': self.setAvaClicked
        })

        avatar_grid.addWidget(self.userAvatar, 0, 0, 2, 2)
        avatar_grid.addWidget(set_avatarBtn, 2, 0, 1, 2)

    def account_section(self):
        self.accSection, account_grid = GroupGrid("Account")
        self.userField = LineEdit()
        self.pwField = LineEdit({'fn': 'password'})
        self.cfpwField = LineEdit({'fn': 'password'})

        account_grid.addWidget(Label({'txt': 'User Name'}), 0, 0, 1, 2)
        account_grid.addWidget(Label({'txt': 'Password'}), 1, 0, 1, 2)
        account_grid.addWidget(Label({'txt': 'Confirm Password'}), 2, 0, 1, 2)

        account_grid.addWidget(self.userField, 0, 3, 1, 4)
        account_grid.addWidget(self.pwField, 1, 3, 1, 4)
        account_grid.addWidget(self.cfpwField, 2, 3, 1, 4)

    def profile_section(self):
        self.prfSection, profile_grid = GroupGrid("Profile")

        profile_grid.addWidget(Label({'txt': 'First Name'}), 0, 0, 1, 2)
        profile_grid.addWidget(Label({'txt': 'Last Name'}), 1, 0, 1, 2)
        profile_grid.addWidget(Label({'txt': 'Your Title'}), 2, 0, 1, 2)
        profile_grid.addWidget(Label({'txt': 'Email'}), 3, 0, 1, 2)
        profile_grid.addWidget(Label({'txt': 'Phone Number'}), 4, 0, 1, 2)

        self.titleField = LineEdit()
        self.firstnameField = LineEdit()
        self.lastnameField = LineEdit()
        self.emailField = LineEdit()
        self.phoneField = LineEdit()

        profile_grid.addWidget(self.firstnameField, 0, 2, 1, 4)
        profile_grid.addWidget(self.lastnameField, 1, 2, 1, 4)
        profile_grid.addWidget(self.titleField, 2, 2, 1, 4)
        profile_grid.addWidget(self.emailField, 3, 2, 1, 4)
        profile_grid.addWidget(self.phoneField, 4, 2, 1, 4)

    def location_section(self):
        self.conSection, conGrid = GroupGrid("Location")

        conGrid.addWidget(Label({'txt': "Address Line 1"}), 0, 0, 1, 2)
        conGrid.addWidget(Label({'txt': "Address Line 2"}), 1, 0, 1, 2)
        conGrid.addWidget(Label({'txt': "Postal"}), 2, 0, 1, 2)
        conGrid.addWidget(Label({'txt': "City"}), 3, 0, 1, 2)
        conGrid.addWidget(Label({'txt': "Country"}), 4, 0, 1, 2)

        self.addressLine1 = LineEdit()
        self.addressLine2 = LineEdit()
        self.postalCode = LineEdit()
        self.city = LineEdit()
        self.country = LineEdit()

        conGrid.addWidget(self.addressLine1, 0, 2, 1, 4)
        conGrid.addWidget(self.addressLine2, 1, 2, 1, 4)
        conGrid.addWidget(self.city, 2, 2, 1, 4)
        conGrid.addWidget(self.postalCode, 3, 2, 1, 4)
        conGrid.addWidget(self.country, 4, 2, 1, 4)

    def security_section(self):

        self.serSection, questions_grid = GroupGrid("Security Question")

        self.ques1 = ComboBox(
            {'items': [str(i) for i in QUESTIONS.split('\n')]})
        self.answ2 = LineEdit()

        self.ques2 = ComboBox(
            {'items': [str(i) for i in QUESTIONS.split('\n')]})
        self.answ1 = LineEdit()

        questions_grid.addWidget(Label({'txt': 'Question 1'}), 0, 0, 1, 3)
        questions_grid.addWidget(Label({'txt': 'Answer 1'}), 1, 0, 1, 3)
        questions_grid.addWidget(Label({'txt': 'Question 2'}), 2, 0, 1, 3)
        questions_grid.addWidget(Label({'txt': 'Answer 2'}), 3, 0, 1, 3)

        questions_grid.addWidget(self.ques1, 0, 3, 1, 6)
        questions_grid.addWidget(self.answ1, 1, 3, 1, 6)
        questions_grid.addWidget(self.ques2, 2, 3, 1, 6)
        questions_grid.addWidget(self.answ2, 3, 3, 1, 6)

    def buttons_section(self):
        self.btnSection, btn_grid = GroupGrid()

        self.user_agree_checkBox = CheckBox(txt=USER_CHECK_REQUIRED)
        okBtn = Button({
            'txt': 'Create Account',
            'tt': 'Confirm to create an account',
            'cl': self.createBtnClicked
        })
        cancelBtn = Button({
            'txt':
            'Cancel',
            'tt':
            'Go back to Login stage',
            'cl':
            partial(self.signals.emit, 'showLayout', 'SignIn', 'SignIn')
        })
        quitBtn = Button({
            'txt': 'Quit',
            'tt': 'Quit the application',
            'cl': QApplication.quit
        })

        btn_grid.addWidget(self.user_agree_checkBox, 0, 0, 1, 6)
        btn_grid.addWidget(okBtn, 1, 0, 1, 2)
        btn_grid.addWidget(cancelBtn, 1, 2, 1, 2)
        btn_grid.addWidget(quitBtn, 1, 4, 1, 2)

    def setAvaClicked(self):
        options = QFileDialog.Options()
        options |= QFileDialog.DontUseNativeDialog
        self.rawAvatarPth, _ = QFileDialog.getOpenFileName(
            self,
            "Your Avatar",
            os.path.join('imgs', 'avatar'),
            "All Files (*);;Img Files (*.jpg)",
            options=options)

        if self.rawAvatarPth:
            self.userAvatar.setPixmap(
                QPixmap.fromImage(QImage(self.rawAvatarPth)))
            self.userAvatar.update()

    def createBtnClicked(self):
        if self.check_all_conditions():
            data = self.generate_user_data()
            MessageBox(self, "Failed", "information", WAIT_LAYOUT_COMPLETE,
                       'ok')
            return

    def collect_input(self):
        username = str(self.userField.text())
        password = str(self.pwField.text())
        confirm = str(self.cfpwField.text())
        firstname = str(self.firstnameField.text())
        lastname = str(self.lastnameField.text())
        email = str(self.emailField.text())
        phone = str(self.phoneField.text())
        address1 = str(self.addressLine1.text())
        address2 = str(self.addressLine2.text())
        postal = str(self.postalCode.text())
        city = str(self.city.text())
        country = str(self.country.text())
        answer1 = str(self.answ1.text())
        answer2 = str(self.answ2.text())
        return [
            username, password, confirm, firstname, lastname, email, phone,
            address1, address2, postal, city, country, answer1, answer2
        ]

    def check_all_conditions(self):
        if self.check_all_field_blank():
            if self.check_user_agreement():
                if self.check_pw_matching():
                    return True
        else:
            return False

    def check_all_field_blank(self):
        regInput = self.collect_input()
        secName = [
            "Username", "Password", "Confirm Password", "Firstname",
            "Lastname", "Email", "Phone", "Address line 1", "Address line 2",
            "Postal", "City", "Country", "Answer 1", "Answer 2"
        ]
        for section in regInput:
            if check_blank(section):
                return True
            else:
                QMessageBox.information(
                    self, "Fail", secName[regInput.index(section)] + "Blank",
                    QMessageBox.Ok)
                break

    def check_user_agreement(self):
        return self.user_agree_checkBox.checkState()

    def applySetting(self):
        self.resize(450, 900)

    def generate_user_data(self):
        regInput = self.collect_input()
        question1 = str(self.ques1.currentText())
        question2 = str(self.ques2.currentText())
        title = str(self.titleField.text()) or "Guess"

        token = getToken()
        timelog = getTime()
        sysInfo = get_user_location()
        productID = sysInfo['Product ID']
        ip, cityIP, countryIP = get_local_pc_info()
        unix = getUnix()
        datelog = getDate()
        pcOS = sysInfo['os']
        pcUser = sysInfo['pcUser']
        pcPython = sysInfo['python']

        if not os.path.exists(self.rawAvatarPth):
            avatar = get_avatar_image('default')
        else:
            avatar = self.rawAvatarPth

        data = [
            regInput[0], regInput[1], regInput[3], regInput[4], title,
            regInput[5], regInput[6], regInput[7], regInput[8], regInput[9],
            regInput[10], regInput[11], token, timelog, productID, ip, cityIP,
            countryIP, unix, question1, regInput[12], question2, regInput[13],
            datelog, pcOS, pcUser, pcPython, avatar
        ]
        return data

    def check_pw_matching(self):
        password = str(self.pwField.text())
        confirm = str(self.cfpwField.text())
        check_pass = check_match(password, confirm)
        if not check_pass:
            QMessageBox.information(self, "Warning", PW_UNMATCH,
                                    QMessageBox.Retry)
            return False
        return True

    def loginChanged(self, login):
        self._login = login

    @property
    def login(self):
        return self._login

    @login.setter
    def login(self, newVal):
        self._login = newVal
コード例 #17
0
class HeaderCheckBoxes(GridLayout):

    key = 'HeaderCheckBoxes'
    toolBarCBs = DAMGLIST()
    menuCBs = DAMGLIST()
    connectCBs = DAMGLIST()
    checkboxes = DAMGDICT()
    def __init__(self, parent=None):
        super(HeaderCheckBoxes, self).__init__(parent)
        self.parent = parent
        self.la = 0
        self.buildHeaderCheckBoxes()

        cbs = [self.toolBarCBs, self.menuCBs, self.connectCBs, [self.headerCB]]

        for i in range(len(cbs)):
            if i == 0:
                prefix = 'ToolBar'
            elif i == 1:
                prefix = 'Menu'
            elif i == 2:
                prefix = 'Network'
            else:
                prefix = 'Header'

            for cb in cbs[i]:
                cb.key = '{0}_{1}_CheckBox_{2}'.format(self.parent.key, prefix, cb.text())
                cb._name = '{0} {1} Check Box: {2}'.format(self.parent.key, prefix, cb.text())

                cb.settings._settingEnable = True
                state = cb.getValue('checkState')
                if state is None:
                    state = True
                cb.setValue('checkState', state)
                cb.setChecked(str2bool(state))
                self.checkboxes.add(cb.key, cb)

    def buildHeaderCheckBoxes(self):
        self.buildToolBarCheckBoxes()
        self.buildMenuCheckBoxes()
        self.buildServerStatusCheckBoxes()
        self.headerCB = CheckBox('Header')
        self.headerCB.stateChanged.connect(self.headerStateChanged)

        mnl = self.la
        csl = mnl + 1
        tbl = csl + 1
        hdl = tbl + 1

        self.addWidget(Label({'txt': 'Menus'}), mnl, 0, 1, 1)
        self.addWidget(self.allMenuCB, mnl, 1, 1, 1)
        self.addWidget(self.mnAppCB, mnl, 2, 1, 1)
        self.addWidget(self.mnGoCB, mnl, 3, 1, 1)
        self.addWidget(self.mnOfficeCB, mnl, 4, 1, 1)
        self.addWidget(self.mnToolsCB, mnl, 5, 1, 1)
        self.addWidget(self.mnDevCB, mnl, 6, 1, 1)
        self.addWidget(self.mnLibCB, mnl, 7, 1, 1)
        self.addWidget(self.mnHelpCB, mnl, 8, 1, 1)

        self.addWidget(Label({'txt': 'Tool Bar: '}), tbl, 0, 1, 1)
        self.addWidget(self.allToolBarCB, tbl, 1, 1, 1)
        self.addWidget(self.tbTDCB, tbl, 2, 1, 1)
        self.addWidget(self.tbVfxCB, tbl, 3, 1, 1)
        self.addWidget(self.tbArtCB, tbl, 4, 1, 1)
        self.addWidget(self.tbTexCB, tbl, 5, 1, 1)
        self.addWidget(self.tbPostCB, tbl, 6, 1, 1)

        self.addWidget(Label({'txt': 'Connect Status'}), csl, 0, 1, 1)
        self.addWidget(self.allConnectCB, csl, 1, 1, 1)
        self.addWidget(self.serverCB, csl, 2, 1, 1)
        self.addWidget(self.onlineCB, csl, 3, 1, 1)
        self.addWidget(self.modeCB, csl, 4, 1, 1)

        self.addWidget(Label({'txt': 'Header'}), hdl, 0, 1, 1)
        self.addWidget(self.headerCB, hdl, 1, 1, 1)

    def buildServerStatusCheckBoxes(self):
        self.serverCB = CheckBox('Server')
        self.onlineCB = CheckBox('Internet')
        self.modeCB = CheckBox('Mode')
        self.allConnectCB = CheckBox("All: ")
        self.allConnectCB.stateChanged.connect(self.allConnectStateChanged)
        for cb in [self.serverCB, self.onlineCB, self.modeCB, self.allConnectCB]:
            self.connectCBs.append(cb)

    def buildMenuCheckBoxes(self):
        self.mnAppCB = CheckBox('&App')
        self.mnGoCB = CheckBox('&Go')
        self.mnOfficeCB = CheckBox('&Office')
        self.mnToolsCB = CheckBox('&Tools')
        self.mnDevCB = CheckBox('&Dev')
        self.mnLibCB = CheckBox('&Lib')
        self.mnHelpCB = CheckBox('&Help')
        self.allMenuCB = CheckBox('All: ')
        self.allMenuCB.stateChanged.connect(self.allMenuStateChanged)
        for cb in [self.mnAppCB, self.mnGoCB, self.mnOfficeCB, self.mnToolsCB, self.mnDevCB, self.mnLibCB,
                   self.mnHelpCB, self.allMenuCB]:
            self.menuCBs.append(cb)

    def buildToolBarCheckBoxes(self):
        self.tbTDCB = CheckBox("TD")
        self.tbVfxCB = CheckBox("VFX")
        self.tbArtCB = CheckBox("Art")
        self.tbTexCB = CheckBox("Tex")
        self.tbPostCB = CheckBox('Post')
        self.allToolBarCB = CheckBox("All: ")
        self.allToolBarCB.stateChanged.connect(self.allToolBarStateChanged)
        for cb in [self.tbTDCB, self.tbVfxCB, self.tbArtCB, self.tbTexCB, self.tbPostCB, self.allToolBarCB]:
            self.toolBarCBs.append(cb)

    def allToolBarStateChanged(self, bool):
        for cb in self.toolBarCBs:
            cb.setChecked(bool)

    def allMenuStateChanged(self, bool):
        for cb in self.menuCBs:
            cb.setChecked(bool)

    def allConnectStateChanged(self, bool):
        for cb in self.connectCBs:
            cb.setChecked(bool)

    def headerStateChanged(self, bool):
        self.allToolBarCB.setChecked(bool)
        self.allMenuCB.setChecked(bool)
        self.allConnectCB.setChecked(bool)