SF.net SVN: fclient:[918] trunk/fclient/fclient/impl/DlgDownloadKeyToDisk. py
Status: Pre-Alpha
Brought to you by:
jurner
From: <jU...@us...> - 2008-08-16 08:19:59
|
Revision: 918 http://fclient.svn.sourceforge.net/fclient/?rev=918&view=rev Author: jUrner Date: 2008-08-16 08:20:07 +0000 (Sat, 16 Aug 2008) Log Message: ----------- no longer needed Removed Paths: ------------- trunk/fclient/fclient/impl/DlgDownloadKeyToDisk.py Deleted: trunk/fclient/fclient/impl/DlgDownloadKeyToDisk.py =================================================================== --- trunk/fclient/fclient/impl/DlgDownloadKeyToDisk.py 2008-08-16 08:19:24 UTC (rev 917) +++ trunk/fclient/fclient/impl/DlgDownloadKeyToDisk.py 2008-08-16 08:20:07 UTC (rev 918) @@ -1,146 +0,0 @@ -#*************************************************************************************** -#TODO: -# x. have to inject (..whatebver) a checkbox into msg box invalid key warning <x don't show this message again> -# x. save dialog pos/size on exit -# -#************************************************************************************* - -from __future__ import absolute_import -if __name__ == '__main__': # see --> http://bugs.python.org/issue1510172 . works only current dir and below - import os; __path__ = [os.path.dirname(__file__)] - -import os -from PyQt4 import QtCore, QtGui - -from . import config -from .lib import fcp2 - -from .tpls.Ui_DlgDownloadKeyToDiskTpl import Ui_DlgDownloadKeyToDisk -#********************************************************************************** -# -#********************************************************************************** -class Settings(config.SettingsBase): - _key_ = 'DlgDownloadKeyToDisk' - _settings_ = ( - ('Geometry', 'ByteArray', QtCore.QByteArray()), - ) - - -#********************************************************************************** -# -#********************************************************************************** -class DlgDownloadKeyToDisk(QtGui.QDialog, Ui_DlgDownloadKeyToDisk): - - IdEdKey = 'edKey' - IdEdFileName = 'edFileName' - IdEdDirectory = 'edDirectory' - IdBtChooseDirectory = 'btChooseDirectory' - - - def __init__(self, parent=None, fcpKey=None): - QtGui.QDialog.__init__(self, parent) - - self.setupUi(self) - self.setWindowTitle(config.FcAppName + self.trUtf8(' - Download key..')) - self.fcSettings = Settings(self).restore() - - self._fileName = None - self._fcpKey = fcpKey - - # setup key editbox - ed = self.controlById(self.IdEdKey) - if fcpKey is not None: - ed.setText(fcpKey.toString()) - - # setup filename editbox - ed = self.controlById(self.IdEdFileName) - if fcpKey is not None: - # find out fileName to dl key to - fileName = config.guessFileNameFromKey(self._fcpKey) - if fileName is None: - fileName = self.trUtf8('UNKNOWN') - ed.setText(fileName) - - # setup directory editbox - ed = self.controlById(self.IdEdDirectory) - ed.setText(unicode(config.fcSettings.value('DownloadDir'))) - bt = self.controlById(self.IdBtChooseDirectory) - self.connect(bt, QtCore.SIGNAL('clicked()'), self.onChooseDirectory) - - - self.restoreGeometry(self.fcSettings.value('Geometry')) - - ############################## - ## methods - ############################## - def controlById(self, idControl): - return getattr(self, idControl) - - def fileName(self): - return self._fileName - - def fcpKey(self): - return self._fcpKey - - ############################## - ## overwritten methods - ############################## - def accept(self): - edKey = self.controlById(self.IdEdKey) - edFileName = self.controlById(self.IdEdFileName) - edDirectory = self.controlById(self.IdEdDirectory) - - key = unicode(edKey.text()) - if not key: - return QtGui.QMessageBox.warning(self, self.windowTitle(), 'Please enter a key to download') - try: - self._fcpKey = fcp2.Key(key) - except fcp2.ErrorKey: - return QtGui.QMessageBox.warning(self, self.windowTitle(), 'Looks like the key entered is not valid') - - fileName = edFileName.text() - if fileName.isEmpty(): - return QtGui.QMessageBox.warning(self, self.windowTitle(), 'Please enter a filename for the key') - - directory = edDirectory.text() - if directory.isEmpty(): - return QtGui.QMessageBox.warning(self, self.windowTitle(), 'Please enter a directory under wich to save the key') - - self._fileName = os.path.join(unicode(directory), unicode(fileName)) - self.done(self.Accepted) - - ############################## - ## overwritten events - ############################## - def hideEvent(self, event): - self.fcSettings.setValues(Geometry=self.saveGeometry()) - - ############################## - ## event handlers - ############################## - def onChooseDirectory(self): - edDirectory = self.controlById(self.IdEdDirectory) - directory = QtGui.QFileDialog.getExistingDirectory( - self, - config.FcAppName + self.trUtf8(' - Download key to..'), - edDirectory.text(), - ) - if directory: - edDirectory.setText(directory) - -#********************************************************************************** -# -#********************************************************************************** -if __name__ == '__main__': - import sys - - app = QtGui.QApplication(sys.argv) - w = DlgDownloadKeyToDisk( - #None, - fcpKey=fcp2.KeyKSK('foo.txt') - ) - w.show() - res = app.exec_() - sys.exit(res) - - This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |