From kde-commits Thu Jul 31 23:01:38 2014 From: =?utf-8?q?Sebastian_K=C3=83gler?= Date: Thu, 31 Jul 2014 23:01:38 +0000 To: kde-commits Subject: [plasma-desktop] applets/kickoff: Remove local copy of KUser QML bindings Message-Id: X-MARC-Message: https://marc.info/?l=kde-commits&m=140684771020194 Git commit af8fdadcbba3e99ff91958e91dcafb609e178891 by Sebastian K=C3=83gle= r. Committed on 31/07/2014 at 22:58. Pushed by sebas into branch 'master'. Remove local copy of KUser QML bindings KUser has moved to the KCoreAddons import, it's now located in the kdeclarative framework. (Which also means that you all should update to the latest kdeclarative. M +0 -1 applets/kickoff/CMakeLists.txt M +0 -2 applets/kickoff/core/kickoffplugin.cpp D +0 -135 applets/kickoff/core/kuserproxy.cpp D +0 -61 applets/kickoff/core/kuserproxy.h M +3 -4 applets/kickoff/package/contents/ui/Header.qml http://commits.kde.org/plasma-desktop/af8fdadcbba3e99ff91958e91dcafb609e178= 891 diff --git a/applets/kickoff/CMakeLists.txt b/applets/kickoff/CMakeLists.txt index b927385..11851d0 100644 --- a/applets/kickoff/CMakeLists.txt +++ b/applets/kickoff/CMakeLists.txt @@ -21,7 +21,6 @@ set(libkickoff_SRCS core/recentapplications.cpp core/recentlyusedmodel.cpp core/systemmodel.cpp - core/kuserproxy.cpp core/urlitemlauncher.cpp core/processrunner.cpp ) diff --git a/applets/kickoff/core/kickoffplugin.cpp b/applets/kickoff/core/= kickoffplugin.cpp index 8addff5..4eb059d 100644 --- a/applets/kickoff/core/kickoffplugin.cpp +++ b/applets/kickoff/core/kickoffplugin.cpp @@ -23,7 +23,6 @@ #include "leavemodel.h" #include "recentlyusedmodel.h" #include "systemmodel.h" -#include "kuserproxy.h" #include "urlitemlauncher.h" #include "processrunner.h" = @@ -39,7 +38,6 @@ void KickoffPlugin::registerTypes (const char *uri) qmlRegisterType(uri, 0, 1, "SystemModel"); qmlRegisterType(uri, 0, 1, "Launcher"); qmlRegisterType(uri, 0, 1, "ProcessRunner"); - qmlRegisterType(uri, 0, 1, "KUser"); } = #include "kickoffplugin.moc" diff --git a/applets/kickoff/core/kuserproxy.cpp b/applets/kickoff/core/kus= erproxy.cpp deleted file mode 100644 index 89321a7..0000000 --- a/applets/kickoff/core/kuserproxy.cpp +++ /dev/null @@ -1,135 +0,0 @@ -/*************************************************************************= ** - * Copyright 2013 Marco Martin = * - * Copyright 2014 Sebastian K=C3=BCgler = * - * = * - * This program is free software; you can redistribute it and/or modify = * - * it under the terms of the GNU General Public License as published by = * - * the Free Software Foundation; either version 2 of the License, or = * - * (at your option) any later version. = * - * = * - * This program 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 General Public License for more details. = * - * = * - * You should have received a copy of the GNU General Public License = * - * along with this program; if not, write to the = * - * Free Software Foundation, Inc., = * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . = * - *************************************************************************= **/ - -#include - -#include "kuserproxy.h" -#include -#include -#include - -#include -#include - -#include - -const QString etcPasswd =3D QStringLiteral("/etc/passwd"); - -KUserProxy::KUserProxy (QObject *parent) - : QObject(parent), - m_temporaryEmptyFaceIconPath(false) -{ - m_dirWatch.addFile(m_user.faceIconPath()); - if (QFile::exists(etcPasswd)) { - m_dirWatch.addFile(etcPasswd); - } - - connect(&m_dirWatch, &KDirWatch::dirty, this, &KUserProxy::update); - connect(&m_dirWatch, &KDirWatch::created, this, &KUserProxy::update); -} - -KUserProxy::~KUserProxy() -{ -} - -void KUserProxy::update(const QString &path) -{ - if (path =3D=3D m_user.faceIconPath()) { - // we need to force updates, even when the path doesn't change, - // but the underlying image does. Change path temporarily, to - // make the Image reload. - // Needs cache: false in the Image item to actually reload - m_temporaryEmptyFaceIconPath =3D true; - emit faceIconPathChanged(); - m_temporaryEmptyFaceIconPath =3D false; - emit faceIconPathChanged(); - } else if (path =3D=3D etcPasswd) { - m_user =3D KUser(); - emit nameChanged(); - } - } -QString KUserProxy::fullName() const -{ - QString fullName =3D m_user.property(KUser::FullName).toString(); - if (!fullName.isEmpty()) { - return fullName; - } - return loginName(); -} - -QString KUserProxy::loginName() const -{ - return m_user.loginName(); -} - -QString KUserProxy::faceIconPath() const -{ - if (m_temporaryEmptyFaceIconPath) { - return QString(); - } - const QString u =3D m_user.faceIconPath(); - const QFile f(u); - if (f.exists(u)) { - // We need to return a file URL, not a simple path - return QUrl::fromLocalFile(u).toString(); - } - return QString(); -} - -QString KUserProxy::os() -{ - if (m_os.isEmpty()) { - m_os =3D i18n("Plasma by KDE"); - QFile osfile("/etc/os-release"); - if (osfile.exists()) { - if (!osfile.open(QIODevice::ReadOnly | QIODevice::Text)) { - return QString(); - } - - QTextStream in(&osfile); - while(!in.atEnd()) { - QString line =3D in.readLine(); - if (line.startsWith("PRETTY_NAME")) { - QStringList fields =3D line.split("PRETTY_NAME=3D\""); - if (fields.count() =3D=3D 2) { - osfile.close(); - QString pretty =3D fields.at(1); - pretty.chop(1); - m_os =3D pretty; - return pretty; - } - } - } - osfile.close(); - } - } - return m_os; -} - -QString KUserProxy::host() const -{ - char hostname[256]; - hostname[0] =3D '\0'; - if (!gethostname(hostname, sizeof(hostname))) { - hostname[sizeof(hostname)-1] =3D '\0'; - } - return QString(hostname); -} - diff --git a/applets/kickoff/core/kuserproxy.h b/applets/kickoff/core/kuser= proxy.h deleted file mode 100644 index e0eaaec..0000000 --- a/applets/kickoff/core/kuserproxy.h +++ /dev/null @@ -1,61 +0,0 @@ -/*************************************************************************= ** - * Copyright 2014 Sebastian K=EF=BF=BDgler = * - * = * - * This program is free software; you can redistribute it and/or modify = * - * it under the terms of the GNU General Public License as published by = * - * the Free Software Foundation; either version 2 of the License, or = * - * (at your option) any later version. = * - * = * - * This program 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 General Public License for more details. = * - * = * - * You should have received a copy of the GNU General Public License = * - * along with this program; if not, write to the = * - * Free Software Foundation, Inc., = * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . = * - *************************************************************************= **/ - -#ifndef KUSERPROXY_H -#define KUSERPROXY_H - -#include - -#include -#include - -class KUserProxy : public QObject -{ - Q_OBJECT - - Q_PROPERTY(QString fullName READ fullName NOTIFY nameChanged) - Q_PROPERTY(QString loginName READ loginName NOTIFY nameChanged) - Q_PROPERTY(QString faceIconPath READ faceIconPath NOTIFY faceIconPathC= hanged) - Q_PROPERTY(QString os READ os CONSTANT) - Q_PROPERTY(QString host READ host CONSTANT) - -public: - KUserProxy(QObject *parent =3D 0); - ~KUserProxy(); - - QString fullName() const; - QString loginName() const; - QString faceIconPath() const; - QString os(); - QString host() const; - -Q_SIGNALS: - void nameChanged(); - void faceIconPathChanged(); - -private: - void update(const QString &path); - KDirWatch m_dirWatch; - KUser m_user; - QString m_os; - bool m_temporaryEmptyFaceIconPath; -}; - -#endif //KUSERPROXY_H - diff --git a/applets/kickoff/package/contents/ui/Header.qml b/applets/kicko= ff/package/contents/ui/Header.qml index 427694d..9523542 100644 --- a/applets/kickoff/package/contents/ui/Header.qml +++ b/applets/kickoff/package/contents/ui/Header.qml @@ -20,8 +20,7 @@ import QtQuick 2.0 import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.plasma.components 2.0 as PlasmaComponents import org.kde.plasma.extras 2.0 as PlasmaExtras - -import org.kde.plasma.private.kickoff 0.1 as Kickoff +import org.kde.kcoreaddons 1.0 as KCoreAddons = Item { id: header @@ -31,7 +30,7 @@ Item { property alias query: queryField.text property Item input: queryField = - Kickoff.KUser { + KCoreAddons.KUser { id: kuser } = @@ -55,7 +54,7 @@ Item { = Image { id: faceIcon - source: kuser.faceIconPath + source: kuser.faceIconUrl cache: false visible: source !=3D "" =20