UI: Disable wheel scrolling on QComboBoxes
Adds a new ProxyStyle, OBSIgnoreWheelProxyStyle, and applies it to the entire program. This style sets a StyleHint to disable mouse wheel scrolling on QComboBoxes. The existing OBSProxyStyle, which is used only for the context bar, has been renamed accordingly.master
parent
f2b049c0e7
commit
e33b7d2dab
|
@ -39,6 +39,7 @@
|
||||||
|
|
||||||
#include "qt-wrappers.hpp"
|
#include "qt-wrappers.hpp"
|
||||||
#include "obs-app.hpp"
|
#include "obs-app.hpp"
|
||||||
|
#include "obs-proxy-style.hpp"
|
||||||
#include "log-viewer.hpp"
|
#include "log-viewer.hpp"
|
||||||
#include "slider-ignorewheel.hpp"
|
#include "slider-ignorewheel.hpp"
|
||||||
#include "window-basic-main.hpp"
|
#include "window-basic-main.hpp"
|
||||||
|
@ -1116,6 +1117,7 @@ bool OBSApp::SetTheme(std::string name, std::string path)
|
||||||
QString mpath = QString("file:///") + path.c_str();
|
QString mpath = QString("file:///") + path.c_str();
|
||||||
setPalette(defaultPalette);
|
setPalette(defaultPalette);
|
||||||
ParseExtraThemeData(path.c_str());
|
ParseExtraThemeData(path.c_str());
|
||||||
|
setStyle(new OBSIgnoreWheelProxyStyle);
|
||||||
setStyleSheet(mpath);
|
setStyleSheet(mpath);
|
||||||
QColor color = palette().text().color();
|
QColor color = palette().text().color();
|
||||||
themeDarkMode = !(color.redF() < 0.5);
|
themeDarkMode = !(color.redF() < 0.5);
|
||||||
|
|
|
@ -12,9 +12,10 @@ static inline uint qt_intensity(uint r, uint g, uint b)
|
||||||
*
|
*
|
||||||
* https://code.woboq.org/qt5/qtbase/src/widgets/styles/qcommonstyle.cpp.html#6429
|
* https://code.woboq.org/qt5/qtbase/src/widgets/styles/qcommonstyle.cpp.html#6429
|
||||||
*/
|
*/
|
||||||
QPixmap OBSProxyStyle::generatedIconPixmap(QIcon::Mode iconMode,
|
QPixmap
|
||||||
const QPixmap &pixmap,
|
OBSContextBarProxyStyle::generatedIconPixmap(QIcon::Mode iconMode,
|
||||||
const QStyleOption *option) const
|
const QPixmap &pixmap,
|
||||||
|
const QStyleOption *option) const
|
||||||
{
|
{
|
||||||
if (iconMode == QIcon::Disabled) {
|
if (iconMode == QIcon::Disabled) {
|
||||||
QImage im =
|
QImage im =
|
||||||
|
@ -75,3 +76,16 @@ QPixmap OBSProxyStyle::generatedIconPixmap(QIcon::Mode iconMode,
|
||||||
|
|
||||||
return QProxyStyle::generatedIconPixmap(iconMode, pixmap, option);
|
return QProxyStyle::generatedIconPixmap(iconMode, pixmap, option);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int OBSIgnoreWheelProxyStyle::styleHint(StyleHint hint,
|
||||||
|
const QStyleOption *option,
|
||||||
|
const QWidget *widget,
|
||||||
|
QStyleHintReturn *returnData) const
|
||||||
|
{
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
|
||||||
|
if (hint == SH_ComboBox_AllowWheelScrolling)
|
||||||
|
return false;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return QProxyStyle::styleHint(hint, option, widget, returnData);
|
||||||
|
}
|
||||||
|
|
|
@ -2,7 +2,14 @@
|
||||||
|
|
||||||
#include <QProxyStyle>
|
#include <QProxyStyle>
|
||||||
|
|
||||||
class OBSProxyStyle : public QProxyStyle {
|
class OBSIgnoreWheelProxyStyle : public QProxyStyle {
|
||||||
|
public:
|
||||||
|
int styleHint(StyleHint hint, const QStyleOption *option,
|
||||||
|
const QWidget *widget,
|
||||||
|
QStyleHintReturn *returnData) const override;
|
||||||
|
};
|
||||||
|
|
||||||
|
class OBSContextBarProxyStyle : public OBSIgnoreWheelProxyStyle {
|
||||||
public:
|
public:
|
||||||
QPixmap generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &pixmap,
|
QPixmap generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &pixmap,
|
||||||
const QStyleOption *option) const override;
|
const QStyleOption *option) const override;
|
||||||
|
|
|
@ -257,7 +257,7 @@ OBSBasic::OBSBasic(QWidget *parent)
|
||||||
|
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
ui->previewDisabledWidget->setVisible(false);
|
ui->previewDisabledWidget->setVisible(false);
|
||||||
ui->contextContainer->setStyle(new OBSProxyStyle);
|
ui->contextContainer->setStyle(new OBSContextBarProxyStyle);
|
||||||
ui->broadcastButton->setVisible(false);
|
ui->broadcastButton->setVisible(false);
|
||||||
|
|
||||||
startingDockLayout = saveState();
|
startingDockLayout = saveState();
|
||||||
|
|
Loading…
Reference in New Issue