Re-set previous layout after changing layout settings.

Signed-off-by: Mavridis Philippe <mavridisf@gmail.com>
pull/202/head
Mavridis Philippe 3 years ago
parent eff93621da
commit 44ae59c0d9
No known key found for this signature in database
GPG Key ID: F8D2D7E2F989A494

@ -24,6 +24,8 @@
#include <kdebug.h>
#include <tdeapplication.h>
#include <kiconloader.h>
#include <dcopref.h>
#include <dcopclient.h>
#include "extension.h"
#include "kxkbconfig.h"
@ -355,7 +357,38 @@ void LayoutConfig::save()
m_kxkbConfig.save();
kapp->tdeinitExec("kxkb");
// Get current layout from Kxkb
if (!kapp->dcopClient()->isAttached())
kapp->dcopClient()->attach();
DCOPRef kxkbref("kxkb", "kxkb");
DCOPReply reply = kxkbref.call( "getCurrentLayout" );
TQString currentLayout;
if ( reply.isValid() ) {
reply.get(currentLayout);
} else {
kdDebug() << "Warning: cannot get current layout! (invalid DCOP reply from Kxkb)" << endl;
}
// Cause Kxkb to reread configuration
kapp->tdeinitExecWait("kxkb");
// If previous call was valid, try to change layout
if ( reply.isValid() ) {
DCOPReply successReply = kxkbref.call( "setLayout", currentLayout );
if ( successReply.isValid() ) {
bool success;
successReply.get(success);
if ( ! success )
kdDebug() << "Warning: restoring previous layout failed!" << endl;
} else {
kdDebug() << "Warning: cannot restore previous layout! (invalid DCOP reply from Kxkb)" << endl;
}
}
emit TDECModule::changed( false );
}

Loading…
Cancel
Save