[vlc-commits] [Git][videolan/vlc][master] 3 commits: qt: reload prefs on settings reset
Jean-Baptiste Kempf (@jbk)
gitlab at videolan.org
Mon Oct 18 14:20:26 UTC 2021
Jean-Baptiste Kempf pushed to branch master at VideoLAN / VLC
Commits:
86258a82 by Prince Gupta at 2021-10-18T12:55:43+00:00
qt: reload prefs on settings reset
- - - - -
96053261 by Prince Gupta at 2021-10-18T12:55:43+00:00
qt/MainInterface: handle runtime settings changes
- - - - -
0246f5a3 by Prince Gupta at 2021-10-18T12:55:43+00:00
qml/MainDisplay: handle playlist width factor changes
- - - - -
4 changed files:
- modules/gui/qt/dialogs/preferences/preferences.cpp
- modules/gui/qt/maininterface/main_interface.cpp
- modules/gui/qt/maininterface/main_interface.hpp
- modules/gui/qt/maininterface/qml/MainDisplay.qml
Changes:
=====================================
modules/gui/qt/dialogs/preferences/preferences.cpp
=====================================
@@ -305,6 +305,8 @@ void PrefsDialog::reset()
config_ResetAll();
config_SaveConfigFile( p_intf );
getSettings()->clear();
+ p_intf->p_mi->reloadPrefs();
+ p_intf->p_mi->reloadFromSettings();
#ifdef _WIN32
simple_panels[0]->cleanLang();
=====================================
modules/gui/qt/maininterface/main_interface.cpp
=====================================
@@ -98,6 +98,32 @@ static int IntfRaiseMainCB( vlc_object_t *p_this, const char *psz_variable,
const QEvent::Type MainInterface::ToolbarsNeedRebuild =
(QEvent::Type)QEvent::registerEventType();
+namespace
+{
+
+template <typename T>
+T loadVLCOption(vlc_object_t *obj, const char *name);
+
+template <>
+float loadVLCOption<float>(vlc_object_t *obj, const char *name)
+{
+ return var_InheritFloat(obj, name);
+}
+
+template <>
+int loadVLCOption<int>(vlc_object_t *obj, const char *name)
+{
+ return var_InheritInteger(obj, name);
+}
+
+template <>
+bool loadVLCOption<bool>(vlc_object_t *obj, const char *name)
+{
+ return var_InheritBool(obj, name);
+}
+
+}
+
MainInterface::MainInterface(qt_intf_t *_p_intf)
: p_intf(_p_intf)
{
@@ -114,16 +140,11 @@ MainInterface::MainInterface(qt_intf_t *_p_intf)
* Pre-building of interface
**/
- /* Are we in the enhanced always-video mode or not ? */
- b_minimalView = var_InheritBool( p_intf, "qt-minimal-view" );
-
- /* Do we want anoying popups or not */
- i_notificationSetting = var_InheritInteger( p_intf, "qt-notification" );
+ settings = getSettings();
+ m_colorScheme = new ColorSchemeModel(this);
- /* */
- m_intfUserScaleFactor = var_InheritFloat(p_intf, "qt-interface-scale");
- if (m_intfUserScaleFactor == -1)
- m_intfUserScaleFactor = getSettings()->value( "MainWindow/interface-scale", 1.0).toDouble();
+ loadPrefs(false);
+ loadFromSettingsImpl(false);
/* Get the available interfaces */
m_extraInterfaces = new VLCVarChoiceModel(VLC_OBJECT(p_intf->intf), "intf-add", this);
@@ -134,32 +155,9 @@ MainInterface::MainInterface(qt_intf_t *_p_intf)
m_medialib = new MediaLib(p_intf, this);
}
- /* Set the other interface settings */
- settings = getSettings();
-
- /* playlist settings */
- b_playlistDocked = getSettings()->value( "MainWindow/pl-dock-status", true ).toBool();
- playlistVisible = getSettings()->value( "MainWindow/playlist-visible", false ).toBool();
- playlistWidthFactor = getSettings()->value( "MainWindow/playlist-width-factor", 4.0 ).toDouble();
- m_gridView = getSettings()->value( "MainWindow/grid-view", true).toBool();
- m_showRemainingTime = getSettings()->value( "MainWindow/ShowRemainingTime", false ).toBool();
- m_pinVideoControls = getSettings()->value("MainWindow/pin-video-controls", false ).toBool();
-
- m_colorScheme = new ColorSchemeModel(this);
- const auto currentColorScheme = static_cast<ColorSchemeModel::ColorScheme>(getSettings()->value( "MainWindow/color-scheme", ColorSchemeModel::System ).toInt());
- m_colorScheme->setCurrentScheme(currentColorScheme);
-
/* Controlbar Profile Model Creation */
m_controlbarProfileModel = new ControlbarProfileModel(p_intf, this);
- /* Should the UI stays on top of other windows */
- b_interfaceOnTop = var_InheritBool( p_intf, "video-on-top" );
-
-#if QT_CLIENT_SIDE_DECORATION_AVAILABLE
- m_clientSideDecoration = ! var_InheritBool( p_intf, "qt-titlebar" );
-#endif
- m_hasToolbarMenu = var_InheritBool( p_intf, "qt-menubar" );
-
m_dialogFilepath = getSettings()->value( "filedialog-path", QVLCUserDir( VLC_HOME_DIR ) ).toString();
QString platformName = QGuiApplication::platformName();
@@ -274,25 +272,88 @@ bool MainInterface::hasFirstrun() const {
* Main UI handling *
*****************************/
-void MainInterface::reloadPrefs()
+void MainInterface::loadPrefs(const bool callSignals)
{
- i_notificationSetting = var_InheritInteger( p_intf, "qt-notification" );
+ const auto loadFromVLCOption = [this, callSignals](auto &variable, const char *name
+ , const std::function<void(MainInterface *)> signal)
+ {
+ using variableType = std::remove_reference_t<decltype(variable)>;
- if ( m_hasToolbarMenu != var_InheritBool( p_intf, "qt-menubar" ) )
+ const auto value = loadVLCOption<variableType>(VLC_OBJECT(p_intf), name);
+ if (value == variable)
+ return;
+
+ variable = value;
+ if (callSignals && signal)
+ signal(this);
+ };
+
+ /* Are we in the enhanced always-video mode or not ? */
+ loadFromVLCOption(b_minimalView, "qt-minimal-view", nullptr);
+
+ /* Do we want anoying popups or not */
+ loadFromVLCOption(i_notificationSetting, "qt-notification", nullptr);
+
+ /* Should the UI stays on top of other windows */
+ loadFromVLCOption(b_interfaceOnTop, "video-on-top", [this](MainInterface *)
{
- m_hasToolbarMenu = !m_hasToolbarMenu;
- emit hasToolbarMenuChanged();
- }
+ emit interfaceAlwaysOnTopChanged(b_interfaceOnTop);
+ });
+
+ loadFromVLCOption(m_hasToolbarMenu, "qt-menubar", &MainInterface::hasToolbarMenuChanged);
#if QT_CLIENT_SIDE_DECORATION_AVAILABLE
- if (m_clientSideDecoration != (! var_InheritBool( p_intf, "qt-titlebar" )))
+ loadFromVLCOption(m_clientSideDecoration, "qt-titlebar" , &MainInterface::useClientSideDecorationChanged);
+#endif
+}
+
+void MainInterface::loadFromSettingsImpl(const bool callSignals)
+{
+ const auto loadFromSettings = [this, callSignals](auto &variable, const char *name
+ , const auto defaultValue, auto signal)
+ {
+ using variableType = std::remove_reference_t<decltype(variable)>;
+
+ const auto value = getSettings()->value(name, defaultValue).template value<variableType>();
+ if (value == variable)
+ return;
+
+ variable = value;
+ if (callSignals && signal)
+ (this->*signal)(variable);
+ };
+
+ loadFromSettings(b_playlistDocked, "MainWindow/pl-dock-status", true, &MainInterface::playlistDockedChanged);
+
+ loadFromSettings(playlistVisible, "MainWindow/playlist-visible", false, &MainInterface::playlistVisibleChanged);
+
+ loadFromSettings(playlistWidthFactor, "MainWindow/playlist-width-factor", 4.0 , &MainInterface::playlistWidthFactorChanged);
+
+ loadFromSettings(m_gridView, "MainWindow/grid-view", true, &MainInterface::gridViewChanged);
+
+ loadFromSettings(m_showRemainingTime, "MainWindow/ShowRemainingTime", false, &MainInterface::showRemainingTimeChanged);
+
+ loadFromSettings(m_pinVideoControls, "MainWindow/pin-video-controls", false, &MainInterface::pinVideoControlsChanged);
+
+ const auto colorScheme = static_cast<ColorSchemeModel::ColorScheme>(getSettings()->value( "MainWindow/color-scheme", ColorSchemeModel::System ).toInt());
+ if (m_colorScheme->currentScheme() != colorScheme)
+ m_colorScheme->setCurrentScheme(colorScheme);
+
+ /* user interface scale factor */
+ auto userIntfScaleFactor = var_InheritFloat(p_intf, "qt-interface-scale");
+ if (userIntfScaleFactor == -1)
+ userIntfScaleFactor = getSettings()->value( "MainWindow/interface-scale", 1.0).toDouble();
+ if (m_intfUserScaleFactor != userIntfScaleFactor)
{
- m_clientSideDecoration = !m_clientSideDecoration;
- emit useClientSideDecorationChanged();
+ m_intfUserScaleFactor = userIntfScaleFactor;
+ updateIntfScaleFactor();
}
-#endif
}
+void MainInterface::reloadPrefs()
+{
+ loadPrefs(true);
+}
void MainInterface::onInputChanged( bool hasInput )
{
@@ -323,9 +384,8 @@ void MainInterface::sendHotkey(Qt::Key key , Qt::KeyboardModifiers modifiers)
void MainInterface::updateIntfScaleFactor()
{
- QWindow* window = p_intf->p_compositor->interfaceMainWindow();
m_intfScaleFactor = m_intfUserScaleFactor;
- if (window)
+ if (QWindow* window = p_intf->p_compositor ? p_intf->p_compositor->interfaceMainWindow() : nullptr)
{
QScreen* screen = window->screen();
if (screen)
=====================================
modules/gui/qt/maininterface/main_interface.hpp
=====================================
@@ -221,6 +221,7 @@ public:
inline void setDialogFilePath(const QUrl& filepath ){ m_dialogFilepath = filepath; }
inline bool useAcrylicBackground() const { return m_useAcrylicBackground; }
inline bool hasAcrylicSurface() const { return m_hasAcrylicSurface; }
+ inline void reloadFromSettings() { loadFromSettingsImpl(true); }
bool hasEmbededVideo() const;
VideoSurfaceProvider* getVideoSurfaceProvider() const;
@@ -265,9 +266,9 @@ protected:
QMap<QWidget *, QSize> stackWidgetsSizes;
/* Flags */
- double m_intfUserScaleFactor;
- double m_intfScaleFactor;
- unsigned i_notificationSetting; /// Systray Notifications
+ double m_intfUserScaleFactor;
+ double m_intfScaleFactor;
+ int i_notificationSetting; /// Systray Notifications
bool b_hideAfterCreation;
bool b_minimalView; ///< Minimal video
bool b_playlistDocked;
@@ -367,6 +368,10 @@ signals:
void pinVideoControlsChanged( bool );
void useAcrylicBackgroundChanged();
void hasAcrylicSurfaceChanged();
+
+private:
+ void loadPrefs(bool callSignals);
+ void loadFromSettingsImpl(bool callSignals);
};
#endif
=====================================
modules/gui/qt/maininterface/qml/MainDisplay.qml
=====================================
@@ -355,6 +355,9 @@ FocusScope {
Widgets.HorizontalResizeHandle {
id: resizeHandle
+
+ property bool _inhibitMainInterfaceUpdate: false
+
anchors {
top: parent.top
bottom: parent.bottom
@@ -367,10 +370,28 @@ FocusScope {
targetWidth: playlistColumn.width
sourceWidth: root.width
- onWidthFactorChanged: mainInterface.setPlaylistWidthFactor(widthFactor)
- Component.onCompleted: {
- //don't bind just provide the initial value, HorizontalResizeHandle.widthFactor updates itself
+ onWidthFactorChanged: {
+ if (!_inhibitMainInterfaceUpdate)
+ mainInterface.setPlaylistWidthFactor(widthFactor)
+ }
+
+ Component.onCompleted: _updateFromMainInterface()
+
+ function _updateFromMainInterface() {
+ if (widthFactor == mainInterface.playlistWidthFactor)
+ return
+
+ _inhibitMainInterfaceUpdate = true
widthFactor = mainInterface.playlistWidthFactor
+ _inhibitMainInterfaceUpdate = false
+ }
+
+ Connections {
+ target: mainInterface
+
+ onPlaylistWidthFactorChanged: {
+ resizeHandle._updateFromMainInterface()
+ }
}
}
}
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/0da4aa9de0d5f16b77d7627081ae926456f9d8e3...0246f5a3043a0daef7d73f956df9fbaeeb1a7531
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/0da4aa9de0d5f16b77d7627081ae926456f9d8e3...0246f5a3043a0daef7d73f956df9fbaeeb1a7531
You're receiving this email because of your account on code.videolan.org.
More information about the vlc-commits
mailing list