mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-31 04:25:35 +08:00
refs #887, do not start wizard when other applications are running
(potential problems with writing settings) Utility functions in info list
This commit is contained in:
committed by
Mathew Sutcliffe
parent
1076eb2b29
commit
2005e1881b
@@ -21,4 +21,19 @@ namespace BlackMisc
|
|||||||
{
|
{
|
||||||
return this->contains(&CApplicationInfo::application, application);
|
return this->contains(&CApplicationInfo::application, application);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int CApplicationInfoList::removeApplication(CApplicationInfo::Application application)
|
||||||
|
{
|
||||||
|
return this->removeIf(&CApplicationInfo::application, application);
|
||||||
|
}
|
||||||
|
|
||||||
|
QStringList CApplicationInfoList::runningProcessNames() const
|
||||||
|
{
|
||||||
|
QStringList names;
|
||||||
|
for (const CApplicationInfo &info : *this)
|
||||||
|
{
|
||||||
|
names.append(info.processInfo().processName());
|
||||||
|
}
|
||||||
|
return names;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,6 +36,12 @@ namespace BlackMisc
|
|||||||
|
|
||||||
//! List containing entry for CApplicationInfo::Application ?
|
//! List containing entry for CApplicationInfo::Application ?
|
||||||
bool containsApplication(CApplicationInfo::Application application) const;
|
bool containsApplication(CApplicationInfo::Application application) const;
|
||||||
|
|
||||||
|
//! Remove given application
|
||||||
|
int removeApplication(CApplicationInfo::Application application);
|
||||||
|
|
||||||
|
//! Running application names
|
||||||
|
QStringList runningProcessNames() const;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,6 +24,7 @@
|
|||||||
#include <QBitmap>
|
#include <QBitmap>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
|
#include <QStringBuilder>
|
||||||
#include <QDesktopServices>
|
#include <QDesktopServices>
|
||||||
#include <QShortcut>
|
#include <QShortcut>
|
||||||
#include <qcompilerdetection.h>
|
#include <qcompilerdetection.h>
|
||||||
@@ -359,6 +360,20 @@ void CSwiftLauncher::saveSetup()
|
|||||||
m_setup.set(setup);
|
m_setup.set(setup);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CSwiftLauncher::warnAboutOtherSwiftApplications()
|
||||||
|
{
|
||||||
|
CApplicationInfoList running = CGuiApplication::getRunningApplications();
|
||||||
|
running.removeApplication(CApplicationInfo::Laucher);
|
||||||
|
if (running.isEmpty()) { return true; }
|
||||||
|
|
||||||
|
// getting here means another application is running
|
||||||
|
const QString msg =
|
||||||
|
QStringLiteral("While using the wizard no other application should run.\nClose applications and try again.\nCurrently running: ") %
|
||||||
|
running.runningProcessNames().join(',');
|
||||||
|
QMessageBox::question(this, "Wizard", msg, QMessageBox::Close);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
QString CSwiftLauncher::toCmdLine(const QString &exe, const QStringList &exeArgs)
|
QString CSwiftLauncher::toCmdLine(const QString &exe, const QStringList &exeArgs)
|
||||||
{
|
{
|
||||||
if (exeArgs.isEmpty()) { return exe; }
|
if (exeArgs.isEmpty()) { return exe; }
|
||||||
@@ -527,6 +542,8 @@ void CSwiftLauncher::ps_checkRunningApplicationsAndCore()
|
|||||||
|
|
||||||
void CSwiftLauncher::ps_startWizard()
|
void CSwiftLauncher::ps_startWizard()
|
||||||
{
|
{
|
||||||
|
const bool show = this->warnAboutOtherSwiftApplications();
|
||||||
|
if (!show) { return; }
|
||||||
if (!m_wizard)
|
if (!m_wizard)
|
||||||
{
|
{
|
||||||
m_wizard.reset(new CConfigurationWizard(this));
|
m_wizard.reset(new CConfigurationWizard(this));
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ private:
|
|||||||
QScopedPointer<Ui::CSwiftLauncher> ui;
|
QScopedPointer<Ui::CSwiftLauncher> ui;
|
||||||
QScopedPointer<BlackGui::Components::CConfigurationWizard> m_wizard;
|
QScopedPointer<BlackGui::Components::CConfigurationWizard> m_wizard;
|
||||||
BlackMisc::CData<BlackCore::Data::TUpdateInfo> m_updateInfo { this, &CSwiftLauncher::ps_changedUpdateInfoCache }; //!< version cache
|
BlackMisc::CData<BlackCore::Data::TUpdateInfo> m_updateInfo { this, &CSwiftLauncher::ps_changedUpdateInfoCache }; //!< version cache
|
||||||
BlackMisc::CData<BlackCore::Data::TLauncherSetup> m_setup { this }; //! setup, ie last user selection
|
BlackMisc::CData<BlackCore::Data::TLauncherSetup> m_setup { this }; //!< setup, i.e. last user selection
|
||||||
QString m_executable;
|
QString m_executable;
|
||||||
QStringList m_executableArgs;
|
QStringList m_executableArgs;
|
||||||
QTimer m_checkTimer { this };
|
QTimer m_checkTimer { this };
|
||||||
@@ -140,6 +140,9 @@ private:
|
|||||||
//! Save state
|
//! Save state
|
||||||
void saveSetup();
|
void saveSetup();
|
||||||
|
|
||||||
|
//! Check for other swift applications, if so show message box
|
||||||
|
bool warnAboutOtherSwiftApplications();
|
||||||
|
|
||||||
//! Command line
|
//! Command line
|
||||||
static QString toCmdLine(const QString &exe, const QStringList &exeArgs);
|
static QString toCmdLine(const QString &exe, const QStringList &exeArgs);
|
||||||
|
|
||||||
@@ -183,7 +186,7 @@ private slots:
|
|||||||
//! Show the log page
|
//! Show the log page
|
||||||
void ps_showLogPage();
|
void ps_showLogPage();
|
||||||
|
|
||||||
//! Check if applicationas are already running
|
//! Check if applications are already running
|
||||||
void ps_checkRunningApplicationsAndCore();
|
void ps_checkRunningApplicationsAndCore();
|
||||||
|
|
||||||
//! Start the configuration wizard
|
//! Start the configuration wizard
|
||||||
|
|||||||
Reference in New Issue
Block a user