Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Plasma
Plasma Desktop
Commits
38db66f2
Commit
38db66f2
authored
Jan 11, 2021
by
Andrey Butirsky
Browse files
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
Changes
6
Hide whitespace changes
Inline
Side-by-side
applets/keyboardlayout/contents/ui/main.qml
View file @
38db66f2
...
...
@@ -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
(
i
dName
)
{
const
action
=
plasmoid
.
action
(
i
dName
)
function
onLayoutChanged
(
i
ndex
)
{
const
action
=
plasmoid
.
action
(
i
ndex
)
text
=
action
.
toolTip
root
.
Plasmoid
.
toolTipSubText
=
action
.
text
...
...
kcms/keyboard/keyboard_daemon.cpp
View file @
38db66f2
...
...
@@ -185,9 +185,9 @@ void KeyboardDaemon::layoutChangedSlot()
}
if
(
newLayout
!=
currentLayout
)
{
currentLayout
=
newLayout
;
emit
layoutChanged
(
new
Layout
.
toString
());
}
currentLayout
=
newLayout
;
emit
layoutChanged
(
get
Layout
());
}
}
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
::
set
Layout
(
LayoutUnit
(
layout
)
);
return
X11Helper
::
set
Group
(
index
);
}
QStr
in
g
KeyboardDaemon
::
getLayout
()
const
u
in
t
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
;
}
...
...
kcms/keyboard/keyboard_daemon.h
View file @
38db66f2
...
...
@@ -61,13 +61,13 @@ private Q_SLOTS:
public
Q_SLOTS
:
Q_SCRIPTABLE
void
switchToNextLayout
();
Q_SCRIPTABLE
bool
setLayout
(
const
QString
&
layout
);
Q_SCRIPTABLE
QStr
in
g
getLayout
()
const
;
Q_SCRIPTABLE
bool
setLayout
(
uint
index
);
Q_SCRIPTABLE
u
in
t
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:
...
...
kcms/keyboard/layoutnames.cpp
View file @
38db66f2
...
...
@@ -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
;
}
kcms/keyboard/layoutnames.h
View file @
38db66f2
...
...
@@ -9,7 +9,6 @@ struct LayoutNames
{
static
void
registerMetaType
();
QString
id
;
QString
shortName
;
QString
displayName
;
QString
longName
;
...
...
kcms/keyboard/x11_helper.h
View file @
38db66f2
...
...
@@ -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
);
};
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment