Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Plasma
Discover
Commits
a8420b2a
Commit
a8420b2a
authored
Jan 22, 2018
by
Aleix Pol Gonzalez
🐧
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename DiscoverMainWindow to DiscoverObject
It's not the main window anymore
parent
9b9a2991
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
42 additions
and
42 deletions
+42
-42
discover/CMakeLists.txt
discover/CMakeLists.txt
+1
-1
discover/DiscoverObject.cpp
discover/DiscoverObject.cpp
+29
-29
discover/DiscoverObject.h
discover/DiscoverObject.h
+3
-3
discover/main.cpp
discover/main.cpp
+9
-9
No files found.
discover/CMakeLists.txt
View file @
a8420b2a
...
...
@@ -8,7 +8,7 @@ qt5_add_resources(plasma_discover_SRCS assets.qrc)
add_executable
(
plasma-discover
${
plasma_discover_SRCS
}
main.cpp
Discover
MainWindow
.cpp
Discover
Object
.cpp
DiscoverDeclarativePlugin.cpp
FeaturedModel.cpp
...
...
discover/Discover
MainWindow
.cpp
→
discover/Discover
Object
.cpp
View file @
a8420b2a
...
...
@@ -17,7 +17,7 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "Discover
MainWindow
.h"
#include "Discover
Object
.h"
#include "PaginateModel.h"
#include "UnityLauncher.h"
#include "FeaturedModel.h"
...
...
@@ -79,7 +79,7 @@ public:
}
};
Discover
MainWindow
::
DiscoverMainWindow
(
CompactMode
mode
)
Discover
Object
::
DiscoverObject
(
CompactMode
mode
)
:
QObject
()
,
m_engine
(
new
QQmlApplicationEngine
)
,
m_mode
(
mode
)
...
...
@@ -100,7 +100,7 @@ DiscoverMainWindow::DiscoverMainWindow(CompactMode mode)
qmlRegisterType
<
QQuickView
>
();
qmlRegisterType
<
QActionGroup
>
();
qmlRegisterType
<
QAction
>
();
qmlRegisterUncreatableType
<
Discover
MainWindow
>
(
"org.kde.discover.app"
,
1
,
0
,
"DiscoverMainWindow"
,
QStringLiteral
(
"don't do that"
));
qmlRegisterUncreatableType
<
Discover
Object
>
(
"org.kde.discover.app"
,
1
,
0
,
"DiscoverMainWindow"
,
QStringLiteral
(
"don't do that"
));
setupActions
();
auto
uri
=
"org.kde.discover"
;
...
...
@@ -114,21 +114,21 @@ DiscoverMainWindow::DiscoverMainWindow(CompactMode mode)
m_engine
->
setNetworkAccessManagerFactory
(
m_networkAccessManagerFactory
.
data
());
m_engine
->
rootContext
()
->
setContextProperty
(
QStringLiteral
(
"app"
),
this
);
connect
(
m_engine
,
&
QQmlApplicationEngine
::
objectCreated
,
this
,
&
Discover
MainWindow
::
integrateObject
);
connect
(
m_engine
,
&
QQmlApplicationEngine
::
objectCreated
,
this
,
&
Discover
Object
::
integrateObject
);
m_engine
->
load
(
QUrl
(
QStringLiteral
(
"qrc:/qml/DiscoverWindow.qml"
)));
}
Discover
MainWindow
::~
Discover
MainWindow
()
Discover
Object
::~
Discover
Object
()
{
delete
m_engine
;
}
bool
Discover
MainWindow
::
isRoot
()
bool
Discover
Object
::
isRoot
()
{
return
::
getuid
()
==
0
;
}
QStringList
Discover
MainWindow
::
modes
()
const
QStringList
Discover
Object
::
modes
()
const
{
QStringList
ret
;
QObject
*
obj
=
rootObject
();
...
...
@@ -142,7 +142,7 @@ QStringList DiscoverMainWindow::modes() const
return
ret
;
}
void
Discover
MainWindow
::
openMode
(
const
QString
&
_mode
)
void
Discover
Object
::
openMode
(
const
QString
&
_mode
)
{
if
(
!
modes
().
contains
(
_mode
))
qWarning
()
<<
"unknown mode"
<<
_mode
;
...
...
@@ -159,12 +159,12 @@ void DiscoverMainWindow::openMode(const QString& _mode)
obj
->
setProperty
(
"currentTopLevel"
,
modeComp
);
}
void
Discover
MainWindow
::
openMimeType
(
const
QString
&
mime
)
void
Discover
Object
::
openMimeType
(
const
QString
&
mime
)
{
emit
listMimeInternal
(
mime
);
}
void
Discover
MainWindow
::
openCategory
(
const
QString
&
category
)
void
Discover
Object
::
openCategory
(
const
QString
&
category
)
{
rootObject
()
->
setProperty
(
"defaultStartup"
,
false
);
auto
action
=
new
OneTimeAction
(
...
...
@@ -186,7 +186,7 @@ void DiscoverMainWindow::openCategory(const QString& category)
}
}
void
Discover
MainWindow
::
openLocalPackage
(
const
QUrl
&
localfile
)
void
Discover
Object
::
openLocalPackage
(
const
QUrl
&
localfile
)
{
if
(
!
QFile
::
exists
(
localfile
.
toLocalFile
()))
{
// showPassiveNotification(i18n("Trying to open unexisting file '%1'", localfile.toString()));
...
...
@@ -214,13 +214,13 @@ void DiscoverMainWindow::openLocalPackage(const QUrl& localfile)
}
}
void
Discover
MainWindow
::
openApplication
(
const
QUrl
&
url
)
void
Discover
Object
::
openApplication
(
const
QUrl
&
url
)
{
Q_ASSERT
(
!
url
.
isEmpty
());
Q_EMIT
openUrl
(
url
);
}
void
Discover
MainWindow
::
integrateObject
(
QObject
*
object
)
void
Discover
Object
::
integrateObject
(
QObject
*
object
)
{
if
(
!
object
)
{
qWarning
()
<<
"Errors when loading the GUI"
;
...
...
@@ -244,7 +244,7 @@ void DiscoverMainWindow::integrateObject(QObject* object)
connect
(
object
,
&
QObject
::
destroyed
,
qGuiApp
,
&
QCoreApplication
::
quit
);
}
bool
Discover
MainWindow
::
eventFilter
(
QObject
*
object
,
QEvent
*
event
)
bool
Discover
Object
::
eventFilter
(
QObject
*
object
,
QEvent
*
event
)
{
if
(
object
!=
rootObject
())
return
false
;
...
...
@@ -265,40 +265,40 @@ bool DiscoverMainWindow::eventFilter(QObject * object, QEvent * event)
return
false
;
}
void
Discover
MainWindow
::
setupActions
()
void
Discover
Object
::
setupActions
()
{
if
(
KAuthorized
::
authorizeAction
(
QStringLiteral
(
"help_contents"
)))
{
auto
mHandBookAction
=
KStandardAction
::
helpContents
(
this
,
&
Discover
MainWindow
::
appHelpActivated
,
this
);
auto
mHandBookAction
=
KStandardAction
::
helpContents
(
this
,
&
Discover
Object
::
appHelpActivated
,
this
);
m_collection
[
mHandBookAction
->
objectName
()]
=
mHandBookAction
;
}
if
(
KAuthorized
::
authorizeAction
(
QStringLiteral
(
"help_report_bug"
))
&&
!
KAboutData
::
applicationData
().
bugAddress
().
isEmpty
())
{
auto
mReportBugAction
=
KStandardAction
::
reportBug
(
this
,
&
Discover
MainWindow
::
reportBug
,
this
);
auto
mReportBugAction
=
KStandardAction
::
reportBug
(
this
,
&
Discover
Object
::
reportBug
,
this
);
m_collection
[
mReportBugAction
->
objectName
()]
=
mReportBugAction
;
}
if
(
KAuthorized
::
authorizeAction
(
QStringLiteral
(
"help_about_app"
)))
{
auto
mAboutAppAction
=
KStandardAction
::
aboutApp
(
this
,
&
Discover
MainWindow
::
aboutApplication
,
this
);
auto
mAboutAppAction
=
KStandardAction
::
aboutApp
(
this
,
&
Discover
Object
::
aboutApplication
,
this
);
m_collection
[
mAboutAppAction
->
objectName
()]
=
mAboutAppAction
;
}
}
QAction
*
Discover
MainWindow
::
action
(
const
QString
&
name
)
const
QAction
*
Discover
Object
::
action
(
const
QString
&
name
)
const
{
return
m_collection
.
value
(
name
);
}
QString
Discover
MainWindow
::
iconName
(
const
QIcon
&
icon
)
QString
Discover
Object
::
iconName
(
const
QIcon
&
icon
)
{
return
icon
.
name
();
}
void
Discover
MainWindow
::
appHelpActivated
()
void
Discover
Object
::
appHelpActivated
()
{
QDesktopServices
::
openUrl
(
QUrl
(
QStringLiteral
(
"help:/"
)));
}
void
Discover
MainWindow
::
aboutApplication
()
void
Discover
Object
::
aboutApplication
()
{
static
QPointer
<
QDialog
>
dialog
;
if
(
!
dialog
)
{
...
...
@@ -308,7 +308,7 @@ void DiscoverMainWindow::aboutApplication()
dialog
->
show
();
}
void
Discover
MainWindow
::
reportBug
()
void
Discover
Object
::
reportBug
()
{
static
QPointer
<
QDialog
>
dialog
;
if
(
!
dialog
)
{
...
...
@@ -318,14 +318,14 @@ void DiscoverMainWindow::reportBug()
dialog
->
show
();
}
void
Discover
MainWindow
::
switchApplicationLanguage
()
void
Discover
Object
::
switchApplicationLanguage
()
{
// auto langDialog = new KSwitchLanguageDialog(nullptr);
// connect(langDialog, SIGNAL(finished(int)), this, SLOT(dialogFinished()));
// langDialog->show();
}
void
Discover
MainWindow
::
setCompactMode
(
Discover
MainWindow
::
CompactMode
mode
)
void
Discover
Object
::
setCompactMode
(
Discover
Object
::
CompactMode
mode
)
{
if
(
m_mode
!=
mode
)
{
m_mode
=
mode
;
...
...
@@ -381,21 +381,21 @@ private:
QList
<
QQmlError
>
m_warnings
;
};
void
Discover
MainWindow
::
loadTest
(
const
QUrl
&
url
)
void
Discover
Object
::
loadTest
(
const
QUrl
&
url
)
{
new
DiscoverTestExecutor
(
rootObject
(),
engine
(),
url
);
}
QWindow
*
Discover
MainWindow
::
rootObject
()
const
QWindow
*
Discover
Object
::
rootObject
()
const
{
return
qobject_cast
<
QWindow
*>
(
m_engine
->
rootObjects
().
at
(
0
));
}
void
Discover
MainWindow
::
showPassiveNotification
(
const
QString
&
msg
)
void
Discover
Object
::
showPassiveNotification
(
const
QString
&
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
,
{}));
});
}
#include "Discover
MainWindow
.moc"
#include "Discover
Object
.moc"
discover/Discover
MainWindow
.h
→
discover/Discover
Object
.h
View file @
a8420b2a
...
...
@@ -31,7 +31,7 @@ class QQmlApplicationEngine;
class
CachedNetworkAccessManagerFactory
;
class
ResourcesProxyModel
;
class
Discover
MainWindow
:
public
QObject
class
Discover
Object
:
public
QObject
{
Q_OBJECT
Q_PROPERTY
(
CompactMode
compactMode
READ
compactMode
WRITE
setCompactMode
NOTIFY
compactModeChanged
)
...
...
@@ -40,8 +40,8 @@ class DiscoverMainWindow : public QObject
enum
CompactMode
{
Auto
,
Compact
,
Full
};
Q_ENUM
(
CompactMode
)
explicit
Discover
MainWindow
(
CompactMode
mode
);
~
Discover
MainWindow
()
override
;
explicit
Discover
Object
(
CompactMode
mode
);
~
Discover
Object
()
override
;
QStringList
modes
()
const
;
void
setupActions
();
...
...
discover/main.cpp
View file @
a8420b2a
...
...
@@ -26,17 +26,17 @@
#include <KLocalizedString>
#include <QCommandLineParser>
#include <qwindow.h>
#include "Discover
MainWindow
.h"
#include "Discover
Object
.h"
#include <DiscoverBackendsFactory.h>
#include "DiscoverVersion.h"
#include <QTextStream>
#include <QStandardPaths>
typedef
QHash
<
QString
,
Discover
MainWindow
::
CompactMode
>
StringCompactMode
;
typedef
QHash
<
QString
,
Discover
Object
::
CompactMode
>
StringCompactMode
;
Q_GLOBAL_STATIC_WITH_ARGS
(
StringCompactMode
,
s_decodeCompactMode
,
(
StringCompactMode
{
{
QLatin1String
(
"auto"
),
Discover
MainWindow
::
Auto
},
{
QLatin1String
(
"compact"
),
Discover
MainWindow
::
Compact
},
{
QLatin1String
(
"full"
),
Discover
MainWindow
::
Full
}
{
QLatin1String
(
"auto"
),
Discover
Object
::
Auto
},
{
QLatin1String
(
"compact"
),
Discover
Object
::
Compact
},
{
QLatin1String
(
"full"
),
Discover
Object
::
Full
}
}))
QCommandLineParser
*
createParser
()
...
...
@@ -59,7 +59,7 @@ QCommandLineParser* createParser()
return
parser
;
}
void
processArgs
(
QCommandLineParser
*
parser
,
Discover
MainWindow
*
mainWindow
)
void
processArgs
(
QCommandLineParser
*
parser
,
Discover
Object
*
mainWindow
)
{
if
(
parser
->
isSet
(
QStringLiteral
(
"application"
)))
mainWindow
->
openApplication
(
QUrl
(
parser
->
value
(
QStringLiteral
(
"application"
))));
...
...
@@ -100,7 +100,7 @@ int main(int argc, char** argv)
about
.
setProductName
(
"discover/discover"
);
KAboutData
::
setApplicationData
(
about
);
Discover
MainWindow
*
mainWindow
=
nullptr
;
Discover
Object
*
mainWindow
=
nullptr
;
{
QScopedPointer
<
QCommandLineParser
>
parser
(
createParser
());
parser
->
process
(
app
);
...
...
@@ -121,8 +121,8 @@ int main(int argc, char** argv)
KDBusService
*
service
=
new
KDBusService
(
KDBusService
::
Unique
,
&
app
);
mainWindow
=
new
Discover
MainWindow
(
s_decodeCompactMode
->
value
(
parser
->
value
(
QStringLiteral
(
"compact"
)),
Discover
MainWindow
::
Full
));
QObject
::
connect
(
&
app
,
&
QCoreApplication
::
aboutToQuit
,
mainWindow
,
&
Discover
MainWindow
::
deleteLater
);
mainWindow
=
new
Discover
Object
(
s_decodeCompactMode
->
value
(
parser
->
value
(
QStringLiteral
(
"compact"
)),
Discover
Object
::
Full
));
QObject
::
connect
(
&
app
,
&
QCoreApplication
::
aboutToQuit
,
mainWindow
,
&
Discover
Object
::
deleteLater
);
QObject
::
connect
(
service
,
&
KDBusService
::
activateRequested
,
mainWindow
,
[
mainWindow
](
const
QStringList
&
arguments
,
const
QString
&
/*workingDirectory*/
){
if
(
!
mainWindow
->
rootObject
())
QCoreApplication
::
instance
()
->
quit
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment