Changeset View
Changeset View
Standalone View
Standalone View
cuttlefish/src/view.cpp
- This file was deleted.
1 | /*************************************************************************** | | |||
---|---|---|---|---|---|
2 | * * | | |||
3 | * Copyright 2014 Sebastian Kügler <sebas@kde.org> * | | |||
4 | * * | | |||
5 | * This program is free software; you can redistribute it and/or modify * | | |||
6 | * it under the terms of the GNU General Public License as published by * | | |||
7 | * the Free Software Foundation; either version 2 of the License, or * | | |||
8 | * (at your option) any later version. * | | |||
9 | * * | | |||
10 | * This program is distributed in the hope that it will be useful, * | | |||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * | | |||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * | | |||
13 | * GNU General Public License for more details. * | | |||
14 | * * | | |||
15 | * You should have received a copy of the GNU General Public License * | | |||
16 | * along with this program; if not, write to the * | | |||
17 | * Free Software Foundation, Inc., * | | |||
18 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * | | |||
19 | ***************************************************************************/ | | |||
20 | | ||||
21 | #include "view.h" | | |||
22 | #include "iconmodel.h" | | |||
23 | | ||||
24 | #include <QDebug> | | |||
25 | #include <QQmlContext> | | |||
26 | #include <QQmlEngine> | | |||
27 | #include <QQuickItem> | | |||
28 | | ||||
29 | #include <KPackage/PackageLoader> | | |||
30 | | ||||
31 | #include <KDeclarative/KDeclarative> | | |||
32 | #include <KLocalizedString> | | |||
33 | | ||||
34 | using namespace CuttleFish; | | |||
35 | | ||||
36 | View::View(const QString &category, QCommandLineParser &parser, QWindow *parent) | | |||
37 | : QQuickView(parent), | | |||
38 | m_browserRootItem(nullptr) | | |||
39 | { | | |||
40 | setResizeMode(QQuickView::SizeRootObjectToView); | | |||
41 | QQuickWindow::setDefaultAlphaBuffer(true); | | |||
42 | | ||||
43 | KDeclarative::KDeclarative kdeclarative; | | |||
44 | kdeclarative.setDeclarativeEngine(engine()); | | |||
45 | kdeclarative.setTranslationDomain(QStringLiteral("cuttlefish")); | | |||
46 | kdeclarative.setupBindings(); | | |||
47 | | ||||
48 | auto iconModel = new IconModel(this); | | |||
49 | rootContext()->setContextProperty("iconModel", iconModel); | | |||
50 | rootContext()->setContextProperty("pickerMode", parser.isSet("picker")); | | |||
51 | qmlRegisterType<IconModel>(); | | |||
52 | | ||||
53 | m_package = KPackage::PackageLoader::self()->loadPackage("Plasma/Generic"); | | |||
54 | m_package.setPath("org.kde.plasma.cuttlefish"); | | |||
55 | | ||||
56 | if (!m_package.isValid() || !m_package.metadata().isValid()) { | | |||
57 | qWarning() << "Could not load package org.kde.plasma.cuttlefish:" << m_package.path(); | | |||
58 | return; | | |||
59 | } | | |||
60 | | ||||
61 | setIcon(QIcon::fromTheme(m_package.metadata().iconName())); | | |||
62 | setTitle(m_package.metadata().name()); | | |||
63 | | ||||
64 | const QString qmlFile = m_package.filePath("mainscript"); | | |||
65 | setSource(QUrl::fromLocalFile(m_package.filePath("mainscript"))); | | |||
66 | show(); | | |||
67 | | ||||
68 | //qDebug() << "m_dirModel" << m_dirModel.rowCount(dirModel::index(KDirModel::Name); | | |||
69 | | ||||
70 | } | | |||
71 | | ||||
72 | View::~View() | | |||
73 | { | | |||
74 | } | |