forked from qt-creator/qt-creator
S60: Provide a message box prompting to start TRK
... with cancel, similar to the Bluetooth connect box. Reviewed-by: Robert Loehning <robert.loehning@nokia.com>
This commit is contained in:
@@ -50,6 +50,9 @@
|
||||
|
||||
#include <debugger/debuggermanager.h>
|
||||
|
||||
#include <QtGui/QMessageBox>
|
||||
#include <QtGui/QMainWindow>
|
||||
|
||||
using namespace ProjectExplorer;
|
||||
using namespace Qt4ProjectManager::Internal;
|
||||
|
||||
@@ -446,6 +449,11 @@ S60DeviceRunControlBase::~S60DeviceRunControlBase()
|
||||
void S60DeviceRunControlBase::start()
|
||||
{
|
||||
emit started();
|
||||
if (m_serialPortName.isEmpty()) {
|
||||
error(this, tr("There is no device plugged in."));
|
||||
emit finished();
|
||||
return;
|
||||
}
|
||||
|
||||
emit addToOutputWindow(this, tr("Creating %1.sisx ...").arg(QDir::toNativeSeparators(m_baseFileName)));
|
||||
emit addToOutputWindow(this, tr("Executable file: %1").arg(m_executableFileName));
|
||||
@@ -472,10 +480,23 @@ void S60DeviceRunControlBase::start()
|
||||
m_makesis->start(m_makesisTool, QStringList(m_packageFile), QIODevice::ReadOnly);
|
||||
}
|
||||
|
||||
static inline void stopProcess(QProcess *p)
|
||||
{
|
||||
const int timeOutMS = 200;
|
||||
if (p->state() != QProcess::Running)
|
||||
return;
|
||||
p->terminate();
|
||||
if (p->waitForFinished(timeOutMS))
|
||||
return;
|
||||
p->kill();
|
||||
}
|
||||
|
||||
void S60DeviceRunControlBase::stop()
|
||||
{
|
||||
m_makesis->kill();
|
||||
m_signsis->kill();
|
||||
if (m_makesis)
|
||||
stopProcess(m_makesis);
|
||||
if (m_signsis)
|
||||
stopProcess(m_signsis);
|
||||
if (m_launcher)
|
||||
m_launcher->terminate();
|
||||
}
|
||||
@@ -529,6 +550,7 @@ void S60DeviceRunControlBase::makesisProcessFinished()
|
||||
{
|
||||
if (m_makesis->exitCode() != 0) {
|
||||
error(this, tr("An error occurred while creating the package."));
|
||||
stop();
|
||||
emit finished();
|
||||
return;
|
||||
}
|
||||
@@ -557,6 +579,7 @@ void S60DeviceRunControlBase::signsisProcessFinished()
|
||||
{
|
||||
if (m_signsis->exitCode() != 0) {
|
||||
error(this, tr("An error occurred while creating the package."));
|
||||
stop();
|
||||
emit finished();
|
||||
return;
|
||||
}
|
||||
@@ -570,6 +593,7 @@ void S60DeviceRunControlBase::signsisProcessFinished()
|
||||
connect(m_launcher, SIGNAL(installingStarted()), this, SLOT(printInstallingNotice()));
|
||||
connect(m_launcher, SIGNAL(canNotInstall(QString,QString)), this, SLOT(printInstallFailed(QString,QString)));
|
||||
connect(m_launcher, SIGNAL(copyProgress(int)), this, SLOT(printCopyProgress(int)));
|
||||
connect(m_launcher, SIGNAL(stateChanged(int)), this, SLOT(slotLauncherStateChanged(int)));
|
||||
|
||||
//TODO sisx destination and file path user definable
|
||||
m_launcher->setTrkServerName(m_serialPortName);
|
||||
@@ -593,18 +617,17 @@ void S60DeviceRunControlBase::signsisProcessFinished()
|
||||
break;
|
||||
case trk::PromptStartCommunicationCanceled:
|
||||
case trk::PromptStartCommunicationError:
|
||||
delete m_launcher;
|
||||
m_launcher = 0;
|
||||
error(this, errorMessage);
|
||||
stop();
|
||||
emit finished();
|
||||
return;
|
||||
};
|
||||
|
||||
if (!m_launcher->startServer(&errorMessage)) {
|
||||
delete m_launcher;
|
||||
m_launcher = 0;
|
||||
|
||||
error(this, tr("Could not connect to phone on port '%1': %2\n"
|
||||
"Check if the phone is connected and the TRK application is running.").arg(m_serialPortName, errorMessage));
|
||||
stop();
|
||||
emit finished();
|
||||
}
|
||||
}
|
||||
@@ -657,6 +680,37 @@ void S60DeviceRunControlBase::launcherFinished()
|
||||
handleLauncherFinished();
|
||||
}
|
||||
|
||||
QMessageBox *S60DeviceRunControlBase::createTrkWaitingMessageBox(const QString &port, QWidget *parent)
|
||||
{
|
||||
const QString title = QCoreApplication::translate("Qt4ProjectManager::Internal::S60DeviceRunControlBase",
|
||||
"Waiting for TRK");
|
||||
const QString text = QCoreApplication::translate("Qt4ProjectManager::Internal::S60DeviceRunControlBase",
|
||||
"Please start TRK on %1.").arg(port);
|
||||
QMessageBox *rc = new QMessageBox(QMessageBox::Information, title, text,
|
||||
QMessageBox::Cancel, parent);
|
||||
return rc;
|
||||
}
|
||||
|
||||
void S60DeviceRunControlBase::slotLauncherStateChanged(int s)
|
||||
{
|
||||
if (s == trk::Launcher::WaitingForTrk) {
|
||||
QMessageBox *mb = S60DeviceRunControlBase::createTrkWaitingMessageBox(m_launcher->trkServerName(),
|
||||
Core::ICore::instance()->mainWindow());
|
||||
connect(m_launcher, SIGNAL(stateChanged(int)), mb, SLOT(close()));
|
||||
connect(mb, SIGNAL(finished(int)), this, SLOT(slotWaitingForTrkClosed()));
|
||||
mb->open();
|
||||
}
|
||||
}
|
||||
|
||||
void S60DeviceRunControlBase::slotWaitingForTrkClosed()
|
||||
{
|
||||
if (m_launcher && m_launcher->state() == trk::Launcher::WaitingForTrk) {
|
||||
stop();
|
||||
error(this, tr("Canceled."));
|
||||
emit finished();
|
||||
}
|
||||
}
|
||||
|
||||
void S60DeviceRunControlBase::processFailed(const QString &program, QProcess::ProcessError errorCode)
|
||||
{
|
||||
QString errorString;
|
||||
@@ -671,6 +725,7 @@ void S60DeviceRunControlBase::processFailed(const QString &program, QProcess::Pr
|
||||
errorString = tr("An error has occurred while running %1.");
|
||||
}
|
||||
error(this, errorString.arg(program));
|
||||
stop();
|
||||
emit finished();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user