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.
|
2022-09-06 11:36:55 +08:00
|
|
|
|
//
|
|
|
|
|
// SPDX-License-Identifier: LGPL-3.0-or-later
|
2018-02-07 11:52:47 +08:00
|
|
|
|
|
2017-12-28 19:23:50 +08:00
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <QScopedPointer>
|
2018-07-24 19:55:39 +08:00
|
|
|
|
#include <QLabel>
|
|
|
|
|
|
2017-12-28 19:23:50 +08:00
|
|
|
|
#include "abstracttraywidget.h"
|
|
|
|
|
|
2021-07-26 16:10:50 +08:00
|
|
|
|
class QGSettings;
|
|
|
|
|
|
2017-12-28 19:23:50 +08:00
|
|
|
|
class IndicatorTrayWidget: public AbstractTrayWidget
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
public:
|
2019-03-18 20:15:32 +08:00
|
|
|
|
explicit IndicatorTrayWidget(const QString &indicatorName, QWidget *parent = Q_NULLPTR, Qt::WindowFlags f = Qt::WindowFlags());
|
2017-12-28 19:23:50 +08:00
|
|
|
|
~IndicatorTrayWidget();
|
|
|
|
|
|
2019-03-18 20:15:32 +08:00
|
|
|
|
QString itemKeyForConfig() override;
|
2020-06-13 19:19:30 +08:00
|
|
|
|
void updateIcon() override;
|
|
|
|
|
void sendClick(uint8_t, int, int) override;
|
2021-07-26 16:10:50 +08:00
|
|
|
|
void enableLabel(bool enable);
|
2019-03-18 16:11:02 +08:00
|
|
|
|
static QString toIndicatorKey(const QString &indicatorName) { return QString("indicator:%1").arg(indicatorName); }
|
2017-12-28 19:23:50 +08:00
|
|
|
|
static bool isIndicatorKey(const QString &itemKey) { return itemKey.startsWith("indicator:"); }
|
|
|
|
|
|
2021-07-26 16:10:50 +08:00
|
|
|
|
protected:
|
|
|
|
|
void resizeEvent(QResizeEvent *event) override;
|
|
|
|
|
|
2017-12-28 19:23:50 +08:00
|
|
|
|
public Q_SLOTS:
|
|
|
|
|
Q_SCRIPTABLE void setPixmapData(const QByteArray &data);
|
|
|
|
|
Q_SCRIPTABLE void setText(const QString &text);
|
|
|
|
|
|
2021-07-26 16:10:50 +08:00
|
|
|
|
private slots:
|
|
|
|
|
void onGSettingsChanged(const QString &key);
|
|
|
|
|
|
2017-12-28 19:23:50 +08:00
|
|
|
|
Q_SIGNALS:
|
|
|
|
|
void clicked(uint8_t, int, int);
|
|
|
|
|
|
|
|
|
|
private:
|
2018-07-24 19:55:39 +08:00
|
|
|
|
QLabel *m_label;
|
2019-03-18 20:15:32 +08:00
|
|
|
|
|
|
|
|
|
QString m_indicatorName;
|
2021-07-26 16:10:50 +08:00
|
|
|
|
const QGSettings *m_gsettings;
|
|
|
|
|
bool m_enableClick; // 置灰时设置为false,不触发click信号
|
2017-12-28 19:23:50 +08:00
|
|
|
|
};
|
|
|
|
|
|