Commit 04026def authored by Erwan Demairy's avatar Erwan Demairy
Browse files

Highlight the parameters entries corresponding to a left-most icon when the icon is clicked.

parent 4c7e4353
Pipeline #254587 passed with stage
in 0 seconds
......@@ -255,7 +255,7 @@ QWidget *dtkWidgetsOverlayPaneSliderArea::widget(int index)
if (dtkWidgetsOverlayPaneSliderViewPort *viewport = dynamic_cast<dtkWidgetsOverlayPaneSliderViewPort *>(QScrollArea::widget())) {
for (int i = 0; i < viewport->layout->count(); ++i) {
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())) {
......@@ -560,6 +560,23 @@ void dtkWidgetsOverlayPaneSliderPrivate::setCurrentIndex(int index, std::functio
if (this->area->to)
return;
// 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 = this->area->widget( n_widget );
if (widget) {
QPalette pal = palette();
if (n_widget == index) {
pal.setColor(QPalette::Background, pal.color( QPalette::Highlight ) );
}
widget->setAutoFillBackground(true);
widget->setPalette(pal);
}
}
QWidget *destination = this->area->widget(index);
const QRect microFocus = destination ->inputMethodQuery(Qt::ImMicroFocus).toRect();
......
......@@ -31,9 +31,9 @@ void dtkWidgetsWorkspaceStackBarOverview::paintEvent(QPaintEvent *event)
QPainter painter(this);
painter.setRenderHint(QPainter::Antialiasing);
painter.setPen(Qt::NoPen);
painter.setBrush(QColor(0, 0, 0, 128));
painter.setBrush(QColor(255, 0, 0, 128));
painter.drawRect(0, this->size().height() - offset - margin, this->size().width(), margin * 7/4);
painter.setPen(Qt::white);
painter.setPen(Qt::green);
painter.drawText(this->size().width()/2 - metrics.width(text)/2, this->size().height() - offset, text);
}
......@@ -64,13 +64,14 @@ public:
}
public:
QWidget* source( void );
void setSource(QWidget *);
protected:
void mousePressEvent(QMouseEvent *);
private:
QWidget *source = nullptr;
QWidget *_source = nullptr;
private:
dtkWidgetsWorkspaceStackBarOverview *overview;
......@@ -102,11 +103,16 @@ dtkWidgetsWorkspaceStackBarItem::~dtkWidgetsWorkspaceStackBarItem(void)
}
QWidget* dtkWidgetsWorkspaceStackBarItem::source( void )
{
return this->_source;
}
void dtkWidgetsWorkspaceStackBarItem::setSource(QWidget *source)
{
this->source = source;
this->_source = source;
this->overview->setObjectName(this->source->objectName());
this->overview->setObjectName(this->_source->objectName());
QTimer *timer = new QTimer(this);
timer->setInterval(1000);
......@@ -115,8 +121,8 @@ void dtkWidgetsWorkspaceStackBarItem::setSource(QWidget *source)
connect(timer, &QTimer::timeout, [=] (void) {
if (this->visibleRegion().isNull())
return;
QPixmap pixmap(this->source->size());
this->source->render(&pixmap);
QPixmap pixmap(this->_source->size());
this->_source->render(&pixmap);
this->overview->setPixmap(pixmap.scaledToWidth(280));
});
......@@ -195,6 +201,12 @@ void dtkWidgetsWorkspaceStackBar::setStack(QStackedWidget *stack)
for(dtkWidgetsWorkspaceStackBarItem *it : d->items) {
this->style()->unpolish(it);
it->setActive(it == item);
QPalette pal = palette();
pal.setColor(QPalette::Background, Qt::black);
it->source()->setAutoFillBackground(true);
it->source()->setPalette(pal);
this->style()->polish(it);
}
});
......
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