Show notifications in msgbox on double click
This commit is contained in:
parent
7f58bd6024
commit
d3e2c89a0b
|
@ -52,6 +52,7 @@ DbQueryWidget::DbQueryWidget(TagEditorWidget *tagEditorWidget, QWidget *parent)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
m_ui->notificationLabel->setText(tr("Search hasn't been started"));
|
m_ui->notificationLabel->setText(tr("Search hasn't been started"));
|
||||||
|
m_ui->notificationLabel->setContext(tr("MusicBrainz/LyricsWikia notifications"));
|
||||||
m_ui->searchGroupBox->installEventFilter(this);
|
m_ui->searchGroupBox->installEventFilter(this);
|
||||||
|
|
||||||
// initialize buttons
|
// initialize buttons
|
||||||
|
|
|
@ -7,7 +7,9 @@
|
||||||
#include <QFontMetrics>
|
#include <QFontMetrics>
|
||||||
#include <QBrush>
|
#include <QBrush>
|
||||||
#include <QConicalGradient>
|
#include <QConicalGradient>
|
||||||
#include <QDebug>
|
#include <QMessageBox>
|
||||||
|
#include <QCoreApplication>
|
||||||
|
#include <QStringBuilder>
|
||||||
|
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
||||||
|
@ -65,6 +67,14 @@ void NotificationLabel::paintEvent(QPaintEvent *event)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NotificationLabel::mouseDoubleClickEvent(QMouseEvent *event)
|
||||||
|
{
|
||||||
|
if(m_type == NotificationType::Progress) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
showMessageBox();
|
||||||
|
}
|
||||||
|
|
||||||
void NotificationLabel::updateAnimation()
|
void NotificationLabel::updateAnimation()
|
||||||
{
|
{
|
||||||
switch(m_type) {
|
switch(m_type) {
|
||||||
|
@ -77,6 +87,15 @@ void NotificationLabel::updateAnimation()
|
||||||
update(iconRect());
|
update(iconRect());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NotificationLabel::showMessageBox() const
|
||||||
|
{
|
||||||
|
QMessageBox msgbox;
|
||||||
|
msgbox.setWindowTitle((m_context.isEmpty() ? tr("Notifications") : m_context) % QStringLiteral(" - ") % QCoreApplication::applicationName());
|
||||||
|
msgbox.setIconPixmap(m_mainPixmap);
|
||||||
|
msgbox.setText(m_text);
|
||||||
|
msgbox.exec();
|
||||||
|
}
|
||||||
|
|
||||||
QRect NotificationLabel::iconRect() const
|
QRect NotificationLabel::iconRect() const
|
||||||
{
|
{
|
||||||
QRect rect = this->rect();
|
QRect rect = this->rect();
|
||||||
|
|
|
@ -26,6 +26,7 @@ class NotificationLabel : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(QString text READ text WRITE setText)
|
Q_PROPERTY(QString text READ text WRITE setText)
|
||||||
|
Q_PROPERTY(QString context READ context WRITE setContext)
|
||||||
Q_PROPERTY(NotificationType notificationType READ notificationType WRITE setNotificationType)
|
Q_PROPERTY(NotificationType notificationType READ notificationType WRITE setNotificationType)
|
||||||
Q_PROPERTY(NotificationSubject notificationSubject READ notificationSubject WRITE setNotificationSubject)
|
Q_PROPERTY(NotificationSubject notificationSubject READ notificationSubject WRITE setNotificationSubject)
|
||||||
Q_PROPERTY(int percentage READ percentage WRITE setPercentage)
|
Q_PROPERTY(int percentage READ percentage WRITE setPercentage)
|
||||||
|
@ -35,6 +36,7 @@ public:
|
||||||
explicit NotificationLabel(QWidget *parent = nullptr);
|
explicit NotificationLabel(QWidget *parent = nullptr);
|
||||||
|
|
||||||
const QString &text() const;
|
const QString &text() const;
|
||||||
|
const QString &context() const;
|
||||||
NotificationType notificationType() const;
|
NotificationType notificationType() const;
|
||||||
NotificationSubject notificationSubject() const;
|
NotificationSubject notificationSubject() const;
|
||||||
int percentage() const;
|
int percentage() const;
|
||||||
|
@ -46,6 +48,7 @@ public:
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void setText(const QString &text);
|
void setText(const QString &text);
|
||||||
|
void setContext(const QString &context);
|
||||||
void clearText();
|
void clearText();
|
||||||
void appendLine(const QString &line);
|
void appendLine(const QString &line);
|
||||||
void setNotificationType(NotificationType value);
|
void setNotificationType(NotificationType value);
|
||||||
|
@ -55,19 +58,21 @@ public slots:
|
||||||
void setMaxIconSize(int size);
|
void setMaxIconSize(int size);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void paintEvent(QPaintEvent *event);
|
void paintEvent(QPaintEvent *event);
|
||||||
|
void mouseDoubleClickEvent(QMouseEvent *event);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void updateAnimation();
|
void updateAnimation();
|
||||||
|
void showMessageBox() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QRect iconRect() const;
|
QRect iconRect() const;
|
||||||
QRect textRect() const;
|
QRect textRect() const;
|
||||||
void setupPixmaps(const QSize &size);
|
void setupPixmaps(const QSize &size);
|
||||||
void drawProgressIndicator(QPainter &painter, QRect rect, const QColor &color, int angle);
|
void drawProgressIndicator(QPainter &painter, QRect rect, const QColor &color, int angle);
|
||||||
static void toGrayPixmap(const QPixmap &original, QPixmap grayed);
|
|
||||||
|
|
||||||
QString m_text;
|
QString m_text;
|
||||||
|
QString m_context;
|
||||||
NotificationType m_type;
|
NotificationType m_type;
|
||||||
NotificationSubject m_subject;
|
NotificationSubject m_subject;
|
||||||
int m_percentage;
|
int m_percentage;
|
||||||
|
@ -76,8 +81,6 @@ private:
|
||||||
bool m_pixmapsInvalidated;
|
bool m_pixmapsInvalidated;
|
||||||
QPixmap m_mainPixmap;
|
QPixmap m_mainPixmap;
|
||||||
QPixmap m_smallPixmap;
|
QPixmap m_smallPixmap;
|
||||||
QPixmap m_mainPixmapDisabled;
|
|
||||||
QPixmap m_smallPixmapDisabled;
|
|
||||||
QTimer m_updateTimer;
|
QTimer m_updateTimer;
|
||||||
int m_animationStep;
|
int m_animationStep;
|
||||||
};
|
};
|
||||||
|
@ -87,6 +90,16 @@ inline const QString &NotificationLabel::text() const
|
||||||
return m_text;
|
return m_text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline const QString &NotificationLabel::context() const
|
||||||
|
{
|
||||||
|
return m_context;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void NotificationLabel::setContext(const QString &context)
|
||||||
|
{
|
||||||
|
m_context = context;
|
||||||
|
}
|
||||||
|
|
||||||
inline NotificationType NotificationLabel::notificationType() const
|
inline NotificationType NotificationLabel::notificationType() const
|
||||||
{
|
{
|
||||||
return m_type;
|
return m_type;
|
||||||
|
|
|
@ -130,6 +130,8 @@ TagEditorWidget::TagEditorWidget(QWidget *parent) :
|
||||||
// other widgets
|
// other widgets
|
||||||
updateFileStatusStatus();
|
updateFileStatusStatus();
|
||||||
m_ui->abortButton->setVisible(false);
|
m_ui->abortButton->setVisible(false);
|
||||||
|
m_ui->parsingNotificationWidget->setContext(tr("Parsing notifications"));
|
||||||
|
m_ui->makingNotificationWidget->setContext(tr("Applying notifications"));
|
||||||
// connect signals and slots, install event filter
|
// connect signals and slots, install event filter
|
||||||
// buttons: save, delete, next, close
|
// buttons: save, delete, next, close
|
||||||
connect(m_ui->saveButton, &QPushButton::clicked, this, &TagEditorWidget::applyEntriesAndSaveChangings);
|
connect(m_ui->saveButton, &QPushButton::clicked, this, &TagEditorWidget::applyEntriesAndSaveChangings);
|
||||||
|
|
Loading…
Reference in New Issue