Skip to content

Commit

Permalink
FIX(ui): resolve text/icon scaling issues
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
dexgs committed Aug 22, 2022
1 parent 0ebe49f commit 369d963
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
21 changes: 11 additions & 10 deletions src/mumble/Log.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,9 @@ QString Log::validHtml(const QString &html, QTextCursor *tc) {
}

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

QTextFrameFormat qttf;
qttf.setTopMargin(msgMargin);
qttf.setBottomMargin(0);
qttf.setPosition(QTextFrameFormat::FloatLeft);

LogTextBrowser *tlog = Global::get().mw->qteLog;
const int oldscrollvalue = tlog->getLogScroll();
const bool scroll = (oldscrollvalue == tlog->getLogScrollMaximum());
Expand All @@ -728,13 +735,6 @@ void Log::log(MsgType mt, const QString &console, const QString &terse, bool own
QString fixedNLPlain =
plain.replace(QLatin1String("\r\n"), QLatin1String("\n")).replace(QLatin1String("\r"), QLatin1String("\n"));

QTextFrameFormat qttf;
// `insertFrame` causes a blank line to precede the inserted frame.
// This is remedied by setting a negative top margin of equal height.
static int lineSpacing = QFontMetrics(tc.currentFrame()->format().toCharFormat().font()).lineSpacing();
qttf.setTopMargin(-lineSpacing);
qttf.setBottomMargin(msgMargin);

if (fixedNLPlain.contains(QRegExp(QLatin1String("\\n[ \\t]*$")))) {
// If the message ends with one or more blank lines (or lines only containing whitespace)
// paint a border around the message to make clear that it contains invisible parts.
Expand All @@ -743,10 +743,11 @@ void Log::log(MsgType mt, const QString &console, const QString &terse, bool own
qttf.setBorder(1);
qttf.setPadding(2);
qttf.setBorderStyle(QTextFrameFormat::BorderStyle_Dashed);
tc.insertFrame(qttf);
} else if (!tc.atStart()) {
tc.insertFrame(qttf);
}

tc.insertFrame(qttf);

const QString timeString =
dt.time().toString(QLatin1String(Global::get().s.bLog24HourClock ? "HH:mm:ss" : "hh:mm:ss AP"));
tc.insertHtml(Log::msgColor(QString::fromLatin1("[%1] ").arg(timeString.toHtmlEscaped()), Log::Time));
Expand Down
4 changes: 2 additions & 2 deletions src/mumble/UserView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,9 @@ UserView::UserView(QWidget *p) : QTreeView(p) {
// Calculate the icon size for status icons based on font size
// This should automaticially adjust size when the user has
// display scaling enabled
m_flagTotalDimension = QFontMetrics(p->font()).height();
m_flagTotalDimension = std::max(18, QFontMetrics(p->font()).height());
int flagIconPadding = 1;
int flagIconDimension = m_flagTotalDimension - (4 * flagIconPadding);
int flagIconDimension = m_flagTotalDimension - (2 * flagIconPadding);
setItemDelegate(new UserDelegate(this, m_flagTotalDimension, flagIconPadding, flagIconDimension));

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

0 comments on commit 369d963

Please sign in to comment.