Common/MsgHandler: Namespace code within the Common namespace

Closes another gap in the Common library where code isn't being
namespaced under it.
This commit is contained in:
Lioncash
2019-06-16 23:45:37 -04:00
parent e7dd46a531
commit 4f1f55093f
15 changed files with 214 additions and 143 deletions

View File

@ -35,7 +35,8 @@
#include "UICommon/CommandLineParse.h"
#include "UICommon/UICommon.h"
static bool QtMsgAlertHandler(const char* caption, const char* text, bool yes_no, MsgType style)
static bool QtMsgAlertHandler(const char* caption, const char* text, bool yes_no,
Common::MsgType style)
{
std::optional<bool> r = RunOnObject(QApplication::instance(), [&] {
ModalMessageBox message_box(QApplication::activeWindow());
@ -43,19 +44,19 @@ static bool QtMsgAlertHandler(const char* caption, const char* text, bool yes_no
message_box.setText(QString::fromUtf8(text));
message_box.setStandardButtons(yes_no ? QMessageBox::Yes | QMessageBox::No : QMessageBox::Ok);
if (style == MsgType::Warning)
if (style == Common::MsgType::Warning)
message_box.addButton(QMessageBox::Ignore)->setText(QObject::tr("Ignore for this session"));
message_box.setIcon([&] {
switch (style)
{
case MsgType::Information:
case Common::MsgType::Information:
return QMessageBox::Information;
case MsgType::Question:
case Common::MsgType::Question:
return QMessageBox::Question;
case MsgType::Warning:
case Common::MsgType::Warning:
return QMessageBox::Warning;
case MsgType::Critical:
case Common::MsgType::Critical:
return QMessageBox::Critical;
}
// appease MSVC
@ -67,7 +68,7 @@ static bool QtMsgAlertHandler(const char* caption, const char* text, bool yes_no
return true;
if (button == QMessageBox::Ignore)
SetEnableAlert(false);
Common::SetEnableAlert(false);
return false;
});
@ -137,7 +138,7 @@ int main(int argc, char* argv[])
Settings::Instance().SetBatchModeEnabled(options.is_set("batch"));
// Hook up alerts from core
RegisterMsgAlertHandler(QtMsgAlertHandler);
Common::RegisterMsgAlertHandler(QtMsgAlertHandler);
// Hook up translations
Translation::Initialize();

View File

@ -263,7 +263,7 @@ void InterfacePane::OnSaveConfig()
settings.m_show_active_title = m_checkbox_show_active_title->isChecked();
settings.m_PauseOnFocusLost = m_checkbox_pause_on_focus_lost->isChecked();
SetEnableAlert(settings.bUsePanicHandlers);
Common::SetEnableAlert(settings.bUsePanicHandlers);
auto new_language = m_combobox_language->currentData().toString().toStdString();
if (new_language != SConfig::GetInstance().m_InterfaceLanguage)

View File

@ -292,7 +292,8 @@ static bool TryInstallTranslator(const QString& exact_language_code)
void Translation::Initialize()
{
// Hook up Dolphin internal translation
RegisterStringTranslator([](const char* text) { return QObject::tr(text).toStdString(); });
Common::RegisterStringTranslator(
[](const char* text) { return QObject::tr(text).toStdString(); });
// Hook up Qt translations
auto& configured_language = SConfig::GetInstance().m_InterfaceLanguage;