refs #473, own launcher subproject

* command line args for swift GUI
* removed _ from swiftgui_standard
* removed _ from swift_resources
This commit is contained in:
Klaus Basan
2015-11-05 02:50:51 +01:00
committed by Mathew Sutcliffe
parent 8e57914e67
commit 6dd66284ca
26 changed files with 346 additions and 115 deletions

View File

@@ -0,0 +1,113 @@
/* Copyright (C) 2014
* 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 "introwindow.h"
#include "ui_introwindow.h"
#include "blackcore/dbus_server.h"
#include "blackcore/settingscache.h"
#include "blackmisc/network/networkutils.h"
#include "blackmisc/project.h"
#include <QDesktopServices>
#include <QUrl>
#include <QDir>
#include <QProcess>
#include <QFileInfo>
using namespace BlackMisc;
using namespace BlackMisc::Network;
using namespace BlackCore;
using namespace BlackGui;
/*
* Constructor
*/
CIntroWindow::CIntroWindow(QWidget *parent) :
QDialog(parent, (Qt::WindowStaysOnTopHint)),
// (Qt::Tool | Qt::WindowStaysOnTopHint)),
ui(new Ui::CIntroWindow)
{
ui->setupUi(this);
this->setWindowTitle(CProject::swiftVersionStringDevInfo());
this->layout()->setSizeConstraint(QLayout::SetFixedSize);
this->ui->cb_DBusServer->addItem(CDBusServer::sessionDBusServer());
this->ui->cb_DBusServer->addItem(CDBusServer::systemDBusServer());
this->ui->cb_DBusServer->addItems(CNetworkUtils::getKnownIpAddresses());
this->ui->cb_DBusServer->setCurrentIndex(0);
}
/*
* Destructor
*/
CIntroWindow::~CIntroWindow() { }
/*
* Window mode
*/
BlackGui::CEnableForFramelessWindow::WindowMode CIntroWindow::getWindowMode() const
{
if (this->ui->rb_WindowFrameless->isChecked())
return CEnableForFramelessWindow::WindowFrameless;
else
return CEnableForFramelessWindow::WindowTool;
}
/*
* Core mode
*/
GuiModes::CoreMode CIntroWindow::getCoreMode() const
{
if (this->ui->rb_CoreExternalVoiceLocal->isChecked())
{
return GuiModes::CoreExternalAudioLocal;
}
else if (this->ui->rb_CoreInGuiProcess->isChecked())
{
return GuiModes::CoreInGuiProcess;
}
else
{
return GuiModes::CoreExternal;
}
}
/*
* DBus server address
*/
QString CIntroWindow::getDBusAddress() const
{
return this->ui->cb_DBusServer->currentText();
}
/*
* Button clicked
*/
void CIntroWindow::buttonClicked() const
{
QObject *sender = QObject::sender();
if (sender == this->ui->pb_ModelDb)
{
QDesktopServices::openUrl(QUrl("http://vatrep.vatsim-germany.org/page/index.php", QUrl::TolerantMode));
}
else if (sender == this->ui->pb_WebSite)
{
QDesktopServices::openUrl(QUrl("https://dev.vatsim-germany.org/", QUrl::TolerantMode));
}
else if (sender == this->ui->pb_SettingsDir)
{
QString path(QDir::toNativeSeparators(CSettingsCache::persistentStore()));
QDesktopServices::openUrl(QUrl("file:///" + path));
}
else if (sender == this->ui->pb_CoreStart)
{
//! \todo make fully OS independent
QString sfx = QFileInfo(QCoreApplication::applicationFilePath()).suffix();
QString core = QDir(QApplication::applicationDirPath()).filePath("swiftcore." + sfx);
QProcess::startDetached(core);
}
}

View File

@@ -0,0 +1,51 @@
/* Copyright (C) 2013
* 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.
*/
//! \file
#ifndef STDGUI_INTROWINDOW_H
#define STDGUI_INTROWINDOW_H
#include "swiftguistandard/guimodeenums.h"
#include "blackgui/enableforframelesswindow.h"
#include <QDialog>
#include <QScopedPointer>
namespace Ui { class CIntroWindow; }
//! Intro screen
class CIntroWindow : public QDialog
{
Q_OBJECT
public:
//! Constructor
explicit CIntroWindow(QWidget *parent = nullptr);
//! Destructor
~CIntroWindow();
//! Selected window mode
BlackGui::CEnableForFramelessWindow::WindowMode getWindowMode() const;
//! Get core mode
GuiModes::CoreMode getCoreMode() const;
//! select DBus address/mode
QString getDBusAddress() const;
private slots:
//! Button has been clicked
void buttonClicked() const;
private:
QScopedPointer<Ui::CIntroWindow> ui;
};
#endif // guard

View File

@@ -0,0 +1,357 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>CIntroWindow</class>
<widget class="QDialog" name="CIntroWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>250</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>swift intro screen</string>
</property>
<property name="windowIcon">
<iconset>
<normaloff>:/blackgui/icons/aircraftdeparture.png</normaloff>:/blackgui/icons/aircraftdeparture.png</iconset>
</property>
<property name="styleSheet">
<string notr="true">QWidget {
font-family: arial-rounded;
font: bold 10px;
color: yellow; /** font **/
background-color: black;
}
QPushButton {
background-color: rgba(255, 255, 0, 175);
color: black;
border-style: solid;
border-width:1px;
border-radius: 5px;
border-color: green;
margin: 3px;
padding: 3px;
}
QRadioButton {
background-color: transparent;
}
QGroupBox {
border: 2px solid yellow;
border-radius: 5px;
margin-top: 2ex; /* leave space at the top for the title */
}
QComboBox {
background-color: black;
border: 1px solid yellow;
}
QGroupBox::title {
subcontrol-origin: margin;
subcontrol-position: top left; /* position at the top center */
padding: 0 0px;
margin: 0px;
background-color: black;
}
#lbl_Icon {
max-height: 128;
max-width: 128;
}</string>
</property>
<property name="sizeGripEnabled">
<bool>false</bool>
</property>
<property name="modal">
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QGridLayout" name="gridLayout">
<property name="leftMargin">
<number>9</number>
</property>
<property name="topMargin">
<number>9</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>9</number>
</property>
<property name="spacing">
<number>9</number>
</property>
<item row="0" column="0">
<widget class="QGroupBox" name="gb_Window">
<property name="title">
<string>Window</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QRadioButton" name="rb_WindowNormal">
<property name="text">
<string>Normal</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="rb_WindowFrameless">
<property name="text">
<string>Frameless</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="1" column="0">
<widget class="QGroupBox" name="gb_Core">
<property name="title">
<string>Core</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QRadioButton" name="rb_CoreInGuiProcess">
<property name="text">
<string>Included in GUI
process</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="rb_CoreExternal">
<property name="text">
<string>External (DBus)</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="rb_CoreExternalVoiceLocal">
<property name="text">
<string>External,
voice included</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pb_CoreStart">
<property name="text">
<string>start core</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="0" column="1" rowspan="2">
<widget class="QFrame" name="fr_Info">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QVBoxLayout" name="vl_FrameInfo">
<property name="spacing">
<number>3</number>
</property>
<property name="leftMargin">
<number>2</number>
</property>
<property name="topMargin">
<number>2</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>2</number>
</property>
<item>
<widget class="QPushButton" name="pb_ModelDb">
<property name="text">
<string>Model DB</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pb_WebSite">
<property name="text">
<string>Web site</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pb_SettingsDir">
<property name="text">
<string>settings dir.</string>
</property>
</widget>
</item>
<item>
<spacer name="vs_InfoSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item row="2" column="0" colspan="2">
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
<widget class="QLabel" name="lbl_DBusServer">
<property name="text">
<string>DBus server</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="cb_DBusServer">
<property name="editable">
<bool>true</bool>
</property>
<property name="insertPolicy">
<enum>QComboBox::InsertAtTop</enum>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item>
<widget class="QDialogButtonBox" name="bb_OkCancel">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>bb_OkCancel</sender>
<signal>accepted()</signal>
<receiver>CIntroWindow</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>240</x>
<y>290</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>bb_OkCancel</sender>
<signal>rejected()</signal>
<receiver>CIntroWindow</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>240</x>
<y>290</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>pb_ModelDb</sender>
<signal>clicked()</signal>
<receiver>CIntroWindow</receiver>
<slot>buttonClicked()</slot>
<hints>
<hint type="sourcelabel">
<x>217</x>
<y>34</y>
</hint>
<hint type="destinationlabel">
<x>319</x>
<y>37</y>
</hint>
</hints>
</connection>
<connection>
<sender>pb_WebSite</sender>
<signal>clicked()</signal>
<receiver>CIntroWindow</receiver>
<slot>buttonClicked()</slot>
<hints>
<hint type="sourcelabel">
<x>238</x>
<y>75</y>
</hint>
<hint type="destinationlabel">
<x>322</x>
<y>73</y>
</hint>
</hints>
</connection>
<connection>
<sender>pb_SettingsDir</sender>
<signal>clicked()</signal>
<receiver>CIntroWindow</receiver>
<slot>buttonClicked()</slot>
<hints>
<hint type="sourcelabel">
<x>197</x>
<y>97</y>
</hint>
<hint type="destinationlabel">
<x>86</x>
<y>250</y>
</hint>
</hints>
</connection>
<connection>
<sender>pb_CoreStart</sender>
<signal>clicked()</signal>
<receiver>CIntroWindow</receiver>
<slot>buttonClicked()</slot>
<hints>
<hint type="sourcelabel">
<x>90</x>
<y>194</y>
</hint>
<hint type="destinationlabel">
<x>0</x>
<y>218</y>
</hint>
</hints>
</connection>
</connections>
<slots>
<slot>buttonClicked()</slot>
</slots>
</ui>

View File

@@ -0,0 +1,54 @@
/* Copyright (C) 2013
* 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 "swiftguistandard/guimodeenums.h"
#include "introwindow.h"
#include "blackcore/blackcorefreefunctions.h"
#include "blackgui/guiutility.h"
#include "blackmisc/blackmiscfreefunctions.h"
#include "blackmisc/logmessage.h"
#include "blackmisc/icons.h"
#include "blackmisc/project.h"
#include <QtGlobal>
#include <QProcess>
#include <QApplication>
#include <QMessageBox>
#include <QPushButton>
#include <QCommandLineParser>
using namespace BlackGui;
using namespace BlackMisc;
using namespace BlackCore;
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
CGuiUtility::initSwiftGuiApplication(a, "swiftgui", CIcons::swift24());
// Dialog to decide external or internal core
CIntroWindow intro;
intro.setWindowIcon(CIcons::swift24());
if (intro.exec() == QDialog::Rejected) { return 0; }
GuiModes::CoreMode coreMode = intro.getCoreMode();
CEnableForFramelessWindow::WindowMode windowMode = intro.getWindowMode();
QString dBusAddress(intro.getDBusAddress());
intro.close();
QString args(" --core %1 --dbus %2 --window %3");
QString exe = QDir::currentPath() + "/swiftguistd.exe" +
args.arg(GuiModes::coreModeToString(coreMode)).arg(dBusAddress).arg(CEnableForFramelessWindow::windowModeToString(windowMode));
QProcess *process = new QProcess(QCoreApplication::instance());
Q_ASSERT_X(process, Q_FUNC_INFO, "Cannot start process");
Q_UNUSED(process);
process->startDetached(exe);
return 0;
}

BIN
src/swiftlauncher/swift.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.6 KiB

View File

@@ -0,0 +1 @@
IDI_ICON1 ICON DISCARDABLE "swift.ico"

View File

@@ -0,0 +1,37 @@
load(common_pre)
QT += core dbus gui svg network xml multimedia
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = swiftlauncher
TEMPLATE = app
SOURCES += *.cpp
HEADERS += *.h
FORMS += *.ui
CONFIG += blackmisc blacksound blackinput blackcore blackgui
macx {
CONFIG += app_bundle
deployment.files = ../blackgui/qss
deployment.path = Contents/MacOS
QMAKE_BUNDLE_DATA += deployment
}
DEPENDPATH += . $$SourceRoot/src/blackmisc \
$$SourceRoot/src/blacksound \
$$SourceRoot/src/blackcore \
$$SourceRoot/src/blackgui \
$$SourceRoot/src/blackinput
INCLUDEPATH += . $$SourceRoot/src
OTHER_FILES += *.qss *.ico *.rc
RC_FILE = swift.rc
DISTFILES += swift.rc
DESTDIR = $$DestRoot/bin
load(common_post)