[Pykafe-commits] SF.net SVN: pykafe: [156] trunk
Status: Pre-Alpha
Brought to you by:
jnmbk
From: <jn...@us...> - 2008-01-27 15:43:22
|
Revision: 156 http://pykafe.svn.sourceforge.net/pykafe/?rev=156&view=rev Author: jnmbk Date: 2008-01-27 07:43:26 -0800 (Sun, 27 Jan 2008) Log Message: ----------- show dummy passwordWindow Modified Paths: -------------- trunk/TODO trunk/pykafe/server/main.py trunk/pykafe/server/mainwindow_server.py trunk/pykafe/server/passwordwindow.py Added Paths: ----------- trunk/ui/passwordwindow.ui Modified: trunk/TODO =================================================================== --- trunk/TODO 2008-01-27 11:20:14 UTC (rev 155) +++ trunk/TODO 2008-01-27 15:43:26 UTC (rev 156) @@ -5,3 +5,4 @@ * complete all inline TODO's * menus should be capable of doing anything * add shortcut keys to all functions and buttons +* Make applications unique like in KUniqueApplication or QtSingleApplication Modified: trunk/pykafe/server/main.py =================================================================== --- trunk/pykafe/server/main.py 2008-01-27 11:20:14 UTC (rev 155) +++ trunk/pykafe/server/main.py 2008-01-27 15:43:26 UTC (rev 156) @@ -19,6 +19,9 @@ from PyQt4 import QtCore from PyQt4 import QtGui +import passwordwindow +import mainwindow_server + def loadTranslator(): settings = QtCore.QSettings() if settings.contains("language"): @@ -37,9 +40,15 @@ loadTranslator() - import mainwindow_server mainWindow = mainwindow_server.MainWindow() + passwordWindow = passwordwindow.PasswordWindow(mainWindow) + settings = QtCore.QSettings() + if settings.value("start/askpassword", QtCore.QVariant(True)).toBool(): + passwordWindow.show() + else: + mainWindow.show() + return app.exec_() if __name__ == "__main__": Modified: trunk/pykafe/server/mainwindow_server.py =================================================================== --- trunk/pykafe/server/mainwindow_server.py 2008-01-27 11:20:14 UTC (rev 155) +++ trunk/pykafe/server/mainwindow_server.py 2008-01-27 15:43:26 UTC (rev 156) @@ -24,12 +24,13 @@ self.tcpServer = tcpserver.TcpServer(self) - self.show() + """ if not self.tcpServer.isListening(): QtGui.QMessageBox.critical(self, QtGui.QApplication.translate("MainWindow", "Connection Error"), QtGui.QApplication.translate("MainWindow", "Unable to start server: %1").arg(self.tcpServer.errorString())) + """ @QtCore.pyqtSignature("on_main_startButton_clicked()") def on_main_startButton_clicked(self): Modified: trunk/pykafe/server/passwordwindow.py =================================================================== --- trunk/pykafe/server/passwordwindow.py 2008-01-27 11:20:14 UTC (rev 155) +++ trunk/pykafe/server/passwordwindow.py 2008-01-27 15:43:26 UTC (rev 156) @@ -1,5 +1,8 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- # -# Copyright (C) 2007, pyKafe Development Team +# Licensed under GPL v2 +# Copyright 2008, Ugur Cetin # # This program is free software; you can redistribute it and/or modify it under # the terms of the GNU General Public License as published by the Free @@ -9,82 +12,32 @@ # Please read the COPYING file. # -from PyQt4 import QtCore, QtGui -from database import Database -from mainwindow import Ui_MainWindow import sha -import locale, gettext -locale.setlocale(locale.LC_ALL, "C") -_ = gettext.translation("pyKafe_server", fallback=True).ugettext +from PyQt4 import QtCore +from PyQt4 import QtGui -class Ui_Dialog(object): - def setupUi(self, Dialog): - Dialog.setObjectName("Dialog") - Dialog.resize(QtCore.QSize(QtCore.QRect(0,0,226,159).size()).expandedTo(Dialog.minimumSizeHint())) - Dialog.setWindowIcon(QtGui.QIcon("../../data/icons/pyKafe.png")) +import passwordwindow_ui - self.gridlayout = QtGui.QGridLayout(Dialog) - self.gridlayout.setMargin(9) - self.gridlayout.setSpacing(6) - self.gridlayout.setObjectName("gridlayout") +class PasswordWindow(QtGui.QDialog, passwordwindow_ui.Ui_Dialog): + def __init__(self, mainWindow): + QtGui.QDialog.__init__(self, mainWindow) + self.setupUi(self) + self.mainWindow = mainWindow - spacerItem = QtGui.QSpacerItem(40,20,QtGui.QSizePolicy.Expanding,QtGui.QSizePolicy.Minimum) - self.gridlayout.addItem(spacerItem,2,0,1,1) - - spacerItem1 = QtGui.QSpacerItem(40,20,QtGui.QSizePolicy.Expanding,QtGui.QSizePolicy.Minimum) - self.gridlayout.addItem(spacerItem1,2,3,1,1) - - spacerItem2 = QtGui.QSpacerItem(20,40,QtGui.QSizePolicy.Minimum,QtGui.QSizePolicy.Expanding) - self.gridlayout.addItem(spacerItem2,0,2,1,1) - - spacerItem3 = QtGui.QSpacerItem(20,40,QtGui.QSizePolicy.Minimum,QtGui.QSizePolicy.Expanding) - self.gridlayout.addItem(spacerItem3,4,2,1,1) - - self.buttonBox = QtGui.QDialogButtonBox(Dialog) - self.buttonBox.setOrientation(QtCore.Qt.Horizontal) - self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel|QtGui.QDialogButtonBox.NoButton|QtGui.QDialogButtonBox.Ok) - self.buttonBox.setObjectName("buttonBox") - self.gridlayout.addWidget(self.buttonBox,3,1,1,2) - - self.label = QtGui.QLabel(Dialog) - self.label.setObjectName("label") - self.gridlayout.addWidget(self.label,1,1,1,1) - - self.username = QtGui.QLineEdit(Dialog) - self.username.setObjectName("username") - self.gridlayout.addWidget(self.username,1,2,1,1) - - self.label_2 = QtGui.QLabel(Dialog) - self.label_2.setObjectName("label_2") - self.gridlayout.addWidget(self.label_2,2,1,1,1) - - self.password = QtGui.QLineEdit(Dialog) - self.password.setEchoMode(QtGui.QLineEdit.Password) - self.password.setObjectName("password") - self.gridlayout.addWidget(self.password,2,2,1,1) - - self.retranslateUi(Dialog) - self.dialog = Dialog - QtCore.QObject.connect(self.buttonBox,QtCore.SIGNAL("accepted()"),self.accept) - QtCore.QObject.connect(self.buttonBox,QtCore.SIGNAL("rejected()"),self.reject) - QtCore.QMetaObject.connectSlotsByName(Dialog) - - def retranslateUi(self, Dialog): - Dialog.setWindowTitle("pyKafe") - self.label.setText(_("Username:")) - self.label_2.setText(_("Password:")) - def accept(self): - parameters = unicode(self.username.text()), sha.new(unicode(self.password.text())).hexdigest() - result = Database().runOnce("select count(*) from members where username=? and password=? and is_cashier='1'", parameters) - if result[0][0]: - self.dialog.hide() - window = QtGui.QMainWindow(self.dialog) - ui = Ui_MainWindow() - ui.setupUi(window, parameters[0]) - window.show() + parameters = (unicode(self.username.text()), + sha.new(unicode(self.password.text())).hexdigest()) + #TODO: this shoud use database + #found = Database().runOnce("select count(*) from members where username=? and password=? and is_cashier='1'", parameters) + found = True + if found: + self.hide() + self.mainWindow.show() else: - QtGui.QMessageBox.critical(self.dialog, _("Error"), _("Wrong username or password")) + QtGui.QMessageBox.critical(None, QtGui.QApplication.translate("MainWindow", + "Error"), QtGui.QApplication.translate("MainWindow", + "Wrong username or password!")) + QtGui.QApplication.quit() def reject(self): - self.dialog.close() + QtGui.QApplication.quit() Copied: trunk/ui/passwordwindow.ui (from rev 145, trunk/pykafe/server/password.ui) =================================================================== --- trunk/ui/passwordwindow.ui (rev 0) +++ trunk/ui/passwordwindow.ui 2008-01-27 15:43:26 UTC (rev 156) @@ -0,0 +1,162 @@ +<ui version="4.0" > + <class>Dialog</class> + <widget class="QDialog" name="Dialog" > + <property name="geometry" > + <rect> + <x>0</x> + <y>0</y> + <width>226</width> + <height>159</height> + </rect> + </property> + <property name="windowTitle" > + <string>PyKafe</string> + </property> + <property name="windowIcon" > + <iconset resource="../data/pykafe.qrc" >:/icons/icons/pyKafe.png</iconset> + </property> + <layout class="QGridLayout" > + <property name="leftMargin" > + <number>9</number> + </property> + <property name="topMargin" > + <number>9</number> + </property> + <property name="rightMargin" > + <number>9</number> + </property> + <property name="bottomMargin" > + <number>9</number> + </property> + <property name="horizontalSpacing" > + <number>6</number> + </property> + <property name="verticalSpacing" > + <number>6</number> + </property> + <item row="2" column="0" > + <spacer> + <property name="orientation" > + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" > + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item row="2" column="3" > + <spacer> + <property name="orientation" > + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" > + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item row="0" column="2" > + <spacer> + <property name="orientation" > + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" > + <size> + <width>20</width> + <height>40</height> + </size> + </property> + </spacer> + </item> + <item row="4" column="2" > + <spacer> + <property name="orientation" > + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" > + <size> + <width>20</width> + <height>40</height> + </size> + </property> + </spacer> + </item> + <item row="3" column="1" colspan="2" > + <widget class="QDialogButtonBox" name="buttonBox" > + <property name="orientation" > + <enum>Qt::Horizontal</enum> + </property> + <property name="standardButtons" > + <set>QDialogButtonBox::Cancel|QDialogButtonBox::NoButton|QDialogButtonBox::Ok</set> + </property> + </widget> + </item> + <item row="1" column="1" > + <widget class="QLabel" name="label" > + <property name="text" > + <string>Username:</string> + </property> + </widget> + </item> + <item row="1" column="2" > + <widget class="QLineEdit" name="username" /> + </item> + <item row="2" column="1" > + <widget class="QLabel" name="label_2" > + <property name="text" > + <string>Password:</string> + </property> + </widget> + </item> + <item row="2" column="2" > + <widget class="QLineEdit" name="password" > + <property name="echoMode" > + <enum>QLineEdit::Password</enum> + </property> + </widget> + </item> + </layout> + </widget> + <resources> + <include location="../data/pykafe.qrc" /> + </resources> + <connections> + <connection> + <sender>buttonBox</sender> + <signal>accepted()</signal> + <receiver>Dialog</receiver> + <slot>accept()</slot> + <hints> + <hint type="sourcelabel" > + <x>248</x> + <y>254</y> + </hint> + <hint type="destinationlabel" > + <x>157</x> + <y>274</y> + </hint> + </hints> + </connection> + <connection> + <sender>buttonBox</sender> + <signal>rejected()</signal> + <receiver>Dialog</receiver> + <slot>reject()</slot> + <hints> + <hint type="sourcelabel" > + <x>316</x> + <y>260</y> + </hint> + <hint type="destinationlabel" > + <x>286</x> + <y>274</y> + </hint> + </hints> + </connection> + </connections> +</ui> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |