Commit a8420b2a authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧

Rename DiscoverMainWindow to DiscoverObject

It's not the main window anymore
parent 9b9a2991
...@@ -8,7 +8,7 @@ qt5_add_resources(plasma_discover_SRCS assets.qrc) ...@@ -8,7 +8,7 @@ qt5_add_resources(plasma_discover_SRCS assets.qrc)
add_executable(plasma-discover ${plasma_discover_SRCS} add_executable(plasma-discover ${plasma_discover_SRCS}
main.cpp main.cpp
DiscoverMainWindow.cpp DiscoverObject.cpp
DiscoverDeclarativePlugin.cpp DiscoverDeclarativePlugin.cpp
FeaturedModel.cpp FeaturedModel.cpp
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/ */
#include "DiscoverMainWindow.h" #include "DiscoverObject.h"
#include "PaginateModel.h" #include "PaginateModel.h"
#include "UnityLauncher.h" #include "UnityLauncher.h"
#include "FeaturedModel.h" #include "FeaturedModel.h"
...@@ -79,7 +79,7 @@ public: ...@@ -79,7 +79,7 @@ public:
} }
}; };
DiscoverMainWindow::DiscoverMainWindow(CompactMode mode) DiscoverObject::DiscoverObject(CompactMode mode)
: QObject() : QObject()
, m_engine(new QQmlApplicationEngine) , m_engine(new QQmlApplicationEngine)
, m_mode(mode) , m_mode(mode)
...@@ -100,7 +100,7 @@ DiscoverMainWindow::DiscoverMainWindow(CompactMode mode) ...@@ -100,7 +100,7 @@ DiscoverMainWindow::DiscoverMainWindow(CompactMode mode)
qmlRegisterType<QQuickView>(); qmlRegisterType<QQuickView>();
qmlRegisterType<QActionGroup>(); qmlRegisterType<QActionGroup>();
qmlRegisterType<QAction>(); qmlRegisterType<QAction>();
qmlRegisterUncreatableType<DiscoverMainWindow>("org.kde.discover.app", 1, 0, "DiscoverMainWindow", QStringLiteral("don't do that")); qmlRegisterUncreatableType<DiscoverObject>("org.kde.discover.app", 1, 0, "DiscoverMainWindow", QStringLiteral("don't do that"));
setupActions(); setupActions();
auto uri = "org.kde.discover"; auto uri = "org.kde.discover";
...@@ -114,21 +114,21 @@ DiscoverMainWindow::DiscoverMainWindow(CompactMode mode) ...@@ -114,21 +114,21 @@ DiscoverMainWindow::DiscoverMainWindow(CompactMode mode)
m_engine->setNetworkAccessManagerFactory(m_networkAccessManagerFactory.data()); m_engine->setNetworkAccessManagerFactory(m_networkAccessManagerFactory.data());
m_engine->rootContext()->setContextProperty(QStringLiteral("app"), this); m_engine->rootContext()->setContextProperty(QStringLiteral("app"), this);
connect(m_engine, &QQmlApplicationEngine::objectCreated, this, &DiscoverMainWindow::integrateObject); connect(m_engine, &QQmlApplicationEngine::objectCreated, this, &DiscoverObject::integrateObject);
m_engine->load(QUrl(QStringLiteral("qrc:/qml/DiscoverWindow.qml"))); m_engine->load(QUrl(QStringLiteral("qrc:/qml/DiscoverWindow.qml")));
} }
DiscoverMainWindow::~DiscoverMainWindow() DiscoverObject::~DiscoverObject()
{ {
delete m_engine; delete m_engine;
} }
bool DiscoverMainWindow::isRoot() bool DiscoverObject::isRoot()
{ {
return ::getuid() == 0; return ::getuid() == 0;
} }
QStringList DiscoverMainWindow::modes() const QStringList DiscoverObject::modes() const
{ {
QStringList ret; QStringList ret;
QObject* obj = rootObject(); QObject* obj = rootObject();
...@@ -142,7 +142,7 @@ QStringList DiscoverMainWindow::modes() const ...@@ -142,7 +142,7 @@ QStringList DiscoverMainWindow::modes() const
return ret; return ret;
} }
void DiscoverMainWindow::openMode(const QString& _mode) void DiscoverObject::openMode(const QString& _mode)
{ {
if(!modes().contains(_mode)) if(!modes().contains(_mode))
qWarning() << "unknown mode" << _mode; qWarning() << "unknown mode" << _mode;
...@@ -159,12 +159,12 @@ void DiscoverMainWindow::openMode(const QString& _mode) ...@@ -159,12 +159,12 @@ void DiscoverMainWindow::openMode(const QString& _mode)
obj->setProperty("currentTopLevel", modeComp); obj->setProperty("currentTopLevel", modeComp);
} }
void DiscoverMainWindow::openMimeType(const QString& mime) void DiscoverObject::openMimeType(const QString& mime)
{ {
emit listMimeInternal(mime); emit listMimeInternal(mime);
} }
void DiscoverMainWindow::openCategory(const QString& category) void DiscoverObject::openCategory(const QString& category)
{ {
rootObject()->setProperty("defaultStartup", false); rootObject()->setProperty("defaultStartup", false);
auto action = new OneTimeAction( auto action = new OneTimeAction(
...@@ -186,7 +186,7 @@ void DiscoverMainWindow::openCategory(const QString& category) ...@@ -186,7 +186,7 @@ void DiscoverMainWindow::openCategory(const QString& category)
} }
} }
void DiscoverMainWindow::openLocalPackage(const QUrl& localfile) void DiscoverObject::openLocalPackage(const QUrl& localfile)
{ {
if (!QFile::exists(localfile.toLocalFile())) { if (!QFile::exists(localfile.toLocalFile())) {
// showPassiveNotification(i18n("Trying to open unexisting file '%1'", localfile.toString())); // showPassiveNotification(i18n("Trying to open unexisting file '%1'", localfile.toString()));
...@@ -214,13 +214,13 @@ void DiscoverMainWindow::openLocalPackage(const QUrl& localfile) ...@@ -214,13 +214,13 @@ void DiscoverMainWindow::openLocalPackage(const QUrl& localfile)
} }
} }
void DiscoverMainWindow::openApplication(const QUrl& url) void DiscoverObject::openApplication(const QUrl& url)
{ {
Q_ASSERT(!url.isEmpty()); Q_ASSERT(!url.isEmpty());
Q_EMIT openUrl(url); Q_EMIT openUrl(url);
} }
void DiscoverMainWindow::integrateObject(QObject* object) void DiscoverObject::integrateObject(QObject* object)
{ {
if (!object) { if (!object) {
qWarning() << "Errors when loading the GUI"; qWarning() << "Errors when loading the GUI";
...@@ -244,7 +244,7 @@ void DiscoverMainWindow::integrateObject(QObject* object) ...@@ -244,7 +244,7 @@ void DiscoverMainWindow::integrateObject(QObject* object)
connect(object, &QObject::destroyed, qGuiApp, &QCoreApplication::quit); connect(object, &QObject::destroyed, qGuiApp, &QCoreApplication::quit);
} }
bool DiscoverMainWindow::eventFilter(QObject * object, QEvent * event) bool DiscoverObject::eventFilter(QObject * object, QEvent * event)
{ {
if (object!=rootObject()) if (object!=rootObject())
return false; return false;
...@@ -265,40 +265,40 @@ bool DiscoverMainWindow::eventFilter(QObject * object, QEvent * event) ...@@ -265,40 +265,40 @@ bool DiscoverMainWindow::eventFilter(QObject * object, QEvent * event)
return false; return false;
} }
void DiscoverMainWindow::setupActions() void DiscoverObject::setupActions()
{ {
if (KAuthorized::authorizeAction(QStringLiteral("help_contents"))) { if (KAuthorized::authorizeAction(QStringLiteral("help_contents"))) {
auto mHandBookAction = KStandardAction::helpContents(this, &DiscoverMainWindow::appHelpActivated, this); auto mHandBookAction = KStandardAction::helpContents(this, &DiscoverObject::appHelpActivated, this);
m_collection[mHandBookAction->objectName()] = mHandBookAction; m_collection[mHandBookAction->objectName()] = mHandBookAction;
} }
if (KAuthorized::authorizeAction(QStringLiteral("help_report_bug")) && !KAboutData::applicationData().bugAddress().isEmpty()) { if (KAuthorized::authorizeAction(QStringLiteral("help_report_bug")) && !KAboutData::applicationData().bugAddress().isEmpty()) {
auto mReportBugAction = KStandardAction::reportBug(this, &DiscoverMainWindow::reportBug, this); auto mReportBugAction = KStandardAction::reportBug(this, &DiscoverObject::reportBug, this);
m_collection[mReportBugAction->objectName()] = mReportBugAction; m_collection[mReportBugAction->objectName()] = mReportBugAction;
} }
if (KAuthorized::authorizeAction(QStringLiteral("help_about_app"))) { if (KAuthorized::authorizeAction(QStringLiteral("help_about_app"))) {
auto mAboutAppAction = KStandardAction::aboutApp(this, &DiscoverMainWindow::aboutApplication, this); auto mAboutAppAction = KStandardAction::aboutApp(this, &DiscoverObject::aboutApplication, this);
m_collection[mAboutAppAction->objectName()] = mAboutAppAction; m_collection[mAboutAppAction->objectName()] = mAboutAppAction;
} }
} }
QAction * DiscoverMainWindow::action(const QString& name) const QAction * DiscoverObject::action(const QString& name) const
{ {
return m_collection.value(name); return m_collection.value(name);
} }
QString DiscoverMainWindow::iconName(const QIcon& icon) QString DiscoverObject::iconName(const QIcon& icon)
{ {
return icon.name(); return icon.name();
} }
void DiscoverMainWindow::appHelpActivated() void DiscoverObject::appHelpActivated()
{ {
QDesktopServices::openUrl(QUrl(QStringLiteral("help:/"))); QDesktopServices::openUrl(QUrl(QStringLiteral("help:/")));
} }
void DiscoverMainWindow::aboutApplication() void DiscoverObject::aboutApplication()
{ {
static QPointer<QDialog> dialog; static QPointer<QDialog> dialog;
if (!dialog) { if (!dialog) {
...@@ -308,7 +308,7 @@ void DiscoverMainWindow::aboutApplication() ...@@ -308,7 +308,7 @@ void DiscoverMainWindow::aboutApplication()
dialog->show(); dialog->show();
} }
void DiscoverMainWindow::reportBug() void DiscoverObject::reportBug()
{ {
static QPointer<QDialog> dialog; static QPointer<QDialog> dialog;
if (!dialog) { if (!dialog) {
...@@ -318,14 +318,14 @@ void DiscoverMainWindow::reportBug() ...@@ -318,14 +318,14 @@ void DiscoverMainWindow::reportBug()
dialog->show(); dialog->show();
} }
void DiscoverMainWindow::switchApplicationLanguage() void DiscoverObject::switchApplicationLanguage()
{ {
// auto langDialog = new KSwitchLanguageDialog(nullptr); // auto langDialog = new KSwitchLanguageDialog(nullptr);
// connect(langDialog, SIGNAL(finished(int)), this, SLOT(dialogFinished())); // connect(langDialog, SIGNAL(finished(int)), this, SLOT(dialogFinished()));
// langDialog->show(); // langDialog->show();
} }
void DiscoverMainWindow::setCompactMode(DiscoverMainWindow::CompactMode mode) void DiscoverObject::setCompactMode(DiscoverObject::CompactMode mode)
{ {
if (m_mode != mode) { if (m_mode != mode) {
m_mode = mode; m_mode = mode;
...@@ -381,21 +381,21 @@ private: ...@@ -381,21 +381,21 @@ private:
QList<QQmlError> m_warnings; QList<QQmlError> m_warnings;
}; };
void DiscoverMainWindow::loadTest(const QUrl& url) void DiscoverObject::loadTest(const QUrl& url)
{ {
new DiscoverTestExecutor(rootObject(), engine(), url); new DiscoverTestExecutor(rootObject(), engine(), url);
} }
QWindow* DiscoverMainWindow::rootObject() const QWindow* DiscoverObject::rootObject() const
{ {
return qobject_cast<QWindow*>(m_engine->rootObjects().at(0)); return qobject_cast<QWindow*>(m_engine->rootObjects().at(0));
} }
void DiscoverMainWindow::showPassiveNotification(const QString& msg) void DiscoverObject::showPassiveNotification(const QString& msg)
{ {
QTimer::singleShot(100, this, [this, msg](){ QTimer::singleShot(100, this, [this, msg](){
QMetaObject::invokeMethod(rootObject(), "showPassiveNotification", Qt::QueuedConnection, Q_ARG(QVariant, msg), Q_ARG(QVariant, {}), Q_ARG(QVariant, {}), Q_ARG(QVariant, {})); QMetaObject::invokeMethod(rootObject(), "showPassiveNotification", Qt::QueuedConnection, Q_ARG(QVariant, msg), Q_ARG(QVariant, {}), Q_ARG(QVariant, {}), Q_ARG(QVariant, {}));
}); });
} }
#include "DiscoverMainWindow.moc" #include "DiscoverObject.moc"
...@@ -31,7 +31,7 @@ class QQmlApplicationEngine; ...@@ -31,7 +31,7 @@ class QQmlApplicationEngine;
class CachedNetworkAccessManagerFactory; class CachedNetworkAccessManagerFactory;
class ResourcesProxyModel; class ResourcesProxyModel;
class DiscoverMainWindow : public QObject class DiscoverObject : public QObject
{ {
Q_OBJECT Q_OBJECT
Q_PROPERTY(CompactMode compactMode READ compactMode WRITE setCompactMode NOTIFY compactModeChanged) Q_PROPERTY(CompactMode compactMode READ compactMode WRITE setCompactMode NOTIFY compactModeChanged)
...@@ -40,8 +40,8 @@ class DiscoverMainWindow : public QObject ...@@ -40,8 +40,8 @@ class DiscoverMainWindow : public QObject
enum CompactMode { Auto, Compact, Full }; enum CompactMode { Auto, Compact, Full };
Q_ENUM(CompactMode) Q_ENUM(CompactMode)
explicit DiscoverMainWindow(CompactMode mode); explicit DiscoverObject(CompactMode mode);
~DiscoverMainWindow() override; ~DiscoverObject() override;
QStringList modes() const; QStringList modes() const;
void setupActions(); void setupActions();
......
...@@ -26,17 +26,17 @@ ...@@ -26,17 +26,17 @@
#include <KLocalizedString> #include <KLocalizedString>
#include <QCommandLineParser> #include <QCommandLineParser>
#include <qwindow.h> #include <qwindow.h>
#include "DiscoverMainWindow.h" #include "DiscoverObject.h"
#include <DiscoverBackendsFactory.h> #include <DiscoverBackendsFactory.h>
#include "DiscoverVersion.h" #include "DiscoverVersion.h"
#include <QTextStream> #include <QTextStream>
#include <QStandardPaths> #include <QStandardPaths>
typedef QHash<QString, DiscoverMainWindow::CompactMode> StringCompactMode; typedef QHash<QString, DiscoverObject::CompactMode> StringCompactMode;
Q_GLOBAL_STATIC_WITH_ARGS(StringCompactMode, s_decodeCompactMode, (StringCompactMode { Q_GLOBAL_STATIC_WITH_ARGS(StringCompactMode, s_decodeCompactMode, (StringCompactMode {
{ QLatin1String("auto"), DiscoverMainWindow::Auto }, { QLatin1String("auto"), DiscoverObject::Auto },
{ QLatin1String("compact"), DiscoverMainWindow::Compact }, { QLatin1String("compact"), DiscoverObject::Compact },
{ QLatin1String("full"), DiscoverMainWindow::Full } { QLatin1String("full"), DiscoverObject::Full }
})) }))
QCommandLineParser* createParser() QCommandLineParser* createParser()
...@@ -59,7 +59,7 @@ QCommandLineParser* createParser() ...@@ -59,7 +59,7 @@ QCommandLineParser* createParser()
return parser; return parser;
} }
void processArgs(QCommandLineParser* parser, DiscoverMainWindow* mainWindow) void processArgs(QCommandLineParser* parser, DiscoverObject* mainWindow)
{ {
if(parser->isSet(QStringLiteral("application"))) if(parser->isSet(QStringLiteral("application")))
mainWindow->openApplication(QUrl(parser->value(QStringLiteral("application")))); mainWindow->openApplication(QUrl(parser->value(QStringLiteral("application"))));
...@@ -100,7 +100,7 @@ int main(int argc, char** argv) ...@@ -100,7 +100,7 @@ int main(int argc, char** argv)
about.setProductName("discover/discover"); about.setProductName("discover/discover");
KAboutData::setApplicationData(about); KAboutData::setApplicationData(about);
DiscoverMainWindow *mainWindow = nullptr; DiscoverObject *mainWindow = nullptr;
{ {
QScopedPointer<QCommandLineParser> parser(createParser()); QScopedPointer<QCommandLineParser> parser(createParser());
parser->process(app); parser->process(app);
...@@ -121,8 +121,8 @@ int main(int argc, char** argv) ...@@ -121,8 +121,8 @@ int main(int argc, char** argv)
KDBusService* service = new KDBusService(KDBusService::Unique, &app); KDBusService* service = new KDBusService(KDBusService::Unique, &app);
mainWindow = new DiscoverMainWindow(s_decodeCompactMode->value(parser->value(QStringLiteral("compact")), DiscoverMainWindow::Full)); mainWindow = new DiscoverObject(s_decodeCompactMode->value(parser->value(QStringLiteral("compact")), DiscoverObject::Full));
QObject::connect(&app, &QCoreApplication::aboutToQuit, mainWindow, &DiscoverMainWindow::deleteLater); QObject::connect(&app, &QCoreApplication::aboutToQuit, mainWindow, &DiscoverObject::deleteLater);
QObject::connect(service, &KDBusService::activateRequested, mainWindow, [mainWindow](const QStringList &arguments, const QString &/*workingDirectory*/){ QObject::connect(service, &KDBusService::activateRequested, mainWindow, [mainWindow](const QStringList &arguments, const QString &/*workingDirectory*/){
if (!mainWindow->rootObject()) if (!mainWindow->rootObject())
QCoreApplication::instance()->quit(); QCoreApplication::instance()->quit();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment