examples: Use lambdas instead of functor classes
Change-Id: Iee2cc22a9239ab5a351cb5ecb2c8ce10ed019b2c Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
This commit is contained in:
parent
280f067fe0
commit
e7b8df6349
@ -282,23 +282,10 @@ void MainWindow::loadLayout()
|
||||
}
|
||||
}
|
||||
|
||||
class DockWidgetAreaCornerFunctor {
|
||||
public:
|
||||
explicit DockWidgetAreaCornerFunctor(QMainWindow *mw, Qt::Corner c, Qt::DockWidgetArea a)
|
||||
: m_mainWindow(mw), m_area(a), m_corner(c) {}
|
||||
|
||||
void operator()() const { m_mainWindow->setCorner(m_corner, m_area); }
|
||||
|
||||
private:
|
||||
QMainWindow *m_mainWindow;
|
||||
Qt::DockWidgetArea m_area;
|
||||
Qt::Corner m_corner;
|
||||
};
|
||||
|
||||
static QAction *addCornerAction(const QString &text, QMainWindow *mw, QMenu *menu, QActionGroup *group,
|
||||
Qt::Corner c, Qt::DockWidgetArea a)
|
||||
{
|
||||
QAction *result = menu->addAction(text, mw, DockWidgetAreaCornerFunctor(mw, c, a));
|
||||
QAction *result = menu->addAction(text, mw, [=]() { mw->setCorner(c, a); });
|
||||
result->setCheckable(true);
|
||||
group->addAction(result);
|
||||
return result;
|
||||
|
@ -264,16 +264,6 @@ void MainWindow::updateMenus()
|
||||
#endif
|
||||
}
|
||||
|
||||
class ActiveMdiSubWindowFunctor {
|
||||
public:
|
||||
explicit ActiveMdiSubWindowFunctor(QMdiArea *mdiArea, QMdiSubWindow *activeWindow) : m_mdiArea(mdiArea), m_activeWindow(activeWindow) {}
|
||||
void operator()() const { m_mdiArea->setActiveSubWindow(m_activeWindow); }
|
||||
|
||||
private:
|
||||
QMdiArea *m_mdiArea;
|
||||
QMdiSubWindow *m_activeWindow;
|
||||
};
|
||||
|
||||
void MainWindow::updateWindowMenu()
|
||||
{
|
||||
windowMenu->clear();
|
||||
@ -302,7 +292,9 @@ void MainWindow::updateWindowMenu()
|
||||
text = tr("%1 %2").arg(i + 1)
|
||||
.arg(child->userFriendlyCurrentFile());
|
||||
}
|
||||
QAction *action = windowMenu->addAction(text, mdiSubWindow, ActiveMdiSubWindowFunctor(mdiArea, mdiSubWindow));
|
||||
QAction *action = windowMenu->addAction(text, mdiSubWindow, [this, mdiSubWindow]() {
|
||||
mdiArea->setActiveSubWindow(mdiSubWindow);
|
||||
});
|
||||
action->setCheckable(true);
|
||||
action ->setChecked(child == activeMdiChild());
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user