diff --git a/.circleci/config.yml b/.circleci/config.yml index 2b139b3..83bed3a 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -32,6 +32,9 @@ jobs: libxcb-util-dev \ libxcb-cursor-dev \ libxcb1-dev \ + libglib2.0-dev \ + libgtk2.0-dev \ + libnotify-dev \ - run: name: QMake Version command: qmake --version diff --git a/README.md b/README.md index 7875156..307d216 100644 --- a/README.md +++ b/README.md @@ -31,6 +31,7 @@ Additionally, on Linux, you require: * XCB * XCB xfixes * XCB cursor +* libnotify Despite the name implying so, this project does not depend on the KDE API at all. diff --git a/docs/index.md b/docs/index.md index 4904609..c6c60f6 100644 --- a/docs/index.md +++ b/docs/index.md @@ -18,8 +18,11 @@ It has many features, including: * Automatic upload/clipboard copying, * Hotkeys, * Color picker, and last but not least, -* Custom upload destinations -* Upload from clipboard +* Custom upload destinations, +* Upload from clipboard, +* Upload History, +* Crossplatform, +* Windows 10 Darkmode ## Enough talking, show us how it looks The main window is rather simple, with only a log, and a button in it: diff --git a/src/main.cpp b/src/main.cpp index e3b0290..5244152 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -109,6 +109,8 @@ int main(int argc, char *argv[]) { } #endif + notifications::init(); + QCommandLineParser parser; parser.addHelpOption(); diff --git a/src/notifications.cpp b/src/notifications.cpp index ce8aa0a..ff8e07d 100644 --- a/src/notifications.cpp +++ b/src/notifications.cpp @@ -4,6 +4,21 @@ #include "ui_mainwindow.h" #include +#ifdef Q_OS_LINUX +#undef signals +extern "C" +{ +#include +} +#define signals public +#endif + +void notifications::init() { +#ifdef Q_OS_LINUX + notify_init("KShare"); +#endif +} + void notifications::notify(QString title, QString body, QSystemTrayIcon::MessageIcon icon) { if (!MainWindow::inst() || !MainWindow::inst()->valid()) return; notifyNolog(title, body, icon); @@ -11,7 +26,30 @@ void notifications::notify(QString title, QString body, QSystemTrayIcon::Message } void notifications::notifyNolog(QString title, QString body, QSystemTrayIcon::MessageIcon icon) { +#ifdef Q_OS_LINUX + NotifyNotification *n = notify_notification_new(title.toLocal8Bit(), body.toLocal8Bit(), 0); + notify_notification_set_timeout(n, 5000); + + NotifyUrgency urgency; + switch(icon) { + case QSystemTrayIcon::Warning: + urgency = NotifyUrgency::NOTIFY_URGENCY_NORMAL; + break; + + case QSystemTrayIcon::Critical: + urgency = NotifyUrgency::NOTIFY_URGENCY_CRITICAL; + break; + + default: + urgency = NotifyUrgency::NOTIFY_URGENCY_LOW; + break; + } + + notify_notification_set_urgency(n, urgency); + notify_notification_show(n, 0); +#else if (!MainWindow::inst()) return; MainWindow::inst()->tray->showMessage(title, body, icon, 5000); +#endif MainWindow::inst()->statusBar()->showMessage(title + ": " + body); } diff --git a/src/notifications.hpp b/src/notifications.hpp index 75306be..9acceac 100644 --- a/src/notifications.hpp +++ b/src/notifications.hpp @@ -5,6 +5,7 @@ #include namespace notifications { + void init(); void notify(QString title, QString body, QSystemTrayIcon::MessageIcon icon = QSystemTrayIcon::Information); void notifyNolog(QString title, QString body, QSystemTrayIcon::MessageIcon icon = QSystemTrayIcon::Information); } // namespace notifications diff --git a/src/src.pro b/src/src.pro index 42adc08..184c239 100644 --- a/src/src.pro +++ b/src/src.pro @@ -146,6 +146,9 @@ nopkg { } else { CONFIG += link_pkgconfig PKGCONFIG += libavformat libavcodec libswscale libavutil + unix { + PKGCONFIG += libnotify + } } mac {