mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-14 00:25:35 +08:00
refs #485, first version of a Gui/Core application class
Also specialized GUI application class for standard GUI
This commit is contained in:
committed by
Mathew Sutcliffe
parent
d9aac6427b
commit
158efe819a
70
src/swiftguistandard/swiftguistdapplication.cpp
Normal file
70
src/swiftguistandard/swiftguistdapplication.cpp
Normal file
@@ -0,0 +1,70 @@
|
||||
/* Copyright (C) 2016
|
||||
* swift project Community / Contributors
|
||||
*
|
||||
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
||||
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||
* contained in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "swiftguistdapplication.h"
|
||||
#include "blackcore/coremodeenums.h"
|
||||
#include "blackmisc/dbusserver.h"
|
||||
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackCore;
|
||||
|
||||
CSwiftGuiStdApplication::CSwiftGuiStdApplication(int argc, char *argv[]) : CGuiApplication(argc, argv, "swift pilot client GUI")
|
||||
{
|
||||
this->setWindowIcon(CIcons::swift24());
|
||||
this->addParserOption(this->m_cmdFacadeMode);
|
||||
this->addWindowModeOption();
|
||||
this->addDBusAddressOption();
|
||||
}
|
||||
|
||||
void CSwiftGuiStdApplication::startCoreFacade()
|
||||
{
|
||||
CoreModes::CoreMode coreMode = CoreModes::CoreInGuiProcess;
|
||||
const QString dBusAddress(this->getCmdDBusAddressValue());
|
||||
if (this->isParserOptionSet(this->m_cmdFacadeMode))
|
||||
{
|
||||
const QString v(this->getParserOptionValue(this->m_cmdFacadeMode));
|
||||
coreMode = CoreModes::stringToCoreMode(v);
|
||||
}
|
||||
|
||||
CCoreFacadeConfig runtimeConfig;
|
||||
switch (coreMode)
|
||||
{
|
||||
case CoreModes::CoreExternalCoreAudio:
|
||||
runtimeConfig = CCoreFacadeConfig::remote(dBusAddress);
|
||||
break;
|
||||
default:
|
||||
case CoreModes::CoreInGuiProcess:
|
||||
runtimeConfig = CCoreFacadeConfig::local(dBusAddress);
|
||||
break;
|
||||
case CoreModes::CoreExternalAudioGui:
|
||||
runtimeConfig = CCoreFacadeConfig::remoteLocalAudio(dBusAddress);
|
||||
break;
|
||||
}
|
||||
this->useContexts(runtimeConfig);
|
||||
}
|
||||
|
||||
void CSwiftGuiStdApplication::parsingHookIn()
|
||||
{
|
||||
// Parse core relevant arguments
|
||||
const QString dBusAddress(this->getCmdDBusAddressValue());
|
||||
if (!dBusAddress.isEmpty())
|
||||
{
|
||||
// check if rechable
|
||||
if (!CDBusServer::isDBusAvailable(dBusAddress))
|
||||
{
|
||||
this->parserErrorMessage("DBus server at " + dBusAddress + " can not be reached");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CSwiftGuiStdApplication *instance()
|
||||
{
|
||||
return qobject_cast<CSwiftGuiStdApplication *>(CApplication::instance());
|
||||
}
|
||||
Reference in New Issue
Block a user