[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [plasma-desktop] applets/kickoff: Remove local copy of KUser QML bindings
From:       Sebastian_KÃgler <sebas () kde ! org>
Date:       2014-07-31 23:01:38
Message-ID: E1XCzLu-0004KQ-KT () scm ! kde ! org
[Download RAW message or body]

Git commit af8fdadcbba3e99ff91958e91dcafb609e178891 by Sebastian KÃgler.
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/af8fdadcbba3e99ff91958e91dcafb609e178891

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<Kickoff::SystemModel>(uri, 0, 1, "SystemModel");
     qmlRegisterType<Kickoff::UrlItemLauncher>(uri, 0, 1, "Launcher");
     qmlRegisterType<Kickoff::ProcessRunner>(uri, 0, 1, "ProcessRunner");
-    qmlRegisterType<KUserProxy>(uri, 0, 1, "KUser");
 }
 
 #include "kickoffplugin.moc"
diff --git a/applets/kickoff/core/kuserproxy.cpp \
b/applets/kickoff/core/kuserproxy.cpp deleted file mode 100644
index 89321a7..0000000
--- a/applets/kickoff/core/kuserproxy.cpp
+++ /dev/null
@@ -1,135 +0,0 @@
-/***************************************************************************
- *   Copyright 2013 Marco Martin <mart@kde.org>                            *
- *   Copyright 2014 Sebastian Kügler <sebas@kde.org>                       *
- *                                                                         *
- *   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 <unistd.h>
-
-#include "kuserproxy.h"
-#include <QFile>
-#include <QTextStream>
-#include <QUrl>
-
-#include <KDirWatch>
-#include <KLocalizedString>
-
-#include <QDebug>
-
-const QString etcPasswd = 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 == 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 = true;
-            emit faceIconPathChanged();
-            m_temporaryEmptyFaceIconPath = false;
-            emit faceIconPathChanged();
-        } else if (path == etcPasswd) {
-            m_user = KUser();
-            emit nameChanged();
-        }
-    }
-QString KUserProxy::fullName() const
-{
-    QString fullName = 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 = 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 = 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 = in.readLine();
-                if (line.startsWith("PRETTY_NAME")) {
-                    QStringList fields = line.split("PRETTY_NAME=\"");
-                    if (fields.count() == 2) {
-                        osfile.close();
-                        QString pretty = fields.at(1);
-                        pretty.chop(1);
-                        m_os = pretty;
-                        return pretty;
-                    }
-                }
-            }
-            osfile.close();
-        }
-    }
-    return m_os;
-}
-
-QString KUserProxy::host() const
-{
-    char hostname[256];
-    hostname[0] = '\0';
-    if (!gethostname(hostname, sizeof(hostname))) {
-        hostname[sizeof(hostname)-1] = '\0';
-    }
-    return QString(hostname);
-}
-
diff --git a/applets/kickoff/core/kuserproxy.h b/applets/kickoff/core/kuserproxy.h
deleted file mode 100644
index e0eaaec..0000000
--- a/applets/kickoff/core/kuserproxy.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/***************************************************************************
- *   Copyright 2014 Sebastian K�gler <sebas@kde.org>                       *
- *                                                                         *
- *   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 <QObject>
-
-#include <KDirWatch>
-#include <KUser>
-
-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 faceIconPathChanged)
-    Q_PROPERTY(QString os READ os CONSTANT)
-    Q_PROPERTY(QString host READ host CONSTANT)
-
-public:
-    KUserProxy(QObject *parent = 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/kickoff/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 != ""
 


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic