mirror of
https://bitbucket.org/smil3y/kde-workspace.git
synced 2025-02-23 18:32:50 +00:00
kgreeter: implement option to change the font
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
d0aa1f0c30
commit
55b00d0c37
6 changed files with 63 additions and 20 deletions
|
@ -28,6 +28,7 @@
|
|||
#include <kstandarddirs.h>
|
||||
#include <kmessagebox.h>
|
||||
#include <kstyle.h>
|
||||
#include <kglobalsettings.h>
|
||||
#include <kaboutdata.h>
|
||||
#include <kpluginfactory.h>
|
||||
#include <kpluginloader.h>
|
||||
|
@ -64,6 +65,8 @@ KCMGreeter::KCMGreeter(QWidget* parent, const QVariantList& args)
|
|||
|
||||
load();
|
||||
|
||||
connect(fontchooser, SIGNAL(fontSelected(QFont)), this, SLOT(slotFontChanged(QFont)));
|
||||
|
||||
const QStringList kthemercs = KGlobal::dirs()->findAllResources("data", "kstyle/themes/*.themerc");
|
||||
foreach (const QString &style, QStyleFactory::keys()) {
|
||||
QString kthemename = style;
|
||||
|
@ -109,6 +112,13 @@ void KCMGreeter::load()
|
|||
{
|
||||
QSettings kgreetersettings(KDE_SYSCONFDIR "/lightdm/lightdm-kgreeter-greeter.conf", QSettings::IniFormat);
|
||||
|
||||
const QString kgreeterfontstring = kgreetersettings.value("greeter/font").toString();
|
||||
QFont kgreeterfont;
|
||||
if (!kgreeterfont.fromString(kgreeterfontstring)) {
|
||||
kgreeterfont = KGlobalSettings::generalFont();
|
||||
}
|
||||
fontchooser->setFont(kgreeterfont);
|
||||
|
||||
for (int i = 0; i < stylesbox->count(); i++) {
|
||||
if (stylesbox->itemData(i).toString().toLower() == KStyle::defaultStyle().toLower()) {
|
||||
stylesbox->setCurrentIndex(i);
|
||||
|
@ -150,6 +160,7 @@ void KCMGreeter::save()
|
|||
{
|
||||
KAuth::Action kgreeteraction("org.kde.kcontrol.kcmkgreeter.save");
|
||||
kgreeteraction.setHelperID("org.kde.kcontrol.kcmkgreeter");
|
||||
kgreeteraction.addArgument("font", fontchooser->font().toString());
|
||||
kgreeteraction.addArgument("style", stylesbox->itemData(stylesbox->currentIndex()).toString());
|
||||
kgreeteraction.addArgument("colorscheme", colorsbox->itemData(colorsbox->currentIndex()).toString());
|
||||
kgreeteraction.addArgument("background", backgroundrequester->url().path());
|
||||
|
@ -168,6 +179,7 @@ void KCMGreeter::save()
|
|||
|
||||
void KCMGreeter::defaults()
|
||||
{
|
||||
fontchooser->setFont(KGlobalSettings::generalFont());
|
||||
for (int i = 0; i < stylesbox->count(); i++) {
|
||||
if (stylesbox->itemData(i).toString().toLower() == KStyle::defaultStyle().toLower()) {
|
||||
stylesbox->setCurrentIndex(i);
|
||||
|
@ -182,6 +194,13 @@ void KCMGreeter::defaults()
|
|||
emit changed(true);
|
||||
}
|
||||
|
||||
void KCMGreeter::slotFontChanged(const QFont &font)
|
||||
{
|
||||
Q_UNUSED(font);
|
||||
enableTest(false);
|
||||
emit changed(true);
|
||||
}
|
||||
|
||||
void KCMGreeter::slotStyleChanged(const QString &style)
|
||||
{
|
||||
Q_UNUSED(style);
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#ifndef KGREETERCONFIG_H
|
||||
#define KGREETERCONFIG_H
|
||||
|
||||
#include <QFont>
|
||||
#include <QProcess>
|
||||
#include <kcmodule.h>
|
||||
|
||||
|
@ -43,6 +44,7 @@ public Q_SLOTS:
|
|||
void defaults() final;
|
||||
|
||||
private Q_SLOTS:
|
||||
void slotFontChanged(const QFont &font);
|
||||
void slotStyleChanged(const QString &style);
|
||||
void slotColorChanged(const QString &color);
|
||||
void slotURLChanged(const QString &url);
|
||||
|
|
|
@ -6,19 +6,19 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>496</width>
|
||||
<height>253</height>
|
||||
<width>501</width>
|
||||
<height>467</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="6" column="1">
|
||||
<item row="7" column="1">
|
||||
<widget class="QPushButton" name="testbutton">
|
||||
<property name="text">
|
||||
<string>Test</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
<item row="7" column="0">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
|
@ -31,7 +31,7 @@
|
|||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="6" column="2">
|
||||
<item row="7" column="2">
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
|
@ -44,7 +44,20 @@
|
|||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="0" colspan="3">
|
||||
<item row="6" column="0" colspan="3">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="3">
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
|
@ -100,22 +113,21 @@
|
|||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="5" column="0" colspan="3">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
<item row="0" column="0" colspan="3">
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="KFontChooser" name="fontchooser"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>KFontChooser</class>
|
||||
<extends></extends>
|
||||
<header>kfontdialog.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>KUrlRequester</class>
|
||||
<extends></extends>
|
||||
|
|
|
@ -25,8 +25,9 @@
|
|||
|
||||
ActionReply KGreeterHelper::save(const QVariantMap ¶meters)
|
||||
{
|
||||
if (!parameters.contains("style") || !parameters.contains("colorscheme")
|
||||
|| !parameters.contains("background") || !parameters.contains("rectangle")) {
|
||||
if (!parameters.contains("font") || !parameters.contains("style")
|
||||
|| !parameters.contains("colorscheme") || !parameters.contains("background")
|
||||
|| !parameters.contains("rectangle")) {
|
||||
return KAuth::ActionReply::HelperErrorReply;
|
||||
}
|
||||
|
||||
|
@ -36,6 +37,7 @@ ActionReply KGreeterHelper::save(const QVariantMap ¶meters)
|
|||
}
|
||||
|
||||
QSettings kgreetersettings(KDE_SYSCONFDIR "/lightdm/lightdm-kgreeter-greeter.conf", QSettings::IniFormat);
|
||||
kgreetersettings.setValue("greeter/font", parameters.value("font"));
|
||||
kgreetersettings.setValue("greeter/style", parameters.value("style"));
|
||||
kgreetersettings.setValue("greeter/colorscheme", colorscheme);
|
||||
kgreetersettings.setValue("greeter/background", parameters.value("background"));
|
||||
|
|
|
@ -515,6 +515,13 @@ int main(int argc, char**argv)
|
|||
{
|
||||
QApplication app(argc, argv);
|
||||
|
||||
const QString kgreeterfontstring = kgreetersettings.value("greeter/font").toString();
|
||||
QFont kgreeterfont;
|
||||
if (!kgreeterfont.fromString(kgreeterfontstring)) {
|
||||
kgreeterfont = KGlobalSettings::generalFont();
|
||||
}
|
||||
app.setFont(kgreeterfont);
|
||||
|
||||
// for the style
|
||||
const QStringList pluginpaths = KGlobal::dirs()->resourceDirs("qtplugins");
|
||||
Q_FOREACH (const QString &path, pluginpaths) {
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
# Available configuration options listed below.
|
||||
#
|
||||
[greeter]
|
||||
#font=
|
||||
#style=
|
||||
#colorscheme=
|
||||
#background=
|
||||
|
|
Loading…
Add table
Reference in a new issue