Skip to content

Commit

Permalink
feat: update deepin 20.4
Browse files Browse the repository at this point in the history
  • Loading branch information
XMuli committed Feb 7, 2022
1 parent 4e06b21 commit 8cfe655
Show file tree
Hide file tree
Showing 10 changed files with 512 additions and 16 deletions.
19 changes: 15 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# cmake 运行最低版本
cmake_minimum_required(VERSION 2.8)
cmake_minimum_required(VERSION 3.2)

# 使用 set 命令设置一个变量
set(PLUGIN_NAME "lfxSpeed")
Expand All @@ -26,9 +26,20 @@ file(GLOB_RECURSE SRCS "*.h" "*.cpp" "*.json")
# <库名>_DIR 在哪个目录下找到的(Qt5Widgets_DIR)
# <库名>_INCLUDE_DIRS 有哪些头文件目录(Qt5Widgets_INCLUDE_DIRS)
# <库名>_LIBRARIES 有哪些库文件(Qt5Widgets_LIBRARIES)
#find_package(Qt5Widgets REQUIRED)
#find_package(Qt5Network REQUIRED)
#find_package(DtkWidget REQUIRED)

find_package(PkgConfig REQUIRED)
find_package(Qt5Widgets REQUIRED)
find_package(Qt5Network REQUIRED)
#find_package(Qt5Svg REQUIRED)
#find_package(Qt5DBus REQUIRED)
find_package(DtkWidget REQUIRED)
#pkg_check_modules(DFrameworkDBus REQUIRED dframeworkdbus)

#pkg_check_modules(DFrameworkDBus REQUIRED dframeworkdbus)
#pkg_check_modules(QGSettings REQUIRED gsettings-qt)

# find_package 命令还可以用来加载 cmake 的功能模块
# 并不是所有的库都直接支持 cmake 查找的,但大部分都支持了 pkg-config 这个标准,
Expand All @@ -38,7 +49,7 @@ find_package(DtkWidget REQUIRED)
# PKG_CONFIG_FOUND pkg-config 可执行文件是否找到了
# PKG_CONFIG_EXECUTABLE pkg-config 可执行文件的路径
# PKG_CONFIG_VERSION_STRING pkg-config 的版本信息
find_package(PkgConfig REQUIRED)
#find_package(PkgConfig REQUIRED)

# 加载 FindPkgConfig 模块后就可以使用 pkg_check_modules 命令加载需要的库
# pkg_check_modules 命令是由 FindPkgConfig 模块提供的,因此要使用这个命令必须先加载 FindPkgConfig 模块。
Expand All @@ -47,7 +58,7 @@ find_package(PkgConfig REQUIRED)
# DdeDockInterface_INCLUDE_DIRS
# DdeDockInterface_LIBRARIES
# 还有有另外的一些变量以及更灵活的用法,比如一次性查找多个库,这些请自行查找 cmake 文档学习。
pkg_check_modules(DdeDockInterface REQUIRED dde-dock)
#pkg_check_modules(DFrameworkDBus REQUIRED dframeworkdbus)

# add_definitions 命令用于声明/定义一些编译/预处理参数
# 根据 cmake 文档描述此命令已经有另外几个功能划分的更为细致的命令所取代,具体请查阅文档
Expand Down Expand Up @@ -121,4 +132,4 @@ foreach(_ts_file ${TS_FILES})
execute_process(
COMMAND ${LRELEASE_EXECUTABLE} ${_ts_file})

endforeach()
endforeach()
17 changes: 11 additions & 6 deletions aboutdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ void AboutDialog::init()
QVBoxLayout *vLayout = new QVBoxLayout(content);
vLayout->setContentsMargins(0, 0, 0, 0);
vLayout->addSpacing(15);
DLabel *labVersion = new DLabel(tr("Version: 0.6.5 2021/03/31"));
DLabel *labCopyright = new DLabel(tr("Copyright (c) 2021 By ifmet.cn"));
DLabel *labVersion = new DLabel(tr("Version: 0.7 2022/02/06"));
DLabel *labCopyright = new DLabel(tr("Copyright (c) 2021 By XMuli"));
vLayout->addWidget(labVersion, 0, Qt::AlignCenter);
vLayout->addWidget(labCopyright, 0, Qt::AlignCenter);
vLayout->addSpacing(15);
Expand All @@ -56,6 +56,9 @@ void AboutDialog::init()
DLabel *labAuthor = new DLabel();
labAuthor->setOpenExternalLinks(true);
labAuthor->setText(tr("<a href=\"https://ifmet.cn\">Author"));
DLabel *labAcknowledgements = new DLabel();
labAcknowledgements->setOpenExternalLinks(true);
labAcknowledgements->setText(tr("<a href=\"https://github.com/justforlxz\">Thanks"));
DLabel *labGithub = new DLabel();
labGithub->setOpenExternalLinks(true);
labGithub->setText(tr("<a href=\"https://github.com/xmuli/lfxSpeed\">GitHub"));
Expand All @@ -65,13 +68,15 @@ void AboutDialog::init()
DLabel *labDonation = new DLabel();
labDonation->setOpenExternalLinks(true);
labDonation->setText(tr("<a href=\"\">Donation"));
DLabel *labAcknowledgements = new DLabel();
labAcknowledgements->setOpenExternalLinks(true);
labAcknowledgements->setText(tr("<a href=\"https://github.com/justforlxz\">Author"));
hLayout->addStretch(1);
hLayout->addWidget(labAuthor);
hLayout->addWidget(labAcknowledgements);
hLayout->addWidget(labGithub);
hLayout->addWidget(labLicense);
hLayout->addWidget(labAcknowledgements);
hLayout->addStretch(1);
hLayout->setStretch(1, 1);
hLayout->setStretch(2, 1);
hLayout->setStretch(3, 1);

vLayout->addLayout(hLayout);
addContent(content);
Expand Down
2 changes: 1 addition & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ mkdir -p build
cd build
cmake ..
make
sudo cp `dirname $0`/liblfxSpeed.so /usr/lib/dde-dock/plugins/liblfxSpeed.so
sudo cp liblfxSpeed.so /usr/lib/dde-dock/plugins/liblfxSpeed.so
killall dde-dock
cd ..
rm -rf build
102 changes: 102 additions & 0 deletions constants.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
/*
* Copyright (C) 2011 ~ 2018 Deepin Technology Co., Ltd.
*
* Author: sbw <[email protected]>
*
* Maintainer: sbw <[email protected]>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef CONSTANTS_H
#define CONSTANTS_H

#include <QtCore>

namespace Dock {

#define DOCK_PLUGIN_MIME "dock/plugin"
#define DOCK_PLUGIN_API_VERSION "1.2.3"

#define PROP_DISPLAY_MODE "DisplayMode"

#define PLUGIN_BACKGROUND_MAX_SIZE 40
#define PLUGIN_BACKGROUND_MIN_SIZE 20

#define PLUGIN_ICON_MAX_SIZE 20
#define PLUGIN_ITEM_WIDTH 300

// 需求变更成插件图标始终保持20x20,但16x16的资源还在。所以暂时保留此宏
#define PLUGIN_ICON_MIN_SIZE 20

// 插件最小尺寸,图标采用深色
#define PLUGIN_MIN_ICON_NAME "-dark"

// dock最大尺寸
#define DOCK_MAX_SIZE 100
///
/// \brief The DisplayMode enum
/// spec dock display mode
///
enum DisplayMode {
Fashion = 0,
Efficient = 1,
// deprecreated
// Classic = 2,
};

#define PROP_HIDE_MODE "HideMode"
///
/// \brief The HideMode enum
/// spec dock hide behavior
///
enum HideMode {
KeepShowing = 0,
KeepHidden = 1,
SmartHide = 3,
};

#define PROP_POSITION "Position"
///
/// \brief The Position enum
/// spec dock position, dock always placed at primary screen,
/// so all position is the primary screen edge.
///
enum Position {
Top = 0,
Right = 1,
Bottom = 2,
Left = 3,
};

#define PROP_HIDE_STATE "HideState"
///
/// \brief The HideState enum
/// spec current dock should hide or shown.
/// this argument works only HideMode is SmartHide
///
enum HideState {
Unknown = 0,
Show = 1,
Hide = 2,
};

#define IS_TOUCH_STATE "isTouchState"

}

Q_DECLARE_METATYPE(Dock::DisplayMode)
Q_DECLARE_METATYPE(Dock::Position)

#endif // CONSTANTS_H
98 changes: 98 additions & 0 deletions pluginproxyinterface.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
/*
* Copyright (C) 2011 ~ 2018 Deepin Technology Co., Ltd.
*
* Author: sbw <[email protected]>
*
* Maintainer: sbw <[email protected]>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef PLUGINPROXYINTERFACE_H
#define PLUGINPROXYINTERFACE_H

#include "constants.h"

#include <QtCore>

class PluginsItemInterface;
class PluginProxyInterface
{
public:
///
/// \brief itemAdded
/// add a new dock item
/// if itemkey of this plugin inter already exist, the new item
/// will be ignored, so if you need to add multiple item, you need
/// to ensure all itemKey is different.
/// \param itemInter
/// your plugin interface
/// \param itemKey
/// your item unique key
///
virtual void itemAdded(PluginsItemInterface * const itemInter, const QString &itemKey) = 0;
///
/// \brief itemUpdate
/// update(repaint) spec item
/// \param itemInter
/// \param itemKey
///
virtual void itemUpdate(PluginsItemInterface * const itemInter, const QString &itemKey) = 0;
///
/// \brief itemRemoved
/// remove spec item, if spec item is not exist, dock will to nothing.
/// dock will NOT delete your object, you should manage memory by your self.
/// \param itemInter
/// \param itemKey
///
virtual void itemRemoved(PluginsItemInterface * const itemInter, const QString &itemKey) = 0;
///
/// \brief requestContextMenu
/// request show context menu
///
//virtual void requestContextMenu(PluginsItemInterface * const itemInter, const QString &itemKey) = 0;

virtual void requestWindowAutoHide(PluginsItemInterface * const itemInter, const QString &itemKey, const bool autoHide) = 0;
virtual void requestRefreshWindowVisible(PluginsItemInterface * const itemInter, const QString &itemKey) = 0;

virtual void requestSetAppletVisible(PluginsItemInterface * const itemInter, const QString &itemKey, const bool visible) = 0;

///
/// \brief saveValue
/// save module config to .config/deepin/dde-dock.conf
/// all key-values of all plugins will be save to that file
/// and grouped by the returned value of pluginName() function which is defined in PluginsItemInterface
/// \param itemInter the plugin object
/// \param key the key of data
/// \param value the data
///
virtual void saveValue(PluginsItemInterface * const itemInter, const QString &key, const QVariant &value) = 0;

///
/// \brief getValue
/// SeeAlse: saveValue
/// return value from .config/deepin/dde-dock.conf
///
virtual const QVariant getValue(PluginsItemInterface *const itemInter, const QString &key, const QVariant& fallback = QVariant()) = 0;

///
/// \brief removeValue
/// remove the values specified by keyList
/// remove all values of itemInter if keyList is empty
/// SeeAlse: saveValue
///
virtual void removeValue(PluginsItemInterface *const itemInter, const QStringList &keyList) = 0;
};

#endif // PLUGINPROXYINTERFACE_H
Loading

0 comments on commit 8cfe655

Please sign in to comment.