mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-30 11:55:35 +08:00
Ref T369, replace font style in style sheet from font dialog
This commit is contained in:
@@ -11,9 +11,12 @@
|
||||
#include "ui_settingstextmessagestyle.h"
|
||||
#include "settingsfontdialog.h"
|
||||
#include "texteditdialog.h"
|
||||
#include "settingstextmessagestyle.h"
|
||||
|
||||
#include <QTextEdit>
|
||||
#include <QPushButton>
|
||||
#include <QRegularExpression>
|
||||
#include <QStringBuilder>
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
@@ -53,6 +56,8 @@ namespace BlackGui
|
||||
const QDialog::DialogCode r = static_cast<QDialog::DialogCode>(m_fontSettingsDialog->exec());
|
||||
if (r == QDialog::Accepted)
|
||||
{
|
||||
const QStringList familySizeStyle = this->getFamilySizeStyle();
|
||||
this->setFontFamilySizeStyle(familySizeStyle);
|
||||
emit this->changed();
|
||||
}
|
||||
}
|
||||
@@ -73,5 +78,20 @@ namespace BlackGui
|
||||
emit this->changed();
|
||||
}
|
||||
}
|
||||
|
||||
bool CSettingsTextMessageStyle::setFontFamilySizeStyle(const QStringList &familySizeStlye)
|
||||
{
|
||||
if (familySizeStlye.size() != 3) { return false; }
|
||||
static const QString f("font-family: \"%1\"; font-size: %2; font-style: %3");
|
||||
|
||||
QString style = m_style;
|
||||
const QString tableStyle = QStringLiteral("table { ") % f.arg(familySizeStlye.at(0), familySizeStlye.at(1), familySizeStlye.at(2)) % QStringLiteral(" }");
|
||||
|
||||
thread_local const QRegularExpression re("table\\s*\\{.*\\}");
|
||||
style.replace(re, tableStyle);
|
||||
|
||||
m_style = style;
|
||||
return true;
|
||||
}
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
@@ -63,6 +63,9 @@ namespace BlackGui
|
||||
|
||||
//! Change style
|
||||
void changeStyle();
|
||||
|
||||
//! Update the font part
|
||||
bool setFontFamilySizeStyle(const QStringList &familySizeStlye);
|
||||
};
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
Reference in New Issue
Block a user