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