refs #485, fixed default values in launcher

(discovered during testing, not really related)
This commit is contained in:
Klaus Basan
2016-02-15 00:12:36 +01:00
committed by Mathew Sutcliffe
parent 41a88266ab
commit a0b7f741ee
2 changed files with 33 additions and 7 deletions

View File

@@ -55,7 +55,8 @@ CSwiftLauncher::CSwiftLauncher(QWidget *parent) :
this->ui->le_DBusServerPort->setValidator(new QIntValidator(0, 65535, this)); this->ui->le_DBusServerPort->setValidator(new QIntValidator(0, 65535, this));
// default from settings // default from settings
this->ui->cb_DBusServerAddress->setCurrentText(this->m_dbusServerAddress.get()); const QString dbus(this->m_dbusServerAddress.get());
this->setDefault(dbus);
} }
CSwiftLauncher::~CSwiftLauncher() CSwiftLauncher::~CSwiftLauncher()
@@ -86,9 +87,10 @@ QString CSwiftLauncher::getDBusAddress() const
{ {
if (this->ui->rb_DBusSession->isChecked()) { return CDBusServer::sessionBusAddress(); } if (this->ui->rb_DBusSession->isChecked()) { return CDBusServer::sessionBusAddress(); }
if (this->ui->rb_DBusSystem->isChecked()) { return CDBusServer::systemBusAddress(); } if (this->ui->rb_DBusSystem->isChecked()) { return CDBusServer::systemBusAddress(); }
return CDBusServer::normalizeAddress( return CDBusServer::p2pAddress(
this->ui->cb_DBusServerAddress->currentText() + ":" + this->ui->cb_DBusServerAddress->currentText() + ":" +
this->ui->le_DBusServerPort->text()); this->ui->le_DBusServerPort->text()
);
} }
void CSwiftLauncher::mouseMoveEvent(QMouseEvent *event) void CSwiftLauncher::mouseMoveEvent(QMouseEvent *event)
@@ -176,10 +178,12 @@ void CSwiftLauncher::initLogDisplay()
void CSwiftLauncher::startSwiftCore() void CSwiftLauncher::startSwiftCore()
{ {
const QString dBus(this->getDBusAddress());
this->m_dbusServerAddress.setAndSave(dBus);
QStringList args( QStringList args(
{ {
"--start", "--start",
"--dbus", this->getDBusAddress() "--dbus", dBus
}); });
if (this->ui->rb_SwiftCoreAudio->isChecked()) if (this->ui->rb_SwiftCoreAudio->isChecked())
@@ -190,7 +194,7 @@ void CSwiftLauncher::startSwiftCore()
// I set this for debug purpose only // I set this for debug purpose only
this->m_executableArgs = args; this->m_executableArgs = args;
this->m_executable = CProject::swiftCoreExecutableName(); this->m_executable = CProject::swiftCoreExecutableName();
CLogMessage(this).debug() << this->getCmdLine(); CLogMessage(this).info(this->getCmdLine());
// start // start
QProcess::startDetached(this->m_executable, this->m_executableArgs); QProcess::startDetached(this->m_executable, this->m_executableArgs);
@@ -207,7 +211,6 @@ bool CSwiftLauncher::setSwiftGuiExecutable()
QString msg; QString msg;
if (this->isStandaloneGuiSelected() || this->canConnectDBusServer(msg)) if (this->isStandaloneGuiSelected() || this->canConnectDBusServer(msg))
{ {
m_executable = CProject::swiftGuiExecutableName(); m_executable = CProject::swiftGuiExecutableName();
QStringList args QStringList args
{ {
@@ -216,8 +219,11 @@ bool CSwiftLauncher::setSwiftGuiExecutable()
}; };
if (!this->isStandaloneGuiSelected()) if (!this->isStandaloneGuiSelected())
{ {
const QString dBus(this->getDBusAddress());
this->m_dbusServerAddress.setAndSave(dBus);
args.append("--dbus"); args.append("--dbus");
args.append(getDBusAddress()); // already converted args.append(dBus); // already converted
} }
m_executableArgs = args; m_executableArgs = args;
return true; return true;
@@ -245,6 +251,23 @@ bool CSwiftLauncher::isStandaloneGuiSelected() const
return this->ui->rb_SwiftStandalone->isChecked(); return this->ui->rb_SwiftStandalone->isChecked();
} }
void CSwiftLauncher::setDefault(const QString &value)
{
QString v(value.toLower().trimmed());
if (v.isEmpty() || v.startsWith("session"))
{
this->ui->rb_DBusSession->setChecked(true);
}
else if (v.startsWith("sys"))
{
this->ui->rb_DBusSystem->setChecked(true);
}
else
{
this->ui->rb_DBusP2P->setChecked(true);
}
}
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; }

View File

@@ -108,6 +108,9 @@ private:
//! Standalone GUI selected //! Standalone GUI selected
bool isStandaloneGuiSelected() const; bool isStandaloneGuiSelected() const;
//! Set default
void setDefault(const QString &value);
//! Command line //! Command line
static QString toCmdLine(const QString &exe, const QStringList &exeArgs); static QString toCmdLine(const QString &exe, const QStringList &exeArgs);