Display who seen loading state as disabled item.

This commit is contained in:
John Preston 2021-09-08 14:38:05 +03:00
parent fa5e66a736
commit 8f480b52e7
3 changed files with 18 additions and 5 deletions

View file

@ -112,6 +112,11 @@ Action::Action(
updateUserpicsFromContent(); updateUserpicsFromContent();
refreshText(); refreshText();
refreshDimensions(); refreshDimensions();
setPointerCursor(isEnabled());
_dummyAction->setEnabled(isEnabled());
if (!isEnabled()) {
setSelected(false);
}
update(); update();
}, lifetime()); }, lifetime());
@ -172,6 +177,9 @@ void Action::updateUserpicsFromContent() {
void Action::populateSubmenu() { void Action::populateSubmenu() {
if (_content.participants.size() < 2) { if (_content.participants.size() < 2) {
_parentMenu->removeSubmenu(action()); _parentMenu->removeSubmenu(action());
if (!isEnabled()) {
setSelected(false);
}
return; return;
} }
const auto submenu = _parentMenu->ensureSubmenu(action()); const auto submenu = _parentMenu->ensureSubmenu(action());
@ -186,15 +194,20 @@ void Action::populateSubmenu() {
} }
void Action::paint(Painter &p) { void Action::paint(Painter &p) {
const auto enabled = isEnabled();
const auto selected = isSelected(); const auto selected = isSelected();
if (selected && _st.itemBgOver->c.alpha() < 255) { if (selected && _st.itemBgOver->c.alpha() < 255) {
p.fillRect(0, 0, width(), _height, _st.itemBg); p.fillRect(0, 0, width(), _height, _st.itemBg);
} }
p.fillRect(0, 0, width(), _height, selected ? _st.itemBgOver : _st.itemBg); p.fillRect(0, 0, width(), _height, selected ? _st.itemBgOver : _st.itemBg);
if (isEnabled()) { if (enabled) {
paintRipple(p, 0, 0); paintRipple(p, 0, 0);
} }
p.setPen(selected ? _st.itemFgOver : _st.itemFg); p.setPen(!enabled
? _st.itemFgDisabled
: selected
? _st.itemFgOver
: _st.itemFg);
_text.drawLeftElided( _text.drawLeftElided(
p, p,
_st.itemPadding.left(), _st.itemPadding.left(),
@ -247,7 +260,7 @@ void Action::refreshDimensions() {
} }
bool Action::isEnabled() const { bool Action::isEnabled() const {
return true; return !_content.participants.empty();
} }
not_null<QAction*> Action::action() const { not_null<QAction*> Action::action() const {

@ -1 +1 @@
Subproject commit f4cf3094c29e445256bd1c198323d393be4405c1 Subproject commit 02c1bd567451152e4f15f674a21ca118421c3c3e

2
cmake

@ -1 +1 @@
Subproject commit f343a1634cbdefb476e9020687db30a356ffe8f2 Subproject commit e97617c7c5e5e00a06b9b7fb2fa735e3a23e2673