summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDanny Baumann <dannybaumann@web.de>2008-09-18 13:21:40 +0200
committerDanny Baumann <dannybaumann@web.de>2008-09-18 13:21:40 +0200
commit104719e2a62248298bf33cd838554b1c11fda959 (patch)
treec42f42cc53c121ece261c5fe6166535d6f33a810
parent09ab35f0c5485806e4fdd47ca588b933d8db0ae1 (diff)
downloadsimple-ccsm-kde-104719e2a62248298bf33cd838554b1c11fda959.tar.gz
simple-ccsm-kde-104719e2a62248298bf33cd838554b1c11fda959.tar.bz2
Use libcompizconfig button binding functions.
-rw-r--r--dialog.cpp85
1 files changed, 19 insertions, 66 deletions
diff --git a/dialog.cpp b/dialog.cpp
index b50c910..9a2ea8e 100644
--- a/dialog.cpp
+++ b/dialog.cpp
@@ -571,76 +571,21 @@ void Dialog::setupKeyButton( CCSPlugin* plugin, const char* option, QLabel* lab
CCSSettingButtonValue val;
ccsGetButton( s, &val );
KAcceleratorManager::setNoAccel( button );
- button->setText( buttonToString( val ));
+ char *binding = ccsButtonBindingToString( &val );
+ if (binding)
+ {
+ button->setText( binding );
+ free( binding );
+ }
}
void Dialog::saveKeyButton( CCSPlugin* plugin, const char* option, QPushButton* button )
{
CCSSetting* s = setting( plugin, option );
- ccsSetButton( s, stringToButton( button->text()));
- }
-
-// TODO libcompizconfig actually has functions for this, use them
-static const char* const edges[] = { "LeftEdge", "RightEdge", "TopEdge", "BottomEdge",
- "TopLeftEdge", "TopRightEdge", "BottomLeftEdge", "BottomRightEdge", NULL };
-// TODO use Ctrl and Meta to match KDE
-// Shift = ShiftMask = (1<<0) [from X.h]
-// Control = ControlMask = (1<<2) [from X.h]
-// Alt = CompAltMask = (1<<16) [from compiz.h]
-// Super = CompSuperMask = (1<<18) [from compiz.h]
-static const char* const mods[] = { "Shift", "", "Control", "", "", "", "", "", "", "", "", "", "",
- "", "", "", "Alt", "", "Super", NULL };
-
-static QString bitmapToString( unsigned int bitmap, const char* const items[] )
- {
- QString ret;
- for( int i = 0;
- i < 32 && items[ i ] != NULL;
- ++i )
- if( bitmap & ( 1 << i ))
- ret += '<' + QString( items[ i ] ) + '>';
- return ret;
- }
-
-static unsigned int stringToBitmap( const QString& string, const char* const items[] )
- {
- if( !string.contains( '>' ))
- return 0;
- int ret = 0;
- // split for each item in <>
- foreach( QString s, string.mid( 1, string.lastIndexOf( '>' ) - 1 ).split( "><" ))
- {
- for( int i = 0;
- items[ i ] != NULL;
- ++i )
- {
- if( items[ i ] == s )
- {
- ret |= ( 1 << i );
- break;
- }
- }
- }
- return ret;
- }
+ CCSSettingButtonValue value;
-QString Dialog::buttonToString( const CCSSettingButtonValue& button )
- {
- return bitmapToString( button.edgeMask, edges ) + bitmapToString( button.buttonModMask, mods )
- + ( button.button == 0 ? "Disabled" : QString( "Button%1" ).arg( button.button ));
- }
-
-CCSSettingButtonValue Dialog::stringToButton( const QString& button )
- {
- CCSSettingButtonValue val;
- val.edgeMask = stringToBitmap( button, edges );
- val.buttonModMask = stringToBitmap( button, mods );
- QRegExp reg( ".*Button([0-9])" );
- if( reg.exactMatch( button ))
- val.button = reg.cap( 1 ).toInt();
- else
- val.button = 0;
- return val;
+ if (ccsStringToButtonBinding( button->text().toAscii(), &value ))
+ ccsSetButton( s, value );
}
void Dialog::editScreenZoomIn()
@@ -665,14 +610,22 @@ void Dialog::editAreaZoomOut()
void Dialog::editButton( QPushButton* button )
{
- CCSSettingButtonValue val = stringToButton( button->text());
+ CCSSettingButtonValue val;
+ if (!ccsStringToButtonBinding( button->text().toAscii(), &val) )
+ return;
ButtonDialog dialog( this, val.edgeMask, val.buttonModMask, val.button );
if( dialog.exec() == KDialog::Accepted )
{
val.edgeMask = dialog.edgeMask();
val.buttonModMask = dialog.buttonModMask();
val.button = dialog.button();
- button->setText( buttonToString( val ));
+
+ char *binding = ccsButtonBindingToString( &val );
+ if (binding)
+ {
+ button->setText( binding );
+ free( binding );
+ }
}
}