Notifications now provide API.
This commit is contained in:
parent
a5e1b1b116
commit
598a83b7cb
11 changed files with 36 additions and 27 deletions
|
@ -131,7 +131,7 @@ void FormCategoryDetails::apply() {
|
|||
qApp->showGuiMessage(tr("Cannot add category"),
|
||||
tr("Category was not added due to error."),
|
||||
QSystemTrayIcon::Critical,
|
||||
qApp->mainForm());
|
||||
qApp->mainForm(), true);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -142,7 +142,7 @@ void FormCategoryDetails::apply() {
|
|||
qApp->showGuiMessage(tr("Cannot edit category"),
|
||||
tr("Category was not edited due to error."),
|
||||
QSystemTrayIcon::Critical,
|
||||
qApp->mainForm());
|
||||
qApp->mainForm(), true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -246,7 +246,7 @@ void FormFeedDetails::apply() {
|
|||
else {
|
||||
qApp->showGuiMessage(tr("Cannot add feed"),
|
||||
tr("Feed was not added due to error."),
|
||||
QSystemTrayIcon::Critical);
|
||||
QSystemTrayIcon::Critical, this, true);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -257,7 +257,7 @@ void FormFeedDetails::apply() {
|
|||
else {
|
||||
qApp->showGuiMessage(tr("Cannot edit feed"),
|
||||
tr("Feed was not edited due to error."),
|
||||
QSystemTrayIcon::Critical);
|
||||
QSystemTrayIcon::Critical, this, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -79,8 +79,6 @@ FormMain::FormMain(QWidget *parent, Qt::WindowFlags f)
|
|||
|
||||
// Initialize the web factory.
|
||||
WebFactory::instance()->loadState();
|
||||
|
||||
(new Notification())->notify("abcd abcd abcd abcd abcd abcd \naaa\n\n\nabcd abcd abcd abcd abcd", "def def def def def", qApp->icons()->fromTheme("item-update-all"));
|
||||
}
|
||||
|
||||
FormMain::~FormMain() {
|
||||
|
@ -466,7 +464,7 @@ void FormMain::showWiki() {
|
|||
if (!WebFactory::instance()->openUrlInExternalBrowser(APP_URL_WIKI)) {
|
||||
qApp->showGuiMessage(tr("Cannot open external browser"),
|
||||
tr("Cannot open external browser. Navigate to application website manually."),
|
||||
QSystemTrayIcon::Warning);
|
||||
QSystemTrayIcon::Warning, this, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -474,7 +472,7 @@ void FormMain::reportABugOnGitHub() {
|
|||
if (!WebFactory::instance()->openUrlInExternalBrowser(APP_URL_ISSUES_NEW_GITHUB)) {
|
||||
qApp->showGuiMessage(tr("Cannot open external browser"),
|
||||
tr("Cannot open external browser. Navigate to application website manually."),
|
||||
QSystemTrayIcon::Warning);
|
||||
QSystemTrayIcon::Warning, this, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -482,7 +480,7 @@ void FormMain::reportABugOnBitBucket() {
|
|||
if (!WebFactory::instance()->openUrlInExternalBrowser(APP_URL_ISSUES_NEW_BITBUCKET)) {
|
||||
qApp->showGuiMessage(tr("Cannot open external browser"),
|
||||
tr("Cannot open external browser. Navigate to application website manually."),
|
||||
QSystemTrayIcon::Warning);
|
||||
QSystemTrayIcon::Warning, this, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -490,7 +488,7 @@ void FormMain::donate() {
|
|||
if (!WebFactory::instance()->openUrlInExternalBrowser(APP_DONATE_URL)) {
|
||||
qApp->showGuiMessage(tr("Cannot open external browser"),
|
||||
tr("Cannot open external browser. Navigate to application website manually."),
|
||||
QSystemTrayIcon::Warning);
|
||||
QSystemTrayIcon::Warning, this, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -237,7 +237,7 @@ void FormUpdate::startUpdate() {
|
|||
qApp->showGuiMessage(tr("Cannot update application"),
|
||||
tr("Cannot navigate to installation file. Check new installation downloads manually on project website."),
|
||||
QSystemTrayIcon::Warning,
|
||||
this);
|
||||
this, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -504,7 +504,7 @@ void FeedMessageViewer::showDbCleanupAssistant() {
|
|||
else {
|
||||
qApp->showGuiMessage(tr("Cannot cleanup database"),
|
||||
tr("Cannot cleanup database, because another critical action is running."),
|
||||
QSystemTrayIcon::Warning, this);
|
||||
QSystemTrayIcon::Warning, qApp->mainForm(), true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -520,7 +520,7 @@ void FeedMessageViewer::updateFeeds(QList<FeedsModelFeed *> feeds) {
|
|||
if (!qApp->feedUpdateLock()->tryLock()) {
|
||||
qApp->showGuiMessage(tr("Cannot update all items"),
|
||||
tr("You cannot update all items because another another critical operation is ongoing."),
|
||||
QSystemTrayIcon::Warning, qApp->mainForm());
|
||||
QSystemTrayIcon::Warning, qApp->mainForm(), true);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -244,7 +244,7 @@ void FeedsView::addNewCategory() {
|
|||
// is quitting.
|
||||
qApp->showGuiMessage(tr("Cannot add standard category"),
|
||||
tr("You cannot add new standard category now because another critical operation is ongoing."),
|
||||
QSystemTrayIcon::Warning, qApp->mainForm());
|
||||
QSystemTrayIcon::Warning, qApp->mainForm(), true);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -273,7 +273,7 @@ void FeedsView::addNewFeed() {
|
|||
// is quitting.
|
||||
qApp->showGuiMessage(tr("Cannot add standard feed"),
|
||||
tr("You cannot add new standard feed now because another critical operation is ongoing."),
|
||||
QSystemTrayIcon::Warning, qApp->mainForm());
|
||||
QSystemTrayIcon::Warning, qApp->mainForm(), true);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -338,7 +338,7 @@ void FeedsView::editSelectedItem() {
|
|||
// is quitting.
|
||||
qApp->showGuiMessage(tr("Cannot edit item"),
|
||||
tr("Selected item cannot be edited because another critical operation is ongoing."),
|
||||
QSystemTrayIcon::Warning, qApp->mainForm());
|
||||
QSystemTrayIcon::Warning, qApp->mainForm(), true);
|
||||
|
||||
// Thus, cannot delete and quit the method.
|
||||
return;
|
||||
|
@ -365,7 +365,7 @@ void FeedsView::deleteSelectedItem() {
|
|||
// is quitting.
|
||||
qApp->showGuiMessage(tr("Cannot delete item"),
|
||||
tr("Selected item cannot be deleted because another critical operation is ongoing."),
|
||||
QSystemTrayIcon::Warning, qApp->mainForm());
|
||||
QSystemTrayIcon::Warning, qApp->mainForm(), true);
|
||||
|
||||
// Thus, cannot delete and quit the method.
|
||||
return;
|
||||
|
@ -396,7 +396,7 @@ void FeedsView::deleteSelectedItem() {
|
|||
// or update is undergoing.
|
||||
qApp->showGuiMessage(tr("Deletion of item failed."),
|
||||
tr("Selected item was not deleted due to error."),
|
||||
QSystemTrayIcon::Warning, qApp->mainForm());
|
||||
QSystemTrayIcon::Warning, qApp->mainForm(), true);
|
||||
}
|
||||
|
||||
// Changes are done, unlock the update master lock.
|
||||
|
|
|
@ -41,6 +41,7 @@ Notification::Notification() : QWidget(0), m_title(QString()), m_text(QString())
|
|||
}
|
||||
|
||||
Notification::~Notification() {
|
||||
qDebug("Destroying Notification instance.");
|
||||
}
|
||||
|
||||
bool Notification::areNotificationsActivated() {
|
||||
|
|
|
@ -31,7 +31,7 @@ class Notification : public QWidget {
|
|||
explicit Notification();
|
||||
virtual ~Notification();
|
||||
|
||||
inline static bool areNotificationsActivated();
|
||||
static bool areNotificationsActivated();
|
||||
|
||||
public slots:
|
||||
void notify(const QString &text, const QString &title, const QIcon &icon);
|
||||
|
|
|
@ -132,6 +132,8 @@ int main(int argc, char *argv[]) {
|
|||
|
||||
// Setup single-instance behavior.
|
||||
QObject::connect(&application, SIGNAL(messageReceived(QString)), &application, SLOT(processExecutionMessage(QString)));
|
||||
qApp->showGuiMessage(QSL(APP_NAME), QObject::tr("Welcome to %1 %2.").arg(APP_NAME, APP_VERSION), QSystemTrayIcon::Information,
|
||||
NULL, false, qApp->icons()->fromTheme(APP_LOW_NAME));
|
||||
|
||||
// Enter global event loop.
|
||||
return Application::exec();
|
||||
|
|
|
@ -169,19 +169,27 @@ void Application::deleteTrayIcon() {
|
|||
}
|
||||
|
||||
void Application::showGuiMessage(const QString &title, const QString &message,
|
||||
QSystemTrayIcon::MessageIcon message_type,
|
||||
QWidget *parent, int duration) {
|
||||
/*if (true) {
|
||||
QSystemTrayIcon::MessageIcon message_type, QWidget *parent,
|
||||
bool show_at_least_msgbox, const QIcon &custom_icon) {
|
||||
if (Notification::areNotificationsActivated()) {
|
||||
// Show OSD instead if tray icon bubble, depending on settings.
|
||||
if (custom_icon.isNull()) {
|
||||
notification()->notify(message, title, message_type);
|
||||
}
|
||||
else */if (SystemTrayIcon::isSystemTrayActivated()) {
|
||||
trayIcon()->showMessage(title, message, message_type, duration);
|
||||
}
|
||||
else {
|
||||
notification()->notify(message, title, custom_icon);
|
||||
}
|
||||
}
|
||||
else if (SystemTrayIcon::isSystemTrayActivated()) {
|
||||
trayIcon()->showMessage(title, message, message_type, TRAY_ICON_BUBBLE_TIMEOUT);
|
||||
}
|
||||
else if (show_at_least_msgbox) {
|
||||
// Tray icon or OSD is not available, display simple text box.
|
||||
MessageBox::show(parent, (QMessageBox::Icon) message_type, title, message);
|
||||
}
|
||||
else {
|
||||
qDebug("Silencing GUI message: '%s'.", qPrintable(message));
|
||||
}
|
||||
}
|
||||
|
||||
void Application::onCommitData(QSessionManager &manager) {
|
||||
|
|
|
@ -146,7 +146,7 @@ class Application : public QtSingleApplication {
|
|||
// Displays given simple message in tray icon bubble or OSD
|
||||
// or in message box if tray icon is disabled.
|
||||
void showGuiMessage(const QString &title, const QString &message, QSystemTrayIcon::MessageIcon message_type,
|
||||
QWidget *parent = NULL, int duration = TRAY_ICON_BUBBLE_TIMEOUT);
|
||||
QWidget *parent = NULL, bool show_at_least_msgbox = false, const QIcon &custom_icon = QIcon());
|
||||
|
||||
// Returns pointer to "GOD" application singleton.
|
||||
inline static Application *instance() {
|
||||
|
|
Loading…
Add table
Reference in a new issue