UI: Force fixed font in plain text edits
Since the Yami QSS changes the default font for widgets, we need to force the system fixed font for plain text edits.
This commit is contained in:
parent
38d8a844de
commit
ed32dcc677
@ -186,6 +186,8 @@ target_sources(
|
|||||||
menu-button.cpp
|
menu-button.cpp
|
||||||
menu-button.hpp
|
menu-button.hpp
|
||||||
mute-checkbox.hpp
|
mute-checkbox.hpp
|
||||||
|
plain-text-edit.cpp
|
||||||
|
plain-text-edit.hpp
|
||||||
properties-view.cpp
|
properties-view.cpp
|
||||||
properties-view.hpp
|
properties-view.hpp
|
||||||
properties-view.moc.hpp
|
properties-view.moc.hpp
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
#include "crash-report.hpp"
|
#include "crash-report.hpp"
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QFontDatabase>
|
#include <QFontDatabase>
|
||||||
#include <QPlainTextEdit>
|
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
#include <QClipboard>
|
#include <QClipboard>
|
||||||
#include "qt-wrappers.hpp"
|
#include "qt-wrappers.hpp"
|
||||||
|
#include "plain-text-edit.hpp"
|
||||||
|
|
||||||
OBSCrashReport::OBSCrashReport(QWidget *parent, const char *text)
|
OBSCrashReport::OBSCrashReport(QWidget *parent, const char *text)
|
||||||
: QDialog(parent)
|
: QDialog(parent)
|
||||||
@ -17,10 +17,9 @@ OBSCrashReport::OBSCrashReport(QWidget *parent, const char *text)
|
|||||||
QPushButton *exitButton = new QPushButton;
|
QPushButton *exitButton = new QPushButton;
|
||||||
exitButton->setText("Exit");
|
exitButton->setText("Exit");
|
||||||
|
|
||||||
textBox = new QPlainTextEdit;
|
textBox = new OBSPlainTextEdit;
|
||||||
textBox->setPlainText(QT_UTF8(text));
|
textBox->setPlainText(QT_UTF8(text));
|
||||||
textBox->setLineWrapMode(QPlainTextEdit::NoWrap);
|
textBox->setLineWrapMode(QPlainTextEdit::NoWrap);
|
||||||
textBox->setFont(QFontDatabase::systemFont(QFontDatabase::FixedFont));
|
|
||||||
|
|
||||||
QHBoxLayout *buttonLayout = new QHBoxLayout;
|
QHBoxLayout *buttonLayout = new QHBoxLayout;
|
||||||
buttonLayout->addWidget(copyButton);
|
buttonLayout->addWidget(copyButton);
|
||||||
|
@ -2,12 +2,12 @@
|
|||||||
|
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
|
|
||||||
class QPlainTextEdit;
|
class OBSPlainTextEdit;
|
||||||
|
|
||||||
class OBSCrashReport : public QDialog {
|
class OBSCrashReport : public QDialog {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
QPlainTextEdit *textBox;
|
OBSPlainTextEdit *textBox;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
OBSCrashReport(QWidget *parent, const char *text);
|
OBSCrashReport(QWidget *parent, const char *text);
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
<number>4</number>
|
<number>4</number>
|
||||||
</property>
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPlainTextEdit" name="textArea">
|
<widget class="OBSPlainTextEdit" name="textArea">
|
||||||
<property name="readOnly">
|
<property name="readOnly">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
@ -92,6 +92,13 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
|
<customwidgets>
|
||||||
|
<customwidget>
|
||||||
|
<class>OBSPlainTextEdit</class>
|
||||||
|
<extends>QPlainTextEdit</extends>
|
||||||
|
<header>plain-text-edit.hpp</header>
|
||||||
|
</customwidget>
|
||||||
|
</customwidgets>
|
||||||
<resources>
|
<resources>
|
||||||
<include location="obs.qrc"/>
|
<include location="obs.qrc"/>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -44,6 +44,8 @@ target_sources(
|
|||||||
${CMAKE_SOURCE_DIR}/plugins/aja/aja-widget-io.hpp
|
${CMAKE_SOURCE_DIR}/plugins/aja/aja-widget-io.hpp
|
||||||
${CMAKE_SOURCE_DIR}/UI/double-slider.cpp
|
${CMAKE_SOURCE_DIR}/UI/double-slider.cpp
|
||||||
${CMAKE_SOURCE_DIR}/UI/double-slider.hpp
|
${CMAKE_SOURCE_DIR}/UI/double-slider.hpp
|
||||||
|
${CMAKE_SOURCE_DIR}/UI/plain-text-edit.hpp
|
||||||
|
${CMAKE_SOURCE_DIR}/UI/plain-text-edit.cpp
|
||||||
${CMAKE_SOURCE_DIR}/UI/properties-view.hpp
|
${CMAKE_SOURCE_DIR}/UI/properties-view.hpp
|
||||||
${CMAKE_SOURCE_DIR}/UI/properties-view.cpp
|
${CMAKE_SOURCE_DIR}/UI/properties-view.cpp
|
||||||
${CMAKE_SOURCE_DIR}/UI/properties-view.moc.hpp
|
${CMAKE_SOURCE_DIR}/UI/properties-view.moc.hpp
|
||||||
|
@ -26,6 +26,8 @@ target_sources(
|
|||||||
decklink-ui-main.h
|
decklink-ui-main.h
|
||||||
${CMAKE_SOURCE_DIR}/UI/double-slider.cpp
|
${CMAKE_SOURCE_DIR}/UI/double-slider.cpp
|
||||||
${CMAKE_SOURCE_DIR}/UI/double-slider.hpp
|
${CMAKE_SOURCE_DIR}/UI/double-slider.hpp
|
||||||
|
${CMAKE_SOURCE_DIR}/UI/plain-text-edit.hpp
|
||||||
|
${CMAKE_SOURCE_DIR}/UI/plain-text-edit.cpp
|
||||||
${CMAKE_SOURCE_DIR}/UI/properties-view.hpp
|
${CMAKE_SOURCE_DIR}/UI/properties-view.hpp
|
||||||
${CMAKE_SOURCE_DIR}/UI/properties-view.cpp
|
${CMAKE_SOURCE_DIR}/UI/properties-view.cpp
|
||||||
${CMAKE_SOURCE_DIR}/UI/properties-view.moc.hpp
|
${CMAKE_SOURCE_DIR}/UI/properties-view.moc.hpp
|
||||||
|
@ -38,7 +38,9 @@ target_sources(
|
|||||||
${CMAKE_SOURCE_DIR}/UI/slider-ignorewheel.cpp
|
${CMAKE_SOURCE_DIR}/UI/slider-ignorewheel.cpp
|
||||||
${CMAKE_SOURCE_DIR}/UI/slider-ignorewheel.hpp
|
${CMAKE_SOURCE_DIR}/UI/slider-ignorewheel.hpp
|
||||||
${CMAKE_SOURCE_DIR}/UI/vertical-scroll-area.hpp
|
${CMAKE_SOURCE_DIR}/UI/vertical-scroll-area.hpp
|
||||||
${CMAKE_SOURCE_DIR}/UI/vertical-scroll-area.cpp)
|
${CMAKE_SOURCE_DIR}/UI/vertical-scroll-area.cpp
|
||||||
|
${CMAKE_SOURCE_DIR}/UI/plain-text-edit.cpp
|
||||||
|
${CMAKE_SOURCE_DIR}/UI/plain-text-edit.hpp)
|
||||||
|
|
||||||
target_compile_features(frontend-tools PRIVATE cxx_std_17)
|
target_compile_features(frontend-tools PRIVATE cxx_std_17)
|
||||||
|
|
||||||
|
@ -2,9 +2,9 @@
|
|||||||
#include "scripts.hpp"
|
#include "scripts.hpp"
|
||||||
#include "../../properties-view.hpp"
|
#include "../../properties-view.hpp"
|
||||||
#include "../../qt-wrappers.hpp"
|
#include "../../qt-wrappers.hpp"
|
||||||
|
#include "../../plain-text-edit.hpp"
|
||||||
|
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include <QPlainTextEdit>
|
|
||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
#include <QScrollBar>
|
#include <QScrollBar>
|
||||||
@ -81,18 +81,14 @@ struct ScriptData {
|
|||||||
static ScriptData *scriptData = nullptr;
|
static ScriptData *scriptData = nullptr;
|
||||||
static ScriptsTool *scriptsWindow = nullptr;
|
static ScriptsTool *scriptsWindow = nullptr;
|
||||||
static ScriptLogWindow *scriptLogWindow = nullptr;
|
static ScriptLogWindow *scriptLogWindow = nullptr;
|
||||||
static QPlainTextEdit *scriptLogWidget = nullptr;
|
static OBSPlainTextEdit *scriptLogWidget = nullptr;
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
/* ----------------------------------------------------------------- */
|
||||||
|
|
||||||
ScriptLogWindow::ScriptLogWindow() : QWidget(nullptr)
|
ScriptLogWindow::ScriptLogWindow() : QWidget(nullptr)
|
||||||
{
|
{
|
||||||
const QFont fixedFont =
|
OBSPlainTextEdit *edit = new OBSPlainTextEdit();
|
||||||
QFontDatabase::systemFont(QFontDatabase::FixedFont);
|
|
||||||
|
|
||||||
QPlainTextEdit *edit = new QPlainTextEdit();
|
|
||||||
edit->setReadOnly(true);
|
edit->setReadOnly(true);
|
||||||
edit->setFont(fixedFont);
|
|
||||||
edit->setWordWrapMode(QTextOption::NoWrap);
|
edit->setWordWrapMode(QTextOption::NoWrap);
|
||||||
|
|
||||||
QHBoxLayout *buttonLayout = new QHBoxLayout();
|
QHBoxLayout *buttonLayout = new QHBoxLayout();
|
||||||
|
@ -21,14 +21,6 @@ OBSLogViewer::OBSLogViewer(QWidget *parent)
|
|||||||
|
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
const QFont fixedFont =
|
|
||||||
QFontDatabase::systemFont(QFontDatabase::FixedFont);
|
|
||||||
|
|
||||||
ui->textArea->setFont(fixedFont);
|
|
||||||
// Fix display of tabs & multiple spaces
|
|
||||||
ui->textArea->document()->setDefaultStyleSheet(
|
|
||||||
"font { white-space: pre; }");
|
|
||||||
|
|
||||||
bool showLogViewerOnStartup = config_get_bool(
|
bool showLogViewerOnStartup = config_get_bool(
|
||||||
App()->GlobalConfig(), "LogViewer", "ShowLogStartup");
|
App()->GlobalConfig(), "LogViewer", "ShowLogStartup");
|
||||||
|
|
||||||
|
19
UI/plain-text-edit.cpp
Normal file
19
UI/plain-text-edit.cpp
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
#include "plain-text-edit.hpp"
|
||||||
|
#include <QFontDatabase>
|
||||||
|
|
||||||
|
OBSPlainTextEdit::OBSPlainTextEdit(QWidget *parent, bool monospace)
|
||||||
|
: QPlainTextEdit(parent)
|
||||||
|
{
|
||||||
|
// Fix display of tabs & multiple spaces
|
||||||
|
document()->setDefaultStyleSheet("font { white-space: pre; }");
|
||||||
|
|
||||||
|
if (monospace) {
|
||||||
|
const QFont fixedFont =
|
||||||
|
QFontDatabase::systemFont(QFontDatabase::FixedFont);
|
||||||
|
|
||||||
|
setStyleSheet(
|
||||||
|
QString("font-family: %1; font-size: %2pt;")
|
||||||
|
.arg(fixedFont.family(),
|
||||||
|
QString::number(fixedFont.pointSize())));
|
||||||
|
}
|
||||||
|
}
|
11
UI/plain-text-edit.hpp
Normal file
11
UI/plain-text-edit.hpp
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <QPlainTextEdit>
|
||||||
|
|
||||||
|
class OBSPlainTextEdit : public QPlainTextEdit {
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit OBSPlainTextEdit(QWidget *parent = nullptr,
|
||||||
|
bool monospace = true);
|
||||||
|
};
|
@ -14,7 +14,6 @@
|
|||||||
#include <QStandardItem>
|
#include <QStandardItem>
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include <QColorDialog>
|
#include <QColorDialog>
|
||||||
#include <QPlainTextEdit>
|
|
||||||
#include <QDialogButtonBox>
|
#include <QDialogButtonBox>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
@ -29,6 +28,7 @@
|
|||||||
#include "qt-wrappers.hpp"
|
#include "qt-wrappers.hpp"
|
||||||
#include "properties-view.hpp"
|
#include "properties-view.hpp"
|
||||||
#include "properties-view.moc.hpp"
|
#include "properties-view.moc.hpp"
|
||||||
|
#include "plain-text-edit.hpp"
|
||||||
#include "obs-app.hpp"
|
#include "obs-app.hpp"
|
||||||
|
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
@ -265,17 +265,13 @@ QWidget *OBSPropertiesView::AddText(obs_property_t *prop, QFormLayout *layout,
|
|||||||
{
|
{
|
||||||
const char *name = obs_property_name(prop);
|
const char *name = obs_property_name(prop);
|
||||||
const char *val = obs_data_get_string(settings, name);
|
const char *val = obs_data_get_string(settings, name);
|
||||||
const bool monospace = obs_property_text_monospace(prop);
|
bool monospace = obs_property_text_monospace(prop);
|
||||||
obs_text_type type = obs_property_text_type(prop);
|
obs_text_type type = obs_property_text_type(prop);
|
||||||
|
|
||||||
if (type == OBS_TEXT_MULTILINE) {
|
if (type == OBS_TEXT_MULTILINE) {
|
||||||
QPlainTextEdit *edit = new QPlainTextEdit(QT_UTF8(val));
|
OBSPlainTextEdit *edit = new OBSPlainTextEdit(this, monospace);
|
||||||
|
edit->setPlainText(QT_UTF8(val));
|
||||||
edit->setTabStopDistance(40);
|
edit->setTabStopDistance(40);
|
||||||
if (monospace) {
|
|
||||||
QFont f("Courier");
|
|
||||||
f.setStyleHint(QFont::Monospace);
|
|
||||||
edit->setFont(f);
|
|
||||||
}
|
|
||||||
return NewWidget(prop, edit, SIGNAL(textChanged()));
|
return NewWidget(prop, edit, SIGNAL(textChanged()));
|
||||||
|
|
||||||
} else if (type == OBS_TEXT_PASSWORD) {
|
} else if (type == OBS_TEXT_PASSWORD) {
|
||||||
@ -1725,7 +1721,8 @@ void WidgetInfo::TextChanged(const char *setting)
|
|||||||
obs_text_type type = obs_property_text_type(property);
|
obs_text_type type = obs_property_text_type(property);
|
||||||
|
|
||||||
if (type == OBS_TEXT_MULTILINE) {
|
if (type == OBS_TEXT_MULTILINE) {
|
||||||
QPlainTextEdit *edit = static_cast<QPlainTextEdit *>(widget);
|
OBSPlainTextEdit *edit =
|
||||||
|
static_cast<OBSPlainTextEdit *>(widget);
|
||||||
obs_data_set_string(view->settings, setting,
|
obs_data_set_string(view->settings, setting,
|
||||||
QT_TO_UTF8(edit->toPlainText()));
|
QT_TO_UTF8(edit->toPlainText()));
|
||||||
return;
|
return;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user