diff --git a/src/veditwindow.cpp b/src/veditwindow.cpp index 10c1ef1d..2f30ce2a 100644 --- a/src/veditwindow.cpp +++ b/src/veditwindow.cpp @@ -17,12 +17,13 @@ VEditWindow::VEditWindow(VNote *vnote, VEditArea *editArea, QWidget *parent) initTabActions(); setupCornerWidget(); + // Explicit speficy in macOS. + setUsesScrollButtons(true); setTabsClosable(true); setMovable(true); setContextMenuPolicy(Qt::CustomContextMenu); QTabBar *bar = tabBar(); - bar->installEventFilter(this); bar->setContextMenuPolicy(Qt::CustomContextMenu); connect(bar, &QTabBar::customContextMenuRequested, 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() { int idx = currentIndex(); diff --git a/src/veditwindow.h b/src/veditwindow.h index c7ceeb95..5a1cb100 100644 --- a/src/veditwindow.h +++ b/src/veditwindow.h @@ -49,7 +49,6 @@ public: protected: void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE; - bool eventFilter(QObject *watched, QEvent *event) Q_DECL_OVERRIDE; signals: 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 generateTabText(const QString &p_name, bool p_modified) const; bool canRemoveSplit(); - // If the scroller of the tabBar() is visible - bool scrollerVisible() const; - void setLeftCornerWidgetVisible(bool p_visible); VNote *vnote; VEditArea *m_editArea;