#include "favoritenamepopup.h" #include "ui_favoritenamepopup.h" #include "primewindow.h" FavoriteNamePopup::FavoriteNamePopup(QWidget *parent) : QWidget(parent), ui(new Ui::FavoriteNamePopup) { ui->setupUi(this); ui->lineEdit->setFocus(); ui->lineEdit->selectAll(); } FavoriteNamePopup::FavoriteNamePopup(QWidget *parent, ManualCookSetting setting) : FavoriteNamePopup(parent) { type = Manual; manualSetting = setting; } FavoriteNamePopup::FavoriteNamePopup(QWidget *parent, AutoCookSetting setting) : FavoriteNamePopup(parent) { type = Auto; autoSetting = setting; } FavoriteNamePopup::~FavoriteNamePopup() { delete ui; } void FavoriteNamePopup::ok() { int id; switch (type) { case Manual: id = CookHistory::addFavorite(manualSetting, ui->lineEdit->text()); break; case Auto: id = CookHistory::addFavorite(autoSetting, ui->lineEdit->text()); break; default: return; } PrimeWindow *w = new PrimeWindow(parentWidget()); w->setWindowModality(Qt::WindowModal); w->listFavorites(); w->focusFavorite(id); w->showFullScreen(); w->raise(); deleteLater(); } void FavoriteNamePopup::cancel() { deleteLater(); } void FavoriteNamePopup::on_okButton_clicked() { ok(); } void FavoriteNamePopup::on_cancelButton_clicked() { cancel(); }