mirror of
https://github.com/huderlem/porymap.git
synced 2026-03-21 17:45:44 -05:00
Add font settings
This commit is contained in:
parent
a3d3a6c176
commit
e00c7d456d
|
|
@ -6,8 +6,8 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>530</width>
|
||||
<height>432</height>
|
||||
<width>549</width>
|
||||
<height>476</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
|
|
@ -38,98 +38,194 @@
|
|||
<number>12</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_MonitorProjectFiles">
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>If checked, a prompt to reload your project will appear if relevant project files are edited</p></body></html></string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Monitor project files</string>
|
||||
<widget class="QScrollArea" name="scrollArea">
|
||||
<property name="widgetResizable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<widget class="QWidget" name="scrollAreaWidgetContents">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>493</width>
|
||||
<height>374</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_6">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_MonitorProjectFiles">
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>If checked, a prompt to reload your project will appear if relevant project files are edited</p></body></html></string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Monitor project files</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_OpenRecentProject">
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>If checked, Porymap will automatically open your most recently opened project on startup</p></body></html></string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Open recent project on launch</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_CheckForUpdates">
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>If checked, Porymap will automatically alert you on startup if a new release is available</p></body></html></string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Automatically check for updates</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_Themes">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Application Theme</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_Fonts">
|
||||
<property name="title">
|
||||
<string>Fonts</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="3" column="0">
|
||||
<spacer name="verticalSpacer_5">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="2" column="2">
|
||||
<widget class="QPushButton" name="pushButton_ResetMapListFont">
|
||||
<property name="text">
|
||||
<string>Reset</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QPushButton" name="pushButton_CustomizeMapListFont">
|
||||
<property name="text">
|
||||
<string>Customize...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_MapListFont">
|
||||
<property name="text">
|
||||
<string>Map List Font</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QPushButton" name="pushButton_ResetApplicationFont">
|
||||
<property name="text">
|
||||
<string>Reset</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QPushButton" name="pushButton_CustomizeApplicationFont">
|
||||
<property name="text">
|
||||
<string>Customize...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_ApplicationFont">
|
||||
<property name="text">
|
||||
<string>Application Font</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="3">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_Logging">
|
||||
<property name="title">
|
||||
<string>Logging</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_StatusMessages">
|
||||
<property name="text">
|
||||
<string>Status bar message types</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_StatusErrors">
|
||||
<property name="text">
|
||||
<string>Errors</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_StatusWarnings">
|
||||
<property name="text">
|
||||
<string>Warnings</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_StatusInformation">
|
||||
<property name="text">
|
||||
<string>Information</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer_4">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_OpenRecentProject">
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>If checked, Porymap will automatically open your most recently opened project on startup</p></body></html></string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Open recent project on launch</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_CheckForUpdates">
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>If checked, Porymap will automatically alert you on startup if a new release is available</p></body></html></string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Automatically check for updates</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_Themes">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Application Theme</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_Logging">
|
||||
<property name="title">
|
||||
<string>Logging</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_StatusMessages">
|
||||
<property name="text">
|
||||
<string>Status bar message types</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_StatusErrors">
|
||||
<property name="text">
|
||||
<string>Errors</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_StatusWarnings">
|
||||
<property name="text">
|
||||
<string>Warnings</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_StatusInformation">
|
||||
<property name="text">
|
||||
<string>Information</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer_4">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Orientation::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tab_Events">
|
||||
|
|
@ -198,7 +294,7 @@
|
|||
<item>
|
||||
<spacer name="verticalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Orientation::Vertical</enum>
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
|
|
@ -210,7 +306,7 @@
|
|||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tab">
|
||||
<widget class="QWidget" name="tab_TextEditor">
|
||||
<attribute name="title">
|
||||
<string>Text Editor</string>
|
||||
</attribute>
|
||||
|
|
@ -227,7 +323,7 @@
|
|||
<item>
|
||||
<widget class="QScrollArea" name="scrollArea_TextEditor">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::Shape::NoFrame</enum>
|
||||
<enum>QFrame::NoFrame</enum>
|
||||
</property>
|
||||
<property name="widgetResizable">
|
||||
<bool>true</bool>
|
||||
|
|
@ -243,7 +339,7 @@
|
|||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<property name="sizeConstraint">
|
||||
<enum>QLayout::SizeConstraint::SetMinimumSize</enum>
|
||||
<enum>QLayout::SetMinimumSize</enum>
|
||||
</property>
|
||||
<item row="6" column="0" colspan="2">
|
||||
<widget class="QLabel" name="label_TextEditorGotoLineHelp">
|
||||
|
|
@ -251,7 +347,7 @@
|
|||
<string><html><head/><body><p>When this command is set a button will appear next to the <span style=" font-weight:600; font-style:italic;">Script</span> combo-box in the <span style=" font-weight:600; font-style:italic;">Events</span> tab which executes this command.<span style=" font-weight:600;"> %F</span> will be substituted with the file path of the script and <span style=" font-weight:600;">%L</span> will be substituted with the line number of the script in that file. <span style=" font-weight:600;">%F </span><span style=" font-style:italic;">must</span> be given if <span style=" font-weight:600;">%L</span> is given. If <span style=" font-weight:600;">%F</span> is <span style=" font-style:italic;">not</span> given then the script's file path will be added to the end of the command. If the script can't be found then the current map's scripts file is opened.</p></body></html></string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignmentFlag::AlignLeading|Qt::AlignmentFlag::AlignLeft|Qt::AlignmentFlag::AlignTop</set>
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
|
|
@ -284,7 +380,7 @@
|
|||
<string><html><head/><body><p>This is the command that is executed when clicking <span style=" font-weight:600; font-style:italic;">Open Project in Text Editor</span> in the <span style=" font-weight:600; font-style:italic;">Tools</span> menu. <span style=" font-weight:600;">%D</span> will be substituted with the project's root directory. If <span style=" font-weight:600;">%D</span> is <span style=" font-style:italic;">not</span> specified then the project directory will be added to the end of the command.</p></body></html></string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignmentFlag::AlignLeading|Qt::AlignmentFlag::AlignLeft|Qt::AlignmentFlag::AlignTop</set>
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
|
|
@ -314,10 +410,10 @@
|
|||
<item row="2" column="0" colspan="2">
|
||||
<spacer name="verticalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Orientation::Vertical</enum>
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Policy::Fixed</enum>
|
||||
<enum>QSizePolicy::Fixed</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
|
|
@ -330,7 +426,7 @@
|
|||
<item row="7" column="0" colspan="2">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Orientation::Vertical</enum>
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
|
|
@ -351,7 +447,7 @@
|
|||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::StandardButton::Apply|QDialogButtonBox::StandardButton::Cancel|QDialogButtonBox::StandardButton::Ok</set>
|
||||
<set>QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
|
|
|||
|
|
@ -12,6 +12,8 @@
|
|||
#include <QUrl>
|
||||
#include <QVersionNumber>
|
||||
#include <QGraphicsPixmapItem>
|
||||
#include <QFontDatabase>
|
||||
#include <QStandardPaths>
|
||||
#include <set>
|
||||
|
||||
#include "events.h"
|
||||
|
|
@ -64,6 +66,7 @@ class PorymapConfig: public KeyValueConfigBase
|
|||
public:
|
||||
PorymapConfig();
|
||||
virtual void reset() override {
|
||||
setRoot(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation));
|
||||
this->recentProjects.clear();
|
||||
this->projectManuallyClosed = false;
|
||||
this->reopenOnLaunch = true;
|
||||
|
|
@ -110,6 +113,8 @@ public:
|
|||
this->shownInGameReloadMessage = false;
|
||||
this->gridSettings = GridSettings();
|
||||
this->statusBarLogTypes = { LogType::LOG_ERROR, LogType::LOG_WARN };
|
||||
this->applicationFont = QFont();
|
||||
this->mapListFont = PorymapConfig::defaultMapListFont();
|
||||
}
|
||||
void addRecentProject(QString project);
|
||||
void setRecentProjects(QStringList projects);
|
||||
|
|
@ -128,6 +133,8 @@ public:
|
|||
QMap<QString, QByteArray> getProjectSettingsEditorGeometry();
|
||||
QMap<QString, QByteArray> getCustomScriptsEditorGeometry();
|
||||
|
||||
static QFont defaultMapListFont() { return QFontDatabase::systemFont(QFontDatabase::FixedFont); }
|
||||
|
||||
bool reopenOnLaunch;
|
||||
bool projectManuallyClosed;
|
||||
int mapListTab;
|
||||
|
|
@ -177,6 +184,8 @@ public:
|
|||
GridSettings gridSettings;
|
||||
// Prefer over QSet to prevent shuffling elements when writing the config file.
|
||||
std::set<LogType> statusBarLogTypes;
|
||||
QFont applicationFont;
|
||||
QFont mapListFont;
|
||||
|
||||
protected:
|
||||
virtual void parseConfigKeyValue(QString key, QString value) override;
|
||||
|
|
@ -502,7 +511,10 @@ class ShortcutsConfig : public KeyValueConfigBase
|
|||
public:
|
||||
ShortcutsConfig();
|
||||
|
||||
virtual void reset() override { user_shortcuts.clear(); }
|
||||
virtual void reset() override {
|
||||
setRoot(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation));
|
||||
user_shortcuts.clear();
|
||||
}
|
||||
|
||||
// Call this before applying user shortcuts so that the user can restore defaults.
|
||||
void setDefaultShortcuts(const QObjectList &objects);
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ namespace Util {
|
|||
Qt::Orientations getOrientation(bool xflip, bool yflip);
|
||||
QString replaceExtension(const QString &path, const QString &newExtension);
|
||||
void setErrorStylesheet(QLineEdit *lineEdit, bool isError);
|
||||
QString toStylesheetString(const QFont &font);
|
||||
}
|
||||
|
||||
#endif // UTILITY_H
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@
|
|||
#define MAPLISTMODELS_H
|
||||
|
||||
#include <QTreeView>
|
||||
#include <QFontDatabase>
|
||||
#include <QStyledItemDelegate>
|
||||
#include <QStandardItemModel>
|
||||
#include <QMap>
|
||||
|
|
@ -24,7 +23,6 @@ class MapTree : public QTreeView {
|
|||
public:
|
||||
MapTree(QWidget *parent) : QTreeView(parent) {
|
||||
this->setDropIndicatorShown(true);
|
||||
this->setFont(QFontDatabase::systemFont(QFontDatabase::FixedFont));
|
||||
this->setFocusPolicy(Qt::StrongFocus);
|
||||
this->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,10 +28,12 @@ signals:
|
|||
private:
|
||||
Ui::PreferenceEditor *ui;
|
||||
NoScrollComboBox *themeSelector;
|
||||
QFont applicationFont;
|
||||
QFont mapListFont;
|
||||
|
||||
void initFields();
|
||||
void saveFields();
|
||||
|
||||
void openFontDialog(QFont *font);
|
||||
|
||||
private slots:
|
||||
void dialogButtonClicked(QAbstractButton *button);
|
||||
|
|
|
|||
|
|
@ -14,7 +14,6 @@
|
|||
#include <QLabel>
|
||||
#include <QTextStream>
|
||||
#include <QRegularExpression>
|
||||
#include <QStandardPaths>
|
||||
#include <QAction>
|
||||
#include <QAbstractButton>
|
||||
|
||||
|
|
@ -310,7 +309,6 @@ PorymapConfig porymapConfig;
|
|||
|
||||
PorymapConfig::PorymapConfig() : KeyValueConfigBase(QStringLiteral("porymap.cfg")) {
|
||||
reset();
|
||||
setRoot(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation));
|
||||
}
|
||||
|
||||
void PorymapConfig::parseConfigKeyValue(QString key, QString value) {
|
||||
|
|
@ -485,6 +483,12 @@ void PorymapConfig::parseConfigKeyValue(QString key, QString value) {
|
|||
LogType type = static_cast<LogType>(getConfigInteger(key, typeString, 0, 2));
|
||||
this->statusBarLogTypes.insert(type);
|
||||
}
|
||||
} else if (key == "application_font") {
|
||||
this->applicationFont = QFont();
|
||||
this->applicationFont.fromString(value);
|
||||
} else if (key == "map_list_font") {
|
||||
this->mapListFont = QFont();
|
||||
this->mapListFont.fromString(value);
|
||||
} else {
|
||||
logWarn(QString("Invalid config key found in config file %1: '%2'").arg(this->filepath()).arg(key));
|
||||
}
|
||||
|
|
@ -574,6 +578,8 @@ QMap<QString, QString> PorymapConfig::getKeyValueMap() {
|
|||
logTypesStrings.append(QString::number(type));
|
||||
}
|
||||
map.insert("status_bar_log_types", logTypesStrings.join(","));
|
||||
map.insert("application_font", this->applicationFont.toString());
|
||||
map.insert("map_list_font", this->mapListFont.toString());
|
||||
|
||||
return map;
|
||||
}
|
||||
|
|
@ -1285,7 +1291,6 @@ ShortcutsConfig shortcutsConfig;
|
|||
ShortcutsConfig::ShortcutsConfig() : KeyValueConfigBase(QStringLiteral("porymap.shortcuts.cfg")),
|
||||
user_shortcuts({ }),
|
||||
default_shortcuts({ }) {
|
||||
setRoot(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation));
|
||||
}
|
||||
|
||||
void ShortcutsConfig::parseConfigKeyValue(QString key, QString value) {
|
||||
|
|
|
|||
|
|
@ -48,6 +48,25 @@ QString Util::toHtmlParagraph(const QString &text) {
|
|||
return QString("<html><head/><body><p>%1</p></body></html>").arg(text);
|
||||
}
|
||||
|
||||
QString Util::toStylesheetString(const QFont &font) {
|
||||
QString s = QString("font-family: \"%1\";").arg(font.family());
|
||||
|
||||
if (font.pixelSize() >= 0) {
|
||||
s.append(QString(" font-size: %1px;").arg(font.pixelSize()));
|
||||
} else if (font.pointSize() >= 0) {
|
||||
s.append(QString(" font-size: %1pt;").arg(font.pointSize()));
|
||||
}
|
||||
if (font.bold()) {
|
||||
s.append(" font-weight: bold;");
|
||||
}
|
||||
if (font.style() == QFont::StyleItalic) {
|
||||
s.append(" font-style: italic;");
|
||||
} else if (font.style() == QFont::StyleOblique) {
|
||||
s.append(" font-style: oblique;");
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
QString Util::stripPrefix(const QString &s, const QString &prefix) {
|
||||
if (!s.startsWith(prefix)) {
|
||||
return s;
|
||||
|
|
|
|||
10
src/log.cpp
10
src/log.cpp
|
|
@ -12,6 +12,7 @@ namespace Log {
|
|||
static QString path;
|
||||
static QFile file;
|
||||
static QTextStream textStream;
|
||||
static bool initialized = false;
|
||||
|
||||
struct Display {
|
||||
QPointer<QStatusBar> statusBar;
|
||||
|
|
@ -155,12 +156,16 @@ void log(const QString &message, LogType type) {
|
|||
break;
|
||||
}
|
||||
|
||||
updateLogDisplays(message, type);
|
||||
|
||||
QString fullMessage = QString("%1 %2 %3").arg(now).arg(typeString).arg(message);
|
||||
|
||||
qDebug().noquote() << colorizeMessage(fullMessage, type);
|
||||
|
||||
if (!Log::initialized) {
|
||||
return;
|
||||
}
|
||||
|
||||
updateLogDisplays(message, type);
|
||||
|
||||
Log::textStream << fullMessage << Qt::endl;
|
||||
Log::file.flush();
|
||||
}
|
||||
|
|
@ -194,4 +199,5 @@ void logInit() {
|
|||
if (cleanupLargeLog()) {
|
||||
logWarn(QString("Previous log file %1 was cleared due to being over 20MB in size.").arg(Log::path));
|
||||
}
|
||||
Log::initialized = true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -687,6 +687,10 @@ void MainWindow::setTheme(QString theme) {
|
|||
QFile File(QString(":/themes/%1.qss").arg(theme));
|
||||
File.open(QFile::ReadOnly);
|
||||
QString stylesheet = QLatin1String(File.readAll());
|
||||
|
||||
stylesheet.append(QString("QWidget { %1 } ").arg(Util::toStylesheetString(porymapConfig.applicationFont)));
|
||||
stylesheet.append(QString("MapTree { %1 } ").arg(Util::toStylesheetString(porymapConfig.mapListFont)));
|
||||
|
||||
setStyleSheet(stylesheet);
|
||||
}
|
||||
|
||||
|
|
@ -2940,10 +2944,7 @@ void MainWindow::on_actionPreferences_triggered() {
|
|||
}
|
||||
|
||||
void MainWindow::togglePreferenceSpecificUi() {
|
||||
if (porymapConfig.textEditorOpenFolder.isEmpty())
|
||||
ui->actionOpen_Project_in_Text_Editor->setEnabled(false);
|
||||
else
|
||||
ui->actionOpen_Project_in_Text_Editor->setEnabled(true);
|
||||
ui->actionOpen_Project_in_Text_Editor->setEnabled(!porymapConfig.textEditorOpenFolder.isEmpty());
|
||||
|
||||
if (this->updatePromoter)
|
||||
this->updatePromoter->updatePreferences();
|
||||
|
|
|
|||
|
|
@ -7,6 +7,8 @@
|
|||
#include <QRegularExpression>
|
||||
#include <QDirIterator>
|
||||
#include <QFormLayout>
|
||||
#include <QFontDialog>
|
||||
#include <QToolTip>
|
||||
|
||||
|
||||
PreferenceEditor::PreferenceEditor(QWidget *parent) :
|
||||
|
|
@ -21,8 +23,23 @@ PreferenceEditor::PreferenceEditor(QWidget *parent) :
|
|||
themeSelector->setMinimumContentsLength(0);
|
||||
formLayout->addRow("Themes", themeSelector);
|
||||
setAttribute(Qt::WA_DeleteOnClose);
|
||||
connect(ui->buttonBox, &QDialogButtonBox::clicked,
|
||||
this, &PreferenceEditor::dialogButtonClicked);
|
||||
connect(ui->buttonBox, &QDialogButtonBox::clicked, this, &PreferenceEditor::dialogButtonClicked);
|
||||
|
||||
connect(ui->pushButton_CustomizeApplicationFont, &QPushButton::clicked, [this] {
|
||||
openFontDialog(&this->applicationFont);
|
||||
});
|
||||
connect(ui->pushButton_CustomizeMapListFont, &QPushButton::clicked, [this] {
|
||||
openFontDialog(&this->mapListFont);
|
||||
});
|
||||
connect(ui->pushButton_ResetApplicationFont, &QPushButton::clicked, [this] {
|
||||
this->applicationFont = QFont();
|
||||
QToolTip::showText(ui->pushButton_ResetApplicationFont->mapToGlobal(QPoint(0, 0)), "Font reset!");
|
||||
});
|
||||
connect(ui->pushButton_ResetMapListFont, &QPushButton::clicked, [this] {
|
||||
this->mapListFont = PorymapConfig::defaultMapListFont();
|
||||
QToolTip::showText(ui->pushButton_ResetMapListFont->mapToGlobal(QPoint(0, 0)), "Font reset!");
|
||||
});
|
||||
|
||||
initFields();
|
||||
updateFields();
|
||||
}
|
||||
|
|
@ -64,13 +81,16 @@ void PreferenceEditor::updateFields() {
|
|||
ui->checkBox_StatusErrors->setChecked(porymapConfig.statusBarLogTypes.find(LogType::LOG_ERROR) != logTypeEnd);
|
||||
ui->checkBox_StatusWarnings->setChecked(porymapConfig.statusBarLogTypes.find(LogType::LOG_WARN) != logTypeEnd);
|
||||
ui->checkBox_StatusInformation->setChecked(porymapConfig.statusBarLogTypes.find(LogType::LOG_INFO) != logTypeEnd);
|
||||
|
||||
this->applicationFont = porymapConfig.applicationFont;
|
||||
this->mapListFont = porymapConfig.mapListFont;
|
||||
}
|
||||
|
||||
void PreferenceEditor::saveFields() {
|
||||
bool changedTheme = false;
|
||||
if (themeSelector->currentText() != porymapConfig.theme) {
|
||||
const auto theme = themeSelector->currentText();
|
||||
porymapConfig.theme = theme;
|
||||
emit themeChanged(theme);
|
||||
porymapConfig.theme = themeSelector->currentText();
|
||||
changedTheme = true;
|
||||
}
|
||||
bool loadAllEventScripts = ui->checkBox_AutocompleteAllScripts->isChecked();
|
||||
if (loadAllEventScripts != porymapConfig.loadAllEventScripts) {
|
||||
|
|
@ -90,9 +110,22 @@ void PreferenceEditor::saveFields() {
|
|||
if (ui->checkBox_StatusWarnings->isChecked()) porymapConfig.statusBarLogTypes.insert(LogType::LOG_WARN);
|
||||
if (ui->checkBox_StatusInformation->isChecked()) porymapConfig.statusBarLogTypes.insert(LogType::LOG_INFO);
|
||||
|
||||
if (porymapConfig.applicationFont != this->applicationFont) {
|
||||
porymapConfig.applicationFont = this->applicationFont;
|
||||
changedTheme = true;
|
||||
}
|
||||
if (porymapConfig.mapListFont != this->mapListFont) {
|
||||
porymapConfig.mapListFont = this->mapListFont;
|
||||
changedTheme = true;
|
||||
}
|
||||
|
||||
porymapConfig.save();
|
||||
|
||||
emit preferencesSaved();
|
||||
|
||||
if (changedTheme) {
|
||||
emit themeChanged(porymapConfig.theme);
|
||||
}
|
||||
}
|
||||
|
||||
void PreferenceEditor::dialogButtonClicked(QAbstractButton *button) {
|
||||
|
|
@ -106,3 +139,12 @@ void PreferenceEditor::dialogButtonClicked(QAbstractButton *button) {
|
|||
close();
|
||||
}
|
||||
}
|
||||
|
||||
void PreferenceEditor::openFontDialog(QFont *font) {
|
||||
auto dialog = new QFontDialog(*font, this);
|
||||
dialog->setAttribute(Qt::WA_DeleteOnClose);
|
||||
connect(dialog, &QFontDialog::fontSelected, [font](const QFont &selectedFont) {
|
||||
*font = selectedFont;
|
||||
});
|
||||
dialog->open();
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user