mirror of
https://bitbucket.org/smil3y/kde-playground.git
synced 2025-02-23 18:32:51 +00:00
kgreeter: moved to kde-workspace
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
88d53a0a60
commit
599a545c40
16 changed files with 0 additions and 1346 deletions
|
@ -26,5 +26,3 @@ macro_optional_add_subdirectory (zeroconf-ioslave)
|
|||
macro_optional_add_subdirectory (kdestopspy)
|
||||
macro_optional_add_subdirectory (kvolume)
|
||||
macro_optional_add_subdirectory (ksnapshot)
|
||||
macro_optional_add_subdirectory (kgreeter)
|
||||
|
||||
|
|
|
@ -1,2 +0,0 @@
|
|||
[SeatDefaults]
|
||||
greeter-session=lightdm-kgreeter-greeter
|
|
@ -1,82 +0,0 @@
|
|||
project(kgreeter)
|
||||
|
||||
if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
find_package(KDE4 4.21.0 REQUIRED)
|
||||
include(KDE4Defaults)
|
||||
include_directories(${KDE4_INCLUDES})
|
||||
add_definitions(${QT_DEFINITIONS} ${KDE4_DEFINITIONS})
|
||||
endif()
|
||||
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/modules")
|
||||
set(CMAKE_AUTOMOC TRUE)
|
||||
set(CMAKE_AUTOUIC TRUE)
|
||||
|
||||
include(GNUInstallDirs)
|
||||
|
||||
find_package(LightDM)
|
||||
set_package_properties(LightDM PROPERTIES
|
||||
PURPOSE "Required for the greeter"
|
||||
DESCRIPTION "Cross-desktop display manager"
|
||||
URL "https://github.com/canonical/lightdm"
|
||||
TYPE REQUIRED
|
||||
)
|
||||
|
||||
find_package(GLIB2)
|
||||
set_package_properties(GLIB2 PROPERTIES
|
||||
PURPOSE "Required for the greeter"
|
||||
DESCRIPTION "Low-level core library that forms the basis for projects such as GTK and GNOME"
|
||||
URL "https://gitlab.gnome.org/GNOME/glib"
|
||||
TYPE REQUIRED
|
||||
)
|
||||
|
||||
configure_file(
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/config-kgreeter.h.cmake
|
||||
${CMAKE_CURRENT_BINARY_DIR}/config-kgreeter.h
|
||||
@ONLY
|
||||
)
|
||||
|
||||
include_directories(${CMAKE_CURRENT_BINARY_DIR})
|
||||
add_subdirectory(kcm)
|
||||
|
||||
include_directories(
|
||||
${LIGHTDM_INCLUDE_DIR}
|
||||
${GLIB2_INCLUDE_DIR}
|
||||
)
|
||||
|
||||
add_definitions(
|
||||
${LIGHTDM_DEFINITIONS}
|
||||
)
|
||||
|
||||
add_executable(kgreeter kgreeter.cpp)
|
||||
target_link_libraries(kgreeter
|
||||
${QT_QTCORE_LIBRARY}
|
||||
${QT_QTGUI_LIBRARY}
|
||||
${KDE4_KDEUI_LIBS}
|
||||
${LIGHTDM_LIBRARIES}
|
||||
${GLIB2_LIBRARIES}
|
||||
gobject-2.0
|
||||
)
|
||||
|
||||
set_target_properties(kgreeter PROPERTIES
|
||||
OUTPUT_NAME lightdm-kgreeter-greeter
|
||||
)
|
||||
|
||||
install(
|
||||
TARGETS kgreeter
|
||||
DESTINATION ${KDE4_SBIN_INSTALL_DIR}
|
||||
)
|
||||
|
||||
install(
|
||||
FILES lightdm-kgreeter-greeter.conf
|
||||
DESTINATION ${KDE4_SYSCONF_INSTALL_DIR}/lightdm
|
||||
)
|
||||
|
||||
install(
|
||||
FILES 50-lightdm-kgreeter-greeter.conf
|
||||
DESTINATION ${KDE4_SHARE_INSTALL_PREFIX}/lightdm/lightdm.conf.d
|
||||
)
|
||||
|
||||
install(
|
||||
FILES lightdm-kgreeter-greeter.desktop
|
||||
DESTINATION ${KDE4_SHARE_INSTALL_PREFIX}/xgreeters
|
||||
)
|
|
@ -1,42 +0,0 @@
|
|||
# Try to find LightDM library, once done this will define:
|
||||
#
|
||||
# LIGHTDM_FOUND - system has LightDM
|
||||
# LIGHTDM_INCLUDE_DIR - the LightDM include directory
|
||||
# LIGHTDM_LIBRARIES - the libraries needed to use LightDM
|
||||
# LIGHTDM_DEFINITIONS - compiler switches required for using LightDM
|
||||
#
|
||||
# Copyright (c) 2022 Ivailo Monev <xakepa10@gmail.com>
|
||||
#
|
||||
# Redistribution and use is allowed according to the terms of the BSD license.
|
||||
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
|
||||
|
||||
if(NOT WIN32)
|
||||
include(FindPkgConfig)
|
||||
pkg_check_modules(PC_LIGHTDM QUIET liblightdm-gobject-1)
|
||||
|
||||
set(LIGHTDM_INCLUDE_DIR ${PC_LIGHTDM_INCLUDE_DIRS})
|
||||
set(LIGHTDM_LIBRARIES ${PC_LIGHTDM_LIBRARIES})
|
||||
endif()
|
||||
|
||||
set(LIGHTDM_VERSION ${PC_LIGHTDM_VERSION})
|
||||
set(LIGHTDM_DEFINITIONS ${PC_LIGHTDM_CFLAGS_OTHER})
|
||||
|
||||
if(NOT LIGHTDM_INCLUDE_DIR OR NOT LIGHTDM_LIBRARIES)
|
||||
find_path(LIGHTDM_INCLUDE_DIR
|
||||
NAMES lightdm-gobject-1/lightdm.h
|
||||
HINTS $ENV{LIGHTDMDIR}/include
|
||||
)
|
||||
|
||||
find_library(LIGHTDM_LIBRARIES
|
||||
NAMES lightdm-gobject-1
|
||||
HINTS $ENV{LIGHTDMDIR}/lib
|
||||
)
|
||||
endif()
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(LightDM
|
||||
VERSION_VAR LIGHTDM_VERSION
|
||||
REQUIRED_VARS LIGHTDM_LIBRARIES LIGHTDM_INCLUDE_DIR
|
||||
)
|
||||
|
||||
mark_as_advanced(LIGHTDM_INCLUDE_DIR LIGHTDM_LIBRARIES)
|
|
@ -1,2 +0,0 @@
|
|||
|
||||
#define SYSCONF_INSTALL_DIR "@KDE4_SYSCONF_INSTALL_DIR@"
|
|
@ -1,36 +0,0 @@
|
|||
########### next target ###############
|
||||
|
||||
set(kgreeterconfig_SRCS
|
||||
kgreeterconfig.cpp
|
||||
kgreeterconfig.ui
|
||||
)
|
||||
|
||||
kde4_add_plugin(kcm_kgreeterconfig ${kgreeterconfig_SRCS})
|
||||
|
||||
target_link_libraries(kcm_kgreeterconfig
|
||||
${KDE4_KDEUI_LIBS}
|
||||
${KDE4_KCMUTILS_LIBS}
|
||||
${KDE4_KIO_LIBS}
|
||||
)
|
||||
|
||||
install(
|
||||
TARGETS kcm_kgreeterconfig
|
||||
DESTINATION ${KDE4_PLUGIN_INSTALL_DIR}
|
||||
)
|
||||
|
||||
install(
|
||||
FILES kcm_kgreeterconfig.desktop
|
||||
DESTINATION ${KDE4_SERVICES_INSTALL_DIR}
|
||||
)
|
||||
|
||||
########### next target ###############
|
||||
|
||||
add_executable(kcmkgreeterhelper kgreeterhelper.cpp)
|
||||
target_link_libraries(kcmkgreeterhelper ${KDE4_KDECORE_LIBS})
|
||||
|
||||
install(
|
||||
TARGETS kcmkgreeterhelper
|
||||
DESTINATION ${KDE4_LIBEXEC_INSTALL_DIR}
|
||||
)
|
||||
|
||||
kde4_install_auth_helper_files(kcmkgreeterhelper org.kde.kcontrol.kcmkgreeter root)
|
|
@ -1,16 +0,0 @@
|
|||
[Desktop Entry]
|
||||
Exec=kcmshell4 kgreeterconfig
|
||||
Icon=preferences-system-login
|
||||
Type=Service
|
||||
|
||||
X-KDE-ServiceTypes=KCModule
|
||||
X-KDE-Library=kcm_kgreeterconfig
|
||||
X-KDE-ParentApp=kcontrol
|
||||
X-KDE-System-Settings-Parent-Category=workspace-appearance-and-behavior
|
||||
X-KDE-System-Settings-Parent-Category-V2=workspace-appearance-and-behavior
|
||||
X-DocPath=kcontrol/kgreeterconfig/index.html
|
||||
Categories=Qt;KDE;X-KDE-settings-workspace-appearance-and-behavior;
|
||||
|
||||
Name=Greeter
|
||||
Comment=Change greeter options
|
||||
X-KDE-Keywords=Greeter,Login
|
|
@ -1,174 +0,0 @@
|
|||
/* This file is part of the KDE project
|
||||
Copyright (C) 2022 Ivailo Monev <xakepa10@gmail.com>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License version 2, as published by the Free Software Foundation.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public License
|
||||
along with this library; see the file COPYING.LIB. If not, write to
|
||||
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "kgreeterconfig.h"
|
||||
|
||||
#include <QSettings>
|
||||
#include <QStyleFactory>
|
||||
#include <QProcess>
|
||||
#include <kdebug.h>
|
||||
#include <klocale.h>
|
||||
#include <kauthaction.h>
|
||||
#include <kimageio.h>
|
||||
#include <kstandarddirs.h>
|
||||
#include <kmessagebox.h>
|
||||
#include <kaboutdata.h>
|
||||
#include <kpluginfactory.h>
|
||||
#include <kpluginloader.h>
|
||||
|
||||
#include "config-kgreeter.h"
|
||||
|
||||
K_PLUGIN_FACTORY(KCMGreeterFactory, registerPlugin<KCMGreeter>();)
|
||||
K_EXPORT_PLUGIN(KCMGreeterFactory("kcmgreeterconfig", "kcm_greeterconfig"))
|
||||
|
||||
KCMGreeter::KCMGreeter(QWidget* parent, const QVariantList& args)
|
||||
: KCModule(KCMGreeterFactory::componentData(), parent)
|
||||
{
|
||||
Q_UNUSED(args);
|
||||
|
||||
setQuickHelp(i18n("<h1>KGreeter</h1> This module allows you to change KDE greeter options."));
|
||||
|
||||
setupUi(this);
|
||||
|
||||
KAboutData *about =
|
||||
new KAboutData(I18N_NOOP("kcmkgreeter"), 0,
|
||||
ki18n("KDE Greeter Module"),
|
||||
0, KLocalizedString(), KAboutData::License_GPL,
|
||||
ki18n("Copyright 2022, Ivailo Monev <email>xakepa10@gmail.com</email>"
|
||||
));
|
||||
|
||||
about->addAuthor(ki18n("Ivailo Monev"), KLocalizedString(), "xakepa10@gmail.com");
|
||||
setAboutData(about);
|
||||
|
||||
setNeedsAuthorization(true);
|
||||
setButtons(KCModule::Help | KCModule::Apply);
|
||||
|
||||
load();
|
||||
|
||||
stylesbox->addItems(QStyleFactory::keys());
|
||||
connect(stylesbox, SIGNAL(currentIndexChanged(QString)), this, SLOT(slotStyleChanged(QString)));
|
||||
|
||||
const QStringList kcolorschemes = KGlobal::dirs()->findAllResources("data", "color-schemes/*.colors", KStandardDirs::NoDuplicates);
|
||||
foreach (const QString &kcolorscheme, kcolorschemes) {
|
||||
const QString kcolorschemename = QSettings(kcolorscheme, QSettings::IniFormat).value("General/Name").toString();
|
||||
const QString kcolorschemebasename = QFileInfo(kcolorscheme).baseName();
|
||||
colorsbox->addItem(kcolorschemename, QVariant(kcolorschemebasename));
|
||||
}
|
||||
connect(colorsbox, SIGNAL(currentIndexChanged(QString)), this, SLOT(slotColorChanged(QString)));
|
||||
|
||||
backgroundrequester->setFilter(KImageIO::pattern(KImageIO::Reading));
|
||||
connect(backgroundrequester, SIGNAL(textChanged(QString)), this, SLOT(slotURLChanged(QString)));
|
||||
connect(backgroundrequester, SIGNAL(urlSelected(KUrl)), this, SLOT(slotURLChanged(KUrl)));
|
||||
|
||||
rectanglerequester->setFilter(KImageIO::pattern(KImageIO::Reading));
|
||||
connect(rectanglerequester, SIGNAL(textChanged(QString)), this, SLOT(slotURLChanged(QString)));
|
||||
connect(rectanglerequester, SIGNAL(urlSelected(KUrl)), this, SLOT(slotURLChanged(KUrl)));
|
||||
|
||||
m_lightdmexe = KStandardDirs::findRootExe("lightdm");
|
||||
testbutton->setEnabled(!m_lightdmexe.isEmpty());
|
||||
testbutton->setIcon(KIcon("debug-run"));
|
||||
connect(testbutton, SIGNAL(pressed()), this, SLOT(slotTest()));
|
||||
}
|
||||
|
||||
KCMGreeter::~KCMGreeter()
|
||||
{
|
||||
}
|
||||
|
||||
void KCMGreeter::load()
|
||||
{
|
||||
QSettings kgreetersettings(SYSCONF_INSTALL_DIR "/lightdm/lightdm-kgreeter-greeter.conf", QSettings::IniFormat);
|
||||
|
||||
const QString kgreeterstyle = kgreetersettings.value("greeter/style").toString();
|
||||
if (!kgreeterstyle.isEmpty()) {
|
||||
for (int i = 0; i < stylesbox->count(); i++) {
|
||||
if (stylesbox->itemText(i) == kgreeterstyle) {
|
||||
stylesbox->setCurrentIndex(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const QString kgreetercolor = kgreetersettings.value("greeter/colorscheme").toString();
|
||||
if (!kgreetercolor.isEmpty()) {
|
||||
for (int i = 0; i < colorsbox->count(); i++) {
|
||||
if (colorsbox->itemData(i).toString() == kgreetercolor) {
|
||||
colorsbox->setCurrentIndex(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const QString kgreeterbackground = kgreetersettings.value("greeter/background").toString();
|
||||
backgroundrequester->setUrl(KUrl(kgreeterbackground));
|
||||
|
||||
const QString kgreeterrectangle = kgreetersettings.value("greeter/rectangle").toString();
|
||||
rectanglerequester->setUrl(KUrl(kgreeterrectangle));
|
||||
|
||||
emit changed(false);
|
||||
}
|
||||
|
||||
void KCMGreeter::save()
|
||||
{
|
||||
KAuth::Action kgreeteraction("org.kde.kcontrol.kcmkgreeter.save");
|
||||
kgreeteraction.setHelperID("org.kde.kcontrol.kcmkgreeter");
|
||||
kgreeteraction.addArgument("style", stylesbox->currentText());
|
||||
kgreeteraction.addArgument("colorscheme", colorsbox->itemData(colorsbox->currentIndex()).toString());
|
||||
kgreeteraction.addArgument("background", backgroundrequester->url().path());
|
||||
kgreeteraction.addArgument("rectangle", rectanglerequester->url().path());
|
||||
KAuth::ActionReply kgreeterreply = kgreeteraction.execute();
|
||||
|
||||
// qDebug() << kgreeter.errorCode() << kgreeter.errorDescription();
|
||||
|
||||
if (kgreeterreply != KAuth::ActionReply::SuccessReply) {
|
||||
KMessageBox::error(this, kgreeterreply.errorDescription());
|
||||
}
|
||||
emit changed(false);
|
||||
}
|
||||
|
||||
void KCMGreeter::slotStyleChanged(const QString &style)
|
||||
{
|
||||
Q_UNUSED(style);
|
||||
emit changed(true);
|
||||
}
|
||||
|
||||
void KCMGreeter::slotColorChanged(const QString &color)
|
||||
{
|
||||
Q_UNUSED(color);
|
||||
emit changed(true);
|
||||
}
|
||||
|
||||
void KCMGreeter::slotURLChanged(const QString &url)
|
||||
{
|
||||
Q_UNUSED(url);
|
||||
emit changed(true);
|
||||
}
|
||||
|
||||
void KCMGreeter::slotURLChanged(const KUrl &url)
|
||||
{
|
||||
Q_UNUSED(url);
|
||||
emit changed(true);
|
||||
}
|
||||
|
||||
void KCMGreeter::slotTest()
|
||||
{
|
||||
if (!QProcess::startDetached(m_lightdmexe, QStringList() << QString::fromLatin1("--test-mode"))) {
|
||||
KMessageBox::error(this, i18n("Could not start LightDM"));
|
||||
}
|
||||
}
|
||||
|
||||
#include "moc_kgreeterconfig.cpp"
|
|
@ -1,54 +0,0 @@
|
|||
/* This file is part of the KDE project
|
||||
Copyright (C) 2022 Ivailo Monev <xakepa10@gmail.com>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License version 2, as published by the Free Software Foundation.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public License
|
||||
along with this library; see the file COPYING.LIB. If not, write to
|
||||
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef KGREETERCONFIG_H
|
||||
#define KGREETERCONFIG_H
|
||||
|
||||
#include <kcmodule.h>
|
||||
|
||||
#include "ui_kgreeterconfig.h"
|
||||
|
||||
/**
|
||||
* Control look of KDE greeter
|
||||
*
|
||||
* @author Ivailo Monev (xakepa10@gmail.com)
|
||||
*/
|
||||
class KCMGreeter : public KCModule, public Ui_KGreeterDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
// KCModule reimplementations
|
||||
KCMGreeter(QWidget* parent, const QVariantList&);
|
||||
~KCMGreeter();
|
||||
|
||||
void load() final;
|
||||
void save() final;
|
||||
|
||||
private Q_SLOTS:
|
||||
void slotStyleChanged(const QString &style);
|
||||
void slotColorChanged(const QString &color);
|
||||
void slotURLChanged(const QString &url);
|
||||
void slotURLChanged(const KUrl &url);
|
||||
|
||||
void slotTest();
|
||||
|
||||
private:
|
||||
QString m_lightdmexe;
|
||||
};
|
||||
|
||||
#endif // KGREETERCONFIG_H
|
|
@ -1,127 +0,0 @@
|
|||
<?xml version="1.0" encoding="System"?>
|
||||
<ui version="4.0">
|
||||
<class>KGreeterDialog</class>
|
||||
<widget class="QWidget" name="KGreeterDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>496</width>
|
||||
<height>253</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="6" column="1">
|
||||
<widget class="QPushButton" name="testbutton">
|
||||
<property name="text">
|
||||
<string>Test</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="6" column="2">
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="0" colspan="3">
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Color scheme:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Style:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QComboBox" name="colorsbox"/>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Background:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="KUrlRequester" name="backgroundrequester"/>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QComboBox" name="stylesbox"/>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>Rectangle:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<widget class="KUrlRequester" name="rectanglerequester"/>
|
||||
</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>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>KUrlRequester</class>
|
||||
<extends></extends>
|
||||
<header>kurlrequester.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
|
@ -1,48 +0,0 @@
|
|||
/* This file is part of the KDE project
|
||||
Copyright (C) 2022 Ivailo Monev <xakepa10@gmail.com>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License version 2, as published by the Free Software Foundation.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public License
|
||||
along with this library; see the file COPYING.LIB. If not, write to
|
||||
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "kgreeterhelper.h"
|
||||
|
||||
#include <QSettings>
|
||||
#include <kauthhelpersupport.h>
|
||||
|
||||
#include "config-kgreeter.h"
|
||||
|
||||
ActionReply KGreeterHelper::save(const QVariantMap ¶meters)
|
||||
{
|
||||
if (!parameters.contains("style") || !parameters.contains("colorscheme")
|
||||
|| !parameters.contains("background") || !parameters.contains("rectangle")) {
|
||||
return KAuth::ActionReply::HelperErrorReply;
|
||||
}
|
||||
|
||||
QSettings kgreetersettings(SYSCONF_INSTALL_DIR "/lightdm/lightdm-kgreeter-greeter.conf", QSettings::IniFormat);
|
||||
kgreetersettings.setValue("greeter/style", parameters.value("style"));
|
||||
kgreetersettings.setValue("greeter/colorscheme", parameters.value("colorscheme"));
|
||||
kgreetersettings.setValue("greeter/background", parameters.value("background"));
|
||||
kgreetersettings.setValue("greeter/rectangle", parameters.value("rectangle"));
|
||||
if (kgreetersettings.status() != QSettings::NoError) {
|
||||
KAuth::ActionReply errorreply(KAuth::ActionReply::HelperError);
|
||||
errorreply.setErrorDescription("Could not save settings");
|
||||
errorreply.setErrorCode(1);
|
||||
return errorreply;
|
||||
}
|
||||
|
||||
return KAuth::ActionReply::SuccessReply;
|
||||
}
|
||||
|
||||
KDE4_AUTH_HELPER_MAIN("org.kde.kcontrol.kcmkgreeter", KGreeterHelper)
|
|
@ -1,34 +0,0 @@
|
|||
/* This file is part of the KDE project
|
||||
Copyright (C) 2022 Ivailo Monev <xakepa10@gmail.com>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License version 2, as published by the Free Software Foundation.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public License
|
||||
along with this library; see the file COPYING.LIB. If not, write to
|
||||
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef KGREETERHELPER_H
|
||||
#define KGREETERHELPER_H
|
||||
|
||||
#include <kauthactionreply.h>
|
||||
|
||||
// methods return type must be ActionReply otherwise QMetaObject::invokeMethod() fails
|
||||
using namespace KAuth;
|
||||
|
||||
class KGreeterHelper : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public slots:
|
||||
ActionReply save(const QVariantMap ¶meters);
|
||||
};
|
||||
|
||||
#endif // KGREETERHELPER_H
|
|
@ -1,486 +0,0 @@
|
|||
#define QT_NO_KEYWORDS
|
||||
#include <QDebug>
|
||||
#include <QSettings>
|
||||
#include <QMainWindow>
|
||||
#include <QPainter>
|
||||
#include <KMessageBox>
|
||||
#include <KIcon>
|
||||
#include <KStyle>
|
||||
#include <KGlobalSettings>
|
||||
#include <KSharedConfig>
|
||||
#include <KLocale>
|
||||
|
||||
#include <glib.h>
|
||||
#include <lightdm-gobject-1/lightdm.h>
|
||||
|
||||
#include "ui_kgreeter.h"
|
||||
#include "config-kgreeter.h"
|
||||
|
||||
// for the callbacks
|
||||
static GMainLoop *glibloop = NULL;
|
||||
|
||||
static QSettings kgreetersettings(SYSCONF_INSTALL_DIR "/lightdm/lightdm-kgreeter-greeter.conf", QSettings::IniFormat);
|
||||
|
||||
class KGreeter : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit KGreeter(QWidget *parent = nullptr);
|
||||
|
||||
QByteArray getUser() const;
|
||||
QByteArray getPass() const;
|
||||
QByteArray getSession() const;
|
||||
|
||||
LightDMGreeter* getGreeter() const;
|
||||
|
||||
static void showPromptCb(LightDMGreeter *ldmgreeter, const char *ldmtext, LightDMPromptType ldmtype, gpointer ldmptr);
|
||||
static void authenticationCompleteCb(LightDMGreeter *ldmgreeter, gpointer ldmptr);
|
||||
static void showMessageCb(LightDMGreeter *ldmgreeter, const gchar *ldmtext, LightDMMessageType ldmtype, gpointer ldmptr);
|
||||
|
||||
// QMainWindow reimplementations
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *event) final;
|
||||
|
||||
private Q_SLOTS:
|
||||
void slotSuspend();
|
||||
void slotHibernate();
|
||||
void slotPoweroff();
|
||||
void slotReboot();
|
||||
|
||||
void slotSession();
|
||||
|
||||
void slotLayout();
|
||||
|
||||
void slotLogin();
|
||||
|
||||
private:
|
||||
void setUser(const QString &user);
|
||||
void setSession(const QString &session);
|
||||
bool isUserLogged() const;
|
||||
|
||||
Ui::KGreeter m_ui;
|
||||
LightDMGreeter *m_ldmgreeter;
|
||||
QList<QAction*> m_sessionactions;
|
||||
QList<QAction*> m_layoutactions;
|
||||
QImage m_background;
|
||||
QImage m_rectangle;
|
||||
};
|
||||
|
||||
KGreeter::KGreeter(QWidget *parent)
|
||||
: QMainWindow(parent),
|
||||
m_ldmgreeter(nullptr)
|
||||
{
|
||||
#if !defined(GLIB_VERSION_2_36)
|
||||
g_type_init();
|
||||
#endif
|
||||
|
||||
m_ui.setupUi(this);
|
||||
|
||||
m_background = QImage(kgreetersettings.value("greeter/background").toString());
|
||||
m_rectangle = QImage(kgreetersettings.value("greeter/rectangle").toString());
|
||||
|
||||
m_ldmgreeter = lightdm_greeter_new();
|
||||
|
||||
g_signal_connect(
|
||||
m_ldmgreeter, LIGHTDM_GREETER_SIGNAL_SHOW_PROMPT,
|
||||
G_CALLBACK(KGreeter::showPromptCb), this
|
||||
);
|
||||
g_signal_connect(
|
||||
m_ldmgreeter, LIGHTDM_GREETER_SIGNAL_AUTHENTICATION_COMPLETE,
|
||||
G_CALLBACK(KGreeter::authenticationCompleteCb), this
|
||||
);
|
||||
g_signal_connect(
|
||||
m_ldmgreeter, LIGHTDM_GREETER_SIGNAL_SHOW_MESSAGE,
|
||||
G_CALLBACK(KGreeter::showMessageCb), this
|
||||
);
|
||||
|
||||
// TODO: sort and then add
|
||||
GList *ldmlayouts = lightdm_get_layouts();
|
||||
for (GList *ldmitem = ldmlayouts; ldmitem; ldmitem = ldmitem->next) {
|
||||
LightDMLayout *ldmlayout = static_cast<LightDMLayout*>(ldmitem->data);
|
||||
Q_ASSERT(ldmlayout);
|
||||
|
||||
QAction* layoutaction = new QAction(m_ui.menuKeyboard);
|
||||
layoutaction->setCheckable(true);
|
||||
layoutaction->setText(QString::fromUtf8(lightdm_layout_get_description(ldmlayout)));
|
||||
layoutaction->setData(QVariant(QString::fromUtf8(lightdm_layout_get_name(ldmlayout))));
|
||||
connect(layoutaction, SIGNAL(triggered()), this, SLOT(slotLayout()));
|
||||
m_ui.menuKeyboard->addAction(layoutaction);
|
||||
m_layoutactions.append(layoutaction);
|
||||
}
|
||||
|
||||
GList *ldmusers = lightdm_user_list_get_users(lightdm_user_list_get_instance());
|
||||
for (GList *ldmitem = ldmusers; ldmitem; ldmitem = ldmitem->next) {
|
||||
LightDMUser *ldmuser = static_cast<LightDMUser*>(ldmitem->data);
|
||||
Q_ASSERT(ldmuser);
|
||||
|
||||
const QString ldmuserimage = QString::fromUtf8(lightdm_user_get_image(ldmuser));
|
||||
if (!ldmuserimage.isEmpty()) {
|
||||
m_ui.usersbox->addItem(QIcon(QPixmap(ldmuserimage)), QString::fromUtf8(lightdm_user_get_name(ldmuser)));
|
||||
} else {
|
||||
m_ui.usersbox->addItem(QString::fromUtf8(lightdm_user_get_name(ldmuser)));
|
||||
}
|
||||
}
|
||||
|
||||
GList *ldmsessions = lightdm_get_sessions();
|
||||
for (GList* ldmitem = ldmsessions; ldmitem; ldmitem = ldmitem->next) {
|
||||
LightDMSession *ldmsession = static_cast<LightDMSession*>(ldmitem->data);
|
||||
Q_ASSERT(ldmsession);
|
||||
|
||||
const QString ldmsessionname = QString::fromUtf8(lightdm_session_get_name(ldmsession));
|
||||
const QString ldmsessionkey = QString::fromUtf8(lightdm_session_get_key(ldmsession));
|
||||
|
||||
QAction* sessionaction = new QAction(m_ui.menuSessions);
|
||||
sessionaction->setCheckable(true);
|
||||
sessionaction->setText(ldmsessionname);
|
||||
sessionaction->setData(QVariant(ldmsessionkey));
|
||||
connect(sessionaction, SIGNAL(triggered()), this, SLOT(slotSession()));
|
||||
m_ui.menuSessions->addAction(sessionaction);
|
||||
m_sessionactions.append(sessionaction);
|
||||
}
|
||||
|
||||
const QString ldmdefaultuser = QString::fromUtf8(lightdm_greeter_get_select_user_hint(m_ldmgreeter));
|
||||
if (!ldmdefaultuser.isEmpty()) {
|
||||
setUser(ldmdefaultuser);
|
||||
}
|
||||
const QString ldmdefaultsession = QString::fromUtf8(lightdm_greeter_get_default_session_hint(m_ldmgreeter));
|
||||
if (!ldmdefaultsession.isEmpty()) {
|
||||
setSession(ldmdefaultsession);
|
||||
}
|
||||
|
||||
QSettings kgreeterstate("lightdm-kgreeter-state");
|
||||
const QString lastuser = kgreeterstate.value("state/lastuser").toString();
|
||||
if (!lastuser.isEmpty()) {
|
||||
setUser(lastuser);
|
||||
}
|
||||
const QString lastsession = kgreeterstate.value("state/lastsession").toString();
|
||||
if (!lastsession.isEmpty()) {
|
||||
setSession(lastsession);
|
||||
}
|
||||
|
||||
// if no default session is specified and no last session is saved use the first
|
||||
bool sessionchecked = false;
|
||||
Q_FOREACH (QAction *sessionaction, m_sessionactions) {
|
||||
if (sessionaction->isChecked()) {
|
||||
sessionchecked = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!sessionchecked && !m_sessionactions.isEmpty()) {
|
||||
m_sessionactions.first()->setChecked(true);
|
||||
}
|
||||
|
||||
m_ui.groupbox->setTitle(QString::fromUtf8(lightdm_get_hostname()));
|
||||
|
||||
m_ui.actionSuspend->setVisible(lightdm_get_can_suspend());
|
||||
m_ui.actionSuspend->setIcon(KIcon("system-suspend"));
|
||||
m_ui.actionHibernate->setVisible(lightdm_get_can_hibernate());
|
||||
m_ui.actionHibernate->setIcon(KIcon("system-suspend-hibernate"));
|
||||
m_ui.actionPoweroff->setVisible(lightdm_get_can_shutdown());
|
||||
m_ui.actionPoweroff->setIcon(KIcon("system-shutdown"));
|
||||
m_ui.actionReboot->setVisible(lightdm_get_can_restart());
|
||||
m_ui.actionReboot->setIcon(KIcon("system-reboot"));
|
||||
connect(m_ui.actionSuspend, SIGNAL(triggered()), this, SLOT(slotSuspend()));
|
||||
connect(m_ui.actionHibernate, SIGNAL(triggered()), this, SLOT(slotHibernate()));
|
||||
connect(m_ui.actionPoweroff, SIGNAL(triggered()), this, SLOT(slotPoweroff()));
|
||||
connect(m_ui.actionReboot, SIGNAL(triggered()), this, SLOT(slotReboot()));
|
||||
|
||||
connect(m_ui.loginbutton, SIGNAL(pressed()), this, SLOT(slotLogin()));
|
||||
|
||||
if (lightdm_greeter_get_hide_users_hint(m_ldmgreeter)
|
||||
|| lightdm_greeter_get_show_manual_login_hint(m_ldmgreeter)) {
|
||||
m_ui.userlabel->setVisible(false);
|
||||
m_ui.usersbox->setVisible(false);
|
||||
m_ui.useredit->setFocus();
|
||||
} else {
|
||||
m_ui.userlabel2->setVisible(false);
|
||||
m_ui.useredit->setVisible(false);
|
||||
m_ui.passedit->setFocus();
|
||||
}
|
||||
}
|
||||
|
||||
void KGreeter::paintEvent(QPaintEvent *event)
|
||||
{
|
||||
if (!m_background.isNull()) {
|
||||
QPainter painter(this);
|
||||
painter.drawImage(rect(), m_background);
|
||||
}
|
||||
|
||||
if (!m_rectangle.isNull()) {
|
||||
m_ui.groupbox->setFlat(true);
|
||||
QPainter painter(this);
|
||||
QSize kgreeterrectanglesize(m_ui.groupbox->size());
|
||||
kgreeterrectanglesize.rwidth() = kgreeterrectanglesize.width() * 1.04;
|
||||
kgreeterrectanglesize.rheight() = kgreeterrectanglesize.height() * 1.8;
|
||||
painter.drawImage(m_ui.groupbox->pos(), m_rectangle.scaled(kgreeterrectanglesize));
|
||||
} else {
|
||||
m_ui.groupbox->setFlat(false);
|
||||
}
|
||||
|
||||
QMainWindow::paintEvent(event);
|
||||
}
|
||||
|
||||
QByteArray KGreeter::getUser() const
|
||||
{
|
||||
if (m_ui.useredit->isVisible()) {
|
||||
return m_ui.useredit->text().toUtf8();
|
||||
}
|
||||
return m_ui.usersbox->currentText().toUtf8();
|
||||
}
|
||||
|
||||
QByteArray KGreeter::getPass() const
|
||||
{
|
||||
return m_ui.passedit->text().toUtf8();
|
||||
}
|
||||
|
||||
QByteArray KGreeter::getSession() const
|
||||
{
|
||||
Q_FOREACH (const QAction *sessionaction, m_sessionactions) {
|
||||
if (sessionaction->isChecked()) {
|
||||
return sessionaction->data().toByteArray();
|
||||
}
|
||||
}
|
||||
Q_ASSERT(false);
|
||||
return QByteArray();
|
||||
}
|
||||
|
||||
LightDMGreeter * KGreeter::getGreeter() const
|
||||
{
|
||||
return m_ldmgreeter;
|
||||
}
|
||||
|
||||
void KGreeter::showPromptCb(LightDMGreeter *ldmgreeter, const char *ldmtext, LightDMPromptType ldmtype, gpointer ldmptr)
|
||||
{
|
||||
// qDebug() << Q_FUNC_INFO;
|
||||
|
||||
KGreeter* kgreeter = static_cast<KGreeter*>(ldmptr);
|
||||
Q_ASSERT(kgreeter);
|
||||
|
||||
if (ldmtype == LIGHTDM_PROMPT_TYPE_SECRET) {
|
||||
const QByteArray kgreeterpass = kgreeter->getPass();
|
||||
|
||||
g_autoptr(GError) gliberror = NULL;
|
||||
if (!lightdm_greeter_respond(ldmgreeter, kgreeterpass.constData(), &gliberror)) {
|
||||
kgreeter->statusBar()->showMessage(i18n("Failed to repsond: %1", gliberror->message));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void KGreeter::authenticationCompleteCb(LightDMGreeter *ldmgreeter, gpointer ldmptr)
|
||||
{
|
||||
// qDebug() << Q_FUNC_INFO;
|
||||
|
||||
KGreeter* kgreeter = static_cast<KGreeter*>(ldmptr);
|
||||
Q_ASSERT(kgreeter);
|
||||
|
||||
const QByteArray kgreetersession = kgreeter->getSession();
|
||||
|
||||
g_autoptr(GError) gliberror = NULL;
|
||||
if (!lightdm_greeter_get_is_authenticated(ldmgreeter) ||
|
||||
!lightdm_greeter_start_session_sync(ldmgreeter, kgreetersession.constData(), &gliberror)) {
|
||||
kgreeter->statusBar()->showMessage(i18n("Failed to authenticate or start session: %1", gliberror->message));
|
||||
g_main_loop_quit(glibloop);
|
||||
} else {
|
||||
g_main_loop_quit(glibloop);
|
||||
qApp->quit();
|
||||
}
|
||||
}
|
||||
|
||||
void KGreeter::showMessageCb(LightDMGreeter *ldmgreeter, const gchar *ldmtext, LightDMMessageType ldmtype, gpointer ldmptr)
|
||||
{
|
||||
// qDebug() << Q_FUNC_INFO;
|
||||
|
||||
KGreeter* kgreeter = static_cast<KGreeter*>(ldmptr);
|
||||
Q_ASSERT(kgreeter);
|
||||
|
||||
kgreeter->statusBar()->showMessage(QString::fromUtf8(ldmtext));
|
||||
}
|
||||
|
||||
void KGreeter::slotSuspend()
|
||||
{
|
||||
g_autoptr(GError) gliberror = NULL;
|
||||
if (!lightdm_suspend(&gliberror)) {
|
||||
statusBar()->showMessage(i18n("Could not suspend: %1", gliberror->message));
|
||||
}
|
||||
}
|
||||
|
||||
void KGreeter::slotHibernate()
|
||||
{
|
||||
g_autoptr(GError) gliberror = NULL;
|
||||
if (!lightdm_hibernate(&gliberror)) {
|
||||
statusBar()->showMessage(i18n("Could not hibernate: %1", gliberror->message));
|
||||
}
|
||||
}
|
||||
|
||||
void KGreeter::slotPoweroff()
|
||||
{
|
||||
if (isUserLogged()) {
|
||||
const int kmessageresult = KMessageBox::questionYesNo(
|
||||
this,
|
||||
i18n("There is user logged in, are you sure you want to poweroff?")
|
||||
);
|
||||
if (kmessageresult != KMessageBox::Yes) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
g_autoptr(GError) gliberror = NULL;
|
||||
if (!lightdm_shutdown(&gliberror)) {
|
||||
statusBar()->showMessage(i18n("Could not poweroff: %1", gliberror->message));
|
||||
}
|
||||
}
|
||||
|
||||
void KGreeter::slotReboot()
|
||||
{
|
||||
if (isUserLogged()) {
|
||||
const int kmessageresult = KMessageBox::questionYesNo(
|
||||
this,
|
||||
i18n("There is user logged in, are you sure you want to reboot?")
|
||||
);
|
||||
if (kmessageresult != KMessageBox::Yes) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
g_autoptr(GError) gliberror = NULL;
|
||||
if (!lightdm_restart(&gliberror)) {
|
||||
statusBar()->showMessage(i18n("Could not reboot: %1", gliberror->message));
|
||||
}
|
||||
}
|
||||
|
||||
void KGreeter::slotSession()
|
||||
{
|
||||
const QAction* sessionaction = qobject_cast<QAction*>(sender());
|
||||
const QString sessionname = sessionaction->data().toString();
|
||||
|
||||
Q_FOREACH (QAction *sessionaction, m_sessionactions) {
|
||||
sessionaction->setChecked(false);
|
||||
if (sessionaction->data().toString() == sessionname) {
|
||||
sessionaction->setChecked(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void KGreeter::slotLayout()
|
||||
{
|
||||
QString ldmlayoutname;
|
||||
|
||||
const QAction* layoutaction = qobject_cast<QAction*>(sender());
|
||||
const QString layoutname = layoutaction->data().toString();
|
||||
GList *ldmlayouts = lightdm_get_layouts();
|
||||
for (GList *ldmitem = ldmlayouts; ldmitem; ldmitem = ldmitem->next) {
|
||||
LightDMLayout *ldmlayout = static_cast<LightDMLayout*>(ldmitem->data);
|
||||
Q_ASSERT(ldmlayout);
|
||||
|
||||
ldmlayoutname = QString::fromUtf8(lightdm_layout_get_name(ldmlayout));
|
||||
if (layoutname == ldmlayoutname) {
|
||||
lightdm_set_layout(ldmlayout);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (ldmlayoutname.isEmpty()) {
|
||||
Q_ASSERT(false);
|
||||
return;
|
||||
}
|
||||
|
||||
Q_FOREACH (QAction *layoutaction, m_layoutactions) {
|
||||
layoutaction->setChecked(false);
|
||||
if (layoutaction->data().toString() == ldmlayoutname) {
|
||||
layoutaction->setChecked(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void KGreeter::slotLogin()
|
||||
{
|
||||
const QByteArray kgreeterusername = getUser();
|
||||
const QByteArray kgreetersession = getSession();
|
||||
|
||||
// the trick is to save before lightdm_greeter_authenticate()
|
||||
{
|
||||
QSettings kgreeterstate("lightdm-kgreeter-state");
|
||||
kgreeterstate.setValue("state/lastsession", kgreetersession);
|
||||
kgreeterstate.setValue("state/lastuser", kgreeterusername);
|
||||
}
|
||||
|
||||
g_autoptr(GError) gliberror = NULL;
|
||||
lightdm_greeter_authenticate(m_ldmgreeter, kgreeterusername.constData(), &gliberror);
|
||||
|
||||
g_main_loop_run(glibloop);
|
||||
}
|
||||
|
||||
void KGreeter::setUser(const QString &user)
|
||||
{
|
||||
for (int i = 0; i < m_ui.usersbox->count(); i++) {
|
||||
if (m_ui.usersbox->itemText(i) == user) {
|
||||
m_ui.usersbox->setCurrentIndex(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
m_ui.useredit->setText(user);
|
||||
}
|
||||
|
||||
void KGreeter::setSession(const QString &session)
|
||||
{
|
||||
Q_FOREACH (QAction *sessionaction, m_sessionactions) {
|
||||
sessionaction->setChecked(false);
|
||||
if (sessionaction->data().toString() == session) {
|
||||
sessionaction->setChecked(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool KGreeter::isUserLogged() const
|
||||
{
|
||||
GList *ldmusers = lightdm_user_list_get_users(lightdm_user_list_get_instance());
|
||||
for (GList *ldmitem = ldmusers; ldmitem; ldmitem = ldmitem->next) {
|
||||
LightDMUser *ldmuser = static_cast<LightDMUser*>(ldmitem->data);
|
||||
Q_ASSERT(ldmuser);
|
||||
|
||||
if (lightdm_user_get_logged_in(ldmuser)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
int main(int argc, char**argv)
|
||||
{
|
||||
QApplication app(argc, argv);
|
||||
|
||||
const QString kgreeterstyle = kgreetersettings.value("greeter/style").toString();
|
||||
if (!kgreeterstyle.isEmpty()) {
|
||||
app.setStyle(kgreeterstyle);
|
||||
} else {
|
||||
app.setStyle(KStyle::defaultStyle());
|
||||
}
|
||||
|
||||
const QString kgreetercolorscheme = kgreetersettings.value("greeter/colorscheme").toString();
|
||||
if (!kgreetercolorscheme.isEmpty()) {
|
||||
KSharedConfigPtr kcolorschemeconfig = KSharedConfig::openConfig(
|
||||
QString::fromLatin1("color-schemes/%1.colors").arg(kgreetercolorscheme),
|
||||
KConfig::FullConfig, "data"
|
||||
);
|
||||
app.setPalette(KGlobalSettings::createApplicationPalette(kcolorschemeconfig));
|
||||
} else {
|
||||
app.setPalette(KGlobalSettings::createApplicationPalette());
|
||||
}
|
||||
|
||||
glibloop = g_main_loop_new(NULL, false);
|
||||
|
||||
KGreeter kgreeter;
|
||||
kgreeter.showMaximized();
|
||||
|
||||
LightDMGreeter *ldmgreeter = kgreeter.getGreeter();
|
||||
|
||||
g_autoptr(GError) gliberror = NULL;
|
||||
if (!lightdm_greeter_connect_to_daemon_sync(ldmgreeter, &gliberror)) {
|
||||
::fprintf(stderr, "%s: %s\n", "Could not connect to daemon", gliberror->message);
|
||||
return 1;
|
||||
}
|
||||
|
||||
return app.exec();
|
||||
}
|
||||
|
||||
#include "kgreeter.moc"
|
|
@ -1,227 +0,0 @@
|
|||
<?xml version="1.0" encoding="System"?>
|
||||
<ui version="4.0">
|
||||
<class>KGreeter</class>
|
||||
<widget class="QMainWindow" name="KGreeter">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>511</width>
|
||||
<height>417</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>KGreeter</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralwidget">
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="1" column="0" rowspan="2">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="0" colspan="3">
|
||||
<spacer name="verticalSpacer_2">
|
||||
<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="4" 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="1">
|
||||
<layout class="QGridLayout" name="gridLayout_4">
|
||||
<item row="1" column="1">
|
||||
<widget class="QPushButton" name="loginbutton">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Login</string>
|
||||
</property>
|
||||
<property name="autoDefault">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="default">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<spacer name="horizontalSpacer_4">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="0" colspan="3">
|
||||
<widget class="QGroupBox" name="groupbox">
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
<property name="flat">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0" colspan="3">
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Password:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QComboBox" name="usersbox"/>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="userlabel">
|
||||
<property name="text">
|
||||
<string>User:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QLineEdit" name="passedit">
|
||||
<property name="echoMode">
|
||||
<enum>QLineEdit::Password</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="useredit"/>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="userlabel2">
|
||||
<property name="text">
|
||||
<string>User:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="2" rowspan="2">
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QMenuBar" name="menubar">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>511</width>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
<widget class="QMenu" name="menuSystem">
|
||||
<property name="title">
|
||||
<string>System</string>
|
||||
</property>
|
||||
<addaction name="actionSuspend"/>
|
||||
<addaction name="actionHibernate"/>
|
||||
<addaction name="actionPoweroff"/>
|
||||
<addaction name="actionReboot"/>
|
||||
</widget>
|
||||
<widget class="QMenu" name="menuKeyboard">
|
||||
<property name="title">
|
||||
<string>Keyboard</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QMenu" name="menuSessions">
|
||||
<property name="title">
|
||||
<string>Sessions</string>
|
||||
</property>
|
||||
</widget>
|
||||
<addaction name="menuSystem"/>
|
||||
<addaction name="menuSessions"/>
|
||||
<addaction name="menuKeyboard"/>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="statusbar"/>
|
||||
<action name="actionSuspend">
|
||||
<property name="text">
|
||||
<string>Suspend</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionHibernate">
|
||||
<property name="text">
|
||||
<string>Hibernate</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionPoweroff">
|
||||
<property name="text">
|
||||
<string>Poweroff</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionReboot">
|
||||
<property name="text">
|
||||
<string>Reboot</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
|
@ -1,8 +0,0 @@
|
|||
# LightDM KGreeter Configuration
|
||||
# Available configuration options listed below.
|
||||
#
|
||||
[greeter]
|
||||
#style=
|
||||
#colorscheme=
|
||||
#background=
|
||||
#rectangle=
|
|
@ -1,6 +0,0 @@
|
|||
[Desktop Entry]
|
||||
Name=LightDM KGreeter Greeter
|
||||
Comment=This runs the KGreeter greeter, it should only be run from LightDM
|
||||
Exec=lightdm-kgreeter-greeter
|
||||
Type=Application
|
||||
X-Ubuntu-Gettext-Domain=lightdm
|
Loading…
Add table
Reference in a new issue