summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorllunak <llunak@magic.suse.cz>2008-10-16 18:15:35 +0200
committerllunak <llunak@magic.suse.cz>2008-10-16 18:15:35 +0200
commit8e7f60271edad3cfff75ee08ffd898f53b50c43f (patch)
tree2e8960dfa248b6e96a5cede77a340d2faa12d7eb
parentf9df9c05ffce48bff2f67c8445e104dc6519e7b7 (diff)
downloadsimple-ccsm-kde-8e7f60271edad3cfff75ee08ffd898f53b50c43f.tar.gz
simple-ccsm-kde-8e7f60271edad3cfff75ee08ffd898f53b50c43f.tar.bz2
Adjust animation settings for the recent animation plugin changes (bnc#428106).
-rw-r--r--dialog.cpp139
-rw-r--r--dialog.h3
2 files changed, 112 insertions, 30 deletions
diff --git a/dialog.cpp b/dialog.cpp
index 9a2ea8e..e013628 100644
--- a/dialog.cpp
+++ b/dialog.cpp
@@ -187,21 +187,20 @@ void Dialog::changeProfile( int index )
void Dialog::setupAnimation()
{
ui.animations_enable->setChecked( pluginActive( "animation" ));
- CCSPlugin* animation = plugin( "animation" );
- setupCombo( animation, "open_effects", ui.open_label, ui.open_combo );
- setupCombo( animation, "close_effects", ui.close_label, ui.close_combo );
- setupCombo( animation, "minimize_effects", ui.minimize_label, ui.minimize_combo );
- setupCombo( animation, "focus_effects", ui.focus_label, ui.focus_combo );
+ setupAnimationCombo( "open_effects", ui.open_label, ui.open_combo );
+ setupAnimationCombo( "close_effects", ui.close_label, ui.close_combo );
+ setupAnimationCombo( "minimize_effects", ui.minimize_label, ui.minimize_combo );
+ setupAnimationCombo( "focus_effects", ui.focus_label, ui.focus_combo );
}
void Dialog::saveAnimation()
{
CCSPlugin* animation = plugin( "animation" );
ccsPluginSetActive( animation, ui.animations_enable->isChecked());
- saveCombo( animation, "open_effects", ui.open_combo );
- saveCombo( animation, "close_effects", ui.close_combo );
- saveCombo( animation, "minimize_effects", ui.minimize_combo );
- saveCombo( animation, "focus_effects", ui.focus_combo );
+ saveAnimationCombo( "open_effects", ui.open_combo );
+ saveAnimationCombo( "close_effects", ui.close_combo );
+ saveAnimationCombo( "minimize_effects", ui.minimize_combo );
+ saveAnimationCombo( "focus_effects", ui.focus_combo );
}
void Dialog::setupSwitcher()
@@ -448,31 +447,34 @@ void Dialog::setupCombo( CCSPlugin* p, const char* option, QLabel* label, QCombo
label->setToolTip( s->longDesc );
combo->setToolTip( s->longDesc );
// kdDebug() << "TYPE:" << s->info.forList.listType;
- int active;
- CCSIntDescList l;
- if( s->type == TypeList )
- {
- assert( s->info.forList.listType == TypeInt );
- active = listIntOption( s );
- l = s->info.forList.listInfo->forInt.desc;
- }
- else if( s->type == TypeInt )
+ if(( s->type == TypeList && s->info.forList.listType == TypeInt )
+ || s->type == TypeInt )
{
- ccsGetInt( s, &active );
- l = s->info.forInt.desc;
+ int active;
+ CCSIntDescList l;
+ if( s->type == TypeList )
+ {
+ active = listIntOption( s );
+ l = s->info.forList.listInfo->forInt.desc;
+ }
+ else // s->type == TypeInt
+ {
+ ccsGetInt( s, &active );
+ l = s->info.forInt.desc;
+ }
+// kdDebug() << "ACT:" << active;
+ for( ;
+ l != NULL;
+ l = l->next )
+ {
+// kdDebug() << "IT:" << l->data->name;
+ combo->addItem( l->data->name, l->data->value );
+ if( l->data->value == active ) // set active
+ combo->setCurrentIndex( combo->count() - 1 );
+ }
}
else
abort();
-// kdDebug() << "ACT:" << active;
- for( ;
- l != NULL;
- l = l->next )
- {
-// kdDebug() << "IT:" << l->data->name;
- combo->addItem( l->data->name, l->data->value );
- if( l->data->value == active ) // set active
- combo->setCurrentIndex( combo->count() - 1 );
- }
}
void Dialog::saveCombo( CCSPlugin* p, const char* option, QComboBox* combo )
@@ -495,6 +497,67 @@ void Dialog::saveCombo( CCSPlugin* p, const char* option, QComboBox* combo )
abort();
}
+void Dialog::setupAnimationCombo( const char* option, QLabel* label, QComboBox* combo )
+ {
+ CCSPlugin* p = plugin( "animation" );
+ CCSSetting* s = setting( p, option );
+ label->setText( s->shortDesc );
+ label->setToolTip( s->longDesc );
+ combo->setToolTip( s->longDesc );
+ assert( s->type == TypeList && s->info.forList.listType == TypeString );
+ QString active = listStringOption( s );
+// kdDebug() << "ACT:" << active;
+ for( CCSPluginList pl = context->plugins;
+ pl != NULL;
+ pl = pl->next )
+ {
+ if( !QString( pl->data->name ).startsWith( "animation" ))
+ continue;
+ CCSPlugin* p = plugin( pl->data->name );
+ for( CCSStrExtensionList el = ccsGetPluginStrExtensions( p );
+ el != NULL;
+ el = el->next )
+ {
+ if( qstrcmp( el->data->basePlugin, "animation" ) == 0 )
+ {
+ for( CCSStrRestrictionList rl = el->data->restriction;
+ rl != NULL;
+ rl = rl->next )
+ {
+// kdDebug() << "IT:" << rl->data->name;
+ combo->addItem( rl->data->name, rl->data->value );
+ if( rl->data->value == active ) // set active
+ combo->setCurrentIndex( combo->count() - 1 );
+ }
+ }
+ }
+ // TODO leaks?
+ }
+ }
+
+void Dialog::saveAnimationCombo( const char* option, QComboBox* combo )
+ {
+ CCSPlugin* p = plugin( "animation" );
+ CCSSetting* s = setting( p, option );
+ assert( s->type == TypeList && s->info.forList.listType == TypeString );
+ {
+ CCSSettingValueList l;
+ QByteArray ba = combo->itemData( combo->currentIndex()).toString().toLocal8Bit();
+ char* val[ 1 ] = { ba.data() };
+ l = ccsGetValueListFromStringArray( val, 1, s );
+ if (l)
+ {
+ ccsSetList( s, l );
+ ccsSettingValueListFree( l, TRUE );
+ }
+ if( ba.indexOf( ':' ) >= 0 )
+ { // activate the needed plugin
+ if( CCSPlugin* p2 = plugin( ba.left( ba.indexOf( ':' ))))
+ ccsPluginSetActive( p2, TRUE );
+ }
+ }
+ }
+
void Dialog::setupSpinbox( CCSPlugin* p, const char* option, QLabel* label, QDoubleSpinBox* spinbox )
{
CCSSetting* s = setting( p, option );
@@ -672,6 +735,22 @@ int Dialog::listIntOption( CCSSetting* s )
return retval;
}
+QString Dialog::listStringOption( CCSSetting* s )
+ {
+ CCSSettingValueList l;
+ ccsGetList( s, &l );
+ int num;
+ QString retval;
+ char** val = ccsGetStringArrayFromValueList( l, &num );
+ if ( l != NULL)
+ {
+ if (num >= 1)
+ retval = val[ 0 ];
+ free( val );
+ }
+ return retval;
+ }
+
Widget::Widget( QWidget* parent )
: QWidget( parent )
{
diff --git a/dialog.h b/dialog.h
index b6c12fb..65d1c37 100644
--- a/dialog.h
+++ b/dialog.h
@@ -76,6 +76,8 @@ class Dialog
void saveEdges();
void setupCombo( CCSPlugin* plugin, const char* option, QLabel* label, QComboBox* combo );
void saveCombo( CCSPlugin* plugin, const char* option, QComboBox* combo );
+ void setupAnimationCombo( const char* option, QLabel* label, QComboBox* combo );
+ void saveAnimationCombo( const char* option, QComboBox* combo );
void setupSpinbox( CCSPlugin* plugin, const char* option, QLabel* label, QDoubleSpinBox* spinbox );
void saveSpinbox( CCSPlugin* plugin, const char* option, QDoubleSpinBox* spinbox );
void setupCheckbox( CCSPlugin* plugin, const char* option, bool group, QCheckBox* checkbox );
@@ -85,6 +87,7 @@ class Dialog
void setupKeyButton( CCSPlugin* plugin, const char* option, QLabel* label, QPushButton* button );
void saveKeyButton( CCSPlugin* plugin, const char* option, QPushButton* button );
int listIntOption( CCSSetting* s );
+ QString listStringOption( CCSSetting* s );
void addEdge( int edge, CCSPlugin* plugin, const char* option, int index );
void saveEdge( CCSPlugin* plugin, const char* option, unsigned int edges );
QString buttonToString( const CCSSettingButtonValue& button );