// ANSI C #include // POSIX #include // qt #include #include #include #include // myth #include "exitcodes.h" #include "mythcontext.h" #include "signalhandling.h" #include "questionnotice.h" int questionReturnCode; QuestionNoticeDialog::QuestionNoticeDialog(MythScreenStack *parent, const char *name) :MythScreenType(parent, name), m_title_text(NULL), m_notice_text(NULL), m_question_text(NULL) { gCoreContext->addListener(this); } bool QuestionNoticeDialog::Create(QString questionORnotice, QString title, QString displayText, QString yesButtonText, QString noButtonText) { bool foundtheme = false; // Load the theme for this screen foundtheme = LoadWindowFromXML("install-ui.xml", "questionnotice_screen", this); if (!foundtheme) return false; bool err = false; UIUtilE::Assign(this, m_title_text, "title", &err); UIUtilE::Assign(this, m_notice_text, "notice_text", &err); UIUtilE::Assign(this, m_ok_button, "ok_button", &err); UIUtilE::Assign(this, m_question_text, "question_text", &err); UIUtilE::Assign(this, m_yes_button, "yes_button", &err); UIUtilE::Assign(this, m_no_button, "no_button", &err); if (err) { LOG(VB_GENERAL, LOG_ERR, "Cannot load screen 'questionnotice_screen'"); return false; } m_title_text->SetVisible(true); m_title_text->SetText(title); //show the correct text and buttons depending on questionORnotice if (questionORnotice.contains("notice")) { m_notice_text->SetVisible(true); m_notice_text->SetText(displayText); m_ok_button->SetVisible(true); m_question_text->SetVisible(false); m_yes_button->SetVisible(false); m_no_button->SetVisible(false); } else { m_notice_text->SetVisible(false); m_ok_button->SetVisible(false); m_question_text->SetVisible(true); m_question_text->SetText(displayText); m_yes_button->SetVisible(true); m_no_button->SetVisible(true); } m_ok_button->SetText("OK"); connect(m_ok_button, SIGNAL(Clicked()), this, SLOT(okButtonClick())); m_yes_button->SetText(yesButtonText); connect(m_yes_button, SIGNAL(Clicked()), this, SLOT(yesButtonClick())); m_no_button->SetText(noButtonText); connect(m_no_button, SIGNAL(Clicked()), this, SLOT(noButtonClick())); BuildFocusList(); return true; } void QuestionNoticeDialog::okButtonClick(void) { // this makes sure the button appears to click properly QTimer::singleShot(500, this, SLOT(okButton())); } void QuestionNoticeDialog::okButton(void) { questionReturnCode = 0; Close(); } void QuestionNoticeDialog::yesButtonClick(void) { // this makes sure the button appears to click properly QTimer::singleShot(500, this, SLOT(yesButton())); } void QuestionNoticeDialog::yesButton(void) { questionReturnCode = 16; Close(); } void QuestionNoticeDialog::noButtonClick(void) { // this makes sure the button appears to click properly QTimer::singleShot(500, this, SLOT(noButton())); } void QuestionNoticeDialog::noButton(void) { questionReturnCode = 17; Close(); } QuestionNoticeDialog::~QuestionNoticeDialog() { gCoreContext->removeListener(this); }