[vlc-commits] [Git][videolan/vlc][master] qt: move disable_volume_keys to MainCtxWin32
Steve Lhomme (@robUx4)
gitlab at videolan.org
Tue Oct 15 05:08:26 UTC 2024
Steve Lhomme pushed to branch master at VideoLAN / VLC
Commits:
9d8130ab by Pierre Lamot at 2024-10-15T04:45:42+00:00
qt: move disable_volume_keys to MainCtxWin32
it doesn't need to be exposed to the whole application
- - - - -
3 changed files:
- modules/gui/qt/maininterface/mainctx_win32.cpp
- modules/gui/qt/maininterface/mainctx_win32.hpp
- modules/gui/qt/qt.hpp
Changes:
=====================================
modules/gui/qt/maininterface/mainctx_win32.cpp
=====================================
@@ -782,14 +782,23 @@ void WinTaskbarWidget::changeThumbbarButtons( PlayerController::PlayingState i_s
MainCtxWin32::MainCtxWin32(qt_intf_t * _p_intf )
: MainCtx( _p_intf )
{
- /* Volume keys */
- p_intf->disable_volume_keys = var_InheritBool( _p_intf, "qt-disable-volume-keys" );
+ m_disableVolumeKeys = var_InheritBool( _p_intf, "qt-disable-volume-keys" );
}
void MainCtxWin32::reloadPrefs()
{
- p_intf->disable_volume_keys = var_InheritBool( p_intf, "qt-disable-volume-keys" );
MainCtx::reloadPrefs();
+ bool disableVolumeKeys = var_InheritBool( p_intf, "qt-disable-volume-keys" );
+ if (disableVolumeKeys != m_disableVolumeKeys)
+ {
+ m_disableVolumeKeys = disableVolumeKeys;
+ emit disableVolumeKeysChanged(disableVolumeKeys);
+ }
+}
+
+bool MainCtxWin32::getDisableVolumeKeys() const
+{
+ return m_disableVolumeKeys;
}
// InterfaceWindowHandlerWin32
@@ -798,6 +807,13 @@ InterfaceWindowHandlerWin32::InterfaceWindowHandlerWin32(qt_intf_t *_p_intf, Mai
: InterfaceWindowHandler(_p_intf, mainCtx, window, parent)
, m_CSDWindowEventHandler(new CSDWin32EventHandler(mainCtx, window, window))
{
+ auto mainCtxWin32 = qobject_cast<MainCtxWin32*>(mainCtx);
+ assert(mainCtxWin32);
+ m_disableVolumeKeys = mainCtxWin32->getDisableVolumeKeys();
+ connect(mainCtxWin32, &MainCtxWin32::disableVolumeKeysChanged, this, [this](bool disable){
+ m_disableVolumeKeys = disable;
+ });
+
auto systemMenuButton = std::make_shared<WinSystemMenuButton>(mainCtx->intfMainWindow(), nullptr);
mainCtx->csdButtonModel()->setSystemMenuButton(systemMenuButton);
@@ -910,7 +926,7 @@ bool InterfaceWindowHandlerWin32::eventFilter(QObject* obj, QEvent* ev)
case WM_APPCOMMAND:
cmd = GET_APPCOMMAND_LPARAM(msg->lParam);
- if( p_intf->disable_volume_keys &&
+ if( m_disableVolumeKeys &&
( cmd == APPCOMMAND_VOLUME_DOWN ||
cmd == APPCOMMAND_VOLUME_UP ||
cmd == APPCOMMAND_VOLUME_MUTE ) )
=====================================
modules/gui/qt/maininterface/mainctx_win32.hpp
=====================================
@@ -79,12 +79,22 @@ private:
class MainCtxWin32 : public MainCtx
{
Q_OBJECT
+ Q_PROPERTY(bool disableVolumeKeys READ getDisableVolumeKeys NOTIFY disableVolumeKeysChanged FINAL)
public:
explicit MainCtxWin32(qt_intf_t *);
virtual ~MainCtxWin32() = default;
+public:
+ bool getDisableVolumeKeys() const;
+
public slots:
void reloadPrefs() override;
+
+signals:
+ void disableVolumeKeysChanged(bool);
+
+private:
+ bool m_disableVolumeKeys = false;
};
class InterfaceWindowHandlerWin32 : public InterfaceWindowHandler, public QAbstractNativeEventFilter
@@ -103,6 +113,8 @@ protected:
private:
void updateCSDWindowSettings() override;
QObject *m_CSDWindowEventHandler {};
+
+ bool m_disableVolumeKeys = false;
};
#endif // MAIN_INTERFACE_WIN32_HPP
=====================================
modules/gui/qt/qt.hpp
=====================================
@@ -98,10 +98,6 @@ struct qt_intf_t
PlayerController* p_mainPlayerController;
std::unique_ptr<vlc::Compositor> p_compositor;
-#ifdef _WIN32
- bool disable_volume_keys;
-#endif
-
int refCount;
bool isShuttingDown;
};
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/9d8130ab8d25b547f8cbc77a94fad087d3cfa885
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/9d8130ab8d25b547f8cbc77a94fad087d3cfa885
You're receiving this email because of your account on code.videolan.org.
VideoLAN code repository instance
More information about the vlc-commits
mailing list