viewertexteditor: improved UI
This commit is contained in:
@@ -344,7 +344,7 @@ void ViewerDisplayWidget::mouseDoubleClickEvent(QMouseEvent *event)
|
|||||||
text_edit->setGeometry(transformed_geom.toRect());
|
text_edit->setGeometry(transformed_geom.toRect());
|
||||||
|
|
||||||
ViewerTextEditorToolBar *toolbar = new ViewerTextEditorToolBar(this);
|
ViewerTextEditorToolBar *toolbar = new ViewerTextEditorToolBar(this);
|
||||||
toolbar->setWindowFlags(Qt::FramelessWindowHint | Qt::Window | Qt::WindowStaysOnTopHint);
|
toolbar->setWindowFlags(Qt::Dialog | Qt::FramelessWindowHint);
|
||||||
toolbar->resize(toolbar->sizeHint());
|
toolbar->resize(toolbar->sizeHint());
|
||||||
|
|
||||||
QPoint pos = mapToGlobal(QPoint(transformed_geom.x(), transformed_geom.y() - toolbar->height()));
|
QPoint pos = mapToGlobal(QPoint(transformed_geom.x(), transformed_geom.y() - toolbar->height()));
|
||||||
|
|||||||
@@ -36,7 +36,8 @@ namespace olive {
|
|||||||
|
|
||||||
ViewerTextEditor::ViewerTextEditor(double scale, QWidget *parent) :
|
ViewerTextEditor::ViewerTextEditor(double scale, QWidget *parent) :
|
||||||
super(parent),
|
super(parent),
|
||||||
transparent_clone_(nullptr)
|
transparent_clone_(nullptr),
|
||||||
|
block_update_toolbar_signal_(false)
|
||||||
{
|
{
|
||||||
// Ensure default text color is white
|
// Ensure default text color is white
|
||||||
QPalette p = palette();
|
QPalette p = palette();
|
||||||
@@ -198,8 +199,10 @@ void ViewerTextEditor::FocusChanged(QWidget *old, QWidget *now)
|
|||||||
|
|
||||||
void ViewerTextEditor::FormatChanged(const QTextCharFormat &f)
|
void ViewerTextEditor::FormatChanged(const QTextCharFormat &f)
|
||||||
{
|
{
|
||||||
foreach (ViewerTextEditorToolBar *toolbar, toolbars_) {
|
if (!block_update_toolbar_signal_) {
|
||||||
UpdateToolBar(toolbar, f, textCursor().blockFormat(), this->alignment());
|
foreach (ViewerTextEditorToolBar *toolbar, toolbars_) {
|
||||||
|
UpdateToolBar(toolbar, f, textCursor().blockFormat(), this->alignment());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -210,42 +213,51 @@ void ViewerTextEditor::SetFamily(const QString &s)
|
|||||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 13, 0)
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 13, 0)
|
||||||
f.setFontFamilies({s});
|
f.setFontFamilies({s});
|
||||||
#endif
|
#endif
|
||||||
mergeCurrentCharFormat(f);
|
MergeCharFormat(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ViewerTextEditor::SetStyle(const QString &s)
|
void ViewerTextEditor::SetStyle(const QString &s)
|
||||||
{
|
{
|
||||||
QTextCharFormat f;
|
QTextCharFormat f;
|
||||||
f.setFontStyleName(s);
|
f.setFontStyleName(s);
|
||||||
mergeCurrentCharFormat(f);
|
MergeCharFormat(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ViewerTextEditor::SetFontStrikethrough(bool e)
|
void ViewerTextEditor::SetFontStrikethrough(bool e)
|
||||||
{
|
{
|
||||||
QTextCharFormat f;
|
QTextCharFormat f;
|
||||||
f.setFontStrikeOut(e);
|
f.setFontStrikeOut(e);
|
||||||
mergeCurrentCharFormat(f);
|
MergeCharFormat(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ViewerTextEditor::SetSmallCaps(bool e)
|
void ViewerTextEditor::SetSmallCaps(bool e)
|
||||||
{
|
{
|
||||||
QTextCharFormat f;
|
QTextCharFormat f;
|
||||||
f.setFontCapitalization(e ? QFont::SmallCaps : QFont::MixedCase);
|
f.setFontCapitalization(e ? QFont::SmallCaps : QFont::MixedCase);
|
||||||
mergeCurrentCharFormat(f);
|
MergeCharFormat(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ViewerTextEditor::SetFontStretch(int i)
|
void ViewerTextEditor::SetFontStretch(int i)
|
||||||
{
|
{
|
||||||
QTextCharFormat f;
|
QTextCharFormat f;
|
||||||
f.setFontStretch(i);
|
f.setFontStretch(i);
|
||||||
mergeCurrentCharFormat(f);
|
MergeCharFormat(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ViewerTextEditor::SetFontKerning(qreal i)
|
void ViewerTextEditor::SetFontKerning(qreal i)
|
||||||
{
|
{
|
||||||
QTextCharFormat f;
|
QTextCharFormat f;
|
||||||
f.setFontLetterSpacing(i);
|
f.setFontLetterSpacing(i);
|
||||||
mergeCurrentCharFormat(f);
|
MergeCharFormat(f);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ViewerTextEditor::MergeCharFormat(const QTextCharFormat &fmt)
|
||||||
|
{
|
||||||
|
// mergeCurrentCharFormat throws a currentCharFormatChanged signal that updates the toolbar,
|
||||||
|
// this can be undesirable if the user is currently typing a font
|
||||||
|
block_update_toolbar_signal_ = true;
|
||||||
|
mergeCurrentCharFormat(fmt);
|
||||||
|
block_update_toolbar_signal_ = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ViewerTextEditor::SetLineHeight(qreal i)
|
void ViewerTextEditor::SetLineHeight(qreal i)
|
||||||
|
|||||||
@@ -142,12 +142,16 @@ protected:
|
|||||||
private:
|
private:
|
||||||
static void UpdateToolBar(ViewerTextEditorToolBar *toolbar, const QTextCharFormat &f, const QTextBlockFormat &b, Qt::Alignment alignment);
|
static void UpdateToolBar(ViewerTextEditorToolBar *toolbar, const QTextCharFormat &f, const QTextBlockFormat &b, Qt::Alignment alignment);
|
||||||
|
|
||||||
|
void MergeCharFormat(const QTextCharFormat &fmt);
|
||||||
|
|
||||||
QVector<ViewerTextEditorToolBar *> toolbars_;
|
QVector<ViewerTextEditorToolBar *> toolbars_;
|
||||||
|
|
||||||
QImage dpi_force_;
|
QImage dpi_force_;
|
||||||
|
|
||||||
QTextDocument *transparent_clone_;
|
QTextDocument *transparent_clone_;
|
||||||
|
|
||||||
|
bool block_update_toolbar_signal_;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void FocusChanged(QWidget *old, QWidget *now);
|
void FocusChanged(QWidget *old, QWidget *now);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user