89 lines
2.2 KiB
C++
89 lines
2.2 KiB
C++
#include "DockWidget.h"
|
|
|
|
#include <QStyleOptionDockWidget>
|
|
|
|
#include "ui/Menu/SystemManagerMenu.h"
|
|
#include "common/SpdLogger.h"
|
|
#include "ui/MainFrame.h"
|
|
|
|
|
|
DockWidgetTitleBar::DockWidgetTitleBar(QWidget* parent)
|
|
: QWidget(parent) {
|
|
|
|
}
|
|
|
|
DockWidgetTitleBar::~DockWidgetTitleBar() {
|
|
|
|
}
|
|
|
|
//QSize DockWidgetTitleBar::minimumSizeHint() const {
|
|
// QDockWidget* dw = qobject_cast<QDockWidget*>(parentWidget());
|
|
// Q_ASSERT(dw);
|
|
// QSize result(0, 90);
|
|
// if (dw->features() & QDockWidget::DockWidgetVerticalTitleBar)
|
|
// result.transpose();
|
|
// return result;
|
|
//}
|
|
|
|
|
|
DockWidget::DockWidget(const QString& title, QWidget* parent)
|
|
: QDockWidget(title, parent) {
|
|
setFeatures(DockWidgetClosable | DockWidgetMovable | DockWidgetFloatable);
|
|
SystemManagerMenu* windowManagerMenu = MainFrame::Get().GetMenuManager<SystemManagerMenu>("system_manager");
|
|
if (nullptr != windowManagerMenu) {
|
|
windowManagerMenu->AddDockWidget(this);
|
|
}
|
|
}
|
|
|
|
DockWidget::DockWidget(QWidget* parent)
|
|
: QDockWidget(parent) {
|
|
setFeatures(DockWidgetClosable | DockWidgetMovable | DockWidgetFloatable);
|
|
}
|
|
|
|
|
|
DockWidget::~DockWidget() {
|
|
}
|
|
|
|
void DockWidget::setWindowTitle(const QString& text) {
|
|
QDockWidget::setWindowTitle(text);
|
|
if (nullptr != titleBar_) {
|
|
titleBar_->SetTitle(text);
|
|
}
|
|
}
|
|
|
|
void DockWidget::SetDockWidgetTitleBar(DockWidgetTitleBar* titleBar) {
|
|
if (nullptr != titleBar_) {
|
|
disconnect(titleBar_, &DockWidgetTitleBar::signalClose, this, &DockWidget::close);
|
|
}
|
|
titleBar_ = titleBar;
|
|
if (nullptr == titleBar_) {
|
|
LOG_ERROR("DockWidget::SetDockWidgetTitleBar titleBar is nullptr");
|
|
return;
|
|
}
|
|
|
|
titleBar_->SetTitle(windowTitle());
|
|
connect(titleBar_, &DockWidgetTitleBar::signalClose, this, &DockWidget::OnClose);
|
|
QDockWidget::setTitleBarWidget(titleBar_);
|
|
}
|
|
|
|
void DockWidget::showEvent(QShowEvent* e) {
|
|
QDockWidget::showEvent(e);
|
|
}
|
|
|
|
void DockWidget::resizeEvent(QResizeEvent* e) {
|
|
QDockWidget::resizeEvent(e);
|
|
}
|
|
|
|
void DockWidget::paintEvent(QPaintEvent* e) {
|
|
QDockWidget::paintEvent(e);
|
|
QStyleOptionDockWidget opt;
|
|
initStyleOption(&opt);
|
|
}
|
|
|
|
void DockWidget::OnClose() {
|
|
LOG_INFO("DockWidget::OnClose");
|
|
close();
|
|
emit signalClose();
|
|
}
|
|
|