Commit ac70c168 authored by Lorenz Haas's avatar Lorenz Haas Committed by Eike Ziller

Optimize usage of QPalette

setPalette() does not replace the old one but rather adds the
difference. Thus a previous copy of the palette is unnecessary.

Change-Id: I5c06da456b76144efc4a984ccda13c7d2243a7bc
Reviewed-by: default avatarEike Ziller <eike.ziller@digia.com>
parent a142270d
......@@ -144,7 +144,7 @@ CustomColorDialog::CustomColorDialog(QWidget *parent) : QFrame(parent )
void CustomColorDialog::setupColor(const QColor &color)
{
QPalette pal = m_beforeColorWidget->palette();
QPalette pal;
pal.setColor(QPalette::Background, color);
m_beforeColorWidget->setPalette(pal);
setColor(color);
......@@ -179,7 +179,7 @@ void CustomColorDialog::setupWidgets()
m_gSpinBox->setValue(m_color.greenF());
m_bSpinBox->setValue(m_color.blueF());
m_colorBox->setColor(m_color);
QPalette pal = m_currentColorWidget->palette();
QPalette pal;
pal.setColor(QPalette::Background, m_color);
m_currentColorWidget->setPalette(pal);
m_blockUpdate = false;
......
......@@ -451,11 +451,9 @@ void FancyTabWidget::removeTab(int index)
void FancyTabWidget::setBackgroundBrush(const QBrush &brush)
{
QPalette pal = m_tabBar->palette();
QPalette pal;
pal.setBrush(QPalette::Mid, brush);
m_tabBar->setPalette(pal);
pal = m_cornerWidgetContainer->palette();
pal.setBrush(QPalette::Mid, brush);
m_cornerWidgetContainer->setPalette(pal);
}
......
......@@ -62,7 +62,7 @@ void SearchResultTreeView::setTextEditorFont(const QFont &font, const SearchResu
{
m_model->setTextEditorFont(font, color);
QPalette p = palette();
QPalette p;
p.setColor(QPalette::Base, color.textBackground);
setPalette(p);
}
......
......@@ -90,7 +90,7 @@ SearchResultWidget::SearchResultWidget(QWidget *parent) :
setLayout(layout);
QFrame *topWidget = new QFrame;
QPalette pal = topWidget->palette();
QPalette pal;
pal.setColor(QPalette::Window, QColor(255, 255, 225));
pal.setColor(QPalette::WindowText, Qt::black);
topWidget->setPalette(pal);
......@@ -103,7 +103,6 @@ SearchResultWidget::SearchResultWidget(QWidget *parent) :
layout->addWidget(topWidget);
m_messageWidget = new QFrame;
pal.setColor(QPalette::Window, QColor(255, 255, 225));
pal.setColor(QPalette::WindowText, Qt::red);
m_messageWidget->setPalette(pal);
m_messageWidget->setFrameStyle(QFrame::Panel | QFrame::Raised);
......
......@@ -207,7 +207,7 @@ void InfoBarDisplay::update()
foreach (const InfoBarEntry &info, m_infoBar->m_infoBarEntries) {
QFrame *infoWidget = new QFrame;
QPalette pal = infoWidget->palette();
QPalette pal;
pal.setColor(QPalette::Window, QColor(255, 255, 225));
pal.setColor(QPalette::WindowText, Qt::black);
......
......@@ -177,7 +177,7 @@ void ChangeSelectionDialog::acceptShow()
//! Set commit message in details
void ChangeSelectionDialog::setDetails(int exitCode)
{
QPalette palette = m_ui->changeNumberEdit->palette();
QPalette palette;
if (exitCode == 0) {
m_ui->detailsText->setPlainText(QString::fromUtf8(m_process->readAllStandardOutput()));
palette.setColor(QPalette::Text, Qt::black);
......
......@@ -68,7 +68,7 @@ QueryValidatingLineEdit::QueryValidatingLineEdit(QWidget *parent)
void QueryValidatingLineEdit::setTextColor(const QColor &c)
{
QPalette pal = palette();
QPalette pal;
pal.setColor(QPalette::Active, QPalette::Text, c);
setPalette(pal);
}
......
......@@ -648,7 +648,7 @@ MiniProjectTargetSelector::MiniProjectTargetSelector(QAction *targetSelectorActi
m_runConfiguration(0),
m_hideOnRelease(false)
{
QPalette p = palette();
QPalette p;
p.setColor(QPalette::Text, QColor(255, 255, 255, 160));
setPalette(p);
setProperty("panelwidget", true);
......
......@@ -123,7 +123,7 @@ PanelsWidget::PanelsWidget(QWidget *parent) :
m_root->setMaximumWidth(900);
m_root->setContentsMargins(0, 0, 40, 0);
QPalette pal = m_root->palette();
QPalette pal;
QColor background = Utils::StyleHelper::mergedColors(
palette().window().color(), Qt::white, 85);
pal.setColor(QPalette::All, QPalette::Window, background.darker(102));
......
......@@ -69,7 +69,7 @@ TargetSettingsWidget::TargetSettingsWidget(QWidget *parent) :
connect(m_targetSelector, SIGNAL(menuShown(int)),
this, SIGNAL(menuShown(int)));
QPalette shadowPal = palette();
QPalette shadowPal;
QLinearGradient grad(0, 0, 0, 2);
grad.setColorAt(0, QColor(0, 0, 0, 60));
grad.setColorAt(1, Qt::transparent);
......
......@@ -267,7 +267,7 @@ QWidget *QmlProfilerTool::createWidgets()
layout->addWidget(d->m_clearButton);
d->m_timeLabel = new QLabel();
QPalette palette = d->m_timeLabel->palette();
QPalette palette;
palette.setColor(QPalette::WindowText, Qt::white);
d->m_timeLabel->setPalette(palette);
d->m_timeLabel->setIndent(10);
......
......@@ -5394,7 +5394,7 @@ void BaseTextEditorWidget::applyFontSettings()
updateTabStops(); // update tab stops, they depend on the font
// Line numbers
QPalette ep = d->m_extraArea->palette();
QPalette ep;
ep.setColor(QPalette::Dark, lineNumberFormat.foreground().color());
ep.setColor(QPalette::Background, lineNumberFormat.background().style() != Qt::NoBrush ?
lineNumberFormat.background().color() : background);
......
......@@ -329,7 +329,7 @@ void ColorSchemeEdit::checkCheckBoxes()
void ColorSchemeEdit::setItemListBackground(const QColor &color)
{
QPalette pal = m_ui->itemList->palette();
QPalette pal;
pal.setColor(QPalette::Base, color);
m_ui->itemList->setPalette(pal);
}
......@@ -99,7 +99,7 @@ void CheckoutProgressWizardPage::slotFinished(bool ok, int exitCode, const QVari
m_state = Succeeded;
QApplication::restoreOverrideCursor();
ui->statusLabel->setText(tr("Succeeded."));
QPalette palette = ui->statusLabel->palette();
QPalette palette;
palette.setColor(QPalette::Active, QPalette::Text, Qt::green);
ui->statusLabel->setPalette(palette);
emit completeChanged();
......@@ -111,7 +111,7 @@ void CheckoutProgressWizardPage::slotFinished(bool ok, int exitCode, const QVari
m_state = Failed;
QApplication::restoreOverrideCursor();
ui->statusLabel->setText(tr("Failed."));
QPalette palette = ui->statusLabel->palette();
QPalette palette;
palette.setColor(QPalette::Active, QPalette::Text, Qt::red);
ui->statusLabel->setPalette(palette);
emit terminated(false);
......
......@@ -191,7 +191,7 @@ VcsBaseSubmitEditor::VcsBaseSubmitEditor(const VcsBaseSubmitEditorParameters *pa
const QTextCharFormat tf = fs.toTextCharFormat(TextEditor::C_TEXT);
descriptionEdit->setFont(tf.font());
const QTextCharFormat selectionFormat = fs.toTextCharFormat(TextEditor::C_SELECTION);
QPalette pal = descriptionEdit->palette();
QPalette pal;
pal.setColor(QPalette::Base, tf.background().color());
pal.setColor(QPalette::Text, tf.foreground().color());
pal.setColor(QPalette::Foreground, tf.foreground().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