SGPopupResult StorageGroupPopup::showPopup(MythMainWindow *parent, QString title, QString message, QString& text) { MythPopupBox *popup = new MythPopupBox(parent, title.toAscii().constData()); popup->addLabel(message); MythLineEdit *textEdit = new MythLineEdit(popup, "chooseEdit"); textEdit->setText(text); popup->addWidget(textEdit); popup->addButton(QObject::tr("OK"), popup, SLOT(accept())); popup->addButton(QObject::tr("Cancel"), popup, SLOT(reject())); textEdit->setFocus(); bool ok = (MythDialog::Accepted == popup->ExecPopup()); if (ok) { text = textEdit->text(); text.detach(); } popup->hide(); popup->deleteLater(); return (ok) ? SGPopup_OK : SGPopup_CANCEL; }
bool UIListBtnType::incSearchStart(void) { MythPopupBox *popup = new MythPopupBox(GetMythMainWindow(), "incserach_popup"); QLabel *caption = popup->addLabel(tr("Search"), MythPopupBox::Large); caption->setAlignment(Qt::AlignCenter); MythComboBox *modeCombo = new MythComboBox(false, popup, "mode_combo" ); modeCombo->insertItem(tr("Starts with text")); modeCombo->insertItem(tr("Contains text")); popup->addWidget(modeCombo); MythLineEdit *searchEdit = new MythLineEdit(false, popup, "mode_combo"); searchEdit->setText(m_incSearch); popup->addWidget(searchEdit); searchEdit->setFocus(); popup->addButton(tr("Search")); popup->addButton(tr("Cancel"), popup, SLOT(reject())); DialogCode res = popup->ExecPopup(); if (kDialogCodeButton0 == res) { m_incSearch = searchEdit->text(); m_bIncSearchContains = (modeCombo->currentIndex() == 1); incSearchNext(); } popup->hide(); popup->deleteLater(); return (kDialogCodeButton0 == res); }
void VirtualKeyboardQt::SwitchLayout(const QString &lang) { if (!m_parentEdit) { VERBOSE(VB_IMPORTANT, LOC_ERR + "No edit receiving output"); reject(); return; } QString language = lang.toLower(); QString theme_file = QString("keyboard/%1_").arg(language); if (!loadThemedWindow("keyboard", theme_file)) { VERBOSE(VB_GENERAL, LOC_WARN + QString("Cannot find layout for '%1'").arg(language)); // cannot find layout so fallback to US English layout if (!loadThemedWindow("keyboard", "keyboard/en_us_")) { VERBOSE(VB_IMPORTANT, LOC_ERR + "Cannot find layout for US English"); reject(); return; } } // get dialog size from keyboard_container area LayerSet *container = getContainer("keyboard_container"); if (!container) { VERBOSE(VB_IMPORTANT, LOC_ERR + "Cannot find the 'keyboard_container' in your theme"); reject(); return; } m_popupWidth = container->GetAreaRect().width(); m_popupHeight = container->GetAreaRect().height(); setFixedSize(QSize(m_popupWidth, m_popupHeight)); QWidget *pw = m_parentEdit; QWidget *tlw = pw->topLevelWidget(); QRect pwg = pw->geometry(); QRect tlwg = tlw->frameGeometry(); QPoint newpos; PopupPositionQt preferredPos; if (m_parentEdit->inherits("MythLineEdit")) { MythLineEdit *par = (MythLineEdit *)m_parentEdit; preferredPos = par->getPopupPosition(); } else if (m_parentEdit->inherits("MythRemoteLineEdit")) { MythRemoteLineEdit *par = (MythRemoteLineEdit *)m_parentEdit; preferredPos = par->getPopupPosition(); } else if (m_parentEdit->inherits("MythComboBox")) { MythComboBox *par = (MythComboBox *)m_parentEdit; preferredPos = par->getPopupPosition(); } else { preferredPos = VKQT_POSCENTERDIALOG; } if (preferredPos == VKQT_POSBELOWEDIT) { if (pw->mapTo(tlw, QPoint(0,pwg.height() + m_popupHeight + 5)).y() < tlwg.height()) { newpos = QPoint(pwg.width() / 2 - m_popupWidth / 2, pwg.height() + 5); } else { newpos = QPoint(pwg.width() / 2 - m_popupWidth / 2, - 5 - m_popupHeight); } } else if (preferredPos == VKQT_POSABOVEEDIT) { if (pw->mapTo(tlw, QPoint(0, - m_popupHeight - 5)).y() > 0) { newpos = QPoint(pwg.width() / 2 - m_popupWidth / 2, - 5 - m_popupHeight); } else { newpos = QPoint(pwg.width() / 2 - m_popupWidth / 2, pwg.height() + 5); } } else if (preferredPos == VKQT_POSTOPDIALOG) { newpos = QPoint(tlwg.width() / 2 - m_popupWidth / 2, 5); this->move(newpos); } else if (preferredPos == VKQT_POSBOTTOMDIALOG) { newpos = QPoint(tlwg.width() / 2 - m_popupWidth / 2, tlwg.height() - 5 - m_popupHeight); this->move(newpos); } else if (preferredPos == VKQT_POSCENTERDIALOG) { newpos = QPoint(tlwg.width() / 2 - m_popupWidth / 2, tlwg.height() / 2 - m_popupHeight / 2); this->move(newpos); } if (preferredPos == VKQT_POSABOVEEDIT || preferredPos == VKQT_POSBELOWEDIT) { int delx = pw->mapTo(tlw,newpos).x() + m_popupWidth - tlwg.width() + 5; newpos = QPoint(newpos.x() - (delx > 0 ? delx : 0), newpos.y()); delx = pw->mapTo(tlw, newpos).x(); newpos = QPoint(newpos.x() - (delx < 0 ? delx : 0), newpos.y()); int xbase, width, ybase, height; float wmult, hmult; GetMythUI()->GetScreenSettings(xbase, width, wmult, ybase, height, hmult); newpos.setX(newpos.x() - xbase); newpos.setY(newpos.y() - ybase); this->move( pw->mapToGlobal( newpos ) ); } // find the UIKeyboardType m_keyboard = getUIKeyboardType("keyboard"); if (!m_keyboard) { VERBOSE(VB_IMPORTANT, LOC_ERR + "Cannot find the UIKeyboardType in your theme"); reject(); return; } if (m_parentEdit->inherits("QComboBox")) { QComboBox *combo = (QComboBox *) m_parentEdit; m_keyboard->SetEdit(combo->lineEdit()); } else m_keyboard->SetEdit(m_parentEdit); m_keyboard->SetParentDialog(this); }