Skip to content

Commit

Permalink
fix: tidy up the project
Browse files Browse the repository at this point in the history
use applicationManager instead of Launcherd1 since that interface is
moved
update the usage of cmake, use scanner instead
mask dmemorywarningdialog since startmanager is removed
update cmake to c++17

Log:
  • Loading branch information
Decodetalkers committed Jan 9, 2024
1 parent 069b40a commit fc3ba27
Show file tree
Hide file tree
Showing 25 changed files with 376 additions and 363 deletions.
29 changes: 6 additions & 23 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ cmake_minimum_required(VERSION 3.13)
set(PROJECT_NAME dde-session-ui)
project(${PROJECT_NAME})

set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
Expand Down Expand Up @@ -60,30 +60,10 @@ set(Test_Libraries
-lgcov
-lgtest
-lgmock
)

set(XML2CPP_DIR ${PROJECT_SOURCE_DIR}/global_util/dbus)
file(GLOB_RECURSE XMLFILES xml/*.xml)
)

find_package(DtkTools REQUIRED)

foreach(XMLFILE ${XMLFILES})
string(FIND ${XMLFILE} "/" INDEX REVERSE)
string(SUBSTRING ${XMLFILE} ${INDEX} -1 filename)
string(REPLACE "/" "" filename ${filename})
string(REPLACE ".xml" "" filename ${filename})
string(REPLACE "." "_" filename ${filename})

string(FIND ${filename} "_" INDEX1 REVERSE)
string(SUBSTRING ${filename} ${INDEX1} -1 classname)
string(REPLACE "_" "" classname ${classname})

string(TOLOWER ${filename} filename)

execute_process(COMMAND ${DTK_XML2CPP} -c ${classname} -p ${XML2CPP_DIR}/${filename} ${XMLFILE}
WORKING_DIRECTORY ${XML2CPP_DIR})
endforeach()

# shared objects
add_subdirectory("common")
add_subdirectory("widgets")
Expand All @@ -103,7 +83,10 @@ add_subdirectory("dde-touchscreen-dialog")
add_subdirectory("dde-warning-dialog")
add_subdirectory("dde-welcome")
add_subdirectory("dde-wm-chooser")
add_subdirectory("dmemory-warning-dialog")

# FIXME: startmanager is removed, so it need to be updated
# add_subdirectory("dmemory-warning-dialog")

add_subdirectory("dnetwork-secret-dialog")
#TODO 需要break旧版本的控制中心
add_subdirectory("reset-password-dialog")
Expand Down
4 changes: 0 additions & 4 deletions dde-osd/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ set(OSD_Name dde-osd)
add_executable(${OSD_Name}
main.cpp
)
target_include_directories(dde-osd-shared
PRIVATE
${CMAKE_CURRENT_LIST_DIR}
)

target_link_libraries(${OSD_Name} PRIVATE
dde-osd-shared
Expand Down
10 changes: 5 additions & 5 deletions dde-osd/src/audioprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ DGUI_USE_NAMESPACE

AudioProvider::AudioProvider(QObject *parent)
: AbstractOSDProvider(parent),
m_audioInter(new org::deepin::dde::Audio1("org.deepin.dde.Audio1",
"/org/deepin/dde/Audio1",
QDBusConnection::sessionBus(), this)),
m_audioInter(new Audio1("org.deepin.dde.Audio1",
"/org/deepin/dde/Audio1",
QDBusConnection::sessionBus(), this)),
m_sinkInter(nullptr)
{
m_suitableParams << "AudioUp" << "AudioDown" << "AudioMute" << "AudioUpAsh" << "AudioDownAsh" << "AudioMuteAsh";

m_audioInter->setSync(true, false);
connect(m_audioInter, &__Audio1::DefaultSinkChanged,
connect(m_audioInter, &Audio1::DefaultSinkChanged,
this, &AudioProvider::defaultSinkChanged);

auto onAudioIsValid = [ = ](bool isvalid) {
Expand All @@ -28,7 +28,7 @@ AudioProvider::AudioProvider(QObject *parent)
}
};

connect(m_audioInter, &__Audio1::serviceValidChanged, this, onAudioIsValid);
connect(m_audioInter, &Audio1::serviceValidChanged, this, onAudioIsValid);

onAudioIsValid(m_audioInter->isValid());
}
Expand Down
4 changes: 3 additions & 1 deletion dde-osd/src/audioprovider.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
#include "org_deepin_dde_audio1.h"
#include "org_deepin_dde_audio1_sink.h"

using org::deepin::dde::Audio1;

/*!
* \~chinese \class AudioProvider
* \~chinese \brief 调整音频时的通知类
Expand All @@ -29,7 +31,7 @@ class AudioProvider : public AbstractOSDProvider
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override;

private:
org::deepin::dde::Audio1 *m_audioInter;
Audio1 *m_audioInter;
org::deepin::dde::audio1::Sink *m_sinkInter;

QString pixmapName() const;
Expand Down
6 changes: 3 additions & 3 deletions dde-osd/src/displaymodeprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ DisplayModeProvider::DisplayModeProvider(QObject *parent)

updateOutputNames();

connect(m_displayInter, &__Display1::DisplayModeChanged,
connect(m_displayInter, &Display1::DisplayModeChanged,
this, &DisplayModeProvider::displayModeChanged);
connect(m_displayInter, &__Display1::PrimaryChanged,
connect(m_displayInter, &Display1::PrimaryChanged,
this, &DisplayModeProvider::primaryChanged);
connect(m_displayInter, &__Display1::MonitorsChanged,
connect(m_displayInter, &Display1::MonitorsChanged,
this, &DisplayModeProvider::updateOutputNames);

displayModeChanged(m_displayInter->displayMode());
Expand Down
6 changes: 3 additions & 3 deletions dde-osd/src/kblayoutindicator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ DataWrapper::DataWrapper(KeyboardInterface *kinter, QObject *parent) :
}
};

connect(m_keyboardInter, &__Keyboard::UserLayoutListChanged,
connect(m_keyboardInter, &KeyboardInterface::UserLayoutListChanged,
this, &DataWrapper::setLayoutList);
connect(m_keyboardInter, &__Keyboard::CurrentLayoutChanged,
connect(m_keyboardInter, &KeyboardInterface::CurrentLayoutChanged,
this, &DataWrapper::setCurrentLayout);
connect(m_keyboardInter, &__Keyboard::serviceValidChanged,
connect(m_keyboardInter, &KeyboardInterface::serviceValidChanged,
this, keyboardIsValid);

keyboardIsValid(m_keyboardInter->isValid());
Expand Down
6 changes: 3 additions & 3 deletions dde-osd/src/kblayoutprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ KBLayoutProvider::KBLayoutProvider(QObject *parent)
}
};

connect(m_keyboardInter, &__Keyboard::UserLayoutListChanged,
connect(m_keyboardInter, &Keyboard::UserLayoutListChanged,
this, &KBLayoutProvider::userLayoutListChanged);
connect(m_keyboardInter, &__Keyboard::CurrentLayoutChanged,
connect(m_keyboardInter, &Keyboard::CurrentLayoutChanged,
this, &KBLayoutProvider::currentLayoutChanged);
connect(m_keyboardInter, &__Keyboard::serviceValidChanged,
connect(m_keyboardInter, &Keyboard::serviceValidChanged,
this, keyboardIsValid);

keyboardIsValid(m_keyboardInter->isValid());
Expand Down
2 changes: 2 additions & 0 deletions dde-osd/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ int main(int argc, char *argv[])

DLogManager::registerConsoleAppender();
DLogManager::registerFileAppender();
DLogManager::registerJournalAppender();
QAccessible::installFactory(accessibleFactory);

QTranslator translator;
translator.load("/usr/share/dde-session-ui/translations/dde-session-ui_" + QLocale::system().name());
app->installTranslator(&translator);
Expand Down
14 changes: 1 addition & 13 deletions dde-osd/src/notification/bubblemanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@
#include <QDateTime>
#include <QGSettings>

#include <algorithm>

#include "org_deepin_dde_display1.h"
#include "org_deepin_dde_display1_monitor.h"

Expand Down Expand Up @@ -70,7 +68,7 @@ BubbleManager::BubbleManager(AbstractPersistence *persistence, AbstractNotifySet
m_slideWidth = (m_dockDeamonInter->position() == OSD::DockPosition::Right) ? 100 : 0;
m_dockInter->setSync(false);

connect(m_userInter, &__SessionManager1::LockedChanged, this, [ this ] {
connect(m_userInter, &UserInter::LockedChanged, this, [ this ] {
// 当锁屏状态发生变化时立即隐藏所有通知并插入到通知中心(根据通知的实际情况决定),桌面和锁屏的通知不交叉显示
popAllBubblesImmediately();
});
Expand Down Expand Up @@ -565,16 +563,6 @@ void BubbleManager::SetSystemInfo(uint item, const QDBusVariant var)
Q_EMIT systemSettingChanged(m_notifySettings->getSystemSetings_v1());
}

void BubbleManager::appInfoChanged(QString action, LauncherItemInfo info)
{
if (action == DeletedAction) {
m_notifySettings->appRemoved(info.id);
Q_EMIT appRemoved(info.id);
} else if (action == CreatedAction) {
m_notifySettings->appAdded(info);
Q_EMIT appAdded(m_notifySettings->getAppSettings_v1(info.id));
}
}

void BubbleManager::onOpacityChanged(double value)
{
Expand Down
3 changes: 0 additions & 3 deletions dde-osd/src/notification/bubblemanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
#include "org_deepin_dde_soundeffect1.h"
#include "org_deepin_dde_gesture1.h"
#include "org_deepin_dde_display1.h"
#include "org_deepin_dde_daemon_launcherd1.h"
#include "org_deepin_dde_daemon_dock1.h"
#include "org_deepin_dde_appearance1.h"

Expand All @@ -27,7 +26,6 @@

using Appearance = org::deepin::dde::Appearance1;
using UserInter = org::deepin::dde::SessionManager1;
using LauncherInter = org::deepin::dde::daemon::Launcher1;
using SoundeffectInter = org::deepin::dde::SoundEffect1;
using GestureInter = org::deepin::dde::Gesture1;
using DisplayInter = org::deepin::dde::Display1;
Expand Down Expand Up @@ -211,7 +209,6 @@ private Q_SLOTS:
* \~chinese \brief 当主屏幕发生改变或几何大小发送改变,更新所有通知气泡的几何位置
*/
void updateGeometry();
void appInfoChanged(QString action, LauncherItemInfo info);
void onOpacityChanged(double value);

private:
Expand Down
104 changes: 87 additions & 17 deletions dde-osd/src/notification/notifysettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

#include "notifysettings.h"
#include "constants.h"
#include "types/objectmanager_type.h"
#include "types/launcheriteminfo.h"
#include <DUtil>

#include <QGSettings>
#include <QTimer>
Expand All @@ -22,15 +25,82 @@ const QString schemaPath = "/com/deepin/dde/notifications/";
const QString appSchemaKey = "com.deepin.dde.notifications.applications";
const QString appSchemaPath = "/com/deepin/dde/notifications/applications/%1/";


static QStringList getUILanguages() {
QLocale syslocal = QLocale::system();

QStringList uiLanguages = syslocal.uiLanguages();
// the nameMap uses underscore instead of minus sign
for (auto &lang : uiLanguages) {
lang.replace('-', '_');
}
uiLanguages << "default";

return uiLanguages;
}

static LauncherItemInfo fromObjectInterfaceMapToItemInfo(const QDBusObjectPath &path, const ObjectInterfaceMap &valueMap)
{

auto uiLanguages = getUILanguages();
LauncherItemInfo info;
info.path = path.path();
for (const QVariantMap &mapInter : valueMap) {
if (mapInter.count() == 0) {
continue;
}

QString icon;
if (auto mapicons = mapInter.value("Icons"); !mapicons.isNull()) {
auto icons = qdbus_cast<QMap<QString, QString>>(mapicons);
if (!icons.value("Desktop Entry").isNull()) {
icon = icons["Desktop Entry"];
}
}
info.icon = icon;
auto nameMap = qdbus_cast<QMap<QString, QString>>(mapInter["Name"]);
QString id = qdbus_cast<QString>(mapInter["ID"]);
info.id = id;

QString showName = id;

for (auto &lang : uiLanguages) {
auto iter = nameMap.find(lang);
if (iter != nameMap.end()) {
showName = iter.value();
break;
}
}
info.name = showName;
if (mapInter.contains("X-Created-By")) {
info.x_created_by = qdbus_cast<QString>(mapInter["X-Created-By"]);
}
}
return info;

}

static QList<LauncherItemInfo> fromObjectMaptoLauncherItemInfoList(const ObjectMap &map)
{
auto uiLanguages = getUILanguages();

Check warning on line 85 in dde-osd/src/notification/notifysettings.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Variable 'uiLanguages' is assigned a value that is never used.

QList<LauncherItemInfo> infos;
for (auto [dbusPath, valueMap] : map.toStdMap()) {
infos << fromObjectInterfaceMapToItemInfo(dbusPath, valueMap);
}
return infos;
}

NotifySettings::NotifySettings(QObject *parent)
: AbstractNotifySetting(parent)
, m_initTimer(new QTimer(this))
, m_launcherInter(new LauncherInter("org.deepin.dde.daemon.Launcher1",
"/org/deepin/dde/daemon/Launcher1",
QDBusConnection::sessionBus(), this))
, m_applicationObjectInter(
new ApplicationObjectManager1("org.desktopspec.ApplicationManager1",
"/org/desktopspec/ApplicationManager1",
QDBusConnection::sessionBus(),
this))
{
registerLauncherItemInfoListMetaType();
registerLauncherItemInfoMetaType();
registerAmMetaType();

if (!QGSettings::isSchemaInstalled("com.deepin.dde.notification")) {
qDebug()<<"System configuration fetch failed!";
Expand All @@ -39,30 +109,30 @@ NotifySettings::NotifySettings(QObject *parent)
m_systemSetting = new QGSettings(schemaKey.toLocal8Bit(), schemaPath.toLocal8Bit(), this);

connect(m_initTimer, &QTimer::timeout, this, &NotifySettings::initAllSettings);
connect(m_launcherInter, &LauncherInter::ItemChanged, this, [ = ] (QString action, LauncherItemInfo info, qlonglong id) {
Q_UNUSED(id)
if (action == "deleted") {
appRemoved(info.id);
} else if (action == "created") {
appAdded(info);
}
connect(m_applicationObjectInter, &ApplicationObjectManager1::InterfacesAdded, this, [this](const QDBusObjectPath &object_path, ObjectInterfaceMap interfaces) {
LauncherItemInfo info = fromObjectInterfaceMapToItemInfo(object_path, interfaces);
appAdded(info);
});
connect(m_applicationObjectInter, &ApplicationObjectManager1::InterfacesRemoved, this, [this](const QDBusObjectPath &object_path, const QStringList) {
QString id = DUtil::unescapeFromObjectPath(object_path.path());
appRemoved(id);
});
}

void NotifySettings::initAllSettings()
{
LauncherItemInfoList itemInfoList = m_launcherInter->GetAllItemInfos();
if (!itemInfoList.isEmpty()) {
ObjectMap app_map = m_applicationObjectInter->GetManagedObjects();
if (app_map.isEmpty()) {
m_initTimer->stop();
}
LauncherItemInfoList itemInfoList = fromObjectMaptoLauncherItemInfoList(app_map);

QStringList appList = m_systemSetting->get("app-list").toStringList();
QStringList launcherList;

foreach(const LauncherItemInfo &item, itemInfoList) {
for(const LauncherItemInfo &item: itemInfoList) {
launcherList << item.id;
DDesktopEntry desktopInfo(item.path);
if (IgnoreList.contains(item.id) || desktopInfo.rawValue("X-Created-By") == "Deepin WINE Team") {
if (IgnoreList.contains(item.id) || (item.x_created_by.value_or("") == "Deepin WINE Team") ) {
continue;
}

Expand Down
8 changes: 3 additions & 5 deletions dde-osd/src/notification/notifysettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,14 @@
#ifndef NOTIFYSETTINGS_H
#define NOTIFYSETTINGS_H

#include "org_deepin_dde_daemon_launcherd1.h"
#include "types/launcheriteminfo.h"
#include "types/launcheriteminfolist.h"
#include "objectmanager_interface.h"

#include <QObject>

class QGSettings;
class QTimer;

using LauncherInter = org::deepin::dde::daemon::Launcher1;

class AbstractNotifySetting : public QObject
{
Q_OBJECT
Expand Down Expand Up @@ -94,7 +91,8 @@ class NotifySettings : public AbstractNotifySetting

QTimer *m_initTimer;
QGSettings *m_systemSetting;
LauncherInter *m_launcherInter;
//LauncherInter *m_launcherInter;
ApplicationObjectManager1 *m_applicationObjectInter;
};

#endif // NOTIFYSETTINGS_H
Loading

0 comments on commit fc3ba27

Please sign in to comment.