[Companion] Improve first use of Companion & upgrade notice (#4940)
* [Companion] On first use of Companion show preferences dialog and new welcome message (closes #4731); Improve detection of new version upgrade & reformat message; Add download link URL to Linux update notice (closes #4774); Fix issue with leftover top-level settings categories when checking for older versions which don't exist; Introduce basic structure for warnings/messages to be suppressed by user preferences (eg. "don't show this message again" option). * Welcome msg typo fix.
This commit is contained in:
committed by
Bertrand Songis
parent
69576cb17d
commit
0fc1681d5c
@@ -53,6 +53,7 @@
|
||||
#include <QFileInfo>
|
||||
#include <QDesktopServices>
|
||||
|
||||
#define OPENTX_DOWNLOADS_PAGE_URL "http://www.open-tx.org/downloads"
|
||||
#define OPENTX_COMPANION_DOWNLOADS "http://downloads-22.open-tx.org/companion"
|
||||
#define DONATE_STR "https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=QUZ48K4SEXDP2"
|
||||
|
||||
@@ -114,7 +115,16 @@ MainWindow::MainWindow():
|
||||
if (showSplash) {
|
||||
updateDelay += (SPLASH_TIME*1000);
|
||||
}
|
||||
QTimer::singleShot(updateDelay, this, SLOT(doAutoUpdates()));
|
||||
|
||||
if (g.isFirstUse()) {
|
||||
g.warningId(g.warningId() | AppMessages::MSG_WELCOME);
|
||||
QTimer::singleShot(updateDelay-500, this, SLOT(appPrefs())); // must be shown before warnings dialog but after splash
|
||||
}
|
||||
else {
|
||||
if (!g.previousVersion().isEmpty())
|
||||
g.warningId(g.warningId() | AppMessages::MSG_UPGRADED);
|
||||
QTimer::singleShot(updateDelay, this, SLOT(doAutoUpdates()));
|
||||
}
|
||||
QTimer::singleShot(updateDelay, this, SLOT(displayWarnings()));
|
||||
|
||||
QStringList strl = QApplication::arguments();
|
||||
@@ -167,21 +177,39 @@ MainWindow::~MainWindow()
|
||||
|
||||
void MainWindow::displayWarnings()
|
||||
{
|
||||
int warnId = g.warningId();
|
||||
if (warnId<WARNING_ID && warnId!=0) {
|
||||
int res=0;
|
||||
if (WARNING_LEVEL>0)
|
||||
QMessageBox::warning(this, "Companion", WARNING);
|
||||
else
|
||||
QMessageBox::about(this, "Companion", WARNING);
|
||||
res = QMessageBox::question(this, "Companion", tr("Display previous warning again at startup ?"), QMessageBox::Yes | QMessageBox::No);
|
||||
if (res == QMessageBox::No) {
|
||||
g.warningId(WARNING_ID);
|
||||
}
|
||||
using namespace AppMessages;
|
||||
static uint shownMsgs = 0;
|
||||
int showMsgs = g.warningId();
|
||||
int msgId;
|
||||
QString infoTxt;
|
||||
|
||||
if ((showMsgs & MSG_WELCOME) && !(shownMsgs & MSG_WELCOME)) {
|
||||
infoTxt = CPN_STR_MSG_WELCOME.arg(VERSION);
|
||||
msgId = MSG_WELCOME;
|
||||
}
|
||||
else if (warnId==0) {
|
||||
g.warningId(WARNING_ID);
|
||||
else if ((showMsgs & MSG_UPGRADED) && !(shownMsgs & MSG_UPGRADED)) {
|
||||
infoTxt = CPN_STR_MSG_UPGRADED.arg(VERSION);
|
||||
msgId = MSG_UPGRADED;
|
||||
}
|
||||
else {
|
||||
return;
|
||||
}
|
||||
|
||||
QMessageBox msgBox(this);
|
||||
msgBox.setWindowTitle(tr("Companion"));
|
||||
msgBox.setIcon(QMessageBox::Information);
|
||||
msgBox.setStandardButtons(QMessageBox::Ok);
|
||||
msgBox.setInformativeText(infoTxt);
|
||||
QCheckBox * cb = new QCheckBox(tr("Show this message again at next startup?"), &msgBox);
|
||||
msgBox.setCheckBox(cb);
|
||||
|
||||
msgBox.exec();
|
||||
|
||||
shownMsgs |= msgId;
|
||||
if (!cb->isChecked())
|
||||
g.warningId(showMsgs & ~msgId);
|
||||
|
||||
displayWarnings(); // in case more warnings need showing
|
||||
}
|
||||
|
||||
void MainWindow::doAutoUpdates()
|
||||
@@ -317,7 +345,7 @@ void MainWindow::checkForCompanionUpdateFinished(QNetworkReply * reply)
|
||||
}
|
||||
}
|
||||
#else
|
||||
QMessageBox::warning(this, tr("New release available"), tr("A new release of Companion is available, please check the OpenTX website!"));
|
||||
QMessageBox::warning(this, tr("New release available"), tr("A new release of Companion is available, please check the <a href='%1'>OpenTX website!</a>").arg(OPENTX_DOWNLOADS_PAGE_URL));
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
|
||||
Reference in New Issue
Block a user