2023-02-16 13:51:55 +08:00
|
|
|
|
// Copyright (C) 2011 ~ 2018 Deepin Technology Co., Ltd.
|
|
|
|
|
// SPDX-FileCopyrightText: 2018 - 2023 UnionTech Software Technology Co., Ltd.
|
|
|
|
|
//
|
|
|
|
|
// SPDX-License-Identifier: LGPL-3.0-or-later
|
2022-05-12 17:09:10 +08:00
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <QScopedPointer>
|
|
|
|
|
#include <QLabel>
|
2023-03-07 14:43:30 +08:00
|
|
|
|
#include <QPaintEvent>
|
2022-05-12 17:09:10 +08:00
|
|
|
|
|
|
|
|
|
#include "basetraywidget.h"
|
|
|
|
|
|
|
|
|
|
class QGSettings;
|
|
|
|
|
|
|
|
|
|
class IndicatorTrayItem: public BaseTrayWidget
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
explicit IndicatorTrayItem(const QString &indicatorName, QWidget *parent = Q_NULLPTR, Qt::WindowFlags f = Qt::WindowFlags());
|
|
|
|
|
~IndicatorTrayItem() override;
|
|
|
|
|
|
|
|
|
|
QString itemKeyForConfig() override;
|
|
|
|
|
void updateIcon() override;
|
|
|
|
|
void sendClick(uint8_t, int, int) override;
|
|
|
|
|
void enableLabel(bool enable);
|
|
|
|
|
static QString toIndicatorKey(const QString &indicatorName) { return QString("indicator:%1").arg(indicatorName); }
|
|
|
|
|
static bool isIndicatorKey(const QString &itemKey) { return itemKey.startsWith("indicator:"); }
|
|
|
|
|
QPixmap icon() override;
|
2022-05-17 20:57:09 +08:00
|
|
|
|
const QByteArray &pixmapData() const;
|
|
|
|
|
const QString text() const;
|
2023-03-15 12:10:07 +08:00
|
|
|
|
bool containsPoint(const QPoint &mouse) override { return false; }
|
2022-05-12 17:09:10 +08:00
|
|
|
|
|
2023-03-07 14:43:30 +08:00
|
|
|
|
private:
|
|
|
|
|
void paintEvent(QPaintEvent *) override;
|
|
|
|
|
|
2022-05-12 17:09:10 +08:00
|
|
|
|
public Q_SLOTS:
|
|
|
|
|
Q_SCRIPTABLE void setPixmapData(const QByteArray &data);
|
|
|
|
|
Q_SCRIPTABLE void setText(const QString &text);
|
|
|
|
|
|
|
|
|
|
Q_SIGNALS:
|
|
|
|
|
void clicked(uint8_t, int, int);
|
2023-03-07 14:43:30 +08:00
|
|
|
|
void textChanged(const QString &text);
|
2022-05-12 17:09:10 +08:00
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
QString m_indicatorName;
|
|
|
|
|
bool m_enableClick; // 置灰时设置为false,不触发click信号
|
2022-05-17 20:57:09 +08:00
|
|
|
|
QByteArray m_pixmapData;
|
2023-03-07 14:43:30 +08:00
|
|
|
|
QString m_text;
|
2022-05-12 17:09:10 +08:00
|
|
|
|
};
|
|
|
|
|
|