mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Added gradient colors to sessions section.
This commit is contained in:
parent
58fe2d7ecc
commit
bba45293da
1 changed files with 39 additions and 25 deletions
|
@ -218,29 +218,43 @@ void RenameBox(not_null<Ui::GenericBox*> box) {
|
||||||
return Type::Other;
|
return Type::Other;
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] style::color ColorForType(Type type) {
|
[[nodiscard]] QBrush GradientForType(Type type, int size) {
|
||||||
switch (type) {
|
const auto colors = [&]() -> std::pair<style::color, style::color> {
|
||||||
case Type::Windows:
|
switch (type) {
|
||||||
case Type::Mac:
|
case Type::Windows:
|
||||||
case Type::Other:
|
case Type::Mac:
|
||||||
return st::historyPeer4UserpicBg; // blue
|
case Type::Other:
|
||||||
case Type::Ubuntu:
|
// Blue.
|
||||||
return st::historyPeer8UserpicBg; // orange
|
return { st::historyPeer4UserpicBg, st::historyPeer4UserpicBg2 };
|
||||||
case Type::Linux:
|
case Type::Ubuntu:
|
||||||
return st::historyPeer5UserpicBg; // purple
|
// Orange.
|
||||||
case Type::iPhone:
|
return { st::historyPeer8UserpicBg, st::historyPeer8UserpicBg2 };
|
||||||
case Type::iPad:
|
case Type::Linux:
|
||||||
return st::historyPeer7UserpicBg; // sea
|
// Purple.
|
||||||
case Type::Android:
|
return { st::historyPeer5UserpicBg, st::historyPeer5UserpicBg2 };
|
||||||
return st::historyPeer2UserpicBg; // green
|
case Type::iPhone:
|
||||||
case Type::Web:
|
case Type::iPad:
|
||||||
case Type::Chrome:
|
// Sea.
|
||||||
case Type::Edge:
|
return { st::historyPeer7UserpicBg, st::historyPeer7UserpicBg2 };
|
||||||
case Type::Firefox:
|
case Type::Android:
|
||||||
case Type::Safari:
|
// Green.
|
||||||
return st::historyPeer6UserpicBg; // pink
|
return { st::historyPeer2UserpicBg, st::historyPeer2UserpicBg2 };
|
||||||
}
|
case Type::Web:
|
||||||
Unexpected("Type in ColorForType.");
|
case Type::Chrome:
|
||||||
|
case Type::Edge:
|
||||||
|
case Type::Firefox:
|
||||||
|
case Type::Safari:
|
||||||
|
// Pink.
|
||||||
|
return { st::historyPeer6UserpicBg, st::historyPeer6UserpicBg2 };
|
||||||
|
}
|
||||||
|
Unexpected("Type in GradientForType.");
|
||||||
|
}();
|
||||||
|
auto gradient = QLinearGradient(0, 0, 0, size);
|
||||||
|
gradient.setStops({
|
||||||
|
{ 0.0, colors.first->c },
|
||||||
|
{ 1.0, colors.second->c },
|
||||||
|
});
|
||||||
|
return QBrush(std::move(gradient));
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] const style::icon &IconForType(Type type) {
|
[[nodiscard]] const style::icon &IconForType(Type type) {
|
||||||
|
@ -308,7 +322,7 @@ void RenameBox(not_null<Ui::GenericBox*> box) {
|
||||||
|
|
||||||
auto p = QPainter(&result);
|
auto p = QPainter(&result);
|
||||||
auto hq = PainterHighQualityEnabler(p);
|
auto hq = PainterHighQualityEnabler(p);
|
||||||
p.setBrush(ColorForType(type));
|
p.setBrush(GradientForType(type, size));
|
||||||
p.setPen(Qt::NoPen);
|
p.setPen(Qt::NoPen);
|
||||||
p.drawEllipse(rect);
|
p.drawEllipse(rect);
|
||||||
IconForType(type).paintInCenter(p, rect);
|
IconForType(type).paintInCenter(p, rect);
|
||||||
|
@ -344,7 +358,7 @@ void RenameBox(not_null<Ui::GenericBox*> box) {
|
||||||
|
|
||||||
auto p = QPainter(&state->background);
|
auto p = QPainter(&state->background);
|
||||||
auto hq = PainterHighQualityEnabler(p);
|
auto hq = PainterHighQualityEnabler(p);
|
||||||
p.setBrush(ColorForType(type));
|
p.setBrush(GradientForType(type, size));
|
||||||
p.setPen(Qt::NoPen);
|
p.setPen(Qt::NoPen);
|
||||||
p.drawEllipse(rect);
|
p.drawEllipse(rect);
|
||||||
if (const auto icon = IconBigForType(type)) {
|
if (const auto icon = IconBigForType(type)) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue