Commit 43ab462b authored by BADER Wael's avatar BADER Wael
Browse files

Looks better

parent 7e706712
Pipeline #257485 passed with stage
in 0 seconds
{
"files.associations": {
"*.moc": "cpp",
"chrono": "cpp",
"algorithm": "cpp",
"variant": "cpp"
}
}
\ No newline at end of file
......@@ -280,7 +280,7 @@ dtkWidgetsMenuItemCustomFacade::~dtkWidgetsMenuItemCustomFacade(void)
dtkWidgetsMenuFacade::dtkWidgetsMenuFacade(dtkWidgetsMenu *m, QWidget *parent) : QWidget(parent), menu(m)
{
QVBoxLayout *layout = new QVBoxLayout(this);
layout->setContentsMargins(0, 0, 0, 0);
layout->setContentsMargins(0, 10, 0, 10);
layout->setSpacing(1);
layout->setAlignment(Qt::AlignTop);
......
......@@ -173,6 +173,7 @@ public:
void enableSpying(bool);
public:
QWidget *widgetHeader(int index);
QWidget *widget(int index);
protected:
......@@ -286,6 +287,31 @@ QWidget *dtkWidgetsOverlayPaneSliderArea::widget(int index)
return nullptr;
}
QWidget *dtkWidgetsOverlayPaneSliderArea::widgetHeader(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) { // \TODO Is it possible to have more than one item in viewport->layout?
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) {
return facade;
}
++k;
}
}
}
}
}
return nullptr;
}
void dtkWidgetsOverlayPaneSliderArea::scrollContentsBy(int dx, int dy)
{
QScrollArea::scrollContentsBy(dx, dy);
......@@ -563,9 +589,19 @@ void dtkWidgetsOverlayPaneSliderPrivate::setCurrentIndex(int index, std::functio
// highlight the destination widget
dtkWidgetsOverlayPaneSliderViewPort *viewport = dynamic_cast<dtkWidgetsOverlayPaneSliderViewPort *>(((QScrollArea*)this->area)->widget());
dtkWidgetsMenuBarContainerSlide *slide = dynamic_cast<dtkWidgetsMenuBarContainerSlide *>(viewport->layout->itemAt( 0 )->widget());
for (int n_widget = 0; n_widget < slide->layout()->count(); n_widget++)
{
QWidget *widget_header = this->area->widgetHeader( n_widget );
if (widget_header) {
QPalette pal = palette();
if (n_widget == index) {
pal.setColor(QPalette::Background, pal.color( QPalette::Highlight ) );
}
widget_header->setAutoFillBackground(true);
widget_header->setPalette(pal);
}
QWidget *widget = this->area->widget( n_widget );
if (widget) {
QPalette pal = palette();
......
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