Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions debian/dde-shell.install
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ usr/share/dsg/configs/org.deepin.dde.shell/org.deepin.dde.shell.notification.jso
usr/share/dsg/configs/org.deepin.dde.shell/org.deepin.ds.dde-apps.json
usr/share/dde-shell/*/translations
usr/share/dde-dock/icons/dcc-setting/*.svg
usr/lib/*/qt6/qml/org/deepin/ds/notification/*
usr/lib/*/qt6/qml/org/deepin/ds/notificationcenter/*
usr/lib/*/dde-shell/org.deepin.ds.notificationcenter*
usr/share/dde-shell/org.deepin.ds.notificationcenter*/
Expand Down
1 change: 1 addition & 0 deletions panels/notification/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ target_link_libraries(ds-notification-shared PUBLIC
install(TARGETS ds-notification-shared DESTINATION "${LIB_INSTALL_DIR}")
ds_install_package(PACKAGE org.deepin.ds.notification TARGET ds-notification)

add_subdirectory(plugin)
add_subdirectory(bubble)
add_subdirectory(center)
add_subdirectory(osd)
Expand Down
101 changes: 22 additions & 79 deletions panels/notification/bubble/bubbleitem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@
void BubbleItem::setEntity(const NotifyEntity &entity)
{
m_entity = entity;
updateActions();

QVariantMap hints = entity.hints();
if (hints.contains("urgency")) {
Expand Down Expand Up @@ -229,68 +230,36 @@
return m_entity.cTime();
}

bool BubbleItem::hasDisplayAction() const
QString BubbleItem::defaultAction() const
{
return displayActions().count() >= 2;
return m_defaultAction;
}

bool BubbleItem::hasDefaultAction() const
QVariantList BubbleItem::actions() const
{
return defaultActionIdIndex() >= 0;
return m_actions;
}

QString BubbleItem::defaultActionText() const
void BubbleItem::updateActions()
{
const auto index = defaultActionTextIndex();
if (index < 0)
return QString();

return m_entity.actions().at(index);
}

QString BubbleItem::defaultActionId() const
{
const auto index = defaultActionIdIndex();
if (index < 0)
return QString();

return m_entity.actions().at(index);
}

QString BubbleItem::firstActionText() const
{
if (!hasDisplayAction())
return QString();

return displayActions().at(1);
}

QString BubbleItem::firstActionId() const
{
if (!hasDisplayAction())
return QString();

return displayActions().at(0);
}

QStringList BubbleItem::actionTexts() const
{
QStringList res;
const auto tmp = displayActions();
for (int i = 3; i < tmp.count(); i += 2)
res << tmp[i];

return res;
}
QStringList actions = m_entity.actions();
const auto defaultIndex = actions.indexOf(QLatin1String("default"));
if (defaultIndex >= 0) {
actions.remove(defaultIndex, 2);
m_defaultAction = QLatin1String("default");
}

QStringList BubbleItem::actionIds() const
{
QStringList res;
const auto tmp = displayActions();
for (int i = 2; i < tmp.count(); i += 2)
res << tmp[i];
QVariantList array;
for (int i = 0; i < actions.size(); i += 2) {
const auto id = actions[i];
const auto text = actions[i + 1];
QVariantMap item;
item["id"] = id;
item["text"] = text;
array.append(item);
}

return res;
m_actions = array;
}

int BubbleItem::level() const
Expand Down Expand Up @@ -330,33 +299,7 @@
m_enablePreview = enable;
}

int BubbleItem::defaultActionIdIndex() const
{
return m_entity.actions().indexOf("default");
}

int BubbleItem::defaultActionTextIndex() const
{
const auto index = defaultActionIdIndex();
if (index >= 0)
return index + 1;

return -1;
}

QStringList BubbleItem::displayActions() const
{
const auto defaultIndex = defaultActionIdIndex();
if (defaultIndex >= 0) {
auto tmp = m_entity.actions();
tmp.remove(defaultIndex, 1);
return tmp;
}

return m_entity.actions();
}

QString BubbleItem::displayText() const

Check warning on line 302 in panels/notification/bubble/bubbleitem.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

The function 'displayText' is never used.
{
return m_enablePreview ? m_entity.body() : tr("1 new message");
}
Expand Down
18 changes: 5 additions & 13 deletions panels/notification/bubble/bubbleitem.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,9 @@ class BubbleItem : public QObject
QString bodyImagePath() const;
qint64 ctime() const;

bool hasDisplayAction() const;
bool hasDefaultAction() const;
QString defaultActionText() const;
QString defaultActionId() const;
QString firstActionText() const;
QString firstActionId() const;
QStringList actionTexts() const;
QStringList actionIds() const;
QString defaultAction() const;
QVariantList actions() const;
void updateActions();

int level() const;
void setLevel(int level);
Expand All @@ -57,19 +52,16 @@ class BubbleItem : public QObject
void timeTipChanged();

private:
int defaultActionIdIndex() const;
int defaultActionTextIndex() const;
QStringList displayActions() const;
QString displayText() const;

private:
NotifyEntity m_entity;

private:
int m_level = 0;
int m_urgency = NotifyEntity::Normal;
QString m_timeTip;
bool m_enablePreview = true;
QVariantList m_actions;
QString m_defaultAction;
};

}
Expand Down
24 changes: 6 additions & 18 deletions panels/notification/bubble/bubblemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,18 +174,10 @@ QVariant BubbleModel::data(const QModelIndex &index, int role) const
return m_bubbles[row]->bodyImagePath();
case BubbleModel::OverlayCount:
return overlayCount();
case BubbleModel::hasDefaultAction:
return m_bubbles[row]->hasDefaultAction();
case BubbleModel::hasDisplayAction:
return m_bubbles[row]->hasDisplayAction();
case BubbleModel::FirstActionText:
return m_bubbles[row]->firstActionText();
case BubbleModel::FirstActionId:
return m_bubbles[row]->firstActionId();
case BubbleModel::ActionTexts:
return m_bubbles[row]->actionTexts();
case BubbleModel::ActionIds:
return m_bubbles[row]->actionIds();
case BubbleModel::DefaultAction:
return m_bubbles[row]->defaultAction();
case BubbleModel::Actions:
return m_bubbles[row]->actions();
case BubbleModel::Urgency:
return m_bubbles[row]->urgency();
default:
Expand All @@ -207,12 +199,8 @@ QHash<int, QByteArray> BubbleModel::roleNames() const
mapRoleNames[BubbleModel::Urgency] = "urgency";
mapRoleNames[BubbleModel::BodyImagePath] = "bodyImagePath";
mapRoleNames[BubbleModel::OverlayCount] = "overlayCount";
mapRoleNames[BubbleModel::hasDefaultAction] = "hasDefaultAction";
mapRoleNames[BubbleModel::hasDisplayAction] = "hasDisplayAction";
mapRoleNames[BubbleModel::FirstActionText] = "firstActionText";
mapRoleNames[BubbleModel::FirstActionId] = "firstActionId";
mapRoleNames[BubbleModel::ActionTexts] = "actionTexts";
mapRoleNames[BubbleModel::ActionIds] = "actionIds";
mapRoleNames[BubbleModel::DefaultAction] = "defaultAction";
mapRoleNames[BubbleModel::Actions] = "actions";
return mapRoleNames;
}

Expand Down
9 changes: 2 additions & 7 deletions panels/notification/bubble/bubblemodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,8 @@ class BubbleModel : public QAbstractListModel
TimeTip,
BodyImagePath,
OverlayCount,
hasDefaultAction,
hasDisplayAction,
FirstActionText,
FirstActionId,
DefaultActionId,
ActionTexts,
ActionIds,
DefaultAction,
Actions,
Urgency,
} BubbleRole;

Expand Down
10 changes: 0 additions & 10 deletions panels/notification/bubble/bubblepanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,16 +78,6 @@ BubbleModel *BubblePanel::bubbles() const
return m_bubbles;
}

void BubblePanel::invokeDefaultAction(int bubbleIndex)
{
auto bubble = bubbleItem(bubbleIndex);
if (!bubble)
return;

m_bubbles->remove(bubbleIndex);
onActionInvoked(bubble->id(), bubble->bubbleId(), bubble->defaultActionId());
}

void BubblePanel::invokeAction(int bubbleIndex, const QString &actionId)
{
auto bubble = bubbleItem(bubbleIndex);
Expand Down
1 change: 0 additions & 1 deletion panels/notification/bubble/bubblepanel.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ class BubblePanel : public DS_NAMESPACE::DPanel
bool enabled() const;

public Q_SLOTS:
void invokeDefaultAction(int bubbleIndex);
void invokeAction(int bubbleIndex, const QString &actionId);
void close(int bubbleIndex);
void delayProcess(int bubbleIndex);
Expand Down
54 changes: 0 additions & 54 deletions panels/notification/bubble/package/BubbleAction.qml

This file was deleted.

Loading
Loading