Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/qml/filters/richtext/vui.qml
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,7 @@ Shotcut.VuiBase {
icon.source: 'qrc:///icons/oxygen/32x32/actions/font.png'
onTriggered: {
fontDialog.selectedFont.family = document.fontFamily;
fontDialog.selectedFont.styleName = document.fontStyleName;
fontDialog.selectedFont.pointSize = document.fontSize;
fontDialog.selectedFont.underline = document.underline;
fontDialog.selectedFont.strikeout = document.strikeout;
Expand Down Expand Up @@ -672,7 +673,8 @@ Shotcut.VuiBase {
icon.source: 'qrc:///icons/oxygen/32x32/actions/font.png'
onTriggered: {
fontDialog.selectedFont.family = document.fontFamily;
fontDialog.seelctedFont.pointSize = document.fontSize;
fontDialog.selectedFont.styleName = document.fontStyleName;
fontDialog.selectedFont.pointSize = document.fontSize;
fontDialog.selectedFont.underline = document.underline;
fontDialog.selectedFont.strikeout = document.strikeout;
fontDialog.open();
Expand Down Expand Up @@ -714,6 +716,7 @@ Shotcut.VuiBase {

onAccepted: {
document.fontFamily = selectedFont.family;
document.fontStyleName = selectedFont.styleName;
document.fontSize = selectedFont.pointSize;
document.underline = selectedFont.underline;
document.strikeout = selectedFont.strikeout;
Expand Down
22 changes: 19 additions & 3 deletions src/qml/modules/Shotcut/Controls/TextFilterUi.qml
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,12 @@ GridLayout {
middleRadioButton.checked = true;
else if (align === 'bottom')
bottomRadioButton.checked = true;
const mltFamily = filter.get('family');
const fontStyleName = filter.get('shotcut:fontStyle');
const qtFamily = (fontStyleName && mltFamily.endsWith(' ' + fontStyleName)) ? mltFamily.slice(0, mltFamily.length - fontStyleName.length - 1) : mltFamily;
fontDialog.selectedFont = Qt.font({
"family": filter.get('family'),
"family": qtFamily,
"styleName": fontStyleName,
"pointSize": getPointSize(),
"italic": filter.get('style') === 'italic',
"weight": filter.getDouble('weight'),
Expand Down Expand Up @@ -246,7 +250,13 @@ GridLayout {
property string fontFamily: ''

onSelectedFontChanged: {
filter.set('family', selectedFont.family);
const stdStyles = ['', 'regular', 'bold', 'italic', 'bold italic', 'oblique', 'bold oblique'];
const styleName = selectedFont.styleName;
let family = selectedFont.family;
filter.set('shotcut:fontStyle', styleName);
if (styleName && !stdStyles.includes(styleName.toLowerCase()))
family = family + ' ' + styleName;
filter.set('family', family);
filter.set('weight', selectedFont.weight);
filter.set('style', selectedFont.italic ? 'italic' : 'normal');
filter.set('underline', selectedFont.underline);
Expand All @@ -257,7 +267,13 @@ GridLayout {
}
refreshFontButton();
}
onAccepted: fontFamily = selectedFont.family
onAccepted: {
const stdStyles = ['', 'regular', 'bold', 'italic', 'bold italic', 'oblique', 'bold oblique'];
const styleName = selectedFont.styleName;
fontFamily = selectedFont.family;
if (styleName && !stdStyles.includes(styleName.toLowerCase()))
fontFamily = fontFamily + ' ' + styleName;
}
onRejected: {
filter.set('family', fontFamily);
refreshFontButton();
Expand Down
23 changes: 23 additions & 0 deletions src/qmltypes/qmlrichtext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ void QmlRichText::setCursorPosition(int position)
void QmlRichText::reset()
{
emit fontFamilyChanged();
emit fontStyleNameChanged();
emit alignmentChanged();
emit boldChanged();
emit italicChanged();
Expand Down Expand Up @@ -423,3 +424,25 @@ void QmlRichText::setFontFamily(const QString &arg)
mergeFormatOnWordOrSelection(format);
emit fontFamilyChanged();
}

QString QmlRichText::fontStyleName() const
{
QTextCursor cursor = textCursor();
if (cursor.isNull())
return QString();
QTextCharFormat format = cursor.charFormat();
return format.font().styleName();
}

void QmlRichText::setFontStyleName(const QString &arg)
{
QTextCursor cursor = textCursor();
if (cursor.isNull())
return;
QTextCharFormat format;
QFont font;
font.setStyleName(arg);
format.setFont(font, QTextCharFormat::FontPropertiesSpecifiedOnly);
mergeFormatOnWordOrSelection(format);
emit fontStyleNameChanged();
}
5 changes: 5 additions & 0 deletions src/qmltypes/qmlrichtext.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ class QmlRichText : public QObject
Q_PROPERTY(int selectionEnd READ selectionEnd WRITE setSelectionEnd NOTIFY selectionEndChanged)
Q_PROPERTY(QColor textColor READ textColor WRITE setTextColor NOTIFY textColorChanged)
Q_PROPERTY(QString fontFamily READ fontFamily WRITE setFontFamily NOTIFY fontFamilyChanged)
Q_PROPERTY(
QString fontStyleName READ fontStyleName WRITE setFontStyleName NOTIFY fontStyleNameChanged)
Q_PROPERTY(Qt::Alignment alignment READ alignment WRITE setAlignment NOTIFY alignmentChanged)
Q_PROPERTY(bool bold READ bold WRITE setBold NOTIFY boldChanged)
Q_PROPERTY(bool italic READ italic WRITE setItalic NOTIFY italicChanged)
Expand All @@ -78,6 +80,7 @@ class QmlRichText : public QObject
int selectionStart() const { return m_selectionStart; }
int selectionEnd() const { return m_selectionEnd; }
QString fontFamily() const;
QString fontStyleName() const;
QColor textColor() const;
Qt::Alignment alignment() const;
void setAlignment(Qt::Alignment a);
Expand All @@ -98,6 +101,7 @@ public slots:
void setFontSize(int arg);
void setTextColor(const QColor &arg);
void setFontFamily(const QString &arg);
void setFontStyleName(const QString &arg);
void setFileUrl(const QUrl &arg);
void setText(const QString &arg);
void saveAs(const QUrl &arg, QString fileType = QString());
Expand All @@ -113,6 +117,7 @@ public slots:
void selectionStartChanged();
void selectionEndChanged();
void fontFamilyChanged();
void fontStyleNameChanged();
void textColorChanged();
void alignmentChanged();
void boldChanged();
Expand Down
Loading