mirror of
https://github.com/obsproject/obs-studio.git
synced 2026-08-30 17:58:37 +08:00
frontend: Set cursor width for OBSHotkeyEdit to 0
This hides the cursor from the OBSHotkeyEdit spin boxes even when they are in focus. Uses a shared style owned by OBSApp.
This commit is contained in:
committed by
Ryan Foster
parent
4b403d2a3e
commit
7685a0c78b
@@ -21,6 +21,7 @@
|
||||
#include <dialogs/LogUploadDialog.hpp>
|
||||
#include <utility/CrashHandler.hpp>
|
||||
#include <utility/OBSEventFilter.hpp>
|
||||
#include <utility/OBSProxyStyle.hpp>
|
||||
#if defined(_WIN32) || defined(ENABLE_SPARKLE_UPDATER)
|
||||
#include <utility/models/branches.hpp>
|
||||
#endif
|
||||
@@ -1344,6 +1345,14 @@ bool OBSApp::TranslateString(const char *lookupVal, const char **out) const
|
||||
return text_lookup_getstr(App()->GetTextLookup(), lookupVal, out);
|
||||
}
|
||||
|
||||
QStyle *OBSApp::GetInvisibleCursorStyle()
|
||||
{
|
||||
if (!invisibleCursorStyle) {
|
||||
invisibleCursorStyle = std::make_unique<OBSInvisibleCursorProxyStyle>();
|
||||
}
|
||||
return invisibleCursorStyle.get();
|
||||
}
|
||||
|
||||
// Global handler to receive all QEvent::Show events so we can apply
|
||||
// display affinity on any newly created windows and dialogs without
|
||||
// caring where they are coming from (e.g. plugins).
|
||||
|
||||
@@ -105,6 +105,7 @@ private:
|
||||
OBSTheme *currentTheme = nullptr;
|
||||
QHash<QString, OBSTheme> themes;
|
||||
QPointer<QFileSystemWatcher> themeWatcher;
|
||||
std::unique_ptr<QStyle> invisibleCursorStyle;
|
||||
|
||||
void FindThemes();
|
||||
|
||||
@@ -151,6 +152,7 @@ public:
|
||||
OBSTheme *GetTheme(const QString &name);
|
||||
bool SetTheme(const QString &name);
|
||||
bool IsThemeDark() const { return currentTheme ? currentTheme->isDark : false; }
|
||||
QStyle *GetInvisibleCursorStyle();
|
||||
|
||||
void SetBranchData(const std::string &data);
|
||||
std::vector<UpdateBranch> GetBranches();
|
||||
|
||||
@@ -19,6 +19,8 @@
|
||||
|
||||
#include <obs.hpp>
|
||||
|
||||
#include <OBSApp.hpp>
|
||||
|
||||
#include <QLineEdit>
|
||||
|
||||
class OBSBasicSettings;
|
||||
@@ -45,6 +47,7 @@ public:
|
||||
{
|
||||
setAttribute(Qt::WA_InputMethodEnabled, false);
|
||||
setAttribute(Qt::WA_MacShowFocusRect, true);
|
||||
setStyle(App()->GetInvisibleCursorStyle());
|
||||
InitSignalHandler();
|
||||
ResetKey();
|
||||
}
|
||||
@@ -52,6 +55,7 @@ public:
|
||||
{
|
||||
setAttribute(Qt::WA_InputMethodEnabled, false);
|
||||
setAttribute(Qt::WA_MacShowFocusRect, true);
|
||||
setStyle(App()->GetInvisibleCursorStyle());
|
||||
InitSignalHandler();
|
||||
ResetKey();
|
||||
}
|
||||
|
||||
@@ -13,3 +13,13 @@ int OBSProxyStyle::styleHint(StyleHint hint, const QStyleOption *option, const Q
|
||||
|
||||
return QProxyStyle::styleHint(hint, option, widget, returnData);
|
||||
}
|
||||
|
||||
int OBSInvisibleCursorProxyStyle::pixelMetric(PixelMetric metric, const QStyleOption *option,
|
||||
const QWidget *widget) const
|
||||
{
|
||||
|
||||
if (metric == PM_TextCursorWidth)
|
||||
return 0;
|
||||
|
||||
return QProxyStyle::pixelMetric(metric, option, widget);
|
||||
}
|
||||
|
||||
@@ -13,3 +13,12 @@ public:
|
||||
int styleHint(StyleHint hint, const QStyleOption *option, const QWidget *widget,
|
||||
QStyleHintReturn *returnData) const override;
|
||||
};
|
||||
|
||||
class OBSInvisibleCursorProxyStyle : public OBSProxyStyle {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
OBSInvisibleCursorProxyStyle() : OBSProxyStyle() {}
|
||||
|
||||
int pixelMetric(PixelMetric pm, const QStyleOption *option, const QWidget *widget) const override;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user