Commit 540a21bd authored by Pierre Lamot's avatar Pierre Lamot
Browse files

qt: expose interface scale factor

  This allows better handling of fractional scaling and allows user to
  define their own scale factor.
parent 4e72a403
......@@ -78,6 +78,8 @@
#include <vlc_actions.h> /* Wheel event */
#include <vlc_vout_window.h> /* VOUT_ events */
#define VLC_REFERENCE_SCALE_FACTOR 96.
using namespace vlc::playlist;
// #define DEBUG_INTF
......@@ -129,6 +131,13 @@ MainInterface::MainInterface( intf_thread_t *_p_intf )
/* */
b_pauseOnMinimize = var_InheritBool( p_intf, "qt-pause-minimized" );
m_intfUserScaleFactor = var_InheritFloat(p_intf, "qt-interface-scale");
winId(); //force window creation
QWindow* window = windowHandle();
if (window)
connect(window, &QWindow::screenChanged, this, &MainInterface::updateIntfScaleFactor);
updateIntfScaleFactor();
/* Get the available interfaces */
m_extraInterfaces = new VLCVarChoiceModel(p_intf, "intf-add", this);
......@@ -302,6 +311,22 @@ void MainInterface::sendHotkey(Qt::Key key , Qt::KeyboardModifiers modifiers)
var_SetInteger(vlc_object_instance(p_intf), "key-pressed", vlckey);
}
void MainInterface::updateIntfScaleFactor()
{
QWindow* window = windowHandle();
m_intfScaleFactor = m_intfUserScaleFactor;
if (window)
{
QScreen* screen = window->screen();
if (screen)
{
qreal dpi = screen->logicalDotsPerInch();
m_intfScaleFactor = m_intfUserScaleFactor * dpi / VLC_REFERENCE_SCALE_FACTOR;
}
}
emit intfScaleFactorChanged();
}
inline void MainInterface::initSystray()
{
bool b_systrayAvailable = QSystemTrayIcon::isSystemTrayAvailable();
......
......@@ -69,6 +69,7 @@ class MainInterface : public QVLCMW
Q_PROPERTY(bool hasEmbededVideo READ hasEmbededVideo NOTIFY hasEmbededVideoChanged)
Q_PROPERTY(bool showRemainingTime READ isShowRemainingTime WRITE setShowRemainingTime NOTIFY showRemainingTimeChanged)
Q_PROPERTY(VLCVarChoiceModel* extraInterfaces READ getExtraInterfaces CONSTANT)
Q_PROPERTY(float intfScaleFactor READ getIntfScaleFactor NOTIFY intfScaleFactorChanged)
public:
/* tors */
......@@ -105,6 +106,7 @@ public:
bool isPlaylistVisible() { return playlistVisible; }
bool isInterfaceAlwaysOnTop() { return b_interfaceOnTop; }
inline bool isShowRemainingTime() const { return m_showRemainingTime; }
inline float getIntfScaleFactor() const { return m_intfScaleFactor; }
bool hasEmbededVideo() const;
VideoSurfaceProvider* getVideoSurfaceProvider() const;
......@@ -157,6 +159,8 @@ protected:
QMap<QWidget *, QSize> stackWidgetsSizes;
/* Flags */
float m_intfUserScaleFactor;
float m_intfScaleFactor;
unsigned i_notificationSetting; /// Systray Notifications
bool b_autoresize; ///< persistent resizable window
bool b_videoFullScreen; ///< --fullscreen
......@@ -215,6 +219,7 @@ protected slots:
void setRaise();
void setFullScreen( bool );
void onInputChanged( bool );
void updateIntfScaleFactor();
void sendHotkey(Qt::Key key, Qt::KeyboardModifiers modifiers );
......@@ -238,6 +243,8 @@ signals:
void hasEmbededVideoChanged(bool);
void toolBarConfUpdated();
void showRemainingTimeChanged(bool);
void intfScaleFactorChanged();
};
#endif
......@@ -153,6 +153,8 @@ static void ShowDialog ( intf_thread_t *, int, int, intf_dialog_args_t * );
" This option only works with Windows and " \
"X11 with composite extensions." )
#define INTERFACE_SCALE_TEXT N_( "User scale factor for the interface, betwwen 0.1 and 10.0" )
#define ERROR_TEXT N_( "Show unimportant error and warnings dialogs" )
#define UPDATER_TEXT N_( "Activate the updates availability notification" )
......@@ -281,6 +283,9 @@ vlc_module_begin ()
add_float_with_range( "qt-fs-opacity", 0.8, 0.1, 1., OPACITY_FS_TEXT,
OPACITY_FS_LONGTEXT, false )
add_float_with_range( "qt-interface-scale", 1.0, 0.1, 10., INTERFACE_SCALE_TEXT,
INTERFACE_SCALE_TEXT, false )
add_bool( "qt-video-autoresize", true, KEEPSIZE_TEXT,
KEEPSIZE_LONGTEXT, false )
add_bool( "qt-name-in-title", true, TITLE_TEXT,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment