mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-25 18:25:42 +08:00
refactor: Remove custom audio menu
This commit is contained in:
@@ -26,7 +26,6 @@
|
|||||||
#include "gui/guiapplication.h"
|
#include "gui/guiapplication.h"
|
||||||
#include "gui/guiutility.h"
|
#include "gui/guiutility.h"
|
||||||
#include "gui/led.h"
|
#include "gui/led.h"
|
||||||
#include "misc/audio/audioutils.h"
|
|
||||||
#include "misc/network/server.h"
|
#include "misc/network/server.h"
|
||||||
#include "misc/simulation/simulatorplugininfo.h"
|
#include "misc/simulation/simulatorplugininfo.h"
|
||||||
|
|
||||||
@@ -47,9 +46,6 @@ namespace swift::gui::components
|
|||||||
this->initLeds();
|
this->initLeds();
|
||||||
this->adjustTextSize();
|
this->adjustTextSize();
|
||||||
|
|
||||||
ui->lbl_Audio->setContextMenuPolicy(Qt::CustomContextMenu);
|
|
||||||
connect(ui->lbl_Audio, &QLabel::customContextMenuRequested, this,
|
|
||||||
&CInfoBarStatusComponent::onCustomAudioContextMenuRequested);
|
|
||||||
connect(ui->comp_XpdrMode, &CTransponderModeComponent::changed, this,
|
connect(ui->comp_XpdrMode, &CTransponderModeComponent::changed, this,
|
||||||
&CInfoBarStatusComponent::transponderModeChanged);
|
&CInfoBarStatusComponent::transponderModeChanged);
|
||||||
|
|
||||||
@@ -193,31 +189,6 @@ namespace swift::gui::components
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CInfoBarStatusComponent::onCustomAudioContextMenuRequested(const QPoint &position)
|
|
||||||
{
|
|
||||||
const QWidget *sender = qobject_cast<QWidget *>(QWidget::sender());
|
|
||||||
Q_ASSERT_X(sender, Q_FUNC_INFO, "Missing sender");
|
|
||||||
const QPoint globalPosition = sender->mapToGlobal(position);
|
|
||||||
|
|
||||||
QMenu menuAudio(this);
|
|
||||||
menuAudio.addAction("Toogle mute");
|
|
||||||
|
|
||||||
if (CBuildConfig::isRunningOnWindowsNtPlatform()) { menuAudio.addAction("Mixer"); }
|
|
||||||
|
|
||||||
const QAction *selectedItem = menuAudio.exec(globalPosition);
|
|
||||||
if (selectedItem)
|
|
||||||
{
|
|
||||||
// http://forum.technical-assistance.co.uk/sndvol32exe-command-line-parameters-vt1348.html
|
|
||||||
const QList<QAction *> actions = menuAudio.actions();
|
|
||||||
if (selectedItem == actions.at(0))
|
|
||||||
{
|
|
||||||
// toggle MUTED
|
|
||||||
sGui->getCContextAudioBase()->setOutputMute(!sGui->getCContextAudioBase()->isOutputMuted());
|
|
||||||
}
|
|
||||||
else if (actions.size() > 1 && selectedItem == actions.at(1)) { startWindowsMixer(); }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void CInfoBarStatusComponent::onOutputMuteChanged(bool muted)
|
void CInfoBarStatusComponent::onOutputMuteChanged(bool muted)
|
||||||
{
|
{
|
||||||
const bool on = !muted && isAudioAvailableAndNotMuted(); // make sure audio is started
|
const bool on = !muted && isAudioAvailableAndNotMuted(); // make sure audio is started
|
||||||
|
|||||||
@@ -80,9 +80,6 @@ namespace swift::gui::components
|
|||||||
void onNetworkConnectionChanged(const swift::misc::network::CConnectionStatus &from,
|
void onNetworkConnectionChanged(const swift::misc::network::CConnectionStatus &from,
|
||||||
const swift::misc::network::CConnectionStatus &to);
|
const swift::misc::network::CConnectionStatus &to);
|
||||||
|
|
||||||
//! Context menu requested
|
|
||||||
void onCustomAudioContextMenuRequested(const QPoint &position);
|
|
||||||
|
|
||||||
//! Output mute changed
|
//! Output mute changed
|
||||||
void onOutputMuteChanged(bool muted);
|
void onOutputMuteChanged(bool muted);
|
||||||
|
|
||||||
|
|||||||
@@ -11,8 +11,6 @@ add_library(misc SHARED
|
|||||||
audio/audiodeviceinfolist.h
|
audio/audiodeviceinfolist.h
|
||||||
audio/audiosettings.cpp
|
audio/audiosettings.cpp
|
||||||
audio/audiosettings.h
|
audio/audiosettings.h
|
||||||
audio/audioutils.cpp
|
|
||||||
audio/audioutils.h
|
|
||||||
audio/notificationsounds.cpp
|
audio/notificationsounds.cpp
|
||||||
audio/notificationsounds.h
|
audio/notificationsounds.h
|
||||||
audio/registermetadataaudio.cpp
|
audio/registermetadataaudio.cpp
|
||||||
|
|||||||
@@ -1,22 +0,0 @@
|
|||||||
// SPDX-FileCopyrightText: Copyright (C) 2013 swift Project Community / Contributors
|
|
||||||
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
|
|
||||||
|
|
||||||
#include "misc/audio/audioutils.h"
|
|
||||||
|
|
||||||
#include <QAudioDevice>
|
|
||||||
#include <QMediaDevices>
|
|
||||||
#include <QProcess>
|
|
||||||
|
|
||||||
#include "config/buildconfig.h"
|
|
||||||
|
|
||||||
using namespace swift::config;
|
|
||||||
|
|
||||||
namespace swift::misc::audio
|
|
||||||
{
|
|
||||||
bool startWindowsMixer()
|
|
||||||
{
|
|
||||||
if (!CBuildConfig::isRunningOnWindowsNtPlatform()) { return false; }
|
|
||||||
return QProcess::startDetached("SndVol.exe");
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace swift::misc::audio
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
// SPDX-FileCopyrightText: Copyright (C) 2015 swift Project Community / Contributors
|
|
||||||
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
|
|
||||||
|
|
||||||
//! \file
|
|
||||||
|
|
||||||
#ifndef SWIFT_MISC_AUDIO_UTILS_H
|
|
||||||
#define SWIFT_MISC_AUDIO_UTILS_H
|
|
||||||
|
|
||||||
#include "misc/swiftmiscexport.h"
|
|
||||||
|
|
||||||
namespace swift::misc::audio
|
|
||||||
{
|
|
||||||
//! Start the Windows mixer
|
|
||||||
SWIFT_MISC_EXPORT bool startWindowsMixer();
|
|
||||||
} // namespace swift::misc::audio
|
|
||||||
|
|
||||||
#endif // SWIFT_MISC_AUDIO_UTILS_H
|
|
||||||
@@ -11,7 +11,6 @@
|
|||||||
#include "gui/enableforframelesswindow.h"
|
#include "gui/enableforframelesswindow.h"
|
||||||
#include "gui/guiapplication.h"
|
#include "gui/guiapplication.h"
|
||||||
#include "gui/guiutility.h"
|
#include "gui/guiutility.h"
|
||||||
#include "misc/audio/audioutils.h"
|
|
||||||
#include "misc/crashhandler.h"
|
#include "misc/crashhandler.h"
|
||||||
|
|
||||||
using namespace swift::gui;
|
using namespace swift::gui;
|
||||||
|
|||||||
Reference in New Issue
Block a user