@ -19,8 +19,8 @@ void KeyboardLayout::requestDBusData<KeyboardLayout::CurrentLayoutDisplayName>()
{ if ( mIface ) requestDBusData ( mIface - > getLayoutDisplayName ( mCurrentLayout ) , mCurrentLayoutDisplayName , & KeyboardLayout : : currentLayoutDisplayNameChanged ) ; }
template < >
void KeyboardLayout : : requestDBusData < KeyboardLayout : : CurrentLayoutShort Name > ( )
{ if ( mIface ) requestDBusData ( mIface - > getCurrentLayoutShort Name ( ) , mCurrentLayoutShort Name , & KeyboardLayout : : currentLayoutShort NameChanged ) ; }
void KeyboardLayout : : requestDBusData < KeyboardLayout : : CurrentLayoutLong Name > ( )
{ if ( mIface ) requestDBusData ( mIface - > getCurrentLayoutLong Name ( ) , mCurrentLayoutLong Name , & KeyboardLayout : : currentLayoutLong NameChanged ) ; }
template < >
void KeyboardLayout : : requestDBusData < KeyboardLayout : : Layouts > ( )
@ -42,37 +42,50 @@ KeyboardLayout::KeyboardLayout(QObject* parent)
}
connect ( mIface , & OrgKdeKeyboardLayoutsInterface : : currentLayoutChanged ,
this , & KeyboardLayout : : onCurrentLayoutChanged ) ;
this , [ this ] ( const QString & newLayout )
{
mCurrentLayout = newLayout ;
requestDBusData < CurrentLayoutDisplayName > ( ) ;
requestDBusData < CurrentLayoutLongName > ( ) ;
} ) ;
connect ( mIface , & OrgKdeKeyboardLayoutsInterface : : layoutListChanged ,
this , & KeyboardLayout : : onLayoutListChanged ) ;
this , [ this ] ( )
{
requestDBusData < CurrentLayout > ( ) ;
requestDBusData < CurrentLayoutLongName > ( ) ;
requestDBusData < Layouts > ( ) ;
} ) ;
connect ( this , & KeyboardLayout : : currentLayoutChanged ,
this , & KeyboardLayout : : requestDBusData < CurrentLayoutDisplayName > ) ;
requestDBusData < CurrentLayout > ( ) ;
requestDBusData < CurrentLayoutShortName > ( ) ;
requestDBusData < Layouts > ( ) ;
emit mIface - > OrgKdeKeyboardLayoutsInterface : : layoutListChanged ( ) ;
}
KeyboardLayout : : ~ KeyboardLayout ( )
{
}
void KeyboardLayout : : onCurrentLayoutChanged ( const QString & newLayout )
{
mCurrentLayout = newLayout ;
requestDBusData < CurrentLayoutShortName > ( ) ;
requestDBusData < CurrentLayoutDisplayName > ( ) ;
}
void KeyboardLayout : : onLayoutListChanged ( )
void KeyboardLayout : : setCurrentLayout ( const QString & layout )
{
requestDBusData < CurrentLayout > ( ) ;
requestDBusData < CurrentLayoutShortName > ( ) ;
requestDBusData < Layouts > ( ) ;
if ( mIface ) mIface - > setLayout ( layout ) ;
}
void KeyboardLayout : : setCurrentLayout ( const QString & layout )
template < class T >
void KeyboardLayout : : requestDBusData ( QDBusPendingReply < T > pendingReply , T & out , void ( KeyboardLayout : : * notify ) ( ) )
{
if ( mIface ) mIface - > setLayout ( layout ) ;
const QDBusPendingCallWatcher * const watcher = new QDBusPendingCallWatcher ( pendingReply , this ) ;
connect ( watcher , & QDBusPendingCallWatcher : : finished , this ,
[ this , & out , notify ] ( QDBusPendingCallWatcher * watcher )
{
QDBusPendingReply < T > reply = * watcher ;
if ( reply . isError ( ) ) {
qCWarning ( KEYBOARD_LAYOUT ) < < reply . error ( ) . message ( ) ;
} else {
out = reply . value ( ) ;
emit ( this - > * notify ) ( ) ;
}
watcher - > deleteLater ( ) ;
}
) ;
}