Commit d3ef2bd0 authored by LE BRETON Come's avatar LE BRETON Come

An unstable version.

parent e07d7da1
......@@ -135,11 +135,18 @@ dtkWidgetsMenu *dtkWidgetsMenu::addMenu(int icon_id, const QString& title)
dtkWidgetsMenuFacade *dtkWidgetsMenu::widget(void)
{
if(!d->widget) {
d->widget = new dtkWidgetsMenuFacade(this);
for (QObject *object : d->object_list) {
d->widget->addWidget(dtkWidgetsMenuHelper::build(object));
if( d->widget) {
while(d->widget->layout()->count()) {
d->widget->layout()->takeAt(0)->widget()->setParent(0);
}
delete d->widget;
}
d->widget = new dtkWidgetsMenuFacade(this);
for (QObject *object : d->object_list) {
d->widget->addWidget(dtkWidgetsMenuHelper::build(object));
}
return d->widget;
......
......@@ -79,7 +79,6 @@ void handle(QWidget *item, int i, int s, QWidget *l, dtkWidgetsMenuItemFacade *l
return;
if (dtkWidgetsMenuItemFacade *facade = dynamic_cast<dtkWidgetsMenuItemFacade *>(item)) {
QObject::connect(facade, &dtkWidgetsMenuItemFacade::clicked, [=] (void) -> void
{
// facade->menu_item->emit triggered();
......@@ -330,6 +329,11 @@ dtkWidgetsMenuBarContainerSlide::~dtkWidgetsMenuBarContainerSlide(void)
void dtkWidgetsMenuBarContainerSlide::update(dtkWidgetsMenu *menu)
{
for(int i = 0; i < this->layout()->count(); i++) {
if(!menu->widget()->items().contains(this->layout()->itemAt(i)->widget()))
this->layout()->itemAt(i)->widget()->hide();
}
int i = 0;
int s = -10;
......@@ -356,11 +360,21 @@ void dtkWidgetsMenuBarContainerSlide::update(dtkWidgetsMenu *menu)
void dtkWidgetsMenuBarContainerSlide::update(dtkWidgetsMenuBar *bar)
{
QList<QWidget *> widgets;
for (dtkWidgetsMenu *menu : bar->menus()) {
widgets << menu->widget();
widgets << menu->header();
}
for(int i = 0; i < this->layout()->count(); i++) {
if(!widgets.contains(this->layout()->itemAt(i)->widget()))
this->layout()->itemAt(i)->widget()->hide();
}
for (dtkWidgetsMenu *menu : bar->menus()) {
dtkWidgetsMenuHeaderFacade *header = menu->header();
dtkWidgetsMenuFacade *widget = menu->widget();
bool got = 0;
for(int i = 0; i < this->layout()->count(); i++)
......@@ -370,6 +384,9 @@ void dtkWidgetsMenuBarContainerSlide::update(dtkWidgetsMenuBar *bar)
if(!got) {
this->layout()->addWidget(header);
this->layout()->addWidget(widget);
header->show();
widget->show();
}
int i = 0;
......
......@@ -170,7 +170,7 @@ public:
public:
QWidget *widget(int index);
protected:
bool event(QEvent *) override;
......@@ -240,7 +240,7 @@ void dtkWidgetsOverlayPaneSliderArea::wheelEvent(QWheelEvent *event)
event->phase(),
event->source(),
event->inverted());
QScrollArea::wheelEvent(e);
}
......@@ -248,30 +248,29 @@ QWidget *dtkWidgetsOverlayPaneSliderArea::widget(int index)
{
if(this->size().width() < 100)
return nullptr;
if (dtkWidgetsOverlayPaneSliderViewPort *viewport = dynamic_cast<dtkWidgetsOverlayPaneSliderViewPort *>(QScrollArea::widget())) {
for (int i = 0; i < viewport->layout->count(); i++) {
if (dtkWidgetsMenuBarContainerSlide *slide = dynamic_cast<dtkWidgetsMenuBarContainerSlide *>(viewport->layout->itemAt(i)->widget())) {
int k = 0;
for (int j = 0; j < slide->layout()->count(); j++) {
if (dtkWidgetsMenuHeaderFacade *facade = dynamic_cast<dtkWidgetsMenuHeaderFacade *>(slide->layout()->itemAt(j)->widget())) {
if(k == index) {
for (int k = j; j < slide->layout()->count(); k++) {
for (int k = j; j < slide->layout()->count(); k++) {
if (dtkWidgetsMenuFacade *facade = dynamic_cast<dtkWidgetsMenuFacade *>(slide->layout()->itemAt(k)->widget())) {
return facade;
}
}
}
k++;
}
}
......@@ -283,11 +282,11 @@ QWidget *dtkWidgetsOverlayPaneSliderArea::widget(int index)
}
void dtkWidgetsOverlayPaneSliderArea::scrollContentsBy(int dx, int dy)
{
{
QScrollArea::scrollContentsBy(dx, dy);
if (this->spying && !this->to) {
if (dtkWidgetsOverlayPaneSliderViewPort *viewport = dynamic_cast<dtkWidgetsOverlayPaneSliderViewPort *>(QScrollArea::widget())) {
for (int i = 0; i < viewport->layout->count(); i++) {
......@@ -295,16 +294,16 @@ void dtkWidgetsOverlayPaneSliderArea::scrollContentsBy(int dx, int dy)
if (dtkWidgetsMenuBarContainerSlide *slide = dynamic_cast<dtkWidgetsMenuBarContainerSlide *>(viewport->layout->itemAt(i)->widget())) {
int k = 0;
for (int j = 0; j < slide->layout()->count(); j++) {
if (dtkWidgetsMenuHeaderFacade *facade = dynamic_cast<dtkWidgetsMenuHeaderFacade *>(slide->layout()->itemAt(j)->widget())) {
int p_y = this->mapToGlobal(this->rect().topLeft()).y();
int s_y = facade->mapToGlobal(this->rect().topLeft()).y();
if(s_y > p_y) {
emit q->indexVisible(k);
return;
......@@ -348,7 +347,7 @@ public slots:
public slots:
void setCurrentIndex(int);
void setCurrentIndex(int, std::function<void (void)>&);
private slots:
QAbstractAnimation *slideToPrivate(int);
QAbstractAnimation *slideToPrivate(int, std::function<void (void)>&);
......@@ -610,12 +609,12 @@ void dtkWidgetsOverlayPaneSliderPrivate::setCurrentIndex(int index)
{
if (this->size().width() < 100)
return;
if (this->area->to)
return;
QWidget *destination = this->area->widget(index);
const QRect microFocus = destination ->inputMethodQuery(Qt::ImMicroFocus).toRect();
const QRect defaultMicroFocus = destination->QWidget::inputMethodQuery(Qt::ImMicroFocus).toRect();
......@@ -632,7 +631,7 @@ void dtkWidgetsOverlayPaneSliderPrivate::setCurrentIndex(int index)
double xf = this->area->verticalScrollBar()->value();
double xt = -1.0;
if (focusRect.height() > visibleRect.height())
xt = focusRect.center().y() - this->area->viewport()->height() / 2;
else if (focusRect.bottom() > visibleRect.bottom())
......@@ -686,7 +685,7 @@ void dtkWidgetsOverlayPaneSliderPrivate::setCurrentIndex(int index, std::functio
return;
focusRect.adjust(0, -32, 0, 32 + 1); // No bug. To include title. // TODO: use theme
double xf = this->area->verticalScrollBar()->value();
double xt = -1.0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment