mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-03 00:15:21 +00:00
Transparent panel
This commit is contained in:
parent
7ff94854e4
commit
f047e958c4
@ -1,3 +1,23 @@
|
||||
<RCC>
|
||||
<qresource prefix="/test"/>
|
||||
<qresource prefix="/test">
|
||||
<file>Resources/images/brasero.png</file>
|
||||
<file>Resources/images/crossover.png</file>
|
||||
<file>Resources/images/d-feet.png</file>
|
||||
<file>Resources/images/deepin-multitasking-view.svg</file>
|
||||
<file>Resources/images/display-im6.q16.png</file>
|
||||
<file>Resources/images/eog.png</file>
|
||||
<file>Resources/images/file-roller.png</file>
|
||||
<file>Resources/images/gcr-gnupg.png</file>
|
||||
<file>Resources/images/gcr-key-pair.png</file>
|
||||
<file>Resources/images/gcr-key.png</file>
|
||||
<file>Resources/images/gcr-password.png</file>
|
||||
<file>Resources/images/gcr-smart-card.png</file>
|
||||
<file>Resources/images/google-chrome.png</file>
|
||||
<file>Resources/images/gparted.png</file>
|
||||
<file>Resources/images/inkscape.png</file>
|
||||
<file>Resources/images/QtProject-qtcreator.png</file>
|
||||
<file>Resources/images/remmina.png</file>
|
||||
<file>Resources/images/terminator.png</file>
|
||||
<file>Resources/images/vim.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
@ -1,17 +1,19 @@
|
||||
#include "panel.h"
|
||||
|
||||
Panel::Panel(QWidget *parent)
|
||||
: QWidget(parent),parentWidget(parent)
|
||||
: QLabel(parent),parentWidget(parent)
|
||||
{
|
||||
this->setStyleSheet("QWidget{background-color: rgba(0,0,0,0.3);}");
|
||||
|
||||
leftLayout = new DockLayout(this);
|
||||
leftLayout->resize(1024,50);
|
||||
leftLayout->move(0,0);
|
||||
|
||||
AppItem * b1 = new AppItem("App","../Resources/images/brasero.png");b1->resize(50,50);b1->setAcceptDrops(true);
|
||||
AppItem * b2 = new AppItem("App","../Resources/images/crossover.png");b2->resize(50,50);b2->setAcceptDrops(true);
|
||||
AppItem * b3 = new AppItem("App","../Resources/images/gcr-gnupg.png");b3->resize(50,50);b3->setAcceptDrops(true);
|
||||
AppItem * b4 = new AppItem("App","../Resources/images/display-im6.q16.png");b4->resize(50,50);b4->setAcceptDrops(true);
|
||||
AppItem * b5 = new AppItem("App","../Resources/images/eog.png");b5->resize(50,50);b5->setAcceptDrops(true);
|
||||
AppItem * b1 = new AppItem("App",":/test/Resources/images/brasero.png");
|
||||
AppItem * b2 = new AppItem("App",":/test/Resources/images/crossover.png");
|
||||
AppItem * b3 = new AppItem("App",":/test/Resources/images/vim.png");
|
||||
AppItem * b4 = new AppItem("App",":/test/Resources/images/google-chrome.png");
|
||||
AppItem * b5 = new AppItem("App",":/test/Resources/images/QtProject-qtcreator.png");
|
||||
|
||||
leftLayout->addItem(b1);
|
||||
leftLayout->addItem(b2);
|
||||
@ -22,8 +24,8 @@ Panel::Panel(QWidget *parent)
|
||||
connect(leftLayout,SIGNAL(dragStarted()),this,SLOT(slotDragStarted()));
|
||||
connect(leftLayout,SIGNAL(itemDropped()),this,SLOT(slotItemDropped()));
|
||||
|
||||
AppItem * b6 = new AppItem("App","../Resources/images/display-im6.q16.png");b6->resize(50,50);b6->setAcceptDrops(true);
|
||||
AppItem * b7 = new AppItem("App","../Resources/images/eog.png");b7->resize(50,50);b7->setAcceptDrops(true);
|
||||
AppItem * b6 = new AppItem("App","../Resources/images/display-im6.q16.png");
|
||||
AppItem * b7 = new AppItem("App","../Resources/images/eog.png");
|
||||
rightLayout = new DockLayout(this);
|
||||
rightLayout->setSortDirection(DockLayout::RightToLeft);
|
||||
rightLayout->resize(300,50);
|
||||
|
@ -2,13 +2,14 @@
|
||||
#define PANEL_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QLabel>
|
||||
#include <QPushButton>
|
||||
#include <QDebug>
|
||||
#include "Widgets/appitem.h"
|
||||
#include "Widgets/docklayout.h"
|
||||
#include "Widgets/screenmask.h"
|
||||
|
||||
class Panel : public QWidget
|
||||
class Panel : public QLabel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
@ -3,5 +3,5 @@
|
||||
AppBackground::AppBackground(QWidget *parent) :
|
||||
QLabel(parent)
|
||||
{
|
||||
this->setStyleSheet("background:#121922;border-radius: 4px;");
|
||||
this->setStyleSheet("QLabel#AppBackground{background: rgba(255,255,255,0.3);border-radius: 4px;}");
|
||||
}
|
||||
|
@ -11,6 +11,8 @@ AppIcon::AppIcon(QWidget *parent,Qt::WindowFlags f) :
|
||||
{
|
||||
this->setParent(parent);
|
||||
this->setWindowFlags(f);
|
||||
this->setAttribute(Qt::WA_TranslucentBackground);
|
||||
this->setAlignment(Qt::AlignCenter);
|
||||
}
|
||||
|
||||
AppIcon::AppIcon(QString iconPath, QWidget *parent, Qt::WindowFlags f) :
|
||||
@ -18,9 +20,11 @@ AppIcon::AppIcon(QString iconPath, QWidget *parent, Qt::WindowFlags f) :
|
||||
{
|
||||
this->setParent(parent);
|
||||
this->setWindowFlags(f);
|
||||
this->setAttribute(Qt::WA_TranslucentBackground);
|
||||
this->setAlignment(Qt::AlignCenter);
|
||||
|
||||
QString sysIconPath = getSysIcon(iconPath);
|
||||
QPixmap iconPixmap(this->width(),this->height());
|
||||
QPixmap iconPixmap;
|
||||
if (sysIconPath != "")
|
||||
{
|
||||
iconPixmap.load(sysIconPath);
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include <QWidget>
|
||||
#include <QLabel>
|
||||
#include <QPixmap>
|
||||
#include <QDebug>
|
||||
|
||||
class AppIcon : public QLabel
|
||||
{
|
||||
|
@ -5,8 +5,9 @@ AppItem::AppItem(QWidget *parent) :
|
||||
{
|
||||
setParent(parent);
|
||||
|
||||
initBackground();
|
||||
setAcceptDrops(true);
|
||||
resize(itemWidth,itemHeight);
|
||||
initBackground();
|
||||
}
|
||||
|
||||
AppItem::AppItem(QString title, QWidget *parent):
|
||||
@ -15,7 +16,9 @@ AppItem::AppItem(QString title, QWidget *parent):
|
||||
this->setParent(parent);
|
||||
this->itemTitle = title;
|
||||
|
||||
this->initBackground();
|
||||
setAcceptDrops(true);
|
||||
resize(itemWidth,itemHeight);
|
||||
initBackground();
|
||||
}
|
||||
|
||||
AppItem::AppItem(QString title, QString iconPath, QWidget *parent) :
|
||||
@ -25,20 +28,10 @@ AppItem::AppItem(QString title, QString iconPath, QWidget *parent) :
|
||||
this->itemTitle = title;
|
||||
this->itemIconPath = iconPath;
|
||||
|
||||
this->initBackground();
|
||||
this->setIcon(itemIconPath);
|
||||
}
|
||||
|
||||
void AppItem::resize(const QSize &size)
|
||||
{
|
||||
QFrame::resize(size);
|
||||
resizeResources();
|
||||
}
|
||||
|
||||
void AppItem::resize(int width, int height)
|
||||
{
|
||||
QFrame::resize(width,height);
|
||||
resizeResources();
|
||||
setAcceptDrops(true);
|
||||
resize(itemWidth,itemHeight);
|
||||
initBackground();
|
||||
setIcon(itemIconPath);
|
||||
}
|
||||
|
||||
QPoint AppItem::getNextPos()
|
||||
|
@ -27,8 +27,6 @@ public:
|
||||
AppItem(QString title, QString iconPath, QWidget *parent = 0);
|
||||
~AppItem();
|
||||
|
||||
void resize(const QSize &size);
|
||||
void resize(int width, int height);
|
||||
QPoint getNextPos();
|
||||
void setNextPos(const QPoint &value);
|
||||
void setNextPos(int x, int y);
|
||||
@ -62,6 +60,8 @@ private:
|
||||
private:
|
||||
AppBackground * appBackground = NULL;
|
||||
QPoint nextPos;
|
||||
const int itemWidth = 60;
|
||||
const int itemHeight = 50;
|
||||
};
|
||||
|
||||
#endif // APPITEM_H
|
||||
|
@ -19,7 +19,7 @@ void DockItem::setIcon(const QString &iconPath, int size)
|
||||
{
|
||||
appIcon = new AppIcon(iconPath,this);
|
||||
appIcon->resize(size,size);
|
||||
appIcon->move(this->width() / 2, this->height() / 2);
|
||||
appIcon->move((this->height() - appIcon->height()) / 2, (this->height() - appIcon->height()) / 2);
|
||||
}
|
||||
|
||||
void DockItem::setActived(bool value)
|
||||
|
@ -91,7 +91,7 @@ void DockLayout::sortLeftToRight()
|
||||
if (appList.count() <= 0)
|
||||
return;
|
||||
|
||||
appList.at(0)->move(0,0);
|
||||
appList.at(0)->move(itemSpacing,0);
|
||||
|
||||
for (int i = 1; i < appList.count(); i ++)
|
||||
{
|
||||
@ -172,7 +172,7 @@ void DockLayout::addSpacingItem()
|
||||
animation->setStartValue(targetItem->pos());
|
||||
animation->setEndValue(targetItem->getNextPos());
|
||||
animation->setDuration(150 + i * 10);
|
||||
animation->setEasingCurve(QEasingCurve::InOutBack);
|
||||
animation->setEasingCurve(QEasingCurve::OutCubic);
|
||||
|
||||
animation->start();
|
||||
}
|
||||
@ -272,7 +272,7 @@ void DockLayout::slotItemEntered(QDragEnterEvent * event,AppItem *item)
|
||||
animation->setStartValue(targetItem->pos());
|
||||
animation->setEndValue(targetItem->getNextPos());
|
||||
animation->setDuration(200);
|
||||
animation->setEasingCurve(QEasingCurve::InOutBack);
|
||||
animation->setEasingCurve(QEasingCurve::OutCubic);
|
||||
animation->start();
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,10 @@ MainWidget::MainWidget(QWidget *parent)
|
||||
mainPanel->setMinimumSize(this->width(),this->height());
|
||||
mainPanel->resize(this->width(),this->height());
|
||||
mainPanel->move(0,0);
|
||||
|
||||
this->setWindowFlags(Qt::ToolTip);
|
||||
this->setAttribute(Qt::WA_TranslucentBackground);
|
||||
this->move(0,800);
|
||||
}
|
||||
|
||||
MainWidget::~MainWidget()
|
||||
|
Loading…
x
Reference in New Issue
Block a user