-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
23 changed files
with
1,099 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"api": "2.0.0" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// SPDX-FileCopyrightText: 2019 - 2023 UnionTech Software Technology Co., Ltd. | ||
// | ||
// SPDX-License-Identifier: LGPL-3.0-or-later | ||
|
||
#ifndef CLIPBOARDCONTROLLER_H | ||
#define CLIPBOARDCONTROLLER_H | ||
|
||
#include <DSingleton> | ||
|
||
#include <QDBusInterface> | ||
#include <QObject> | ||
|
||
class ClipboardController : public QObject, public Dtk::Core::DSingleton<ClipboardController> | ||
{ | ||
friend Dtk::Core::DSingleton<ClipboardController>; | ||
|
||
Q_OBJECT | ||
public: | ||
ClipboardController() | ||
{ | ||
} | ||
|
||
~ClipboardController() { } | ||
|
||
void toggle() | ||
{ | ||
QDBusInterface interface("org.deepin.dde.Clipboard1", | ||
"/org/deepin/dde/Clipboard1", | ||
"org.deepin.dde.Clipboard1", | ||
QDBusConnection::sessionBus()); | ||
if (interface.isValid()) { | ||
interface.call("Toggle"); | ||
} | ||
} | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
// SPDX-FileCopyrightText: 2020 - 2022 UnionTech Software Technology Co., Ltd. | ||
// | ||
// SPDX-License-Identifier: LGPL-3.0-or-later | ||
|
||
#include "clipboarditem.h" | ||
#include "constants.h" | ||
#include "clipboardcontroller.h" | ||
|
||
#include <DDBusSender> | ||
#include <DGuiApplicationHelper> | ||
|
||
#include <QDBusConnection> | ||
#include <QIcon> | ||
#include <QJsonDocument> | ||
#include <QPainter> | ||
#include <QVBoxLayout> | ||
#include <QMouseEvent> | ||
|
||
DGUI_USE_NAMESPACE | ||
|
||
#define SHIFT "shift" | ||
|
||
ClipboardItem::ClipboardItem(QWidget* parent) | ||
: QWidget(parent) | ||
, m_tipsLabel(new TipsWidget(this)) | ||
, m_icon(new CommonIconButton(this)) | ||
{ | ||
init(); | ||
} | ||
|
||
void ClipboardItem::init() | ||
{ | ||
m_tipsLabel->setVisible(false); | ||
m_tipsLabel->setText(tr("Clipboard")); | ||
|
||
m_icon->setFixedSize(Dock::DOCK_PLUGIN_ITEM_FIXED_SIZE); | ||
m_icon->setIcon(QIcon::fromTheme("clipboard")); | ||
m_icon->setClickable(true); | ||
|
||
auto vLayout = new QVBoxLayout(this); | ||
vLayout->setSpacing(0); | ||
vLayout->setMargin(0); | ||
vLayout->addWidget(m_icon, 0, Qt::AlignCenter); | ||
|
||
refreshIcon(); | ||
|
||
connect(DGuiApplicationHelper::instance(), &DGuiApplicationHelper::themeTypeChanged, this, &ClipboardItem::refreshIcon); | ||
connect(m_icon, &CommonIconButton::clicked, this, [] { | ||
ClipboardController::ref().toggle(); | ||
}); | ||
} | ||
|
||
QWidget* ClipboardItem::tipsWidget() | ||
{ | ||
return m_tipsLabel; | ||
} | ||
|
||
const QString ClipboardItem::contextMenu() const | ||
{ | ||
QList<QVariant> items; | ||
items.reserve(1); | ||
|
||
QMap<QString, QVariant> shift; | ||
shift["itemId"] = SHIFT; | ||
shift["itemText"] = tr("Open"); | ||
shift["isActive"] = true; | ||
items.push_back(shift); | ||
|
||
QMap<QString, QVariant> menu; | ||
menu["items"] = items; | ||
menu["checkableMenu"] = false; | ||
menu["singleCheck"] = false; | ||
|
||
return QJsonDocument::fromVariant(menu).toJson(); | ||
} | ||
|
||
void ClipboardItem::invokeMenuItem(const QString menuId, const bool checked) | ||
{ | ||
Q_UNUSED(menuId); | ||
Q_UNUSED(checked); | ||
|
||
if (menuId == SHIFT) { | ||
ClipboardController::ref().toggle(); | ||
Q_EMIT requestHideApplet(); | ||
} | ||
} | ||
|
||
void ClipboardItem::refreshIcon() | ||
{ | ||
m_icon->setState(CommonIconButton::Default); | ||
} | ||
|
||
void ClipboardItem::resizeEvent(QResizeEvent* e) | ||
{ | ||
QWidget::resizeEvent(e); | ||
|
||
const Dock::Position position = qApp->property(PROP_POSITION).value<Dock::Position>(); | ||
if (position == Dock::Bottom || position == Dock::Top) { | ||
setMaximumWidth(height()); | ||
setMaximumHeight(QWIDGETSIZE_MAX); | ||
} else { | ||
setMaximumHeight(width()); | ||
setMaximumWidth(QWIDGETSIZE_MAX); | ||
} | ||
|
||
refreshIcon(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// SPDX-FileCopyrightText: 2020 - 2022 UnionTech Software Technology Co., Ltd. | ||
// | ||
// SPDX-License-Identifier: LGPL-3.0-or-later | ||
|
||
#ifndef CLIPBOARDITEM_H | ||
#define CLIPBOARDITEM_H | ||
|
||
#include "commoniconbutton.h" | ||
#include "widget/tipswidget.h" | ||
|
||
#include <QWidget> | ||
|
||
class ClipboardItem : public QWidget | ||
{ | ||
Q_OBJECT | ||
|
||
public: | ||
explicit ClipboardItem(QWidget *parent = nullptr); | ||
|
||
QWidget *tipsWidget(); | ||
const QString contextMenu() const; | ||
void invokeMenuItem(const QString menuId, const bool checked); | ||
void refreshIcon(); | ||
|
||
protected: | ||
void resizeEvent(QResizeEvent *e) override; | ||
|
||
signals: | ||
void requestHideApplet(); | ||
|
||
private: | ||
void init(); | ||
|
||
private: | ||
TipsWidget *m_tipsLabel; | ||
CommonIconButton *m_icon; | ||
QPixmap m_iconPixmap; | ||
}; | ||
|
||
#endif // CLIPBOARDITEM_H |
Oops, something went wrong.