aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorksooo <3226626+ksooo@users.noreply.github.com>2023-12-08 14:51:39 +0100
committerksooo <3226626+ksooo@users.noreply.github.com>2023-12-08 14:51:39 +0100
commit06418a134fda7ac57474f9a36e16d9ebf0c901c2 (patch)
tree1dcce1415ea79fec77a4968017fa2e8409f834f0
parentc68601d6c27d76ec3909b04a951a29d1cf8cb301 (diff)
[video] Derive VIDEO::GUILIB::CVideoSelectActionProcessorBase from VIDEO::GUILIB::CVideoPlayActionProcessorBase -> eliminate duplicate code.
-rw-r--r--xbmc/favourites/GUIWindowFavourites.cpp4
-rw-r--r--xbmc/listproviders/DirectoryProvider.cpp4
-rw-r--r--xbmc/pvr/dialogs/GUIDialogPVRGuideInfo.cpp2
-rw-r--r--xbmc/pvr/dialogs/GUIDialogPVRRecordingInfo.cpp2
-rw-r--r--xbmc/pvr/windows/GUIWindowPVRRecordings.cpp4
-rw-r--r--xbmc/video/ContextMenus.cpp6
-rw-r--r--xbmc/video/dialogs/GUIDialogVideoInfo.cpp6
-rw-r--r--xbmc/video/dialogs/GUIDialogVideoVersion.cpp2
-rw-r--r--xbmc/video/guilib/VideoPlayActionProcessor.cpp42
-rw-r--r--xbmc/video/guilib/VideoPlayActionProcessor.h13
-rw-r--r--xbmc/video/guilib/VideoSelectActionProcessor.cpp64
-rw-r--r--xbmc/video/guilib/VideoSelectActionProcessor.h30
-rw-r--r--xbmc/video/windows/GUIWindowVideoBase.cpp4
13 files changed, 70 insertions, 113 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/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/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 ef73320587..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::ACTION_RESUME);
+ proc.ProcessAction(VIDEO::GUILIB::ACTION_RESUME);
else
- proc.Process(VIDEO::GUILIB::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 a76286d711..df4582d229 100644
--- a/xbmc/video/dialogs/GUIDialogVideoInfo.cpp
+++ b/xbmc/video/dialogs/GUIDialogVideoInfo.cpp
@@ -790,7 +790,7 @@ void CGUIDialogVideoInfo::Play(bool resume)
if (resume)
{
CVideoPlayActionProcessor proc{m_movieItem};
- proc.Process(VIDEO::GUILIB::ACTION_RESUME);
+ proc.ProcessAction(VIDEO::GUILIB::ACTION_RESUME);
}
else
{
@@ -798,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(VIDEO::GUILIB::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/VideoPlayActionProcessor.cpp b/xbmc/video/guilib/VideoPlayActionProcessor.cpp
index 2f59154603..bea41524d8 100644
--- a/xbmc/video/guilib/VideoPlayActionProcessor.cpp
+++ b/xbmc/video/guilib/VideoPlayActionProcessor.cpp
@@ -20,48 +20,48 @@
using namespace VIDEO::GUILIB;
-Action CVideoPlayActionProcessorBase::GetDefaultPlayAction()
+Action CVideoPlayActionProcessorBase::GetDefaultAction()
{
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(Action 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 ACTION_PLAY_OR_RESUME:
{
- const Action 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 ACTION_RESUME:
@@ -76,11 +76,11 @@ bool CVideoPlayActionProcessorBase::Process(Action playAction)
return false; // We did not handle the action.
}
-Action CVideoPlayActionProcessorBase::ChoosePlayOrResume()
+Action CVideoPlayActionProcessorBase::ChoosePlayOrResume(const CFileItem& item)
{
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;
diff --git a/xbmc/video/guilib/VideoPlayActionProcessor.h b/xbmc/video/guilib/VideoPlayActionProcessor.h
index a09ffd30e8..33105be8ad 100644
--- a/xbmc/video/guilib/VideoPlayActionProcessor.h
+++ b/xbmc/video/guilib/VideoPlayActionProcessor.h
@@ -29,14 +29,17 @@ public:
}
virtual ~CVideoPlayActionProcessorBase() = default;
- static Action GetDefaultPlayAction();
-
- bool Process();
- bool Process(Action 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;
- Action ChoosePlayOrResume();
- bool m_versionChecked{false};
const std::shared_ptr<const CFileItem> m_videoVersion;
};
} // namespace GUILIB
diff --git a/xbmc/video/guilib/VideoSelectActionProcessor.cpp b/xbmc/video/guilib/VideoSelectActionProcessor.cpp
index 3bab184d23..4458115bbf 100644
--- a/xbmc/video/guilib/VideoSelectActionProcessor.cpp
+++ b/xbmc/video/guilib/VideoSelectActionProcessor.cpp
@@ -22,7 +22,6 @@
#include "utils/Variant.h"
#include "video/VideoInfoTag.h"
#include "video/VideoUtils.h"
-#include "video/guilib/VideoActionProcessorHelper.h"
using namespace VIDEO::GUILIB;
@@ -32,43 +31,28 @@ Action CVideoSelectActionProcessorBase::GetDefaultSelectAction()
CSettings::SETTING_MYVIDEOS_SELECTACTION));
}
-bool CVideoSelectActionProcessorBase::Process()
+Action CVideoSelectActionProcessorBase::GetDefaultAction()
{
- return Process(GetDefaultSelectAction());
+ return GetDefaultSelectAction();
}
-bool CVideoSelectActionProcessorBase::Process(Action selectAction)
+bool CVideoSelectActionProcessorBase::Process(Action action)
{
- CVideoActionProcessorHelper procHelper{m_item, m_videoVersion};
+ if (CVideoPlayActionProcessorBase::Process(action))
+ return true;
- if (!m_versionChecked)
- {
- 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)
+ switch (action)
{
case ACTION_CHOOSE:
{
- const Action action = ChooseVideoItemSelectAction();
- if (action < 0)
- return true; // User cancelled the context menu. We're done.
-
- return Process(action);
- }
-
- case ACTION_PLAY_OR_RESUME:
- {
- const Action 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 ACTION_PLAYPART:
@@ -80,12 +64,6 @@ bool CVideoSelectActionProcessorBase::Process(Action selectAction)
return OnPlayPartSelected(part);
}
- case ACTION_RESUME:
- return OnResumeSelected();
-
- case ACTION_PLAY_FROM_BEGINNING:
- return OnPlaySelected();
-
case ACTION_QUEUE:
return OnQueueSelected();
@@ -124,24 +102,6 @@ unsigned int CVideoSelectActionProcessorBase::ChooseStackItemPartNumber() const
return dialog->GetSelectedItem() + 1; // part numbers are 1-based
}
-Action CVideoSelectActionProcessorBase::ChoosePlayOrResume(const CFileItem& item)
-{
- Action action = ACTION_PLAY_FROM_BEGINNING;
-
- const std::string resumeString = VIDEO_UTILS::GetResumeString(item);
- if (!resumeString.empty())
- {
- CContextButtons choices;
-
- choices.Add(ACTION_RESUME, resumeString);
- choices.Add(ACTION_PLAY_FROM_BEGINNING, 12021); // Play from beginning
-
- action = static_cast<Action>(CGUIDialogContextMenu::ShowAndGetChoice(choices));
- }
-
- return action;
-}
-
Action CVideoSelectActionProcessorBase::ChooseVideoItemSelectAction() const
{
CContextButtons choices;
diff --git a/xbmc/video/guilib/VideoSelectActionProcessor.h b/xbmc/video/guilib/VideoSelectActionProcessor.h
index 12332addb9..11217df5a6 100644
--- a/xbmc/video/guilib/VideoSelectActionProcessor.h
+++ b/xbmc/video/guilib/VideoSelectActionProcessor.h
@@ -8,7 +8,7 @@
#pragma once
-#include "video/guilib/VideoAction.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 Action GetDefaultSelectAction();
- bool Process();
- bool Process(Action selectAction);
+ ~CVideoSelectActionProcessorBase() override = default;
- static Action 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;
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 6ad778a048..99721ed0b8 100644
--- a/xbmc/video/windows/GUIWindowVideoBase.cpp
+++ b/xbmc/video/windows/GUIWindowVideoBase.cpp
@@ -614,7 +614,7 @@ bool CGUIWindowVideoBase::OnFileAction(int iItem, Action action, const std::stri
return false;
CVideoSelectActionProcessor proc(*this, item, iItem, player);
- return proc.Process(action);
+ return proc.ProcessAction(action);
}
bool CGUIWindowVideoBase::OnItemInfo(int iItem)
@@ -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)