Move DisplayMessage() to utility.hpp

This commit is contained in:
WarmUpTill 2021-05-03 22:14:38 +02:00 committed by WarmUpTill
parent dad36689c4
commit f37f384b5a
3 changed files with 24 additions and 23 deletions

View File

@ -11,6 +11,7 @@
#include "headers/advanced-scene-switcher.hpp"
#include "headers/curl-helper.hpp"
#include "headers/utility.hpp"
#include "headers/version.h"
SwitcherData *switcher = nullptr;
@ -73,28 +74,6 @@ void AdvSceneSwitcher::loadUI()
/******************************************************************************
* UI helpers
******************************************************************************/
bool AdvSceneSwitcher::DisplayMessage(QString msg, bool question)
{
if (question) {
QMessageBox::StandardButton reply;
reply = QMessageBox::question(
nullptr, "Advanced Scene Switcher", msg,
QMessageBox::Yes | QMessageBox::No);
if (reply == QMessageBox::Yes) {
return true;
} else {
return false;
}
} else {
QMessageBox Msgbox;
Msgbox.setWindowTitle("Advanced Scene Switcher");
Msgbox.setText(msg);
Msgbox.exec();
}
return false;
}
void AdvSceneSwitcher::addSelectionEntry(QComboBox *sel,
const char *description,
bool selectable, const char *tooltip)

View File

@ -64,7 +64,6 @@ public:
void setTabOrder();
void restoreWindowGeo();
static bool DisplayMessage(QString msg, bool question = false);
static void AskBackup(obs_data_t *obj);
static void addSelectionEntry(QComboBox *sel, const char *description,

View File

@ -4,6 +4,7 @@
#include <QTextStream>
#include <QLayout>
#include <QLabel>
#include <QMessageBox>
#include <unordered_map>
#include <obs.hpp>
@ -204,3 +205,25 @@ static inline bool compareIgnoringLineEnding(QString &s1, QString &s2)
return true;
}
static inline bool DisplayMessage(QString msg, bool question = false)
{
if (question) {
QMessageBox::StandardButton reply;
reply = QMessageBox::question(
nullptr, "Advanced Scene Switcher", msg,
QMessageBox::Yes | QMessageBox::No);
if (reply == QMessageBox::Yes) {
return true;
} else {
return false;
}
} else {
QMessageBox Msgbox;
Msgbox.setWindowTitle("Advanced Scene Switcher");
Msgbox.setText(msg);
Msgbox.exec();
}
return false;
}