mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-03 00:15:21 +00:00
Achieve sort right to left
This commit is contained in:
parent
1a3ba913d2
commit
f172da48d3
@ -21,18 +21,31 @@ Panel::Panel(QWidget *parent)
|
||||
|
||||
connect(leftLayout,SIGNAL(dragStarted()),this,SLOT(slotDragStarted()));
|
||||
connect(leftLayout,SIGNAL(itemDropped()),this,SLOT(slotItemDropped()));
|
||||
|
||||
AppItem * b6 = new AppItem("App",":/test/Resources/images/display-im6.q16.png");b6->resize(50,50);b6->setAcceptDrops(true);
|
||||
AppItem * b7 = new AppItem("App",":/test/Resources/images/eog.png");b7->resize(50,50);b7->setAcceptDrops(true);
|
||||
rightLayout = new DockLayout(this);
|
||||
rightLayout->setSortDirection(DockLayout::RightToLeft);
|
||||
rightLayout->resize(300,50);
|
||||
rightLayout->move(0,0);
|
||||
rightLayout->addItem(b6);
|
||||
rightLayout->addItem(b7);
|
||||
}
|
||||
|
||||
void Panel::resize(const QSize &size)
|
||||
{
|
||||
QWidget::resize(size);
|
||||
leftLayout->resize(this->width() * 2 / 3,this->height());
|
||||
qWarning() << "=========++++++++++";
|
||||
rightLayout->move(this->width() - rightLayout->width(),0);
|
||||
}
|
||||
|
||||
void Panel::resize(int width, int height)
|
||||
{
|
||||
QWidget::resize(width,height);
|
||||
leftLayout->resize(this->width() * 2 / 3,this->height());
|
||||
qWarning() << "=========++++++++++";
|
||||
rightLayout->move(this->width() - rightLayout->width(),0);
|
||||
}
|
||||
|
||||
void Panel::showScreenMask()
|
||||
|
@ -29,6 +29,7 @@ public slots:
|
||||
|
||||
private:
|
||||
DockLayout * leftLayout;
|
||||
DockLayout *rightLayout;
|
||||
QWidget * parentWidget = NULL;
|
||||
ScreenMask * maskWidget = NULL;
|
||||
};
|
||||
|
@ -86,6 +86,56 @@ void DockLayout::setSortDirection(DockLayout::Direction value)
|
||||
this->sortDirection = value;
|
||||
}
|
||||
|
||||
void DockLayout::sortLeftToRight()
|
||||
{
|
||||
if (appList.count() <= 0)
|
||||
return;
|
||||
|
||||
appList.at(0)->move(0,0);
|
||||
|
||||
for (int i = 1; i < appList.count(); i ++)
|
||||
{
|
||||
AppItem * frontItem = appList.at(i - 1);
|
||||
appList.at(i)->move(frontItem->pos().x() + frontItem->width() + itemSpacing,0);
|
||||
}
|
||||
}
|
||||
|
||||
void DockLayout::sortRightToLeft()
|
||||
{
|
||||
if (appList.count()<=0)
|
||||
return;
|
||||
|
||||
appList.at(0)->move(this->width() - itemSpacing - appList.at(0)->width(),0);
|
||||
|
||||
for (int i = 1; i < appList.count(); i++)
|
||||
{
|
||||
AppItem *fromItem = appList.at(i - 1);
|
||||
AppItem *toItem = appList.at(i);
|
||||
toItem->move(fromItem->x() - itemSpacing - toItem->width(),0);
|
||||
}
|
||||
}
|
||||
|
||||
void DockLayout::sortTopToBottom()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void DockLayout::sortBottomToTop()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
int DockLayout::indexOf(AppItem *item)
|
||||
{
|
||||
return appList.indexOf(item);
|
||||
}
|
||||
|
||||
int DockLayout::indexOf(int x, int y)
|
||||
{
|
||||
//TODO
|
||||
return 0;
|
||||
}
|
||||
|
||||
void DockLayout::relayout()
|
||||
{
|
||||
switch (sortDirection)
|
||||
@ -115,7 +165,6 @@ void DockLayout::dragoutFromLayout(int index)
|
||||
|
||||
if (index == appList.count())//note,target hast been remove before
|
||||
{
|
||||
// qWarning() << "end of list...";
|
||||
return;//at the end of list
|
||||
}
|
||||
|
||||
@ -144,46 +193,6 @@ void DockLayout::dragoutFromLayout(int index)
|
||||
|
||||
}
|
||||
|
||||
void DockLayout::sortLeftToRight()
|
||||
{
|
||||
if (appList.count() <= 0)
|
||||
return;
|
||||
|
||||
appList.at(0)->move(0,0);
|
||||
|
||||
for (int i = 1; i < appList.count(); i ++)
|
||||
{
|
||||
AppItem * frontItem = appList.at(i - 1);
|
||||
appList.at(i)->move(frontItem->pos().x() + frontItem->width() + itemSpacing,0);
|
||||
}
|
||||
}
|
||||
|
||||
void DockLayout::sortRightToLeft()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void DockLayout::sortTopToBottom()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void DockLayout::sortBottomToTop()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
int DockLayout::indexOf(AppItem *item)
|
||||
{
|
||||
return appList.indexOf(item);
|
||||
}
|
||||
|
||||
int DockLayout::indexOf(int x, int y)
|
||||
{
|
||||
//TODO
|
||||
return 0;
|
||||
}
|
||||
|
||||
void DockLayout::dragEnterEvent(QDragEnterEvent *event)
|
||||
{
|
||||
event->setDropAction(Qt::MoveAction);
|
||||
|
@ -37,10 +37,10 @@ public:
|
||||
void setMargin(DockLayout::MarginEdge edge, qreal margin);
|
||||
void setSpacing(qreal spacing);
|
||||
void setSortDirection(DockLayout::Direction value);
|
||||
void relayout();
|
||||
void dragoutFromLayout(int index);
|
||||
int indexOf(AppItem * item);
|
||||
int indexOf(int x,int y);
|
||||
void relayout();
|
||||
void dragoutFromLayout(int index);
|
||||
|
||||
signals:
|
||||
void dragStarted();
|
||||
|
@ -7,6 +7,7 @@ MainWidget::MainWidget(QWidget *parent)
|
||||
this->resize(rec.width(),50);
|
||||
Panel * mainPanel = new Panel(this);
|
||||
mainPanel->setMinimumSize(this->width(),this->height());
|
||||
mainPanel->resize(this->width(),this->height());
|
||||
mainPanel->move(0,0);
|
||||
this->setWindowFlags(Qt::ToolTip);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user