ui: add idle delay combo to mining tab
Add inline combo box (30s/1m/2m/5m/10m) next to the idle mining toggle so users can choose how long to wait before idle mining starts.
This commit is contained in:
@@ -866,9 +866,42 @@ void RenderMiningTab(App* app)
|
|||||||
ImGui::SetMouseCursor(ImGuiMouseCursor_Hand);
|
ImGui::SetMouseCursor(ImGuiMouseCursor_Hand);
|
||||||
ImGui::SetTooltip("%s", idleOn ? TR("mining_idle_on_tooltip") : TR("mining_idle_off_tooltip"));
|
ImGui::SetTooltip("%s", idleOn ? TR("mining_idle_on_tooltip") : TR("mining_idle_off_tooltip"));
|
||||||
}
|
}
|
||||||
ImGui::SetCursorScreenPos(savedCur);
|
|
||||||
|
|
||||||
idleRightEdge = btnX - 4.0f * dp;
|
idleRightEdge = btnX - 4.0f * dp;
|
||||||
|
|
||||||
|
// Idle delay combo (to the left of the icon when enabled)
|
||||||
|
if (idleOn) {
|
||||||
|
struct DelayOption { int seconds; const char* label; };
|
||||||
|
static const DelayOption delays[] = {
|
||||||
|
{30, "30s"}, {60, "1m"}, {120, "2m"}, {300, "5m"}, {600, "10m"}
|
||||||
|
};
|
||||||
|
int curDelay = app->settings()->getMineIdleDelay();
|
||||||
|
const char* previewLabel = "2m";
|
||||||
|
for (const auto& d : delays) {
|
||||||
|
if (d.seconds == curDelay) { previewLabel = d.label; break; }
|
||||||
|
}
|
||||||
|
float comboW = schema::UI().drawElement("components.settings-page", "idle-combo-width").sizeOr(64.0f);
|
||||||
|
float comboX = idleRightEdge - comboW;
|
||||||
|
float comboY = curY + (headerH - ImGui::GetFrameHeight()) * 0.5f;
|
||||||
|
ImGui::SetCursorScreenPos(ImVec2(comboX, comboY));
|
||||||
|
ImGui::SetNextItemWidth(comboW);
|
||||||
|
if (ImGui::BeginCombo("##IdleDelay", previewLabel, ImGuiComboFlags_NoArrowButton)) {
|
||||||
|
for (const auto& d : delays) {
|
||||||
|
bool selected = (d.seconds == curDelay);
|
||||||
|
if (ImGui::Selectable(d.label, selected)) {
|
||||||
|
app->settings()->setMineIdleDelay(d.seconds);
|
||||||
|
app->settings()->save();
|
||||||
|
}
|
||||||
|
if (selected) ImGui::SetItemDefaultFocus();
|
||||||
|
}
|
||||||
|
ImGui::EndCombo();
|
||||||
|
}
|
||||||
|
if (ImGui::IsItemHovered())
|
||||||
|
ImGui::SetTooltip("%s", TR("tt_idle_delay"));
|
||||||
|
idleRightEdge = comboX - 4.0f * dp;
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui::SetCursorScreenPos(savedCur);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Active mining indicator (left of idle toggle)
|
// Active mining indicator (left of idle toggle)
|
||||||
|
|||||||
Reference in New Issue
Block a user