mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-04-25 06:44:59 +00:00
Updater: Show progress in taskbar
This commit is contained in:
parent
80259b019b
commit
1595a9bdcd
3 changed files with 19 additions and 12 deletions
|
@ -656,14 +656,9 @@ bool PerformUpdate(const TodoList& todo, const std::string& install_base_path,
|
||||||
|
|
||||||
void FatalError(const std::string& message)
|
void FatalError(const std::string& message)
|
||||||
{
|
{
|
||||||
auto wide_message = UTF8ToUTF16(message);
|
|
||||||
|
|
||||||
MessageBox(nullptr,
|
|
||||||
(L"A fatal error occured and the updater cannot continue:\n " + wide_message).c_str(),
|
|
||||||
L"Error", MB_ICONERROR);
|
|
||||||
|
|
||||||
fprintf(log_fp, "%s\n", message.c_str());
|
fprintf(log_fp, "%s\n", message.c_str());
|
||||||
|
|
||||||
|
UI::Error(message);
|
||||||
UI::Stop();
|
UI::Stop();
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
#include "Updater/UI.h"
|
#include "Updater/UI.h"
|
||||||
|
|
||||||
#include <CommCtrl.h>
|
#include <CommCtrl.h>
|
||||||
|
#include <ShObjIdl.h>
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
@ -16,6 +17,7 @@ namespace
|
||||||
HWND window_handle = nullptr;
|
HWND window_handle = nullptr;
|
||||||
HWND label_handle = nullptr;
|
HWND label_handle = nullptr;
|
||||||
HWND progressbar_handle = nullptr;
|
HWND progressbar_handle = nullptr;
|
||||||
|
ITaskbarList3* taskbar_list = nullptr;
|
||||||
|
|
||||||
Common::Flag running;
|
Common::Flag running;
|
||||||
Common::Flag request_stop;
|
Common::Flag request_stop;
|
||||||
|
@ -44,6 +46,8 @@ bool Init()
|
||||||
if (!window_handle)
|
if (!window_handle)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
CoCreateInstance(CLSID_TaskbarList, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&taskbar_list));
|
||||||
|
|
||||||
label_handle = CreateWindow(L"STATIC", NULL, WS_VISIBLE | WS_CHILD, 5, 5, 500, 25, window_handle,
|
label_handle = CreateWindow(L"STATIC", NULL, WS_VISIBLE | WS_CHILD, 5, 5, 500, 25, window_handle,
|
||||||
nullptr, nullptr, 0);
|
nullptr, nullptr, 0);
|
||||||
|
|
||||||
|
@ -80,6 +84,7 @@ void SetMarquee(bool marquee)
|
||||||
{
|
{
|
||||||
SetWindowLong(progressbar_handle, GWL_STYLE, PROGRESSBAR_FLAGS | (marquee ? PBS_MARQUEE : 0));
|
SetWindowLong(progressbar_handle, GWL_STYLE, PROGRESSBAR_FLAGS | (marquee ? PBS_MARQUEE : 0));
|
||||||
SendMessage(progressbar_handle, PBM_SETMARQUEE, marquee, 0);
|
SendMessage(progressbar_handle, PBM_SETMARQUEE, marquee, 0);
|
||||||
|
taskbar_list->SetProgressState(window_handle, marquee ? TBPF_INDETERMINATE : TBPF_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ResetProgress()
|
void ResetProgress()
|
||||||
|
@ -88,15 +93,22 @@ void ResetProgress()
|
||||||
SetMarquee(true);
|
SetMarquee(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Error(const std::string& text)
|
||||||
|
{
|
||||||
|
auto wide_text = UTF8ToUTF16(text);
|
||||||
|
|
||||||
|
MessageBox(nullptr,
|
||||||
|
(L"A fatal error occured and the updater cannot continue:\n " + wide_text).c_str(),
|
||||||
|
L"Error", MB_ICONERROR);
|
||||||
|
|
||||||
|
taskbar_list->SetProgressState(window_handle, TBPF_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
void SetProgress(int current, int total)
|
void SetProgress(int current, int total)
|
||||||
{
|
{
|
||||||
SendMessage(progressbar_handle, PBM_SETRANGE32, 0, total);
|
SendMessage(progressbar_handle, PBM_SETRANGE32, 0, total);
|
||||||
SendMessage(progressbar_handle, PBM_SETPOS, current, 0);
|
SendMessage(progressbar_handle, PBM_SETPOS, current, 0);
|
||||||
}
|
taskbar_list->SetProgressValue(window_handle, current, total);
|
||||||
|
|
||||||
void IncrementProgress(int amount)
|
|
||||||
{
|
|
||||||
SendMessage(progressbar_handle, PBM_DELTAPOS, amount, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetDescription(const std::string& text)
|
void SetDescription(const std::string& text)
|
||||||
|
|
|
@ -9,11 +9,11 @@
|
||||||
namespace UI
|
namespace UI
|
||||||
{
|
{
|
||||||
void MessageLoop();
|
void MessageLoop();
|
||||||
|
void Error(const std::string& text);
|
||||||
void Stop();
|
void Stop();
|
||||||
|
|
||||||
void SetDescription(const std::string& text);
|
void SetDescription(const std::string& text);
|
||||||
void SetMarquee(bool marquee);
|
void SetMarquee(bool marquee);
|
||||||
void ResetProgress();
|
void ResetProgress();
|
||||||
void SetProgress(int current, int total);
|
void SetProgress(int current, int total);
|
||||||
void IncrementProgress(int amount);
|
|
||||||
} // namespace UI
|
} // namespace UI
|
||||||
|
|
Loading…
Add table
Reference in a new issue