| 953 | } |
| 954 | |
| 955 | void Controller::initContextWidget() |
| 956 | { |
| 957 | if (!d->stackContextWidget) |
| 958 | d->stackContextWidget = new DStackedWidget(d->mainWindow); |
| 959 | if (!d->contextTabBar) |
| 960 | d->contextTabBar = new DFrame(d->mainWindow); |
| 961 | if (!d->contextWidget) |
| 962 | d->contextWidget = new DWidget(d->mainWindow); |
| 963 | |
| 964 | DStyle::setFrameRadius(d->contextTabBar, 0); |
| 965 | d->contextTabBar->setLineWidth(0); |
| 966 | d->contextTabBar->setFixedHeight(40); |
| 967 | |
| 968 | d->contextButtonLayout = new QHBoxLayout; |
| 969 | d->contextButtonLayout->setSpacing(0); |
| 970 | d->contextButtonLayout->setContentsMargins(12, 6, 12, 6); |
| 971 | d->contextButtonLayout->setAlignment(Qt::AlignLeft); |
| 972 | |
| 973 | DToolButton *hideBtn = new DToolButton(d->contextTabBar); |
| 974 | hideBtn->setFixedSize(35, 35); |
| 975 | hideBtn->setIcon(QIcon::fromTheme("hide_dock")); |
| 976 | hideBtn->setToolTip(tr("Hide ContextWidget")); |
| 977 | connect(hideBtn, &DToolButton::clicked, d->contextWidget, [=]() { |
| 978 | if (d->stackContextWidget->isVisible()) { |
| 979 | d->stackContextWidget->hide(); |
| 980 | d->contextWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed); |
| 981 | d->mainWindow->resizeDock(WN_CONTEXTWIDGET, d->contextTabBar->size()); |
| 982 | } else { |
| 983 | d->contextWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); |
| 984 | d->stackContextWidget->show(); |
| 985 | } |
| 986 | }); |
| 987 | |
| 988 | QHBoxLayout *tabbarLayout = new QHBoxLayout(d->contextTabBar); |
| 989 | tabbarLayout->setContentsMargins(0, 0, 0, 0); |
| 990 | tabbarLayout->addLayout(d->contextButtonLayout); |
| 991 | tabbarLayout->addWidget(hideBtn, Qt::AlignRight); |
| 992 | |
| 993 | QVBoxLayout *contextVLayout = new QVBoxLayout; |
| 994 | contextVLayout->setContentsMargins(0, 0, 0, 0); |
| 995 | contextVLayout->setSpacing(0); |
| 996 | contextVLayout->addWidget(d->contextTabBar); |
| 997 | contextVLayout->addWidget(new DHorizontalLine); |
| 998 | contextVLayout->addWidget(d->stackContextWidget); |
| 999 | d->contextWidget->setLayout(contextVLayout); |
| 1000 | |
| 1001 | // add contextWidget after add centralWidget or it`s height is incorrect |
| 1002 | WidgetInfo info; |
| 1003 | info.name = WN_CONTEXTWIDGET; |
| 1004 | info.setWidget(d->contextWidget); |
| 1005 | info.defaultPos = Position::Bottom; |
| 1006 | info.icon = QIcon::fromTheme("context_widget"); |
| 1007 | |
| 1008 | if (d->statusBar) { |
| 1009 | d->showContextBtn = createDockButton(info); |
| 1010 | d->showContextBtn->setChecked(true); |
| 1011 | d->statusBar->insertPermanentWidget(0, d->showContextBtn); |
| 1012 | } |
nothing calls this directly
no test coverage detected