Hide update status label when no action is required

This commit is contained in:
kobewi 2024-04-22 21:36:22 +02:00
parent 7529c0bec5
commit b8ee1366bc
2 changed files with 7 additions and 33 deletions

View file

@ -180,22 +180,15 @@ void EngineUpdateLabel::_set_message(const String &p_message, const Color &p_col
void EngineUpdateLabel::_set_status(UpdateStatus p_status) {
status = p_status;
if (compact_mode) {
if (status != UpdateStatus::BUSY && status != UpdateStatus::UPDATE_AVAILABLE) {
hide();
return;
} else {
show();
}
if (status == UpdateStatus::DEV || status == UpdateStatus::BUSY || status == UpdateStatus::UP_TO_DATE) {
// Hide the label to prevent unnecessary distraction.
hide();
return;
} else {
show();
}
switch (status) {
case UpdateStatus::DEV: {
set_disabled(true);
_set_message(TTR("Running a development build."), theme_cache.disabled_color);
set_tooltip_text(TTR("Exact version can't be determined for update checking."));
break;
}
case UpdateStatus::OFFLINE: {
set_disabled(false);
if (int(EDITOR_GET("network/connection/network_mode")) == EditorSettings::NETWORK_OFFLINE) {
@ -206,23 +199,12 @@ void EngineUpdateLabel::_set_status(UpdateStatus p_status) {
set_tooltip_text("");
break;
}
case UpdateStatus::BUSY: {
set_disabled(true);
_set_message(TTR("Checking for updates..."), theme_cache.default_color);
set_tooltip_text("");
} break;
case UpdateStatus::ERROR: {
set_disabled(false);
set_tooltip_text(TTR("An error has occurred. Click to try again."));
} break;
case UpdateStatus::UP_TO_DATE: {
set_disabled(false);
_set_message(TTR("Current version up to date."), theme_cache.disabled_color);
set_tooltip_text(TTR("Click to check again."));
} break;
case UpdateStatus::UPDATE_AVAILABLE: {
set_disabled(false);
set_tooltip_text(TTR("Click to open download page."));
@ -315,8 +297,7 @@ void EngineUpdateLabel::pressed() {
emit_signal("offline_clicked");
} break;
case UpdateStatus::ERROR:
case UpdateStatus::UP_TO_DATE: {
case UpdateStatus::ERROR: {
_check_update();
} break;
@ -329,10 +310,6 @@ void EngineUpdateLabel::pressed() {
}
}
void EngineUpdateLabel::enable_compact_mode() {
compact_mode = true;
}
EngineUpdateLabel::EngineUpdateLabel() {
set_underline_mode(UNDERLINE_MODE_ON_HOVER);

View file

@ -76,7 +76,6 @@ private:
} theme_cache;
HTTPRequest *http = nullptr;
bool compact_mode = false;
UpdateStatus status = UpdateStatus::NONE;
bool checked_update = false;
@ -99,8 +98,6 @@ protected:
virtual void pressed() override;
public:
void enable_compact_mode();
EngineUpdateLabel();
};