Merge lp:~zeller-benjamin/qtcreator-plugin-ubuntu/bug-1387299 into lp:qtcreator-plugin-ubuntu

Proposed by Benjamin Zeller
Status: Merged
Approved by: Zoltan Balogh
Approved revision: 291
Merged at revision: 290
Proposed branch: lp:~zeller-benjamin/qtcreator-plugin-ubuntu/bug-1387299
Merge into: lp:qtcreator-plugin-ubuntu
Diff against target: 120 lines (+56/-20)
2 files modified
share/qtcreator/ubuntu/devicespage/NewEmulatorDialog.qml (+26/-6)
src/ubuntu/ubuntudevicesmodel.cpp (+30/-14)
To merge this branch: bzr merge lp:~zeller-benjamin/qtcreator-plugin-ubuntu/bug-1387299
Reviewer Review Type Date Requested Status
Zoltan Balogh Approve
PS Jenkins bot continuous-integration Approve
Review via email: mp+240234@code.launchpad.net

Commit message

- Fix bug lp:1387299 "Need to be able to create emulators for other image channels"
- Make the create emulator state not cancellable, it blocks the UI and does nothing

Description of the change

- Fix bug lp:1387299 "Need to be able to create emulators for other image channels"
- Make the create emulator state not cancellable, it blocks the UI and does nothing

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Zoltan Balogh (bzoltan) wrote :

OK

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'share/qtcreator/ubuntu/devicespage/NewEmulatorDialog.qml'
2--- share/qtcreator/ubuntu/devicespage/NewEmulatorDialog.qml 2014-07-28 09:25:34 +0000
3+++ share/qtcreator/ubuntu/devicespage/NewEmulatorDialog.qml 2014-10-31 10:18:20 +0000
4@@ -36,9 +36,26 @@
5
6 ListItem.ItemSelector {
7 id: channel
8- model: [i18n.tr("devel"),
9- i18n.tr("devel-proposed"),
10- i18n.tr("stable")]
11+ model: ["devel",
12+ "devel-proposed",
13+ "stable",
14+ "rtm-14.09",
15+ "rtm-14.09-proposed",
16+ "custom channel"]
17+ }
18+
19+ TextField {
20+ id: inputChannelName
21+ placeholderText: i18n.tr("Emulator channel")
22+ visible: channel.model[channel.selectedIndex] === "custom channel"
23+ }
24+
25+ Label {
26+ id: inputChannelNameError
27+ horizontalAlignment: Text.AlignHCenter
28+ text: "Channel name can not be empty"
29+ color: "red"
30+ visible: inputChannelName.visible && inputChannelName.text.length == 0
31 }
32
33 Button {
34@@ -49,11 +66,14 @@
35 Button {
36 text: "Create"
37 color: UbuntuColors.orange
38- enabled: !inputName.hasError
39+ enabled: !inputName.hasError && !inputChannelNameError.visible
40 onClicked: {
41- if(inputName.hasError)
42+ if(inputName.hasError || inputChannelNameError.visible)
43 return;
44- devicesModel.createEmulatorImage(inputName.text,arch.model[arch.selectedIndex],channel.model[channel.selectedIndex]);
45+ devicesModel.createEmulatorImage(inputName.text,
46+ arch.model[arch.selectedIndex],
47+ (inputChannelName.visible ? inputChannelName.text : channel.model[channel.selectedIndex])
48+ );
49 PopupUtils.close(dialogue);
50 }
51 }
52
53=== modified file 'src/ubuntu/ubuntudevicesmodel.cpp'
54--- src/ubuntu/ubuntudevicesmodel.cpp 2014-09-30 07:00:38 +0000
55+++ src/ubuntu/ubuntudevicesmodel.cpp 2014-10-31 10:18:20 +0000
56@@ -766,26 +766,42 @@
57 strEmulatorPath += QLatin1String(Constants::DEFAULT_EMULATOR_PATH);
58 strEmulatorPath += QDir::separator();
59 QString strUserName = QProcessEnvironment::systemEnvironment().value(QLatin1String("USER"));
60- QString strUserHome = QProcessEnvironment::systemEnvironment().value(QLatin1String("HOME"));
61+ QString strUserHome = QProcessEnvironment::systemEnvironment().value(QLatin1String("HOME"));
62 process->append(QStringList() << QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_LOCAL_CREATE_EMULATOR_SCRIPT)
63- .arg(QString::fromLatin1(Ubuntu::Constants::UBUNTU_SUDO_BINARY))
64- .arg(Ubuntu::Constants::UBUNTU_SCRIPTPATH)
65- .arg(strEmulatorPath)
66- .arg(strEmulatorName)
67- .arg(arch)
68- .arg(channel)
69- .arg(strUserName)
70- .arg(strUserHome)
71- << QCoreApplication::applicationDirPath());
72+ .arg(QString::fromLatin1(Ubuntu::Constants::UBUNTU_SUDO_BINARY))
73+ .arg(Ubuntu::Constants::UBUNTU_SCRIPTPATH)
74+ .arg(strEmulatorPath)
75+ .arg(strEmulatorName)
76+ .arg(arch)
77+ .arg(channel)
78+ .arg(strUserName)
79+ .arg(strUserHome)
80+ << QCoreApplication::applicationDirPath());
81 process->start(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_LOCAL_CREATE_EMULATOR));
82 }
83
84 void UbuntuDevicesModel::createEmulatorImage(const QString &name, const QString &arch, const QString &channel)
85 {
86+ QString ch = channel;
87+
88+ //to work around a problem in the UITK that clips long text in dropdown menus we use short aliases in the UI
89+ //for some channels. Here they are resolved to the correct channel names.
90+ QMap<QString,QString> channelAliasMap = {
91+ {QStringLiteral("rtm-14.09"),QStringLiteral("ubuntu-touch/ubuntu-rtm/14.09")},
92+ {QStringLiteral("rtm-14.09-proposed"),QStringLiteral("ubuntu-touch/ubuntu-rtm/14.09-proposed")}
93+ };
94+
95+ if(channelAliasMap.contains(ch))
96+ ch = channelAliasMap[ch];
97+
98 setState(CreateEmulatorImage);
99- setCancellable(true);
100+
101+ //@BUG this should be cancellable but the QProcess::kill call just blocks for a long time, and then returns
102+ // with the process still running. Most likely because the subprocess is executed with pkexec and has
103+ // elevated priviledges
104+ setCancellable(false);
105 beginAction(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_LOCAL_CREATE_EMULATOR));
106- doCreateEmulatorImage(m_process,name,arch,channel);
107+ doCreateEmulatorImage(m_process,name,arch,ch);
108 }
109
110 void UbuntuDevicesModel::queryAdb()
111@@ -827,8 +843,8 @@
112
113 QStringList args = QStringList() << name;
114 if(QProcess::startDetached(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_LOCAL_STOP_EMULATOR_SCRIPT).arg(Ubuntu::Constants::UBUNTU_SCRIPTPATH)
115- ,args
116- ,QCoreApplication::applicationDirPath())) {
117+ ,args
118+ ,QCoreApplication::applicationDirPath())) {
119 }
120 }
121

Subscribers

People subscribed via source and target branches