mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-06 10:15:38 +08:00
Ref T195, improved core UI
* removed start/stop * added restart * use DBus UI component * show info about audio
This commit is contained in:
@@ -33,7 +33,6 @@ int main(int argc, char *argv[])
|
||||
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.parseAndSynchronizeSetup()) { return EXIT_FAILURE; }
|
||||
|
||||
|
||||
@@ -8,13 +8,14 @@
|
||||
*/
|
||||
|
||||
#include "swiftcore.h"
|
||||
#include "blackcore/corefacade.h"
|
||||
#include "blackgui/components/commandinput.h"
|
||||
#include "blackgui/components/coreinfoareacomponent.h"
|
||||
#include "blackgui/components/coresettingsdialog.h"
|
||||
#include "blackgui/components/logcomponent.h"
|
||||
#include "blackgui/guiapplication.h"
|
||||
#include "blackgui/stylesheetutility.h"
|
||||
#include "blackcore/context/contextaudio.h"
|
||||
#include "blackcore/corefacade.h"
|
||||
#include "blackmisc/dbusserver.h"
|
||||
#include "blackmisc/icons.h"
|
||||
#include "blackmisc/loghandler.h"
|
||||
@@ -41,6 +42,7 @@ CSwiftCore::CSwiftCore(QWidget *parent) :
|
||||
CIdentifiable(this),
|
||||
ui(new Ui::CSwiftCore)
|
||||
{
|
||||
Q_ASSERT(sGui);
|
||||
ui->setupUi(this);
|
||||
sGui->initMainApplicationWindow(this);
|
||||
const QString name(sGui->getApplicationNameAndVersion());
|
||||
@@ -51,19 +53,26 @@ CSwiftCore::CSwiftCore(QWidget *parent) :
|
||||
m_mwaOverlayFrame = nullptr;
|
||||
m_mwaStatusBar = nullptr;
|
||||
|
||||
initLogDisplay();
|
||||
initSlots();
|
||||
initStyleSheet();
|
||||
initDBusMode();
|
||||
initMenus();
|
||||
connect(ui->pb_Restart, &QPushButton::clicked, this, &CSwiftCore::restart);
|
||||
connect(sGui, &CGuiApplication::styleSheetsChanged, this, &CSwiftCore::onStyleSheetsChanged);
|
||||
|
||||
this->initLogDisplay();
|
||||
this->initStyleSheet();
|
||||
this->initMenus();
|
||||
this->initAudio();
|
||||
|
||||
// log
|
||||
CStatusMessage m = CStatusMessage(this).info("Cmd: " + CGuiApplication::arguments().join(" "));
|
||||
this->appendLogMessage(m);
|
||||
|
||||
// command line
|
||||
ui->lep_CommandLineInput->setIdentifier(this->identifier());
|
||||
connect(ui->lep_CommandLineInput, &CCommandInput::commandEntered, sGui->getCoreFacade(), &CCoreFacade::parseCommandLine);
|
||||
|
||||
if (sGui->isParserOptionSet("start")) { startCore(sGui->getCmdDBusAddressValue()); }
|
||||
}
|
||||
|
||||
CSwiftCore::~CSwiftCore()
|
||||
{ }
|
||||
|
||||
void CSwiftCore::initStyleSheet()
|
||||
{
|
||||
const QString s = sGui->getStyleSheetUtility().styles(
|
||||
@@ -76,56 +85,12 @@ void CSwiftCore::initStyleSheet()
|
||||
this->setStyleSheet(s);
|
||||
}
|
||||
|
||||
void CSwiftCore::initDBusMode()
|
||||
{
|
||||
const QString dBusAddress(sGui->getCmdDBusAddressValue());
|
||||
if (dBusAddress.startsWith(CDBusServer::sessionBusAddress()))
|
||||
{
|
||||
ui->rb_SessionBus->setChecked(true);
|
||||
}
|
||||
else if (dBusAddress.startsWith(CDBusServer::systemBusAddress()))
|
||||
{
|
||||
ui->rb_SystemBus->setChecked(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->rb_P2PBus->setChecked(true);
|
||||
ui->le_P2PAddress->setText(dBusAddress);
|
||||
}
|
||||
}
|
||||
|
||||
CSwiftCore::~CSwiftCore()
|
||||
{ }
|
||||
|
||||
void CSwiftCore::ps_startCorePressed()
|
||||
{
|
||||
startCore(getDBusAddress());
|
||||
}
|
||||
|
||||
void CSwiftCore::ps_stopCorePressed()
|
||||
{
|
||||
stopCore();
|
||||
}
|
||||
|
||||
void CSwiftCore::ps_appendLogMessage(const CStatusMessage &message)
|
||||
void CSwiftCore::appendLogMessage(const CStatusMessage &message)
|
||||
{
|
||||
ui->comp_InfoArea->getLogComponent()->appendStatusMessageToList(message);
|
||||
}
|
||||
|
||||
void CSwiftCore::ps_p2pModeToggled(bool checked)
|
||||
{
|
||||
if (checked)
|
||||
{
|
||||
ui->le_P2PAddress->setEnabled(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->le_P2PAddress->setText(QString());
|
||||
ui->le_P2PAddress->setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
void CSwiftCore::ps_showSettingsDialog()
|
||||
void CSwiftCore::showSettingsDialog()
|
||||
{
|
||||
if (!m_settingsDialog)
|
||||
{
|
||||
@@ -134,19 +99,11 @@ void CSwiftCore::ps_showSettingsDialog()
|
||||
m_settingsDialog->show();
|
||||
}
|
||||
|
||||
void CSwiftCore::ps_onStyleSheetsChanged()
|
||||
void CSwiftCore::onStyleSheetsChanged()
|
||||
{
|
||||
this->initStyleSheet();
|
||||
}
|
||||
|
||||
void CSwiftCore::initSlots()
|
||||
{
|
||||
connect(ui->pb_StartCore, &QPushButton::clicked, this, &CSwiftCore::ps_startCorePressed);
|
||||
connect(ui->pb_StopCore, &QPushButton::clicked, this, &CSwiftCore::ps_stopCorePressed);
|
||||
connect(ui->rb_P2PBus, &QRadioButton::toggled, this, &CSwiftCore::ps_p2pModeToggled);
|
||||
connect(sGui, &CGuiApplication::styleSheetsChanged, this, &CSwiftCore::ps_onStyleSheetsChanged);
|
||||
}
|
||||
|
||||
void CSwiftCore::initLogDisplay()
|
||||
{
|
||||
m_mwaLogComponent->showDetails(false);
|
||||
@@ -155,7 +112,7 @@ void CSwiftCore::initLogDisplay()
|
||||
auto logHandler = CLogHandler::instance()->handlerForPattern(
|
||||
CLogPattern().withSeverityAtOrAbove(CStatusMessage::SeverityInfo)
|
||||
);
|
||||
logHandler->subscribe(this, &CSwiftCore::ps_appendLogMessage);
|
||||
logHandler->subscribe(this, &CSwiftCore::appendLogMessage);
|
||||
ui->comp_InfoArea->getLogComponent()->showFilterDialog(); // add a filter dialog
|
||||
}
|
||||
|
||||
@@ -164,36 +121,40 @@ void CSwiftCore::initMenus()
|
||||
sGui->addMenuFile(*ui->menu_File);
|
||||
sGui->addMenuWindow(*ui->menu_Window);
|
||||
sGui->addMenuHelp(*ui->menu_Help);
|
||||
connect(ui->menu_SettingsDialog, &QAction::triggered, this, &CSwiftCore::ps_showSettingsDialog);
|
||||
connect(ui->menu_SettingsDialog, &QAction::triggered, this, &CSwiftCore::showSettingsDialog);
|
||||
}
|
||||
|
||||
void CSwiftCore::startCore(const QString &dBusAdress)
|
||||
void CSwiftCore::initAudio()
|
||||
{
|
||||
if (dBusAdress.isEmpty()) { return; }
|
||||
Q_ASSERT_X(sGui, Q_FUNC_INFO, "Missing sGui");
|
||||
Q_ASSERT_X(sGui->getCoreFacade(), Q_FUNC_INFO, "Missing facade");
|
||||
|
||||
ui->pb_StartCore->setEnabled(false);
|
||||
ui->pb_StopCore->setEnabled(true);
|
||||
ui->gb_DBusMode->setDisabled(true);
|
||||
sGui->processEventsToRefreshGui();
|
||||
if (!sGui->getIContextAudio()) { return; }
|
||||
ui->lbl_AudioRunsWhere->setText(sGui->getIContextAudio()->audioRunsWhereInfo());
|
||||
if (sGui->getIContextAudio()->isUsingImplementingObject())
|
||||
{
|
||||
ui->rb_AudioOnCore->setChecked(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->rb_AudioOnGui->setChecked(true);
|
||||
}
|
||||
}
|
||||
|
||||
void CSwiftCore::stopCore()
|
||||
void CSwiftCore::restart()
|
||||
{
|
||||
ui->pb_StartCore->setEnabled(true);
|
||||
ui->pb_StopCore->setEnabled(false);
|
||||
ui->gb_DBusMode->setDisabled(false);
|
||||
sGui->processEventsToRefreshGui();
|
||||
sGui->exit();
|
||||
ui->pb_Restart->setEnabled(false);
|
||||
const QStringList args = this->getRestartCmdArgs();
|
||||
sGui->restartApplication(args, { "--coreaudio" });
|
||||
}
|
||||
|
||||
QString CSwiftCore::getDBusAddress() const
|
||||
QString CSwiftCore::getAudioCmdFromRadioButtons() const
|
||||
{
|
||||
if (ui->rb_SessionBus->isChecked()) { return CDBusServer::sessionBusAddress(); }
|
||||
if (ui->rb_SystemBus->isChecked()) { return CDBusServer::systemBusAddress(); }
|
||||
if (ui->rb_P2PBus->isChecked()) { return CDBusServer::normalizeAddress(ui->le_P2PAddress->text()); }
|
||||
|
||||
Q_ASSERT_X(false, Q_FUNC_INFO, "Wrong DBus address");
|
||||
if (ui->rb_AudioOnCore->isChecked()) { return "--coreaudio"; }
|
||||
return "";
|
||||
}
|
||||
|
||||
QStringList CSwiftCore::getRestartCmdArgs() const
|
||||
{
|
||||
const QString coreAudio = this->getAudioCmdFromRadioButtons();
|
||||
QStringList cmds = ui->comp_DBusSelector->getDBusCmdLineArgs();
|
||||
if (!coreAudio.isEmpty()) { cmds.append(coreAudio); }
|
||||
return cmds;
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
|
||||
/* Copyright (C) 2015
|
||||
* swift project Community / Contributors
|
||||
*
|
||||
@@ -12,6 +13,7 @@
|
||||
#ifndef SWIFTCORE_H
|
||||
#define SWIFTCORE_H
|
||||
|
||||
#include "blackcore/coremodeenums.h"
|
||||
#include "blackgui/mainwindowaccess.h"
|
||||
#include "blackgui/systemtraywindow.h"
|
||||
#include "blackmisc/identifiable.h"
|
||||
@@ -43,34 +45,35 @@ public:
|
||||
//! Destructor
|
||||
virtual ~CSwiftCore();
|
||||
|
||||
private slots:
|
||||
//! \name PushButton slots
|
||||
//! @{
|
||||
void ps_startCorePressed();
|
||||
void ps_stopCorePressed();
|
||||
void ps_appendLogMessage(const BlackMisc::CStatusMessage &message);
|
||||
void ps_p2pModeToggled(bool checked);
|
||||
//! @}
|
||||
|
||||
//! Show the settings dialog
|
||||
void ps_showSettingsDialog();
|
||||
|
||||
//! Style sheet has changed
|
||||
virtual void ps_onStyleSheetsChanged();
|
||||
|
||||
private:
|
||||
//! \name Init
|
||||
//! @{
|
||||
void initSlots();
|
||||
void initLogDisplay();
|
||||
void initStyleSheet();
|
||||
void initDBusMode();
|
||||
void initMenus();
|
||||
void initAudio();
|
||||
//! @}
|
||||
|
||||
void startCore(const QString &dBusAdress);
|
||||
void stopCore();
|
||||
QString getDBusAddress() const;
|
||||
//! Add a message to log UI
|
||||
void appendLogMessage(const BlackMisc::CStatusMessage &message);
|
||||
|
||||
//! Toggled P2P mode
|
||||
void p2pModeToggled(bool checked);
|
||||
|
||||
//! Show the settings dialog
|
||||
void showSettingsDialog();
|
||||
|
||||
//! Style sheet has changed
|
||||
virtual void onStyleSheetsChanged();
|
||||
|
||||
//! Restart with new arguments
|
||||
void restart();
|
||||
|
||||
//! Core mode from radio buttons
|
||||
QString getAudioCmdFromRadioButtons() const;
|
||||
|
||||
//! Restart CMD args
|
||||
QStringList getRestartCmdArgs() const;
|
||||
|
||||
QScopedPointer<BlackGui::Components::CCoreSettingsDialog> m_settingsDialog;
|
||||
QScopedPointer<Ui::CSwiftCore> ui;
|
||||
|
||||
@@ -6,55 +6,29 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>460</width>
|
||||
<height>382</height>
|
||||
<width>450</width>
|
||||
<height>550</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>450</width>
|
||||
<height>550</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>swiftcore</string>
|
||||
<string>swiftcore UI</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="qw_MainWidget">
|
||||
<layout class="QGridLayout" name="gl_Main">
|
||||
<item row="1" column="2">
|
||||
<widget class="QGroupBox" name="gb_Controls">
|
||||
<property name="title">
|
||||
<string>Controls</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gl_Controls">
|
||||
<item row="0" column="1">
|
||||
<widget class="QPushButton" name="pb_StartCore">
|
||||
<property name="styleSheet">
|
||||
<string notr="true">/** Main window **/
|
||||
QTextEdit {
|
||||
background-color: DimGray;
|
||||
}</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Start</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QPushButton" name="pb_StopCore">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">/** Main window **/
|
||||
QTextEdit {
|
||||
background-color: DimGray;
|
||||
}</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Stop</string>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<property name="topMargin">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<item row="5" column="0" colspan="3">
|
||||
<widget class="BlackGui::Components::CCommandInput" name="lep_CommandLineInput"/>
|
||||
</item>
|
||||
<item row="0" column="0" colspan="3">
|
||||
<widget class="BlackGui::Components::CInfoBarStatusComponent" name="comp_InfoBarStatus" native="true">
|
||||
@@ -81,54 +55,134 @@ QTextEdit {
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="2">
|
||||
<widget class="QGroupBox" name="gb_DBusMode">
|
||||
<property name="title">
|
||||
<string>DBus Mode</string>
|
||||
<item row="4" column="0" colspan="3">
|
||||
<widget class="BlackGui::Components::CCoreInfoAreaComponent" name="comp_InfoArea" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="MinimumExpanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gl_DBusMode">
|
||||
<item row="0" column="0">
|
||||
<widget class="QRadioButton" name="rb_SessionBus">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>200</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QGroupBox" name="gb_Audio">
|
||||
<property name="title">
|
||||
<string>Audio</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="vl_Audio">
|
||||
<property name="leftMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="lbl_AudioRunsWhere">
|
||||
<property name="text">
|
||||
<string>Session</string>
|
||||
<string><Audio is where></string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="rb_AudioOnCore">
|
||||
<property name="text">
|
||||
<string>on core side</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="rb_AudioOnGui">
|
||||
<property name="text">
|
||||
<string>on GUI side</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QRadioButton" name="rb_P2PBus">
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="2" alignment="Qt::AlignBottom">
|
||||
<widget class="QGroupBox" name="gb_Controls">
|
||||
<property name="title">
|
||||
<string>Control</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="vl_Controls">
|
||||
<property name="leftMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<item alignment="Qt::AlignRight">
|
||||
<widget class="QPushButton" name="pb_Restart">
|
||||
<property name="styleSheet">
|
||||
<string notr="true">/** Main window **/
|
||||
QTextEdit {
|
||||
background-color: DimGray;
|
||||
}</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>P2P</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QRadioButton" name="rb_SystemBus">
|
||||
<property name="text">
|
||||
<string>System</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="3">
|
||||
<widget class="QLineEdit" name="le_P2PAddress">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="placeholderText">
|
||||
<string>P2P address</string>
|
||||
<string>restart</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0" colspan="3">
|
||||
<widget class="BlackGui::Components::CCommandInput" name="lep_CommandLineInput"/>
|
||||
</item>
|
||||
<item row="3" column="0" colspan="3">
|
||||
<widget class="BlackGui::Components::CCoreInfoAreaComponent" name="comp_InfoArea" native="true"/>
|
||||
<item row="1" column="0" rowspan="2" colspan="2">
|
||||
<widget class="QGroupBox" name="gb_DBus">
|
||||
<property name="title">
|
||||
<string>DBus Mode</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="vl_DBus">
|
||||
<property name="leftMargin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="BlackGui::Components::CDBusServerAddressSelector" name="comp_DBusSelector">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
@@ -137,7 +191,7 @@ QTextEdit {
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>460</width>
|
||||
<width>450</width>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
@@ -179,6 +233,12 @@ QTextEdit {
|
||||
</widget>
|
||||
<layoutdefault spacing="6" margin="11"/>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>BlackGui::Components::CDBusServerAddressSelector</class>
|
||||
<extends>QFrame</extends>
|
||||
<header>blackgui/components/dbusserveraddressselector.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>BlackGui::CSystemTrayWindow</class>
|
||||
<extends>QMainWindow</extends>
|
||||
|
||||
Reference in New Issue
Block a user