1
0
mirror of https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System.git synced 2025-04-01 02:42:39 +08:00

clazy: pass context object to QObject::connect

This commit is contained in:
fb 2022-11-15 21:20:38 +01:00
parent d56bf47d39
commit fe8f205b50
2 changed files with 6 additions and 6 deletions

View File

@ -341,7 +341,7 @@ struct MainWindowPrivate
DockWidget->setMinimumSizeHintMode(ads::CDockWidget::MinimumSizeHintFromContent);
auto ToolBar = DockWidget->createDefaultToolBar();
auto Action = ToolBar->addAction(svgIcon(":/adsdemo/images/fullscreen.svg"), "Toggle Fullscreen");
QObject::connect(Action, &QAction::triggered, [=]()
QObject::connect(Action, &QAction::triggered, DockWidget, [=]()
{
if (DockWidget->isFullScreen())
{
@ -419,7 +419,7 @@ void MainWindowPrivate::createContent()
auto DockArea = DockManager->addDockWidget(ads::CenterDockWidgetArea, DockWidget, TopDockArea);
// Now we create a action to test resizing of DockArea widget
auto Action = ui.menuTests->addAction(QString("Resize %1").arg(DockWidget->windowTitle()));
QObject::connect(Action, &QAction::triggered, [DockArea]()
QObject::connect(Action, &QAction::triggered, DockArea, [DockArea]()
{
// Resizing only works, if the Splitter is visible and has a valid
// sizes
@ -445,7 +445,7 @@ void MainWindowPrivate::createContent()
auto TitleBar = DockArea->titleBar();
int Index = TitleBar->indexOf(TitleBar->tabBar());
TitleBar->insertWidget(Index + 1, CustomButton);
QObject::connect(CustomButton, &QToolButton::clicked, [=]()
QObject::connect(CustomButton, &QToolButton::clicked, DockArea, [=]()
{
auto DockWidget = createEditorWidget();
DockWidget->setFeature(ads::CDockWidget::DockWidgetDeleteOnClose, true);
@ -464,7 +464,7 @@ void MainWindowPrivate::createContent()
// Tests CustomCloseHandling without DeleteOnClose
LabelDockWidget->setFeature(ads::CDockWidget::CustomCloseHandling, true);
QObject::connect(LabelDockWidget, &ads::CDockWidget::closeRequested, [LabelDockWidget, this]()
QObject::connect(LabelDockWidget, &ads::CDockWidget::closeRequested, LabelDockWidget, [LabelDockWidget, this]()
{
int Result = QMessageBox::question(_this, "Custom Close Request",
"Do you really want to close this dock widget?");

View File

@ -35,7 +35,7 @@ int main(int argc, char *argv[])
ads::CDockManager::setConfigFlag(ads::CDockManager::AllTabsHaveCloseButton, true);
auto dockManager = new ads::CDockManager(&w);
w.setDockManager(dockManager);
QObject::connect(dockManager, &ads::CDockManager::focusedDockWidgetChanged, [] (ads::CDockWidget* old, ads::CDockWidget* now) {
QObject::connect(dockManager, &ads::CDockManager::focusedDockWidgetChanged, [](ads::CDockWidget* old, ads::CDockWidget* now) {
static int Count = 0;
qDebug() << Count++ << " CDockManager::focusedDockWidgetChanged old: " << (old ? old->objectName() : "-") << " now: " << now->objectName() << " visible: " << now->isVisible();
now->widget()->setFocus();
@ -69,7 +69,7 @@ int main(int argc, char *argv[])
action = new QAction("Toggle [DeleteContentOnClose]", &w);
w.menuBar()->addAction(action);
QObject::connect(action, &QAction::triggered, [dw]() {
QObject::connect(action, &QAction::triggered, dw, [dw]() {
dw->toggleView(dw->isClosed());
qDebug() << QString("dock widget %1! contents widget %2!").arg(dw->isClosed() ? "closed" : "open", dw->widget() ? "created" : "deleted");
});