From cd5492eb14f28df8450cac4911e8283a14b68a22 Mon Sep 17 00:00:00 2001 From: Pawel Polanski <pawel.3.polanski@nokia.com> Date: Fri, 13 Aug 2010 08:48:02 +0200 Subject: [PATCH] Progress bar for Launching for S60 sequence has been changed to behave like for other targets Reviewed-by: Tobias Hunger --- .../qt-s60/s60devicerunconfiguration.cpp | 80 ++++++++++--------- .../qt-s60/s60devicerunconfiguration.h | 11 ++- 2 files changed, 51 insertions(+), 40 deletions(-) diff --git a/src/plugins/qt4projectmanager/qt-s60/s60devicerunconfiguration.cpp b/src/plugins/qt4projectmanager/qt-s60/s60devicerunconfiguration.cpp index c839fbe7bd4..6d8ebf49ee4 100644 --- a/src/plugins/qt4projectmanager/qt-s60/s60devicerunconfiguration.cpp +++ b/src/plugins/qt4projectmanager/qt-s60/s60devicerunconfiguration.cpp @@ -660,38 +660,10 @@ bool S60DeviceRunControlBase::isRunning() const void S60DeviceRunControlBase::startLaunching() { QString errorMessage; - bool success = false; - do { - connect(SymbianUtils::SymbianDeviceManager::instance(), SIGNAL(deviceRemoved(const SymbianUtils::SymbianDevice)), - this, SLOT(deviceRemoved(SymbianUtils::SymbianDevice))); - m_launcher = trk::Launcher::acquireFromDeviceManager(m_serialPortName, 0, &errorMessage); - if (!m_launcher) - break; - - connect(m_launcher, SIGNAL(finished()), this, SLOT(launcherFinished())); - connect(m_launcher, SIGNAL(canNotConnect(QString)), this, SLOT(printConnectFailed(QString))); - connect(m_launcher, SIGNAL(stateChanged(int)), this, SLOT(slotLauncherStateChanged(int))); - connect(m_launcher, SIGNAL(processStopped(uint,uint,uint,QString)), - this, SLOT(processStopped(uint,uint,uint,QString))); - - if (!m_commandLineArguments.isEmpty()) - m_launcher->setCommandLineArgs(m_commandLineArguments); - const QString runFileName = QString::fromLatin1("%1:\\sys\\bin\\%2.exe").arg(m_installationDrive).arg(m_targetName); - initLauncher(runFileName, m_launcher); - const trk::PromptStartCommunicationResult src = - S60RunConfigBluetoothStarter::startCommunication(m_launcher->trkDevice(), - 0, &errorMessage); - if (src != trk::PromptStartCommunicationConnected) - break; - if (!m_launcher->startServer(&errorMessage)) { - errorMessage = tr("Could not connect to phone on port '%1': %2\n" - "Check if the phone is connected and App TRK is running.").arg(m_serialPortName, errorMessage); - break; - } - success = true; - } while (false); - - if (!success) { + if (setupLauncher(errorMessage)) { + if (m_deployProgress) + m_deployProgress->setProgressValue(PROGRESS_MAX/2); + } else { if (!errorMessage.isEmpty()) appendMessage(this, errorMessage, true); stop(); @@ -699,6 +671,39 @@ void S60DeviceRunControlBase::startLaunching() } } +bool S60DeviceRunControlBase::setupLauncher(QString &errorMessage) +{ + connect(SymbianUtils::SymbianDeviceManager::instance(), SIGNAL(deviceRemoved(const SymbianUtils::SymbianDevice)), + this, SLOT(deviceRemoved(SymbianUtils::SymbianDevice))); + m_launcher = trk::Launcher::acquireFromDeviceManager(m_serialPortName, 0, &errorMessage); + if (!m_launcher) + return false; + + connect(m_launcher, SIGNAL(finished()), this, SLOT(launcherFinished())); + connect(m_launcher, SIGNAL(canNotConnect(QString)), this, SLOT(printConnectFailed(QString))); + connect(m_launcher, SIGNAL(stateChanged(int)), this, SLOT(slotLauncherStateChanged(int))); + connect(m_launcher, SIGNAL(processStopped(uint,uint,uint,QString)), + this, SLOT(processStopped(uint,uint,uint,QString))); + + if (!m_commandLineArguments.isEmpty()) + m_launcher->setCommandLineArgs(m_commandLineArguments); + + const QString runFileName = QString::fromLatin1("%1:\\sys\\bin\\%2.exe").arg(m_installationDrive).arg(m_targetName); + initLauncher(runFileName, m_launcher); + const trk::PromptStartCommunicationResult src = + S60RunConfigBluetoothStarter::startCommunication(m_launcher->trkDevice(), + 0, &errorMessage); + if (src != trk::PromptStartCommunicationConnected) + return false; + + if (!m_launcher->startServer(&errorMessage)) { + errorMessage = tr("Could not connect to phone on port '%1': %2\n" + "Check if the phone is connected and App TRK is running.").arg(m_serialPortName, errorMessage); + return false; + } + return true; +} + void S60DeviceRunControlBase::printConnectFailed(const QString &errorMessage) { emit appendMessage(this, tr("Could not connect to App TRK on device: %1. Restarting App TRK might help.").arg(errorMessage), true); @@ -799,8 +804,8 @@ S60DeviceRunControl::S60DeviceRunControl(ProjectExplorer::RunConfiguration *runC void S60DeviceRunControl::initLauncher(const QString &executable, trk::Launcher *launcher) { connect(launcher, SIGNAL(startingApplication()), this, SLOT(printStartingNotice())); - connect(launcher, SIGNAL(applicationRunning(uint)), this, SLOT(printRunNotice(uint))); - connect(launcher, SIGNAL(canNotRun(QString)), this, SLOT(printRunFailNotice(QString))); + connect(launcher, SIGNAL(applicationRunning(uint)), this, SLOT(applicationRunNotice(uint))); + connect(launcher, SIGNAL(canNotRun(QString)), this, SLOT(applicationRunFailedNotice(QString))); connect(launcher, SIGNAL(applicationOutputReceived(QString)), this, SLOT(printApplicationOutput(QString))); launcher->addStartupActions(trk::Launcher::ActionRun); launcher->setFileName(executable); @@ -817,12 +822,15 @@ void S60DeviceRunControl::printStartingNotice() emit appendMessage(this, tr("Starting application..."), false); } -void S60DeviceRunControl::printRunNotice(uint pid) +void S60DeviceRunControl::applicationRunNotice(uint pid) { emit appendMessage(this, tr("Application running with pid %1.").arg(pid), false); + if (m_deployProgress) + m_deployProgress->setProgressValue(PROGRESS_MAX); } -void S60DeviceRunControl::printRunFailNotice(const QString &errorMessage) { +void S60DeviceRunControl::applicationRunFailedNotice(const QString &errorMessage) +{ emit appendMessage(this, tr("Could not start application: %1").arg(errorMessage), true); } diff --git a/src/plugins/qt4projectmanager/qt-s60/s60devicerunconfiguration.h b/src/plugins/qt4projectmanager/qt-s60/s60devicerunconfiguration.h index 83e57633ce6..1080c952726 100644 --- a/src/plugins/qt4projectmanager/qt-s60/s60devicerunconfiguration.h +++ b/src/plugins/qt4projectmanager/qt-s60/s60devicerunconfiguration.h @@ -183,6 +183,7 @@ protected slots: void printApplicationOutput(const QString &output, bool onStdErr); void printApplicationOutput(const QString &output); void deviceRemoved(const SymbianUtils::SymbianDevice &); + void reportDeployFinished(); private slots: void processStopped(uint pc, uint pid, uint tid, const QString& reason); @@ -190,10 +191,13 @@ private slots: void launcherFinished(); void slotLauncherStateChanged(int); void slotWaitingForTrkClosed(); - void reportDeployFinished(); + +protected: + QFutureInterface<void> *m_deployProgress; private: void startLaunching(); + bool setupLauncher(QString &errorMessage); ProjectExplorer::ToolChain::ToolChainType m_toolChain; QString m_serialPortName; @@ -205,7 +209,6 @@ private: QString m_qtBinPath; bool m_releaseDeviceAfterLauncherFinish; bool m_handleDeviceRemoval; - QFutureInterface<void> *m_deployProgress; trk::Launcher *m_launcher; char m_installationDrive; }; @@ -223,8 +226,8 @@ protected: private slots: void printStartingNotice(); - void printRunNotice(uint pid); - void printRunFailNotice(const QString &errorMessage); + void applicationRunNotice(uint pid); + void applicationRunFailedNotice(const QString &errorMessage); private: }; -- GitLab