mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-05 13:59:52 +08:00
fix tabbar of the edit area in macOS
1. revert a3b83b7f81192bdbeabb1ba8a7eed57beb4 to avoid flashing; 2. Explicitly specify usesScrollButtons in VEditWindow;
This commit is contained in:
parent
045d6f0241
commit
94ad4adc1c
@ -17,12 +17,13 @@ VEditWindow::VEditWindow(VNote *vnote, VEditArea *editArea, QWidget *parent)
|
|||||||
initTabActions();
|
initTabActions();
|
||||||
setupCornerWidget();
|
setupCornerWidget();
|
||||||
|
|
||||||
|
// Explicit speficy in macOS.
|
||||||
|
setUsesScrollButtons(true);
|
||||||
setTabsClosable(true);
|
setTabsClosable(true);
|
||||||
setMovable(true);
|
setMovable(true);
|
||||||
setContextMenuPolicy(Qt::CustomContextMenu);
|
setContextMenuPolicy(Qt::CustomContextMenu);
|
||||||
|
|
||||||
QTabBar *bar = tabBar();
|
QTabBar *bar = tabBar();
|
||||||
bar->installEventFilter(this);
|
|
||||||
bar->setContextMenuPolicy(Qt::CustomContextMenu);
|
bar->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||||
connect(bar, &QTabBar::customContextMenuRequested,
|
connect(bar, &QTabBar::customContextMenuRequested,
|
||||||
this, &VEditWindow::tabbarContextMenuRequested);
|
this, &VEditWindow::tabbarContextMenuRequested);
|
||||||
@ -595,36 +596,6 @@ void VEditWindow::updateNotebookInfo(const VNotebook *p_notebook)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool VEditWindow::eventFilter(QObject *watched, QEvent *event)
|
|
||||||
{
|
|
||||||
if (event->type() == QEvent::Resize) {
|
|
||||||
setLeftCornerWidgetVisible(scrollerVisible());
|
|
||||||
}
|
|
||||||
return QTabWidget::eventFilter(watched, event);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool VEditWindow::scrollerVisible() const
|
|
||||||
{
|
|
||||||
QTabBar *bar = tabBar();
|
|
||||||
int barWidth = rect().width() - leftBtn->width() - rightBtn->width();
|
|
||||||
int nrTab = count();
|
|
||||||
int tabsWidth = 0;
|
|
||||||
for (int i = 0; i < nrTab; ++i) {
|
|
||||||
tabsWidth += bar->tabRect(i).width();
|
|
||||||
}
|
|
||||||
return tabsWidth > barWidth;
|
|
||||||
}
|
|
||||||
|
|
||||||
void VEditWindow::setLeftCornerWidgetVisible(bool p_visible)
|
|
||||||
{
|
|
||||||
if (p_visible) {
|
|
||||||
setCornerWidget(leftBtn, Qt::TopLeftCorner);
|
|
||||||
leftBtn->setVisible(true);
|
|
||||||
} else {
|
|
||||||
setCornerWidget(NULL, Qt::TopLeftCorner);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
VEditTab *VEditWindow::currentEditTab()
|
VEditTab *VEditWindow::currentEditTab()
|
||||||
{
|
{
|
||||||
int idx = currentIndex();
|
int idx = currentIndex();
|
||||||
|
@ -49,7 +49,6 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
|
void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
|
||||||
bool eventFilter(QObject *watched, QEvent *event) Q_DECL_OVERRIDE;
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void tabStatusChanged(const VFile *p_file, const VEditTab *p_editTab, bool p_editMode);
|
void tabStatusChanged(const VFile *p_file, const VEditTab *p_editTab, bool p_editMode);
|
||||||
@ -91,9 +90,6 @@ private:
|
|||||||
inline QString generateTooltip(const VFile *p_file) const;
|
inline QString generateTooltip(const VFile *p_file) const;
|
||||||
inline QString generateTabText(const QString &p_name, bool p_modified) const;
|
inline QString generateTabText(const QString &p_name, bool p_modified) const;
|
||||||
bool canRemoveSplit();
|
bool canRemoveSplit();
|
||||||
// If the scroller of the tabBar() is visible
|
|
||||||
bool scrollerVisible() const;
|
|
||||||
void setLeftCornerWidgetVisible(bool p_visible);
|
|
||||||
|
|
||||||
VNote *vnote;
|
VNote *vnote;
|
||||||
VEditArea *m_editArea;
|
VEditArea *m_editArea;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user