cutter/src/widgets/CutterDockWidget.cpp

36 lines
740 B
C++
Raw Normal View History

#include "CutterDockWidget.h"
#include "MainWindow.h"
CutterDockWidget::CutterDockWidget(MainWindow *main, QAction *action) :
QDockWidget(main),
action(action)
{
if (action) {
main->addToDockWidgetList(this);
main->addDockWidgetAction(this, action);
connect(action, &QAction::triggered, this, &CutterDockWidget::toggleDockWidget);
}
}
void CutterDockWidget::toggleDockWidget(bool show)
{
2018-03-21 20:32:32 +00:00
if (!show) {
this->close();
2018-03-21 20:32:32 +00:00
} else {
this->show();
this->raise();
}
}
2018-03-21 20:32:32 +00:00
void CutterDockWidget::closeEvent(QCloseEvent *event)
{
if (action) {
this->action->setChecked(false);
}
QDockWidget::closeEvent(event);
}
CutterDockWidget::~CutterDockWidget() {}