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
KWin
Commits
7546af6b
Commit
7546af6b
authored
Sep 30, 2020
by
Benjamin Port
Browse files
KCM KWin Decoration: Add module data
depends on
frameworks/kcmutils!19
parent
5290583f
Changes
4
Hide whitespace changes
Inline
Side-by-side
CMakeLists.txt
View file @
7546af6b
...
...
@@ -414,6 +414,7 @@ include_directories(BEFORE
add_subdirectory
(
libkwineffects
)
if
(
KWIN_BUILD_KCMS
)
include
(
KCMUtilsGenerateModuleData
)
add_subdirectory
(
kcmkwin
)
endif
()
...
...
kcmkwin/kwindecoration/CMakeLists.txt
View file @
7546af6b
...
...
@@ -10,6 +10,14 @@ set(kcmkwindecoration_SRCS
utils.cpp
)
kcmutils_generate_module_data
(
kcmkwindecoration_SRCS
MODULE_DATA_HEADER kwindecorationdata.h
MODULE_DATA_CLASS_NAME KWinDecorationData
SETTINGS_HEADERS kwindecorationsettings.h
SETTINGS_CLASSES KWinDecorationSettings
)
kconfig_add_kcfg_files
(
kcmkwindecoration_SRCS kwindecorationsettings.kcfgc GENERATE_MOC
)
add_library
(
kcm_kwindecoration MODULE
${
kcmkwindecoration_SRCS
}
)
...
...
@@ -17,6 +25,7 @@ add_library(kcm_kwindecoration MODULE ${kcmkwindecoration_SRCS})
target_link_libraries
(
kcm_kwindecoration
KDecoration2::KDecoration
KF5::I18n
KF5::KCMUtils
KF5::NewStuff
KF5::QuickAddons
Qt5::Quick
...
...
kcmkwin/kwindecoration/kcm.cpp
View file @
7546af6b
...
...
@@ -25,9 +25,10 @@
#include
<KNewStuff3/KNS3/DownloadDialog>
#include
"kwindecorationdata.h"
#include
"kwindecorationsettings.h"
K_PLUGIN_FACTORY_WITH_JSON
(
KCMKWinDecorationFactory
,
"kwindecoration.json"
,
registerPlugin
<
KCMKWinDecoration
>
();)
K_PLUGIN_FACTORY_WITH_JSON
(
KCMKWinDecorationFactory
,
"kwindecoration.json"
,
registerPlugin
<
KCMKWinDecoration
>
();
registerPlugin
<
KWinDecorationData
>
();
)
Q_DECLARE_METATYPE
(
KDecoration2
::
BorderSize
)
...
...
@@ -44,7 +45,7 @@ KCMKWinDecoration::KCMKWinDecoration(QObject *parent, const QVariantList &argume
,
m_leftButtonsModel
(
new
KDecoration2
::
Preview
::
ButtonsModel
(
DecorationButtonsList
(),
this
))
,
m_rightButtonsModel
(
new
KDecoration2
::
Preview
::
ButtonsModel
(
DecorationButtonsList
(),
this
))
,
m_availableButtonsModel
(
new
KDecoration2
::
Preview
::
ButtonsModel
(
this
))
,
m_
settings
(
new
KWinDecoration
Settings
(
this
))
,
m_
data
(
new
KWinDecoration
Data
(
this
))
{
auto
about
=
new
KAboutData
(
QStringLiteral
(
"kcm_kwindecoration"
),
i18n
(
"Window Decorations"
),
...
...
@@ -64,8 +65,8 @@ KCMKWinDecoration::KCMKWinDecoration(QObject *parent, const QVariantList &argume
m_proxyThemesModel
->
setSortCaseSensitivity
(
Qt
::
CaseInsensitive
);
m_proxyThemesModel
->
sort
(
0
);
connect
(
m_settings
,
&
KWinDecorationSettings
::
themeChanged
,
this
,
&
KCMKWinDecoration
::
themeChanged
);
connect
(
m_settings
,
&
KWinDecorationSettings
::
borderSizeChanged
,
this
,
&
KCMKWinDecoration
::
borderSizeChanged
);
connect
(
m_
data
->
settings
()
,
&
KWinDecorationSettings
::
themeChanged
,
this
,
&
KCMKWinDecoration
::
themeChanged
);
connect
(
m_
data
->
settings
()
,
&
KWinDecorationSettings
::
borderSizeChanged
,
this
,
&
KCMKWinDecoration
::
borderSizeChanged
);
connect
(
m_leftButtonsModel
,
&
QAbstractItemModel
::
rowsInserted
,
this
,
&
KCMKWinDecoration
::
onLeftButtonsChanged
);
connect
(
m_leftButtonsModel
,
&
QAbstractItemModel
::
rowsMoved
,
this
,
&
KCMKWinDecoration
::
onLeftButtonsChanged
);
...
...
@@ -89,7 +90,7 @@ KCMKWinDecoration::KCMKWinDecoration(QObject *parent, const QVariantList &argume
KWinDecorationSettings
*
KCMKWinDecoration
::
settings
()
const
{
return
m_settings
;
return
m_
data
->
settings
()
;
}
void
KCMKWinDecoration
::
reloadKWinSettings
()
...
...
@@ -120,20 +121,20 @@ void KCMKWinDecoration::load()
{
ManagedConfigModule
::
load
();
m_leftButtonsModel
->
replace
(
Utils
::
buttonsFromString
(
m_
settings
->
buttonsOnLeft
()));
m_rightButtonsModel
->
replace
(
Utils
::
buttonsFromString
(
m_
settings
->
buttonsOnRight
()));
m_leftButtonsModel
->
replace
(
Utils
::
buttonsFromString
(
settings
()
->
buttonsOnLeft
()));
m_rightButtonsModel
->
replace
(
Utils
::
buttonsFromString
(
settings
()
->
buttonsOnRight
()));
setBorderSize
(
borderSizeIndexFromString
(
m_
settings
->
borderSize
()));
setBorderSize
(
borderSizeIndexFromString
(
settings
()
->
borderSize
()));
emit
themeChanged
();
}
void
KCMKWinDecoration
::
save
()
{
if
(
!
m_
settings
->
borderSizeAuto
())
{
m_
settings
->
setBorderSize
(
borderSizeIndexToString
(
m_borderSizeIndex
));
if
(
!
settings
()
->
borderSizeAuto
())
{
settings
()
->
setBorderSize
(
borderSizeIndexToString
(
m_borderSizeIndex
));
}
else
{
m_
settings
->
setBorderSize
(
m_
settings
->
defaultBorderSizeValue
());
settings
()
->
setBorderSize
(
settings
()
->
defaultBorderSizeValue
());
}
ManagedConfigModule
::
save
();
...
...
@@ -151,18 +152,18 @@ void KCMKWinDecoration::defaults()
setBorderSize
(
recommendedBorderSize
());
m_leftButtonsModel
->
replace
(
Utils
::
buttonsFromString
(
m_
settings
->
buttonsOnLeft
()));
m_rightButtonsModel
->
replace
(
Utils
::
buttonsFromString
(
m_
settings
->
buttonsOnRight
()));
m_leftButtonsModel
->
replace
(
Utils
::
buttonsFromString
(
settings
()
->
buttonsOnLeft
()));
m_rightButtonsModel
->
replace
(
Utils
::
buttonsFromString
(
settings
()
->
buttonsOnRight
()));
}
void
KCMKWinDecoration
::
onLeftButtonsChanged
()
{
m_
settings
->
setButtonsOnLeft
(
Utils
::
buttonsToString
(
m_leftButtonsModel
->
buttons
()));
settings
()
->
setButtonsOnLeft
(
Utils
::
buttonsToString
(
m_leftButtonsModel
->
buttons
()));
}
void
KCMKWinDecoration
::
onRightButtonsChanged
()
{
m_
settings
->
setButtonsOnRight
(
Utils
::
buttonsToString
(
m_rightButtonsModel
->
buttons
()));
settings
()
->
setButtonsOnRight
(
Utils
::
buttonsToString
(
m_rightButtonsModel
->
buttons
()));
}
QSortFilterProxyModel
*
KCMKWinDecoration
::
themesModel
()
const
...
...
@@ -211,7 +212,7 @@ int KCMKWinDecoration::recommendedBorderSize() const
int
KCMKWinDecoration
::
theme
()
const
{
return
m_proxyThemesModel
->
mapFromSource
(
m_themesModel
->
findDecoration
(
m_
settings
->
pluginName
(),
m_
settings
->
theme
())).
row
();
return
m_proxyThemesModel
->
mapFromSource
(
m_themesModel
->
findDecoration
(
settings
()
->
pluginName
(),
settings
()
->
theme
())).
row
();
}
void
KCMKWinDecoration
::
setBorderSize
(
int
index
)
...
...
@@ -224,22 +225,22 @@ void KCMKWinDecoration::setBorderSize(int index)
void
KCMKWinDecoration
::
setBorderSize
(
KDecoration2
::
BorderSize
size
)
{
m_
settings
->
setBorderSize
(
Utils
::
borderSizeToString
(
size
));
settings
()
->
setBorderSize
(
Utils
::
borderSizeToString
(
size
));
}
void
KCMKWinDecoration
::
setTheme
(
int
index
)
{
QModelIndex
dataIndex
=
m_proxyThemesModel
->
index
(
index
,
0
);
if
(
dataIndex
.
isValid
())
{
m_
settings
->
setTheme
(
m_proxyThemesModel
->
data
(
dataIndex
,
KDecoration2
::
Configuration
::
DecorationsModel
::
ThemeNameRole
).
toString
());
m_
settings
->
setPluginName
(
m_proxyThemesModel
->
data
(
dataIndex
,
KDecoration2
::
Configuration
::
DecorationsModel
::
PluginNameRole
).
toString
());
settings
()
->
setTheme
(
m_proxyThemesModel
->
data
(
dataIndex
,
KDecoration2
::
Configuration
::
DecorationsModel
::
ThemeNameRole
).
toString
());
settings
()
->
setPluginName
(
m_proxyThemesModel
->
data
(
dataIndex
,
KDecoration2
::
Configuration
::
DecorationsModel
::
PluginNameRole
).
toString
());
emit
themeChanged
();
}
}
bool
KCMKWinDecoration
::
isSaveNeeded
()
const
{
return
!
m_
settings
->
borderSizeAuto
()
&&
borderSizeIndexFromString
(
m_
settings
->
borderSize
())
!=
m_borderSizeIndex
;
return
!
settings
()
->
borderSizeAuto
()
&&
borderSizeIndexFromString
(
settings
()
->
borderSize
())
!=
m_borderSizeIndex
;
}
int
KCMKWinDecoration
::
borderSizeIndexFromString
(
const
QString
&
size
)
const
...
...
kcmkwin/kwindecoration/kcm.h
View file @
7546af6b
...
...
@@ -36,6 +36,7 @@ class DecorationsModel;
}
class
KWinDecorationSettings
;
class
KWinDecorationData
;
class
KCMKWinDecoration
:
public
KQuickAddons
::
ManagedConfigModule
{
...
...
@@ -100,5 +101,5 @@ private:
QPointer
<
KNS3
::
DownloadDialog
>
m_newStuffDialog
;
int
m_borderSizeIndex
=
-
1
;
KWinDecoration
Settings
*
m_settings
;
KWinDecoration
Data
*
m_data
;
};
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