Skip to content

Commit 369d963

Browse files
committed
FIX(ui): resolve text/icon scaling issues
Fixed chat log scaling issue introduced by PR mumble-voip#5619 (my fault, whoops) The bug fixed by that commit is still fixed after this PR, but the regression introduced has been resolved. Added minimum icon size for channel status icons which now scale since PR mumble-voip#5772 Initially, icons were too small at 100% scale.
1 parent 0ebe49f commit 369d963

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

src/mumble/Log.cpp

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -679,7 +679,9 @@ QString Log::validHtml(const QString &html, QTextCursor *tc) {
679679
}
680680

681681
if (tc) {
682-
tc->insertHtml(qtd.toHtml());
682+
QTextCursor tcNew(&qtd);
683+
tcNew.movePosition(QTextCursor::End, QTextCursor::KeepAnchor);
684+
tc->insertFragment(tcNew.selection());
683685
return QString();
684686
} else {
685687
return qtd.toHtml();
@@ -710,6 +712,11 @@ void Log::log(MsgType mt, const QString &console, const QString &terse, bool own
710712
// the setting might change in that time).
711713
const int msgMargin = Global::get().s.iChatMessageMargins;
712714

715+
QTextFrameFormat qttf;
716+
qttf.setTopMargin(msgMargin);
717+
qttf.setBottomMargin(0);
718+
qttf.setPosition(QTextFrameFormat::FloatLeft);
719+
713720
LogTextBrowser *tlog = Global::get().mw->qteLog;
714721
const int oldscrollvalue = tlog->getLogScroll();
715722
const bool scroll = (oldscrollvalue == tlog->getLogScrollMaximum());
@@ -728,13 +735,6 @@ void Log::log(MsgType mt, const QString &console, const QString &terse, bool own
728735
QString fixedNLPlain =
729736
plain.replace(QLatin1String("\r\n"), QLatin1String("\n")).replace(QLatin1String("\r"), QLatin1String("\n"));
730737

731-
QTextFrameFormat qttf;
732-
// `insertFrame` causes a blank line to precede the inserted frame.
733-
// This is remedied by setting a negative top margin of equal height.
734-
static int lineSpacing = QFontMetrics(tc.currentFrame()->format().toCharFormat().font()).lineSpacing();
735-
qttf.setTopMargin(-lineSpacing);
736-
qttf.setBottomMargin(msgMargin);
737-
738738
if (fixedNLPlain.contains(QRegExp(QLatin1String("\\n[ \\t]*$")))) {
739739
// If the message ends with one or more blank lines (or lines only containing whitespace)
740740
// paint a border around the message to make clear that it contains invisible parts.
@@ -743,10 +743,11 @@ void Log::log(MsgType mt, const QString &console, const QString &terse, bool own
743743
qttf.setBorder(1);
744744
qttf.setPadding(2);
745745
qttf.setBorderStyle(QTextFrameFormat::BorderStyle_Dashed);
746+
tc.insertFrame(qttf);
747+
} else if (!tc.atStart()) {
748+
tc.insertFrame(qttf);
746749
}
747750

748-
tc.insertFrame(qttf);
749-
750751
const QString timeString =
751752
dt.time().toString(QLatin1String(Global::get().s.bLog24HourClock ? "HH:mm:ss" : "hh:mm:ss AP"));
752753
tc.insertHtml(Log::msgColor(QString::fromLatin1("[%1] ").arg(timeString.toHtmlEscaped()), Log::Time));

src/mumble/UserView.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,9 @@ UserView::UserView(QWidget *p) : QTreeView(p) {
111111
// Calculate the icon size for status icons based on font size
112112
// This should automaticially adjust size when the user has
113113
// display scaling enabled
114-
m_flagTotalDimension = QFontMetrics(p->font()).height();
114+
m_flagTotalDimension = std::max(18, QFontMetrics(p->font()).height());
115115
int flagIconPadding = 1;
116-
int flagIconDimension = m_flagTotalDimension - (4 * flagIconPadding);
116+
int flagIconDimension = m_flagTotalDimension - (2 * flagIconPadding);
117117
setItemDelegate(new UserDelegate(this, m_flagTotalDimension, flagIconPadding, flagIconDimension));
118118

119119
connect(this, SIGNAL(doubleClicked(const QModelIndex &)), this, SLOT(nodeActivated(const QModelIndex &)));

0 commit comments

Comments
 (0)