Qt: use yes/no buttons for question dialogs to allow canceling even if checkbox is clicked, return checkbox status separately from yes/no buttons
This commit is contained in:
parent
2a68b6e691
commit
50b23d6572
|
@ -121,6 +121,8 @@ static double expScale(double inputValue, double midValue, double maxValue)
|
||||||
#ifdef HAVE_LIBRETRODB
|
#ifdef HAVE_LIBRETRODB
|
||||||
static void scan_finished_handler(void *task_data, void *user_data, const char *err)
|
static void scan_finished_handler(void *task_data, void *user_data, const char *err)
|
||||||
{
|
{
|
||||||
|
bool dontAsk = false;
|
||||||
|
bool answer = false;
|
||||||
menu_ctx_environment_t menu_environ;
|
menu_ctx_environment_t menu_environ;
|
||||||
menu_environ.type = MENU_ENVIRON_RESET_HORIZONTAL_LIST;
|
menu_environ.type = MENU_ENVIRON_RESET_HORIZONTAL_LIST;
|
||||||
menu_environ.data = NULL;
|
menu_environ.data = NULL;
|
||||||
|
@ -134,7 +136,9 @@ static void scan_finished_handler(void *task_data, void *user_data, const char *
|
||||||
if (!ui_window.qtWindow->settings()->value("scan_finish_confirm", true).toBool())
|
if (!ui_window.qtWindow->settings()->value("scan_finish_confirm", true).toBool())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!ui_window.qtWindow->showMessageBox(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_SCAN_FINISHED), MainWindow::MSGBOX_TYPE_INFO, Qt::ApplicationModal))
|
answer = ui_window.qtWindow->showMessageBox(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_SCAN_FINISHED), MainWindow::MSGBOX_TYPE_QUESTION_OKCANCEL, Qt::ApplicationModal, true, &dontAsk);
|
||||||
|
|
||||||
|
if (answer && dontAsk)
|
||||||
ui_window.qtWindow->settings()->setValue("scan_finish_confirm", false);
|
ui_window.qtWindow->settings()->setValue("scan_finish_confirm", false);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -1491,6 +1495,8 @@ void MainWindow::onZoomValueChanged(int value)
|
||||||
|
|
||||||
void MainWindow::showWelcomeScreen()
|
void MainWindow::showWelcomeScreen()
|
||||||
{
|
{
|
||||||
|
bool dontAsk = false;
|
||||||
|
bool answer = false;
|
||||||
const QString welcomeText = QStringLiteral(""
|
const QString welcomeText = QStringLiteral(""
|
||||||
"Welcome to the RetroArch Desktop Menu!<br>\n"
|
"Welcome to the RetroArch Desktop Menu!<br>\n"
|
||||||
"<br>\n"
|
"<br>\n"
|
||||||
|
@ -1512,9 +1518,10 @@ void MainWindow::showWelcomeScreen()
|
||||||
if (!m_settings->value("show_welcome_screen", true).toBool())
|
if (!m_settings->value("show_welcome_screen", true).toBool())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!showMessageBox(welcomeText, MainWindow::MSGBOX_TYPE_INFO, Qt::ApplicationModal))
|
answer = showMessageBox(welcomeText, MainWindow::MSGBOX_TYPE_QUESTION_OKCANCEL, Qt::ApplicationModal, true, &dontAsk);
|
||||||
m_settings->setValue("show_welcome_screen", false);
|
|
||||||
|
|
||||||
|
if (answer && dontAsk)
|
||||||
|
m_settings->setValue("show_welcome_screen", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString& MainWindow::customThemeString() const
|
const QString& MainWindow::customThemeString() const
|
||||||
|
@ -1573,7 +1580,7 @@ void MainWindow::setCustomThemeString(QString qss)
|
||||||
m_customThemeString = qss;
|
m_customThemeString = qss;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MainWindow::showMessageBox(QString msg, MessageBoxType msgType, Qt::WindowModality modality, bool showDontAsk)
|
bool MainWindow::showMessageBox(QString msg, MessageBoxType msgType, Qt::WindowModality modality, bool showDontAsk, bool *dontAsk)
|
||||||
{
|
{
|
||||||
QPointer<QMessageBox> msgBoxPtr;
|
QPointer<QMessageBox> msgBoxPtr;
|
||||||
QMessageBox *msgBox = NULL;
|
QMessageBox *msgBox = NULL;
|
||||||
|
@ -1613,7 +1620,14 @@ bool MainWindow::showMessageBox(QString msg, MessageBoxType msgType, Qt::WindowM
|
||||||
msgBox->setWindowTitle(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_ERROR));
|
msgBox->setWindowTitle(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_ERROR));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case MSGBOX_TYPE_QUESTION:
|
case MSGBOX_TYPE_QUESTION_YESNO:
|
||||||
|
{
|
||||||
|
msgBox->setIcon(QMessageBox::Question);
|
||||||
|
msgBox->setWindowTitle(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_QUESTION));
|
||||||
|
msgBox->setStandardButtons(QMessageBox::Yes | QMessageBox::No);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case MSGBOX_TYPE_QUESTION_OKCANCEL:
|
||||||
{
|
{
|
||||||
msgBox->setIcon(QMessageBox::Question);
|
msgBox->setIcon(QMessageBox::Question);
|
||||||
msgBox->setWindowTitle(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_QUESTION));
|
msgBox->setWindowTitle(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_QUESTION));
|
||||||
|
@ -1630,11 +1644,12 @@ bool MainWindow::showMessageBox(QString msg, MessageBoxType msgType, Qt::WindowM
|
||||||
if (!msgBoxPtr)
|
if (!msgBoxPtr)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (checkBox && checkBox->isChecked())
|
if (msgBox->result() != QMessageBox::Ok && msgBox->result() != QMessageBox::Yes)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (msgBox->result() == QMessageBox::Cancel)
|
if (checkBox)
|
||||||
return false;
|
if (dontAsk)
|
||||||
|
*dontAsk = checkBox->isChecked();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -2006,7 +2021,7 @@ void MainWindow::onPlaylistWidgetContextMenuRequested(const QPoint&)
|
||||||
{
|
{
|
||||||
if (currentPlaylistFile.exists())
|
if (currentPlaylistFile.exists())
|
||||||
{
|
{
|
||||||
if (showMessageBox(QString(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_CONFIRM_DELETE_PLAYLIST)).arg(selectedItem->text()), MainWindow::MSGBOX_TYPE_QUESTION, Qt::ApplicationModal, false))
|
if (showMessageBox(QString(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_CONFIRM_DELETE_PLAYLIST)).arg(selectedItem->text()), MainWindow::MSGBOX_TYPE_QUESTION_YESNO, Qt::ApplicationModal, false))
|
||||||
{
|
{
|
||||||
if (currentPlaylistFile.remove())
|
if (currentPlaylistFile.remove())
|
||||||
reloadPlaylists();
|
reloadPlaylists();
|
||||||
|
@ -2863,7 +2878,7 @@ void MainWindow::deleteCurrentPlaylistItem()
|
||||||
if (!ok)
|
if (!ok)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!showMessageBox(QString(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_CONFIRM_DELETE_PLAYLIST_ITEM)).arg(contentHash["label"]), MainWindow::MSGBOX_TYPE_QUESTION, Qt::ApplicationModal, false))
|
if (!showMessageBox(QString(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_CONFIRM_DELETE_PLAYLIST_ITEM)).arg(contentHash["label"]), MainWindow::MSGBOX_TYPE_QUESTION_YESNO, Qt::ApplicationModal, false))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
playlist = playlist_init(playlistData, COLLECTION_SIZE);
|
playlist = playlist_init(playlistData, COLLECTION_SIZE);
|
||||||
|
|
|
@ -313,7 +313,8 @@ public:
|
||||||
MSGBOX_TYPE_INFO,
|
MSGBOX_TYPE_INFO,
|
||||||
MSGBOX_TYPE_WARNING,
|
MSGBOX_TYPE_WARNING,
|
||||||
MSGBOX_TYPE_ERROR,
|
MSGBOX_TYPE_ERROR,
|
||||||
MSGBOX_TYPE_QUESTION,
|
MSGBOX_TYPE_QUESTION_YESNO,
|
||||||
|
MSGBOX_TYPE_QUESTION_OKCANCEL,
|
||||||
};
|
};
|
||||||
|
|
||||||
MainWindow(QWidget *parent = NULL);
|
MainWindow(QWidget *parent = NULL);
|
||||||
|
@ -341,7 +342,7 @@ public:
|
||||||
QString getThemeString(Theme theme);
|
QString getThemeString(Theme theme);
|
||||||
QHash<QString, QString> getSelectedCore();
|
QHash<QString, QString> getSelectedCore();
|
||||||
void showStatusMessage(QString msg, unsigned priority, unsigned duration, bool flush);
|
void showStatusMessage(QString msg, unsigned priority, unsigned duration, bool flush);
|
||||||
bool showMessageBox(QString msg, MessageBoxType msgType = MSGBOX_TYPE_INFO, Qt::WindowModality modality = Qt::ApplicationModal, bool showDontAsk = true);
|
bool showMessageBox(QString msg, MessageBoxType msgType = MSGBOX_TYPE_INFO, Qt::WindowModality modality = Qt::ApplicationModal, bool showDontAsk = true, bool *dontAsk = NULL);
|
||||||
bool setCustomThemeFile(QString filePath);
|
bool setCustomThemeFile(QString filePath);
|
||||||
void setCustomThemeString(QString qss);
|
void setCustomThemeString(QString qss);
|
||||||
const QString& customThemeString() const;
|
const QString& customThemeString() const;
|
||||||
|
|
Loading…
Reference in New Issue