- Show single warning messages if Preferences dialog box if any option that requires application restart has been changed
}
pref->setItemProperty( "strings", aLangs, curLang );
pref->setItemProperty( "icons", aIcons, curLang );
+ pref->setItemProperty( "restart", true, curLang );
int curLocale = pref->addPreference( tr( "PREF_CURRENT_LOCALE" ), langGroup,
LightApp_Preferences::Bool, "language", "locale" );
+ pref->setItemProperty( "restart", true, curLocale );
// ... "Language" group <<end>>
// ... "Look and feel" group <<start>>
}
if ( sec == "language" && param == "language" )
{
- SUIT_MessageBox::information( desktop(), tr( "WRN_WARNING" ), tr( "LANG_CHANGED" ) );
+ // VSR 18.06.2015 : commented out : single warning dialog box is now shown by the LightApp_PreferencesDlg
+ //SUIT_MessageBox::information( desktop(), tr( "WRN_WARNING" ), tr( "LANG_CHANGED" ) );
}
if ( sec == "language" && param == "locale")
{
- SUIT_MessageBox::information( desktop(), tr( "WRN_WARNING" ), tr( "LOCALE_CHANGED" ) );
+ // VSR 18.06.2015: commented out : single warning dialog box is now shown by the LightApp_PreferencesDlg
+ //SUIT_MessageBox::information( desktop(), tr( "WRN_WARNING" ), tr( "LOCALE_CHANGED" ) );
}
if ( sec == "desktop" && param == "opaque_resize" ) {
bool opaqueResize = resMgr->booleanValue( "desktop", "opaque_resize", false );
// File: LightApp_Preferences.cxx
// Author: Sergey TELKOV
-//
+
#include "LightApp_Preferences.h"
/*!
/*!Emit preference changed.*/
void LightApp_Preferences::changedResources( const ResourceMap& map )
{
+ bool toRestart = false;
for ( ResourceMap::ConstIterator it = map.begin();
it != map.end(); ++it )
{
it.key()->resource( sec, param );
QString mod = module( it.key()->id() );
emit preferenceChanged( mod, sec, param );
+ toRestart = toRestart || it.key()->isRestartRequired();
+ }
+ if ( toRestart ) {
+ emit restartRequired();
}
}
signals:
void preferenceChanged( QString&, QString&, QString& );
void resetToDefaults();
+ void restartRequired();
private slots:
void onHelp();
connect( impBtn, SIGNAL( clicked() ), this, SLOT( onImportPref() ) );
connect( this, SIGNAL( defaultPressed() ), prefs, SIGNAL( resetToDefaults() ) );
+ connect( prefs, SIGNAL( restartRequired() ), this, SLOT( onRestartRequired() ) );
+
setMinimumSize( 800, 600 );
}
myPrefs->toBackup();
}
}
+
+/*! Called if some preferences that will come in force only after application restart are changed */
+void LightApp_PreferencesDlg::onRestartRequired()
+{
+ SUIT_MessageBox::information( this, tr( "WRN_WARNING" ), tr( "PREF_NEED_RESTART" ) );
+}
void onApply();
void onDefault();
void onImportPref();
+ void onRestartRequired();
private:
LightApp_Preferences* myPrefs;
<source>DEFAULT_BTN_TEXT</source>
<translation>Defaults</translation>
</message>
+ <message>
+ <source>PREF_NEED_RESTART</source>
+ <translation>Some changes will take effect only after application restart</translation>
+ </message>
</context>
<context>
<name>LightApp_ModuleAction</name>
*/
QtxPreferenceItem::QtxPreferenceItem( QtxPreferenceItem* parent )
: myParent( 0 ),
-myEval( true )
+ myEval( true ),
+ myRestartNeeded( false )
{
myId = generateId();
*/
QtxPreferenceItem::QtxPreferenceItem( const QString& title, QtxPreferenceItem* parent )
: myParent( 0 ),
+ myEval( true ),
+ myRestartNeeded( false ),
myTitle( title )
{
myId = generateId();
QtxPreferenceItem::QtxPreferenceItem( const QString& title, const QString& sect,
const QString& param, QtxPreferenceItem* parent )
: myParent( 0 ),
+ myEval( true ),
+ myRestartNeeded( false ),
myTitle( title ),
mySection( sect ),
myParameter( param )
sendItemChanges();
}
+/*!
+ \brief Get variables auto-conversion option value
+ \return option value
+*/
bool QtxPreferenceItem::isEvaluateValues() const
{
return myEval;
}
+/*!
+ \brief Switch variables auto-conversion option on/off
+ \param on option value
+*/
void QtxPreferenceItem::setEvaluateValues( const bool on )
{
myEval = on;
}
+/*!
+ \brief Get restart needed option value
+ \return option value
+*/
+bool QtxPreferenceItem::isRestartRequired() const
+{
+ return myRestartNeeded;
+}
+
+/*!
+ \brief Switch restart needed option on/off
+ \param on option value
+*/
+void QtxPreferenceItem::setRestartRequired( const bool on )
+{
+ myRestartNeeded = on;
+}
+
/*!
\fn void QtxPreferenceItem::store();
\brief Save preference item (for example, to the resource file).
QVariant val;
if ( name == "eval" || name == "evaluation" || name == "subst" || name == "substitution" )
val = isEvaluateValues();
+ else if ( name == "restart" )
+ val = isRestartRequired();
else if ( name == "title" )
val = title();
return val;
if ( val.canConvert( QVariant::Bool ) )
setEvaluateValues( val.toBool() );
}
+ if ( name == "restart" )
+ {
+ if ( val.canConvert( QVariant::Bool ) )
+ setRestartRequired( val.toBool() );
+ }
else if ( name == "title" )
{
if ( val.canConvert( QVariant::String ) )
bool isEvaluateValues() const;
void setEvaluateValues( const bool );
+ bool isRestartRequired() const;
+ void setRestartRequired( const bool );
+
virtual void store() = 0;
virtual void retrieve() = 0;
ItemList myChildren;
bool myEval;
+ bool myRestartNeeded;
QIcon myIcon;
QString myTitle;
QString mySection;