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.master
parent
38d8a844de
commit
ed32dcc677
|
@ -186,6 +186,8 @@ target_sources(
|
|||
menu-button.cpp
|
||||
menu-button.hpp
|
||||
mute-checkbox.hpp
|
||||
plain-text-edit.cpp
|
||||
plain-text-edit.hpp
|
||||
properties-view.cpp
|
||||
properties-view.hpp
|
||||
properties-view.moc.hpp
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
#include "crash-report.hpp"
|
||||
#include <QApplication>
|
||||
#include <QFontDatabase>
|
||||
#include <QPlainTextEdit>
|
||||
#include <QPushButton>
|
||||
#include <QVBoxLayout>
|
||||
#include <QHBoxLayout>
|
||||
#include <QClipboard>
|
||||
#include "qt-wrappers.hpp"
|
||||
#include "plain-text-edit.hpp"
|
||||
|
||||
OBSCrashReport::OBSCrashReport(QWidget *parent, const char *text)
|
||||
: QDialog(parent)
|
||||
|
@ -17,10 +17,9 @@ OBSCrashReport::OBSCrashReport(QWidget *parent, const char *text)
|
|||
QPushButton *exitButton = new QPushButton;
|
||||
exitButton->setText("Exit");
|
||||
|
||||
textBox = new QPlainTextEdit;
|
||||
textBox = new OBSPlainTextEdit;
|
||||
textBox->setPlainText(QT_UTF8(text));
|
||||
textBox->setLineWrapMode(QPlainTextEdit::NoWrap);
|
||||
textBox->setFont(QFontDatabase::systemFont(QFontDatabase::FixedFont));
|
||||
|
||||
QHBoxLayout *buttonLayout = new QHBoxLayout;
|
||||
buttonLayout->addWidget(copyButton);
|
||||
|
|
|
@ -2,12 +2,12 @@
|
|||
|
||||
#include <QDialog>
|
||||
|
||||
class QPlainTextEdit;
|
||||
class OBSPlainTextEdit;
|
||||
|
||||
class OBSCrashReport : public QDialog {
|
||||
Q_OBJECT
|
||||
|
||||
QPlainTextEdit *textBox;
|
||||
OBSPlainTextEdit *textBox;
|
||||
|
||||
public:
|
||||
OBSCrashReport(QWidget *parent, const char *text);
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
<number>4</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QPlainTextEdit" name="textArea">
|
||||
<widget class="OBSPlainTextEdit" name="textArea">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
|
@ -92,6 +92,13 @@
|
|||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>OBSPlainTextEdit</class>
|
||||
<extends>QPlainTextEdit</extends>
|
||||
<header>plain-text-edit.hpp</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources>
|
||||
<include location="obs.qrc"/>
|
||||
</resources>
|
||||
|
|
|
@ -44,6 +44,8 @@ target_sources(
|
|||
${CMAKE_SOURCE_DIR}/plugins/aja/aja-widget-io.hpp
|
||||
${CMAKE_SOURCE_DIR}/UI/double-slider.cpp
|
||||
${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.cpp
|
||||
${CMAKE_SOURCE_DIR}/UI/properties-view.moc.hpp
|
||||
|
|
|
@ -26,6 +26,8 @@ target_sources(
|
|||
decklink-ui-main.h
|
||||
${CMAKE_SOURCE_DIR}/UI/double-slider.cpp
|
||||
${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.cpp
|
||||
${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.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)
|
||||
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
#include "scripts.hpp"
|
||||
#include "../../properties-view.hpp"
|
||||
#include "../../qt-wrappers.hpp"
|
||||
#include "../../plain-text-edit.hpp"
|
||||
|
||||
#include <QFileDialog>
|
||||
#include <QPlainTextEdit>
|
||||
#include <QHBoxLayout>
|
||||
#include <QVBoxLayout>
|
||||
#include <QScrollBar>
|
||||
|
@ -81,18 +81,14 @@ struct ScriptData {
|
|||
static ScriptData *scriptData = nullptr;
|
||||
static ScriptsTool *scriptsWindow = nullptr;
|
||||
static ScriptLogWindow *scriptLogWindow = nullptr;
|
||||
static QPlainTextEdit *scriptLogWidget = nullptr;
|
||||
static OBSPlainTextEdit *scriptLogWidget = nullptr;
|
||||
|
||||
/* ----------------------------------------------------------------- */
|
||||
|
||||
ScriptLogWindow::ScriptLogWindow() : QWidget(nullptr)
|
||||
{
|
||||
const QFont fixedFont =
|
||||
QFontDatabase::systemFont(QFontDatabase::FixedFont);
|
||||
|
||||
QPlainTextEdit *edit = new QPlainTextEdit();
|
||||
OBSPlainTextEdit *edit = new OBSPlainTextEdit();
|
||||
edit->setReadOnly(true);
|
||||
edit->setFont(fixedFont);
|
||||
edit->setWordWrapMode(QTextOption::NoWrap);
|
||||
|
||||
QHBoxLayout *buttonLayout = new QHBoxLayout();
|
||||
|
|
|
@ -21,14 +21,6 @@ OBSLogViewer::OBSLogViewer(QWidget *parent)
|
|||
|
||||
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(
|
||||
App()->GlobalConfig(), "LogViewer", "ShowLogStartup");
|
||||
|
||||
|
|
|
@ -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())));
|
||||
}
|
||||
}
|
|
@ -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 <QFileDialog>
|
||||
#include <QColorDialog>
|
||||
#include <QPlainTextEdit>
|
||||
#include <QDialogButtonBox>
|
||||
#include <QMenu>
|
||||
#include <QMessageBox>
|
||||
|
@ -29,6 +28,7 @@
|
|||
#include "qt-wrappers.hpp"
|
||||
#include "properties-view.hpp"
|
||||
#include "properties-view.moc.hpp"
|
||||
#include "plain-text-edit.hpp"
|
||||
#include "obs-app.hpp"
|
||||
|
||||
#include <cstdlib>
|
||||
|
@ -265,17 +265,13 @@ QWidget *OBSPropertiesView::AddText(obs_property_t *prop, QFormLayout *layout,
|
|||
{
|
||||
const char *name = obs_property_name(prop);
|
||||
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);
|
||||
|
||||
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);
|
||||
if (monospace) {
|
||||
QFont f("Courier");
|
||||
f.setStyleHint(QFont::Monospace);
|
||||
edit->setFont(f);
|
||||
}
|
||||
return NewWidget(prop, edit, SIGNAL(textChanged()));
|
||||
|
||||
} 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);
|
||||
|
||||
if (type == OBS_TEXT_MULTILINE) {
|
||||
QPlainTextEdit *edit = static_cast<QPlainTextEdit *>(widget);
|
||||
OBSPlainTextEdit *edit =
|
||||
static_cast<OBSPlainTextEdit *>(widget);
|
||||
obs_data_set_string(view->settings, setting,
|
||||
QT_TO_UTF8(edit->toPlainText()));
|
||||
return;
|
||||
|
|
Loading…
Reference in New Issue