~ubuntu-branches/ubuntu/vivid/qtcreator-plugin-ubuntu/vivid

« back to all changes in this revision

Viewing changes to src/ubuntu/ubuntuclickdialog.cpp

  • Committer: Package Import Robot
  • Author(s): Ubuntu daily release, Benjamin Zeller
  • Date: 2015-02-06 10:29:23 UTC
  • mfrom: (1.1.85)
  • Revision ID: package-import@ubuntu.com-20150206102923-0lltths0etpn9x3o
Tags: 3.1.1+15.04.20150206-0ubuntu1
[ Benjamin Zeller ]
Add support to run more than one click maintenance task in the
chroot dialog.So updating multiple chroots is not asking back for
every single chroot.

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
#include <QPushButton>
26
26
 
27
27
#include <projectexplorer/projectexplorer.h>
28
 
#include <projectexplorer/processparameters.h>
29
28
#include <projectexplorer/toolchainmanager.h>
30
29
#include <texteditor/fontsettings.h>
31
30
 
57
56
    delete m_ui;
58
57
}
59
58
 
60
 
void UbuntuClickDialog::setParameters(ProjectExplorer::ProcessParameters *params)
 
59
void UbuntuClickDialog::setParameters(const QList<ProjectExplorer::ProcessParameters> &params)
61
60
{
62
 
    params->resolveAll();
63
 
    m_process->setCommand(params->command(),params->arguments());
64
 
    m_process->setEnvironment(params->environment());
65
 
    m_process->setWorkingDirectory(params->workingDirectory());
 
61
    m_tasks = params;
66
62
}
67
63
 
68
64
int UbuntuClickDialog::lastExitCode() const
78
74
    m_buttonBox->addButton(QDialogButtonBox::Cancel);
79
75
#endif
80
76
    disableCloseButton(true);
81
 
    m_process->start();
82
 
}
83
 
 
84
 
int UbuntuClickDialog::runClickModal(ProjectExplorer::ProcessParameters *params, QWidget *parent)
 
77
    nextTask();
 
78
}
 
79
 
 
80
int UbuntuClickDialog::runClickModal(const ProjectExplorer::ProcessParameters &params, QWidget *parent)
 
81
{
 
82
    return runClickModal(QList<ProjectExplorer::ProcessParameters>()<<params,parent);
 
83
}
 
84
 
 
85
int UbuntuClickDialog::runClickModal(const QList<ProjectExplorer::ProcessParameters> &params, QWidget *parent)
85
86
{
86
87
    UbuntuClickDialog dlg( parent ? parent : Core::ICore::mainWindow());
87
88
    dlg.setParameters(params);
101
102
    ProjectExplorer::ProcessParameters params;
102
103
    UbuntuClickTool::parametersForCreateChroot(t,&params);
103
104
 
104
 
    bool success = (runClickModal(&params,parent) == 0);
 
105
    bool success = (runClickModal(params,parent) == 0);
105
106
 
106
107
    if(success) {
107
108
        ClickToolChain* tc = new ClickToolChain(t, ProjectExplorer::ToolChain::AutoDetection);
116
117
 
117
118
int UbuntuClickDialog::maintainClickModal(const UbuntuClickTool::Target &target, const UbuntuClickTool::MaintainMode &mode)
118
119
{
119
 
    if(mode == UbuntuClickTool::Delete) {
120
 
        QString title = tr(Constants::UBUNTU_CLICK_DELETE_TITLE);
121
 
        QString text  = tr(Constants::UBUNTU_CLICK_DELETE_MESSAGE);
122
 
        if( QMessageBox::question(Core::ICore::mainWindow(),title,text) != QMessageBox::Yes )
123
 
            return 0;
124
 
 
125
 
        if(UbuntuClickTool::clickChrootSuffix() == QLatin1String(Constants::UBUNTU_CLICK_CHROOT_DEFAULT_NAME)) {
126
 
            ComUbuntuSdkClickChrootAgentInterface clickAgent(QStringLiteral("com.ubuntu.sdk.ClickChrootAgent"),
127
 
                                                             QStringLiteral("/com/ubuntu/sdk/ClickChrootAgent"),
128
 
                                                             QDBusConnection::sessionBus());
129
 
            if(clickAgent.isValid()) {
130
 
                QDBusPendingReply<bool> ret = clickAgent.releaseSession(target.framework,target.architecture);
131
 
                if(ret.isError())
132
 
                    qDebug()<<ret.error();
133
 
 
134
 
                ret.waitForFinished();
 
120
    return maintainClickModal(QList<UbuntuClickTool::Target>()<<target,mode);
 
121
}
 
122
 
 
123
int UbuntuClickDialog::maintainClickModal(const QList<UbuntuClickTool::Target> &targetList, const UbuntuClickTool::MaintainMode &mode)
 
124
{
 
125
    QList<ProjectExplorer::ProcessParameters> paramList;
 
126
    foreach(const UbuntuClickTool::Target &target, targetList) {
 
127
        if(mode == UbuntuClickTool::Delete) {
 
128
            QString title = tr(Constants::UBUNTU_CLICK_DELETE_TITLE);
 
129
            QString text  = tr(Constants::UBUNTU_CLICK_DELETE_MESSAGE);
 
130
            if( QMessageBox::question(Core::ICore::mainWindow(),title,text) != QMessageBox::Yes )
 
131
                return 0;
 
132
 
 
133
            if(UbuntuClickTool::clickChrootSuffix() == QLatin1String(Constants::UBUNTU_CLICK_CHROOT_DEFAULT_NAME)) {
 
134
                ComUbuntuSdkClickChrootAgentInterface clickAgent(QStringLiteral("com.ubuntu.sdk.ClickChrootAgent"),
 
135
                                                                 QStringLiteral("/com/ubuntu/sdk/ClickChrootAgent"),
 
136
                                                                 QDBusConnection::sessionBus());
 
137
                if(clickAgent.isValid()) {
 
138
                    QDBusPendingReply<bool> ret = clickAgent.releaseSession(target.framework,target.architecture);
 
139
                    if(ret.isError())
 
140
                        qDebug()<<ret.error();
 
141
 
 
142
                    ret.waitForFinished();
 
143
                }
135
144
            }
136
145
        }
 
146
 
 
147
        ProjectExplorer::ProcessParameters params;
 
148
        UbuntuClickTool::parametersForMaintainChroot(mode,target,&params);
 
149
        paramList<<params;
137
150
    }
138
151
 
139
 
    ProjectExplorer::ProcessParameters params;
140
 
    UbuntuClickTool::parametersForMaintainChroot(mode,target,&params);
141
 
    return runClickModal(&params);
 
152
    return runClickModal(paramList);
142
153
}
143
154
 
144
155
void UbuntuClickDialog::done(int code)
169
180
    if(bt) bt->setDisabled(disabled);
170
181
}
171
182
 
 
183
void UbuntuClickDialog::nextTask()
 
184
{
 
185
    if(m_tasks.length() <= 0)
 
186
        return;
 
187
 
 
188
    ProjectExplorer::ProcessParameters params = m_tasks.takeFirst();
 
189
    params.resolveAll();
 
190
    m_process->setCommand(params.command(),params.arguments());
 
191
    m_process->setEnvironment(params.environment());
 
192
    m_process->setWorkingDirectory(params.workingDirectory());
 
193
    m_process->start();
 
194
}
 
195
 
172
196
void UbuntuClickDialog::on_clickFinished(int exitCode)
173
197
{
174
 
    disableCloseButton(false);
175
 
#if 0
176
 
    //set the button to close again
177
 
    m_buttonBox->clear();
178
 
    m_buttonBox->addButton(QDialogButtonBox::Close);
179
 
#endif
180
 
 
181
198
    if (exitCode != 0) {
182
199
        on_clickReadyReadStandardError(tr("---%0---").arg(QLatin1String(Constants::UBUNTU_CLICK_ERROR_EXIT_MESSAGE)));
183
200
    } else {
184
201
        on_clickReadyReadStandardOutput(tr("---%0---").arg(QLatin1String(Constants::UBUNTU_CLICK_SUCCESS_EXIT_MESSAGE)));
185
202
    }
186
203
 
 
204
    if(m_tasks.length() > 0) {
 
205
        nextTask();
 
206
        return;
 
207
    }
 
208
 
 
209
    disableCloseButton(false);
 
210
#if 0
 
211
    //set the button to close again
 
212
    m_buttonBox->clear();
 
213
    m_buttonBox->addButton(QDialogButtonBox::Close);
 
214
#endif
 
215
 
187
216
    m_exitCode = exitCode;
188
217
}
189
218