Remove usages of deprecated APIs

Replaced:
  QPalette::ColorRole::Background -> QPalette::ColorRole::Window
  QPalette::ColorRole::Foreground -> QPalette::ColorRole::WindowText
  Qt::ItemDataRole::TextColorRole -> Qt::ItemDataRole::ForegroundRole
  QFontMetrics::width() -> QFontMetrics::horizontalAdvance()

Task-number: QTBUG-76491
Change-Id: I1302e6b569e725daa6f7be1428ffe055657fc644
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
Sona Kurazyan
2019-08-29 11:40:38 +02:00
parent 6f4aa0458c
commit 82bcf4e9f5
22 changed files with 52 additions and 59 deletions

View File

@@ -140,7 +140,7 @@ CustomColorDialog::CustomColorDialog(QWidget *parent) : QFrame(parent )
void CustomColorDialog::setupColor(const QColor &color) void CustomColorDialog::setupColor(const QColor &color)
{ {
QPalette pal; QPalette pal;
pal.setColor(QPalette::Background, color); pal.setColor(QPalette::Window, color);
m_beforeColorWidget->setPalette(pal); m_beforeColorWidget->setPalette(pal);
setColor(color); setColor(color);
} }
@@ -175,7 +175,7 @@ void CustomColorDialog::setupWidgets()
m_bSpinBox->setValue(m_color.blueF()); m_bSpinBox->setValue(m_color.blueF());
m_colorBox->setColor(m_color); m_colorBox->setColor(m_color);
QPalette pal; QPalette pal;
pal.setColor(QPalette::Background, m_color); pal.setColor(QPalette::Window, m_color);
m_currentColorWidget->setPalette(pal); m_currentColorWidget->setPalette(pal);
m_blockUpdate = false; m_blockUpdate = false;
} }

View File

@@ -56,7 +56,7 @@ public:
font.setPixelSize(size == FadingIndicator::LargeText ? 45 : 22); font.setPixelSize(size == FadingIndicator::LargeText ? 45 : 22);
m_label->setFont(font); m_label->setFont(font);
QPalette pal = palette(); QPalette pal = palette();
pal.setColor(QPalette::Foreground, pal.color(QPalette::Background)); pal.setColor(QPalette::WindowText, pal.color(QPalette::Window));
m_label->setPalette(pal); m_label->setPalette(pal);
auto layout = new QHBoxLayout; auto layout = new QHBoxLayout;
setLayout(layout); setLayout(layout);
@@ -98,7 +98,7 @@ protected:
if (!m_pixmap.isNull()) { if (!m_pixmap.isNull()) {
p.drawPixmap(rect(), m_pixmap); p.drawPixmap(rect(), m_pixmap);
} else { } else {
p.setBrush(palette().color(QPalette::Foreground)); p.setBrush(palette().color(QPalette::WindowText));
p.setPen(Qt::NoPen); p.setPen(Qt::NoPen);
p.drawRoundedRect(rect(), 15, 15); p.drawRoundedRect(rect(), 15, 15);
} }

View File

@@ -62,7 +62,7 @@ ConfigurationDialog::ConfigurationDialog(QWidget *parent) :
QPalette pal; QPalette pal;
pal.setColor(QPalette::Base, tf.background().color()); pal.setColor(QPalette::Base, tf.background().color());
pal.setColor(QPalette::Text, tf.foreground().color()); pal.setColor(QPalette::Text, tf.foreground().color());
pal.setColor(QPalette::Foreground, tf.foreground().color()); pal.setColor(QPalette::WindowText, tf.foreground().color());
if (selectionFormat.background().style() != Qt::NoBrush) if (selectionFormat.background().style() != Qt::NoBrush)
pal.setColor(QPalette::Highlight, selectionFormat.background().color()); pal.setColor(QPalette::Highlight, selectionFormat.background().color());
pal.setBrush(QPalette::HighlightedText, selectionFormat.foreground()); pal.setBrush(QPalette::HighlightedText, selectionFormat.foreground());

View File

@@ -247,7 +247,7 @@ QVariant SearchResultTreeModel::data(const SearchResultTreeItem *row, int role)
else else
result = QVariant(); result = QVariant();
break; break;
case Qt::TextColorRole: case Qt::ForegroundRole:
result = m_color.textForeground; result = m_color.textForeground;
break; break;
case Qt::BackgroundRole: case Qt::BackgroundRole:

View File

@@ -64,31 +64,28 @@ static QPalette buttonPalette(bool isActive, bool isCursorInside, bool forText)
Theme *theme = Utils::creatorTheme(); Theme *theme = Utils::creatorTheme();
if (isActive) { if (isActive) {
if (forText) { if (forText) {
pal.setColor(QPalette::Background, theme->color(Theme::Welcome_ForegroundPrimaryColor)); pal.setColor(QPalette::Window, theme->color(Theme::Welcome_ForegroundPrimaryColor));
pal.setColor(QPalette::Foreground, theme->color(Theme::Welcome_ForegroundPrimaryColor));
pal.setColor(QPalette::WindowText, theme->color(Theme::Welcome_BackgroundColor)); pal.setColor(QPalette::WindowText, theme->color(Theme::Welcome_BackgroundColor));
} else { } else {
pal.setColor(QPalette::Background, theme->color(Theme::Welcome_ForegroundPrimaryColor)); pal.setColor(QPalette::Window, theme->color(Theme::Welcome_ForegroundPrimaryColor));
pal.setColor(QPalette::Foreground, theme->color(Theme::Welcome_ForegroundPrimaryColor)); pal.setColor(QPalette::WindowText, theme->color(Theme::Welcome_ForegroundPrimaryColor));
} }
} else { } else {
if (isCursorInside) { if (isCursorInside) {
if (forText) { if (forText) {
pal.setColor(QPalette::Background, theme->color(Theme::Welcome_HoverColor)); pal.setColor(QPalette::Window, theme->color(Theme::Welcome_HoverColor));
pal.setColor(QPalette::Foreground, theme->color(Theme::Welcome_HoverColor));
pal.setColor(QPalette::WindowText, theme->color(Theme::Welcome_TextColor)); pal.setColor(QPalette::WindowText, theme->color(Theme::Welcome_TextColor));
} else { } else {
pal.setColor(QPalette::Background, theme->color(Theme::Welcome_HoverColor)); pal.setColor(QPalette::Window, theme->color(Theme::Welcome_HoverColor));
pal.setColor(QPalette::Foreground, theme->color(Theme::Welcome_ForegroundSecondaryColor)); pal.setColor(QPalette::WindowText, theme->color(Theme::Welcome_ForegroundSecondaryColor));
} }
} else { } else {
if (forText) { if (forText) {
pal.setColor(QPalette::Background, theme->color(Theme::Welcome_ForegroundPrimaryColor)); pal.setColor(QPalette::Window, theme->color(Theme::Welcome_ForegroundPrimaryColor));
pal.setColor(QPalette::Foreground, theme->color(Theme::Welcome_BackgroundColor));
pal.setColor(QPalette::WindowText, theme->color(Theme::Welcome_TextColor)); pal.setColor(QPalette::WindowText, theme->color(Theme::Welcome_TextColor));
} else { } else {
pal.setColor(QPalette::Background, theme->color(Theme::Welcome_BackgroundColor)); pal.setColor(QPalette::Window, theme->color(Theme::Welcome_BackgroundColor));
pal.setColor(QPalette::Foreground, theme->color(Theme::Welcome_ForegroundSecondaryColor)); pal.setColor(QPalette::WindowText, theme->color(Theme::Welcome_ForegroundSecondaryColor));
} }
} }
} }

View File

@@ -246,14 +246,12 @@ QPalette panelPalette(const QPalette &oldPalette, bool lightColored = false)
QPalette pal = oldPalette; QPalette pal = oldPalette;
pal.setBrush(QPalette::All, QPalette::WindowText, color); pal.setBrush(QPalette::All, QPalette::WindowText, color);
pal.setBrush(QPalette::All, QPalette::ButtonText, color); pal.setBrush(QPalette::All, QPalette::ButtonText, color);
pal.setBrush(QPalette::All, QPalette::Foreground, color);
if (lightColored) if (lightColored)
color.setAlpha(100); color.setAlpha(100);
else else
color = creatorTheme()->color(Theme::IconsDisabledColor); color = creatorTheme()->color(Theme::IconsDisabledColor);
pal.setBrush(QPalette::Disabled, QPalette::WindowText, color); pal.setBrush(QPalette::Disabled, QPalette::WindowText, color);
pal.setBrush(QPalette::Disabled, QPalette::ButtonText, color); pal.setBrush(QPalette::Disabled, QPalette::ButtonText, color);
pal.setBrush(QPalette::Disabled, QPalette::Foreground, color);
return pal; return pal;
} }
@@ -291,7 +289,7 @@ void ManhattanStyle::polish(QWidget *widget)
const bool isLightColored = lightColored(widget); const bool isLightColored = lightColored(widget);
QPalette palette = panelPalette(widget->palette(), isLightColored); QPalette palette = panelPalette(widget->palette(), isLightColored);
if (!isLightColored) if (!isLightColored)
palette.setBrush(QPalette::All, QPalette::Foreground, palette.setBrush(QPalette::All, QPalette::WindowText,
creatorTheme()->color(Theme::ComboBoxTextColor)); creatorTheme()->color(Theme::ComboBoxTextColor));
widget->setPalette(palette); widget->setPalette(palette);
widget->setMaximumHeight(StyleHelper::navigationWidgetHeight() - 2); widget->setMaximumHeight(StyleHelper::navigationWidgetHeight() - 2);
@@ -738,7 +736,7 @@ void ManhattanStyle::drawControl(ControlElement element, const QStyleOption *opt
painter->drawText(editRect.adjusted(1, 0, -1, 0), Qt::AlignLeft | Qt::AlignVCenter, text); painter->drawText(editRect.adjusted(1, 0, -1, 0), Qt::AlignLeft | Qt::AlignVCenter, text);
} }
painter->setPen((option->state & State_Enabled) painter->setPen((option->state & State_Enabled)
? option->palette.color(QPalette::Foreground) ? option->palette.color(QPalette::WindowText)
: creatorTheme()->color(Theme::IconsDisabledColor)); : creatorTheme()->color(Theme::IconsDisabledColor));
painter->drawText(editRect.adjusted(1, 0, -1, 0), Qt::AlignLeft | Qt::AlignVCenter, text); painter->drawText(editRect.adjusted(1, 0, -1, 0), Qt::AlignLeft | Qt::AlignVCenter, text);

View File

@@ -284,7 +284,7 @@ protected:
QPainter p(this); QPainter p(this);
QPalette pal = m_editor->extraArea()->palette(); QPalette pal = m_editor->extraArea()->palette();
const QColor fg = pal.color(QPalette::Dark); const QColor fg = pal.color(QPalette::Dark);
const QColor bg = pal.color(QPalette::Background); const QColor bg = pal.color(QPalette::Window);
p.setPen(fg); p.setPen(fg);
// Draw relative line numbers. // Draw relative line numbers.

View File

@@ -216,7 +216,7 @@ void GerritPushDialog::setChangeRange()
QPalette palette = QApplication::palette(); QPalette palette = QApplication::palette();
if (currentRange > ReasonableDistance) { if (currentRange > ReasonableDistance) {
const QColor errorColor = Utils::creatorTheme()->color(Utils::Theme::TextColorError); const QColor errorColor = Utils::creatorTheme()->color(Utils::Theme::TextColorError);
palette.setColor(QPalette::Foreground, errorColor); palette.setColor(QPalette::WindowText, errorColor);
palette.setColor(QPalette::ButtonText, errorColor); palette.setColor(QPalette::ButtonText, errorColor);
labelText.append("\n" + tr("Are you sure you selected the right target branch?")); labelText.append("\n" + tr("Are you sure you selected the right target branch?"));
} }

View File

@@ -236,7 +236,7 @@ void DescriptionWidgetDecorator::highlightCurrentContents(
sel.cursor.select(QTextCursor::LineUnderCursor); sel.cursor.select(QTextCursor::LineUnderCursor);
sel.format.setUnderlineStyle(QTextCharFormat::SingleUnderline); sel.format.setUnderlineStyle(QTextCharFormat::SingleUnderline);
const QColor textColor = TextEditor::TextEditorSettings::fontSettings().formatFor(TextEditor::C_TEXT).foreground(); const QColor textColor = TextEditor::TextEditorSettings::fontSettings().formatFor(TextEditor::C_TEXT).foreground();
sel.format.setUnderlineColor(textColor.isValid() ? textColor : textEditor->palette().color(QPalette::Foreground)); sel.format.setUnderlineColor(textColor.isValid() ? textColor : textEditor->palette().color(QPalette::WindowText));
textEditor->setExtraSelections(TextEditor::TextEditorWidget::OtherSelection, textEditor->setExtraSelections(TextEditor::TextEditorWidget::OtherSelection,
QList<QTextEdit::ExtraSelection>() << sel); QList<QTextEdit::ExtraSelection>() << sel);
} }

View File

@@ -186,9 +186,9 @@ void PanelsWidget::addPropertiesPanel(const QString &displayName, const QIcon &i
QPalette palette = nameLabel->palette(); QPalette palette = nameLabel->palette();
for (int i = QPalette::Active; i < QPalette::NColorGroups; ++i ) { for (int i = QPalette::Active; i < QPalette::NColorGroups; ++i ) {
// FIXME: theming // FIXME: theming
QColor foregroundColor = palette.color(QPalette::ColorGroup(i), QPalette::Foreground); QColor foregroundColor = palette.color(QPalette::ColorGroup(i), QPalette::WindowText);
foregroundColor.setAlpha(110); foregroundColor.setAlpha(110);
palette.setBrush(QPalette::ColorGroup(i), QPalette::Foreground, foregroundColor); palette.setBrush(QPalette::ColorGroup(i), QPalette::WindowText, foregroundColor);
} }
nameLabel->setPalette(palette); nameLabel->setPalette(palette);
nameLabel->setContentsMargins(0, ABOVE_HEADING_MARGIN, 0, 0); nameLabel->setContentsMargins(0, ABOVE_HEADING_MARGIN, 0, 0);

View File

@@ -175,7 +175,7 @@ QVariant FlatModel::data(const QModelIndex &index, int role) const
result = font; result = font;
break; break;
} }
case Qt::TextColorRole: { case Qt::ForegroundRole: {
result = node->isEnabled() ? m_enabledTextColor : m_disabledTextColor; result = node->isEnabled() ? m_enabledTextColor : m_disabledTextColor;
break; break;
} }

View File

@@ -350,7 +350,7 @@ public:
return k->icon(); return k->icon();
} }
case Qt::TextColorRole: { case Qt::ForegroundRole: {
if (!isEnabled()) if (!isEnabled())
return Utils::creatorTheme()->color(Theme::TextColorDisabled); return Utils::creatorTheme()->color(Theme::TextColorDisabled);
break; break;

View File

@@ -538,7 +538,7 @@ void GraphicsView::drawValueScale(QPainter *painter, const QRectF &rect)
double GraphicsView::timeLabelInterval(QPainter *painter, double maxTime) double GraphicsView::timeLabelInterval(QPainter *painter, double maxTime)
{ {
QFontMetrics fm(painter->font()); QFontMetrics fm(painter->font());
int minTextSpacing = fm.width(QString("X%1X").arg(maxTime)); int minTextSpacing = fm.horizontalAdvance(QString("X%1X").arg(maxTime));
int deltaTime = 1; int deltaTime = 1;
int nextFactor = 5; int nextFactor = 5;

View File

@@ -70,9 +70,7 @@ QPalette singleColorPalette(const QColor &color)
{ {
QPalette palette; QPalette palette;
palette.setColor(QPalette::Window, color); palette.setColor(QPalette::Window, color);
palette.setColor(QPalette::Background, color);
palette.setColor(QPalette::WindowText, color); palette.setColor(QPalette::WindowText, color);
palette.setColor(QPalette::Foreground, color);
palette.setColor(QPalette::Base, color); palette.setColor(QPalette::Base, color);
palette.setColor(QPalette::AlternateBase, color); palette.setColor(QPalette::AlternateBase, color);
palette.setColor(QPalette::ToolTipBase, color); palette.setColor(QPalette::ToolTipBase, color);

View File

@@ -219,7 +219,7 @@ QVariant QmlProfilerStatisticsModel::dataForMainEntry(const QModelIndex &index,
return m_rootDuration > 0 ? "+" : "-"; return m_rootDuration > 0 ? "+" : "-";
case TypeIdRole: case TypeIdRole:
return s_mainEntryTypeId; return s_mainEntryTypeId;
case Qt::TextColorRole: case Qt::ForegroundRole:
return Utils::creatorTheme()->color(Utils::Theme::Timeline_TextColor); return Utils::creatorTheme()->color(Utils::Theme::Timeline_TextColor);
case SortRole: case SortRole:
switch (index.column()) { switch (index.column()) {
@@ -296,7 +296,7 @@ QVariant QmlProfilerStatisticsModel::data(const QModelIndex &index, int role) co
auto it = m_notes.constFind(typeIndex); auto it = m_notes.constFind(typeIndex);
return it == m_notes.constEnd() ? QString() : it.value(); return it == m_notes.constEnd() ? QString() : it.value();
} }
case Qt::TextColorRole: case Qt::ForegroundRole:
return (stats.recursive > 0 || m_notes.contains(typeIndex)) return (stats.recursive > 0 || m_notes.contains(typeIndex))
? Utils::creatorTheme()->color(Utils::Theme::Timeline_HighlightColor) ? Utils::creatorTheme()->color(Utils::Theme::Timeline_HighlightColor)
: Utils::creatorTheme()->color(Utils::Theme::Timeline_TextColor); : Utils::creatorTheme()->color(Utils::Theme::Timeline_TextColor);
@@ -393,7 +393,7 @@ void QmlProfilerStatisticsModel::typeDetailsChanged(int typeIndex)
void QmlProfilerStatisticsModel::notesChanged(int typeIndex) void QmlProfilerStatisticsModel::notesChanged(int typeIndex)
{ {
static const QVector<int> noteRoles({Qt::ToolTipRole, Qt::TextColorRole}); static const QVector<int> noteRoles({Qt::ToolTipRole, Qt::ForegroundRole});
const Timeline::TimelineNotesModel *notesModel = m_modelManager->notesModel(); const Timeline::TimelineNotesModel *notesModel = m_modelManager->notesModel();
if (typeIndex == s_invalidTypeId) { if (typeIndex == s_invalidTypeId) {
m_notes.clear(); m_notes.clear();
@@ -564,7 +564,7 @@ QVariant QmlProfilerStatisticsRelativesModel::dataForMainEntry(qint64 totalDurat
switch (role) { switch (role) {
case TypeIdRole: case TypeIdRole:
return QmlProfilerStatisticsModel::s_mainEntryTypeId; return QmlProfilerStatisticsModel::s_mainEntryTypeId;
case Qt::TextColorRole: case Qt::ForegroundRole:
return Utils::creatorTheme()->color(Utils::Theme::Timeline_TextColor); return Utils::creatorTheme()->color(Utils::Theme::Timeline_TextColor);
case SortRole: case SortRole:
if (column == RelativeTotalTime) if (column == RelativeTotalTime)
@@ -614,7 +614,7 @@ QVariant QmlProfilerStatisticsRelativesModel::data(const QModelIndex &index, int
return type.location().column(); return type.location().column();
case Qt::ToolTipRole: case Qt::ToolTipRole:
return stats.isRecursive ? tr("called recursively") : QString(); return stats.isRecursive ? tr("called recursively") : QString();
case Qt::TextColorRole: case Qt::ForegroundRole:
return stats.isRecursive return stats.isRecursive
? Utils::creatorTheme()->color(Utils::Theme::Timeline_HighlightColor) ? Utils::creatorTheme()->color(Utils::Theme::Timeline_HighlightColor)
: Utils::creatorTheme()->color(Utils::Theme::Timeline_TextColor); : Utils::creatorTheme()->color(Utils::Theme::Timeline_TextColor);

View File

@@ -4092,7 +4092,8 @@ void TextEditorWidgetPrivate::paintRightMarginArea(PaintEventData &data, QPainte
return; return;
// Don't use QFontMetricsF::averageCharWidth here, due to it returning // Don't use QFontMetricsF::averageCharWidth here, due to it returning
// a fractional size even when this is not supported by the platform. // a fractional size even when this is not supported by the platform.
data.rightMargin = QFontMetricsF(q->font()).width(QLatin1Char('x')) * m_visibleWrapColumn data.rightMargin = QFontMetricsF(q->font()).horizontalAdvance(QLatin1Char('x'))
* m_visibleWrapColumn
+ data.offset.x() + 4; + data.offset.x() + 4;
const QRect viewportRect = q->viewport()->rect(); const QRect viewportRect = q->viewport()->rect();
if (data.rightMargin < viewportRect.width()) { if (data.rightMargin < viewportRect.width()) {
@@ -4268,7 +4269,7 @@ void TextEditorWidgetPrivate::paintFindScope(const PaintEventData &data, QPainte
QTextLayout *layout = block.layout(); QTextLayout *layout = block.layout();
QString text = block.text(); QString text = block.text();
const TabSettings ts = m_document->tabSettings(); const TabSettings ts = m_document->tabSettings();
qreal spacew = QFontMetricsF(q->font()).width(QLatin1Char(' ')); qreal spacew = QFontMetricsF(q->font()).horizontalAdvance(QLatin1Char(' '));
int offset = 0; int offset = 0;
int relativePos = ts.positionAtColumn(text, int relativePos = ts.positionAtColumn(text,
@@ -4358,7 +4359,7 @@ void TextEditorWidgetPrivate::paintBlockSelection(const PaintEventData &data, QP
QRectF blockBoundingRect = q->blockBoundingRect(data.block).translated(data.offset); QRectF blockBoundingRect = q->blockBoundingRect(data.block).translated(data.offset);
QString text = data.block.text(); QString text = data.block.text();
const TabSettings tabSettings = m_document->tabSettings(); const TabSettings tabSettings = m_document->tabSettings();
const qreal spacew = QFontMetricsF(q->font()).width(QLatin1Char(' ')); const qreal spacew = QFontMetricsF(q->font()).horizontalAdvance(QLatin1Char(' '));
const int cursorw = q->overwriteMode() ? QFontMetrics(q->font()).horizontalAdvance(QLatin1Char(' ')) const int cursorw = q->overwriteMode() ? QFontMetrics(q->font()).horizontalAdvance(QLatin1Char(' '))
: q->cursorWidth(); : q->cursorWidth();
@@ -4433,14 +4434,14 @@ void TextEditorWidgetPrivate::paintCursorAsBlock(const PaintEventData &data, QPa
w = line.cursorToX(relativePos + 1) - x; w = line.cursorToX(relativePos + 1) - x;
if (data.doc->characterAt(data.context.cursorPosition) == QLatin1Char('\t')) { if (data.doc->characterAt(data.context.cursorPosition) == QLatin1Char('\t')) {
doSelection = false; doSelection = false;
qreal space = fontMetrics.width(QLatin1Char(' ')); qreal space = fontMetrics.horizontalAdvance(QLatin1Char(' '));
if (w > space) { if (w > space) {
x += w-space; x += w-space;
w = space; w = space;
} }
} }
} else } else
w = fontMetrics.width(QLatin1Char(' ')); // in sync with QTextLine::draw() w = fontMetrics.horizontalAdvance(QLatin1Char(' ')); // in sync with QTextLine::draw()
QRectF lineRect = line.rect(); QRectF lineRect = line.rect();
lineRect.moveTop(lineRect.top() + blockData.boundingRect.top()); lineRect.moveTop(lineRect.top() + blockData.boundingRect.top());
@@ -5122,7 +5123,7 @@ void TextEditorWidget::extraAreaPaintEvent(QPaintEvent *e)
QPainter painter(d->m_extraArea); QPainter painter(d->m_extraArea);
painter.fillRect(e->rect(), data.palette.color(QPalette::Background)); painter.fillRect(e->rect(), data.palette.color(QPalette::Window));
data.block = firstVisibleBlock(); data.block = firstVisibleBlock();
QPointF offset = contentOffset(); QPointF offset = contentOffset();
@@ -5448,7 +5449,7 @@ void TextEditorWidget::mouseMoveEvent(QMouseEvent *e)
int column = tabSettings.columnAt( int column = tabSettings.columnAt(
cursor.block().text(), cursor.positionInBlock()); cursor.block().text(), cursor.positionInBlock());
if (cursor.positionInBlock() == cursor.block().length()-1) if (cursor.positionInBlock() == cursor.block().length()-1)
column += (e->pos().x() - cursorRect().center().x()) / QFontMetricsF(font()).width(QLatin1Char(' ')); column += (e->pos().x() - cursorRect().center().x()) / QFontMetricsF(font()).horizontalAdvance(QLatin1Char(' '));
int block = cursor.blockNumber(); int block = cursor.blockNumber();
if (block == blockCount() - 1) if (block == blockCount() - 1)
block += (e->pos().y() - cursorRect().center().y()) / QFontMetricsF(font()).lineSpacing(); block += (e->pos().y() - cursorRect().center().y()) / QFontMetricsF(font()).lineSpacing();
@@ -5461,7 +5462,7 @@ void TextEditorWidget::mouseMoveEvent(QMouseEvent *e)
int column = tabSettings.columnAt( int column = tabSettings.columnAt(
cursor.block().text(), cursor.positionInBlock()); cursor.block().text(), cursor.positionInBlock());
if (cursor.positionInBlock() == cursor.block().length()-1) if (cursor.positionInBlock() == cursor.block().length()-1)
column += (e->pos().x() - cursorRect().center().x()) / QFontMetricsF(font()).width(QLatin1Char(' ')); column += (e->pos().x() - cursorRect().center().x()) / QFontMetricsF(font()).horizontalAdvance(QLatin1Char(' '));
d->m_blockSelection.positionBlock = cursor.blockNumber(); d->m_blockSelection.positionBlock = cursor.blockNumber();
d->m_blockSelection.positionColumn = column; d->m_blockSelection.positionColumn = column;
@@ -5499,7 +5500,7 @@ void TextEditorWidget::mousePressEvent(QMouseEvent *e)
int column = d->m_document->tabSettings().columnAt( int column = d->m_document->tabSettings().columnAt(
cursor.block().text(), cursor.positionInBlock()); cursor.block().text(), cursor.positionInBlock());
if (cursor.positionInBlock() == cursor.block().length()-1) if (cursor.positionInBlock() == cursor.block().length()-1)
column += (e->pos().x() - cursorRect(cursor).center().x()) / QFontMetricsF(font()).width(QLatin1Char(' ')); column += (e->pos().x() - cursorRect(cursor).center().x()) / QFontMetricsF(font()).horizontalAdvance(QLatin1Char(' '));
int block = cursor.blockNumber(); int block = cursor.blockNumber();
if (block == blockCount() - 1) if (block == blockCount() - 1)
block += (e->pos().y() - cursorRect(cursor).center().y()) / QFontMetricsF(font()).lineSpacing(); block += (e->pos().y() - cursorRect(cursor).center().y()) / QFontMetricsF(font()).lineSpacing();
@@ -7254,7 +7255,7 @@ void TextEditorWidget::applyFontSettings()
const QColor background = textFormat.background().color(); const QColor background = textFormat.background().color();
QPalette p = palette(); QPalette p = palette();
p.setColor(QPalette::Text, foreground); p.setColor(QPalette::Text, foreground);
p.setColor(QPalette::Foreground, foreground); p.setColor(QPalette::WindowText, foreground);
p.setColor(QPalette::Base, background); p.setColor(QPalette::Base, background);
p.setColor(QPalette::Highlight, (selectionFormat.background().style() != Qt::NoBrush) ? p.setColor(QPalette::Highlight, (selectionFormat.background().style() != Qt::NoBrush) ?
selectionFormat.background().color() : selectionFormat.background().color() :
@@ -7271,7 +7272,7 @@ void TextEditorWidget::applyFontSettings()
// Line numbers // Line numbers
QPalette ep; QPalette ep;
ep.setColor(QPalette::Dark, lineNumberFormat.foreground().color()); ep.setColor(QPalette::Dark, lineNumberFormat.foreground().color());
ep.setColor(QPalette::Background, lineNumberFormat.background().style() != Qt::NoBrush ? ep.setColor(QPalette::Window, lineNumberFormat.background().style() != Qt::NoBrush ?
lineNumberFormat.background().color() : background); lineNumberFormat.background().color() : background);
d->m_extraArea->setPalette(ep); d->m_extraArea->setPalette(ep);
@@ -8107,7 +8108,7 @@ void TextEditorWidgetPrivate::updateTabStops()
{ {
// Although the tab stop is stored as qreal the API from QPlainTextEdit only allows it // Although the tab stop is stored as qreal the API from QPlainTextEdit only allows it
// to be set as an int. A work around is to access directly the QTextOption. // to be set as an int. A work around is to access directly the QTextOption.
qreal charWidth = QFontMetricsF(q->font()).width(QLatin1Char(' ')); qreal charWidth = QFontMetricsF(q->font()).horizontalAdvance(QLatin1Char(' '));
QTextOption option = q->document()->defaultTextOption(); QTextOption option = q->document()->defaultTextOption();
option.setTabStopDistance(charWidth * m_document->tabSettings().m_tabSize); option.setTabStopDistance(charWidth * m_document->tabSettings().m_tabSize);
q->document()->setDefaultTextOption(option); q->document()->setDefaultTextOption(option);
@@ -8116,7 +8117,7 @@ void TextEditorWidgetPrivate::updateTabStops()
int TextEditorWidget::columnCount() const int TextEditorWidget::columnCount() const
{ {
QFontMetricsF fm(font()); QFontMetricsF fm(font());
return int(viewport()->rect().width() / fm.width(QLatin1Char('x'))); return int(viewport()->rect().width() / fm.horizontalAdvance(QLatin1Char('x')));
} }
int TextEditorWidget::rowCount() const int TextEditorWidget::rowCount() const

View File

@@ -78,7 +78,7 @@ QVariant TodoItemsModel::data(const QModelIndex &index, int role) const
TodoItem item = m_todoItemsList->at(index.row()); TodoItem item = m_todoItemsList->at(index.row());
if (role == Qt::TextColorRole) if (role == Qt::ForegroundRole)
return item.color; return item.color;
switch (index.column()) { switch (index.column()) {

View File

@@ -178,7 +178,7 @@ void TodoOutputPane::todoTreeViewClicked(const QModelIndex &index)
item.text = index.sibling(row, Constants::OUTPUT_COLUMN_TEXT).data().toString(); item.text = index.sibling(row, Constants::OUTPUT_COLUMN_TEXT).data().toString();
item.file = Utils::FilePath::fromUserInput(index.sibling(row, Constants::OUTPUT_COLUMN_FILE).data().toString()); item.file = Utils::FilePath::fromUserInput(index.sibling(row, Constants::OUTPUT_COLUMN_FILE).data().toString());
item.line = index.sibling(row, Constants::OUTPUT_COLUMN_LINE).data().toInt(); item.line = index.sibling(row, Constants::OUTPUT_COLUMN_LINE).data().toInt();
item.color = index.data(Qt::TextColorRole).value<QColor>(); item.color = index.data(Qt::ForegroundRole).value<QColor>();
item.iconType = static_cast<IconType>(index.sibling(row, Constants::OUTPUT_COLUMN_TEXT) item.iconType = static_cast<IconType>(index.sibling(row, Constants::OUTPUT_COLUMN_TEXT)
.data(Qt::UserRole).toInt()); .data(Qt::UserRole).toInt());

View File

@@ -181,7 +181,7 @@ VcsBaseSubmitEditor::VcsBaseSubmitEditor(const VcsBaseSubmitEditorParameters *pa
QPalette pal; QPalette pal;
pal.setColor(QPalette::Base, tf.background().color()); pal.setColor(QPalette::Base, tf.background().color());
pal.setColor(QPalette::Text, tf.foreground().color()); pal.setColor(QPalette::Text, tf.foreground().color());
pal.setColor(QPalette::Foreground, tf.foreground().color()); pal.setColor(QPalette::WindowText, tf.foreground().color());
if (selectionFormat.background().style() != Qt::NoBrush) if (selectionFormat.background().style() != Qt::NoBrush)
pal.setColor(QPalette::Highlight, selectionFormat.background().color()); pal.setColor(QPalette::Highlight, selectionFormat.background().color());
pal.setBrush(QPalette::HighlightedText, selectionFormat.foreground()); pal.setBrush(QPalette::HighlightedText, selectionFormat.foreground());

View File

@@ -78,7 +78,7 @@ IntroductionWidget::IntroductionWidget(QWidget *parent)
parent->installEventFilter(this); parent->installEventFilter(this);
QPalette p = palette(); QPalette p = palette();
p.setColor(QPalette::Foreground, QColor(220, 220, 220)); p.setColor(QPalette::WindowText, QColor(220, 220, 220));
setPalette(p); setPalette(p);
m_textWidget = new QWidget(this); m_textWidget = new QWidget(this);

View File

@@ -88,7 +88,6 @@ static QFont sizedFont(int size, const QWidget *widget, bool underline = false)
static QPalette lightText() static QPalette lightText()
{ {
QPalette pal; QPalette pal;
pal.setColor(QPalette::Foreground, themeColor(Theme::Welcome_ForegroundPrimaryColor));
pal.setColor(QPalette::WindowText, themeColor(Theme::Welcome_ForegroundPrimaryColor)); pal.setColor(QPalette::WindowText, themeColor(Theme::Welcome_ForegroundPrimaryColor));
return pal; return pal;
} }
@@ -199,7 +198,7 @@ public:
void enterEvent(QEvent *) override void enterEvent(QEvent *) override
{ {
QPalette pal; QPalette pal;
pal.setColor(QPalette::Background, themeColor(Theme::Welcome_HoverColor)); pal.setColor(QPalette::Window, themeColor(Theme::Welcome_HoverColor));
setPalette(pal); setPalette(pal);
m_label->setFont(sizedFont(11, m_label, true)); m_label->setFont(sizedFont(11, m_label, true));
update(); update();
@@ -208,7 +207,7 @@ public:
void leaveEvent(QEvent *) override void leaveEvent(QEvent *) override
{ {
QPalette pal; QPalette pal;
pal.setColor(QPalette::Background, themeColor(Theme::Welcome_BackgroundColor)); pal.setColor(QPalette::Window, themeColor(Theme::Welcome_BackgroundColor));
setPalette(pal); setPalette(pal);
m_label->setFont(sizedFont(11, m_label, false)); m_label->setFont(sizedFont(11, m_label, false));
update(); update();
@@ -319,7 +318,7 @@ WelcomeMode::WelcomeMode()
setContext(Context(Constants::C_WELCOME_MODE)); setContext(Context(Constants::C_WELCOME_MODE));
QPalette palette = creatorTheme()->palette(); QPalette palette = creatorTheme()->palette();
palette.setColor(QPalette::Background, themeColor(Theme::Welcome_BackgroundColor)); palette.setColor(QPalette::Window, themeColor(Theme::Welcome_BackgroundColor));
m_modeWidget = new QWidget; m_modeWidget = new QWidget;
m_modeWidget->setPalette(palette); m_modeWidget->setPalette(palette);

View File

@@ -66,7 +66,7 @@ void WidgetHost::setFormWindow(QDesignerFormWindowInterface *fw)
setBackgroundRole(QPalette::Base); setBackgroundRole(QPalette::Base);
m_formWindow->setAutoFillBackground(true); m_formWindow->setAutoFillBackground(true);
m_formWindow->setBackgroundRole(QPalette::Background); m_formWindow->setBackgroundRole(QPalette::Window);
connect(m_formResizer, &Internal::FormResizer::formWindowSizeChanged, connect(m_formResizer, &Internal::FormResizer::formWindowSizeChanged,
this, &WidgetHost::fwSizeWasChanged); this, &WidgetHost::fwSizeWasChanged);