diff --git a/dde-dock/Panel/panel.cpp b/dde-dock/Panel/panel.cpp index 7d42bb6bb..c2fe0bc8b 100644 --- a/dde-dock/Panel/panel.cpp +++ b/dde-dock/Panel/panel.cpp @@ -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() diff --git a/dde-dock/Panel/panel.h b/dde-dock/Panel/panel.h index 2be4f64d3..46ec03d06 100644 --- a/dde-dock/Panel/panel.h +++ b/dde-dock/Panel/panel.h @@ -29,6 +29,7 @@ public slots: private: DockLayout * leftLayout; + DockLayout *rightLayout; QWidget * parentWidget = NULL; ScreenMask * maskWidget = NULL; }; diff --git a/dde-dock/Widgets/docklayout.cpp b/dde-dock/Widgets/docklayout.cpp index 5650de5a1..6c0f319fc 100644 --- a/dde-dock/Widgets/docklayout.cpp +++ b/dde-dock/Widgets/docklayout.cpp @@ -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); diff --git a/dde-dock/Widgets/docklayout.h b/dde-dock/Widgets/docklayout.h index e85ff7759..cef4be37e 100644 --- a/dde-dock/Widgets/docklayout.h +++ b/dde-dock/Widgets/docklayout.h @@ -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(); diff --git a/dde-dock/mainwidget.cpp b/dde-dock/mainwidget.cpp index d3b465eef..5b4e680ed 100644 --- a/dde-dock/mainwidget.cpp +++ b/dde-dock/mainwidget.cpp @@ -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); }