Skip to content

Commit 6ee6804

Browse files
committed
chore: tmp bring searchitem back
log: as title
1 parent 10e0c53 commit 6ee6804

33 files changed

+769
-2
lines changed

panels/dock/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ add_subdirectory(tray)
9898
add_subdirectory(multitaskview)
9999
add_subdirectory(dcc-dock-plugin)
100100

101+
add_subdirectory(searchitem)
101102
#add_subdirectory(appruntimeitem)
102103

103104
# dock qml element(include Dock.xx defines and DockCompositor)

panels/dock/multitaskview/package/multitaskview.qml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import org.deepin.ds.dock 1.0
1212
AppletItem {
1313
id: toggleworkspace
1414
property bool useColumnLayout: Panel.position % 2
15-
property int dockOrder: 13
15+
property int dockOrder: 15
1616
property bool shouldVisible: Applet.visible
1717
// 1:4 the distance between app : dock height; get width/height≈0.8
1818
implicitWidth: useColumnLayout ? Panel.rootObject.dockSize : Panel.rootObject.dockItemMaxSize * 0.8
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd.
2+
#
3+
# SPDX-License-Identifier: GPL-3.0-or-later
4+
5+
add_library(dock-searchitem SHARED
6+
searchitem.cpp
7+
searchitem.h
8+
../dockiteminfo.cpp
9+
../dockiteminfo.h
10+
)
11+
12+
target_include_directories(dock-searchitem PRIVATE
13+
"${CMAKE_CURRENT_BINARY_DIR}/../"
14+
"../"
15+
)
16+
17+
target_link_libraries(dock-searchitem PRIVATE
18+
dde-shell-frame
19+
)
20+
21+
ds_install_package(PACKAGE org.deepin.ds.dock.searchitem TARGET dock-searchitem)
22+
ds_handle_package_translation(PACKAGE org.deepin.ds.dock.searchitem)
23+
24+
install(FILES "package/icons/search.svg" DESTINATION share/dde-dock/icons/dcc-setting)
82 KB
Binary file not shown.
2.31 KB
Binary file not shown.
Lines changed: 7 additions & 0 deletions
Loading
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"Plugin": {
3+
"Version": "1.0",
4+
"Id": "org.deepin.ds.dock.searchitem",
5+
"Url": "searchitem.qml",
6+
"Parent": "org.deepin.ds.dock"
7+
}
8+
}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
2+
//
3+
// SPDX-License-Identifier: GPL-3.0-or-later
4+
5+
import QtQuick 2.15
6+
import QtQuick.Controls 2.15
7+
8+
import org.deepin.ds 1.0
9+
import org.deepin.dtk 1.0 as D
10+
import org.deepin.ds.dock 1.0
11+
12+
AppletItem {
13+
property bool useColumnLayout: Panel.position % 2
14+
property int dockOrder: 5
15+
property bool shouldVisible: Applet.visible
16+
// 1:4 the distance between app : dock height; get width/height≈0.8
17+
implicitWidth: useColumnLayout ? Panel.rootObject.dockSize : Panel.rootObject.dockItemMaxSize * 0.8
18+
implicitHeight: useColumnLayout ? Panel.rootObject.dockItemMaxSize * 0.8 : Panel.rootObject.dockSize
19+
20+
PanelToolTip {
21+
id: toolTip
22+
text: qsTr("GrandSearch")
23+
toolTipX: DockPanelPositioner.x
24+
toolTipY: DockPanelPositioner.y
25+
}
26+
27+
D.DciIcon {
28+
id: icon
29+
anchors.centerIn: parent
30+
name: "dde-grand-search"
31+
scale: Panel.rootObject.dockItemMaxSize * 9 / 14 / Dock.MAX_DOCK_TASKMANAGER_ICON_SIZE
32+
// 9:14 (iconSize/dockHeight)
33+
sourceSize: Qt.size(Dock.MAX_DOCK_TASKMANAGER_ICON_SIZE, Dock.MAX_DOCK_TASKMANAGER_ICON_SIZE)
34+
Timer {
35+
id: toolTipShowTimer
36+
interval: 50
37+
onTriggered: {
38+
var point = Applet.rootObject.mapToItem(null, Applet.rootObject.width / 2, Applet.rootObject.height / 2)
39+
toolTip.DockPanelPositioner.bounding = Qt.rect(point.x, point.y, toolTip.width, toolTip.height)
40+
toolTip.open()
41+
}
42+
}
43+
TapHandler {
44+
acceptedButtons: Qt.LeftButton
45+
onTapped: {
46+
Applet.toggleGrandSearch()
47+
toolTip.close()
48+
}
49+
}
50+
HoverHandler {
51+
onHoveredChanged: {
52+
if (hovered) {
53+
toolTipShowTimer.start()
54+
} else {
55+
if (toolTipShowTimer.running) {
56+
toolTipShowTimer.stop()
57+
}
58+
59+
toolTip.close()
60+
}
61+
}
62+
}
63+
}
64+
}
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
// SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd.
2+
//
3+
// SPDX-License-Identifier: GPL-3.0-or-later
4+
5+
#include "searchitem.h"
6+
#include "../constants.h"
7+
#include "applet.h"
8+
#include "pluginfactory.h"
9+
10+
#include <DDBusSender>
11+
#include <DDciIcon>
12+
#include <DGuiApplicationHelper>
13+
14+
#include <QBuffer>
15+
#include <QGuiApplication>
16+
#include <QProcess>
17+
18+
DGUI_USE_NAMESPACE
19+
namespace dock
20+
{
21+
22+
const QString grandSearchService = "com.deepin.dde.GrandSearch";
23+
const QString grandSearchPath = "/com/deepin/dde/GrandSearch";
24+
const QString grandSearchInterface = "com.deepin.dde.GrandSearch";
25+
static DDBusSender searchDbus()
26+
{
27+
return DDBusSender().service(grandSearchService).path(grandSearchPath).interface(grandSearchInterface);
28+
}
29+
30+
SearchItem::SearchItem(QObject *parent)
31+
: DApplet(parent)
32+
, m_visible(true)
33+
, m_grandSearchVisible(false)
34+
{
35+
QDBusConnection::sessionBus()
36+
.connect(grandSearchService, grandSearchPath, grandSearchInterface, "VisibleChanged", this, SLOT(onGrandSearchVisibleChanged(bool)));
37+
}
38+
39+
void SearchItem::toggleGrandSearch()
40+
{
41+
searchDbus().method("SetVisible").arg(true).call();
42+
}
43+
44+
void SearchItem::toggleGrandSearchConfig()
45+
{
46+
QProcess::startDetached("dde-grand-search", QStringList() << "--setting");
47+
}
48+
49+
DockItemInfo SearchItem::dockItemInfo()
50+
{
51+
DockItemInfo info;
52+
info.name = "search";
53+
info.displayName = tr("GrandSearch");
54+
info.itemKey = "search";
55+
info.settingKey = "search";
56+
info.visible = m_visible;
57+
info.dccIcon = DCCIconPath + "search.svg";
58+
return info;
59+
}
60+
61+
void SearchItem::setVisible(bool visible)
62+
{
63+
if (m_visible != visible) {
64+
m_visible = visible;
65+
66+
Q_EMIT visibleChanged(visible);
67+
}
68+
}
69+
70+
void SearchItem::onGrandSearchVisibleChanged(bool visible)
71+
{
72+
if (m_grandSearchVisible != visible) {
73+
m_grandSearchVisible = visible;
74+
75+
Q_EMIT grandSearchVisibleChanged(visible);
76+
}
77+
}
78+
79+
D_APPLET_CLASS(SearchItem)
80+
}
81+
82+
#include "searchitem.moc"
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
// SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd.
2+
//
3+
// SPDX-License-Identifier: GPL-3.0-or-later
4+
5+
#pragma once
6+
7+
#include "../dockiteminfo.h"
8+
#include "applet.h"
9+
#include "dsglobal.h"
10+
11+
class QDBusMessage;
12+
namespace dock
13+
{
14+
15+
class SearchItem : public DS_NAMESPACE::DApplet
16+
{
17+
Q_OBJECT
18+
Q_PROPERTY(bool visible READ visible WRITE setVisible NOTIFY visibleChanged)
19+
Q_PROPERTY(bool grandSearchVisible READ grandSearchVisible NOTIFY grandSearchVisibleChanged)
20+
public:
21+
explicit SearchItem(QObject *parent = nullptr);
22+
23+
Q_INVOKABLE void toggleGrandSearch();
24+
Q_INVOKABLE void toggleGrandSearchConfig();
25+
26+
Q_INVOKABLE DockItemInfo dockItemInfo();
27+
28+
inline bool visible() const
29+
{
30+
return m_visible;
31+
}
32+
Q_INVOKABLE void setVisible(bool visible);
33+
34+
Q_INVOKABLE bool grandSearchVisible() const
35+
{
36+
return m_grandSearchVisible;
37+
}
38+
39+
Q_SIGNALS:
40+
void visibleChanged(bool);
41+
void grandSearchVisibleChanged(bool);
42+
43+
private slots:
44+
void onGrandSearchVisibleChanged(bool);
45+
46+
private:
47+
bool m_visible;
48+
bool m_grandSearchVisible;
49+
};
50+
51+
}

0 commit comments

Comments
 (0)