Add contains interface

This commit is contained in:
reionwong 2021-08-29 22:56:25 +08:00
parent a528b3c538
commit 357e4dd3ab
5 changed files with 20 additions and 0 deletions

View file

@ -129,6 +129,11 @@ void ApplicationModel::removeItem(const QString &desktopFile)
}
}
bool ApplicationModel::desktopContains(const QString &desktopFile)
{
return findItemByDesktop(desktopFile) != nullptr;
}
void ApplicationModel::clicked(const QString &id)
{
ApplicationItem *item = findItemById(id);

View file

@ -49,6 +49,7 @@ public:
void addItem(const QString &desktopFile);
void removeItem(const QString &desktopFile);
bool desktopContains(const QString &desktopFile);
Q_INVOKABLE void save() { savePinAndUnPinList(); }

View file

@ -104,6 +104,14 @@ void MainWindow::remove(const QString &desktop)
m_appModel->removeItem(desktop);
}
bool MainWindow::contains(const QString &desktop)
{
if (desktop.isEmpty())
return false;
return m_appModel->desktopContains(desktop);
}
void MainWindow::updateSize()
{
resizeWindow();

View file

@ -37,8 +37,10 @@ public:
explicit MainWindow(QQuickView *parent = nullptr);
~MainWindow();
// DBus interface
void add(const QString &desktop);
void remove(const QString &desktop);
bool contains(const QString &desktop);
Q_INVOKABLE void updateSize();

View file

@ -3,5 +3,9 @@
<interface name="org.cutefish.Dock">
<method name="add"><arg name="desktopFile" type="s" direction="in"/></method>
<method name="remove"><arg name="desktopFile" type="s" direction="in"/></method>
<method name="contains">
<arg name="desktopFile" type="s" direction="in"/>
<arg type="b" direction="out"/>
</method>
</interface>
</node>