Commit 38db66f2 authored by Andrey Butirsky's avatar Andrey Butirsky

impr: keyboard layout DBus API: rework to index based

We don't pass ID in layout list via DBus any more as it's just Index
now.
parent 4475ab6a
......@@ -31,22 +31,22 @@ KeyboardLayoutButton {
plasmoid.clearActions()
layouts.forEach(
function(layout) {
function(layout, index) {
plasmoid.setAction(
layout.id,
index,
layout.longName,
iconURL(layout.shortName).toString().substring(7) // remove file:// scheme
)
const action = plasmoid.action(layout.id)
const action = plasmoid.action(index)
action.toolTip = layout.displayName || layout.shortName
action.iconText = layout.shortName
}
)
}
function onLayoutChanged(idName) {
const action = plasmoid.action(idName)
function onLayoutChanged(index) {
const action = plasmoid.action(index)
text = action.toolTip
root.Plasmoid.toolTipSubText = action.text
......
......@@ -185,9 +185,9 @@ void KeyboardDaemon::layoutChangedSlot()
}
if( newLayout != currentLayout ) {
currentLayout = newLayout;
emit layoutChanged(newLayout.toString());
}
currentLayout = newLayout;
emit layoutChanged(getLayout());
}
}
void KeyboardDaemon::layoutMapChanged()
......@@ -228,14 +228,14 @@ bool KeyboardDaemon::setLayout(QAction* action)
// return X11Helper::setLayout(LayoutUnit(action->data().toString()));
}
bool KeyboardDaemon::setLayout(const QString& layout)
bool KeyboardDaemon::setLayout(uint index)
{
return X11Helper::setLayout(LayoutUnit(layout));
return X11Helper::setGroup(index);
}
QString KeyboardDaemon::getLayout() const
uint KeyboardDaemon::getLayout() const
{
return currentLayout.toString();
return X11Helper::getGroup();
}
QString KeyboardDaemon::getLayoutLongName() const
......@@ -249,7 +249,7 @@ QVector<LayoutNames> KeyboardDaemon::getLayoutsList() const
const auto layoutsList = X11Helper::getLayoutsList();
for (auto &layoutUnit : layoutsList) {
ret.append( {layoutUnit.toString(), layoutUnit.layout(), Flags::getShortText(layoutUnit, keyboardConfig), Flags::getLongText(layoutUnit, rules)} );
ret.append( {layoutUnit.layout(), Flags::getShortText(layoutUnit, keyboardConfig), Flags::getLongText(layoutUnit, rules)} );
}
return ret;
}
......
......@@ -61,13 +61,13 @@ private Q_SLOTS:
public Q_SLOTS:
Q_SCRIPTABLE void switchToNextLayout();
Q_SCRIPTABLE bool setLayout(const QString& layout);
Q_SCRIPTABLE QString getLayout() const;
Q_SCRIPTABLE bool setLayout(uint index);
Q_SCRIPTABLE uint getLayout() const;
Q_SCRIPTABLE QString getLayoutLongName() const;
Q_SCRIPTABLE QVector<LayoutNames> getLayoutsList() const;
Q_SIGNALS:
Q_SCRIPTABLE void layoutChanged(QString layout);
Q_SCRIPTABLE void layoutChanged(uint index);
Q_SCRIPTABLE void layoutListChanged();
public:
......
......@@ -11,7 +11,7 @@ void LayoutNames::registerMetaType()
QDBusArgument &operator<<(QDBusArgument &argument, const LayoutNames &layoutNames)
{
argument.beginStructure();
argument << layoutNames.id << layoutNames.shortName << layoutNames.displayName << layoutNames.longName;
argument << layoutNames.shortName << layoutNames.displayName << layoutNames.longName;
argument.endStructure();
return argument;
}
......@@ -19,7 +19,7 @@ QDBusArgument &operator<<(QDBusArgument &argument, const LayoutNames &layoutName
const QDBusArgument &operator>>(const QDBusArgument &argument, LayoutNames &layoutNames)
{
argument.beginStructure();
argument >> layoutNames.id >> layoutNames.shortName >> layoutNames.displayName >> layoutNames.longName;
argument >> layoutNames.shortName >> layoutNames.displayName >> layoutNames.longName;
argument.endStructure();
return argument;
}
......@@ -9,7 +9,6 @@ struct LayoutNames
{
static void registerMetaType();
QString id;
QString shortName;
QString displayName;
QString longName;
......
......@@ -206,7 +206,6 @@ public:
enum FetchType { ALL, LAYOUTS_ONLY, MODEL_ONLY };
static bool getGroupNames(Display* dpy, XkbConfig* xkbConfig, FetchType fetchType);
private:
static unsigned int getGroup();
static bool setGroup(unsigned int group);
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment