summaryrefslogtreecommitdiffstats
path: root/gui/dialogs
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2014-03-19 22:28:04 +0100
committerPetr Mrázek <peterix@gmail.com>2014-03-19 22:28:04 +0100
commit1705832febb86181e52222fdbfe87d8d2d0ba5b7 (patch)
tree6b289c02868a7d5a88703eee0042c419a8afeca4 /gui/dialogs
parent4623c1b34f35dd896a9ccacd9b982bca9dc0b880 (diff)
parent55e4cb6fb5ea59958ac0bc386b9df06476c1ddb4 (diff)
downloadMultiMC-1705832febb86181e52222fdbfe87d8d2d0ba5b7.tar
MultiMC-1705832febb86181e52222fdbfe87d8d2d0ba5b7.tar.gz
MultiMC-1705832febb86181e52222fdbfe87d8d2d0ba5b7.tar.lz
MultiMC-1705832febb86181e52222fdbfe87d8d2d0ba5b7.tar.xz
MultiMC-1705832febb86181e52222fdbfe87d8d2d0ba5b7.zip
Merge remote-tracking branch 'origin/feature_notif_65449324' into develop
Diffstat (limited to 'gui/dialogs')
-rw-r--r--gui/dialogs/NotificationDialog.cpp84
-rw-r--r--gui/dialogs/NotificationDialog.h44
-rw-r--r--gui/dialogs/NotificationDialog.ui85
-rw-r--r--gui/dialogs/SettingsDialog.cpp5
-rw-r--r--gui/dialogs/SettingsDialog.ui10
5 files changed, 228 insertions, 0 deletions
diff --git a/gui/dialogs/NotificationDialog.cpp b/gui/dialogs/NotificationDialog.cpp
new file mode 100644
index 00000000..8f920371
--- /dev/null
+++ b/gui/dialogs/NotificationDialog.cpp
@@ -0,0 +1,84 @@
+#include "NotificationDialog.h"
+#include "ui_NotificationDialog.h"
+
+#include <QTimerEvent>
+
+NotificationDialog::NotificationDialog(const NotificationChecker::NotificationEntry &entry, QWidget *parent) :
+ QDialog(parent, Qt::MSWindowsFixedSizeDialogHint | Qt::WindowTitleHint | Qt::CustomizeWindowHint),
+ ui(new Ui::NotificationDialog)
+{
+ ui->setupUi(this);
+
+ QStyle::StandardPixmap icon;
+ switch (entry.type)
+ {
+ case NotificationChecker::NotificationEntry::Critical:
+ icon = QStyle::SP_MessageBoxCritical;
+ break;
+ case NotificationChecker::NotificationEntry::Warning:
+ icon = QStyle::SP_MessageBoxWarning;
+ break;
+ case NotificationChecker::NotificationEntry::Information:
+ icon = QStyle::SP_MessageBoxInformation;
+ break;
+ }
+ ui->iconLabel->setPixmap(style()->standardPixmap(icon, 0, this));
+ ui->messageLabel->setText(entry.message);
+
+ m_dontShowAgainText = tr("Don't show again");
+ m_closeText = tr("Close");
+
+ ui->dontShowAgainBtn->setText(m_dontShowAgainText + QString(" (%1)").arg(m_dontShowAgainTime));
+ ui->closeBtn->setText(m_closeText + QString(" (%1)").arg(m_closeTime));
+
+ startTimer(1000);
+}
+
+NotificationDialog::~NotificationDialog()
+{
+ delete ui;
+}
+
+void NotificationDialog::timerEvent(QTimerEvent *event)
+{
+ if (m_dontShowAgainTime > 0)
+ {
+ m_dontShowAgainTime--;
+ if (m_dontShowAgainTime == 0)
+ {
+ ui->dontShowAgainBtn->setText(m_dontShowAgainText);
+ ui->dontShowAgainBtn->setEnabled(true);
+ }
+ else
+ {
+ ui->dontShowAgainBtn->setText(m_dontShowAgainText + QString(" (%1)").arg(m_dontShowAgainTime));
+ }
+ }
+ if (m_closeTime > 0)
+ {
+ m_closeTime--;
+ if (m_closeTime == 0)
+ {
+ ui->closeBtn->setText(m_closeText);
+ ui->closeBtn->setEnabled(true);
+ }
+ else
+ {
+ ui->closeBtn->setText(m_closeText + QString(" (%1)").arg(m_closeTime));
+ }
+ }
+
+ if (m_closeTime == 0 && m_dontShowAgainTime == 0)
+ {
+ killTimer(event->timerId());
+ }
+}
+
+void NotificationDialog::on_dontShowAgainBtn_clicked()
+{
+ done(DontShowAgain);
+}
+void NotificationDialog::on_closeBtn_clicked()
+{
+ done(Normal);
+}
diff --git a/gui/dialogs/NotificationDialog.h b/gui/dialogs/NotificationDialog.h
new file mode 100644
index 00000000..b7980a98
--- /dev/null
+++ b/gui/dialogs/NotificationDialog.h
@@ -0,0 +1,44 @@
+#ifndef NOTIFICATIONDIALOG_H
+#define NOTIFICATIONDIALOG_H
+
+#include <QDialog>
+
+#include "logic/updater/NotificationChecker.h"
+
+namespace Ui {
+class NotificationDialog;
+}
+
+class NotificationDialog : public QDialog
+{
+ Q_OBJECT
+
+public:
+ explicit NotificationDialog(const NotificationChecker::NotificationEntry &entry, QWidget *parent = 0);
+ ~NotificationDialog();
+
+ enum ExitCode
+ {
+ Normal,
+ DontShowAgain
+ };
+
+protected:
+ void timerEvent(QTimerEvent *event);
+
+private:
+ Ui::NotificationDialog *ui;
+
+ int m_dontShowAgainTime = 10;
+ int m_closeTime = 5;
+
+ QString m_dontShowAgainText;
+ QString m_closeText;
+
+private
+slots:
+ void on_dontShowAgainBtn_clicked();
+ void on_closeBtn_clicked();
+};
+
+#endif // NOTIFICATIONDIALOG_H
diff --git a/gui/dialogs/NotificationDialog.ui b/gui/dialogs/NotificationDialog.ui
new file mode 100644
index 00000000..a2a276e9
--- /dev/null
+++ b/gui/dialogs/NotificationDialog.ui
@@ -0,0 +1,85 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>NotificationDialog</class>
+ <widget class="QDialog" name="NotificationDialog">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>320</width>
+ <height>240</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Dialog</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout" stretch="1,0">
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_2" stretch="0,1">
+ <item>
+ <widget class="QLabel" name="iconLabel">
+ <property name="text">
+ <string>TextLabel</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="messageLabel">
+ <property name="text">
+ <string>TextLabel</string>
+ </property>
+ <property name="wordWrap">
+ <bool>true</bool>
+ </property>
+ <property name="openExternalLinks">
+ <bool>true</bool>
+ </property>
+ <property name="textInteractionFlags">
+ <set>Qt::TextBrowserInteraction</set>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <spacer name="horizontalSpacer">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QPushButton" name="dontShowAgainBtn">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>Don't show again</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="closeBtn">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>Close</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/gui/dialogs/SettingsDialog.cpp b/gui/dialogs/SettingsDialog.cpp
index d79bb558..7ec48336 100644
--- a/gui/dialogs/SettingsDialog.cpp
+++ b/gui/dialogs/SettingsDialog.cpp
@@ -308,6 +308,11 @@ void SettingsDialog::applySettings(SettingsObject *s)
s->set("Language",
ui->languageBox->itemData(ui->languageBox->currentIndex()).toLocale().bcp47Name());
+ if (ui->resetNotificationsBtn->isChecked())
+ {
+ s->set("ShownNotifications", QString());
+ }
+
// Updates
s->set("AutoUpdate", ui->autoUpdateCheckBox->isChecked());
s->set("UpdateChannel", m_currentUpdateChannel);
diff --git a/gui/dialogs/SettingsDialog.ui b/gui/dialogs/SettingsDialog.ui
index e8da8582..74ed68d2 100644
--- a/gui/dialogs/SettingsDialog.ui
+++ b/gui/dialogs/SettingsDialog.ui
@@ -285,6 +285,16 @@
</layout>
</item>
<item>
+ <widget class="QPushButton" name="resetNotificationsBtn">
+ <property name="text">
+ <string>Reset hidden notifications</string>
+ </property>
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
<widget class="QGroupBox" name="sortingModeBox">
<property name="enabled">
<bool>true</bool>