Changeset View
Changeset View
Standalone View
Standalone View
kcalc.cpp
Show First 20 Lines • Show All 2096 Lines • ▼ Show 20 Line(s) | |||||
2097 | //------------------------------------------------------------------------------ | 2097 | //------------------------------------------------------------------------------ | ||
2098 | // Name: setColors | 2098 | // Name: setColors | ||
2099 | // Desc: set the various colours | 2099 | // Desc: set the various colours | ||
2100 | //------------------------------------------------------------------------------ | 2100 | //------------------------------------------------------------------------------ | ||
2101 | void KCalculator::setColors() { | 2101 | void KCalculator::setColors() { | ||
2102 | 2102 | | |||
2103 | calc_display->changeSettings(); | 2103 | calc_display->changeSettings(); | ||
2104 | 2104 | | |||
2105 | const QColor numFontColor(KCalcSettings::numberFontsColor()); | ||||
2106 | for (int i = 0; i < 10; ++i) { | ||||
2107 | qobject_cast<KCalcButton*>((num_button_group_->button(i)))->setTextColor(numFontColor); | ||||
2108 | } | ||||
2109 | | ||||
2110 | const QColor funcFontColor(KCalcSettings::functionFontsColor()); | ||||
2111 | foreach(QAbstractButton *btn, function_button_list_) { | ||||
2112 | qobject_cast<KCalcButton*>(btn)->setTextColor(funcFontColor); | ||||
2113 | } | ||||
2114 | | ||||
2115 | const QColor statFontColor(KCalcSettings::statFontsColor()); | ||||
2116 | foreach(QAbstractButton *btn, stat_buttons_) { | ||||
2117 | qobject_cast<KCalcButton*>(btn)->setTextColor(statFontColor); | ||||
2118 | } | ||||
2119 | | ||||
2120 | const QColor hexFontColor(KCalcSettings::hexFontsColor()); | ||||
2121 | for (int i = 10; i < 16; ++i) { | ||||
2122 | qobject_cast<KCalcButton*>((num_button_group_->button(i)))->setTextColor(hexFontColor); | ||||
2123 | } | ||||
2124 | | ||||
2125 | const QColor memFontColor(KCalcSettings::memoryFontsColor()); | ||||
2126 | foreach(QAbstractButton *btn, mem_button_list_) { | ||||
2127 | qobject_cast<KCalcButton*>(btn)->setTextColor(memFontColor); | ||||
2128 | } | ||||
2129 | | ||||
2130 | const QColor opFontColor(KCalcSettings::operationFontsColor()); | ||||
2131 | foreach(QAbstractButton *btn, operation_button_list_) { | ||||
2132 | qobject_cast<KCalcButton*>(btn)->setTextColor(opFontColor); | ||||
2133 | } | ||||
2134 | | ||||
2105 | KColorScheme schemeButtons(QPalette::Active, KColorScheme::Button); | 2135 | KColorScheme schemeButtons(QPalette::Active, KColorScheme::Button); | ||
2106 | const QColor defaultColor = schemeButtons.background().color(); | 2136 | const QColor defaultColor = schemeButtons.background().color(); | ||
2107 | 2137 | | |||
2138 | // Do not apply style sheets when using default background colors, see bug 237513 | ||||
2108 | if (KCalcSettings::numberButtonsColor() == defaultColor | 2139 | if (KCalcSettings::numberButtonsColor() == defaultColor | ||
2109 | && KCalcSettings::functionButtonsColor() == defaultColor | 2140 | && KCalcSettings::functionButtonsColor() == defaultColor | ||
2110 | && KCalcSettings::statButtonsColor() == defaultColor | 2141 | && KCalcSettings::statButtonsColor() == defaultColor | ||
2111 | && KCalcSettings::hexButtonsColor() == defaultColor | 2142 | && KCalcSettings::hexButtonsColor() == defaultColor | ||
2112 | && KCalcSettings::memoryButtonsColor() == defaultColor | 2143 | && KCalcSettings::memoryButtonsColor() == defaultColor | ||
2113 | && KCalcSettings::operationButtonsColor() == defaultColor) { | 2144 | && KCalcSettings::operationButtonsColor() == defaultColor) { | ||
2114 | return; | 2145 | return; | ||
2115 | } | 2146 | } | ||
cfeck: No need to create a color scheme twice. Please reuse `schemeButtons` for button and text color. | |||||
I didn't want you to remove the complete code. If the colors are not changed, no style sheets should be set. See bug 237513. cfeck: I didn't want you to remove the complete code. If the colors are not changed, no style sheets… | |||||
Hi, I removed because It was affecting the config behaviour. You can reproduce by changing colors and saving. The application will only change when you restart it. This way, no need to restart anymore. thiagoneves: Hi, I removed because It was affecting the config behaviour. You can reproduce by changing… | |||||
2116 | 2147 | | |||
2117 | const QString sheet = QStringLiteral("QPushButton { background-color: %1 }"); | 2148 | const QString sheet = QStringLiteral("QPushButton { background-color: %1 }"); | ||
2118 | 2149 | | |||
2119 | const QColor numPal(KCalcSettings::numberButtonsColor()); | 2150 | const QColor numPal(KCalcSettings::numberButtonsColor()); | ||
2120 | for (int i = 0; i < 10; ++i) { | 2151 | for (int i = 0; i < 10; ++i) { | ||
2121 | (num_button_group_->button(i))->setStyleSheet(sheet.arg(numPal.name())); | 2152 | (num_button_group_->button(i))->setStyleSheet(sheet.arg(numPal.name())); | ||
2122 | } | 2153 | } | ||
cfeck: Please change casts to `qobject_cast` (here and below). | |||||
2123 | 2154 | | |||
2124 | const QColor funcPal(KCalcSettings::functionButtonsColor()); | 2155 | const QColor funcPal(KCalcSettings::functionButtonsColor()); | ||
2125 | foreach(QAbstractButton *btn, function_button_list_) { | 2156 | foreach(QAbstractButton *btn, function_button_list_) { | ||
2126 | btn->setStyleSheet(sheet.arg(funcPal.name())); | 2157 | btn->setStyleSheet(sheet.arg(funcPal.name())); | ||
2127 | } | 2158 | } | ||
2128 | 2159 | | |||
2129 | const QColor statPal(KCalcSettings::statButtonsColor()); | 2160 | const QColor statPal(KCalcSettings::statButtonsColor()); | ||
2130 | foreach(QAbstractButton *btn, stat_buttons_) { | 2161 | foreach(QAbstractButton *btn, stat_buttons_) { | ||
▲ Show 20 Lines • Show All 234 Lines • Show Last 20 Lines |
No need to create a color scheme twice. Please reuse schemeButtons for button and text color.