Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 21 additions & 18 deletions reader/uiframe/DocTabBar.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd.
// Copyright (C) 2019 ~ 2026 Uniontech Software Technology Co.,Ltd.
// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
Expand All @@ -14,9 +14,10 @@
#include <QMimeData>
#include <QDir>
#include <QTimer>
#include <QUuid>

Check warning on line 17 in reader/uiframe/DocTabBar.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QUuid> not found. Please note: Cppcheck does not need standard library headers to get proper results.

Check warning on line 17 in reader/uiframe/DocTabBar.cpp

View workflow job for this annotation

GitHub Actions / static-check / static-check

Include file: <QUuid> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QWindow>

Check warning on line 18 in reader/uiframe/DocTabBar.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QWindow> not found. Please note: Cppcheck does not need standard library headers to get proper results.

Check warning on line 18 in reader/uiframe/DocTabBar.cpp

View workflow job for this annotation

GitHub Actions / static-check / static-check

Include file: <QWindow> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QLayout>

Check warning on line 19 in reader/uiframe/DocTabBar.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QLayout> not found. Please note: Cppcheck does not need standard library headers to get proper results.

Check warning on line 19 in reader/uiframe/DocTabBar.cpp

View workflow job for this annotation

GitHub Actions / static-check / static-check

Include file: <QLayout> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QTabBar>

Check warning on line 20 in reader/uiframe/DocTabBar.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QTabBar> not found. Please note: Cppcheck does not need standard library headers to get proper results.

Check warning on line 20 in reader/uiframe/DocTabBar.cpp

View workflow job for this annotation

GitHub Actions / static-check / static-check

Include file: <QTabBar> not found. Please note: Cppcheck does not need standard library headers to get proper results.

DocTabBar::DocTabBar(QWidget *parent)
: DTabBar(parent)
Expand All @@ -26,6 +27,10 @@
this->setEnabledEmbedStyle(true);//设置直角样式
this->setExpanding(true);//设置平铺窗口模式
#endif
QTabBar *innerTabBar = findChild<QTabBar *>();
if (innerTabBar) {
innerTabBar->setExpanding(false);
}

this->setTabsClosable(true);

Expand Down Expand Up @@ -152,24 +157,17 @@

void DocTabBar::updateTabWidth()
{
qCDebug(appLog) << "DocTabBar::updateTabWidth start";
int tabCount = count();
if (tabCount != 0) {
qCDebug(appLog) << "DocTabBar::updateTabWidth - tabCount:" << tabCount;
int tabWidth = (this->width() - 40) / tabCount - (tabCount - 1) * 10;
for (int i = 0; i < count(); i++) {
if (tabWidth <= 140) {
setUsesScrollButtons(true);
setTabMinimumSize(i, QSize(140, 37));
setTabMaximumSize(i, QSize(140, 37));
} else {
setUsesScrollButtons(false);
setTabMinimumSize(i, QSize(tabWidth, 37));
setTabMaximumSize(i, QSize(tabWidth, 37));
}
int innerWidth = this->width() - 44;
int tabWidth = innerWidth / tabCount;
setUsesScrollButtons(tabWidth <= 140);
for (int i = 0; i < tabCount; i++) {
int w = qMax(tabWidth, 140);
setTabMinimumSize(i, QSize(w, 37));
setTabMaximumSize(i, QSize(w, 37));
}
}
qCDebug(appLog) << "DocTabBar::updateTabWidth end";
}

QMimeData *DocTabBar::createMimeDataFromTab(int index, const QStyleOptionTab &) const
Expand Down Expand Up @@ -246,10 +244,15 @@

void DocTabBar::resizeEvent(QResizeEvent *e)
{
// qCDebug(appLog) << "DocTabBar::resizeEvent start";
DTabBar::resizeEvent(e);
updateTabWidth();
// qCDebug(appLog) << "DocTabBar::resizeEvent end";
DTabBar::resizeEvent(e);
QTabBar *innerTabBar = findChild<QTabBar *>();
if (innerTabBar) {
int w = innerTabBar->width();
int h = innerTabBar->height();
innerTabBar->resize(w + 1, h);
innerTabBar->resize(w, h);
}
}

void DocTabBar::onDragActionChanged(Qt::DropAction action)
Expand Down
Loading