Commit f76050aa authored by Waqar Ahmed's avatar Waqar Ahmed
Browse files

Fix commit dialog width

It was broken since ever and hack was keeping it working in some
situations...

Also fix that subject length label color changes as soon as it hits 52,
but it should actually turn red at 53.

(cherry picked from commit 87bf0ed6)
parent 82664284
......@@ -74,8 +74,6 @@ GitCommitDialog::GitCommitDialog(const QString &lastCommit, const QFont &font, Q
m_le.setFont(font);
QFontMetrics fm(font);
/** Add 8 because 4 + 4 margins on left / right */
const int width = (fm.averageCharWidth() * 72) + 8;
m_leLen.setText(QStringLiteral("0 / 52"));
......@@ -97,10 +95,6 @@ GitCommitDialog::GitCommitDialog(const QString &lastCommit, const QFont &font, Q
vlayout->addWidget(&m_le);
vlayout->addWidget(&m_pe);
// set 72 chars wide plain text edit
m_pe.resize(width, m_pe.height());
resize(width, fm.averageCharWidth() * 52);
loadCommitMessage(lastCommit);
auto bottomLayout = new QHBoxLayout;
......@@ -151,6 +145,12 @@ GitCommitDialog::GitCommitDialog(const QString &lastCommit, const QFont &font, Q
*/
auto hl = new BadLengthHighlighter(m_pe.document(), 72);
Q_UNUSED(hl)
// set 72 chars wide plain text edit
const int avgCharWidth = fm.averageCharWidth();
const int width = (avgCharWidth * 72);
const int fw = width + vlayout->contentsMargins().left() * 2 + m_pe.frameWidth() * 2 + m_pe.contentsMargins().left() + vlayout->spacing();
resize(fw, avgCharWidth * 52);
}
void GitCommitDialog::loadCommitMessage(const QString &lastCommit)
......@@ -196,7 +196,7 @@ void GitCommitDialog::setAmendingCommit()
void GitCommitDialog::updateLineSizeLabel()
{
int len = m_le.text().length();
if (len < 52) {
if (len <= 52) {
m_leLen.setText(i18nc("Number of characters", "%1 / 52", QString::number(len)));
} else {
const QColor red = KColorScheme().foreground(KColorScheme::NegativeText).color();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment