Skip to content

Commit

Permalink
feat(notificationd): enable notificationd module and update to Qt6/KF6
Browse files Browse the repository at this point in the history
  • Loading branch information
elysia-best committed Nov 29, 2024
1 parent 63adec4 commit 582e8cf
Show file tree
Hide file tree
Showing 13 changed files with 50 additions and 45 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ add_subdirectory(powerman)
add_subdirectory(cpufreq)
add_subdirectory(cupdatecursor)
add_subdirectory(gmenuproxy)
# add_subdirectory(notificationd)
add_subdirectory(notificationd)
# add_subdirectory(sddm-helper)
# add_subdirectory(clipboard)
# add_subdirectory(chotkeys)
Expand Down
16 changes: 8 additions & 8 deletions notificationd/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ set(SRCS main.cpp
# for Ubuntu
# qt_add_dbus_adaptor(SRCS org.freedesktop.Notifications.xml notificationserver.h NotificationServer)

qt5_add_dbus_adaptor(DBUS_SOURCES com.lingmo.Notification.xml application.h Application)
qt_add_dbus_adaptor(DBUS_SOURCES com.lingmo.Notification.xml application.h Application)
set_source_files_properties(${DBUS_SOURCES} PROPERTIES SKIP_AUTOGEN ON)

find_package(KF5WindowSystem)
find_package(KF6WindowSystem)

add_executable(lingmo-notificationd ${SRCS} ${DBUS_SOURCES})

Expand All @@ -29,14 +29,14 @@ foreach(filepath ${TS_FILES})
string(REPLACE "${CMAKE_CURRENT_SOURCE_DIR}/" "" filename ${filepath})
list(APPEND ts_files_replaced ${filename})
endforeach()
qt5_create_translation(QM_FILES ${CMAKE_CURRENT_SOURCE_DIR} ${ts_files_replaced})
qt6_create_translation(QM_FILES ${CMAKE_CURRENT_SOURCE_DIR} ${ts_files_replaced})

target_link_libraries(lingmo-notificationd
Qt5::Core
Qt5::DBus
Qt5::Quick
Qt5::Widgets
KF5::WindowSystem
Qt6::Core
Qt6::DBus
Qt6::Quick
Qt6::Widgets
KF6::WindowSystem
)

install(TARGETS lingmo-notificationd
Expand Down
4 changes: 3 additions & 1 deletion notificationd/datehelper.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "datehelper.h"
#include <QDateTime>
#include <qlocale.h>

DateHelper::DateHelper(QObject *parent) : QObject(parent)
{
Expand Down Expand Up @@ -30,5 +31,6 @@ QString DateHelper::friendlyTime(const QDateTime &time)
else if (days <= 10)
return tr("%1 days ago").arg(days);

return time.toString(Qt::DefaultLocaleShortDate);
QLocale cLocale;
return cLocale.toString(time, QLocale::FormatType::LongFormat);
}
15 changes: 7 additions & 8 deletions notificationd/dbus/notificationsadaptor.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,13 @@
#include <QtCore/QObject>
#include <QtDBus/QtDBus>
#include "notificationserver.h"
QT_BEGIN_NAMESPACE
class QByteArray;
template<class T> class QList;
template<class Key, class Value> class QMap;
class QString;
class QStringList;
class QVariant;
QT_END_NAMESPACE

#include <QByteArray>
#include <QList>
#include <QMap>
#include <QString>
#include <QStringList>
#include <QVariant>

/*
* Adaptor class for interface org.freedesktop.Notifications
Expand Down
6 changes: 3 additions & 3 deletions notificationd/historymodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <QSettings>
#include <QDataStream>
#include <QMetaEnum>
#include <qflags.h>

static HistoryModel *s_historyModel = nullptr;

Expand Down Expand Up @@ -136,8 +137,7 @@ void HistoryModel::save()
settings.clear();

QByteArray datas;
QDataStream out(&datas, QIODevice::WriteOnly);

QDataStream out(&datas, QDataStream::WriteOnly);
out << m_notifications;

settings.setValue("datas", datas);
Expand All @@ -147,7 +147,7 @@ void HistoryModel::initDatas()
{
QSettings settings(QSettings::UserScope, "lingmoos", "notifications");
QByteArray listByteArray = settings.value("datas").toByteArray();
QDataStream in(&listByteArray, QIODevice::ReadOnly);
QDataStream in(&listByteArray, QDataStream::WriteOnly);
in >> m_notifications;
}

Expand Down
4 changes: 3 additions & 1 deletion notificationd/notificationpopup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@
#include <QQmlContext>

#include <KWindowSystem>
#include <KX11Extras>
#include <KWindowEffects>
#include <NETWM>

NotificationPopup::NotificationPopup(QQuickView *parent)
: QQuickView(parent)
Expand All @@ -36,7 +38,7 @@ NotificationPopup::NotificationPopup(QQuickView *parent)
bool NotificationPopup::eventFilter(QObject *object, QEvent *event)
{
if (event->type() == QEvent::Show) {
KWindowSystem::setState(winId(), NET::SkipTaskbar | NET::SkipPager | NET::SkipSwitcher);
KX11Extras::setState(winId(), NET::SkipTaskbar | NET::SkipPager | NET::SkipSwitcher);
}

return QObject::eventFilter(object, event);
Expand Down
4 changes: 3 additions & 1 deletion notificationd/notificationwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@
#include <QQmlContext>

#include <KWindowSystem>
#include <KX11Extras>
#include <KWindowEffects>
#include <NETWM>

NotificationWindow::NotificationWindow(QQuickView *parent)
: QQuickView(parent)
Expand Down Expand Up @@ -65,7 +67,7 @@ bool NotificationWindow::eventFilter(QObject *object, QEvent *event)
QQuickView::setVisible(false);
}
} else if (event->type() == QEvent::Show) {
KWindowSystem::setState(winId(), NET::SkipTaskbar | NET::SkipPager | NET::SkipSwitcher);
KX11Extras::setState(winId(), NET::SkipTaskbar | NET::SkipPager | NET::SkipSwitcher);
HistoryModel::self()->updateTime();
} else if (event->type() == QEvent::Hide) {
setMouseGrabEnabled(false);
Expand Down
2 changes: 1 addition & 1 deletion notificationd/qml/IconButton.qml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import QtQuick 2.12
import QtQuick.Controls 2.12
import QtQuick.Layouts 1.12
import LingmoUI 1.0 as LingmoUI
import LingmoUI.Compatible 3.0 as LingmoUI

Item {
id: control
Expand Down
2 changes: 1 addition & 1 deletion notificationd/qml/NotificationWindow.qml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import QtQuick.Controls 2.12
import QtQuick.Layouts 1.12
import QtQuick.Window 2.12
import QtGraphicalEffects 1.0
import LingmoUI 1.0 as LingmoUI
import LingmoUI.Compatible 3.0 as LingmoUI
import Lingmo.Notification 1.0

Item {
Expand Down
2 changes: 1 addition & 1 deletion notificationd/qml/QmlNotificationPopup.qml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import QtQuick.Controls 2.12
import QtQuick.Layouts 1.12
import QtQuick.Window 2.12
import QtGraphicalEffects 1.0
import LingmoUI 1.0 as LingmoUI
import LingmoUI.Compatible 3.0 as LingmoUI
import Lingmo.Notification 1.0

NotificationPopup {
Expand Down
2 changes: 1 addition & 1 deletion notificationd/qml/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import QtQuick.Controls 2.12
import QtQuick.Layouts 1.12
import QtQuick.Window 2.12
import QtGraphicalEffects 1.0
import LingmoUI 1.0 as LingmoUI
import LingmoUI.Compatible 3.0 as LingmoUI
import Lingmo.Notification 1.0

Item {
Expand Down
18 changes: 9 additions & 9 deletions notificationd/translations/en_US.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,50 +4,50 @@
<context>
<name>DateHelper</name>
<message>
<location filename="../datehelper.cpp" line="15"/>
<location filename="../datehelper.cpp" line="16"/>
<source>Now</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../datehelper.cpp" line="17"/>
<location filename="../datehelper.cpp" line="18"/>
<source>1 minute ago</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../datehelper.cpp" line="19"/>
<location filename="../datehelper.cpp" line="20"/>
<source>%1 minutes ago</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../datehelper.cpp" line="23"/>
<location filename="../datehelper.cpp" line="24"/>
<source>1 hour ago</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../datehelper.cpp" line="25"/>
<location filename="../datehelper.cpp" line="26"/>
<source>%1 hours ago</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../datehelper.cpp" line="29"/>
<location filename="../datehelper.cpp" line="30"/>
<source>1 day ago</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../datehelper.cpp" line="31"/>
<location filename="../datehelper.cpp" line="32"/>
<source>%1 days ago</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>NotificationWindow</name>
<message>
<location filename="../qml/NotificationWindow.qml" line="91"/>
<location filename="../qml/NotificationWindow.qml" line="106"/>
<source>Notification Center</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../qml/NotificationWindow.qml" line="123"/>
<location filename="../qml/NotificationWindow.qml" line="155"/>
<source>No notifications</source>
<translation type="unfinished"></translation>
</message>
Expand Down
18 changes: 9 additions & 9 deletions notificationd/translations/zh_CN.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,50 +4,50 @@
<context>
<name>DateHelper</name>
<message>
<location filename="../datehelper.cpp" line="15"/>
<location filename="../datehelper.cpp" line="16"/>
<source>Now</source>
<translation>现在</translation>
</message>
<message>
<location filename="../datehelper.cpp" line="17"/>
<location filename="../datehelper.cpp" line="18"/>
<source>1 minute ago</source>
<translation>一分钟前</translation>
</message>
<message>
<location filename="../datehelper.cpp" line="19"/>
<location filename="../datehelper.cpp" line="20"/>
<source>%1 minutes ago</source>
<translation>%1分钟前</translation>
</message>
<message>
<location filename="../datehelper.cpp" line="23"/>
<location filename="../datehelper.cpp" line="24"/>
<source>1 hour ago</source>
<translation>一小时前</translation>
</message>
<message>
<location filename="../datehelper.cpp" line="25"/>
<location filename="../datehelper.cpp" line="26"/>
<source>%1 hours ago</source>
<translation>%1小时前</translation>
</message>
<message>
<location filename="../datehelper.cpp" line="29"/>
<location filename="../datehelper.cpp" line="30"/>
<source>1 day ago</source>
<translation>一天前</translation>
</message>
<message>
<location filename="../datehelper.cpp" line="31"/>
<location filename="../datehelper.cpp" line="32"/>
<source>%1 days ago</source>
<translation>%1天前</translation>
</message>
</context>
<context>
<name>NotificationWindow</name>
<message>
<location filename="../qml/NotificationWindow.qml" line="91"/>
<location filename="../qml/NotificationWindow.qml" line="106"/>
<source>Notification Center</source>
<translation>通知中心</translation>
</message>
<message>
<location filename="../qml/NotificationWindow.qml" line="123"/>
<location filename="../qml/NotificationWindow.qml" line="155"/>
<source>No notifications</source>
<translation>无通知</translation>
</message>
Expand Down

0 comments on commit 582e8cf

Please sign in to comment.