mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-23 05:45:35 +08:00
Ref T189, UI: spacing of statusbar depending on main window size
This commit is contained in:
@@ -7,18 +7,18 @@
|
|||||||
* contained in the LICENSE file.
|
* contained in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "blackconfig/buildconfig.h"
|
#include "blackgui/components/infobarstatuscomponent.h"
|
||||||
|
#include "blackgui/guiapplication.h"
|
||||||
|
#include "blackgui/led.h"
|
||||||
#include "blackcore/context/contextapplication.h"
|
#include "blackcore/context/contextapplication.h"
|
||||||
#include "blackcore/context/contextaudio.h"
|
#include "blackcore/context/contextaudio.h"
|
||||||
#include "blackcore/context/contextnetwork.h"
|
#include "blackcore/context/contextnetwork.h"
|
||||||
#include "blackcore/context/contextsimulator.h"
|
#include "blackcore/context/contextsimulator.h"
|
||||||
#include "blackcore/simulator.h"
|
#include "blackcore/simulator.h"
|
||||||
#include "blackgui/components/infobarstatuscomponent.h"
|
|
||||||
#include "blackgui/guiapplication.h"
|
|
||||||
#include "blackgui/led.h"
|
|
||||||
#include "blackmisc/audio/audioutils.h"
|
#include "blackmisc/audio/audioutils.h"
|
||||||
#include "blackmisc/network/server.h"
|
#include "blackmisc/network/server.h"
|
||||||
#include "blackmisc/simulation/simulatorplugininfo.h"
|
#include "blackmisc/simulation/simulatorplugininfo.h"
|
||||||
|
#include "blackconfig/buildconfig.h"
|
||||||
#include "ui_infobarstatuscomponent.h"
|
#include "ui_infobarstatuscomponent.h"
|
||||||
|
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
@@ -81,6 +81,7 @@ namespace BlackGui
|
|||||||
|
|
||||||
void CInfoBarStatusComponent::initLeds()
|
void CInfoBarStatusComponent::initLeds()
|
||||||
{
|
{
|
||||||
|
this->updateSpacing();
|
||||||
CLedWidget::LedShape shape = CLedWidget::Circle;
|
CLedWidget::LedShape shape = CLedWidget::Circle;
|
||||||
ui->led_DBus->setValues(CLedWidget::Yellow, CLedWidget::Black, shape, "DBus connected", "DBus disconnected", 14);
|
ui->led_DBus->setValues(CLedWidget::Yellow, CLedWidget::Black, shape, "DBus connected", "DBus disconnected", 14);
|
||||||
ui->led_Network->setValues(CLedWidget::Yellow, CLedWidget::Black, shape, "Network connected", "Network disconnected", 14);
|
ui->led_Network->setValues(CLedWidget::Yellow, CLedWidget::Black, shape, "Network connected", "Network disconnected", 14);
|
||||||
@@ -103,9 +104,17 @@ namespace BlackGui
|
|||||||
ui->led_DBus->setOnToolTip(tooltip);
|
ui->led_DBus->setOnToolTip(tooltip);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CInfoBarStatusComponent::setSpacing(int spacing)
|
||||||
|
{
|
||||||
|
if (this->layout())
|
||||||
|
{
|
||||||
|
this->layout()->setSpacing(spacing);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void CInfoBarStatusComponent::onSimulatorStatusChanged(int status)
|
void CInfoBarStatusComponent::onSimulatorStatusChanged(int status)
|
||||||
{
|
{
|
||||||
ISimulator::SimulatorStatus simStatus = static_cast<ISimulator::SimulatorStatus>(status);
|
const ISimulator::SimulatorStatus simStatus = static_cast<ISimulator::SimulatorStatus>(status);
|
||||||
if (simStatus.testFlag(ISimulator::Connected))
|
if (simStatus.testFlag(ISimulator::Connected))
|
||||||
{
|
{
|
||||||
// at least connected
|
// at least connected
|
||||||
@@ -140,10 +149,9 @@ namespace BlackGui
|
|||||||
this->onMapperReady();
|
this->onMapperReady();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CInfoBarStatusComponent::onNetworkConnectionChanged(BlackCore::INetwork::ConnectionStatus from, BlackCore::INetwork::ConnectionStatus to)
|
void CInfoBarStatusComponent::onNetworkConnectionChanged(INetwork::ConnectionStatus from, INetwork::ConnectionStatus to)
|
||||||
{
|
{
|
||||||
Q_UNUSED(from);
|
Q_UNUSED(from);
|
||||||
|
|
||||||
switch (to)
|
switch (to)
|
||||||
{
|
{
|
||||||
case INetwork::Disconnected:
|
case INetwork::Disconnected:
|
||||||
@@ -190,7 +198,7 @@ namespace BlackGui
|
|||||||
}
|
}
|
||||||
else if (actions.size() > 1 && selectedItem == actions.at(1))
|
else if (actions.size() > 1 && selectedItem == actions.at(1))
|
||||||
{
|
{
|
||||||
BlackMisc::Audio::startWindowsMixer();
|
Audio::startWindowsMixer();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -236,5 +244,13 @@ namespace BlackGui
|
|||||||
ui->led_Network->setOffToolTip("No network/internet access");
|
ui->led_Network->setOffToolTip("No network/internet access");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CInfoBarStatusComponent::updateSpacing()
|
||||||
|
{
|
||||||
|
if (!sGui || !sGui->mainApplicationWindow()) { return; }
|
||||||
|
const int w = sGui->mainApplicationWindow()->width();
|
||||||
|
const int s = (w >= 400) ? 6 : 2;
|
||||||
|
this->setSpacing(s);
|
||||||
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|||||||
@@ -50,6 +50,9 @@ namespace BlackGui
|
|||||||
//! Tooltip for DBus
|
//! Tooltip for DBus
|
||||||
void setDBusTooltip(const QString &tooltip);
|
void setDBusTooltip(const QString &tooltip);
|
||||||
|
|
||||||
|
//! Set the spacing
|
||||||
|
void setSpacing(int spacing);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QScopedPointer<Ui::CInfoBarStatusComponent> ui;
|
QScopedPointer<Ui::CInfoBarStatusComponent> ui;
|
||||||
BlackCore::CActionBind m_actionPtt { "/Voice/Activate push-to-talk", BlackMisc::CIcons::radio16(), this, &CInfoBarStatusComponent::onPttChanged };
|
BlackCore::CActionBind m_actionPtt { "/Voice/Activate push-to-talk", BlackMisc::CIcons::radio16(), this, &CInfoBarStatusComponent::onPttChanged };
|
||||||
@@ -74,6 +77,9 @@ namespace BlackGui
|
|||||||
|
|
||||||
//! Internet accessible?
|
//! Internet accessible?
|
||||||
void onInternetAccessibleChanged(bool access);
|
void onInternetAccessibleChanged(bool access);
|
||||||
|
|
||||||
|
//! Update spacing based on main window size
|
||||||
|
void updateSpacing();
|
||||||
};
|
};
|
||||||
} // ns
|
} // ns
|
||||||
} // ns
|
} // ns
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>226</width>
|
<width>250</width>
|
||||||
<height>20</height>
|
<height>20</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
@@ -21,7 +21,7 @@
|
|||||||
</property>
|
</property>
|
||||||
<layout class="QHBoxLayout" name="hl_InfoBarStatus">
|
<layout class="QHBoxLayout" name="hl_InfoBarStatus">
|
||||||
<property name="spacing">
|
<property name="spacing">
|
||||||
<number>0</number>
|
<number>2</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="leftMargin">
|
<property name="leftMargin">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
@@ -164,7 +164,7 @@
|
|||||||
</property>
|
</property>
|
||||||
<property name="sizeHint" stdset="0">
|
<property name="sizeHint" stdset="0">
|
||||||
<size>
|
<size>
|
||||||
<width>40</width>
|
<width>20</width>
|
||||||
<height>20</height>
|
<height>20</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
|
|||||||
Reference in New Issue
Block a user