forked from qt-creator/qt-creator
Watch the runtime folders, so we can update the starter once added.
Reviewed-by: ck
This commit is contained in:
@@ -115,6 +115,13 @@ MaemoQemuManager::MaemoQemuManager(QObject *parent)
|
|||||||
SLOT(qemuOutput()));
|
SLOT(qemuOutput()));
|
||||||
connect(this, SIGNAL(qemuProcessStatus(QemuStatus, QString)),
|
connect(this, SIGNAL(qemuProcessStatus(QemuStatus, QString)),
|
||||||
this, SLOT(qemuStatusChanged(QemuStatus, QString)));
|
this, SLOT(qemuStatusChanged(QemuStatus, QString)));
|
||||||
|
|
||||||
|
m_runtimeRootWatcher = new QFileSystemWatcher(this);
|
||||||
|
connect(m_runtimeRootWatcher, SIGNAL(directoryChanged(QString)), this,
|
||||||
|
SLOT(runtimeRootChanged(QString)));
|
||||||
|
m_runtimeFolderWatcher = new QFileSystemWatcher(this);
|
||||||
|
connect(m_runtimeFolderWatcher, SIGNAL(directoryChanged(QString)), this,
|
||||||
|
SLOT(runtimeFolderChanged(QString)));
|
||||||
}
|
}
|
||||||
|
|
||||||
MaemoQemuManager::~MaemoQemuManager()
|
MaemoQemuManager::~MaemoQemuManager()
|
||||||
@@ -132,10 +139,8 @@ MaemoQemuManager &MaemoQemuManager::instance(QObject *parent)
|
|||||||
|
|
||||||
bool MaemoQemuManager::runtimeForQtVersion(int uniqueId, Runtime *rt) const
|
bool MaemoQemuManager::runtimeForQtVersion(int uniqueId, Runtime *rt) const
|
||||||
{
|
{
|
||||||
bool found = m_runtimes.contains(uniqueId);
|
*rt = m_runtimes.value(uniqueId, Runtime());
|
||||||
if (found)
|
return rt->isValid();
|
||||||
*rt = m_runtimes.value(uniqueId);
|
|
||||||
return found;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MaemoQemuManager::qtVersionsChanged(const QList<int> &uniqueIds)
|
void MaemoQemuManager::qtVersionsChanged(const QList<int> &uniqueIds)
|
||||||
@@ -146,16 +151,22 @@ void MaemoQemuManager::qtVersionsChanged(const QList<int> &uniqueIds)
|
|||||||
QtVersionManager *manager = QtVersionManager::instance();
|
QtVersionManager *manager = QtVersionManager::instance();
|
||||||
foreach (int uniqueId, uniqueIds) {
|
foreach (int uniqueId, uniqueIds) {
|
||||||
if (manager->isValidId(uniqueId)) {
|
if (manager->isValidId(uniqueId)) {
|
||||||
const QString &qmake = manager->version(uniqueId)->qmakeCommand();
|
QtVersion *version = manager->version(uniqueId);
|
||||||
|
if (version->supportsTargetId(Constants::MAEMO_DEVICE_TARGET_ID)) {
|
||||||
|
const QString &qmake = version->qmakeCommand();
|
||||||
const QString &runtimeRoot = runtimeForQtVersion(qmake);
|
const QString &runtimeRoot = runtimeForQtVersion(qmake);
|
||||||
if (runtimeRoot.isEmpty() || !QFile::exists(runtimeRoot)) {
|
if (!runtimeRoot.isEmpty()) {
|
||||||
// no runtime available, or runtime needs to be installed
|
|
||||||
m_runtimes.remove(uniqueId);
|
|
||||||
} else {
|
|
||||||
// valid maemo qt version, also has a runtime installed
|
|
||||||
Runtime runtime(runtimeRoot);
|
Runtime runtime(runtimeRoot);
|
||||||
|
if (QFile::exists(runtimeRoot))
|
||||||
fillRuntimeInformation(&runtime);
|
fillRuntimeInformation(&runtime);
|
||||||
|
runtime.m_watchPath =
|
||||||
|
runtimeRoot.left(runtimeRoot.lastIndexOf(QLatin1Char('/')));
|
||||||
m_runtimes.insert(uniqueId, runtime);
|
m_runtimes.insert(uniqueId, runtime);
|
||||||
|
if (!m_runtimeRootWatcher->directories().contains(runtime.m_watchPath))
|
||||||
|
m_runtimeRootWatcher->addPath(runtime.m_watchPath);
|
||||||
|
} else {
|
||||||
|
m_runtimes.remove(uniqueId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// this qt version has been removed from the settings
|
// this qt version has been removed from the settings
|
||||||
@@ -462,6 +473,49 @@ void MaemoQemuManager::qemuOutput()
|
|||||||
qDebug("%s", m_qemuProcess->readAllStandardError().data());
|
qDebug("%s", m_qemuProcess->readAllStandardError().data());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MaemoQemuManager::runtimeRootChanged(const QString &directory)
|
||||||
|
{
|
||||||
|
QList<int> uniqueIds;
|
||||||
|
QMap<int, Runtime>::const_iterator it;
|
||||||
|
for (it = m_runtimes.constBegin(); it != m_runtimes.constEnd(); ++it) {
|
||||||
|
if (QDir(it.value().m_watchPath) == QDir(directory))
|
||||||
|
uniqueIds.append(it.key());
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (int uniqueId, uniqueIds) {
|
||||||
|
Runtime runtime = m_runtimes.value(uniqueId, Runtime());
|
||||||
|
if (runtime.isValid()) {
|
||||||
|
if (QFile::exists(runtime.m_root)) {
|
||||||
|
// nothing changed, so we can remove it
|
||||||
|
uniqueIds.removeAll(uniqueId);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (QFile::exists(runtime.m_root)) {
|
||||||
|
if (!QFile::exists(runtime.m_root + QLatin1String("/information"))) {
|
||||||
|
// install might be still in progress
|
||||||
|
uniqueIds.removeAll(uniqueId);
|
||||||
|
m_runtimeFolderWatcher->addPath(runtime.m_root);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
notify(uniqueIds);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MaemoQemuManager::runtimeFolderChanged(const QString &directory)
|
||||||
|
{
|
||||||
|
if (QFile::exists(directory + QLatin1String("/information"))) {
|
||||||
|
QList<int> uniqueIds;
|
||||||
|
QMap<int, Runtime>::const_iterator it;
|
||||||
|
for (it = m_runtimes.constBegin(); it != m_runtimes.constEnd(); ++it) {
|
||||||
|
if (QDir(it.value().m_root) == QDir(directory))
|
||||||
|
uniqueIds.append(it.key());
|
||||||
|
}
|
||||||
|
notify(uniqueIds);
|
||||||
|
m_runtimeFolderWatcher->removePath(directory);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// -- private
|
// -- private
|
||||||
|
|
||||||
void MaemoQemuManager::setupRuntimes()
|
void MaemoQemuManager::setupRuntimes()
|
||||||
@@ -513,7 +567,7 @@ void MaemoQemuManager::toggleStarterButton(Target *target)
|
|||||||
if (m_runningQtId == uniqueId)
|
if (m_runningQtId == uniqueId)
|
||||||
isRunning = false;
|
isRunning = false;
|
||||||
|
|
||||||
m_qemuAction->setEnabled(m_runtimes.contains(uniqueId)
|
m_qemuAction->setEnabled(m_runtimes.value(uniqueId, Runtime()).isValid()
|
||||||
&& targetUsesMatchingRuntimeConfig(target) && !isRunning);
|
&& targetUsesMatchingRuntimeConfig(target) && !isRunning);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -542,7 +596,7 @@ bool MaemoQemuManager::targetUsesMatchingRuntimeConfig(Target *target,
|
|||||||
if (!bc)
|
if (!bc)
|
||||||
return false;
|
return false;
|
||||||
QtVersion *version = bc->qtVersion();
|
QtVersion *version = bc->qtVersion();
|
||||||
if (!version || !m_runtimes.contains(version->uniqueId()))
|
if (!version || !m_runtimes.value(version->uniqueId(), Runtime()).isValid())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (qtVersion)
|
if (qtVersion)
|
||||||
@@ -569,10 +623,9 @@ bool MaemoQemuManager::fillRuntimeInformation(Runtime *runtime) const
|
|||||||
const QStringList files = QDir(runtime->m_root).entryList(QDir::Files
|
const QStringList files = QDir(runtime->m_root).entryList(QDir::Files
|
||||||
| QDir::NoSymLinks | QDir::NoDotAndDotDot);
|
| QDir::NoSymLinks | QDir::NoDotAndDotDot);
|
||||||
|
|
||||||
|
// we need at least the information file
|
||||||
const QLatin1String infoFile("information");
|
const QLatin1String infoFile("information");
|
||||||
// we need at least the information file and a second one, most likely
|
if (files.contains(infoFile)) {
|
||||||
// the image file qemu is going to load
|
|
||||||
if (files.contains(infoFile) && files.count() > 1) {
|
|
||||||
QFile file(runtime->m_root + QLatin1Char('/') + infoFile);
|
QFile file(runtime->m_root + QLatin1Char('/') + infoFile);
|
||||||
if (file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
if (file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||||
QMap<QString, QString> map;
|
QMap<QString, QString> map;
|
||||||
@@ -627,8 +680,8 @@ QString MaemoQemuManager::runtimeForQtVersion(const QString &qmakeCommand) const
|
|||||||
if (line.startsWith(QLatin1String("runtime"))) {
|
if (line.startsWith(QLatin1String("runtime"))) {
|
||||||
const QStringList &list = line.split(QLatin1Char(' '));
|
const QStringList &list = line.split(QLatin1Char(' '));
|
||||||
if (list.count() > 1) {
|
if (list.count() > 1) {
|
||||||
return madRoot
|
return QDir::fromNativeSeparators(madRoot
|
||||||
+ QLatin1String("/runtimes/") + list.at(1).trimmed();
|
+ QLatin1String("/runtimes/") + list.at(1).trimmed());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -639,6 +692,12 @@ QString MaemoQemuManager::runtimeForQtVersion(const QString &qmakeCommand) const
|
|||||||
return QString();
|
return QString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MaemoQemuManager::notify(const QList<int> uniqueIds)
|
||||||
|
{
|
||||||
|
qtVersionsChanged(uniqueIds);
|
||||||
|
environmentChanged(); // to toggle the start button
|
||||||
|
}
|
||||||
|
|
||||||
void MaemoQemuManager::toggleDeviceConnections(MaemoRunConfiguration *mrc,
|
void MaemoQemuManager::toggleDeviceConnections(MaemoRunConfiguration *mrc,
|
||||||
bool _connect)
|
bool _connect)
|
||||||
{
|
{
|
||||||
|
@@ -40,6 +40,7 @@
|
|||||||
#include <QtGui/QIcon>
|
#include <QtGui/QIcon>
|
||||||
|
|
||||||
QT_FORWARD_DECLARE_CLASS(QAction);
|
QT_FORWARD_DECLARE_CLASS(QAction);
|
||||||
|
QT_FORWARD_DECLARE_CLASS(QFileSystemWatcher)
|
||||||
QT_FORWARD_DECLARE_CLASS(QStringList);
|
QT_FORWARD_DECLARE_CLASS(QStringList);
|
||||||
|
|
||||||
namespace ProjectExplorer {
|
namespace ProjectExplorer {
|
||||||
@@ -59,12 +60,16 @@ struct Runtime
|
|||||||
Runtime() {}
|
Runtime() {}
|
||||||
Runtime(const QString &root)
|
Runtime(const QString &root)
|
||||||
: m_root(root) {}
|
: m_root(root) {}
|
||||||
|
bool isValid() const {
|
||||||
|
return !m_bin.isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
QString m_bin;
|
QString m_bin;
|
||||||
QString m_root;
|
QString m_root;
|
||||||
QString m_args;
|
QString m_args;
|
||||||
QString m_libPath;
|
QString m_libPath;
|
||||||
QString m_sshPort;
|
QString m_sshPort;
|
||||||
|
QString m_watchPath;
|
||||||
MaemoPortList m_freePorts;
|
MaemoPortList m_freePorts;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -110,6 +115,9 @@ private slots:
|
|||||||
void qemuStatusChanged(QemuStatus status, const QString &error);
|
void qemuStatusChanged(QemuStatus status, const QString &error);
|
||||||
void qemuOutput();
|
void qemuOutput();
|
||||||
|
|
||||||
|
void runtimeRootChanged(const QString &directory);
|
||||||
|
void runtimeFolderChanged(const QString &directory);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
MaemoQemuManager(QObject *parent);
|
MaemoQemuManager(QObject *parent);
|
||||||
~MaemoQemuManager();
|
~MaemoQemuManager();
|
||||||
@@ -128,6 +136,7 @@ private:
|
|||||||
bool fillRuntimeInformation(Runtime *runtime) const;
|
bool fillRuntimeInformation(Runtime *runtime) const;
|
||||||
QString runtimeForQtVersion(const QString &qmakeCommand) const;
|
QString runtimeForQtVersion(const QString &qmakeCommand) const;
|
||||||
|
|
||||||
|
void notify(const QList<int> uniqueIds);
|
||||||
void toggleDeviceConnections(MaemoRunConfiguration *mrc, bool connect);
|
void toggleDeviceConnections(MaemoRunConfiguration *mrc, bool connect);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -140,6 +149,8 @@ private:
|
|||||||
QIcon m_qemuStarterIcon;
|
QIcon m_qemuStarterIcon;
|
||||||
QMap<int, Runtime> m_runtimes;
|
QMap<int, Runtime> m_runtimes;
|
||||||
static MaemoQemuManager *m_instance;
|
static MaemoQemuManager *m_instance;
|
||||||
|
QFileSystemWatcher *m_runtimeRootWatcher;
|
||||||
|
QFileSystemWatcher *m_runtimeFolderWatcher;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Qt4ProjectManager
|
} // namespace Qt4ProjectManager
|
||||||
|
Reference in New Issue
Block a user