<s> import sys <EOL> from stalker import LocalSession <EOL> from anima . ui . utils import logger <EOL> from anima . ui . lib import QtCore , QtGui <EOL> class AnimaDialogBase ( object ) : <EOL> """<STR_LIT>""" <EOL> def center_window ( self ) : <EOL> """<STR_LIT>""" <EOL> desktop = QtGui . QApplication . desktop ( ) <EOL> cursor_pos = QtGui . QCursor . pos ( ) <EOL> desktop_number = desktop . screenNumber ( cursor_pos ) <EOL> desktop_rect = desktop . screenGeometry ( desktop_number ) <EOL> size = self . geometry ( ) <EOL> self . move ( <EOL> ( desktop_rect . width ( ) - size . width ( ) ) * <NUM_LIT:0.5> + desktop_rect . left ( ) , <EOL> ( desktop_rect . height ( ) - size . height ( ) ) * <NUM_LIT:0.5> + desktop_rect . top ( ) <EOL> ) <EOL> def get_logged_in_user ( self ) : <EOL> """<STR_LIT>""" <EOL> local_session = LocalSession ( ) <EOL> logged_in_user = local_session . logged_in_user <EOL> if not logged_in_user : <EOL> from anima . ui import login_dialog <EOL> dialog = login_dialog . MainDialog ( parent = self ) <EOL> dialog . exec_ ( ) <EOL> logger . debug ( "<STR_LIT>" % dialog . DialogCode ) <EOL> try : <EOL> accepted = QtGui . QDialog . DialogCode . Accepted <EOL> except AttributeError : <EOL> accepted = QtGui . QDialog . Accepted <EOL> if dialog . DialogCode == accepted : <EOL> local_session = LocalSession ( ) <EOL> logged_in_user = local_session . logged_in_user <EOL> else : <EOL> logger . debug ( "<STR_LIT>" ) <EOL> self . close ( ) <EOL> return logged_in_user <EOL> class MultiLineInputDialog ( QtGui . QDialog ) : <EOL> """<STR_LIT>""" <EOL> pass <EOL> def ui_caller ( app_in , executor , DialogClass , ** kwargs ) : <EOL> global app <EOL> global mainDialog <EOL> self_quit = False <EOL> if QtGui . QApplication . instance ( ) is None : <EOL> if not app_in : <EOL> try : <EOL> app = QtGui . QApplication ( sys . argv ) <EOL> except AttributeError : <EOL> app = QtGui . QApplication ( [ ] ) <EOL> else : <EOL> app = app_in <EOL> self_quit = True <EOL> else : <EOL> app = QtGui . QApplication . instance ( ) <EOL> mainDialog = DialogClass ( ** kwargs ) <EOL> mainDialog . show ( ) <EOL> if executor is None : <EOL> app . exec_ ( ) <EOL> if self_quit : <EOL> app . connect ( <EOL> app , <EOL> QtCore . SIGNAL ( "<STR_LIT>" ) , <EOL> app , <EOL> QtCore . SLOT ( "<STR_LIT>" ) <EOL> ) <EOL> else : <EOL> executor . exec_ ( app , mainDialog ) <EOL> return mainDialog </s>
