16#define LOC QString("Slideview: ")
22 std::ranges::copy_if(std::as_const(comment), std::back_inserter(result),
23 [](QChar x) {
return x.isPrint(); } );
39 m_transition(m_availableTransitions.Select(
43 m_slideShowTime(
gCoreContext->GetDurSetting<std::chrono::milliseconds>(
"GallerySlideShowTime", 3s)),
44 m_showCaptions(
gCoreContext->GetBoolSetting(
"GalleryShowSlideCaptions",
true)),
45 m_editsAllowed(editsAllowed)
66 LOG(VB_GUI, LOG_DEBUG,
"Created Slideview");
77 LOG(VB_GUI, LOG_DEBUG,
"Deleted Slideview");
100 LOG(VB_GENERAL, LOG_ERR,
LOC +
"Cannot load screen 'Slideshow'");
107 LOG(VB_GENERAL, LOG_ERR,
LOC +
"Cannot load 'Info buttonlist'");
153 for (
int i = 0; i < actions.size() && !handled; i++)
155 const QString&
action = actions[i];
162 else if (
action ==
"RIGHT")
170 else if (
action ==
"DOWN")
174 else if (
action ==
"INFO")
178 else if (
action ==
"MENU")
182 else if (
action ==
"PLAY")
189 else if (
action ==
"SELECT")
193 else if (
action ==
"STOP")
197 else if (
action ==
"ROTRIGHT")
201 else if (
action ==
"ROTLEFT")
205 else if (
action ==
"FLIPHORIZONTAL")
209 else if (
action ==
"FLIPVERTICAL")
213 else if (
action ==
"ZOOMIN")
217 else if (
action ==
"ZOOMOUT")
221 else if (
action ==
"FULLSIZE")
225 else if (
action ==
"SCROLLUP")
229 else if (
action ==
"SCROLLDOWN")
231 Pan(QPoint(0, -100));
233 else if (
action ==
"SCROLLLEFT")
235 Pan(QPoint(-120, 0));
237 else if (
action ==
"SCROLLRIGHT")
241 else if (
action ==
"RECENTER")
271 auto *me =
dynamic_cast<MythEvent *
>(event);
275 const QString& message = me->
Message();
277 QStringList extra = me->ExtraDataList();
279 if (message ==
"IMAGE_METADATA" && !extra.isEmpty())
281 int id = extra[0].toInt();
284 if (selected && selected->m_id ==
id)
287 else if (message ==
"THUMB_AVAILABLE")
289 if (!extra.isEmpty() &&
m_view->
Update(extra[0].toInt()))
297 QString resultid = dce->GetId();
298 int buttonnum = dce->GetResult();
300 if (resultid ==
"metadatamenu")
309 case 5:
Zoom(10);
break;
310 case 6:
Zoom(-10);
break;
323 auto *
menu =
new MythMenu(tr(
"Slideshow Options"),
this,
"mainmenu");
352 case kBasicInfo: details = tr(
"More Details");
break;
353 case kFullInfo: details = tr(
"Less Details");
break;
355 case kNoInfo: details = tr(
"Show Details");
break;
364 if (menuPopup->Create())
381 this,
"metadatamenu");
384 menu->AddItem(tr(
"Rotate CW"));
385 menu->AddItem(tr(
"Rotate CCW"));
386 menu->AddItem(tr(
"Flip Horizontal"));
387 menu->AddItem(tr(
"Flip Vertical"));
388 menu->AddItem(tr(
"Reset to Exif"));
392 menu->AddItem(tr(
"Zoom In"));
395 menu->AddItem(tr(
"Zoom Out"));
527 list.append(im->m_id);
606 LOG(VB_FILE, LOG_DEBUG,
LOC + QString(
"Selected %1").arg(im->m_filePath));
626 float speed = 0.5F + (count / 2.0F);
632 LOG(VB_FILE, LOG_DEBUG,
LOC + QString(
"Changing speed to %1").arg(speed));
702 if (!comment.isEmpty())
830 SetStatus(tr(
"Failed to load %1").arg(im ? im->m_filePath :
"?"));
Event dispatched from MythUI modal dialogs to a listening class containing a result of some form.
static const Type kEventType
A datastore of images for display by a screen.
bool Update(int id)
Updates view with images that have been updated.
ImagePtrK Prev(int inc)
Decrements iterator and returns previous image. Wraps at start.
bool Select(int id, int fallback=0)
Selects first occurrence of an image.
ImagePtrK HasNext(int inc) const
Peeks at next image in view but does not advance iterator.
ImagePtrK Next(int inc)
Advance iterator and return next image, wrapping if necessary. Regenerates unordered views on wrap.
QString GetPosition() const
Get positional status.
ImagePtrK GetSelected() const
Get current selection.
virtual bool LoadFromDb(int parentId)
Populate view with database images from a directory.
ImagePtrK HasPrev(int inc) const
Peeks at previous image in view but does not decrement iterator.
void Rotate(int id)
Rotate view so that starting image is at front.
void ClearStatus(const Slide &slide)
QString m_statusText
Text to display as status.
MythUIText * m_uiSlideCount
QTimer m_timer
Slide duration timer.
MythUIText * m_uiHideCaptions
ImageManagerFe & m_mgr
Manages the images.
bool m_showCaptions
If true, captions are shown.
void ShowInfo()
Show exif info list.
void HideCaptions()
Hide text widgets.
~GallerySlideView() override
Destructor.
void PlayVideo()
Starts internal player for video.
void Release()
Unpause transition timer.
FlatView * m_view
List of images comprising the slideshow.
void customEvent(QEvent *event) override
Handle custom events.
void HideInfo()
Hide exif info list.
SlideBuffer m_slides
A queue of slides used to display images.
bool Create() override
Initialises the graphical elements.
bool m_editsAllowed
True when edits are enabled.
bool m_transitioning
True when a transition is in progress.
void ShowCaptions()
Show text widgets.
TransitionNone m_updateTransition
Instant transition that is always used for start-up & image updates.
void Start(ImageSlideShowType type, int parentId, int selectedId=0)
Start slideshow.
void TransitionComplete()
Transition to new slide has finished.
QTimer m_delay
Status delay timer.
void SetStatus(QString msg, bool delay=false)
Displays status text (Loading, Paused etc.)
void Pan(QPoint offset=QPoint(0, 0))
Pan current slide.
MythUIText * m_uiCaptionText
void MenuTransforms(MythMenu &mainMenu)
Add Transforms submenu.
InfoList m_infoList
Image details overlay.
void MenuMain()
Shows the popup menu.
GallerySlideView(MythScreenStack *parent, const char *name, bool editsAllowed)
Constructor.
void Stop()
Stop a playing slideshow.
void Zoom(int increment=0)
Zoom current slide.
bool m_playing
True when slideshow is running.
void Pulse() override
Update transition.
void Suspend()
Pause transition timer temporarily.
bool m_suspended
True when transition is running or video playing.
void SlideAvailable(int count)
Start transition.
Transition & m_transition
Selected transition.
bool keyPressEvent(QKeyEvent *event) override
Handle keypresses.
void ShowPrevSlide(int inc=1)
Display the previous slide in the sequence.
std::chrono::milliseconds m_slideShowTime
Time to display a slide in a slideshow.
void Transform(ImageFileTransform state)
Action transform request.
void ShowSlide(int direction=0)
Display slide.
The image manager for use by Frontends.
QString ChangeOrientation(ImageFileTransform transform, const ImageIdList &ids)
Apply an orientation transform to images.
static QString LongDateOf(const ImagePtrK &im)
Return a timestamp/datestamp for an image or dir.
void Display(ImageItemK &im, const QStringList &tagStrings)
Build list of metadata tags.
void Update(const ImagePtrK &im)
Populates available exif details for the current image/dir.
InfoVisibleState GetState() const
bool Hide()
Remove infolist from display.
void Toggle(const ImagePtrK &im)
Toggle infolist state for an image. Focusable widgets toggle between Basic & Full info....
bool Create(bool focusable)
Initialise buttonlist from XML.
void SaveSetting(const QString &key, int newValue)
T GetDurSetting(const QString &key, T defaultval=T::zero())
int GetNumSetting(const QString &key, int defaultval=0)
bool GetBoolSetting(const QString &key, bool defaultval=false)
Basic menu dialog, message and a list of options.
This class is used as a container for messages.
const QString & Message() const
static const Type kMythEventMessage
static void DisableScreensaver()
bool TranslateKeyPress(const QString &Context, QKeyEvent *Event, QStringList &Actions, bool AllowJumps=true)
Get a list of actions for a keypress in the given context.
MythScreenStack * GetStack(const QString &Stackname)
bool HandleMedia(const QString &Handler, const QString &Mrl, const QString &Plot="", const QString &Title="", const QString &Subtitle="", const QString &Director="", int Season=0, int Episode=0, const QString &Inetref="", std::chrono::minutes LenMins=2h, const QString &Year="1895", const QString &Id="", bool UseBookmarks=false)
static void RestoreScreensaver()
void addListener(QObject *listener)
Add a listener to the observable.
void removeListener(QObject *listener)
Remove a listener to the observable.
virtual void AddScreen(MythScreenType *screen, bool allowFade=true)
Screen in which all other widgets are contained and rendered.
void BuildFocusList(void)
MythUIType * GetFocusWidget(void) const
bool keyPressEvent(QKeyEvent *event) override
Key event handler.
bool SetFocusWidget(MythUIType *widget=nullptr)
void Reset(void) override
Reset the widget to it's original state, should not reset changes made by the theme.
virtual void SetText(const QString &text)
virtual void Pulse(void)
Pulse is called 70 times a second to trigger a single frame of an animation.
void ReleaseCurrent()
Move head slide to back of queue and flush waiting slides.
void Initialise(MythUIImage &image)
Construct buffer.
bool Load(const ImagePtrK &im, int direction)
Assign an image to next available slide, start loading and signal when done.
void Preload(const ImagePtrK &im)
Load an image in next available slide.
void SlideReady(int count)
Signals that buffer has (count) loaded slides awaiting display.
A specialised image for slideshows.
void Pan(QPoint offset)
Initiate pan.
void Zoom(int percentage)
Initiate slide zoom.
ImagePtrK GetImageData() const
void Clear()
Reset slide to unused state.
Base class of an animated transition that can be accelerated & reversed.
virtual void Start(Slide &from, Slide &to, bool forwards, float speed=1.0)
Start base transition.
virtual void SetSpeed(float)
A datastore of images for display by a screen. Provides an ordered list of images (no dirs) from a di...
static bool LoadWindowFromXML(const QString &xmlfile, const QString &windowname, MythUIType *parent)
@ kNoInfo
Details not displayed.
@ kBasicInfo
Shows just the most useful exif tags.
@ kFullInfo
Shows all exif tags.
static QString clean_comment(const QString &comment)
ImageSlideShowType
Type of slide show.
Provides view datastores for Gallery screens.
SlideOrderType
Order of images in slideshow.
@ kSeasonal
Biased random selection so that images are more likely to appear on anniversaries.
@ kOrdered
Ordered as per user setting GallerySortOrder.
QSharedPointer< ImageItemK > ImagePtrK
MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
MythConfirmationDialog * ShowOkPopup(const QString &message, bool showCancel)
Non-blocking version of MythPopupBox::showOkPopup()
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
MythPainter * GetMythPainter(void)
MythMainWindow * GetMythMainWindow(void)
static MythThemedMenu * menu
static bool Assign(ContainerType *container, UIType *&item, const QString &name, bool *err=nullptr)
VERBOSE_PREAMBLE Most true