Skip to content

Commit 44e97a0

Browse files
committed
qml: Add message box for InitError calls
1 parent c054cde commit 44e97a0

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

src/qml/bitcoin.cpp

+16
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,18 @@ void SetupUIArgs(ArgsManager& argsman)
3232
argsman.AddArg("-resetguisettings", "Reset all settings changed in the GUI", ArgsManager::ALLOW_ANY, OptionsCategory::GUI);
3333
argsman.AddArg("-splash", strprintf("Show splash screen on startup (default: %u)", DEFAULT_SPLASHSCREEN), ArgsManager::ALLOW_ANY, OptionsCategory::GUI);
3434
}
35+
36+
bool InitErrorMessageBox(
37+
const bilingual_str& message,
38+
[[maybe_unused]] const std::string& caption,
39+
[[maybe_unused]] unsigned int style)
40+
{
41+
QQmlApplicationEngine engine;
42+
engine.rootContext()->setContextProperty("message", QString::fromStdString(message.translated));
43+
engine.load(QUrl(QStringLiteral("qrc:///qml/pages/initerrormessage.qml")));
44+
qGuiApp->exec();
45+
return false;
46+
}
3547
} // namespace
3648

3749

@@ -42,6 +54,8 @@ int QmlGuiMain(int argc, char* argv[])
4254
QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
4355
QGuiApplication app(argc, argv);
4456

57+
auto handler_message_box = ::uiInterface.ThreadSafeMessageBox_connect(InitErrorMessageBox);
58+
4559
// Parse command-line options. We do this after qt in order to show an error if there are problems parsing these.
4660
SetupServerArgs(gArgs);
4761
SetupUIArgs(gArgs);
@@ -68,6 +82,8 @@ int QmlGuiMain(int argc, char* argv[])
6882
std::unique_ptr<interfaces::Node> node = interfaces::MakeNode(&node_context);
6983
node->baseInitialize();
7084

85+
handler_message_box.disconnect();
86+
7187
NodeModel node_model;
7288
InitExecutor init_executor{*node};
7389
QObject::connect(&node_model, &NodeModel::requestedInitialize, &init_executor, &InitExecutor::initialize);

src/qml/bitcoin_qml.qrc

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<!DOCTYPE RCC><RCC version="1.0">
22
<qresource prefix="/qml">
3+
<file>pages/initerrormessage.qml</file>
34
<file>pages/stub.qml</file>
45
</qresource>
56
</RCC>

src/qml/pages/initerrormessage.qml

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import QtQuick 2.12
2+
import QtQuick.Dialogs 1.3
3+
4+
MessageDialog {
5+
id: messageDialog
6+
title: "Bitcoin Core TnG"
7+
text: message
8+
onAccepted: Qt.quit()
9+
Component.onCompleted: visible = true
10+
}

0 commit comments

Comments
 (0)