MythTV master
mythdialogbox.cpp
Go to the documentation of this file.
1
2#include "mythdialogbox.h"
3
4#include <QCoreApplication>
5#include <QDate>
6#include <QDateTime>
7#include <QFileInfo>
8#include <QString>
9#include <QStringList>
10#include <QTime>
11#include <utility>
12
15
16#include "mythmainwindow.h"
17#include "mythfontproperties.h"
18#include "mythuiutils.h"
19#include "mythuitext.h"
20#include "mythuiimage.h"
21#include "mythuibuttonlist.h"
22#include "mythuibutton.h"
23#include "mythuistatetype.h"
24#include "mythuispinbox.h"
25#include "mythgesture.h"
26
27const QEvent::Type DialogCompletionEvent::kEventType =
28 (QEvent::Type) QEvent::registerEventType();
29
30// Force this class to have a vtable so that dynamic_cast works.
31// NOLINTNEXTLINE(modernize-use-equals-default)
33{
34}
35
36MythMenu::MythMenu(QString text, QObject *retobject, QString resultid) :
37 m_text(std::move(text)), m_resultid(std::move(resultid)), m_retObject(retobject)
38{
39 Init();
40}
41
42MythMenu::MythMenu(QString title, QString text, QObject *retobject, QString resultid) :
43 m_title(std::move(title)), m_text(std::move(text)), m_resultid(std::move(resultid)),
44 m_retObject(retobject)
45{
46 Init();
47}
48
50{
51 while (!m_menuItems.isEmpty())
52 {
53 MythMenuItem *item = m_menuItems.takeFirst();
54
55 delete item->m_subMenu;
56 delete item;
57 }
58}
59
60void MythMenu::AddItemV(const QString &title, QVariant data, MythMenu *subMenu, bool selected, bool checked)
61{
62 auto *item = new MythMenuItem(title, checked, subMenu);
63 item->SetData(std::move(data));
64 AddItem(item, selected, subMenu);
65}
66
67// For non-class, static class, or lambda functions.
68void MythMenu::AddItem(const QString &title, const MythUICallbackNMF &slot,
69 MythMenu *subMenu, bool selected, bool checked)
70{
71 auto *item = new MythMenuItem(title, slot, checked, subMenu);
72 AddItem(item, selected, subMenu);
73}
74
75void MythMenu::AddItem(MythMenuItem *item, bool selected, MythMenu *subMenu)
76{
77 m_menuItems.append(item);
78
79 if (selected)
80 m_selectedItem = m_menuItems.indexOf(item);
81
82 if (subMenu)
83 subMenu->SetParent(this);
84}
85
86void MythMenu::SetSelectedByTitle(const QString& title)
87{
88 for (auto *item : std::as_const(m_menuItems))
89 {
90 if (!item)
91 continue;
92
93 if (item->m_text == title)
94 {
95 m_selectedItem = m_menuItems.indexOf(item);
96 break;
97 }
98 }
99}
100
101void MythMenu::SetSelectedByData(const QVariant& data)
102{
103 for (auto *item : std::as_const(m_menuItems))
104 {
105 if (!item)
106 continue;
107
108 if (item->m_data == data)
109 {
110 m_selectedItem = m_menuItems.indexOf(item);
111 break;
112 }
113 }
114}
115
117
119{
120 if (m_menu)
121 {
122 delete m_menu;
123 m_menu = nullptr;
124 }
125}
126
128{
129 QString windowName = (m_fullscreen ? "MythDialogBox" : "MythPopupBox");
130
131 if (m_osdDialog)
132 {
133 if (!XMLParseBase::LoadWindowFromXML("osd.xml", windowName, this))
134 return false;
135 }
136 else if (!CopyWindowFromBase(windowName, this))
137 {
138 return false;
139 }
140
141 bool err = false;
142 if (m_fullscreen)
143 UIUtilW::Assign(this, m_titlearea, "title");
144 UIUtilE::Assign(this, m_textarea, "messagearea", &err);
145 UIUtilE::Assign(this, m_buttonList, "list", &err);
146
147 if (err)
148 {
149 LOG(VB_GENERAL, LOG_ERR, QString("Cannot load screen '%1'")
150 .arg(windowName));
151 return false;
152 }
153
154 if (m_titlearea)
157
159
160 if (m_menu)
161 updateMenu();
162
164 this, &MythDialogBox::Select);
165
166 return true;
167}
168
170{
171 m_menu = menu;
173 updateMenu();
174}
175
177{
178 if (!m_buttonList)
179 {
180 LOG(VB_GENERAL, LOG_ERR, "UpdateMenu() called before we have a button list to update!");
181 return;
182 }
183
184 if (!m_currentMenu)
185 return;
186
187 if (m_titlearea)
189
191
193
194 for (int x = 0; x < m_currentMenu->m_menuItems.count(); x++)
195 {
196 MythMenuItem *menuItem = m_currentMenu->m_menuItems.at(x);
197 auto *button = new MythUIButtonListItem(m_buttonList, menuItem->m_text);
198 button->SetData(QVariant::fromValue(menuItem));
199 button->setDrawArrow((menuItem->m_subMenu != nullptr));
200
203 }
204 // GetVisibleCount here makes sure that the dialog size is
205 // calculated correctly
208}
209
211{
212 if (!item)
213 return;
214
215 if (m_currentMenu)
216 {
217 auto *menuItem = item->GetData().value< MythMenuItem * >();
218 if (menuItem == nullptr)
219 return;
220 if (menuItem->m_subMenu)
221 {
223 m_currentMenu = menuItem->m_subMenu;
224 updateMenu();
225 return;
226 }
227
228 if (menuItem->m_useSlot)
229 {
230 const char *slot = menuItem->m_data.value < const char * >();
231 if (slot)
232 {
233 connect(this, SIGNAL(Selected()), m_currentMenu->m_retObject, slot,
234 Qt::QueuedConnection);
235 emit Selected();
236 }
237 else if (menuItem->m_data.value<MythUICallbackNMF>())
238 {
240 menuItem->m_data.value<MythUICallbackNMF>(),
241 Qt::QueuedConnection);
242 emit Selected();
243 }
244 else if (menuItem->m_data.value<MythUICallbackMF>())
245 {
247 menuItem->m_data.value<MythUICallbackMF>(),
248 Qt::QueuedConnection);
249 emit Selected();
250 }
251 else if (menuItem->m_data.value<MythUICallbackMFc>())
252 {
254 menuItem->m_data.value<MythUICallbackMFc>(),
255 Qt::QueuedConnection);
256 emit Selected();
257 }
258 }
259
260 SendEvent(m_buttonList->GetItemPos(item), item->GetText(), menuItem->m_data);
261 }
262 else
263 {
264 if (m_useSlots)
265 {
266 const char *slot = item->GetData().value<const char *>();
267 if (slot)
268 {
269 connect(this, SIGNAL(Selected()), m_retObject, slot,
270 Qt::QueuedConnection);
271 emit Selected();
272 }
273 else if (item->GetData().value<MythUICallbackNMF>())
274 {
275 connect(this, &MythDialogBox::Selected, m_retObject,
276 item->GetData().value<MythUICallbackNMF>(),
277 Qt::QueuedConnection);
278 emit Selected();
279 }
280 else if (item->GetData().value<MythUICallbackMF>())
281 {
282 connect(this, &MythDialogBox::Selected, m_retObject,
283 item->GetData().value<MythUICallbackMF>(),
284 Qt::QueuedConnection);
285 emit Selected();
286 }
287 else if (item->GetData().value<MythUICallbackMFc>())
288 {
289 connect(this, &MythDialogBox::Selected, m_retObject,
290 item->GetData().value<MythUICallbackMFc>(),
291 Qt::QueuedConnection);
292 emit Selected();
293 }
294 }
295
296 SendEvent(m_buttonList->GetItemPos(item), item->GetText(), item->GetData());
297 }
298
299 if (m_screenStack)
300 m_screenStack->PopScreen(nullptr, false);
301}
302
303void MythDialogBox::SetReturnEvent(QObject *retobject,
304 const QString &resultid)
305{
306 m_retObject = retobject;
307 m_id = resultid;
308}
309
310void MythDialogBox::SetBackAction(const QString &text, QVariant data)
311{
312 m_backtext = text;
313 m_backdata = std::move(data);
314}
315
316void MythDialogBox::SetExitAction(const QString &text, QVariant data)
317{
318 m_exittext = text;
319 m_exitdata = std::move(data);
320}
321
322void MythDialogBox::SetText(const QString &text)
323{
324 if (m_textarea)
325 m_textarea->SetText(text);
326}
327
328void MythDialogBox::AddButtonV(const QString &title, QVariant data, bool newMenu,
329 bool setCurrent)
330{
331 auto *button = new MythUIButtonListItem(m_buttonList, title);
332 button->SetData(std::move(data));
333 button->setDrawArrow(newMenu);
334
335 if (setCurrent)
337 // GetVisibleCount here makes sure that the dialog size is
338 // calculated correctly
340}
341
342bool MythDialogBox::inputMethodEvent(QInputMethodEvent *event)
343{
344 return GetFocusWidget()->inputMethodEvent(event);
345}
346
347bool MythDialogBox::keyPressEvent(QKeyEvent *event)
348{
349 if (GetFocusWidget()->keyPressEvent(event))
350 return true;
351
352 bool handled = false;
353 QStringList actions;
354 handled = GetMythMainWindow()->TranslateKeyPress("qt", event, actions);
355
356 for (int i = 0; i < actions.size() && !handled; i++)
357 {
358 const QString& action = actions[i];
359 handled = true;
360
361 if (action == "ESCAPE")
362 {
364 if (m_exitdata == 0 && m_exittext.isEmpty())
365 Close();
366 }
367 else if ((action == "LEFT" &&
369 (action == "UP" &&
371 {
373 {
375 updateMenu();
376 return true;
377 }
378
380 Close();
381 }
382 else if (action == "MENU")
383 {
384 SendEvent(-2);
385 Close();
386 }
387 else if ((action == "RIGHT" &&
389 (action == "DOWN" &&
391 {
393 }
394 else
395 {
396 handled = false;
397 }
398 }
399
400 if (!handled && MythScreenType::keyPressEvent(event))
401 handled = true;
402
403 return handled;
404}
405
407{
408 bool handled = false;
409 if (event->GetGesture() == MythGestureEvent::Click)
410 {
411 switch (event->GetButton())
412 {
413 case Qt::RightButton:
414 SendEvent(-2);
415 Close();
416 handled = true;
417 break;
418 default :
419 break;
420 }
421
422 }
423
424 if (!handled && MythScreenType::gestureEvent(event))
425 handled = true;
426
427 return handled;
428}
429
430void MythDialogBox::SendEvent(int res, const QString& text, const QVariant& data)
431{
432 if (m_currentMenu)
433 {
434 emit Closed(m_currentMenu->m_resultid, res);
435
437 return;
438
439 auto *dce = new DialogCompletionEvent(m_currentMenu->m_resultid, res, text, data);
440 QCoreApplication::postEvent(m_currentMenu->m_retObject, dce);
441 }
442 else
443 {
444 emit Closed(m_id, res);
445
446 if (!m_retObject)
447 return;
448
449 auto *dce = new DialogCompletionEvent(m_id, res, text, data);
450 QCoreApplication::postEvent(m_retObject, dce);
451 }
452}
453
455
457{
458 if (!CopyWindowFromBase("MythConfirmationDialog", this))
459 return false;
460
461 MythUIButton *okButton = nullptr;
462 MythUIButton *cancelButton = nullptr;
463
464 bool err = false;
465 UIUtilE::Assign(this, m_messageText, "message", &err);
466 UIUtilE::Assign(this, okButton, "ok", &err);
467 UIUtilE::Assign(this, cancelButton, "cancel", &err);
468
469 if (err)
470 {
471 LOG(VB_GENERAL, LOG_ERR, "Cannot load screen 'MythConfirmationDialog'");
472 return false;
473 }
474
475 if (cancelButton && m_showCancel)
476 connect(cancelButton, &MythUIButton::Clicked, this, &MythConfirmationDialog::Cancel);
477 else if (cancelButton)
478 cancelButton->SetVisible(false);
479
480 if (okButton)
481 connect(okButton, &MythUIButton::Clicked, this, &MythConfirmationDialog::Confirm);
482
484
486
487 if (m_showCancel)
488 SetFocusWidget(cancelButton);
489 else
490 SetFocusWidget(okButton);
491
492 return true;
493}
494
496{
497 if (GetFocusWidget()->keyPressEvent(event))
498 return true;
499
500 bool handled = false;
501 QStringList actions;
502 handled = GetMythMainWindow()->TranslateKeyPress("qt", event, actions);
503
504 for (int i = 0; i < actions.size() && !handled; i++)
505 {
506 const QString& action = actions[i];
507 handled = true;
508
509 if (action == "ESCAPE")
510 sendResult(false);
511 else
512 handled = false;
513 }
514
515 if (!handled && MythScreenType::keyPressEvent(event))
516 handled = true;
517
518 return handled;
519}
520
521void MythConfirmationDialog::SetMessage(const QString &message)
522{
523 m_message = message;
524 if (m_messageText)
526}
527
529 const QString &resultid)
530{
531 m_retObject = retobject;
532 m_id = resultid;
533}
534
536{
537 sendResult(true);
538}
539
541{
542 sendResult(false);
543}
544
546{
547 emit haveResult(ok);
548
549 if (m_retObject)
550 {
551 int res = 0;
552 if (ok)
553 res = 1;
554
555 auto *dce = new DialogCompletionEvent(m_id, res, "", m_resultData);
556 QCoreApplication::postEvent(m_retObject, dce);
557 m_retObject = nullptr;
558 }
559
560 Close();
561}
562
566MythConfirmationDialog *ShowOkPopup(const QString &message, bool showCancel)
567{
568 QString LOC = "ShowOkPopup('" + message + "') - ";
569 MythScreenStack *stk = nullptr;
570
572
573 if (win)
574 {
575 stk = win->GetStack("popup stack");
576 }
577 else
578 {
579 LOG(VB_GENERAL, LOG_ERR, LOC + "no main window?");
580 return nullptr;
581 }
582
583 if (!stk)
584 {
585 LOG(VB_GENERAL, LOG_ERR, LOC + "no popup stack? "
586 "Is there a MythThemeBase?");
587 return nullptr;
588 }
589
590 auto *pop = new MythConfirmationDialog(stk, message, showCancel);
591 if (pop->Create())
592 {
593 stk->AddScreen(pop);
594 }
595 else
596 {
597 delete pop;
598 pop = nullptr;
599 LOG(VB_GENERAL, LOG_ERR, LOC + "Couldn't Create() Dialog");
600 }
601
602 return pop;
603}
604
606{
607 if (!dialog)
608 return true; // No dialog is treated as user pressing OK
609
610 // Local event loop processes events whilst we wait
611 QEventLoop block;
612
613 // Quit when dialog exits
614 QObject::connect(dialog, &MythConfirmationDialog::haveResult,
615 &block, [&block](bool result)
616 { block.exit(result ? 1 : 0); });
617
618 // Block and return dialog result
619 return block.exec() != 0;
620}
621
623
625{
626 if (!CopyWindowFromBase("MythTextInputDialog", this))
627 return false;
628
629 MythUIText *messageText = nullptr;
630 MythUIButton *okButton = nullptr;
631 MythUIButton *cancelButton = nullptr;
632
633 bool err = false;
634 UIUtilE::Assign(this, m_textEdit, "input", &err);
635 UIUtilE::Assign(this, messageText, "message", &err);
636 UIUtilE::Assign(this, okButton, "ok", &err);
637 UIUtilW::Assign(this, cancelButton, "cancel");
638
639 if (err)
640 {
641 LOG(VB_GENERAL, LOG_ERR, "Cannot load screen 'MythTextInputDialog'");
642 return false;
643 }
644
645 if (cancelButton)
646 connect(cancelButton, &MythUIButton::Clicked, this, &MythScreenType::Close);
647 if (okButton)
648 connect(okButton, &MythUIButton::Clicked, this, &MythTextInputDialog::sendResult);
649
653
654 if (messageText)
655 messageText->SetText(m_message);
656
658
659 return true;
660}
661
663 const QString &resultid)
664{
665 m_retObject = retobject;
666 m_id = resultid;
667}
668
670{
671 QString inputString = m_textEdit->GetText();
672 emit haveResult(inputString);
673
674 if (m_retObject)
675 {
676 auto *dce = new DialogCompletionEvent(m_id, 0, inputString, "");
677 QCoreApplication::postEvent(m_retObject, dce);
678 }
679
680 Close();
681}
682
684
686 QString message)
687 : MythScreenType(parent, "mythspinboxpopup"),
688 m_message(std::move(message)),
689 m_id("")
690{
691}
692
694{
695 if (!CopyWindowFromBase("MythSpinBoxDialog", this))
696 return false;
697
698 MythUIText *messageText = nullptr;
699 MythUIButton *okButton = nullptr;
700 MythUIButton *cancelButton = nullptr;
701
702 bool err = false;
703 UIUtilE::Assign(this, m_spinBox, "input", &err);
704 UIUtilE::Assign(this, messageText, "message", &err);
705 UIUtilE::Assign(this, okButton, "ok", &err);
706 UIUtilW::Assign(this, cancelButton, "cancel");
707
708 if (err)
709 {
710 LOG(VB_GENERAL, LOG_ERR, "Cannot load screen 'MythSpinBoxDialog'");
711 return false;
712 }
713
714 if (cancelButton)
715 connect(cancelButton, &MythUIButton::Clicked, this, &MythScreenType::Close);
716 if (okButton)
717 connect(okButton, &MythUIButton::Clicked, this, &MythSpinBoxDialog::sendResult);
718
719 if (messageText)
720 messageText->SetText(m_message);
722
723 return true;
724}
725
730void MythSpinBoxDialog::SetRange(int low, int high, int step, uint pageMultiple)
731{
732 m_spinBox->SetRange(low, high, step, pageMultiple);
733}
734
738void MythSpinBoxDialog::AddSelection(const QString& label, int value)
739{
740 m_spinBox->AddSelection(value, label);
741}
742
747void MythSpinBoxDialog::SetValue (const QString & value)
748{
749 m_spinBox->SetValue(value);
750}
751
756{
757 m_spinBox->SetValue(value);
758}
759
760void MythSpinBoxDialog::SetReturnEvent(QObject *retobject,
761 const QString &resultid)
762{
763 m_retObject = retobject;
764 m_id = resultid;
765}
766
768{
769 QString inputString = m_spinBox->GetValue();
770 emit haveResult(inputString);
771
772 if (m_retObject)
773 {
774 auto *dce = new DialogCompletionEvent(m_id, 0, inputString, "");
775 QCoreApplication::postEvent(m_retObject, dce);
776 }
777
778 Close();
779}
780
782
784{
785 if (!CopyWindowFromBase("MythSearchDialog", this))
786 return false;
787
788 MythUIButton *okButton = nullptr;
789 MythUIButton *cancelButton = nullptr;
790
791 bool err = false;
792 UIUtilE::Assign(this, m_textEdit, "input", &err);
793 UIUtilE::Assign(this, m_titleText, "title", &err);
794 UIUtilW::Assign(this, m_matchesText, "matches");
795 UIUtilE::Assign(this, m_itemList, "itemlist", &err);
796 UIUtilE::Assign(this, okButton, "ok", &err);
797 UIUtilW::Assign(this, cancelButton, "cancel");
798
799 if (err)
800 {
801 LOG(VB_GENERAL, LOG_ERR, "Cannot load screen 'MythSearchDialog'");
802 return false;
803 }
804
805 if (cancelButton)
806 connect(cancelButton, &MythUIButton::Clicked, this, &MythScreenType::Close);
807
808 if (okButton)
810
813
816
818 if (m_matchesText)
819 m_matchesText->SetText(tr("%n match(es)", "", 0));
820
822
824
825 return true;
826}
827
829 const QString &resultid)
830{
831 m_retObject = retobject;
832 m_id = resultid;
833}
834
836{
838 return;
839
840 QString result = m_itemList->GetValue();
841
842 emit haveResult(result);
843
844 if (m_retObject)
845 {
846 auto *dce = new DialogCompletionEvent(m_id, 0, result, "");
847 QCoreApplication::postEvent(m_retObject, dce);
848 }
849
850 Close();
851}
852
854{
855 m_itemList->Reset();
856
857 for (const QString& item : std::as_const(m_list))
858 {
859 if (m_matchAnywhere)
860 {
861 if (!item.contains(m_textEdit->GetText(), Qt::CaseInsensitive))
862 continue;
863 }
864 else
865 {
866 if (!item.startsWith(m_textEdit->GetText(), Qt::CaseInsensitive))
867 continue;
868 }
869
870 // add item to list
871 new MythUIButtonListItem(m_itemList, item, nullptr, false);
872 }
873
875
876 if (m_matchesText)
877 m_matchesText->SetText(tr("%n match(es)", "", 0));
878}
879
881
883 QString message,
884 int resolutionFlags,
885 QDateTime startTime,
886 int rangeLimit)
887 : MythScreenType(parent, "timepopup"),
888 m_message(std::move(message)), m_startTime(std::move(startTime)),
889 m_resolution(resolutionFlags), m_rangeLimit(rangeLimit)
890{
891}
892
894{
895 if (!CopyWindowFromBase("MythTimeInputDialog", this))
896 return false;
897
898 MythUIText *messageText = nullptr;
899 MythUIButton *okButton = nullptr;
900
901 bool err = false;
902 UIUtilE::Assign(this, messageText, "message", &err);
903 UIUtilE::Assign(this, m_dateList, "dates", &err);
904 UIUtilE::Assign(this, m_timeList, "times", &err);
905 UIUtilE::Assign(this, okButton, "ok", &err);
906
907 if (err)
908 {
909 LOG(VB_GENERAL, LOG_ERR, "Cannot load screen 'MythTimeInputDialog'");
910 return false;
911 }
912
913 m_dateList->SetVisible(false);
914 m_timeList->SetVisible(false);
915
916 // Date
917 if (kNoDate != (m_resolution & 0xF))
918 {
919 const QDate startdate(m_startTime.toLocalTime().date());
920 QDate date(startdate);
921
922 int limit = 0;
924 {
925 limit += m_rangeLimit;
926 }
928 {
929 limit += m_rangeLimit;
930 date = date.addDays(0-m_rangeLimit);
931 }
932
933 QString text;
934 bool selected = false;
935 for (int x = 0; x <= limit; x++)
936 {
937 selected = false;
938 if (m_resolution & kDay)
939 {
940 date = date.addDays(1);
942 if (m_rangeLimit >= 356)
943 flags |= MythDate::kAddYear;
944 text = MythDate::toString(date, flags);
945
946 if (date == startdate)
947 selected = true;
948 }
949 else if (m_resolution & kMonth)
950 {
951 date = date.addMonths(1);
952 text = date.toString("MMM yyyy");
953
954 if ((date.month() == startdate.month()) &&
955 (date.year() == startdate.year()))
956 selected = true;
957 }
958 else if (m_resolution & kYear)
959 {
960 date = date.addYears(1);
961 text = date.toString("yyyy");
962 if (date.year() == startdate.year())
963 selected = true;
964 }
965
966 auto *item = new MythUIButtonListItem(m_dateList, text, nullptr, false);
967 item->SetData(QVariant(date));
968
969 if (selected)
971 }
972 m_dateList->SetVisible(true);
973 }
974
975 // Time
976 if (kNoTime != (m_resolution & 0xF0))
977 {
978 QDate startdate(m_startTime.toLocalTime().date());
979 QTime starttime(m_startTime.toLocalTime().time());
980 QTime time(0,0,0);
981 QString text;
982 bool selected = false;
983
984 int limit = (m_resolution & kMinutes) ? (60 * 24) : 24;
985
986 for (int x = 0; x < limit; x++)
987 {
988 selected = false;
990 {
991 time = time.addSecs(60);
992#if QT_VERSION < QT_VERSION_CHECK(6,5,0)
993 QDateTime dt = QDateTime(startdate, time, Qt::LocalTime);
994#else
995 QDateTime dt = QDateTime(startdate, time,
996 QTimeZone(QTimeZone::LocalTime));
997#endif
999
1000 if (time == starttime)
1001 selected = true;
1002 }
1003 else if (m_resolution & kHours)
1004 {
1005 time = time.addSecs(60*60);
1006 text = time.toString("hh:00");
1007
1008 if (time.hour() == starttime.hour())
1009 selected = true;
1010 }
1011
1012 auto *item = new MythUIButtonListItem(m_timeList, text, nullptr, false);
1013 item->SetData(QVariant(time));
1014
1015 if (selected)
1017 }
1018 m_timeList->SetVisible(true);
1019 }
1020
1021 if (messageText && !m_message.isEmpty())
1022 messageText->SetText(m_message);
1023
1024 if (okButton)
1025 connect(okButton, &MythUIButton::Clicked, this, &MythTimeInputDialog::okClicked);
1026
1028
1029 return true;
1030}
1031
1033 const QString& resultid)
1034{
1035 m_retObject = retobject;
1036 m_id = resultid;
1037}
1038
1040{
1041 QDate date = m_dateList->GetDataValue().toDate();
1042 QTime time = m_timeList->GetDataValue().toTime();
1043
1044#if QT_VERSION < QT_VERSION_CHECK(6,5,0)
1045 QDateTime dateTime = QDateTime(date, time, Qt::LocalTime).toUTC();
1046#else
1047 QDateTime dateTime = QDateTime(date, time,
1048 QTimeZone(QTimeZone::LocalTime)).toUTC();
1049#endif
1050
1051 emit haveResult(dateTime);
1052
1053 if (m_retObject)
1054 {
1055 QVariant data(dateTime);
1056 auto *dce = new DialogCompletionEvent(m_id, 0, "", data);
1057 QCoreApplication::postEvent(m_retObject, dce);
1058 }
1059
1060 Close();
1061}
Event dispatched from MythUI modal dialogs to a listening class containing a result of some form.
Definition: mythdialogbox.h:40
~DialogCompletionEvent() override
static const Type kEventType
Definition: mythdialogbox.h:55
Dialog asking for user confirmation.
bool keyPressEvent(QKeyEvent *event) override
Key event handler.
MythUIText * m_messageText
bool Create(void) override
void SetMessage(const QString &message)
void SetReturnEvent(QObject *retobject, const QString &resultid)
~MythDialogBox(void) override
void SetBackAction(const QString &text, QVariant data)
QString m_backtext
QVariant m_exitdata
MythUIButtonList * m_buttonList
void SetExitAction(const QString &text, QVariant data)
bool gestureEvent(MythGestureEvent *event) override
Mouse click/movement handler, receives mouse gesture events from the QCoreApplication event loop.
MythUIText * m_textarea
MythMenu * m_currentMenu
QVariant m_backdata
void SendEvent(int res, const QString &text="", const QVariant &data=0)
void Select(MythUIButtonListItem *item)
void SetReturnEvent(QObject *retobject, const QString &resultid)
QString m_exittext
MythMenu * m_menu
void updateMenu(void)
void AddButtonV(const QString &title, QVariant data=0, bool newMenu=false, bool setCurrent=false)
void SetText(const QString &text)
MythUIText * m_titlearea
void SetMenuItems(MythMenu *menu)
QObject * m_retObject
void Closed(QString, int)
bool Create(void) override
bool keyPressEvent(QKeyEvent *event) override
Key event handler.
bool inputMethodEvent(QInputMethodEvent *event) override
Input Method event handler.
A custom event that represents a mouse gesture.
Definition: mythgesture.h:40
Gesture GetGesture() const
Definition: mythgesture.h:85
Qt::MouseButton GetButton() const
Definition: mythgesture.h:88
MythScreenStack * GetMainStack()
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)
MythMenu * m_subMenu
Definition: mythdialogbox.h:90
QString m_text
Definition: mythdialogbox.h:87
void SetSelectedByTitle(const QString &title)
QString m_title
MythMenu(QString text, QObject *retobject, QString resultid)
void AddItemV(const QString &title, QVariant data=0, MythMenu *subMenu=nullptr, bool selected=false, bool checked=false)
~MythMenu(void)
void SetSelectedByData(const QVariant &data)
MythMenu * m_parentMenu
int m_selectedItem
void Init(void)
void AddItem(const QString &title)
QString m_text
void SetParent(MythMenu *parent)
QList< MythMenuItem * > m_menuItems
QString m_resultid
QObject * m_retObject
virtual void PopScreen(MythScreenType *screen=nullptr, bool allowFade=true, bool deleteScreen=true)
virtual void AddScreen(MythScreenType *screen, bool allowFade=true)
virtual MythScreenType * GetTopScreen(void) const
Screen in which all other widgets are contained and rendered.
bool gestureEvent(MythGestureEvent *event) override
Mouse click/movement handler, receives mouse gesture events from the QCoreApplication event loop.
MythScreenStack * m_screenStack
void BuildFocusList(void)
MythUIType * GetFocusWidget(void) const
bool keyPressEvent(QKeyEvent *event) override
Key event handler.
bool SetFocusWidget(MythUIType *widget=nullptr)
virtual void Close()
void haveResult(QString)
QObject * m_retObject
void SetReturnEvent(QObject *retobject, const QString &resultid)
void AddSelection(const QString &label, int value)
MythUISpinBox * m_spinBox
void SetValue(const QString &value)
Can be called only after MythSpinBoxDialog::Create() return successfully The range need to be set bef...
bool Create(void) override
void SetRange(int low, int high, int step, uint pageMultiple=5)
Set the lower and upper bounds of the spinbox, the interval and page amount.
MythSpinBoxDialog(MythScreenStack *parent, QString message)
bool Create(void) override
InputFilter m_filter
void haveResult(QString)
void SetReturnEvent(QObject *retobject, const QString &resultid)
MythUITextEdit * m_textEdit
MythUIButtonList * m_timeList
void SetReturnEvent(QObject *retobject, const QString &resultid)
MythTimeInputDialog(MythScreenStack *parent, QString message, int resolutionFlags, QDateTime startTime=QDateTime::currentDateTime(), int rangeLimit=14)
MythUIButtonList * m_dateList
bool Create() override
void haveResult(QDateTime time)
QString GetText(const QString &name="") const
virtual QString GetValue() const
MythUIButtonListItem * GetItemCurrent() const
void SetItemCurrent(MythUIButtonListItem *item)
void Reset() override
Reset the widget to it's original state, should not reset changes made by the theme.
int GetItemPos(MythUIButtonListItem *item) const
int GetCurrentPos() const
void itemClicked(MythUIButtonListItem *item)
QVariant GetDataValue() const
LayoutType GetLayout() const
A single button widget.
Definition: mythuibutton.h:22
void Clicked()
MythUITextEdit * m_textEdit
void slotUpdateList(void)
void SetReturnEvent(QObject *retobject, const QString &resultid)
MythUIText * m_matchesText
void slotSendResult(void)
QStringList m_list
MythUIButtonList * m_itemList
MythUIText * m_titleText
void haveResult(QString)
bool Create(void) override
void SetRange(int low, int high, int step, uint pageMultiple=5)
Set the lower and upper bounds of the spinbox, the interval and page amount.
void SetValue(int val) override
Definition: mythuispinbox.h:28
void AddSelection(int value, const QString &label="")
Add a special label for a value of the spinbox, it does not need to be in the range.
QString GetValue(void) const override
Definition: mythuispinbox.h:33
void SetPassword(bool isPassword)
QString GetText(void) const
void SetText(const QString &text, bool moveCursor=true)
void SetFilter(InputFilter filter)
void valueChanged()
All purpose text widget, displays a text string.
Definition: mythuitext.h:29
virtual void SetText(const QString &text)
Definition: mythuitext.cpp:115
virtual void SetVisible(bool visible)
void SetRedraw(void)
Definition: mythuitype.cpp:299
virtual bool inputMethodEvent(QInputMethodEvent *event)
Input Method event handler.
Definition: mythuitype.cpp:984
static bool LoadWindowFromXML(const QString &xmlfile, const QString &windowname, MythUIType *parent)
static bool CopyWindowFromBase(const QString &windowname, MythScreenType *win)
unsigned int uint
Definition: compat.h:60
#define LOC
Definition: mythcontext.cpp:75
MythConfirmationDialog * ShowOkPopup(const QString &message, bool showCancel)
Non-blocking version of MythPopupBox::showOkPopup()
bool WaitFor(MythConfirmationDialog *dialog)
Blocks until confirmation dialog exits.
A C++ ripoff of the stroke library for MythTV.
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
Definition: mythlogging.h:39
MythMainWindow * GetMythMainWindow(void)
static MythThemedMenu * menu
void(QObject::*)(void) const MythUICallbackMFc
Definition: mythuitype.h:45
void(QObject::*)(void) MythUICallbackMF
Definition: mythuitype.h:44
std::function< void(void)> MythUICallbackNMF
Definition: mythuitype.h:42
QString toString(const QDateTime &raw_dt, uint format)
Returns formatted string representing the time.
Definition: mythdate.cpp:93
@ kSimplify
Do Today/Yesterday/Tomorrow transform.
Definition: mythdate.h:26
@ kDateFull
Default local time.
Definition: mythdate.h:19
@ kTime
Default local time.
Definition: mythdate.h:22
@ kAddYear
Add year to string if not included.
Definition: mythdate.h:25
static bool Assign(ContainerType *container, UIType *&item, const QString &name, bool *err=nullptr)
Definition: mythuiutils.h:27