refs #603, new CMD args, formerly passed by env.vars

* removed from CProject
* removed. env. vars menu items
* prepared for vatlib cmd. args
* prepared for eol (end of lifetime) timestamp (time bomb)
This commit is contained in:
Klaus Basan
2016-02-29 02:17:20 +01:00
committed by Mathew Sutcliffe
parent d7e5b5206c
commit f4cbfc2fa9
22 changed files with 264 additions and 240 deletions

View File

@@ -10,6 +10,7 @@
#include "application.h"
#include "blackcore/corefacade.h"
#include "blackcore/setupreader.h"
#include "blackcore/networkvatlib.h"
#include "blackcore/webdataservices.h"
#include "blackcore/contextapplication.h"
#include "blackcore/registermetadata.h"
@@ -22,6 +23,7 @@
#include "blackmisc/network/networkutils.h"
#include "blackmisc/simulation/aircraftmodellist.h"
#include "blackmisc/verify.h"
#include "blackmisc/stringutils.h"
#include <QStandardPaths>
#include <QFile>
#include <QFileInfo>
@@ -93,9 +95,16 @@ namespace BlackCore
this->gracefulShutdown();
}
QString CApplication::getApplicationNameAndVersion() const
const QString &CApplication::getApplicationNameAndVersion() const
{
return QCoreApplication::instance()->applicationName() + " " + CProject::version();
static const QString s(QCoreApplication::instance()->applicationName() + " " + CProject::version());
return s;
}
const QString &CApplication::getApplicationNameVersionBetaDev() const
{
static const QString s(QCoreApplication::instance()->applicationName() + " " + this->versionStringDevBetaInfo());
return s;
}
Data::CGlobalSetup CApplication::getGlobalSetup() const
@@ -186,6 +195,76 @@ namespace BlackCore
return CThreadUtils::isCurrentThreadApplicationThread();
}
const QString &CApplication::versionStringDevBetaInfo() const
{
if (isRunningInDeveloperEnvironment() && CProject::isBetaTest())
{
static const QString s(CProject::version() + " [DEV, BETA]");
return s;
}
if (isRunningInDeveloperEnvironment())
{
static const QString s(CProject::version() + " [DEV]");
return s;
}
if (CProject::isBetaTest())
{
static const QString s(CProject::version() + " [BETA]");
return s;
}
return CProject::version();
}
const QString &CApplication::swiftVersionString() const
{
static const QString s(QString("swift %1").arg(versionStringDevBetaInfo()));
return s;
}
const char *CApplication::swiftVersionChar()
{
static const QByteArray a(swiftVersionString().toUtf8());
return a.constData();
}
bool CApplication::isRunningInDeveloperEnvironment() const
{
if (!CProject::canRunInDeveloperEnvironment()) { return false; }
if (!this->m_parser.value(this->m_cmdDevelopment).isEmpty())
{
// explicit value
const QString v(this->m_parser.value(this->m_cmdDevelopment));
return stringToBool(v);
}
else if (this->isSetupSyncronized())
{
// assume value from setup
return this->getGlobalSetup().isDevelopment();
}
return false;
}
QString CApplication::getEnvironmentInfoString(const QString &separator) const
{
QString env("Beta: ");
env.append(boolToYesNo(CProject::isBetaTest()));
env = env.append(" dev.env,: ").append(boolToYesNo(isRunningInDeveloperEnvironment()));
env = env.append(separator);
env.append("Windows: ").append(boolToYesNo(CProject::isRunningOnWindowsNtPlatform()));
return env;
}
QString CApplication::getInfoString(const QString &separator) const
{
QString str(CProject::version());
str = str.append(" ").append(CProject::isReleaseBuild() ? "Release build" : "Debug build");
str = str.append(separator);
str = str.append(getEnvironmentInfoString(separator));
str = str.append(separator);
str.append(CProject::compiledWithInfo(false));
return str;
}
QNetworkReply *CApplication::getFromNetwork(const CUrl &url, const CSlot<void(QNetworkReply *)> &callback)
{
if (this->m_shutdown) { return nullptr; }
@@ -296,14 +375,15 @@ namespace BlackCore
bool CApplication::useContexts(const CCoreFacadeConfig &coreConfig)
{
Q_ASSERT_X(this->m_parsed, Q_FUNC_INFO, "Call this after parsing");
Q_ASSERT_X(this->m_parsed, Q_FUNC_INFO, "Call this function after parsing");
this->m_useContexts = true;
this->m_coreFacadeConfig = coreConfig;
if (!this->m_useWebData)
{
this->useWebDataServices(CWebReaderFlags::AllReaders, CWebReaderFlags::FromCache);
bool s = this->useWebDataServices(CWebReaderFlags::AllReaders, CWebReaderFlags::FromCache);
if (!s) { return false; }
}
return this->startCoreFacade(); // will do nothing if setup is not yet loaded
}
@@ -311,6 +391,13 @@ namespace BlackCore
bool CApplication::useWebDataServices(const CWebReaderFlags::WebReader webReader, CWebReaderFlags::DbReaderHint hint)
{
Q_ASSERT_X(this->m_webDataServices.isNull(), Q_FUNC_INFO, "Services already started");
BLACK_VERIFY_X(QSslSocket::supportsSsl(), Q_FUNC_INFO, "No SSL");
if (!QSslSocket::supportsSsl())
{
this->cmdLineErrorMessage("No SSL supported, can`t be used");
return false;
}
this->m_webReader = webReader;
this->m_dbReaderHint = hint;
this->m_useWebData = true;
@@ -368,6 +455,16 @@ namespace BlackCore
this->m_parser.setApplicationDescription(m_applicationName);
this->m_cmdHelp = this->m_parser.addHelpOption();
this->m_cmdVersion = this->m_parser.addVersionOption();
this->m_cmdDevelopment = QCommandLineOption({ "dev", "developemnt" },
QCoreApplication::translate("application", "Dev.system feature?"),
"development");
this->addParserOption(this->m_cmdDevelopment);
this->m_cmdSharedDir = QCommandLineOption({ "shared", "shareddir" },
QCoreApplication::translate("application", "Local shred directory."),
"shared");
this->addParserOption(this->m_cmdSharedDir);
}
void CApplication::initEnvironment()
@@ -478,6 +575,11 @@ namespace BlackCore
return this->m_parser.addOption(option);
}
bool CApplication::addParserOptions(const QList<QCommandLineOption> &options)
{
return this->m_parser.addOptions(options);
}
void CApplication::addDBusAddressOption()
{
this->m_cmdDBusAddress = QCommandLineOption({ "dbus", "dbus-address", "dbusaddress" },
@@ -486,11 +588,16 @@ namespace BlackCore
this->addParserOption(this->m_cmdDBusAddress);
}
void CApplication::addVatlibOptions()
{
this->addParserOptions(CNetworkVatlib::getCmdLineOptions());
}
QString CApplication::getCmdDBusAddressValue() const
{
if (this->isParserOptionSet(this->m_cmdDBusAddress))
{
const QString v(this->getParserOptionValue(m_cmdDBusAddress));
const QString v(this->getParserValue(m_cmdDBusAddress));
const QString dBusAddress(CDBusServer:: normalizeAddress(v));
return dBusAddress;
}
@@ -500,6 +607,11 @@ namespace BlackCore
}
}
QString CApplication::getCmdSwiftPrivateSharedDir() const
{
return this->m_parser.value(this->m_cmdSharedDir);
}
bool CApplication::isParserOptionSet(const QString &option) const
{
return this->m_parser.isSet(option);
@@ -510,12 +622,12 @@ namespace BlackCore
return this->m_parser.isSet(option);
}
QString CApplication::getParserOptionValue(const QString &option) const
QString CApplication::getParserValue(const QString &option) const
{
return this->m_parser.value(option).trimmed();
}
QString CApplication::getParserOptionValue(const QCommandLineOption &option) const
QString CApplication::getParserValue(const QCommandLineOption &option) const
{
return this->m_parser.value(option).trimmed();
}
@@ -523,9 +635,14 @@ namespace BlackCore
bool CApplication::parse()
{
if (this->m_parsed) { return m_parsed; }
if (CProject::isLifetimeExpired())
{
this->cmdLineErrorMessage("Program exired " + CProject::getEol().toString());
return false;
}
// we call parse because we also want to display a GUI error message when applicable
QStringList args(QCoreApplication::instance()->arguments());
const QStringList args(QCoreApplication::instance()->arguments());
if (!this->m_parser.parse(args))
{
this->cmdLineErrorMessage(this->m_parser.errorText());

View File

@@ -48,6 +48,7 @@ namespace BlackCore
* - The core facade (aka core runtime) is now part of the application. It can be started via cmd line arguments.
* - Settings are loaded
* - Setup is loaded (load the so called bootsrap file) to find servers and other resources
* - An end of lifetime can be specified, aka time bombing
*
* \sa BlackGui::CGuiApplication for the GUI version of application
*/
@@ -69,7 +70,10 @@ namespace BlackCore
virtual ~CApplication();
//! Application name and version
QString getApplicationNameAndVersion() const;
const QString &getApplicationNameAndVersion() const;
//! Version, name beta and dev info
const QString &getApplicationNameVersionBetaDev() const;
//! Global setup
//! \threadsafe
@@ -93,6 +97,24 @@ namespace BlackCore
//! Currently running in application thread?
bool isApplicationThread() const;
//! String with beta, dev. and version
const QString &versionStringDevBetaInfo() const;
//! swift info string
const QString &swiftVersionString() const;
//! swift info string
const char *swiftVersionChar();
//! Running in dev.environment?
bool isRunningInDeveloperEnvironment() const;
//! Info string
QString getEnvironmentInfoString(const QString &separator) const;
//! To string
QString getInfoString(const QString &separator) const;
//! Run event loop
static int exec();
@@ -110,15 +132,24 @@ namespace BlackCore
//! \name parsing of command line options
//! @{
//! \copydoc QCommandLineParser::addOption(const QCommandLineOption &)
//! \copydoc QCommandLineParser::addOption
bool addParserOption(const QCommandLineOption &option);
//! \copydoc QCommandLineParser::addOptions
bool addParserOptions(const QList<QCommandLineOption> &options);
//! CMD line argument for DBus address
void addDBusAddressOption();
//! DBus address from CMD line, otherwise ""
QString getCmdDBusAddressValue() const;
//! Add the VATLIB options
void addVatlibOptions();
//! Private resource dir for developer's own resource files
QString getCmdSwiftPrivateSharedDir() const;
//! Delegates to QCommandLineParser::isSet
bool isParserOptionSet(const QString &option) const;
@@ -126,10 +157,10 @@ namespace BlackCore
bool isParserOptionSet(const QCommandLineOption &option) const;
//! Delegates to QCommandLineParser::value
QString getParserOptionValue(const QString &option) const;
QString getParserValue(const QString &option) const;
//! Delegates to QCommandLineParser::value
QString getParserOptionValue(const QCommandLineOption &option) const;
QString getParserValue(const QCommandLineOption &option) const;
//! Display parser error message
virtual void cmdLineErrorMessage(const QString &cmdLineErrorMessage) const;
@@ -258,6 +289,9 @@ namespace BlackCore
QCommandLineOption m_cmdHelp {"help"}; //!< help option
QCommandLineOption m_cmdVersion {"version"}; //!< version option
QCommandLineOption m_cmdDBusAddress {"empty"}; //!< DBus address
QCommandLineOption m_cmdDevelopment {"dev"}; //!< Dev flag
QCommandLineOption m_cmdSharedDir {"shared"}; //!< Dev flag
bool m_parsed = false; //!< Parsing accomplished?
bool m_started = false; //!< started with success?
bool m_startUpCompleted = false; //!< startup phase completed? Can mean startup failed

View File

@@ -23,7 +23,6 @@ namespace BlackCore
{
CGlobalSetup::CGlobalSetup() :
ITimestampBased(0),
m_development(CProject::isRunningInDeveloperEnvironment()),
m_dbRootDirectoryUrl("http://ubuntu12/swiftdatastore/public"),
m_vatsimBookingsUrl("http://vatbook.euroutepro.com/xml2.php"),
m_vatsimMetarsUrl("http://metar.vatsim.net/metar.php"),

View File

@@ -100,9 +100,9 @@ namespace BlackCore
bool CSetupReader::parseCmdLineArguments()
{
this->m_bootsrapUrlFileValue = CGlobalSetup::buildBootstrapFileUrl(
sApp->getParserOptionValue(this->m_cmdBootstrapUrl)
sApp->getParserValue(this->m_cmdBootstrapUrl)
);
this->m_bootstrapMode = stringToEnum(sApp->getParserOptionValue(this->m_cmdBootstrapMode));
this->m_bootstrapMode = stringToEnum(sApp->getParserValue(this->m_cmdBootstrapMode));
QUrl url(this->m_bootsrapUrlFileValue);
// check on local file
@@ -208,7 +208,7 @@ namespace BlackCore
if (!file.exists())
{
// relative name?
QString dir(CProject::getSwiftPrivateResourceDir());
QString dir(sApp->getCmdSwiftPrivateSharedDir());
if (dir.isEmpty()) { return false; }
// no version for local files, as those come withe the current code
@@ -228,11 +228,6 @@ namespace BlackCore
return true;
}
bool CSetupReader::isForDevelopment()
{
return CProject::useDevelopmentSetup();
}
void CSetupReader::ps_parseSetupFile(QNetworkReply *nwReplyPtr)
{
// wrap pointer, make sure any exit cleans up reply
@@ -343,7 +338,6 @@ namespace BlackCore
CUpdateInfo currentUpdateInfo(m_updateInfo.get()); // from cache
CUpdateInfo loadedUpdateInfo;
loadedUpdateInfo.convertFromJson(Json::jsonObjectFromString(setupJson));
loadedUpdateInfo.setDevelopment(isForDevelopment()); // always update, regardless what persistent setting says
if (lastModified > 0 && lastModified > loadedUpdateInfo.getMSecsSinceEpoch()) { loadedUpdateInfo.setMSecsSinceEpoch(lastModified); }
bool sameVersionLoaded = (loadedUpdateInfo == currentUpdateInfo);
if (sameVersionLoaded)

View File

@@ -111,7 +111,7 @@ namespace BlackCore
CacheOnly
};
bool m_shutdown = false;
bool m_shutdown = false;
std::atomic<bool> m_setupSyncronized { false };
std::atomic<bool> m_updateInfoSyncronized { false };
QString m_localSetupFileValue;
@@ -140,9 +140,6 @@ namespace BlackCore
//! Convert string to mode
static BootsrapMode stringToEnum(const QString &s);
//! Read for development environment?
static bool isForDevelopment();
};
} // ns

View File

@@ -7,6 +7,7 @@
* contained in the LICENSE file.
*/
#include "blackgui/guiapplication.h"
#include "blackmisc/project.h"
#include "dbdebugdatabasesetup.h"
#include "ui_dbdebugdatabasesetup.h"
@@ -23,7 +24,7 @@ namespace BlackGui
ui(new Ui::CDbDebugDatabaseSetup)
{
ui->setupUi(this);
bool enabled = CProject::isRunningInDeveloperEnvironment();
bool enabled = sGui->isRunningInDeveloperEnvironment();
this->setEnabled(enabled);
if (!enabled)
{

View File

@@ -106,7 +106,7 @@ namespace BlackGui
CServerList otherServers(this->m_otherTrafficNetworkServers.get());
// add a testserver when no servers can be loaded
if (otherServers.isEmpty() && CProject::isRunningInBetaOrDeveloperEnvironment())
if (otherServers.isEmpty() && (sGui->isRunningInDeveloperEnvironment() || CProject::isBetaTest()))
{
otherServers.push_back(m_setup.get().fsdTestServersPlusHardcodedServers());
CLogMessage(this).info("Added servers for testing");

View File

@@ -53,11 +53,11 @@ namespace BlackGui
// add swift test servers in case we have no servers:
// this is debug/bootstrap feature we can continue to test when something goes wrong
if (serverList.isEmpty() && CProject::isRunningInBetaOrDeveloperEnvironment())
if (serverList.isEmpty() && (CProject::isBetaTest() || sGui->isRunningInDeveloperEnvironment()))
{
serverList.push_back(m_setup.get().fsdTestServersPlusHardcodedServers());
this->ui->tvp_Servers->updateContainer(serverList);
}
this->ui->tvp_Servers->updateContainer(serverList);
}
void CSettingsNetworkServersComponent::ps_serverSelected(const QModelIndex &index)

View File

@@ -63,7 +63,7 @@ namespace BlackGui
{
if (this->isParserOptionSet(m_cmdWindowMode))
{
const QString v(this->getParserOptionValue(this->m_cmdWindowMode));
const QString v(this->getParserValue(this->m_cmdWindowMode));
return CEnableForFramelessWindow::stringToWindowMode(v);
}
else
@@ -91,7 +91,7 @@ namespace BlackGui
void CGuiApplication::initMainApplicationWindow(QWidget *mainWindow) const
{
if (!mainWindow) { return; }
const QString name(this->getApplicationNameAndVersion());
const QString name(this->getApplicationNameVersionBetaDev());
mainWindow->setObjectName(QCoreApplication::applicationName());
mainWindow->setWindowTitle(name);
mainWindow->setWindowIcon(m_windowIcon);
@@ -139,6 +139,11 @@ namespace BlackGui
return m->displayInOverlayWindow(message);
}
bool CGuiApplication::reloadStyleSheets() const
{
return CStyleSheetUtility::instance().read();
}
void CGuiApplication::cmdLineHelpMessage()
{
if (CProject::isRunningOnWindowsNtPlatform())

View File

@@ -71,6 +71,9 @@ namespace BlackGui
virtual bool displayInOverlayWindow(const BlackMisc::CStatusMessage &message) override;
//! }@
//! Reload style sheets
bool reloadStyleSheets() const;
//! Set icon
//! \note Pixmap requires a valid QApplication, so it cannot be passed as constructor parameter
static void setWindowIcon(const QPixmap &icon);
@@ -78,7 +81,7 @@ namespace BlackGui
//! Main application window
static QWidget *mainApplicationWindow();
//! Main window access
//! Main window access interface
static BlackGui::IMainWindowAccess *mainWindowAccess();
//! Exit application, perform graceful shutdown and exit

View File

@@ -23,16 +23,15 @@
namespace BlackGui
{
class CGuiApplication;
//! Reads and provides style sheets
class BLACKGUI_EXPORT CStyleSheetUtility : public QObject
{
Q_OBJECT
friend class CGuiApplication;
public:
//! Read the *.qss files
bool read();
//! Style for given file name
QString style(const QString &fileName) const;
@@ -136,6 +135,9 @@ namespace BlackGui
void styleSheetsChanged();
private:
//! Read the *.qss files
bool read();
QMap<QString, QString> m_styleSheets; //!< filename, stylesheet
QScopedPointer<QSettings> m_iniFile;

View File

@@ -40,4 +40,8 @@
# define BLACKMISC_EXPORT_TEMPLATE
#endif
#endif // BLACKMISC_MACROS_H
//! make a define quoted (normally to be used then with QString)
#define BLACK_STRINGIFY_X(v) #v
#define BLACK_STRINGIFY(v) BLACK_STRINGIFY_X(v)
#endif // guard

View File

@@ -18,9 +18,13 @@
#include <QCoreApplication>
#include <QProcessEnvironment>
#if !defined(BLACK_VERSION)
#error Missing version
#endif
#define BLACK_VERSION_STR_X(v) #v
#define BLACK_VERSION_STR(v) BLACK_VERSION_STR_X(v)
#if !defined(BLACK_EOL)
#error Missing EOL
#endif
namespace BlackMisc
{
@@ -122,45 +126,13 @@ namespace BlackMisc
const QString &CProject::version()
{
#ifdef BLACK_VERSION
const static QString v(BLACK_VERSION_STR(BLACK_VERSION));
static const QString v(BLACK_STRINGIFY(BLACK_VERSION));
#else
const static QString v("?");
static const QString v("?");
#endif
return v;
}
const QString &CProject::swiftVersionString()
{
static const QString s(QString("swift %1").arg(versionStringDevBetaInfo()));
return s;
}
const QString &CProject::versionStringDevBetaInfo()
{
if (isRunningInDeveloperEnvironment() && isBetaTest())
{
static const QString s(version() + " [DEV, BETA]");
return s;
}
if (isRunningInDeveloperEnvironment())
{
static const QString s(version() + " [DEV]");
return s;
}
if (isBetaTest())
{
static const QString s(version() + " [BETA]");
return s;
}
return version();
}
const char *CProject::swiftVersionChar()
{
static const QByteArray a(swiftVersionString().toUtf8());
return a.constData();
}
int CProject::versionMajor()
{
return getMajorMinor(0);
@@ -207,45 +179,38 @@ namespace BlackMisc
bool CProject::isBetaTest()
{
//! \todo however we do it
#ifdef SWIFT_BETA
return true;
#else
return false;
#endif
}
bool CProject::canRunInDeveloperEnvironment()
{
if (isBetaTest()) { return true; }
return !isShippedVersion();
}
bool CProject::isShippedVersion()
{
#ifdef SWIFT_SHIPPED
return true;
#else
return false;
#endif
}
bool CProject::isRunningOnWindowsNtPlatform()
{
#ifdef Q_OS_WIN
// QSysInfo::WindowsVersion only available on Win platforms
return (QSysInfo::WindowsVersion & QSysInfo::WV_NT_based) ? true : false;
return (QSysInfo::WindowsVersion & QSysInfo::WV_NT_based);
#else
return false;
#endif
}
bool CProject::isRunningInDeveloperEnvironment()
{
static const bool dev = BlackMisc::stringToBool(envVarDevelopmentValue());
return dev;
}
bool CProject::useDevelopmentSetup()
{
static const QString v(envVarDevelopmentValue());
if (v.isEmpty())
{
// no explicit value
return isRunningInBetaOrDeveloperEnvironment();
}
else
{
return stringToBool(v);
}
}
bool CProject::isRunningInBetaOrDeveloperEnvironment()
{
return isBetaTest() || isRunningInDeveloperEnvironment();
}
QList<int> CProject::getVersionParts(const QString &versionString)
{
QStringList parts = versionString.split('.');
@@ -266,23 +231,6 @@ namespace BlackMisc
return partsInt[index];
}
const QString &CProject::envVarDevelopment()
{
static const QString s("SWIFT_DEV");
return s;
}
QString CProject::envVarDevelopmentValue()
{
return QProcessEnvironment::systemEnvironment().value(envVarDevelopment());
}
const QString &CProject::envVarPrivateSetupDir()
{
static const QString s("SWIFT_SETUP_DIR");
return s;
}
const QString &CProject::swiftGuiExecutableName()
{
static const QString s("swiftguistd");
@@ -303,16 +251,29 @@ namespace BlackMisc
const QStringList &CProject::swiftTeamDefaultServers()
{
static const QStringList s( { "https://vatsim-germany.org:50443/mapping/public/shared", "http://ubuntu12/public/bootstrap/shared"});
static const QStringList s({ "https://vatsim-germany.org:50443/mapping/public/shared", "http://ubuntu12/public/bootstrap/shared"});
return s;
}
QString CProject::envVarPrivateSetupDirValue()
const QDateTime &CProject::getEol()
{
return QProcessEnvironment::systemEnvironment().value(envVarPrivateSetupDir());
static const QString eol(BLACK_STRINGIFY(BLACK_EOL));
static const QDateTime dt(eol.isEmpty() ? QDateTime() : QDateTime::fromString(eol, "yyyyMMdd"));
return dt;
}
bool CProject::isLifetimeExpired()
{
if (getEol().isValid())
{
return QDateTime::currentDateTime() > getEol();
}
else
{
return true;
}
}
//! Get application directory
QString getApplicationDirImpl()
{
QFileInfo executable(QCoreApplication::applicationFilePath());
@@ -326,7 +287,6 @@ namespace BlackMisc
return s;
}
//! Get swift resource directory
QString getSwiftResourceDirImpl()
{
QDir dir(CProject::getApplicationDir());
@@ -345,13 +305,6 @@ namespace BlackMisc
return s;
}
QString CProject::getSwiftPrivateResourceDir()
{
static const QString dir(envVarPrivateSetupDirValue());
return dir;
}
//! Get static database directory
QString getSwiftStaticDbFilesDirImpl()
{
QString d(CProject::getSwiftResourceDir());
@@ -367,7 +320,6 @@ namespace BlackMisc
return s;
}
//! Get images directory
QString getImagesDirImpl()
{
QString d(CProject::getSwiftResourceDir());
@@ -382,17 +334,6 @@ namespace BlackMisc
return s;
}
QString CProject::getEnvironmentVariables(const QString &separator)
{
QString e(envVarDevelopment());
e = e.append(": ").append(envVarDevelopmentValue());
e = e.append(separator);
e = e.append(envVarPrivateSetupDir());
e = e.append(": ").append(envVarPrivateSetupDirValue());
return e;
}
const QString &CProject::compiledWithInfo(bool shortVersion)
{
if (shortVersion)
@@ -432,31 +373,6 @@ namespace BlackMisc
return infoLong;
}
}
QString CProject::environmentInfo(const QString &separator)
{
QString env("Beta: ");
env.append(boolToYesNo(isBetaTest()));
env = env.append(" dev.env,: ").append(boolToYesNo(isRunningInDeveloperEnvironment()));
env = env.append(separator);
env.append("Windows: ").append(boolToYesNo(isRunningOnWindowsNtPlatform()));
return env;
}
QString CProject::convertToQString(const QString &separator)
{
QString str(version());
str = str.append(" ").append(isReleaseBuild() ? "Release build" : "Debug build");
str = str.append(separator);
str = str.append(environmentInfo(separator));
str = str.append(separator);
str.append(compiledWithInfo(false));
return str;
}
} // ns
#undef BLACK_VERSION_STR
#undef BLACK_VERSION_STR_X
//! \endcond

View File

@@ -63,15 +63,6 @@ namespace BlackMisc
//! Version info
static const QString &version();
//! System's name and version
static const QString &swiftVersionString();
//! System's name and version
static const char *swiftVersionChar();
//! System's name and version + info if dev.environment / beta
static const QString &versionStringDevBetaInfo();
//! Version major
static int versionMajor();
@@ -90,51 +81,33 @@ namespace BlackMisc
//! Beta test?
static bool isBetaTest();
//! Can run in dev. environment
static bool canRunInDeveloperEnvironment();
//! Shipped version?
static bool isShippedVersion();
//! Running on Windows NT platform?
static bool isRunningOnWindowsNtPlatform();
//! Running in dev.environment, so on a programmers machine
static bool isRunningInDeveloperEnvironment();
//! Use development setup?
static bool useDevelopmentSetup();
//! Beta / dev.environment?
static bool isRunningInBetaOrDeveloperEnvironment();
//! Application directory where current application is located
static const QString &getApplicationDir();
//! Where resource files (static DB files, ...) etc are located
static const QString &getSwiftResourceDir();
//! Private resource dir for developer's own resource files
static QString getSwiftPrivateResourceDir();
//! Where static DB files are located
static const QString &getSwiftStaticDbFilesDir();
//! Where images are located
static const QString &getImagesDir();
//! Dump all env.variables
static QString getEnvironmentVariables(const QString &separator = QString("\n"));
//! Info string about compilation
static const QString &compiledWithInfo(bool shortVersion = true);
//! Env.information
static QString environmentInfo(const QString &separator = QString("\n"));
//! Whole info
static QString convertToQString(const QString &separator = QString("\n"));
//! Environment variable indicating "dev.environment"
static const QString &envVarDevelopment();
//! Environment variable private resources directory
static const QString &envVarPrivateSetupDir();
//! Executable name for swift GUI, no(!) appendix
static const QString &swiftGuiExecutableName();
@@ -147,6 +120,12 @@ namespace BlackMisc
//! swift team default servers for DB, bootstrap etc.
static const QStringList &swiftTeamDefaultServers();
//! End of lifetime
static const QDateTime &getEol();
//! Lifetime ended?
static bool isLifetimeExpired();
private:
//! Constructor
CProject() {}
@@ -156,17 +135,6 @@ namespace BlackMisc
//! Split version
static int getMajorMinor(int index);
// --------------- env.vars. -------------
// centralized in one place here so we have an overview
//! Value
//! \return true|false
static QString envVarDevelopmentValue();
//! Value
//! \return directory path
static QString envVarPrivateSetupDirValue();
};
} // ns

View File

@@ -30,6 +30,7 @@ int main(int argc, char *argv[])
CGuiApplication a("swift core", CIcons::swiftNova24());
a.addWindowStateOption();
a.addDBusAddressOption();
a.addVatlibOptions();
a.addParserOption({{"r", "start"}, QCoreApplication::translate("main", "Start the server.")});
a.addParserOption({{"c", "coreaudio"}, QCoreApplication::translate("main", "Audio in core.")});
if (!a.parse()) { return EXIT_FAILURE; }

View File

@@ -137,7 +137,6 @@
</widget>
<addaction name="menuTemplates"/>
<addaction name="menu_InternalsMetatypes"/>
<addaction name="menu_InternalsEnvVars"/>
<addaction name="menu_InternalsSetup"/>
<addaction name="menu_InternalsCompileInfo"/>
</widget>

View File

@@ -12,7 +12,7 @@
#include "blackgui/components/dbmappingcomponent.h"
#include "blackgui/components/datainfoareacomponent.h"
#include "blackgui/components/logcomponent.h"
#include "blackgui/stylesheetutility.h"
#include "blackgui/guiapplication.h"
#include "blackmisc/datacache.h"
#include "blackmisc/settingscache.h"
#include "blackcore/webdataservices.h"
@@ -37,7 +37,7 @@ void CSwiftData::ps_onMenuClicked()
QObject *sender = QObject::sender();
if (sender == this->ui->menu_FileReloadStyleSheets)
{
CStyleSheetUtility::instance().read();
sGui->reloadStyleSheets();
}
else if (sender == this->ui->menu_WindowFont)
{
@@ -129,13 +129,7 @@ void CSwiftData::ps_onMenuClicked()
}
else if (sender == this->ui->menu_InternalsCompileInfo)
{
QString project(CProject::convertToQString("\n"));
this->ui->comp_MainInfoArea->getLogComponent()->appendPlainTextToConsole(project);
this->displayConsole();
}
else if (sender == this->ui->menu_InternalsEnvVars)
{
QString project(CProject::getEnvironmentVariables());
QString project(sGui->convertToQString("\n"));
this->ui->comp_MainInfoArea->getLogComponent()->appendPlainTextToConsole(project);
this->displayConsole();
}
@@ -159,7 +153,7 @@ void CSwiftData::initDynamicMenus()
Q_ASSERT_X(this->ui->comp_MainInfoArea->getDataInfoAreaComponent(), Q_FUNC_INFO, "Missing DB info area");
this->ui->menu_Mapping->addAction(CIcons::database16(), "Load all DB data", this->ui->comp_MainInfoArea->getDataInfoAreaComponent(), SLOT(requestUpdateOfAllDbData()));
this->ui->menu_Mapping->addAction(CIcons::load16(), "Load DB test data from disk", this->ui->comp_MainInfoArea->getDataInfoAreaComponent(), SLOT(readDbDataFromResourceDir()));
if (CProject::isRunningInDeveloperEnvironment())
if (sGui->isRunningInDeveloperEnvironment())
{
this->ui->menu_Mapping->addAction(CIcons::save16(), "Save DB test data to disk", this->ui->comp_MainInfoArea->getDataInfoAreaComponent(), SLOT(writeDbDataToResourceDir()));
}

View File

@@ -221,7 +221,7 @@
<x>0</x>
<y>0</y>
<width>350</width>
<height>20</height>
<height>21</height>
</rect>
</property>
<property name="sizePolicy">
@@ -271,7 +271,6 @@
</property>
<addaction name="menu_Internals"/>
<addaction name="menu_InternalsMetatypes"/>
<addaction name="menu_InternalsEnvVars"/>
<addaction name="menu_InternalsSetup"/>
<addaction name="menu_InternalsCompileInfo"/>
</widget>

View File

@@ -19,6 +19,7 @@ CSwiftGuiStdApplication::CSwiftGuiStdApplication() : CGuiApplication("swift pilo
this->addParserOption(this->m_cmdFacadeMode);
this->addWindowModeOption();
this->addDBusAddressOption();
this->addVatlibOptions();
}
bool CSwiftGuiStdApplication::startHookIn()
@@ -28,7 +29,7 @@ bool CSwiftGuiStdApplication::startHookIn()
const QString dBusAddress(this->getCmdDBusAddressValue());
if (this->isParserOptionSet(this->m_cmdFacadeMode))
{
const QString v(this->getParserOptionValue(this->m_cmdFacadeMode));
const QString v(this->getParserValue(this->m_cmdFacadeMode));
coreMode = CoreModes::stringToCoreMode(v);
}

View File

@@ -38,10 +38,6 @@ void SwiftGuiStd::init()
this->setVisible(false); // hide all, so no flashing windows during init
sGui->initMainApplicationWindow(this);
// init window
this->setWindowTitle(CProject::versionStringDevBetaInfo());
this->initStyleSheet();
// with frameless window, we shift menu and statusbar into central widget
// http://stackoverflow.com/questions/18316710/frameless-and-transparent-window-qt5
if (this->isFrameless())
@@ -110,7 +106,7 @@ void SwiftGuiStd::init()
this->initMenuIcons();
// info
this->ui->comp_MainInfoArea->getLogComponent()->appendPlainTextToConsole(CProject::swiftVersionString());
this->ui->comp_MainInfoArea->getLogComponent()->appendPlainTextToConsole(sGui->swiftVersionString());
this->ui->comp_MainInfoArea->getLogComponent()->appendPlainTextToConsole(CProject::compiledWithInfo());
// update timers

View File

@@ -10,7 +10,7 @@
#include "swiftguistd.h"
#include "ui_swiftguistd.h"
#include "blackcore/application.h"
#include "blackgui/stylesheetutility.h"
#include "blackgui/guiapplication.h"
#include "blackgui/components/settingscomponent.h"
#include "blackgui/components/logcomponent.h"
#include "blackmisc/statusmessagelist.h"
@@ -58,7 +58,7 @@ void SwiftGuiStd::ps_onMenuClicked()
}
else if (sender == this->ui->menu_FileReloadStyleSheets)
{
CStyleSheetUtility::instance().read();
sGui->reloadStyleSheets();
}
else if (sender == this->ui->menu_WindowFont)
{
@@ -136,13 +136,7 @@ void SwiftGuiStd::ps_onMenuClicked()
}
else if (sender == this->ui->menu_InternalsCompileInfo)
{
QString project(CProject::convertToQString("\n"));
this->ui->comp_MainInfoArea->getLogComponent()->appendPlainTextToConsole(project);
this->displayConsole();
}
else if (sender == this->ui->menu_InternalsEnvVars)
{
QString project(CProject::getEnvironmentVariables());
QString project(sGui->convertToQString("\n"));
this->ui->comp_MainInfoArea->getLogComponent()->appendPlainTextToConsole(project);
this->displayConsole();
}

View File

@@ -163,7 +163,7 @@ void CSwiftLauncher::initDBusGui()
void CSwiftLauncher::initVersion()
{
this->ui->le_CurrentVersion->setText(CProject::versionStringDevBetaInfo());
this->ui->le_CurrentVersion->setText(sGui->versionStringDevBetaInfo());
}
void CSwiftLauncher::initLogDisplay()