mirror of
https://git.suyu.dev/suyu/suyu.git
synced 2024-11-22 14:52:45 +01:00
applets/error: Use aliases for callbacks
This commit is contained in:
parent
2b40cdf04f
commit
d8da9a2afd
4 changed files with 18 additions and 16 deletions
|
@ -8,13 +8,13 @@ namespace Core::Frontend {
|
||||||
|
|
||||||
ErrorApplet::~ErrorApplet() = default;
|
ErrorApplet::~ErrorApplet() = default;
|
||||||
|
|
||||||
void DefaultErrorApplet::ShowError(Result error, std::function<void()> finished) const {
|
void DefaultErrorApplet::ShowError(Result error, FinishedCallback finished) const {
|
||||||
LOG_CRITICAL(Service_Fatal, "Application requested error display: {:04}-{:04} (raw={:08X})",
|
LOG_CRITICAL(Service_Fatal, "Application requested error display: {:04}-{:04} (raw={:08X})",
|
||||||
error.module.Value(), error.description.Value(), error.raw);
|
error.module.Value(), error.description.Value(), error.raw);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DefaultErrorApplet::ShowErrorWithTimestamp(Result error, std::chrono::seconds time,
|
void DefaultErrorApplet::ShowErrorWithTimestamp(Result error, std::chrono::seconds time,
|
||||||
std::function<void()> finished) const {
|
FinishedCallback finished) const {
|
||||||
LOG_CRITICAL(
|
LOG_CRITICAL(
|
||||||
Service_Fatal,
|
Service_Fatal,
|
||||||
"Application requested error display: {:04X}-{:04X} (raw={:08X}) with timestamp={:016X}",
|
"Application requested error display: {:04X}-{:04X} (raw={:08X}) with timestamp={:016X}",
|
||||||
|
@ -23,7 +23,7 @@ void DefaultErrorApplet::ShowErrorWithTimestamp(Result error, std::chrono::secon
|
||||||
|
|
||||||
void DefaultErrorApplet::ShowCustomErrorText(Result error, std::string main_text,
|
void DefaultErrorApplet::ShowCustomErrorText(Result error, std::string main_text,
|
||||||
std::string detail_text,
|
std::string detail_text,
|
||||||
std::function<void()> finished) const {
|
FinishedCallback finished) const {
|
||||||
LOG_CRITICAL(Service_Fatal,
|
LOG_CRITICAL(Service_Fatal,
|
||||||
"Application requested custom error with error_code={:04X}-{:04X} (raw={:08X})",
|
"Application requested custom error with error_code={:04X}-{:04X} (raw={:08X})",
|
||||||
error.module.Value(), error.description.Value(), error.raw);
|
error.module.Value(), error.description.Value(), error.raw);
|
||||||
|
|
|
@ -12,25 +12,27 @@ namespace Core::Frontend {
|
||||||
|
|
||||||
class ErrorApplet {
|
class ErrorApplet {
|
||||||
public:
|
public:
|
||||||
|
using FinishedCallback = std::function<void()>;
|
||||||
|
|
||||||
virtual ~ErrorApplet();
|
virtual ~ErrorApplet();
|
||||||
|
|
||||||
virtual void ShowError(Result error, std::function<void()> finished) const = 0;
|
virtual void ShowError(Result error, FinishedCallback finished) const = 0;
|
||||||
|
|
||||||
virtual void ShowErrorWithTimestamp(Result error, std::chrono::seconds time,
|
virtual void ShowErrorWithTimestamp(Result error, std::chrono::seconds time,
|
||||||
std::function<void()> finished) const = 0;
|
FinishedCallback finished) const = 0;
|
||||||
|
|
||||||
virtual void ShowCustomErrorText(Result error, std::string dialog_text,
|
virtual void ShowCustomErrorText(Result error, std::string dialog_text,
|
||||||
std::string fullscreen_text,
|
std::string fullscreen_text,
|
||||||
std::function<void()> finished) const = 0;
|
FinishedCallback finished) const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
class DefaultErrorApplet final : public ErrorApplet {
|
class DefaultErrorApplet final : public ErrorApplet {
|
||||||
public:
|
public:
|
||||||
void ShowError(Result error, std::function<void()> finished) const override;
|
void ShowError(Result error, FinishedCallback finished) const override;
|
||||||
void ShowErrorWithTimestamp(Result error, std::chrono::seconds time,
|
void ShowErrorWithTimestamp(Result error, std::chrono::seconds time,
|
||||||
std::function<void()> finished) const override;
|
FinishedCallback finished) const override;
|
||||||
void ShowCustomErrorText(Result error, std::string main_text, std::string detail_text,
|
void ShowCustomErrorText(Result error, std::string main_text, std::string detail_text,
|
||||||
std::function<void()> finished) const override;
|
FinishedCallback finished) const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Core::Frontend
|
} // namespace Core::Frontend
|
||||||
|
|
|
@ -14,7 +14,7 @@ QtErrorDisplay::QtErrorDisplay(GMainWindow& parent) {
|
||||||
|
|
||||||
QtErrorDisplay::~QtErrorDisplay() = default;
|
QtErrorDisplay::~QtErrorDisplay() = default;
|
||||||
|
|
||||||
void QtErrorDisplay::ShowError(Result error, std::function<void()> finished) const {
|
void QtErrorDisplay::ShowError(Result error, FinishedCallback finished) const {
|
||||||
callback = std::move(finished);
|
callback = std::move(finished);
|
||||||
emit MainWindowDisplayError(
|
emit MainWindowDisplayError(
|
||||||
tr("Error Code: %1-%2 (0x%3)")
|
tr("Error Code: %1-%2 (0x%3)")
|
||||||
|
@ -25,7 +25,7 @@ void QtErrorDisplay::ShowError(Result error, std::function<void()> finished) con
|
||||||
}
|
}
|
||||||
|
|
||||||
void QtErrorDisplay::ShowErrorWithTimestamp(Result error, std::chrono::seconds time,
|
void QtErrorDisplay::ShowErrorWithTimestamp(Result error, std::chrono::seconds time,
|
||||||
std::function<void()> finished) const {
|
FinishedCallback finished) const {
|
||||||
callback = std::move(finished);
|
callback = std::move(finished);
|
||||||
|
|
||||||
const QDateTime date_time = QDateTime::fromSecsSinceEpoch(time.count());
|
const QDateTime date_time = QDateTime::fromSecsSinceEpoch(time.count());
|
||||||
|
@ -42,7 +42,7 @@ void QtErrorDisplay::ShowErrorWithTimestamp(Result error, std::chrono::seconds t
|
||||||
|
|
||||||
void QtErrorDisplay::ShowCustomErrorText(Result error, std::string dialog_text,
|
void QtErrorDisplay::ShowCustomErrorText(Result error, std::string dialog_text,
|
||||||
std::string fullscreen_text,
|
std::string fullscreen_text,
|
||||||
std::function<void()> finished) const {
|
FinishedCallback finished) const {
|
||||||
callback = std::move(finished);
|
callback = std::move(finished);
|
||||||
emit MainWindowDisplayError(
|
emit MainWindowDisplayError(
|
||||||
tr("Error Code: %1-%2 (0x%3)")
|
tr("Error Code: %1-%2 (0x%3)")
|
||||||
|
|
|
@ -16,11 +16,11 @@ public:
|
||||||
explicit QtErrorDisplay(GMainWindow& parent);
|
explicit QtErrorDisplay(GMainWindow& parent);
|
||||||
~QtErrorDisplay() override;
|
~QtErrorDisplay() override;
|
||||||
|
|
||||||
void ShowError(Result error, std::function<void()> finished) const override;
|
void ShowError(Result error, FinishedCallback finished) const override;
|
||||||
void ShowErrorWithTimestamp(Result error, std::chrono::seconds time,
|
void ShowErrorWithTimestamp(Result error, std::chrono::seconds time,
|
||||||
std::function<void()> finished) const override;
|
FinishedCallback finished) const override;
|
||||||
void ShowCustomErrorText(Result error, std::string dialog_text, std::string fullscreen_text,
|
void ShowCustomErrorText(Result error, std::string dialog_text, std::string fullscreen_text,
|
||||||
std::function<void()> finished) const override;
|
FinishedCallback finished) const override;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void MainWindowDisplayError(QString error_code, QString error_text) const;
|
void MainWindowDisplayError(QString error_code, QString error_text) const;
|
||||||
|
@ -28,5 +28,5 @@ signals:
|
||||||
private:
|
private:
|
||||||
void MainWindowFinishedError();
|
void MainWindowFinishedError();
|
||||||
|
|
||||||
mutable std::function<void()> callback;
|
mutable FinishedCallback callback;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue