Even better API.

This commit is contained in:
Martin Rotter 2015-06-29 19:13:06 +02:00
parent 598a83b7cb
commit 7b15e568aa
6 changed files with 26 additions and 9 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.0 KiB

View File

@ -68,7 +68,7 @@
#define INTERNAL_URL_BLANK "about:blank"
#define DEFAULT_AUTO_UPDATE_INTERVAL 15
#define AUTO_UPDATE_INTERVAL 60000
#define STARTUP_UPDATE_DELAY 1500
#define STARTUP_UPDATE_DELAY 15000
#define TIMEZONE_OFFSET_LIMIT 6
#define CHANGE_EVENT_DELAY 250
#define FLAG_ICON_SUBFOLDER "flags"

View File

@ -277,8 +277,6 @@ void FeedMessageViewer::updateMessageButtonsAvailability() {
form_main->m_ui->m_actionSwitchImportanceOfSelectedMessages->setEnabled(atleast_one_message_selected);
form_main->m_ui->m_actionRestoreSelectedMessagesFromRecycleBin->setEnabled(recycle_bin_selected && atleast_one_message_selected);
// TODO: To samo udělat s feedy, řešit pouze buttony, které se týkají výběru, ale také vzít v potaz, zda zrovna běží update.
}
void FeedMessageViewer::updateFeedButtonsAvailability() {

View File

@ -35,7 +35,7 @@
Notification::Notification() : QWidget(0), m_title(QString()), m_text(QString()), m_icon(QPixmap()), m_screen(-1),
m_width(-1), m_height(-1), m_padding(5), m_widgetMargin(2 * m_padding) {
m_width(-1), m_height(-1), m_padding(5), m_widgetMargin(2 * m_padding), m_timerId(0) {
setupWidget();
loadSettings();
}
@ -49,7 +49,7 @@ bool Notification::areNotificationsActivated() {
}
void Notification::notify(const QString &text, const QString &title, const QIcon &icon) {
hide();
cancel();
// Set new values.
m_text = text;
@ -60,12 +60,22 @@ void Notification::notify(const QString &text, const QString &title, const QIcon
updateGeometries();
repaint();
show();
m_timerId = startTimer(10000);
}
void Notification::notify(const QString &text, const QString &title, QSystemTrayIcon::MessageIcon icon) {
notify(text, title, MessageBox::iconForStatus((QMessageBox::Icon) icon));
}
void Notification::cancel() {
hide();
if (m_timerId != 0) {
killTimer(m_timerId);
}
}
void Notification::updateGeometries() {
// Calculate width and height of notification with given icon and text.
m_width = m_padding +
@ -159,7 +169,7 @@ void Notification::paintEvent(QPaintEvent *event) {
void Notification::mousePressEvent(QMouseEvent *event) {
QWidget::mousePressEvent(event);
QTimer::singleShot(0, this, SLOT(hide()));
cancel();
}
void Notification::enterEvent(QEvent *event) {
@ -172,6 +182,11 @@ void Notification::leaveEvent(QEvent *event) {
repaint();
}
void Notification::timerEvent(QTimerEvent *event) {
QWidget::timerEvent(event);
cancel();
}
void Notification::loadSettings() {
m_position = static_cast<Qt::Corner>(qApp->settings()->value(GROUP(GUI), SETTING(GUI::FancyNotificationsPosition)).toInt());
}

View File

@ -37,11 +37,14 @@ class Notification : public QWidget {
void notify(const QString &text, const QString &title, const QIcon &icon);
void notify(const QString &text, const QString &title, QSystemTrayIcon::MessageIcon icon = QSystemTrayIcon::Information);
void cancel();
protected:
void paintEvent(QPaintEvent *event);
void mousePressEvent(QMouseEvent *event);
void enterEvent(QEvent *event);
void leaveEvent(QEvent *event);
void timerEvent(QTimerEvent *event);
private:
void loadSettings();
@ -61,6 +64,7 @@ class Notification : public QWidget {
int m_height;
int m_padding;
int m_widgetMargin;
int m_timerId;
};
#endif // NOTIFICATION_H

View File

@ -37,9 +37,9 @@ TrayIconMenu::~TrayIconMenu() {
bool TrayIconMenu::event(QEvent *event) {
if (Application::activeModalWidget() != NULL && event->type() == QEvent::Show) {
QTimer::singleShot(0, this, SLOT(hide()));
qApp->trayIcon()->showMessage(QSL(APP_LONG_NAME),
qApp->showGuiMessage(QSL(APP_LONG_NAME),
tr("Close opened modal dialogs first."),
QSystemTrayIcon::Warning);
QSystemTrayIcon::Warning, qApp->mainForm(), true);
}
return QMenu::event(event);
}