mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-04-01 21:17:44 -05:00
ui: Added global running tasks progress bar
This commit is contained in:
@@ -9,10 +9,6 @@
|
||||
|
||||
namespace hex {
|
||||
|
||||
void ImHexApi::Common::sayHello() {
|
||||
log::warn("Hello!");
|
||||
}
|
||||
|
||||
void ImHexApi::Common::closeImHex(bool noQuestions) {
|
||||
EventManager::post<RequestCloseImHex>(noQuestions);
|
||||
}
|
||||
@@ -85,4 +81,9 @@ namespace hex {
|
||||
delete provider;
|
||||
}
|
||||
|
||||
|
||||
Task ImHexApi::Tasks::createTask(const std::string &unlocalizedName, u64 maxValue) {
|
||||
return Task(unlocalizedName, maxValue);
|
||||
}
|
||||
|
||||
}
|
||||
32
plugins/libimhex/source/api/task.cpp
Normal file
32
plugins/libimhex/source/api/task.cpp
Normal file
@@ -0,0 +1,32 @@
|
||||
#include <hex/api/task.hpp>
|
||||
|
||||
#include <hex/helpers/shared_data.hpp>
|
||||
|
||||
namespace hex {
|
||||
|
||||
Task::Task(const std::string& unlocalizedName, u64 maxValue) : m_name(LangEntry(unlocalizedName)), m_maxValue(maxValue), m_currValue(0) {
|
||||
SharedData::runningTasks.push_back(this);
|
||||
}
|
||||
|
||||
Task::~Task() {
|
||||
this->finish();
|
||||
}
|
||||
|
||||
void Task::finish() {
|
||||
SharedData::runningTasks.remove(this);
|
||||
}
|
||||
|
||||
void Task::update(u64 currValue) {
|
||||
if (this->m_currValue < this->m_maxValue)
|
||||
this->m_currValue = currValue;
|
||||
}
|
||||
|
||||
double Task::getProgress() const {
|
||||
return static_cast<double>(this->m_currValue) / static_cast<double>(this->m_maxValue);
|
||||
}
|
||||
|
||||
const std::string& Task::getName() const {
|
||||
return this->m_name;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -29,6 +29,9 @@ namespace hex {
|
||||
std::vector<ContentRegistry::Interface::DrawCallback> SharedData::footerItems;
|
||||
std::vector<ContentRegistry::Interface::DrawCallback> SharedData::toolbarItems;
|
||||
|
||||
std::mutex SharedData::tasksMutex;
|
||||
std::list<Task*> SharedData::runningTasks;
|
||||
|
||||
std::vector<std::string> SharedData::providerNames;
|
||||
|
||||
std::vector<ContentRegistry::DataProcessorNode::impl::Entry> SharedData::dataProcessorNodes;
|
||||
|
||||
Reference in New Issue
Block a user