2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
9 #include "GUIDialogOK.h"
11 #include "ServiceBroker.h"
12 #include "guilib/GUIComponent.h"
13 #include "guilib/GUIMessage.h"
14 #include "guilib/GUIWindowManager.h"
15 #include "utils/Variant.h"
17 CGUIDialogOK::CGUIDialogOK(void)
18 : CGUIDialogBoxBase(WINDOW_DIALOG_OK
, "DialogConfirm.xml")
22 CGUIDialogOK::~CGUIDialogOK(void) = default;
24 bool CGUIDialogOK::OnMessage(CGUIMessage
& message
)
26 if (message
.GetMessage() == GUI_MSG_CLICKED
)
28 int iControl
= message
.GetSenderId();
29 if (iControl
== CONTROL_YES_BUTTON
)
36 return CGUIDialogBoxBase::OnMessage(message
);
39 // \brief Show CGUIDialogOK dialog, then wait for user to dismiss it.
40 bool CGUIDialogOK::ShowAndGetInput(const CVariant
& heading
, const CVariant
& text
)
42 CGUIDialogOK
*dialog
= CServiceBroker::GetGUI()->GetWindowManager().GetWindow
<CGUIDialogOK
>(WINDOW_DIALOG_OK
);
45 dialog
->SetHeading(heading
);
46 dialog
->SetText(text
);
48 return dialog
->IsConfirmed();
51 // \brief Show CGUIDialogOK dialog, then wait for user to dismiss it.
52 bool CGUIDialogOK::ShowAndGetInput(const CVariant
& heading
,
53 const CVariant
& line0
,
54 const CVariant
& line1
,
55 const CVariant
& line2
)
57 CGUIDialogOK
*dialog
= CServiceBroker::GetGUI()->GetWindowManager().GetWindow
<CGUIDialogOK
>(WINDOW_DIALOG_OK
);
60 dialog
->SetHeading(heading
);
61 dialog
->SetLine(0, line0
);
62 dialog
->SetLine(1, line1
);
63 dialog
->SetLine(2, line2
);
65 return dialog
->IsConfirmed();
68 bool CGUIDialogOK::ShowAndGetInput(const HELPERS::DialogOKMessage
& options
)
70 if (!options
.heading
.isNull())
71 SetHeading(options
.heading
);
72 if (!options
.text
.isNull())
73 SetText(options
.text
);
75 for (size_t i
= 0; i
< 3; ++i
)
77 if (!options
.lines
[i
].isNull())
78 SetLine(i
, options
.lines
[i
]);
84 void CGUIDialogOK::OnInitWindow()
86 SET_CONTROL_HIDDEN(CONTROL_NO_BUTTON
);
87 SET_CONTROL_HIDDEN(CONTROL_CUSTOM_BUTTON
);
88 SET_CONTROL_HIDDEN(CONTROL_PROGRESS_BAR
);
89 SET_CONTROL_FOCUS(CONTROL_YES_BUTTON
, 0);
91 CGUIDialogBoxBase::OnInitWindow();
94 int CGUIDialogOK::GetDefaultLabelID(int controlId
) const
96 if (controlId
== CONTROL_YES_BUTTON
)
98 return CGUIDialogBoxBase::GetDefaultLabelID(controlId
);