DDE-Dock入门
Tofloor
poster avatar
海天鹰
deepin
2016-10-29 18:12
Author
本帖最后由 sonichy 于 2016-10-30 16:12 编辑


在 linux0208 的指导下,我终于做成了DDE-Dock!
他写了个教程,但是不愿意公开,我觉得开发文档很重要,分享给大家。
应用商店安装QtCreator,终端 sudo apt install qt5-default 安装Qt5开发包。
到https://github.com/linuxdeepin/dde-dock下载DDE-Dock开发包,解压后改名为dde-dock。
到https://pan.baidu.com/s/1cwxlhG下载最简范例,解压到dde-dock同级目录。

部分源码:
myplugin.cpp
#include "myplugin.h"#include
#define MYPLUGIN_KEY    "myplugin"
MyPlugin::MyPlugin(QObject *parent) :
    QObject(parent),
    m_mainWidget(new QLabel(" color=white>Dock")),
    m_tipsLabel(new QLabel)
{
}
//插件名
const QString MyPlugin::pluginName() const
{
    return "myplugin";
}
//插件初始化
void MyPlugin::init(PluginProxyInterface *proxyInter)
{
    m_proxyInter = proxyInter;
    m_proxyInter->itemAdded(this, MYPLUGIN_KEY);
}
//插件的Widget
QWidget *MyPlugin::itemWidget(const QString &itemKey)
{
    if (itemKey == MYPLUGIN_KEY)
        return m_mainWidget;
    return nullptr;
}
QWidget *MyPlugin::itemTipsWidget(const QString &itemKey)
{
    if (itemKey == MYPLUGIN_KEY)
    {   m_tipsLabel->setText(" color=white>提示");
        return m_tipsLabel;
    }
   return nullptr;
}

我的问题:
1.dock拖不动。
2.如何动态修改Dock文字?

我的终极目标:

设置编译目录:

安装文件:
install.sh
#!/bin/bash
sudo cp `dirname $0`/libMyPlugin.so /usr/lib/dde-dock/plugins/libMyPlugin.so
killall dde-dock

卸载文件:
uninstall.sh
#!/bin/bash
sudo rm /usr/lib/dde-dock/plugins/libMyPlugin.so
killall dde-dock

下面来说说我踩过的坑:
1.安装Qt4编译,(IID "com.deepin.dock.PluginsItemInterface" FILE "MyPlugin.json") 报错。必须要安装Qt5!
选择编译版本


2.dde-dock和自己开发的插件目录必须是同级目录,不然找不到头文件。
Reply Favorite View the author
All Replies
avatar
jingle
deepin
2016-10-29 18:30
#1
Reply View the author
avatar
fuyao
deepin
2016-10-29 18:46
#2
不错,文档真的很重要,可以让后人少走自己走过的坑。坑多了大家就不愿意往前走了。
Reply View the author
avatar
山西姚一
deepin
2016-10-30 06:07
#3
为楼主的精神赞一个!
Reply View the author
avatar
catbb49294929
deepin
2016-10-30 16:59
#4
赞一个,收藏了。
Reply View the author
avatar
hsia1979
deepin
2018-05-27 01:10
#5
Mark一下
Reply View the author
avatar
srwth
deepin
2018-06-01 19:58
#6
mark一下
Reply View the author
avatar
130******12
deepin
2018-06-07 06:22
#7
没看懂→_→
Reply View the author
avatar
许自强
deepin
2018-06-07 18:44
#8
Reply View the author
avatar
海天鹰
deepin
2018-06-15 16:29
#9

别看了,dock经常更新,clone官方插件源码,直接改,出错几率大幅下降。
Reply View the author