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 stk = win->GetStack("popup stack");
575 else
576 {
577 LOG(VB_GENERAL, LOG_ERR, LOC + "no main window?");
578 return nullptr;
579 }
580
581 if (!stk)
582 {
583 LOG(VB_GENERAL, LOG_ERR, LOC + "no popup stack? "
584 "Is there a MythThemeBase?");
585 return nullptr;
586 }
587
588 auto *pop = new MythConfirmationDialog(stk, message, showCancel);
589 if (pop->Create())
590 {
591 stk->AddScreen(pop);
592 }
593 else
594 {
595 delete pop;
596 pop = nullptr;
597 LOG(VB_GENERAL, LOG_ERR, LOC + "Couldn't Create() Dialog");
598 }
599
600 return pop;
601}
602
604{
605 if (!dialog)
606 return true; // No dialog is treated as user pressing OK
607
608 // Local event loop processes events whilst we wait
609 QEventLoop block;
610
611 // Quit when dialog exits
612 QObject::connect(dialog, &MythConfirmationDialog::haveResult,
613 &block, [&block](bool result)
614 { block.exit(result ? 1 : 0); });
615
616 // Block and return dialog result
617 return block.exec() != 0;
618}
619
621
623{
624 if (!CopyWindowFromBase("MythTextInputDialog", this))
625 return false;
626
627 MythUIText *messageText = nullptr;
628 MythUIButton *okButton = nullptr;
629 MythUIButton *cancelButton = nullptr;
630
631 bool err = false;
632 UIUtilE::Assign(this, m_textEdit, "input", &err);
633 UIUtilE::Assign(this, messageText, "message", &err);
634 UIUtilE::Assign(this, okButton, "ok", &err);
635 UIUtilW::Assign(this, cancelButton, "cancel");
636
637 if (err)
638 {
639 LOG(VB_GENERAL, LOG_ERR, "Cannot load screen 'MythTextInputDialog'");
640 return false;
641 }
642
643 if (cancelButton)
644 connect(cancelButton, &MythUIButton::Clicked, this, &MythScreenType::Close);
645 if (okButton)
646 connect(okButton, &MythUIButton::Clicked, this, &MythTextInputDialog::sendResult);
647
651
652 if (messageText)
653 messageText->SetText(m_message);
654
656
657 return true;
658}
659
661 const QString &resultid)
662{
663 m_retObject = retobject;
664 m_id = resultid;
665}
666
668{
669 QString inputString = m_textEdit->GetText();
670 emit haveResult(inputString);
671
672 if (m_retObject)
673 {
674 auto *dce = new DialogCompletionEvent(m_id, 0, inputString, "");
675 QCoreApplication::postEvent(m_retObject, dce);
676 }
677
678 Close();
679}
680
682
684 QString message)
685 : MythScreenType(parent, "mythspinboxpopup"),
686 m_message(std::move(message)),
687 m_id("")
688{
689}
690
692{
693 if (!CopyWindowFromBase("MythSpinBoxDialog", this))
694 return false;
695
696 MythUIText *messageText = nullptr;
697 MythUIButton *okButton = nullptr;
698 MythUIButton *cancelButton = nullptr;
699
700 bool err = false;
701 UIUtilE::Assign(this, m_spinBox, "input", &err);
702 UIUtilE::Assign(this, messageText, "message", &err);
703 UIUtilE::Assign(this, okButton, "ok", &err);
704 UIUtilW::Assign(this, cancelButton, "cancel");
705
706 if (err)
707 {
708 LOG(VB_GENERAL, LOG_ERR, "Cannot load screen 'MythSpinBoxDialog'");
709 return false;
710 }
711
712 if (cancelButton)
713 connect(cancelButton, &MythUIButton::Clicked, this, &MythScreenType::Close);
714 if (okButton)
715 connect(okButton, &MythUIButton::Clicked, this, &MythSpinBoxDialog::sendResult);
716
717 if (messageText)
718 messageText->SetText(m_message);
720
721 return true;
722}
723
728void MythSpinBoxDialog::SetRange(int low, int high, int step, uint pageMultiple)
729{
730 m_spinBox->SetRange(low, high, step, pageMultiple);
731}
732
736void MythSpinBoxDialog::AddSelection(const QString& label, int value)
737{
738 m_spinBox->AddSelection(value, label);
739}
740
745void MythSpinBoxDialog::SetValue (const QString & value)
746{
747 m_spinBox->SetValue(value);
748}
749
754{
755 m_spinBox->SetValue(value);
756}
757
758void MythSpinBoxDialog::SetReturnEvent(QObject *retobject,
759 const QString &resultid)
760{
761 m_retObject = retobject;
762 m_id = resultid;
763}
764
766{
767 QString inputString = m_spinBox->GetValue();
768 emit haveResult(inputString);
769
770 if (m_retObject)
771 {
772 auto *dce = new DialogCompletionEvent(m_id, 0, inputString, "");
773 QCoreApplication::postEvent(m_retObject, dce);
774 }
775
776 Close();
777}
778
780
782{
783 if (!CopyWindowFromBase("MythSearchDialog", this))
784 return false;
785
786 MythUIButton *okButton = nullptr;
787 MythUIButton *cancelButton = nullptr;
788
789 bool err = false;
790 UIUtilE::Assign(this, m_textEdit, "input", &err);
791 UIUtilE::Assign(this, m_titleText, "title", &err);
792 UIUtilW::Assign(this, m_matchesText, "matches");
793 UIUtilE::Assign(this, m_itemList, "itemlist", &err);
794 UIUtilE::Assign(this, okButton, "ok", &err);
795 UIUtilW::Assign(this, cancelButton, "cancel");
796
797 if (err)
798 {
799 LOG(VB_GENERAL, LOG_ERR, "Cannot load screen 'MythSearchDialog'");
800 return false;
801 }
802
803 if (cancelButton)
804 connect(cancelButton, &MythUIButton::Clicked, this, &MythScreenType::Close);
805
806 if (okButton)
808
811
814
816 if (m_matchesText)
817 m_matchesText->SetText(tr("%n match(es)", "", 0));
818
820
822
823 return true;
824}
825
827 const QString &resultid)
828{
829 m_retObject = retobject;
830 m_id = resultid;
831}
832
834{
836 return;
837
838 QString result = m_itemList->GetValue();
839
840 emit haveResult(result);
841
842 if (m_retObject)
843 {
844 auto *dce = new DialogCompletionEvent(m_id, 0, result, "");
845 QCoreApplication::postEvent(m_retObject, dce);
846 }
847
848 Close();
849}
850
852{
853 m_itemList->Reset();
854
855 for (const QString& item : std::as_const(m_list))
856 {
857 if (m_matchAnywhere)
858 {
859 if (!item.contains(m_textEdit->GetText(), Qt::CaseInsensitive))
860 continue;
861 }
862 else
863 {
864 if (!item.startsWith(m_textEdit->GetText(), Qt::CaseInsensitive))
865 continue;
866 }
867
868 // add item to list
869 new MythUIButtonListItem(m_itemList, item, nullptr, false);
870 }
871
873
874 if (m_matchesText)
875 m_matchesText->SetText(tr("%n match(es)", "", 0));
876}
877
879
881 QString message,
882 int resolutionFlags,
883 QDateTime startTime,
884 int rangeLimit)
885 : MythScreenType(parent, "timepopup"),
886 m_message(std::move(message)), m_startTime(std::move(startTime)),
887 m_resolution(resolutionFlags), m_rangeLimit(rangeLimit)
888{
889}
890
892{
893 if (!CopyWindowFromBase("MythTimeInputDialog", this))
894 return false;
895
896 MythUIText *messageText = nullptr;
897 MythUIButton *okButton = nullptr;
898
899 bool err = false;
900 UIUtilE::Assign(this, messageText, "message", &err);
901 UIUtilE::Assign(this, m_dateList, "dates", &err);
902 UIUtilE::Assign(this, m_timeList, "times", &err);
903 UIUtilE::Assign(this, okButton, "ok", &err);
904
905 if (err)
906 {
907 LOG(VB_GENERAL, LOG_ERR, "Cannot load screen 'MythTimeInputDialog'");
908 return false;
909 }
910
911 m_dateList->SetVisible(false);
912 m_timeList->SetVisible(false);
913
914 // Date
915 if (kNoDate != (m_resolution & 0xF))
916 {
917 const QDate startdate(m_startTime.toLocalTime().date());
918 QDate date(startdate);
919
920 int limit = 0;
922 {
923 limit += m_rangeLimit;
924 }
926 {
927 limit += m_rangeLimit;
928 date = date.addDays(0-m_rangeLimit);
929 }
930
931 QString text;
932 bool selected = false;
933 for (int x = 0; x <= limit; x++)
934 {
935 selected = false;
936 if (m_resolution & kDay)
937 {
938 date = date.addDays(1);
940 if (m_rangeLimit >= 356)
941 flags |= MythDate::kAddYear;
942 text = MythDate::toString(date, flags);
943
944 if (date == startdate)
945 selected = true;
946 }
947 else if (m_resolution & kMonth)
948 {
949 date = date.addMonths(1);
950 text = date.toString("MMM yyyy");
951
952 if ((date.month() == startdate.month()) &&
953 (date.year() == startdate.year()))
954 selected = true;
955 }
956 else if (m_resolution & kYear)
957 {
958 date = date.addYears(1);
959 text = date.toString("yyyy");
960 if (date.year() == startdate.year())
961 selected = true;
962 }
963
964 auto *item = new MythUIButtonListItem(m_dateList, text, nullptr, false);
965 item->SetData(QVariant(date));
966
967 if (selected)
969 }
970 m_dateList->SetVisible(true);
971 }
972
973 // Time
974 if (kNoTime != (m_resolution & 0xF0))
975 {
976 QDate startdate(m_startTime.toLocalTime().date());
977 QTime starttime(m_startTime.toLocalTime().time());
978 QTime time(0,0,0);
979 QString text;
980 bool selected = false;
981
982 int limit = (m_resolution & kMinutes) ? (60 * 24) : 24;
983
984 for (int x = 0; x < limit; x++)
985 {
986 selected = false;
988 {
989 time = time.addSecs(60);
990#if QT_VERSION < QT_VERSION_CHECK(6,5,0)
991 QDateTime dt = QDateTime(startdate, time, Qt::LocalTime);
992#else
993 QDateTime dt = QDateTime(startdate, time,
994 QTimeZone(QTimeZone::LocalTime));
995#endif
997
998 if (time == starttime)
999 selected = true;
1000 }
1001 else if (m_resolution & kHours)
1002 {
1003 time = time.addSecs(60*60);
1004 text = time.toString("hh:00");
1005
1006 if (time.hour() == starttime.hour())
1007 selected = true;
1008 }
1009
1010 auto *item = new MythUIButtonListItem(m_timeList, text, nullptr, false);
1011 item->SetData(QVariant(time));
1012
1013 if (selected)
1015 }
1016 m_timeList->SetVisible(true);
1017 }
1018
1019 if (messageText && !m_message.isEmpty())
1020 messageText->SetText(m_message);
1021
1022 if (okButton)
1023 connect(okButton, &MythUIButton::Clicked, this, &MythTimeInputDialog::okClicked);
1024
1026
1027 return true;
1028}
1029
1031 const QString& resultid)
1032{
1033 m_retObject = retobject;
1034 m_id = resultid;
1035}
1036
1038{
1039 QDate date = m_dateList->GetDataValue().toDate();
1040 QTime time = m_timeList->GetDataValue().toTime();
1041
1042#if QT_VERSION < QT_VERSION_CHECK(6,5,0)
1043 QDateTime dateTime = QDateTime(date, time, Qt::LocalTime).toUTC();
1044#else
1045 QDateTime dateTime = QDateTime(date, time,
1046 QTimeZone(QTimeZone::LocalTime)).toUTC();
1047#endif
1048
1049 emit haveResult(dateTime);
1050
1051 if (m_retObject)
1052 {
1053 QVariant data(dateTime);
1054 auto *dce = new DialogCompletionEvent(m_id, 0, "", data);
1055 QCoreApplication::postEvent(m_retObject, dce);
1056 }
1057
1058 Close();
1059}
#define LOC
Event dispatched from MythUI modal dialogs to a listening class containing a result of some form.
Definition: mythdialogbox.h:41
~DialogCompletionEvent() override
static const Type kEventType
Definition: mythdialogbox.h:56
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:91
QString m_text
Definition: mythdialogbox.h:88
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:32
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:37
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:313
virtual bool inputMethodEvent(QInputMethodEvent *event)
Input Method event handler.
Definition: mythuitype.cpp:998
static bool LoadWindowFromXML(const QString &xmlfile, const QString &windowname, MythUIType *parent)
static bool CopyWindowFromBase(const QString &windowname, MythScreenType *win)
unsigned int uint
Definition: freesurround.h:24
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
STL namespace.
static bool Assign(ContainerType *container, UIType *&item, const QString &name, bool *err=nullptr)
Definition: mythuiutils.h:27