diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-10 18:07:22 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-10 18:07:22 +0000 |
commit | c04dcc2e7d834218ef2d4194331e383402495ae1 (patch) | |
tree | 7333e38d10d75386e60f336b80c2443c1166031d /xbmc/dialogs/GUIDialogPlayEject.cpp | |
parent | Initial commit. (diff) | |
download | kodi-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/dialogs/GUIDialogPlayEject.cpp')
-rw-r--r-- | xbmc/dialogs/GUIDialogPlayEject.cpp | 101 |
1 files changed, 101 insertions, 0 deletions
diff --git a/xbmc/dialogs/GUIDialogPlayEject.cpp b/xbmc/dialogs/GUIDialogPlayEject.cpp new file mode 100644 index 0000000..14ee2bc --- /dev/null +++ b/xbmc/dialogs/GUIDialogPlayEject.cpp @@ -0,0 +1,101 @@ +/* + * 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 "GUIDialogPlayEject.h" + +#include "ServiceBroker.h" +#include "guilib/GUIComponent.h" +#include "guilib/GUIWindowManager.h" +#include "storage/MediaManager.h" +#include "utils/Variant.h" + +#include <utility> + +#define ID_BUTTON_PLAY 11 +#define ID_BUTTON_EJECT 10 + +CGUIDialogPlayEject::CGUIDialogPlayEject() + : CGUIDialogYesNo(WINDOW_DIALOG_PLAY_EJECT) +{ +} + +CGUIDialogPlayEject::~CGUIDialogPlayEject() = default; + +bool CGUIDialogPlayEject::OnMessage(CGUIMessage& message) +{ + if (message.GetMessage() == GUI_MSG_CLICKED) + { + int iControl = message.GetSenderId(); + if (iControl == ID_BUTTON_PLAY) + { + if (CServiceBroker::GetMediaManager().IsDiscInDrive()) + { + m_bConfirmed = true; + Close(); + } + + return true; + } + if (iControl == ID_BUTTON_EJECT) + { + CServiceBroker::GetMediaManager().ToggleTray(); + return true; + } + } + + return CGUIDialogYesNo::OnMessage(message); +} + +void CGUIDialogPlayEject::FrameMove() +{ + CONTROL_ENABLE_ON_CONDITION(ID_BUTTON_PLAY, CServiceBroker::GetMediaManager().IsDiscInDrive()); + + CGUIDialogYesNo::FrameMove(); +} + +void CGUIDialogPlayEject::OnInitWindow() +{ + if (CServiceBroker::GetMediaManager().IsDiscInDrive()) + { + m_defaultControl = ID_BUTTON_PLAY; + } + else + { + CONTROL_DISABLE(ID_BUTTON_PLAY); + m_defaultControl = ID_BUTTON_EJECT; + } + + CGUIDialogYesNo::OnInitWindow(); +} + +bool CGUIDialogPlayEject::ShowAndGetInput(const std::string& strLine1, + const std::string& strLine2, + unsigned int uiAutoCloseTime /* = 0 */) +{ + + // Create the dialog + CGUIDialogPlayEject * pDialog = (CGUIDialogPlayEject *)CServiceBroker::GetGUI()->GetWindowManager(). + GetWindow(WINDOW_DIALOG_PLAY_EJECT); + if (!pDialog) + return false; + + // Setup dialog parameters + pDialog->SetHeading(CVariant{219}); + pDialog->SetLine(0, CVariant{429}); + pDialog->SetLine(1, CVariant{strLine1}); + pDialog->SetLine(2, CVariant{strLine2}); + pDialog->SetChoice(ID_BUTTON_PLAY - 10, 208); + pDialog->SetChoice(ID_BUTTON_EJECT - 10, 13391); + if (uiAutoCloseTime) + pDialog->SetAutoClose(uiAutoCloseTime); + + // Display the dialog + pDialog->Open(); + + return pDialog->IsConfirmed(); +} |