<s> """<STR_LIT>""" <EOL> from __future__ import division <EOL> import os <EOL> import os . path <EOL> from PyQt4 import QtGui , QtCore <EOL> from vistrails . core . configuration import ConfigurationObject , ConfigFieldParent , ConfigPath , get_vistrails_configuration , find_simpledoc <EOL> from vistrails . core . thumbnails import ThumbnailCache <EOL> from vistrails . gui . common_widgets import QSearchTreeWindow , QSearchTreeWidget , QDirectoryChooserToolButton <EOL> from vistrails . gui . utils import YES_BUTTON , NO_BUTTON , show_question , show_warning <EOL> from vistrails . core import system <EOL> def bool_conv ( st ) : <EOL> if st == '<STR_LIT:True>' : <EOL> return True <EOL> elif st == '<STR_LIT:False>' : <EOL> return False <EOL> else : <EOL> raise TypeError ( '<STR_LIT>' + str ( st ) ) <EOL> class QConfigurationTreeWidgetItem ( QtGui . QTreeWidgetItem ) : <EOL> def __init__ ( self , parent , obj , parent_obj , name , temp_obj , temp_parent_obj ) : <EOL> lst = [ name ] <EOL> t = type ( obj ) <EOL> if t == bool : <EOL> self . _obj_type = bool_conv <EOL> else : <EOL> self . _obj_type = t <EOL> self . _parent_obj = parent_obj <EOL> self . _temp_parent_obj = temp_parent_obj <EOL> self . _name = name <EOL> if t == ConfigurationObject : <EOL> lst . extend ( [ '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> QtGui . QTreeWidgetItem . __init__ ( self , parent , lst ) <EOL> self . setFlags ( self . flags ( ) & ~ ( QtCore . Qt . ItemIsDragEnabled | <EOL> QtCore . Qt . ItemIsSelectable ) ) <EOL> elif t == tuple and obj [ <NUM_LIT:0> ] is None and isinstance ( obj [ <NUM_LIT:1> ] , type ) : <EOL> self . _obj_type = obj [ <NUM_LIT:1> ] <EOL> lst . extend ( [ '<STR_LIT>' , obj [ <NUM_LIT:1> ] . __name__ ] ) <EOL> QtGui . QTreeWidgetItem . __init__ ( self , parent , lst ) <EOL> self . setFlags ( ( self . flags ( ) & ~ QtCore . Qt . ItemIsDragEnabled ) | <EOL> QtCore . Qt . ItemIsEditable ) <EOL> else : <EOL> lst . extend ( [ str ( obj ) , type ( obj ) . __name__ ] ) <EOL> QtGui . QTreeWidgetItem . __init__ ( self , parent , lst ) <EOL> self . setFlags ( ( self . flags ( ) & ~ QtCore . Qt . ItemIsDragEnabled ) | <EOL> QtCore . Qt . ItemIsEditable ) <EOL> def change_value ( self , new_value ) : <EOL> if self . _parent_obj and not self . _obj_type == ConfigurationObject : <EOL> setattr ( self . _parent_obj , self . _name , self . _obj_type ( new_value ) ) <EOL> setattr ( self . _temp_parent_obj , self . _name , self . _obj_type ( new_value ) ) <EOL> def _get_name ( self ) : <EOL> return self . _name <EOL> name = property ( _get_name ) <EOL> class QConfigurationTreeWidgetItemDelegate ( QtGui . QItemDelegate ) : <EOL> """<STR_LIT>""" <EOL> def createEditor ( self , parent , option , index ) : <EOL> """<STR_LIT>""" <EOL> if index . column ( ) == <NUM_LIT:1> : <EOL> dataType = str ( index . sibling ( index . row ( ) , <NUM_LIT:2> ) . data ( ) ) <EOL> if dataType == '<STR_LIT:int>' : <EOL> editor = QtGui . QLineEdit ( parent ) <EOL> editor . setValidator ( QtGui . QIntValidator ( parent ) ) <EOL> elif dataType == '<STR_LIT:bool>' : <EOL> editor = QtGui . QComboBox ( parent ) <EOL> editor . addItem ( '<STR_LIT:True>' ) <EOL> editor . addItem ( '<STR_LIT:False>' ) <EOL> else : <EOL> editor = QtGui . QItemDelegate . createEditor ( self , parent , <EOL> option , index ) <EOL> return editor <EOL> return None <EOL> def setEditorData ( self , editor , index ) : <EOL> """<STR_LIT>""" <EOL> if isinstance ( editor , QtGui . QComboBox ) : <EOL> editor . setCurrentIndex ( editor . findText ( index . data ( ) ) ) <EOL> else : <EOL> QtGui . QItemDelegate . setEditorData ( self , editor , index ) <EOL> def setModelData ( self , editor , model , index ) : <EOL> """<STR_LIT>""" <EOL> if isinstance ( editor , QtGui . QComboBox ) : <EOL> model . setData ( index , editor . currentText ( ) ) <EOL> elif isinstance ( editor , QtGui . QLineEdit ) : <EOL> model . setData ( index , editor . text ( ) ) <EOL> else : <EOL> assert False <EOL> class QConfigurationTreeWidget ( QSearchTreeWidget ) : <EOL> def __init__ ( self , parent , persistent_config , temp_config ) : <EOL> QSearchTreeWidget . __init__ ( self , parent ) <EOL> self . setMatchedFlags ( QtCore . Qt . ItemIsEditable ) <EOL> self . setColumnCount ( <NUM_LIT:3> ) <EOL> lst = [ '<STR_LIT:Name>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> self . setHeaderLabels ( lst ) <EOL> self . create_tree ( persistent_config , temp_config ) <EOL> def create_tree ( self , persistent_config , temp_config ) : <EOL> def create_item ( parent , obj , parent_obj , name , temp_obj , temp_parent_obj ) : <EOL> item = QConfigurationTreeWidgetItem ( parent , obj , parent_obj , <EOL> name , temp_obj , temp_parent_obj ) <EOL> if isinstance ( obj , ConfigurationObject ) : <EOL> for key in sorted ( obj . keys ( ) ) : <EOL> create_item ( item , getattr ( obj , key ) , obj , key , <EOL> getattr ( temp_obj , key ) , temp_obj ) <EOL> self . disconnect ( self , QtCore . SIGNAL ( '<STR_LIT>' ) , <EOL> self . change_configuration ) <EOL> self . clear ( ) <EOL> self . _configuration = persistent_config <EOL> self . _temp_configuration = temp_config <EOL> create_item ( self , self . _configuration , None , '<STR_LIT>' , <EOL> self . _temp_configuration , None ) <EOL> self . expandAll ( ) <EOL> self . resizeColumnToContents ( <NUM_LIT:0> ) <EOL> self . connect ( self , <EOL> QtCore . SIGNAL ( '<STR_LIT>' ) , <EOL> self . change_configuration ) <EOL> def change_configuration ( self , item , col ) : <EOL> if item . flags ( ) & QtCore . Qt . ItemIsEditable : <EOL> new_value = self . indexFromItem ( item , col ) . data ( ) <EOL> item . change_value ( new_value ) <EOL> if item . _name == '<STR_LIT>' : <EOL> dbState = getattr ( get_vistrails_configuration ( ) , '<STR_LIT>' ) <EOL> if new_value != dbState : <EOL> from vistrails . gui . vistrails_window import _app <EOL> _app . setDBDefault ( dbState ) <EOL> self . emit ( QtCore . SIGNAL ( '<STR_LIT>' ) , <EOL> item , new_value ) <EOL> class QConfigurationTreeWindow ( QSearchTreeWindow ) : <EOL> def __init__ ( self , parent , persistent_config , temp_config ) : <EOL> self . _configuration_object = persistent_config <EOL> self . _temp_configuration = temp_config <EOL> QSearchTreeWindow . __init__ ( self , parent ) <EOL> def createTreeWidget ( self ) : <EOL> self . setWindowTitle ( '<STR_LIT>' ) <EOL> treeWidget = QConfigurationTreeWidget ( self , self . _configuration_object , <EOL> self . _temp_configuration ) <EOL> self . _delegate = QConfigurationTreeWidgetItemDelegate ( ) <EOL> treeWidget . setItemDelegate ( self . _delegate ) <EOL> return treeWidget <EOL> class QConfigurationWidget ( QtGui . QWidget ) : <EOL> def __init__ ( self , parent , persistent_config , temp_config ) : <EOL> QtGui . QWidget . __init__ ( self , parent ) <EOL> layout = QtGui . QVBoxLayout ( self ) <EOL> self . setLayout ( layout ) <EOL> self . _tree = QConfigurationTreeWindow ( self , persistent_config , <EOL> temp_config ) <EOL> lbl = QtGui . QLabel ( "<STR_LIT>" , self ) <EOL> layout . addWidget ( lbl ) <EOL> layout . addWidget ( self . _tree ) <EOL> def configuration_changed ( self , persistent_config , temp_config ) : <EOL> self . _tree . treeWidget . create_tree ( persistent_config , temp_config ) <EOL> class QConfigurationWidgetItem ( object ) : <EOL> def __init__ ( self , key , field , callback_f ) : <EOL> self . key = key <EOL> self . field = field <EOL> self . change_callback_f = callback_f <EOL> self . _desc = None <EOL> def get_desc ( self ) : <EOL> if self . _desc is not None : <EOL> return self . _desc <EOL> options = self . get_widget_options ( ) <EOL> if "<STR_LIT:label>" in options : <EOL> return options [ "<STR_LIT:label>" ] <EOL> return "<STR_LIT>" <EOL> def set_desc ( self , desc = None ) : <EOL> self . _desc = desc <EOL> def get_label_text ( self ) : <EOL> return self . get_desc ( ) <EOL> def set_value ( self , value , signal = True ) : <EOL> raise NotImplementedError ( "<STR_LIT>" ) <EOL> def value_changed ( self , value ) : <EOL> self . change_callback_f ( self , self . key , self . field , value ) <EOL> def get_widget_options ( self ) : <EOL> options = { } <EOL> if self . field . widget_options is not None : <EOL> options = self . field . widget_options <EOL> return options <EOL> class QConfigurationCheckBox ( QtGui . QCheckBox , QConfigurationWidgetItem ) : <EOL> def __init__ ( self , key , field , callback_f , parent = None ) : <EOL> QtGui . QCheckBox . __init__ ( self , parent ) <EOL> QConfigurationWidgetItem . __init__ ( self , key , field , callback_f ) <EOL> self . setText ( self . get_desc ( ) ) <EOL> self . toggled . connect ( self . value_changed ) <EOL> def set_value ( self , value , signal = True ) : <EOL> if not signal : <EOL> self . toggled . disconnect ( self . value_changed ) <EOL> self . setChecked ( value ) <EOL> if not signal : <EOL> self . toggled . connect ( self . value_changed ) <EOL> def get_label_text ( self ) : <EOL> return "<STR_LIT>" <EOL> class QConfigurationLineEdit ( QtGui . QLineEdit , QConfigurationWidgetItem ) : <EOL> def __init__ ( self , key , field , callback_f , parent = None ) : <EOL> QtGui . QLineEdit . __init__ ( self , parent ) <EOL> QConfigurationWidgetItem . __init__ ( self , key , field , callback_f ) <EOL> self . setMinimumWidth ( <NUM_LIT:200> ) <EOL> self . editingFinished . connect ( self . value_changed ) <EOL> def value_changed ( self ) : <EOL> QConfigurationWidgetItem . value_changed ( self , self . text ( ) ) <EOL> def set_value ( self , value , signal = True ) : <EOL> if value is None : <EOL> value = "<STR_LIT>" <EOL> if not signal : <EOL> self . editingFinished . disconnect ( self . value_changed ) <EOL> self . setText ( unicode ( value ) ) <EOL> if not signal : <EOL> self . editingFinished . connect ( self . value_changed ) <EOL> class QConfigurationLineEditButton ( QtGui . QWidget , QConfigurationWidgetItem ) : <EOL> def __init__ ( self , key , field , callback_f , button , parent = None ) : <EOL> QtGui . QWidget . __init__ ( self , parent ) <EOL> QConfigurationWidgetItem . __init__ ( self , key , field , callback_f ) <EOL> layout = QtGui . QHBoxLayout ( ) <EOL> layout . setMargin ( <NUM_LIT:0> ) <EOL> layout . setSpacing ( <NUM_LIT:5> ) <EOL> self . line_edit = QtGui . QLineEdit ( ) <EOL> self . line_edit . setMinimumWidth ( <NUM_LIT:200> ) <EOL> layout . addWidget ( self . line_edit ) <EOL> if button is not None : <EOL> layout . addWidget ( button ) <EOL> self . setLayout ( layout ) <EOL> self . line_edit . editingFinished . connect ( self . value_changed ) <EOL> def add_button ( self , button ) : <EOL> self . layout ( ) . addWidget ( button ) <EOL> def value_changed ( self ) : <EOL> QConfigurationWidgetItem . value_changed ( self , self . line_edit . text ( ) ) <EOL> def set_value ( self , value , signal = True ) : <EOL> if value is None : <EOL> value = "<STR_LIT>" <EOL> if not signal : <EOL> self . line_edit . editingFinished . disconnect ( self . value_changed ) <EOL> self . line_edit . setText ( unicode ( value ) ) <EOL> if not signal : <EOL> self . line_edit . editingFinished . connect ( self . value_changed ) <EOL> class QConfigurationPathEdit ( QConfigurationLineEditButton ) : <EOL> def __init__ ( self , key , field , callback_f , <EOL> button_cls = QDirectoryChooserToolButton , parent = None ) : <EOL> QConfigurationLineEditButton . __init__ ( self , key , field , callback_f , <EOL> None , parent ) <EOL> button = button_cls ( self , self . line_edit ) <EOL> self . add_button ( button ) <EOL> class QConfigurationThumbnailCache ( QConfigurationLineEditButton ) : <EOL> def __init__ ( self , key , field , callback_f , parent = None ) : <EOL> button = QtGui . QPushButton ( "<STR_LIT>" ) <EOL> button . setAutoDefault ( False ) <EOL> button . clicked . connect ( self . clear_clicked ) <EOL> QConfigurationLineEditButton . __init__ ( self , key , field , callback_f , <EOL> button , parent ) <EOL> def clear_clicked ( self , checked = False ) : <EOL> thumbnail_dir = system . get_vistrails_directory ( "<STR_LIT>" ) <EOL> res = show_question ( '<STR_LIT>' , <EOL> ( "<STR_LIT>" <EOL> "<STR_LIT>" % thumbnail_dir ) , <EOL> buttons = [ YES_BUTTON , NO_BUTTON ] , <EOL> default = NO_BUTTON ) <EOL> if res == YES_BUTTON : <EOL> ThumbnailCache . getInstance ( ) . clear ( ) <EOL> class QConfigurationLabelButton ( QtGui . QWidget , QConfigurationWidgetItem ) : <EOL> def __init__ ( self , key , field , callback_f , label = None , button = None , <EOL> parent = None ) : <EOL> QtGui . QWidget . __init__ ( self , parent ) <EOL> QConfigurationWidgetItem . __init__ ( self , key , field , callback_f ) <EOL> layout = QtGui . QHBoxLayout ( ) <EOL> layout . setMargin ( <NUM_LIT:0> ) <EOL> layout . setSpacing ( <NUM_LIT:5> ) <EOL> if label is not None : <EOL> self . label = label <EOL> layout . addWidget ( self . label ) <EOL> if button is not None : <EOL> self . button = button <EOL> layout . addWidget ( self . button ) <EOL> self . setLayout ( layout ) <EOL> def add_button ( self , button ) : <EOL> self . button = button <EOL> self . layout ( ) . addWidget ( self . button ) <EOL> def add_label ( self , label ) : <EOL> self . label = label <EOL> self . layout ( ) . insertWidget ( <NUM_LIT:0> , self . label ) <EOL> def set_value ( self , value , signal = True ) : <EOL> pass <EOL> class QConfigurationLinuxHandler ( QConfigurationLabelButton ) : <EOL> def __init__ ( self , key , field , callback_f , parent = None ) : <EOL> from vistrails . gui . application import linux_default_application_set <EOL> if linux_default_application_set ( ) : <EOL> label = QtGui . QLabel ( "<STR_LIT>" ) <EOL> button = None <EOL> else : <EOL> label = QtGui . QLabel ( "<STR_LIT>" ) <EOL> button = QtGui . QPushButton ( "<STR_LIT>" ) <EOL> button . setAutoDefault ( False ) <EOL> button . clicked . connect ( self . install_clicked ) <EOL> QConfigurationLabelButton . __init__ ( self , key , field , callback_f , <EOL> label , button , parent ) <EOL> def install_clicked ( self , checked = False ) : <EOL> from vistrails . core . application import get_vistrails_application <EOL> app = get_vistrails_application ( ) <EOL> if app . ask_update_default_application ( False ) : <EOL> self . label . setText ( "<STR_LIT>" ) <EOL> class QConfigurationComboBox ( QtGui . QComboBox , QConfigurationWidgetItem ) : <EOL> def __init__ ( self , key , field , callback_f , parent = None ) : <EOL> QtGui . QComboBox . __init__ ( self , parent ) <EOL> QConfigurationWidgetItem . __init__ ( self , key , field , callback_f ) <EOL> inv_remap = None <EOL> options = self . get_widget_options ( ) <EOL> if "<STR_LIT>" in options : <EOL> values = options [ "<STR_LIT>" ] <EOL> if "<STR_LIT>" in options : <EOL> remap = options [ "<STR_LIT>" ] <EOL> inv_remap = dict ( ( v , k ) for ( k , v ) in remap . iteritems ( ) ) <EOL> entries = [ remap [ v ] for v in values ] <EOL> else : <EOL> entries = values <EOL> for entry in entries : <EOL> self . addItem ( entry ) <EOL> self . currentIndexChanged [ int ] . connect ( self . value_changed ) <EOL> def set_value ( self , value , signal = True ) : <EOL> options = self . get_widget_options ( ) <EOL> if not signal : <EOL> self . currentIndexChanged [ int ] . disconnect ( self . value_changed ) <EOL> if value is not None and "<STR_LIT>" in options : <EOL> if "<STR_LIT>" in options : <EOL> remap = options [ "<STR_LIT>" ] <EOL> cur_text = remap [ value ] <EOL> else : <EOL> cur_text = value <EOL> self . setCurrentIndex ( self . findText ( cur_text ) ) <EOL> else : <EOL> self . setCurrentIndex ( - <NUM_LIT:1> ) <EOL> if not signal : <EOL> self . currentIndexChanged [ int ] . connect ( self . value_changed ) <EOL> class QConfigurationPane ( QtGui . QWidget ) : <EOL> def __init__ ( self , parent , persistent_config , temp_config , cat_fields ) : <EOL> QtGui . QWidget . __init__ ( self , parent ) <EOL> layout = QtGui . QFormLayout ( ) <EOL> layout . setMargin ( <NUM_LIT:10> ) <EOL> layout . setSpacing ( <NUM_LIT:4> ) <EOL> self . setLayout ( layout ) <EOL> self . _configuration = persistent_config <EOL> self . _temp_configuration = temp_config <EOL> self . _fields = { } <EOL> self . _field_layouts = { } <EOL> for category , fields in cat_fields : <EOL> self . process_fields ( layout , fields , category ) <EOL> spacer_widget = QtGui . QWidget ( ) <EOL> spacer_layout = QtGui . QVBoxLayout ( ) <EOL> spacer_layout . setMargin ( <NUM_LIT:0> ) <EOL> spacer_layout . addSpacing ( <NUM_LIT:15> ) <EOL> spacer_widget . setLayout ( spacer_layout ) <EOL> layout . addRow ( "<STR_LIT>" , spacer_widget ) <EOL> def process_fields ( self , layout , fields , category , parent_fields = [ ] , <EOL> prev_field = None , prefix = "<STR_LIT>" ) : <EOL> for field in fields : <EOL> if isinstance ( field , ConfigFieldParent ) : <EOL> self . process_fields ( layout , field . sub_fields , category , <EOL> parent_fields , prev_field , <EOL> prefix = "<STR_LIT>" % ( prefix , field . name ) ) <EOL> else : <EOL> if field . depends_on is not None : <EOL> if field . depends_on not in parent_fields : <EOL> if field . depends_on == prev_field : <EOL> parent_fields . append ( prev_field ) <EOL> else : <EOL> raise Exception ( "<STR_LIT>" <EOL> "<STR_LIT>" % field . name ) <EOL> parent_idx = parent_fields . index ( field . depends_on ) <EOL> parent_fields = parent_fields [ : parent_idx + <NUM_LIT:1> ] <EOL> indent = <NUM_LIT:4> * len ( parent_fields ) <EOL> else : <EOL> parent_fields = [ ] <EOL> indent = <NUM_LIT:0> <EOL> self . add_field ( layout , field , category , prefix = prefix , <EOL> indent = indent ) <EOL> prev_field = field . name <EOL> category = "<STR_LIT>" <EOL> def add_field ( self , base_layout , field , category = "<STR_LIT>" , startup_only = False , <EOL> prefix = "<STR_LIT>" , indent = <NUM_LIT:0> ) : <EOL> label_widget = QtGui . QWidget ( ) <EOL> label_layout = QtGui . QHBoxLayout ( ) <EOL> label_layout . setMargin ( <NUM_LIT:0> ) <EOL> label_layout . setSpacing ( <NUM_LIT:5> ) <EOL> label_widget . setLayout ( label_layout ) <EOL> config_key = "<STR_LIT>" % ( prefix , field . name ) <EOL> if self . _temp_configuration . is_unset ( config_key ) : <EOL> config_val = None <EOL> else : <EOL> config_val = self . _temp_configuration . get_deep_value ( config_key ) <EOL> if self . _configuration . is_unset ( config_key ) : <EOL> perm_config_val = None <EOL> else : <EOL> perm_config_val = self . _configuration . get_deep_value ( config_key ) <EOL> icon = self . style ( ) . standardIcon ( QtGui . QStyle . SP_MessageBoxWarning ) <EOL> label = QtGui . QLabel ( ) <EOL> label . setPixmap ( icon . pixmap ( <NUM_LIT> , <NUM_LIT> ) ) <EOL> label . setToolTip ( "<STR_LIT>" ) <EOL> label_layout . addWidget ( label , <NUM_LIT:0> , QtCore . Qt . AlignCenter ) <EOL> space = <NUM_LIT:0> <EOL> if not startup_only and config_val == perm_config_val : <EOL> space = ( label . sizeHint ( ) . width ( ) + <EOL> label_layout . spacing ( ) * ( indent + <NUM_LIT:1> ) ) <EOL> label . hide ( ) <EOL> elif indent > <NUM_LIT:0> : <EOL> space = label_layout . spacing ( ) * indent <EOL> if space > <NUM_LIT:0> : <EOL> spacer = QtGui . QSpacerItem ( space , label . sizeHint ( ) . height ( ) ) <EOL> label_layout . insertSpacerItem ( <NUM_LIT:0> , spacer ) <EOL> config_desc = find_simpledoc ( config_key ) <EOL> widget_type = field . widget_type <EOL> if widget_type is None : <EOL> if field . val_type == bool : <EOL> widget_type = "<STR_LIT>" <EOL> elif field . val_type == ConfigPath : <EOL> widget_type = "<STR_LIT>" <EOL> else : <EOL> widget_type = "<STR_LIT>" <EOL> if widget_type == "<STR_LIT>" : <EOL> widget = QConfigurationComboBox ( config_key , field , <EOL> self . field_changed ) <EOL> elif widget_type == "<STR_LIT>" : <EOL> widget = QConfigurationLineEdit ( config_key , field , <EOL> self . field_changed ) <EOL> elif widget_type == "<STR_LIT>" : <EOL> widget = QConfigurationPathEdit ( config_key , field , <EOL> self . field_changed ) <EOL> elif widget_type == "<STR_LIT>" : <EOL> widget = QConfigurationThumbnailCache ( config_key , field , <EOL> self . field_changed ) <EOL> elif widget_type == "<STR_LIT>" : <EOL> widget = QConfigurationLinuxHandler ( config_key , field , <EOL> self . field_changed ) <EOL> else : <EOL> config_val = bool ( config_val ) <EOL> widget = QConfigurationCheckBox ( config_key , field , <EOL> self . field_changed ) <EOL> widget . set_value ( config_val , False ) <EOL> label_text = widget . get_label_text ( ) <EOL> if not label_text and category : <EOL> label_text = category <EOL> if label_text : <EOL> label = QtGui . QLabel ( label_text + "<STR_LIT::>" ) <EOL> label_layout . addWidget ( label ) <EOL> base_layout . addRow ( label_widget , widget ) <EOL> self . _field_layouts [ config_key ] = ( base_layout , base_layout . rowCount ( ) ) <EOL> def field_changed ( self , widget , config_key , field , val ) : <EOL> config_val = self . _configuration . get_deep_value ( config_key ) <EOL> if config_val != self . _temp_configuration . get_deep_value ( config_key ) : <EOL> retval = QtGui . QMessageBox . question ( <EOL> self , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" , <EOL> QtGui . QMessageBox . Cancel | QtGui . QMessageBox . Ok , <EOL> QtGui . QMessageBox . Ok ) <EOL> if retval != QtGui . QMessageBox . Ok : <EOL> widget . set_value ( self . _temp_configuration . get_deep_value ( <EOL> config_key ) ) <EOL> return <EOL> form_layout , row = self . _field_layouts [ config_key ] <EOL> label_layout = form_layout . itemAt ( row , QtGui . QFormLayout . LabelRole ) . widget ( ) . layout ( ) <EOL> leading_item = label_layout . itemAt ( <NUM_LIT:0> ) <EOL> if isinstance ( leading_item . widget ( ) , QtGui . QLabel ) : <EOL> label = leading_item . widget ( ) <EOL> spacer = QtGui . QSpacerItem ( label . sizeHint ( ) . width ( ) + label_layout . spacing ( ) , <EOL> label . sizeHint ( ) . height ( ) ) <EOL> label_layout . insertSpacerItem ( <NUM_LIT:0> , spacer ) <EOL> else : <EOL> spacer = leading_item <EOL> label = label_layout . itemAt ( <NUM_LIT:1> ) . widget ( ) <EOL> spacer . changeSize ( ( spacer . sizeHint ( ) . width ( ) + <EOL> label . sizeHint ( ) . width ( ) + <EOL> label_layout . spacing ( ) ) , <EOL> label . sizeHint ( ) . height ( ) ) <EOL> label . hide ( ) <EOL> if False : <EOL> QtGui . QMessageBox . information ( <EOL> self , "<STR_LIT>" , <EOL> "<STR_LIT>" ) <EOL> setattr ( self . _temp_configuration , config_key , val ) <EOL> setattr ( self . _configuration , config_key , val ) <EOL> class QThumbnailConfiguration ( QtGui . QWidget ) : <EOL> def thumbs_cache_directory_changed ( self ) : <EOL> """<STR_LIT>""" <EOL> value = str ( self . _thumbs_cache_directory_edt . text ( ) ) <EOL> old_folder = self . _configuration . thumbs . cacheDirectory <EOL> if os . path . exists ( value ) : <EOL> self . _configuration . thumbs . cacheDirectory = value <EOL> self . _temp_configuration . thumbs . cacheDirectory = value <EOL> self . emit ( QtCore . SIGNAL ( '<STR_LIT>' ) , <EOL> None , value ) <EOL> self . _cache . move_cache_directory ( old_folder , value ) <EOL> else : <EOL> show_warning ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . _thumbs_cache_directory_edt . setText ( old_folder ) </s>
