summaryrefslogtreecommitdiffstats
path: root/xbmc/messaging/helpers/DialogHelper.cpp
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-10 18:07:22 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-10 18:07:22 +0000
commitc04dcc2e7d834218ef2d4194331e383402495ae1 (patch)
tree7333e38d10d75386e60f336b80c2443c1166031d /xbmc/messaging/helpers/DialogHelper.cpp
parentInitial commit. (diff)
downloadkodi-c04dcc2e7d834218ef2d4194331e383402495ae1.tar.xz
kodi-c04dcc2e7d834218ef2d4194331e383402495ae1.zip
Adding upstream version 2:20.4+dfsg.upstream/2%20.4+dfsg
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'xbmc/messaging/helpers/DialogHelper.cpp')
-rw-r--r--xbmc/messaging/helpers/DialogHelper.cpp94
1 files changed, 94 insertions, 0 deletions
diff --git a/xbmc/messaging/helpers/DialogHelper.cpp b/xbmc/messaging/helpers/DialogHelper.cpp
new file mode 100644
index 0000000..e269c09
--- /dev/null
+++ b/xbmc/messaging/helpers/DialogHelper.cpp
@@ -0,0 +1,94 @@
+/*
+ * Copyright (C) 2005-2018 Team Kodi
+ * This file is part of Kodi - https://kodi.tv
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ * See LICENSES/README.md for more information.
+ */
+
+#include "DialogHelper.h"
+
+#include "ServiceBroker.h"
+#include "messaging/ApplicationMessenger.h"
+
+#include <cassert>
+#include <utility>
+
+namespace KODI
+{
+namespace MESSAGING
+{
+namespace HELPERS
+{
+DialogResponse ShowYesNoDialogText(CVariant heading, CVariant text, CVariant noLabel, CVariant yesLabel, uint32_t autoCloseTimeout)
+{
+ return ShowYesNoCustomDialog(std::move(heading), std::move(text), std::move(noLabel),
+ std::move(yesLabel), "", autoCloseTimeout);
+}
+
+DialogResponse ShowYesNoCustomDialog(CVariant heading, CVariant text, CVariant noLabel, CVariant yesLabel, CVariant customLabel, uint32_t autoCloseTimeout)
+{
+ DialogYesNoMessage options;
+ options.heading = std::move(heading);
+ options.text = std::move(text);
+ options.noLabel = std::move(noLabel);
+ options.yesLabel = std::move(yesLabel);
+ options.customLabel = std::move(customLabel);
+ options.autoclose = autoCloseTimeout;
+
+ switch (CServiceBroker::GetAppMessenger()->SendMsg(TMSG_GUI_DIALOG_YESNO, -1, -1,
+ static_cast<void*>(&options)))
+ {
+ case -1:
+ return DialogResponse::CHOICE_CANCELLED;
+ case 0:
+ return DialogResponse::CHOICE_NO;
+ case 1:
+ return DialogResponse::CHOICE_YES;
+ case 2:
+ return DialogResponse::CHOICE_CUSTOM;
+ default:
+ //If we get here someone changed the return values without updating this code
+ assert(false);
+ }
+ //This is unreachable code but we need to return something to suppress warnings about
+ //no return
+ return DialogResponse::CHOICE_CANCELLED;
+}
+
+DialogResponse ShowYesNoDialogLines(CVariant heading, CVariant line0, CVariant line1, CVariant line2,
+ CVariant noLabel, CVariant yesLabel, uint32_t autoCloseTimeout)
+{
+ DialogYesNoMessage options;
+ options.heading = std::move(heading);
+ options.lines[0] = std::move(line0);
+ options.lines[1] = std::move(line1);
+ options.lines[2] = std::move(line2);
+ options.noLabel = std::move(noLabel);
+ options.yesLabel = std::move(yesLabel);
+ options.customLabel = "";
+ options.autoclose = autoCloseTimeout;
+
+ switch (CServiceBroker::GetAppMessenger()->SendMsg(TMSG_GUI_DIALOG_YESNO, -1, -1,
+ static_cast<void*>(&options)))
+ {
+ case -1:
+ return DialogResponse::CHOICE_CANCELLED;
+ case 0:
+ return DialogResponse::CHOICE_NO;
+ case 1:
+ return DialogResponse::CHOICE_YES;
+ case 2:
+ return DialogResponse::CHOICE_CUSTOM;
+ default:
+ //If we get here someone changed the return values without updating this code
+ assert(false);
+ }
+ //This is unreachable code but we need to return something to suppress warnings about
+ //no return
+ return DialogResponse::CHOICE_CANCELLED;
+}
+
+}
+}
+}