~ubuntu-branches/ubuntu/raring/plasma-mobile/raring-proposed

« back to all changes in this revision

Viewing changes to applications/about/src/aboutapp.cpp

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2012-07-17 12:04:43 UTC
  • mfrom: (1.1.6)
  • Revision ID: package-import@ubuntu.com-20120717120443-q3ig9u2fnltx67yg
Tags: 2.0+git2012071701-0ubuntu1
* New upstream snapshot
* Remove build-dep on kde-runtime-dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
 *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA .        *
20
20
 ***************************************************************************/
21
21
 
 
22
#include <QDeclarativeContext>
 
23
#include <QFile>
 
24
 
22
25
#include <KAction>
23
26
#include <KIcon>
24
27
#include <KStandardAction>
26
29
#include <Plasma/Theme>
27
30
 
28
31
#include "aboutapp.h"
 
32
#include "kdeclarativeview.h"
29
33
 
30
34
AboutApp::AboutApp()
31
 
    : KMainWindow()
 
35
    : KDeclarativeMainWindow()
32
36
{
33
 
    setAcceptDrops(true);
34
 
    addAction(KStandardAction::close(this, SLOT(close()), this));
35
 
    addAction(KStandardAction::quit(this, SLOT(close()), this));
36
 
    m_widget = new AppView(this);
37
 
 
38
 
    restoreWindowSize(config("Window"));
39
 
    setCentralWidget(m_widget);
40
 
 
41
 
    KConfigGroup cg(KSharedConfig::openConfig("plasmarc"), "Theme-plasma-mobile");
42
 
    const QString themeName = cg.readEntry("name", "air-mobile");
43
 
    Plasma::Theme::defaultTheme()->setUseGlobalSettings(false);
44
 
    Plasma::Theme::defaultTheme()->setThemeName(themeName);
45
 
 
46
 
    connect(m_widget, SIGNAL(titleChanged(QString)), SLOT(setCaption(QString)));
 
37
    declarativeView()->setPackageName("org.kde.active.aboutapp");
 
38
    
 
39
    //FIXME: find a prettier way
 
40
    QString fn;
 
41
    if (QFile::exists("/etc/image-release")) {
 
42
        fn = "/etc/image-release";
 
43
    } else {
 
44
        fn = "/etc/issue";
 
45
    }
 
46
    QFile f(fn);
 
47
    f.open(QIODevice::ReadOnly);
 
48
    const QString osVersion = f.readLine();
 
49
 
 
50
    declarativeView()->rootContext()->setContextProperty("runtimeInfoActiveVersion", "2.0");
 
51
    declarativeView()->rootContext()->setContextProperty("runtimeInfoKdeVersion", KDE::versionString());
 
52
    declarativeView()->rootContext()->setContextProperty("runtimeInfoOsVersion", osVersion);
47
53
}
48
54
 
49
55
AboutApp::~AboutApp()
51
57
    saveWindowSize(config("Window"));
52
58
}
53
59
 
54
 
KConfigGroup AboutApp::config(const QString &group)
55
 
{
56
 
    return KConfigGroup(KSharedConfig::openConfig("active-aboutapprc"), group);
57
 
}
58
 
 
59
 
QString AboutApp::name()
60
 
{
61
 
    return "About Plasma Active";
62
 
    //return m_widget->options()->name;
63
 
}
64
 
 
65
 
QIcon AboutApp::icon()
66
 
{
67
 
    return KIcon("active-about");
68
 
}
69
 
 
70
 
void AboutApp::setUseGL(const bool on)
71
 
{
72
 
    m_widget->setUseGL(on);
73
 
}
74
 
 
75
 
bool AboutApp::useGL() const
76
 
{
77
 
    return m_widget->useGL();
78
 
}
79
 
 
80
60
#include "aboutapp.moc"