on xenial help sign in
shellapp->unityapp
9a5c01fNick Dedekind
src/CMakeLists.txt+8−2
@@ -28,7 +28,7 @@ set(SOURCE_FILES
28 ApplicationArguments.cpp
28 ApplicationArguments.cpp
29 main.cpp
29 main.cpp
30 CachingNetworkManagerFactory.cpp
30 CachingNetworkManagerFactory.cpp
31− ShellApplication.cpp
31+ UnityApplication.cpp
32 UnityCommandLineParser.cpp
32 UnityCommandLineParser.cpp
33 UnixSignalHandler.cpp
33 UnixSignalHandler.cpp
34 DebuggingController.cpp
34 DebuggingController.cpp
@@ -46,7 +46,13 @@ qt5_use_modules(${SHELL_APP} DBus Gui Qml Quick Test)
46if (NOT "${ANDROID_PROPERTIES_INCLUDE_DIRS}" STREQUAL "")
46if (NOT "${ANDROID_PROPERTIES_INCLUDE_DIRS}" STREQUAL "")
47 set_target_properties(${SHELL_APP} PROPERTIES INCLUDE_DIRECTORIES ${ANDROID_PROPERTIES_INCLUDE_DIRS})
47 set_target_properties(${SHELL_APP} PROPERTIES INCLUDE_DIRECTORIES ${ANDROID_PROPERTIES_INCLUDE_DIRS})
48endif()
48endif()
49−target_link_libraries(${SHELL_APP} ${ANDROID_PROPERTIES_LDFLAGS} UbuntuGestures connectivity-qt1 unity8-private qtmirserver)
49+target_link_libraries(${SHELL_APP}
50+ ${ANDROID_PROPERTIES_LDFLAGS}
51+ ${QTMIRSERVER_LDFLAGS}
52+ UbuntuGestures
53+ connectivity-qt1
54+ unity8-private
55+)
50
56
51if (ENABLE_TOUCH_EMULATION)
57if (ENABLE_TOUCH_EMULATION)
52 target_link_libraries(${SHELL_APP} ${MOUSETOUCHADAPTOR_LIBS_LDFLAGS})
58 target_link_libraries(${SHELL_APP} ${MOUSETOUCHADAPTOR_LIBS_LDFLAGS})
src/ShellApplication.cpp → src/UnityApplication.cpprenamed+9−29
@@ -14,7 +14,7 @@
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
15 */
16
16
17−#include "ShellApplication.h"
17+#include "UnityApplication.h"
18
18
19// Qt
19// Qt
20#include <QLibrary>
20#include <QLibrary>
@@ -32,34 +32,14 @@
32#include "CachingNetworkManagerFactory.h"
32#include "CachingNetworkManagerFactory.h"
33#include "UnityCommandLineParser.h"
33#include "UnityCommandLineParser.h"
34#include "DebuggingController.h"
34#include "DebuggingController.h"
35+#include "windowmanagementpolicy.h"
35
36
36#include <QDebug>
37#include <QDebug>
37
38
38−#include <qtmir/windowmanagementpolicy.h>
39
39
40−class WindowManagementPolicy : public qtmir::WindowManagementPolicy
40+
41−{
41+UnityApplication::UnityApplication(int & argc, char ** argv)
42−public:
43− WindowManagementPolicy(const miral::WindowManagerTools &tools, qtmir::WindowManagementPolicyPrivate& dd)
44− : qtmir::WindowManagementPolicy(tools, dd)
45− {}
46−
47−// virtual void advise_adding_to_workspace(
48−// std::shared_ptr<miral::Workspace> const& workspace,
49−// std::vector<miral::Window> const& windows) override
50−// {
51−// }
52−
53−// virtual void advise_removing_from_workspace(
54−// std::shared_ptr<miral::Workspace> const& workspace,
55−// std::vector<miral::Window> const& windows) override
56−// {
57−// }
58−};
59−
60−
61−ShellApplication::ShellApplication(int & argc, char ** argv)
62− : qtmir::MirServerApplication(argc, argv, {})
42+ : qtmir::MirServerApplication(argc, argv, { qtmir::SetWindowManagementPolicy<WindowManagementPolicy>() })
63 , m_qmlArgs(this)
43 , m_qmlArgs(this)
64{
44{
65 setApplicationName(QStringLiteral("unity8"));
45 setApplicationName(QStringLiteral("unity8"));
@@ -103,7 +83,7 @@ ShellApplication::ShellApplication(int & argc, char ** argv)
103 pxpgu = 8;
83 pxpgu = 8;
104 }
84 }
105 m_qmlEngine->rootContext()->setContextProperty("internalGu", pxpgu);
85 m_qmlEngine->rootContext()->setContextProperty("internalGu", pxpgu);
106− m_qmlEngine->load(::qmlDirectory() + "/ShellApplication.qml");
86+ m_qmlEngine->load(m_qmlArgs.qmlfie());
107
87
108 #ifdef UNITY8_ENABLE_TOUCH_EMULATION
88 #ifdef UNITY8_ENABLE_TOUCH_EMULATION
109 // You will need this if you want to interact with touch-only components using a mouse
89 // You will need this if you want to interact with touch-only components using a mouse
@@ -120,12 +100,12 @@ ShellApplication::ShellApplication(int & argc, char ** argv)
120 }
100 }
121}
101}
122
102
123−ShellApplication::~ShellApplication()
103+UnityApplication::~UnityApplication()
124{
104{
125 destroyResources();
105 destroyResources();
126}
106}
127
107
128−void ShellApplication::destroyResources()
108+void UnityApplication::destroyResources()
129{
109{
130 #ifdef UNITY8_ENABLE_TOUCH_EMULATION
110 #ifdef UNITY8_ENABLE_TOUCH_EMULATION
131 delete m_mouseTouchAdaptor;
111 delete m_mouseTouchAdaptor;
@@ -136,7 +116,7 @@ void ShellApplication::destroyResources()
136 m_qmlEngine = nullptr;
116 m_qmlEngine = nullptr;
137}
117}
138
118
139−void ShellApplication::setupQmlEngine()
119+void UnityApplication::setupQmlEngine()
140{
120{
141 m_qmlEngine = new QQmlApplicationEngine(this);
121 m_qmlEngine = new QQmlApplicationEngine(this);
142
122
src/ShellApplication.h → src/UnityApplication.hrenamed+6−6
@@ -14,8 +14,8 @@
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
15 */
16
16
17−#ifndef SHELLAPPLICATION_H
17+#ifndef UNITYAPPLICATION_H
18−#define SHELLAPPLICATION_H
18+#define UNITYAPPLICATION_H
19
19
20#include <QGuiApplication>
20#include <QGuiApplication>
21#include <QQmlApplicationEngine>
21#include <QQmlApplicationEngine>
@@ -30,12 +30,12 @@
30
30
31#include <qtmir/mirserverapplication.h>
31#include <qtmir/mirserverapplication.h>
32
32
33−class ShellApplication : public qtmir::MirServerApplication
33+class UnityApplication : public qtmir::MirServerApplication
34{
34{
35 Q_OBJECT
35 Q_OBJECT
36public:
36public:
37− ShellApplication(int & argc, char ** argv);
37+ UnityApplication(int & argc, char ** argv);
38− virtual ~ShellApplication();
38+ virtual ~UnityApplication();
39
39
40 void destroyResources();
40 void destroyResources();
41
41
@@ -50,4 +50,4 @@ private:
50 QQmlApplicationEngine *m_qmlEngine{nullptr};
50 QQmlApplicationEngine *m_qmlEngine{nullptr};
51};
51};
52
52
53−#endif // SHELLAPPLICATION_H
53+#endif // UNITYAPPLICATION_H
src/UnityCommandLineParser.cpp+8
@@ -15,6 +15,7 @@
15 */
15 */
16
16
17#include "UnityCommandLineParser.h"
17#include "UnityCommandLineParser.h"
18+#include <paths.h>
18
19
19#include <QDebug>
20#include <QDebug>
20
21
@@ -60,6 +61,11 @@ UnityCommandLineParser::UnityCommandLineParser(const QCoreApplication &app)
60 QStringLiteral("mode"), QStringLiteral("full-greeter"));
61 QStringLiteral("mode"), QStringLiteral("full-greeter"));
61 parser.addOption(modeOption);
62 parser.addOption(modeOption);
62
63
64+ QCommandLineOption qmlfileOption(QStringLiteral("qmlfile"),
65+ QStringLiteral("The base qml file to load"),
66+ QStringLiteral("qmlfile"), ::qmlDirectory() + "/ShellApplication.qml");
67+ parser.addOption(qmlfileOption);
68+
63 // Treat args with single dashes the same as arguments with two dashes
69 // Treat args with single dashes the same as arguments with two dashes
64 // Ex: -fullscreen == --fullscreen
70 // Ex: -fullscreen == --fullscreen
65 parser.setSingleDashWordOptionMode(QCommandLineParser::ParseAsLongOptions);
71 parser.setSingleDashWordOptionMode(QCommandLineParser::ParseAsLongOptions);
@@ -85,6 +91,8 @@ UnityCommandLineParser::UnityCommandLineParser(const QCoreApplication &app)
85 m_hasFullscreen = parser.isSet(fullscreenOption);
91 m_hasFullscreen = parser.isSet(fullscreenOption);
86 m_deviceName = parser.value(devicenameOption);
92 m_deviceName = parser.value(devicenameOption);
87 resolveMode(parser, modeOption);
93 resolveMode(parser, modeOption);
94+
95+ m_qmlfile = parser.value(qmlfileOption);
88}
96}
89
97
90int UnityCommandLineParser::parsePixelsValue(const QString &str)
98int UnityCommandLineParser::parsePixelsValue(const QString &str)
src/UnityCommandLineParser.h+3
@@ -37,6 +37,8 @@ public:
37 QString deviceName() const { return m_deviceName; }
37 QString deviceName() const { return m_deviceName; }
38 QString mode() const { return m_mode; }
38 QString mode() const { return m_mode; }
39
39
40+ QString qmlfie() const { return m_qmlfile; }
41+
40protected:
42protected:
41 int parsePixelsValue(const QString &str);
43 int parsePixelsValue(const QString &str);
42 static float getenvFloat(const char* name, float defaultValue);
44 static float getenvFloat(const char* name, float defaultValue);
@@ -55,6 +57,7 @@ protected:
55 bool m_hasFullscreen;
57 bool m_hasFullscreen;
56 QString m_deviceName;
58 QString m_deviceName;
57 QString m_mode;
59 QString m_mode;
60+ QString m_qmlfile;
58};
61};
59
62
60#endif // UNITY_COMMAND_LINE_PARSER_H
63#endif // UNITY_COMMAND_LINE_PARSER_H
src/main.cpp+4−2
@@ -15,9 +15,10 @@
15 */
15 */
16
16
17// local
17// local
18−#include "ShellApplication.h"
18+#include "UnityApplication.h"
19#include "qmldebuggerutils.h"
19#include "qmldebuggerutils.h"
20#include "UnixSignalHandler.h"
20#include "UnixSignalHandler.h"
21+#include <paths.h>
21
22
22#include <QTranslator>
23#include <QTranslator>
23#include <QLibraryInfo>
24#include <QLibraryInfo>
@@ -31,7 +32,8 @@ int main(int argc, const char *argv[])
31 QQmlDebuggingEnabler qQmlEnableDebuggingHelper(true);
32 QQmlDebuggingEnabler qQmlEnableDebuggingHelper(true);
32 }
33 }
33
34
34− ShellApplication *application = new ShellApplication(argc, (char**)argv);
35+ auto *application = new UnityApplication(argc,
36+ (char**)argv);
35
37
36 UnixSignalHandler signalHandler([]{
38 UnixSignalHandler signalHandler([]{
37 QGuiApplication::exit(0);
39 QGuiApplication::exit(0);