diff --git a/CMakeLists.txt b/CMakeLists.txt index 27a896e..2bc3d09 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.8.11) +cmake_minimum_required(VERSION 3.0.2 FATAL_ERROR) project(lxqt-notificationd) @@ -7,6 +7,7 @@ option(UPDATE_TRANSLATIONS "Update source translation translations/*.ts files" O set(CMAKE_INCLUDE_CURRENT_DIR ON) set(CMAKE_POSITION_INDEPENDENT_CODE ON) set(CMAKE_AUTOMOC ON) +set(CMAKE_AUTOUIC ON) find_package(Qt5Widgets REQUIRED QUIET) find_package(Qt5DBus REQUIRED QUIET) @@ -14,11 +15,9 @@ find_package(Qt5LinguistTools REQUIRED QUIET) find_package(KF5WindowSystem REQUIRED QUIET) find_package(lxqt REQUIRED QUIET) -find_package(qt5xdg REQUIRED) - -include(${LXQT_USE_FILE}) -include(${QTXDG_USE_FILE}) +include(GNUInstallDirs) +include(LXQtCompilerSettings NO_POLICY_SCOPE) include(LXQtTranslate) add_subdirectory(src) diff --git a/config/CMakeLists.txt b/config/CMakeLists.txt index c727e7c..4b35bb9 100644 --- a/config/CMakeLists.txt +++ b/config/CMakeLists.txt @@ -1,10 +1,5 @@ project(lxqt-config-notificationd) -include_directories ( - "${CMAKE_CURRENT_BINARY_DIR}" - "${CMAKE_CURRENT_SOURCE_DIR}" -) - set(NOTIFICATIONS_CONF_SRC advancedsettings.cpp basicsettings.cpp @@ -19,8 +14,9 @@ set(NOTIFICATIONS_CONF_UI # Translations ********************************** -lxqt_translate_ts(NOTIFICATIONS_CONF_QM SOURCES +lxqt_translate_ts(NOTIFICATIONS_CONF_QM UPDATE_TRANSLATIONS ${UPDATE_TRANSLATIONS} + SOURCES ${NOTIFICATIONS_CONF_MOC} ${NOTIFICATIONS_CONF_SRC} ${NOTIFICATIONS_CONF_UI} @@ -31,11 +27,9 @@ lxqt_app_translation_loader(QM_LOADER ${PROJECT_NAME}) lxqt_translate_desktop(DESKTOP_FILES SOURCES lxqt-config-notificationd.desktop.in) #************************************************ -qt5_wrap_ui(NOTIFICATIONS_CONF_UI_CPP ${NOTIFICATIONS_CONF_UI}) add_executable(${PROJECT_NAME} ${NOTIFICATIONS_CONF_SRC} - ${NOTIFICATIONS_CONF_UI_CPP} ${NOTIFICATIONS_CONF_QM} ${DESKTOP_FILES} ${QM_LOADER} @@ -44,8 +38,16 @@ add_executable(${PROJECT_NAME} target_link_libraries(${PROJECT_NAME} KF5::WindowSystem Qt5::Widgets - ${LXQT_LIBRARIES} + lxqt ) -install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION bin) -install(FILES ${DESKTOP_FILES} DESTINATION "${CMAKE_INSTALL_PREFIX}/share/applications") +install(TARGETS + ${PROJECT_NAME} + RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" + COMPONENT Runtime +) +install(FILES + ${DESKTOP_FILES} + DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/applications" + COMPONENT Runtime +) diff --git a/config/advancedsettings.ui b/config/advancedsettings.ui index a2de59f..a5935dc 100644 --- a/config/advancedsettings.ui +++ b/config/advancedsettings.ui @@ -92,6 +92,9 @@ sec + + 7200 + diff --git a/config/basicsettings.cpp b/config/basicsettings.cpp index 7604d8c..9524f9f 100644 --- a/config/basicsettings.cpp +++ b/config/basicsettings.cpp @@ -39,28 +39,26 @@ BasicSettings::BasicSettings(LxQt::Settings* settings, QWidget *parent) : restoreSettings(); - connect(topLeftButton, SIGNAL(clicked()), this, SLOT(updateNotification())); - connect(topRightButton, SIGNAL(clicked()), this, SLOT(updateNotification())); - connect(bottomRightButton, SIGNAL(clicked()), this, SLOT(updateNotification())); - connect(bottomLeftButton, SIGNAL(clicked()), this, SLOT(updateNotification())); + connect(topLeftRB, SIGNAL(clicked()), this, SLOT(updateNotification())); + connect(topCenterRB, SIGNAL(clicked()), this, SLOT(updateNotification())); + connect(topRightRB, SIGNAL(clicked()), this, SLOT(updateNotification())); + connect(centerLeftRB, SIGNAL(clicked()), this, SLOT(updateNotification())); + connect(centerCenterRB, SIGNAL(clicked()), this, SLOT(updateNotification())); + connect(centerRightRB, SIGNAL(clicked()), this, SLOT(updateNotification())); + connect(bottomLeftRB, SIGNAL(clicked()), this, SLOT(updateNotification())); + connect(bottomCenterRB, SIGNAL(clicked()), this, SLOT(updateNotification())); + connect(bottomRightRB, SIGNAL(clicked()), this, SLOT(updateNotification())); LxQt::Notification serverTest; QString serverName = serverTest.serverInfo().name; if (serverName != "lxqt-notificationd") { if (serverName.isEmpty()) - { - warningLabel->setText(tr( - "Warning: No notifications daemon is running.\n" - "A fallback will be used.")); - } + warningLabel->setText(tr("Warning: No notifications daemon is running.\n" + "A fallback will be used.")); else - { - warningLabel->setText(tr( - "Warning: A third-party notifications daemon (%1) is running.\n" - "These settings won't have any effect on it!" - ).arg(serverName)); - } + warningLabel->setText(tr("Warning: A third-party notifications daemon (%1) is running.\n" + "These settings won't have any effect on it!").arg(serverName)); } } @@ -70,33 +68,53 @@ BasicSettings::~BasicSettings() void BasicSettings::restoreSettings() { - QString placement = mSettings->value("placement", "bottom-right").toString().toLower(); - if (placement == "bottom-right") - bottomRightButton->setChecked(true); - else if (placement == "bottom-left") - bottomLeftButton->setChecked(true); - else if (placement == "top-right") - topRightButton->setChecked(true); - else if (placement == "top-left") - topLeftButton->setChecked(true); - else - bottomRightButton->setChecked(true); + QString placement = mSettings->value(QStringLiteral("placement"), + QStringLiteral("bottom-right")).toString().toLower(); + + if (QStringLiteral("top-left") == placement) + topLeftRB->setChecked(true); + else if (QStringLiteral("top-center") == placement) + topCenterRB->setChecked(true); + else if (QStringLiteral("top-right") == placement) + topRightRB->setChecked(true); + else if (QStringLiteral("center-left") == placement) + centerLeftRB->setChecked(true); + else if (QStringLiteral("center-center") == placement) + centerCenterRB->setChecked(true); + else if (QStringLiteral("center-right") == placement) + centerRightRB->setChecked(true); + else if (QStringLiteral("bottom-left") == placement) + bottomLeftRB->setChecked(true); + else if (QStringLiteral("bottom-center") == placement) + bottomCenterRB->setChecked(true); + else if (QStringLiteral("bottom-right") == placement) + bottomRightRB->setChecked(true); } void BasicSettings::updateNotification() { - if (bottomRightButton->isChecked()) - mSettings->setValue("placement", "bottom-right"); - else if (bottomLeftButton->isChecked()) - mSettings->setValue("placement", "bottom-left"); - else if (topRightButton->isChecked()) - mSettings->setValue("placement", "top-right"); - else if (topLeftButton->isChecked()) - mSettings->setValue("placement", "top-left"); + QString align; + if (topLeftRB->isChecked()) + align = QStringLiteral("top-left"); + else if (topCenterRB->isChecked()) + align = QStringLiteral("top-center"); + else if (topRightRB->isChecked()) + align = QStringLiteral("top-right"); + else if (centerLeftRB->isChecked()) + align = QStringLiteral("center-left"); + else if (centerCenterRB->isChecked()) + align = QStringLiteral("center-center"); + else if (centerRightRB->isChecked()) + align = QStringLiteral("center-right"); + else if (bottomLeftRB->isChecked()) + align = QStringLiteral("bottom-left"); + else if (bottomCenterRB->isChecked()) + align = QStringLiteral("bottom-center"); + else // if (bottomRightRB->isChecked()) + align = QStringLiteral("bottom-right"); - LxQt::Notification::notify(//"lxqt-config-notificationd", - tr("Notification demo"), - tr("This is a test notification.\n" - "All notifications will now appear here on LXQt."), - "lxqt-logo.png"); + mSettings->setValue(QStringLiteral("placement"), align); + LxQt::Notification::notify(tr("Notification demo ") + align, + tr("This is a test notification.\n All notifications will now appear here on LXQt."), + QStringLiteral("lxqt-logo.png")); } diff --git a/config/basicsettings.ui b/config/basicsettings.ui index f1ed060..c7bccb3 100644 --- a/config/basicsettings.ui +++ b/config/basicsettings.ui @@ -6,12 +6,12 @@ 0 0 - 244 - 218 + 148 + 179 - - + + @@ -24,44 +24,144 @@ - + Position on screen + + Qt::AlignCenter + - - + + + + + + + true + + + buttonGroup + + + + + + + + + + buttonGroup + + + + + - Top/Left + + + buttonGroup + - + + + Qt::Horizontal + + + QSizePolicy::Expanding + + + + 40 + 20 + + + + + + + + + + + buttonGroup + + + + + + + + + + buttonGroup + + + + + - Top/Right + + + buttonGroup + + + + + + + + + + buttonGroup + - + - Bottom/Left + + + buttonGroup + - - + + - Bottom/Right + + + buttonGroup + + + + + Qt::Horizontal + + + QSizePolicy::Expanding + + + + 40 + 20 + + + + - + Qt::Vertical @@ -74,7 +174,7 @@ - + true @@ -85,4 +185,7 @@ + + + diff --git a/config/translations/lxqt-config-notificationd.ts b/config/translations/lxqt-config-notificationd.ts index 312c575..7639f62 100644 --- a/config/translations/lxqt-config-notificationd.ts +++ b/config/translations/lxqt-config-notificationd.ts @@ -1,105 +1,100 @@ - + AdvancedSettings - Menu Configuration - - - - Notification Duration + + Sizes - For some the notification's expiration time is dependent on the notification server's settings. + + Width: - "Server Decides" Time: + + + px - sec + + Spacing: - Sizes + + Duration - Notification Spacing: + + Some notifications set their own on-screen duration. - px + + Default duration: - Notification Width: + + sec BasicSettings + Basic Settings - Display Notifications - - - - Top/Left - - - - Top/Right - - - - Bottom/Left - - - - Bottom/Right - - - - Test Notification + + Position on screen + <b>Warning:</b> No notifications daemon is running. A fallback will be used. + <b>Warning:</b> A third-party notifications daemon (%1) is running. -These settings won't have an effect on it! +These settings won't have any effect on it! - Notification Summary + + Notification demo - Notification Body + + This is a test notification. + All notifications will now appear here on LXQt. MainWindow + Desktop Notifications + Basic Settings + Advanced Settings diff --git a/config/translations/lxqt-config-notificationd_de.desktop b/config/translations/lxqt-config-notificationd_de.desktop index ed6016c..0d5df10 100644 --- a/config/translations/lxqt-config-notificationd_de.desktop +++ b/config/translations/lxqt-config-notificationd_de.desktop @@ -1,3 +1,4 @@ # Translations -GenericName[de]=LxQt Konfigurations Center -Name[de]=LxQt Konfiguration +Name[de]=Mitteilungen der Arbeitsfläche +GenericName[de]=LxQt Mitteilungseinstellungen +Comment[de]=Konfiguration von Benachrichtigungen \ No newline at end of file diff --git a/config/translations/lxqt-config-notificationd_de.ts b/config/translations/lxqt-config-notificationd_de.ts new file mode 100644 index 0000000..9cc4b18 --- /dev/null +++ b/config/translations/lxqt-config-notificationd_de.ts @@ -0,0 +1,105 @@ + + + + + AdvancedSettings + + + Sizes + Größen + + + + Width: + Breite: + + + + + px + px + + + + Spacing: + Abstand: + + + + Duration + Dauer + + + + Some notifications set their own on-screen duration. + Einige Benachrichtigungen setzen ihre eigene Anzeigedauer. + + + + Default duration: + Standarddauer: + + + + sec + s + + + + BasicSettings + + + Basic Settings + Grundeinstellungen + + + + Position on screen + Position auf dem Bildschirm + + + + <b>Warning:</b> No notifications daemon is running. +A fallback will be used. + <b>Warnung:</b> Es läuft kein Benachrichtigungsdaemon. +Ein Ersatz wird verwendet. + + + + <b>Warning:</b> A third-party notifications daemon (%1) is running. +These settings won't have any effect on it! + <b>Warnung:</b> Ein anderer Benachrichtigungsdaemon (%1) läuft. +Diese Einstellungen wirken sich auf ihn nicht aus! + + + + Notification demo + Testbenachrichtigung + + + + This is a test notification. + All notifications will now appear here on LXQt. + Dies ist eine Testbenachrichtigung. +Alle Benachrichtigungen erscheinen jetzt hier auf LXQt. + + + + MainWindow + + + Desktop Notifications + Arbeitsflächenbenachrichtigungen + + + + Basic Settings + Grundeinstellungen + + + + Advanced Settings + Erweiterte Einstellungen + + + diff --git a/config/translations/lxqt-config-notificationd_de_DE.desktop b/config/translations/lxqt-config-notificationd_de_DE.desktop deleted file mode 100644 index a6dc2b9..0000000 --- a/config/translations/lxqt-config-notificationd_de_DE.desktop +++ /dev/null @@ -1,4 +0,0 @@ -# Translations -GenericName[de_DE]=Anwendungsmenü -Name[de_DE]=LxQt Freedesktop Mitteilungen Konfiguration -Comment[de_DE]=Freedesktop Mitteilungen für LxQt Desktop konfigurieren diff --git a/config/translations/lxqt-config-notificationd_fr_FR.desktop b/config/translations/lxqt-config-notificationd_fr_FR.desktop index db31011..d6d9511 100644 --- a/config/translations/lxqt-config-notificationd_fr_FR.desktop +++ b/config/translations/lxqt-config-notificationd_fr_FR.desktop @@ -1,3 +1,3 @@ # Translations -GenericName[fr_FR]=Bloc-notes -Name[fr_FR]=Paramétreur de session LxQt +GenericName[fr_FR]=Paramétrage des notifications du bureau +Name[fr_FR]=Paramétrage notifications diff --git a/config/translations/lxqt-config-notificationd_hr.ts b/config/translations/lxqt-config-notificationd_hr.ts new file mode 100644 index 0000000..b0eec30 --- /dev/null +++ b/config/translations/lxqt-config-notificationd_hr.ts @@ -0,0 +1,107 @@ + + + + + AdvancedSettings + + Menu Configuration + Konfiguracija izbornika + + + Notification Duration + Trajanje obavijesti + + + For some the notification's expiration time is dependent on the notification server's settings. + Za neke obavijesti's vrijeme istjecanja ovisi o postavkama poslužitelja's obavijesti + + + "Server Decides" Time: + + + + sec + sek + + + Sizes + Veličine + + + Notification Spacing: + Razmak obavijesti + + + px + px + + + Notification Width: + Širina obavijesti + + + + BasicSettings + + Basic Settings + Osnovne postavke + + + Display Notifications + Prikaži obavijesti + + + Top/Left + Gore/lijevo + + + Top/Right + Gore/desno + + + Bottom/Left + Dolje/lijevo + + + Bottom/Right + Dolje/desno + + + Test Notification + Isprobaj obavijesti + + + <b>Warning:</b> No notifications daemon is running. +A fallback will be used. + + + + <b>Warning:</b> A third-party notifications daemon (%1) is running. +These settings won't have an effect on it! + + + + Notification Summary + Sažetak obavijesti + + + Notification Body + + + + + MainWindow + + Desktop Notifications + Obavijesti radne površine + + + Basic Settings + Osnovne postavke + + + Advanced Settings + Napredne postavke + + + diff --git a/config/translations/lxqt-config-notificationd_hu.desktop b/config/translations/lxqt-config-notificationd_hu.desktop index 317b8e0..49b8771 100644 --- a/config/translations/lxqt-config-notificationd_hu.desktop +++ b/config/translations/lxqt-config-notificationd_hu.desktop @@ -1,4 +1,4 @@ # Translations -GenericName[hu]=Alkalmazásmenü -Name[hu]=LxQt beállítóközpont -Comment[hu]=A Freedesktop értesítések beállítása +GenericName[hu]=Az asztali értesítések beállítása +Name[hu]=LxQt értesítések beállítása +Comment[hu]=A felbukkanó értesítések beállítása diff --git a/config/translations/lxqt-config-notificationd_hu.ts b/config/translations/lxqt-config-notificationd_hu.ts new file mode 100644 index 0000000..933817b --- /dev/null +++ b/config/translations/lxqt-config-notificationd_hu.ts @@ -0,0 +1,125 @@ + + + + + AdvancedSettings + + + Sizes + Méret + + + + Width: + Szélesség: + + + + + px + pixel + + + + Spacing: + Térköz: + + + + Duration + Tartam + + + + Some notifications set their own on-screen duration. + Egyes értesítések megjelenési ideje + + + + Default duration: + Alapértelmezett tartam: + + + + sec + mp + + + + BasicSettings + + + Basic Settings + Alapbeállítások + + + + Position on screen + Hely + + + + Top/Left + Balra fenn + + + + Top/Right + Jobbra fenn + + + + Bottom/Left + Balra lenn + + + + Bottom/Right + Jobbra lenn + + + + <b>Warning:</b> No notifications daemon is running. +A fallback will be used. + <b>Figyelem:</b> Értesítő démon nem fut. +A vésztartalék használatos. + + + + <b>Warning:</b> A third-party notifications daemon (%1) is running. +These settings won't have any effect on it! + <b>Figyelem:</b> A (%1) démont már valaki futtatja. +Ezek a beállítások arra már hatástalanok! + + + + Notification demo + Értesítési bemutató + + + + This is a test notification. +All notifications will now appear here on LXQt. + Az értesítés tesztje +Minden értesítést megjelenít az LXQt. + + + + MainWindow + + + Desktop Notifications + Asztali értesítések + + + + Basic Settings + Alapbeállítások + + + + Advanced Settings + Haladó beállítások + + + diff --git a/config/translations/lxqt-config-notificationd_it.desktop b/config/translations/lxqt-config-notificationd_it.desktop index 29d9a92..37234f7 100644 --- a/config/translations/lxqt-config-notificationd_it.desktop +++ b/config/translations/lxqt-config-notificationd_it.desktop @@ -1,3 +1,4 @@ # Translations -GenericName[it]=Centro di Configurazione LxQt -Name[it]=Configura LxQt +GenericName[it]=Notifiche +Name[it]=Configura notifiche +Comment[it]=Configura le notifiche Freedesktop del Desktop LxQt diff --git a/config/translations/lxqt-config-notificationd_it.ts b/config/translations/lxqt-config-notificationd_it.ts new file mode 100644 index 0000000..40c4b68 --- /dev/null +++ b/config/translations/lxqt-config-notificationd_it.ts @@ -0,0 +1,110 @@ + + + + + AdvancedSettings + + Menu Configuration + Configurazione del menu + + + Notification Duration + Durata delle notifiche + + + For some the notification's expiration time is dependent on the notification server's settings. + Per alcune notifiche il tempo dipende dalle impostazioni del server delle notifiche. + + + "Server Decides" Time: + Tempo di decisioni del server: + + + sec + sec + + + Sizes + Dimensione + + + Notification Spacing: + a cosa si riferisce?? + Spazing: + + + px + + + + Notification Width: + Larghezza: + + + + BasicSettings + + Basic Settings + Impostazioni base + + + Display Notifications + Mostra notifiche + + + Top/Left + Alto a sinistra + + + Top/Right + Alto a destra + + + Bottom/Left + Fondo a sinistra + + + Bottom/Right + Fondo a destra + + + Test Notification + Notifica di prova + + + <b>Warning:</b> No notifications daemon is running. +A fallback will be used. + <b>Attenzione:</b> Nessun demone di notifiche è in esecuzione. +Sarà usato un sistema di riserva. + + + <b>Warning:</b> A third-party notifications daemon (%1) is running. +These settings won't have an effect on it! + <b>Attenzione:</b> Un altro demone di notifiche (%1) è in esecuzione. +Queste impostazioni non avranno effetto su quello! + + + Notification Summary + Sommario della notifica + + + Notification Body + Corpo della notifica + + + + MainWindow + + Desktop Notifications + Notificazioni Desktop + + + Basic Settings + Impostazioni base + + + Advanced Settings + Impostazioni avanzate + + + diff --git a/config/translations/lxqt-config-notificationd_it_IT.desktop b/config/translations/lxqt-config-notificationd_it_IT.desktop deleted file mode 100644 index 7746944..0000000 --- a/config/translations/lxqt-config-notificationd_it_IT.desktop +++ /dev/null @@ -1,4 +0,0 @@ -# Translations -GenericName[it_IT]=Esci -Name[it_IT]=Esci dal sistema -Comment[it_IT]=Configura le notifiche freedesktop nel desktop LxQt diff --git a/config/translations/lxqt-config-notificationd_ru_RU.desktop b/config/translations/lxqt-config-notificationd_ru_RU.desktop index ddec0f4..28c075a 100644 --- a/config/translations/lxqt-config-notificationd_ru_RU.desktop +++ b/config/translations/lxqt-config-notificationd_ru_RU.desktop @@ -1,4 +1,4 @@ # Translations -GenericName[ru]=Настройки уведомлений LxQt -Name[ru]=Уведомления рабочего стола -Comment[ru]=Настроить уведомления рабочего стола \ No newline at end of file +GenericName[ru_RU]=Настройки уведомлений LxQt +Name[ru_RU]=Уведомления рабочего стола +Comment[ru_RU]=Настроить уведомления рабочего стола diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 998243d..4ec25a1 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,8 +1,3 @@ -include_directories( - "${CMAKE_CURRENT_SOURCE_DIR}" - "${CMAKE_CURRENT_BINARY_DIR}" -) - set(NOTIFICATIONS_SRC main.cpp notificationarea.cpp @@ -16,15 +11,15 @@ set(NOTIFICATIONS_UI notification.ui ) -qt5_wrap_ui(NOTIFICATIONS_UI_CPP ${NOTIFICATIONS_UI}) qt5_add_dbus_adaptor(NOTIFICATIONS_SRC org.freedesktop.Notifications.xml notifyd.h Notifyd ) # Translations ********************************** -lxqt_translate_ts(NOTIFICATIONS_QM_FILES SOURCES +lxqt_translate_ts(NOTIFICATIONS_QM_FILES UPDATE_TRANSLATIONS ${UPDATE_TRANSLATIONS} + SOURCES ${NOTIFICATIONS_SRC} ${NOTIFICATIONS_UI} INSTALL_DIR "${LXQT_TRANSLATIONS_DIR}/${PROJECT_NAME}" @@ -35,7 +30,6 @@ lxqt_app_translation_loader(QM_LOADER ${PROJECT_NAME}) add_executable(lxqt-notificationd ${NOTIFICATIONS_SRC} - ${NOTIFICATIONS_UI_CPP} ${NOTIFICATIONS_QM_FILES} ${QM_LOADER} ) @@ -43,9 +37,12 @@ add_executable(lxqt-notificationd target_link_libraries(lxqt-notificationd Qt5::Widgets Qt5::DBus - ${QTXDG_LIBRARIES} - ${LXQT_LIBRARIES} + lxqt KF5::WindowSystem ) -install(TARGETS lxqt-notificationd RUNTIME DESTINATION bin) +install(TARGETS + lxqt-notificationd + RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" + COMPONENT Runtime +) diff --git a/src/main.cpp b/src/main.cpp index 39e4fba..fd2248b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -34,7 +34,7 @@ #include "notifyd.h" -/*! \mainpage LXDE-Qt notification daemon +/*! \mainpage LXQt notification daemon * * Running in user session; implementing standard as described in: * docs/nodification-spec-latest.html @@ -74,7 +74,7 @@ int main(int argc, char** argv) "NotificationArea {background: transparent;}" "NotificationLayout {background: transparent;}" ); - + Notifyd* daemon = new Notifyd(); new NotificationsAdaptor(daemon); @@ -84,6 +84,5 @@ int main(int argc, char** argv) if (!connection.registerObject("/org/freedesktop/Notifications", daemon)) qDebug() << "registerObject failed: another object with '/org/freedesktop/Notifications' runs already"; - return a.exec(); } diff --git a/src/notification.cpp b/src/notification.cpp index bc0fd25..7d5b2e6 100644 --- a/src/notification.cpp +++ b/src/notification.cpp @@ -32,7 +32,7 @@ #include #include #include -#include +#include #include "notification.h" #include "notificationwidgets.h" @@ -109,21 +109,27 @@ void Notification::setValues(const QString &application, iconLabel->setPixmap(m_pixmap); iconLabel->show(); } + //XXX: workaround to properly set text labels widths (for correct sizeHints after setText) + adjustSize(); // application - appLabel->setVisible(!application.isEmpty()); + appLabel->setVisible(!application.isEmpty()); + appLabel->setFixedWidth(appLabel->width()); appLabel->setText(application); // summary - summaryLabel->setVisible(!summary.isEmpty()); + summaryLabel->setVisible(!summary.isEmpty() && application != summary); + summaryLabel->setFixedWidth(summaryLabel->width()); summaryLabel->setText(summary); - if (application == summary) - summaryLabel->setVisible(false); - // body bodyLabel->setVisible(!body.isEmpty()); - bodyLabel->setText(body); + bodyLabel->setFixedWidth(bodyLabel->width()); + //https://developer.gnome.org/notification-spec + //Body - This is a multi-line body of text. Each line is a paragraph, server implementations are free to word wrap them as they see fit. + //XXX: remove all unsupported tags?!? (supported , , , , ) + QString formatted(body); + bodyLabel->setText(formatted.replace('\n', QStringLiteral("
"))); // Timeout // Special values: @@ -225,7 +231,14 @@ QPixmap Notification::getPixmapFromHint(const QVariant &argument) const arg >> channels; arg >> data; arg.endStructure(); - QImage img = QImage((uchar*)data.constData(), width, height, QImage::Format_ARGB32).rgbSwapped(); + + bool rgb = !hasAlpha && channels == 3 && bitsPerSample == 8; + QImage::Format imageFormat = rgb ? QImage::Format_RGB888 : QImage::Format_ARGB32; + + QImage img = QImage((uchar*)data.constData(), width, height, imageFormat); + + if (!rgb) + img = img.rgbSwapped(); return QPixmap::fromImage(img); } @@ -310,7 +323,7 @@ void NotificationTimer::pause() return; stop(); - m_intervalMsec = m_startTime.msecsTo(QDateTime()); + m_intervalMsec = m_startTime.msecsTo(QDateTime::currentDateTime()); } void NotificationTimer::resume() diff --git a/src/notification.h b/src/notification.h index 35c69d8..bd9d289 100644 --- a/src/notification.h +++ b/src/notification.h @@ -86,7 +86,7 @@ protected: - if there is one action or at least one default action, this default action is triggered on click. \see NotificationActionsWidget::hasDefaultAction() - \see NotificationActionsWidget::defaultAction() + \see NotificationActionsWidget::defaultAction() - it tries to find caller window by a) application name. \see XfitMan::getApplicationName() b) window title. \see XfitMan::getWindowTitle() diff --git a/src/notificationarea.cpp b/src/notificationarea.cpp index 7314e64..27d6852 100644 --- a/src/notificationarea.cpp +++ b/src/notificationarea.cpp @@ -78,38 +78,44 @@ void NotificationArea::setHeight(int contentHeight) // I think it's a bug of Qt. QRect workArea = qApp->desktop()->availableGeometry(qApp->desktop()->primaryScreen()); - int h = workArea.height(); - int safeHeight = contentHeight > h ? h : contentHeight; - int x, y; - - if (m_placement == "bottom-right") + workArea -= QMargins(m_spacing, m_spacing, m_spacing, m_spacing); + QRect notif_rect = workArea.normalized(); + notif_rect.setWidth(width()); + if (notif_rect.height() > contentHeight) + notif_rect.setHeight(contentHeight); + + // no move needed for "top-left" + if ("top-center" == m_placement) { - x = workArea.right() - width() - m_spacing; - y = workArea.bottom() - safeHeight - m_spacing; - } - else if (m_placement == "bottom-left") + notif_rect.moveCenter(workArea.center()); + notif_rect.moveTop(workArea.top()); + } else if ("top-right" == m_placement) { - x = workArea.x() + m_spacing; - y = workArea.bottom() - safeHeight - m_spacing; - } - else if (m_placement == "top-right") + notif_rect.moveRight(workArea.right()); + } else if ("center-left" == m_placement) { - x = workArea.right() - width() - m_spacing; - y = workArea.y() + m_spacing; - } - else if (m_placement == "top-left") + notif_rect.moveCenter(workArea.center()); + notif_rect.moveLeft(workArea.left()); + } else if ("center-center" == m_placement) { - x = workArea.x() + m_spacing; - y = workArea.y() + m_spacing; - } - else + notif_rect.moveCenter(workArea.center()); + } else if ("center-right" == m_placement) + { + notif_rect.moveCenter(workArea.center()); + notif_rect.moveRight(workArea.right()); + } else if ("bottom-left" == m_placement) + { + notif_rect.moveBottom(workArea.bottom()); + } else if ("bottom-center" == m_placement) + { + notif_rect.moveCenter(workArea.center()); + notif_rect.moveBottom(workArea.bottom()); + } else if ("bottom-right" == m_placement) { - x = workArea.right() - width() - m_spacing; - y = workArea.bottom() - safeHeight; + notif_rect.moveBottomRight(workArea.bottomRight()); } - move(x, y); - resize(width(), safeHeight); + setGeometry(notif_rect); // always show the latest notification ensureVisible(0, contentHeight, 0, 0); } diff --git a/src/notificationlayout.cpp b/src/notificationlayout.cpp index 63f9efb..601c133 100644 --- a/src/notificationlayout.cpp +++ b/src/notificationlayout.cpp @@ -41,7 +41,7 @@ NotificationLayout::NotificationLayout(QWidget *parent) setPalette(palette); // Required to display wallpaper setAttribute(Qt::WA_TranslucentBackground); - + // Make the window stay on top setWindowFlags(windowFlags() | Qt::WindowStaysOnTopHint); diff --git a/src/translations/lxqt-notificationd_de.ts b/src/translations/lxqt-notificationd_de.ts new file mode 100644 index 0000000..d0fc59d --- /dev/null +++ b/src/translations/lxqt-notificationd_de.ts @@ -0,0 +1,15 @@ + + + + + NotificationActionsComboWidget + + Actions: + Aktionen: + + + OK + OK + + + diff --git a/src/translations/lxqt-notificationd_hu.ts b/src/translations/lxqt-notificationd_hu.ts new file mode 100644 index 0000000..a168107 --- /dev/null +++ b/src/translations/lxqt-notificationd_hu.ts @@ -0,0 +1,15 @@ + + + + + NotificationActionsComboWidget + + Actions: + Akciók: + + + OK + + + + diff --git a/test/mainwindow.h b/test/mainwindow.h index 5f7f596..6be53c7 100644 --- a/test/mainwindow.h +++ b/test/mainwindow.h @@ -36,7 +36,7 @@ class MainWindow; class MainWindow : public QMainWindow { Q_OBJECT - + public: explicit MainWindow(QWidget* parent = 0); ~MainWindow();