添加开始菜单置顶功能
This commit is contained in:
parent
63caa1841e
commit
069a392679
|
@ -15,13 +15,53 @@ MouseArea {
|
|||
ToolTip.visible: content.textTruncated && control.containsMouse
|
||||
ToolTip.text: name
|
||||
|
||||
RowLayout {
|
||||
anchors.fill: parent
|
||||
spacing: 2
|
||||
|
||||
IconLabel {
|
||||
id: content
|
||||
anchors.fill: parent
|
||||
Layout.alignment: Qt.AlignLeft | Qt.AlignVCenter
|
||||
Layout.fillWidth: true
|
||||
Layout.fillHeight: true
|
||||
|
||||
iconHeight: 32; iconWidth: iconHeight
|
||||
appName: name; appIcon: icon
|
||||
display: Display.TextBesideIcon
|
||||
spacing: 12
|
||||
}
|
||||
|
||||
Loader {
|
||||
id: tag
|
||||
property bool recentInsatlled: false
|
||||
visible: (toTop !== 0) || recentInsatlled
|
||||
Layout.alignment: Qt.AlignRight | Qt.AlignVCenter
|
||||
Layout.fillWidth: true
|
||||
Layout.fillHeight: true
|
||||
Layout.maximumWidth: visible ? 16 : 0
|
||||
Layout.maximumHeight: width
|
||||
Layout.rightMargin: visible ? 25 : 0
|
||||
|
||||
Component {
|
||||
id: tagImage
|
||||
Image {
|
||||
source: "image://appicon/ukui-fixed-symbolic"
|
||||
}
|
||||
}
|
||||
|
||||
Component {
|
||||
id: tagPoint
|
||||
Item {
|
||||
Rectangle {
|
||||
anchors.centerIn: parent
|
||||
width: 8; height: width
|
||||
radius: width / 2
|
||||
color: themePalette.paletteColor(Palette.Highlight)
|
||||
}
|
||||
}
|
||||
}
|
||||
sourceComponent: (toTop === 0) ? tag.recentInsatlled ? tagPoint : null : tagImage
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,6 +45,7 @@ Item {
|
|||
property string id: model.id
|
||||
property string name: model.name
|
||||
property string icon: model.icon
|
||||
property int toTop: model.top
|
||||
sourceComponent: {
|
||||
if (type === DataType.Normal) {
|
||||
return appItem;
|
||||
|
|
|
@ -47,6 +47,7 @@ private Q_SLOTS:
|
|||
public Q_SLOTS:
|
||||
void fixToFavoriteSlot(const QString &path, const int &num);
|
||||
void changedFavoriteOrderSlot(const QString &path, const int &num);
|
||||
void fixToTopSlot(const QString &path, const int &num);
|
||||
|
||||
private:
|
||||
void updateFavoriteApps();
|
||||
|
@ -287,6 +288,15 @@ void AppDataWorker::changedFavoriteOrderSlot(const QString &path, const int &num
|
|||
m_applicationInfo->setFavoritesOfApp(path, num);
|
||||
}
|
||||
|
||||
void AppDataWorker::fixToTopSlot(const QString &path, const int &num)
|
||||
{
|
||||
if (num == 0) {
|
||||
m_applicationInfo->setAppToTop(path);
|
||||
} else {
|
||||
m_applicationInfo->setTopOfApp(path, 0);
|
||||
}
|
||||
}
|
||||
|
||||
void AppDataWorker::removeApps(QStringList &appIdList, QStringList &removedIdList)
|
||||
{
|
||||
QMutexLocker locker(&m_appManager->m_mutex);
|
||||
|
@ -317,6 +327,7 @@ AppDataManager::AppDataManager()
|
|||
connect(appDataWorker, &AppDataWorker::favoriteAppChanged, this, &AppDataManager::favoriteAppChanged);
|
||||
connect(this, &AppDataManager::fixToFavoriteSignal, appDataWorker, &AppDataWorker::fixToFavoriteSlot);
|
||||
connect(this, &AppDataManager::changedFavoriteOrderSignal, appDataWorker, &AppDataWorker::changedFavoriteOrderSlot);
|
||||
connect(this, &AppDataManager::fixToTop, appDataWorker, &AppDataWorker::fixToTopSlot);
|
||||
|
||||
m_workerThread.start();
|
||||
}
|
||||
|
|
|
@ -57,6 +57,7 @@ Q_SIGNALS:
|
|||
void favoriteAppChanged();
|
||||
void fixToFavoriteSignal(const QString &path, const int &num);
|
||||
void changedFavoriteOrderSignal(const QString &path, const int &num);
|
||||
void fixToTop(const QString &path, const int &num);
|
||||
|
||||
private:
|
||||
AppDataManager();
|
||||
|
|
|
@ -100,7 +100,13 @@ void AllAppDataProvider::reloadAppData()
|
|||
}
|
||||
|
||||
std::sort(appData.begin(), appData.end(), [](const DataEntity &a, const DataEntity &b) {
|
||||
return (a.top() > b.top()) || (a.launchTimes() > b.launchTimes());
|
||||
if (a.top() == 0) {
|
||||
return (a.top() == b.top()) ? (a.launchTimes() > b.launchTimes()) : (a.top() > b.top());
|
||||
} else if (b.top() == 0) {
|
||||
return a.top() > b.top();
|
||||
} else {
|
||||
return a.top() < b.top();
|
||||
}
|
||||
});
|
||||
|
||||
m_appData.swap(appData);
|
||||
|
|
|
@ -178,6 +178,7 @@ QHash<int, QByteArray> DataEntity::AppRoleNames()
|
|||
names.insert(DataEntity::Name, "name");
|
||||
names.insert(DataEntity::Comment, "comment");
|
||||
names.insert(DataEntity::ExtraData, "extraData");
|
||||
names.insert(DataEntity::Top, "top");
|
||||
return names;
|
||||
}
|
||||
|
||||
|
|
|
@ -57,7 +57,8 @@ public:
|
|||
Icon,
|
||||
Name,
|
||||
Comment,
|
||||
ExtraData
|
||||
ExtraData,
|
||||
Top
|
||||
};
|
||||
DataEntity();
|
||||
DataEntity(DataType::Type type, const QString& name, const QString& icon, const QString& comment, const QString& extraData);
|
||||
|
|
|
@ -44,6 +44,7 @@ public:
|
|||
QList<QAction *> generateActions(QObject *parent, const RequestType &type, const QVariant &data) override;
|
||||
|
||||
private:
|
||||
void addToTop(QObject *parent, const QString &appId, const int &appTop, QList<QAction *> &list);
|
||||
void addToPanelAction(QObject *parent, const QString &appId, QList<QAction *> &list);
|
||||
void addToDesktopAction(QObject *parent, const QString &appId, QList<QAction *> &list);
|
||||
void addUninstall(QObject *parent, const QString &appId, QList<QAction *> &list);
|
||||
|
@ -75,6 +76,10 @@ AppMenuProvider::generateActions(QObject *parent, const MenuProvider::RequestTyp
|
|||
|
||||
QList<QAction *> list;
|
||||
QString appId = app.id();
|
||||
int appTop = app.top();
|
||||
|
||||
//置顶
|
||||
addToTop(parent, appId, appTop ,list);
|
||||
|
||||
// 添加到任务栏
|
||||
addToPanelAction(parent, appId, list);
|
||||
|
@ -88,6 +93,15 @@ AppMenuProvider::generateActions(QObject *parent, const MenuProvider::RequestTyp
|
|||
return list;
|
||||
}
|
||||
|
||||
void AppMenuProvider::addToTop(QObject *parent, const QString &appId, const int &appTop, QList<QAction *> &list)
|
||||
{
|
||||
QString actionName = (appTop == 0) ? QObject::tr("Fixed to all applications") : QObject::tr("Unfixed from all applications");
|
||||
list << new QAction(actionName, parent);
|
||||
QObject::connect(list.last(), &QAction::triggered, parent, [appId, appTop] {
|
||||
AppDataManager::instance()->fixToTop(appId, appTop);
|
||||
});
|
||||
}
|
||||
|
||||
void AppMenuProvider::addToPanelAction(QObject *parent, const QString &appId, QList<QAction *> &list)
|
||||
{
|
||||
QDBusInterface iface("com.ukui.panel.desktop", "/", "com.ukui.panel.desktop", QDBusConnection::sessionBus());
|
||||
|
|
|
@ -58,6 +58,11 @@ QVariant AppModel::data(const QModelIndex &index, int role) const
|
|||
return m_apps.at(i).comment();
|
||||
case DataEntity::ExtraData:
|
||||
return m_apps.at(i).extraData();
|
||||
case DataEntity::Top:
|
||||
if (DataProviderManager::instance()->activatedProvider() == "all") {
|
||||
return m_apps.at(i).top();
|
||||
}
|
||||
return 0;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -66,6 +66,14 @@
|
|||
<source>Add to taskbar</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Fixed to all applications</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Unfixed from all applications</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>SearchInputBar</name>
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
</message>
|
||||
<message>
|
||||
<source>Add to folder</source>
|
||||
<translation type="unfinished">添加至应用组</translation>
|
||||
<translation>添加至应用组</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Add to new folder</source>
|
||||
|
@ -74,6 +74,14 @@
|
|||
<source>Add to taskbar</source>
|
||||
<translation>固定到任务栏</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Fixed to all applications</source>
|
||||
<translation>固定到所有应用</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Unfixed from all applications</source>
|
||||
<translation>从所有应用取消固定</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>SearchInputBar</name>
|
||||
|
@ -86,14 +94,14 @@
|
|||
<name>UkuiMenu::AllAppDataProvider</name>
|
||||
<message>
|
||||
<source>All</source>
|
||||
<translation>全部</translation>
|
||||
<translation>所有应用</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>UkuiMenu::AppCategoryPlugin</name>
|
||||
<message>
|
||||
<source>Category</source>
|
||||
<translation>分类</translation>
|
||||
<translation>功能排序</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Audio</source>
|
||||
|
|
Loading…
Reference in New Issue