Move common code info FrameViewInterface
So it's not duplicated between QtWidgets and QtQuick
This commit is contained in:
@@ -53,7 +53,7 @@ VBoxLayout::~VBoxLayout() = default;
|
||||
|
||||
Frame_qtwidgets::Frame_qtwidgets(Controllers::Frame *controller, QWidget *parent)
|
||||
: View_qtwidgets<QWidget>(controller, Type::Frame, parent)
|
||||
, m_controller(controller)
|
||||
, FrameViewInterface(controller)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -62,13 +62,13 @@ void Frame_qtwidgets::init()
|
||||
auto vlayout = new VBoxLayout(this);
|
||||
vlayout->setContentsMargins(0, 0, 0, 0);
|
||||
vlayout->setSpacing(0);
|
||||
vlayout->addWidget(asQWidget(m_controller->titleBar()));
|
||||
auto tabWidget = m_controller->tabWidget();
|
||||
vlayout->addWidget(asQWidget(m_controller->tabWidget()));
|
||||
vlayout->addWidget(asQWidget(m_frame->titleBar()));
|
||||
auto tabWidget = m_frame->tabWidget();
|
||||
vlayout->addWidget(asQWidget(m_frame->tabWidget()));
|
||||
|
||||
tabWidget->setTabBarAutoHide(!m_controller->alwaysShowsTabs());
|
||||
tabWidget->setTabBarAutoHide(!m_frame->alwaysShowsTabs());
|
||||
|
||||
if (m_controller->isOverlayed())
|
||||
if (m_frame->isOverlayed())
|
||||
setAutoFillBackground(true);
|
||||
}
|
||||
|
||||
@@ -81,65 +81,60 @@ void Frame_qtwidgets::free_impl()
|
||||
|
||||
void Frame_qtwidgets::renameTab(int index, const QString &text)
|
||||
{
|
||||
m_controller->tabWidget()->renameTab(index, text);
|
||||
m_frame->tabWidget()->renameTab(index, text);
|
||||
}
|
||||
|
||||
void Frame_qtwidgets::changeTabIcon(int index, const QIcon &icon)
|
||||
{
|
||||
m_controller->tabWidget()->changeTabIcon(index, icon);
|
||||
m_frame->tabWidget()->changeTabIcon(index, icon);
|
||||
}
|
||||
|
||||
int Frame_qtwidgets::nonContentsHeight() const
|
||||
{
|
||||
Controllers::TitleBar *tb = m_controller->titleBar();
|
||||
QWidget *tabBar = asQWidget(m_controller->tabBar());
|
||||
Controllers::TitleBar *tb = m_frame->titleBar();
|
||||
QWidget *tabBar = asQWidget(m_frame->tabBar());
|
||||
|
||||
return (tb->isVisible() ? tb->height() : 0) + (tabBar->isVisible() ? tabBar->height() : 0);
|
||||
}
|
||||
|
||||
int Frame_qtwidgets::indexOfDockWidget_impl(const Controllers::DockWidget *dw)
|
||||
{
|
||||
return m_controller->tabWidget()->indexOfDockWidget(dw);
|
||||
return m_frame->tabWidget()->indexOfDockWidget(dw);
|
||||
}
|
||||
|
||||
void Frame_qtwidgets::setCurrentDockWidget_impl(Controllers::DockWidget *dw)
|
||||
{
|
||||
m_controller->tabWidget()->setCurrentDockWidget(dw);
|
||||
m_frame->tabWidget()->setCurrentDockWidget(dw);
|
||||
}
|
||||
|
||||
int Frame_qtwidgets::currentIndex_impl() const
|
||||
{
|
||||
return m_controller->tabWidget()->currentIndex();
|
||||
return m_frame->tabWidget()->currentIndex();
|
||||
}
|
||||
|
||||
void Frame_qtwidgets::insertDockWidget_impl(Controllers::DockWidget *dw, int index)
|
||||
{
|
||||
m_controller->tabWidget()->insertDockWidget(dw, index);
|
||||
m_frame->tabWidget()->insertDockWidget(dw, index);
|
||||
}
|
||||
|
||||
void Frame_qtwidgets::removeWidget_impl(Controllers::DockWidget *dw)
|
||||
{
|
||||
m_controller->tabWidget()->removeDockWidget(dw);
|
||||
m_frame->tabWidget()->removeDockWidget(dw);
|
||||
}
|
||||
|
||||
void Frame_qtwidgets::setCurrentTabIndex_impl(int index)
|
||||
{
|
||||
m_controller->tabWidget()->setCurrentDockWidget(index);
|
||||
m_frame->tabWidget()->setCurrentDockWidget(index);
|
||||
}
|
||||
|
||||
KDDockWidgets::Controllers::DockWidget *Frame_qtwidgets::currentDockWidget_impl() const
|
||||
{
|
||||
return m_controller->tabWidget()->dockwidgetAt(m_controller->tabWidget()->currentIndex());
|
||||
return m_frame->tabWidget()->dockwidgetAt(m_frame->tabWidget()->currentIndex());
|
||||
}
|
||||
|
||||
KDDockWidgets::Controllers::DockWidget *Frame_qtwidgets::dockWidgetAt_impl(int index) const
|
||||
{
|
||||
return m_controller->tabWidget()->dockwidgetAt(index);
|
||||
}
|
||||
|
||||
Controllers::Frame *Frame_qtwidgets::frame() const
|
||||
{
|
||||
return m_controller;
|
||||
return m_frame->tabWidget()->dockwidgetAt(index);
|
||||
}
|
||||
|
||||
bool Frame_qtwidgets::event(QEvent *e)
|
||||
@@ -149,7 +144,7 @@ bool Frame_qtwidgets::event(QEvent *e)
|
||||
|
||||
if (e->type() == QEvent::ParentChange) {
|
||||
auto p = parentView();
|
||||
m_controller->setLayout(p ? p->asLayout() : nullptr);
|
||||
m_frame->setLayout(p ? p->asLayout() : nullptr);
|
||||
}
|
||||
|
||||
return QWidget::event(e);
|
||||
@@ -160,7 +155,7 @@ void Frame_qtwidgets::paintEvent(QPaintEvent *)
|
||||
if (freed())
|
||||
return;
|
||||
|
||||
if (!m_controller->isFloating()) {
|
||||
if (!m_frame->isFloating()) {
|
||||
QPainter p(this);
|
||||
p.setRenderHint(QPainter::Antialiasing);
|
||||
|
||||
@@ -168,7 +163,7 @@ void Frame_qtwidgets::paintEvent(QPaintEvent *)
|
||||
const qreal halfPenWidth = penWidth / 2;
|
||||
const QRectF rectf = QWidget::rect();
|
||||
|
||||
const bool isOverlayed = m_controller->isOverlayed();
|
||||
const bool isOverlayed = m_frame->isOverlayed();
|
||||
const QColor penColor = isOverlayed ? QColor(0x666666)
|
||||
: QColor(184, 184, 184, 184);
|
||||
QPen pen(penColor);
|
||||
@@ -190,18 +185,18 @@ QSize Frame_qtwidgets::maxSizeHint() const
|
||||
return {};
|
||||
|
||||
// waste due to QTabWidget margins, tabbar etc.
|
||||
const QSize waste = minSize() - m_controller->dockWidgetsMinSize();
|
||||
return waste + m_controller->biggestDockWidgetMaxSize();
|
||||
const QSize waste = minSize() - m_frame->dockWidgetsMinSize();
|
||||
return waste + m_frame->biggestDockWidgetMaxSize();
|
||||
}
|
||||
|
||||
QRect Frame_qtwidgets::dragRect() const
|
||||
{
|
||||
QRect rect = m_controller->dragRect();
|
||||
QRect rect = m_frame->dragRect();
|
||||
if (rect.isValid())
|
||||
return rect;
|
||||
|
||||
if (Config::self().flags() & Config::Flag_HideTitleBarWhenTabsVisible) {
|
||||
auto tabBar = qobject_cast<QTabBar *>(asQWidget(m_controller->tabBar()));
|
||||
auto tabBar = qobject_cast<QTabBar *>(asQWidget(m_frame->tabBar()));
|
||||
rect.setHeight(tabBar->height());
|
||||
rect.setWidth(QWidget::width() - tabBar->width());
|
||||
rect.moveTopLeft(QPoint(tabBar->width(), tabBar->y()));
|
||||
|
||||
Reference in New Issue
Block a user