blob: 665b55858d38654f81efb3476574a32666f507ec (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
|
/*
* 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.
*/
#include "VideoSelectActionProcessor.h"
#include "FileItem.h"
#include "ServiceBroker.h"
#include "dialogs/GUIDialogContextMenu.h"
#include "dialogs/GUIDialogSelect.h"
#include "filesystem/Directory.h"
#include "guilib/GUIComponent.h"
#include "guilib/GUIWindowManager.h"
#include "guilib/LocalizeStrings.h"
#include "settings/Settings.h"
#include "settings/SettingsComponent.h"
#include "utils/StringUtils.h"
#include "utils/Variant.h"
#include "video/VideoInfoTag.h"
#include "video/guilib/VideoGUIUtils.h"
using namespace VIDEO::GUILIB;
Action CVideoSelectActionProcessorBase::GetDefaultSelectAction()
{
return static_cast<Action>(CServiceBroker::GetSettingsComponent()->GetSettings()->GetInt(
CSettings::SETTING_MYVIDEOS_SELECTACTION));
}
Action CVideoSelectActionProcessorBase::GetDefaultAction()
{
return GetDefaultSelectAction();
}
bool CVideoSelectActionProcessorBase::Process(Action action)
{
if (CVideoPlayActionProcessorBase::Process(action))
return true;
switch (action)
{
case ACTION_CHOOSE:
{
const Action selectedAction = ChooseVideoItemSelectAction();
if (selectedAction < 0)
{
m_userCancelled = true;
return true; // User cancelled the select menu. We're done.
}
return Process(selectedAction);
}
case ACTION_PLAYPART:
{
const unsigned int part = ChooseStackItemPartNumber();
if (part < 1) // part numbers are 1-based
return false;
return OnPlayPartSelected(part);
}
case ACTION_QUEUE:
return OnQueueSelected();
case ACTION_INFO:
return OnInfoSelected();
case ACTION_MORE:
return OnMoreSelected();
default:
break;
}
return false; // We did not handle the action.
}
unsigned int CVideoSelectActionProcessorBase::ChooseStackItemPartNumber() const
{
CFileItemList parts;
XFILE::CDirectory::GetDirectory(m_item->GetDynPath(), parts, "", XFILE::DIR_FLAG_DEFAULTS);
for (int i = 0; i < parts.Size(); ++i)
parts[i]->SetLabel(StringUtils::Format(g_localizeStrings.Get(23051), i + 1)); // Part #
CGUIDialogSelect* dialog =
CServiceBroker::GetGUI()->GetWindowManager().GetWindow<CGUIDialogSelect>(
WINDOW_DIALOG_SELECT);
dialog->Reset();
dialog->SetHeading(CVariant{20324}); // Play part...
dialog->SetItems(parts);
dialog->Open();
if (!dialog->IsConfirmed())
return 0; // User cancelled the dialog.
return dialog->GetSelectedItem() + 1; // part numbers are 1-based
}
Action CVideoSelectActionProcessorBase::ChooseVideoItemSelectAction() const
{
CContextButtons choices;
const std::string resumeString = VIDEO_UTILS::GetResumeString(*m_item);
if (!resumeString.empty())
{
choices.Add(ACTION_RESUME, resumeString);
choices.Add(ACTION_PLAY_FROM_BEGINNING, 12021); // Play from beginning
}
else
{
choices.Add(ACTION_PLAY_FROM_BEGINNING, 208); // Play
}
choices.Add(ACTION_INFO, 22081); // Show information
choices.Add(ACTION_QUEUE, 13347); // Queue item
choices.Add(ACTION_MORE, 22082); // More
return static_cast<Action>(CGUIDialogContextMenu::ShowAndGetChoice(choices));
}
|