diff options
20 files changed, 140 insertions, 209 deletions
diff --git a/xbmc/favourites/GUIWindowFavourites.cpp b/xbmc/favourites/GUIWindowFavourites.cpp index 25989b364a..10cfc0180f 100644 --- a/xbmc/favourites/GUIWindowFavourites.cpp +++ b/xbmc/favourites/GUIWindowFavourites.cpp @@ -139,7 +139,7 @@ bool CGUIWindowFavourites::OnSelect(int itemIdx) if (targetItem.HasVideoInfoTag() && (!targetItem.m_bIsFolder || isPlayMedia)) { CVideoSelectActionProcessor proc{std::make_shared<CFileItem>(targetItem)}; - if (proc.Process()) + if (proc.ProcessDefaultAction()) return true; } @@ -166,7 +166,7 @@ bool CGUIWindowFavourites::OnAction(const CAction& action) if (item->HasVideoInfoTag() || (item->m_bIsFolder && VIDEO_UTILS::IsItemPlayable(*item))) { CVideoPlayActionProcessor proc{item}; - if (proc.Process()) + if (proc.ProcessDefaultAction()) return true; } diff --git a/xbmc/interfaces/builtins/PlayerBuiltins.cpp b/xbmc/interfaces/builtins/PlayerBuiltins.cpp index 01ee12c1c5..25e6f9c226 100644 --- a/xbmc/interfaces/builtins/PlayerBuiltins.cpp +++ b/xbmc/interfaces/builtins/PlayerBuiltins.cpp @@ -513,13 +513,13 @@ int PlayOrQueueMedia(const std::vector<std::string>& params, bool forcePlay) if (askToResume) { - const VIDEO::GUILIB::SelectAction action = + const VIDEO::GUILIB::Action action = VIDEO::GUILIB::CVideoSelectActionProcessorBase::ChoosePlayOrResume(item); - if (action == VIDEO::GUILIB::SELECT_ACTION_RESUME) + if (action == VIDEO::GUILIB::ACTION_RESUME) { item.SetStartOffset(STARTOFFSET_RESUME); } - else if (action != VIDEO::GUILIB::SELECT_ACTION_PLAY) + else if (action != VIDEO::GUILIB::ACTION_PLAY_FROM_BEGINNING) { // The Resume dialog was closed without any choice return false; diff --git a/xbmc/listproviders/DirectoryProvider.cpp b/xbmc/listproviders/DirectoryProvider.cpp index f1f4228f5d..2811ec1882 100644 --- a/xbmc/listproviders/DirectoryProvider.cpp +++ b/xbmc/listproviders/DirectoryProvider.cpp @@ -564,7 +564,7 @@ bool CDirectoryProvider::OnClick(const CGUIListItemPtr& item) if (targetItem.HasVideoInfoTag() && (!targetItem.m_bIsFolder || isPlayMedia)) { CVideoSelectActionProcessor proc{*this, std::make_shared<CFileItem>(targetItem)}; - if (proc.Process()) + if (proc.ProcessDefaultAction()) return true; } @@ -595,7 +595,7 @@ bool CDirectoryProvider::OnPlay(const CGUIListItemPtr& item) (targetItem.m_bIsFolder && VIDEO_UTILS::IsItemPlayable(targetItem))) { CVideoPlayActionProcessor proc{std::make_shared<CFileItem>(targetItem)}; - if (proc.Process()) + if (proc.ProcessDefaultAction()) return true; } diff --git a/xbmc/pvr/dialogs/GUIDialogPVRGuideInfo.cpp b/xbmc/pvr/dialogs/GUIDialogPVRGuideInfo.cpp index c3c20264e0..1605234bfe 100644 --- a/xbmc/pvr/dialogs/GUIDialogPVRGuideInfo.cpp +++ b/xbmc/pvr/dialogs/GUIDialogPVRGuideInfo.cpp @@ -141,7 +141,7 @@ bool CGUIDialogPVRGuideInfo::OnClickButtonPlay(const CGUIMessage& message) if (recording) { CGUIPVRRecordingsPlayActionProcessor proc{std::make_shared<CFileItem>(recording)}; - proc.Process(); + proc.ProcessDefaultAction(); if (proc.UserCancelled()) Open(); } diff --git a/xbmc/pvr/dialogs/GUIDialogPVRRecordingInfo.cpp b/xbmc/pvr/dialogs/GUIDialogPVRRecordingInfo.cpp index f6af16e05c..6019c3feb1 100644 --- a/xbmc/pvr/dialogs/GUIDialogPVRRecordingInfo.cpp +++ b/xbmc/pvr/dialogs/GUIDialogPVRRecordingInfo.cpp @@ -61,7 +61,7 @@ bool CGUIDialogPVRRecordingInfo::OnClickButtonPlay(const CGUIMessage& message) if (m_recordItem) { CGUIPVRRecordingsPlayActionProcessor proc{m_recordItem}; - proc.Process(); + proc.ProcessDefaultAction(); if (proc.UserCancelled()) Open(); } diff --git a/xbmc/pvr/guilib/PVRGUIActionsPlayback.cpp b/xbmc/pvr/guilib/PVRGUIActionsPlayback.cpp index 4e834af724..504351698a 100644 --- a/xbmc/pvr/guilib/PVRGUIActionsPlayback.cpp +++ b/xbmc/pvr/guilib/PVRGUIActionsPlayback.cpp @@ -60,13 +60,13 @@ bool CPVRGUIActionsPlayback::CheckResumeRecording(const CFileItem& item) const { bool bPlayIt(true); - const VIDEO::GUILIB::SelectAction action = + const VIDEO::GUILIB::Action action = VIDEO::GUILIB::CVideoSelectActionProcessorBase::ChoosePlayOrResume(item); - if (action == VIDEO::GUILIB::SELECT_ACTION_RESUME) + if (action == VIDEO::GUILIB::ACTION_RESUME) { const_cast<CFileItem*>(&item)->SetStartOffset(STARTOFFSET_RESUME); } - else if (action == VIDEO::GUILIB::SELECT_ACTION_PLAY) + else if (action == VIDEO::GUILIB::ACTION_PLAY_FROM_BEGINNING) { const_cast<CFileItem*>(&item)->SetStartOffset(0); } diff --git a/xbmc/pvr/windows/GUIWindowPVRRecordings.cpp b/xbmc/pvr/windows/GUIWindowPVRRecordings.cpp index a1164e640f..3f545098de 100644 --- a/xbmc/pvr/windows/GUIWindowPVRRecordings.cpp +++ b/xbmc/pvr/windows/GUIWindowPVRRecordings.cpp @@ -351,7 +351,7 @@ bool CGUIWindowPVRRecordingsBase::OnMessage(CGUIMessage& message) if (!item->IsParentFolder() && message.GetParam1() == ACTION_PLAYER_PLAY) { CVideoPlayActionProcessor proc{item}; - bReturn = proc.Process(); + bReturn = proc.ProcessDefaultAction(); } else if (item->m_bIsFolder) { @@ -361,7 +361,7 @@ bool CGUIWindowPVRRecordingsBase::OnMessage(CGUIMessage& message) else { CVideoSelectActionProcessor proc(*this, item, iItem); - bReturn = proc.Process(); + bReturn = proc.ProcessDefaultAction(); } break; } diff --git a/xbmc/video/ContextMenus.cpp b/xbmc/video/ContextMenus.cpp index 4128284579..955ad2b3a1 100644 --- a/xbmc/video/ContextMenus.cpp +++ b/xbmc/video/ContextMenus.cpp @@ -236,7 +236,7 @@ bool CVideoChooseVersion::Execute(const std::shared_ptr<CFileItem>& item) const // force selection dialog, regardless of any settings like 'Select default video version' item->SetProperty("force_choose_video_version", true); CVideoSelectActionProcessor proc{item}; - const bool ret = proc.Process(); + const bool ret = proc.ProcessDefaultAction(); item->ClearProperty("force_choose_video_version"); return ret; } @@ -315,9 +315,9 @@ void SetPathAndPlay(const std::shared_ptr<CFileItem>& item, const std::string& p CVideoPlayActionProcessor proc{item, player}; if (resume && (item->GetStartOffset() == STARTOFFSET_RESUME || VIDEO_UTILS::GetItemResumeInformation(*item).isResumable)) - proc.Process(VIDEO::GUILIB::PLAY_ACTION_RESUME); + proc.ProcessAction(VIDEO::GUILIB::ACTION_RESUME); else - proc.Process(VIDEO::GUILIB::PLAY_ACTION_PLAY_FROM_BEGINNING); + proc.ProcessAction(VIDEO::GUILIB::ACTION_PLAY_FROM_BEGINNING); item->ClearProperty("prohibit_choose_video_version"); } diff --git a/xbmc/video/dialogs/GUIDialogVideoInfo.cpp b/xbmc/video/dialogs/GUIDialogVideoInfo.cpp index 08e7a1579f..df4582d229 100644 --- a/xbmc/video/dialogs/GUIDialogVideoInfo.cpp +++ b/xbmc/video/dialogs/GUIDialogVideoInfo.cpp @@ -67,7 +67,6 @@ using namespace XFILE::VIDEODATABASEDIRECTORY; using namespace XFILE; using namespace KODI::MESSAGING; -using namespace VIDEO::GUILIB; #define CONTROL_IMAGE 3 #define CONTROL_TEXTAREA 4 @@ -712,7 +711,7 @@ void CGUIDialogVideoInfo::ClearCastList() namespace { -class CVideoPlayActionProcessor : public CVideoPlayActionProcessorBase +class CVideoPlayActionProcessor : public VIDEO::GUILIB::CVideoPlayActionProcessorBase { public: explicit CVideoPlayActionProcessor(const std::shared_ptr<CFileItem>& item) @@ -791,7 +790,7 @@ void CGUIDialogVideoInfo::Play(bool resume) if (resume) { CVideoPlayActionProcessor proc{m_movieItem}; - proc.Process(PLAY_ACTION_RESUME); + proc.ProcessAction(VIDEO::GUILIB::ACTION_RESUME); } else { @@ -799,13 +798,13 @@ void CGUIDialogVideoInfo::Play(bool resume) { // if dialog has a resume button, play button has always the purpose to start from beginning CVideoPlayActionProcessor proc{m_movieItem}; - proc.Process(PLAY_ACTION_PLAY_FROM_BEGINNING); + proc.ProcessAction(VIDEO::GUILIB::ACTION_PLAY_FROM_BEGINNING); } else { // play button acts according to default play action setting CVideoPlayActionProcessor proc{m_movieItem}; - proc.Process(); + proc.ProcessDefaultAction(); if (proc.UserCancelled()) { // The Resume dialog was closed without any choice diff --git a/xbmc/video/dialogs/GUIDialogVideoVersion.cpp b/xbmc/video/dialogs/GUIDialogVideoVersion.cpp index a8f380ab59..800d4ff311 100644 --- a/xbmc/video/dialogs/GUIDialogVideoVersion.cpp +++ b/xbmc/video/dialogs/GUIDialogVideoVersion.cpp @@ -371,7 +371,7 @@ void CGUIDialogVideoVersion::Play() CloseAll(); CVideoPlayActionProcessor proc{m_videoItem, m_selectedVideoVersion}; - proc.Process(); + proc.ProcessDefaultAction(); } void CGUIDialogVideoVersion::Remove() diff --git a/xbmc/video/guilib/CMakeLists.txt b/xbmc/video/guilib/CMakeLists.txt index c5226897c4..a953270624 100644 --- a/xbmc/video/guilib/CMakeLists.txt +++ b/xbmc/video/guilib/CMakeLists.txt @@ -2,9 +2,8 @@ set(SOURCES VideoPlayActionProcessor.cpp VideoSelectActionProcessor.cpp VideoActionProcessorHelper.cpp) -set(HEADERS VideoPlayAction.h +set(HEADERS VideoAction.h VideoPlayActionProcessor.h - VideoSelectAction.h VideoSelectActionProcessor.h VideoActionProcessorHelper.h) diff --git a/xbmc/video/guilib/VideoAction.h b/xbmc/video/guilib/VideoAction.h new file mode 100644 index 0000000000..d2efd86d3c --- /dev/null +++ b/xbmc/video/guilib/VideoAction.h @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2023 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. + */ + +#pragma once + +namespace VIDEO +{ +namespace GUILIB +{ +// Note: Do not change the numerical values of the elements. Some of them are used as values for +// the integer settings SETTING_MYVIDEOS_SELECTACTION and SETTING_MYVIDEOS_PLAYACTION. +enum Action +{ + ACTION_CHOOSE = 0, + ACTION_PLAY_OR_RESUME = 1, // if resume is possible, ask user. play from beginning otherwise + ACTION_RESUME = 2, // resume if possibly, play from beginning otherwise + ACTION_INFO = 3, + ACTION_MORE = 4, + ACTION_PLAY_FROM_BEGINNING = 5, // play from beginning, also if resume would be possible + ACTION_PLAYPART = 6, + ACTION_QUEUE = 7, +}; +} // namespace GUILIB +} // namespace VIDEO diff --git a/xbmc/video/guilib/VideoPlayAction.h b/xbmc/video/guilib/VideoPlayAction.h deleted file mode 100644 index a566875602..0000000000 --- a/xbmc/video/guilib/VideoPlayAction.h +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright (C) 2023 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. - */ - -#pragma once - -namespace VIDEO -{ -namespace GUILIB -{ -// Note: Do not change the numerical values of the elements. Some of them are used as values for -// the integer setting SETTING_MYVIDEOS_PLAYACTION. -enum PlayAction -{ - PLAY_ACTION_PLAY_OR_RESUME = 1, // if resume is possible, ask user. play from beginning otherwise - PLAY_ACTION_RESUME = 2, // resume if possibly, play from beginning otherwise - PLAY_ACTION_PLAY_FROM_BEGINNING = 5, // play from beginning, also if resume would be possible -}; -} // namespace GUILIB -} // namespace VIDEO diff --git a/xbmc/video/guilib/VideoPlayActionProcessor.cpp b/xbmc/video/guilib/VideoPlayActionProcessor.cpp index 7d508dca82..bea41524d8 100644 --- a/xbmc/video/guilib/VideoPlayActionProcessor.cpp +++ b/xbmc/video/guilib/VideoPlayActionProcessor.cpp @@ -20,54 +20,54 @@ using namespace VIDEO::GUILIB; -PlayAction CVideoPlayActionProcessorBase::GetDefaultPlayAction() +Action CVideoPlayActionProcessorBase::GetDefaultAction() { - return static_cast<PlayAction>(CServiceBroker::GetSettingsComponent()->GetSettings()->GetInt( + return static_cast<Action>(CServiceBroker::GetSettingsComponent()->GetSettings()->GetInt( CSettings::SETTING_MYVIDEOS_PLAYACTION)); } -bool CVideoPlayActionProcessorBase::Process() +bool CVideoPlayActionProcessorBase::ProcessDefaultAction() { - return Process(GetDefaultPlayAction()); + return ProcessAction(GetDefaultAction()); } -bool CVideoPlayActionProcessorBase::Process(PlayAction playAction) +bool CVideoPlayActionProcessorBase::ProcessAction(Action action) { m_userCancelled = false; CVideoActionProcessorHelper procHelper{m_item, m_videoVersion}; - - if (!m_versionChecked) + const auto videoVersion{procHelper.ChooseVideoVersion()}; + if (videoVersion) + m_item = videoVersion; + else { - m_versionChecked = true; - const auto videoVersion{procHelper.ChooseVideoVersion()}; - if (videoVersion) - m_item = videoVersion; - else - { - m_userCancelled = true; - return true; // User cancelled the select menu. We're done. - } + m_userCancelled = true; + return true; // User cancelled the select menu. We're done. } - switch (playAction) + return Process(action); +} + +bool CVideoPlayActionProcessorBase::Process(Action action) +{ + switch (action) { - case PLAY_ACTION_PLAY_OR_RESUME: + case ACTION_PLAY_OR_RESUME: { - const VIDEO::GUILIB::PlayAction action = ChoosePlayOrResume(); - if (action < 0) + const Action selectedAction = ChoosePlayOrResume(*m_item); + if (selectedAction < 0) { m_userCancelled = true; return true; // User cancelled the select menu. We're done. } - return Process(action); + return Process(selectedAction); } - case PLAY_ACTION_RESUME: + case ACTION_RESUME: return OnResumeSelected(); - case PLAY_ACTION_PLAY_FROM_BEGINNING: + case ACTION_PLAY_FROM_BEGINNING: return OnPlaySelected(); default: @@ -76,19 +76,19 @@ bool CVideoPlayActionProcessorBase::Process(PlayAction playAction) return false; // We did not handle the action. } -PlayAction CVideoPlayActionProcessorBase::ChoosePlayOrResume() +Action CVideoPlayActionProcessorBase::ChoosePlayOrResume(const CFileItem& item) { - PlayAction action = PLAY_ACTION_PLAY_FROM_BEGINNING; + Action action = ACTION_PLAY_FROM_BEGINNING; - const std::string resumeString = VIDEO_UTILS::GetResumeString(*m_item); + const std::string resumeString = VIDEO_UTILS::GetResumeString(item); if (!resumeString.empty()) { CContextButtons choices; - choices.Add(PLAY_ACTION_RESUME, resumeString); - choices.Add(PLAY_ACTION_PLAY_FROM_BEGINNING, 12021); // Play from beginning + choices.Add(ACTION_RESUME, resumeString); + choices.Add(ACTION_PLAY_FROM_BEGINNING, 12021); // Play from beginning - action = static_cast<PlayAction>(CGUIDialogContextMenu::ShowAndGetChoice(choices)); + action = static_cast<Action>(CGUIDialogContextMenu::ShowAndGetChoice(choices)); } return action; diff --git a/xbmc/video/guilib/VideoPlayActionProcessor.h b/xbmc/video/guilib/VideoPlayActionProcessor.h index 25753bc6d0..33105be8ad 100644 --- a/xbmc/video/guilib/VideoPlayActionProcessor.h +++ b/xbmc/video/guilib/VideoPlayActionProcessor.h @@ -8,7 +8,7 @@ #pragma once -#include "video/guilib/VideoPlayAction.h" +#include "video/guilib/VideoAction.h" #include <memory> @@ -29,14 +29,17 @@ public: } virtual ~CVideoPlayActionProcessorBase() = default; - static PlayAction GetDefaultPlayAction(); - - bool Process(); - bool Process(PlayAction playAction); + bool ProcessDefaultAction(); + bool ProcessAction(Action action); bool UserCancelled() const { return m_userCancelled; } + static Action ChoosePlayOrResume(const CFileItem& item); + protected: + virtual Action GetDefaultAction(); + virtual bool Process(Action action); + virtual bool OnResumeSelected() = 0; virtual bool OnPlaySelected() = 0; @@ -45,9 +48,7 @@ protected: private: CVideoPlayActionProcessorBase() = delete; - PlayAction ChoosePlayOrResume(); - bool m_versionChecked{false}; const std::shared_ptr<const CFileItem> m_videoVersion; }; } // namespace GUILIB diff --git a/xbmc/video/guilib/VideoSelectAction.h b/xbmc/video/guilib/VideoSelectAction.h deleted file mode 100644 index 731e0cf35b..0000000000 --- a/xbmc/video/guilib/VideoSelectAction.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (C) 2023 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. - */ - -#pragma once - -namespace VIDEO -{ -namespace GUILIB -{ -// Note: Do not change the numerical values of the elements. Some of them are used as values for -// the integer setting SETTING_MYVIDEOS_SELECTACTION. -enum SelectAction -{ - SELECT_ACTION_CHOOSE = 0, - SELECT_ACTION_PLAY_OR_RESUME = 1, - SELECT_ACTION_RESUME = 2, - SELECT_ACTION_INFO = 3, - SELECT_ACTION_MORE = 4, - SELECT_ACTION_PLAY = 5, - SELECT_ACTION_PLAYPART = 6, - SELECT_ACTION_QUEUE = 7, -}; -} // namespace GUILIB -} // namespace VIDEO diff --git a/xbmc/video/guilib/VideoSelectActionProcessor.cpp b/xbmc/video/guilib/VideoSelectActionProcessor.cpp index 15fd6e5e4d..4458115bbf 100644 --- a/xbmc/video/guilib/VideoSelectActionProcessor.cpp +++ b/xbmc/video/guilib/VideoSelectActionProcessor.cpp @@ -22,56 +22,40 @@ #include "utils/Variant.h" #include "video/VideoInfoTag.h" #include "video/VideoUtils.h" -#include "video/guilib/VideoActionProcessorHelper.h" using namespace VIDEO::GUILIB; -SelectAction CVideoSelectActionProcessorBase::GetDefaultSelectAction() +Action CVideoSelectActionProcessorBase::GetDefaultSelectAction() { - return static_cast<SelectAction>(CServiceBroker::GetSettingsComponent()->GetSettings()->GetInt( + return static_cast<Action>(CServiceBroker::GetSettingsComponent()->GetSettings()->GetInt( CSettings::SETTING_MYVIDEOS_SELECTACTION)); } -bool CVideoSelectActionProcessorBase::Process() +Action CVideoSelectActionProcessorBase::GetDefaultAction() { - return Process(GetDefaultSelectAction()); + return GetDefaultSelectAction(); } -bool CVideoSelectActionProcessorBase::Process(SelectAction selectAction) +bool CVideoSelectActionProcessorBase::Process(Action action) { - CVideoActionProcessorHelper procHelper{m_item, m_videoVersion}; + if (CVideoPlayActionProcessorBase::Process(action)) + return true; - if (!m_versionChecked) + switch (action) { - m_versionChecked = true; - const auto videoVersion{procHelper.ChooseVideoVersion()}; - if (videoVersion) - m_item = videoVersion; - else - return true; // User cancelled the select menu. We're done. - } - - switch (selectAction) - { - case SELECT_ACTION_CHOOSE: - { - const SelectAction action = ChooseVideoItemSelectAction(); - if (action < 0) - return true; // User cancelled the context menu. We're done. - - return Process(action); - } - - case SELECT_ACTION_PLAY_OR_RESUME: + case ACTION_CHOOSE: { - const SelectAction action = ChoosePlayOrResume(*m_item); - if (action < 0) + const Action selectedAction = ChooseVideoItemSelectAction(); + if (selectedAction < 0) + { + m_userCancelled = true; return true; // User cancelled the select menu. We're done. + } - return Process(action); + return Process(selectedAction); } - case SELECT_ACTION_PLAYPART: + case ACTION_PLAYPART: { const unsigned int part = ChooseStackItemPartNumber(); if (part < 1) // part numbers are 1-based @@ -80,19 +64,13 @@ bool CVideoSelectActionProcessorBase::Process(SelectAction selectAction) return OnPlayPartSelected(part); } - case SELECT_ACTION_RESUME: - return OnResumeSelected(); - - case SELECT_ACTION_PLAY: - return OnPlaySelected(); - - case SELECT_ACTION_QUEUE: + case ACTION_QUEUE: return OnQueueSelected(); - case SELECT_ACTION_INFO: + case ACTION_INFO: return OnInfoSelected(); - case SELECT_ACTION_MORE: + case ACTION_MORE: return OnMoreSelected(); default: @@ -124,42 +102,24 @@ unsigned int CVideoSelectActionProcessorBase::ChooseStackItemPartNumber() const return dialog->GetSelectedItem() + 1; // part numbers are 1-based } -SelectAction CVideoSelectActionProcessorBase::ChoosePlayOrResume(const CFileItem& item) -{ - SelectAction action = SELECT_ACTION_PLAY; - - const std::string resumeString = VIDEO_UTILS::GetResumeString(item); - if (!resumeString.empty()) - { - CContextButtons choices; - - choices.Add(SELECT_ACTION_RESUME, resumeString); - choices.Add(SELECT_ACTION_PLAY, 12021); // Play from beginning - - action = static_cast<SelectAction>(CGUIDialogContextMenu::ShowAndGetChoice(choices)); - } - - return action; -} - -SelectAction CVideoSelectActionProcessorBase::ChooseVideoItemSelectAction() const +Action CVideoSelectActionProcessorBase::ChooseVideoItemSelectAction() const { CContextButtons choices; const std::string resumeString = VIDEO_UTILS::GetResumeString(*m_item); if (!resumeString.empty()) { - choices.Add(SELECT_ACTION_RESUME, resumeString); - choices.Add(SELECT_ACTION_PLAY, 12021); // Play from beginning + choices.Add(ACTION_RESUME, resumeString); + choices.Add(ACTION_PLAY_FROM_BEGINNING, 12021); // Play from beginning } else { - choices.Add(SELECT_ACTION_PLAY, 208); // Play + choices.Add(ACTION_PLAY_FROM_BEGINNING, 208); // Play } - choices.Add(SELECT_ACTION_INFO, 22081); // Show information - choices.Add(SELECT_ACTION_QUEUE, 13347); // Queue item - choices.Add(SELECT_ACTION_MORE, 22082); // More + choices.Add(ACTION_INFO, 22081); // Show information + choices.Add(ACTION_QUEUE, 13347); // Queue item + choices.Add(ACTION_MORE, 22082); // More - return static_cast<SelectAction>(CGUIDialogContextMenu::ShowAndGetChoice(choices)); + return static_cast<Action>(CGUIDialogContextMenu::ShowAndGetChoice(choices)); } diff --git a/xbmc/video/guilib/VideoSelectActionProcessor.h b/xbmc/video/guilib/VideoSelectActionProcessor.h index a154921166..11217df5a6 100644 --- a/xbmc/video/guilib/VideoSelectActionProcessor.h +++ b/xbmc/video/guilib/VideoSelectActionProcessor.h @@ -8,7 +8,7 @@ #pragma once -#include "video/guilib/VideoSelectAction.h" +#include "video/guilib/VideoPlayActionProcessor.h" #include <memory> @@ -18,41 +18,37 @@ namespace VIDEO { namespace GUILIB { -class CVideoSelectActionProcessorBase +class CVideoSelectActionProcessorBase : public CVideoPlayActionProcessorBase { public: - explicit CVideoSelectActionProcessorBase(const std::shared_ptr<CFileItem>& item) : m_item(item) {} + explicit CVideoSelectActionProcessorBase(const std::shared_ptr<CFileItem>& item) + : CVideoPlayActionProcessorBase(item) + { + } + CVideoSelectActionProcessorBase(const std::shared_ptr<CFileItem>& item, const std::shared_ptr<const CFileItem>& videoVersion) - : m_item{item}, m_videoVersion{videoVersion} + : CVideoPlayActionProcessorBase(item, videoVersion) { } - virtual ~CVideoSelectActionProcessorBase() = default; - - static SelectAction GetDefaultSelectAction(); - bool Process(); - bool Process(SelectAction selectAction); + ~CVideoSelectActionProcessorBase() override = default; - static SelectAction ChoosePlayOrResume(const CFileItem& item); + static Action GetDefaultSelectAction(); protected: + Action GetDefaultAction() override; + bool Process(Action action) override; + virtual bool OnPlayPartSelected(unsigned int part) = 0; - virtual bool OnResumeSelected() = 0; - virtual bool OnPlaySelected() = 0; virtual bool OnQueueSelected() = 0; virtual bool OnInfoSelected() = 0; virtual bool OnMoreSelected() = 0; - std::shared_ptr<CFileItem> m_item; - private: CVideoSelectActionProcessorBase() = delete; - SelectAction ChooseVideoItemSelectAction() const; + Action ChooseVideoItemSelectAction() const; unsigned int ChooseStackItemPartNumber() const; - - bool m_versionChecked{false}; - const std::shared_ptr<const CFileItem> m_videoVersion; }; } // namespace GUILIB } // namespace VIDEO diff --git a/xbmc/video/windows/GUIWindowVideoBase.cpp b/xbmc/video/windows/GUIWindowVideoBase.cpp index 7e7ee38705..99721ed0b8 100644 --- a/xbmc/video/windows/GUIWindowVideoBase.cpp +++ b/xbmc/video/windows/GUIWindowVideoBase.cpp @@ -607,14 +607,14 @@ private: }; } // namespace -bool CGUIWindowVideoBase::OnFileAction(int iItem, SelectAction action, const std::string& player) +bool CGUIWindowVideoBase::OnFileAction(int iItem, Action action, const std::string& player) { const std::shared_ptr<CFileItem> item = m_vecItems->Get(iItem); if (!item) return false; CVideoSelectActionProcessor proc(*this, item, iItem, player); - return proc.Process(action); + return proc.ProcessAction(action); } bool CGUIWindowVideoBase::OnItemInfo(int iItem) @@ -754,13 +754,13 @@ protected: bool OnResumeSelected() override { m_item->SetStartOffset(STARTOFFSET_RESUME); - return m_window.OnFileAction(m_itemIndex, SELECT_ACTION_RESUME, m_player); + return m_window.OnFileAction(m_itemIndex, VIDEO::GUILIB::ACTION_RESUME, m_player); } bool OnPlaySelected() override { m_item->SetStartOffset(0); - return m_window.OnFileAction(m_itemIndex, SELECT_ACTION_PLAY, m_player); + return m_window.OnFileAction(m_itemIndex, VIDEO::GUILIB::ACTION_PLAY_FROM_BEGINNING, m_player); } private: @@ -776,7 +776,7 @@ bool CGUIWindowVideoBase::OnPlayOrResumeItem(int iItem, const std::string& playe return false; CVideoPlayActionProcessor proc{*this, m_vecItems->Get(iItem), iItem, player}; - return proc.Process(); + return proc.ProcessDefaultAction(); } void CGUIWindowVideoBase::GetContextButtons(int itemNumber, CContextButtons &buttons) @@ -851,13 +851,13 @@ bool CGUIWindowVideoBase::OnPlayStackPart(int itemIndex, unsigned int partNumber CDirectory::GetDirectory(path, parts, "", DIR_FLAG_DEFAULTS); const int value = CVideoSelectActionProcessor::ChoosePlayOrResume(*parts[partNumber - 1]); - if (value == SELECT_ACTION_RESUME) + if (value == VIDEO::GUILIB::ACTION_RESUME) { const VIDEO_UTILS::ResumeInformation resumeInfo = VIDEO_UTILS::GetItemResumeInformation(*parts[partNumber - 1]); item->SetStartOffset(resumeInfo.startOffset); } - else if (value != SELECT_ACTION_PLAY) + else if (value != VIDEO::GUILIB::ACTION_PLAY_FROM_BEGINNING) return false; // if not selected PLAY, then we changed our mind so return item->m_lStartPartNumber = partNumber; @@ -894,7 +894,7 @@ bool CGUIWindowVideoBase::OnContextButton(int itemNumber, CONTEXT_BUTTON button) } case CONTEXT_BUTTON_PLAY_PART: { - return OnFileAction(itemNumber, SELECT_ACTION_PLAYPART, ""); + return OnFileAction(itemNumber, VIDEO::GUILIB::ACTION_PLAYPART, ""); } case CONTEXT_BUTTON_PLAY_PARTYMODE: diff --git a/xbmc/video/windows/GUIWindowVideoBase.h b/xbmc/video/windows/GUIWindowVideoBase.h index 9916980d4a..1542ac4dce 100644 --- a/xbmc/video/windows/GUIWindowVideoBase.h +++ b/xbmc/video/windows/GUIWindowVideoBase.h @@ -11,7 +11,7 @@ #include "playlists/PlayListTypes.h" #include "video/VideoDatabase.h" #include "video/VideoThumbLoader.h" -#include "video/guilib/VideoSelectAction.h" +#include "video/guilib/VideoAction.h" #include "windows/GUIMediaWindow.h" namespace @@ -95,7 +95,7 @@ protected: \param action the action to perform \return true if the action is performed, false otherwise */ - bool OnFileAction(int item, VIDEO::GUILIB::SelectAction action, const std::string& player); + bool OnFileAction(int item, VIDEO::GUILIB::Action action, const std::string& player); void OnRestartItem(int iItem, const std::string &player = ""); bool OnPlayOrResumeItem(int iItem, const std::string& player = ""); |