Use PROTOCOL_TELEMETRY_MULTIMODULE for internal multi when available (#7147)
[opentx.git] / companion / src / warnings.h
blob598a911c0b24335dbc93f8fe248a4085323d8359
1 /*
2 * Copyright (C) OpenTX
4 * Based on code named
5 * th9x - http://code.google.com/p/th9x
6 * er9x - http://code.google.com/p/er9x
7 * gruvin9x - http://code.google.com/p/gruvin9x
9 * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2 as
13 * published by the Free Software Foundation.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
21 #ifndef _WARNINGS_H_
22 #define _WARNINGS_H_
24 #include "appdata.h"
26 #include <QtCore>
27 #include <QCheckBox>
28 #include <QMessageBox>
30 #define CPN_STR_MSG_WELCOME QCoreApplication::translate("Companion", \
31 "<p><b>Welcome to OpenTX %1.</b></p>" \
32 "<p>As the first step, please configure the initial Radio Profile by selecting your Radio Type, Menu Language, and Build Options.</p>" \
33 "<p>You may also want to take this time to review the other available options in the displayed Settings dialog.</p>" \
34 "<p>After saving your settings, we recommend you download the latest firmware for your radio by using the <i>File -&gt; Download</i> menu option.</p>" \
35 "<p>Please visit <a href='http://www.open-tx.org'>open-tx.org</a> for latest news, updates and documentation. Thank you for choosing OpenTX!</p>" \
36 "- The OpenTX Team.")
38 #define CPN_STR_MSG_UPGRADED QCoreApplication::translate("Companion", \
39 "<p><b>Thank you for upgrading to OpenTX %1.</b></p>" \
40 "<p>This is a major upgrade that adds and modifies a lot of things, so please make sure that you read release notes carefully" \
41 " to learn about the changes, and thoroughly check each of your models for proper function.</p>" \
42 "<p>Please visit <a href='http://www.open-tx.org'>open-tx.org</a> for release notes and other documentation.</p>" \
43 "- The OpenTX Team.")
45 #define CPN_STR_MSG_NO_RADIO_TYPE QCoreApplication::translate("Companion", \
46 "<p>The radio type in the selected profile does not exist. Using the default type instead.</p> <p><b>Please update your profile settings!</b></p>")
48 class AppMessages
50 Q_DECLARE_TR_FUNCTIONS("AppMessages")
52 public:
53 // These are used for saving "[don't] show this message again" user preferences.
54 enum MessageCodes {
55 MSG_NONE = 0,
56 MSG_WELCOME = 0x01,
57 MSG_UPGRADED = 0x02,
58 MSG_RESERVED = 0x04, // reserved due to legacy code
59 MSG_NO_RADIO_TYPE = 0x08,
60 MSG_ENUM_END
63 static void displayMessage(int id, QWidget * parent = nullptr)
65 QString infoTxt;
66 QMessageBox::Icon icon = QMessageBox::Information;
67 bool transient = false;
69 switch (id) {
70 case MSG_WELCOME:
71 infoTxt = CPN_STR_MSG_WELCOME.arg(VERSION);
72 break;
74 case MSG_UPGRADED:
75 infoTxt = CPN_STR_MSG_UPGRADED.arg(VERSION);
76 break;
78 case MSG_NO_RADIO_TYPE:
79 infoTxt = CPN_STR_MSG_NO_RADIO_TYPE;
80 icon = QMessageBox::Warning;
81 transient = true;
82 break;
84 default:
85 return;
88 QMessageBox msgBox(parent);
89 msgBox.setWindowTitle(CPN_STR_APP_NAME);
90 msgBox.setIcon(icon);
91 msgBox.setStandardButtons(QMessageBox::Ok);
92 msgBox.setText(infoTxt);
94 if (!transient)
95 msgBox.setCheckBox(new QCheckBox(tr("Show this message again at next startup?")));
97 msgBox.exec();
99 if (transient || (msgBox.checkBox() && !msgBox.checkBox()->isChecked()))
100 g.warningId(g.warningId() & ~id);
105 #endif // _WARNINGS_H_