From 568ca4abf650228812650ca5c642c5cda0ab5cb6 Mon Sep 17 00:00:00 2001 From: "craig.p.drummond@gmail.com" Date: Tue, 12 Jun 2012 11:02:20 +0000 Subject: [PATCH] Dont allow selection to overlap tab-widget border lines in preferences dialog. --- ChangeLog | 2 ++ gui/preferencesdialog.cpp | 4 +--- widgets/fancytabwidget.cpp | 14 +++++++++----- widgets/fancytabwidget.h | 7 +++---- 4 files changed, 15 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index c04e14a4b..316a7f2ed 100644 --- a/ChangeLog +++ b/ChangeLog @@ -36,6 +36,8 @@ 21. Enable mouse-tracking for all list/tree views. 22. Allow Icon/List for library view. 23. Add option to show artist images in library view. +24. Dont allow selection to overlap tab-widget border lines in preferences + dialog (Qt-only build). 0.7.1 ----- diff --git a/gui/preferencesdialog.cpp b/gui/preferencesdialog.cpp index d77acd76e..22a46bef3 100644 --- a/gui/preferencesdialog.cpp +++ b/gui/preferencesdialog.cpp @@ -76,9 +76,7 @@ PreferencesDialog::PreferencesDialog(QWidget *parent, LyricsPage *lp) #ifdef ENABLE_KDE_SUPPORT KPageWidget *widget = new KPageWidget(this); #else - FancyTabWidget *widget = new FancyTabWidget(this); - widget->setAllowContextMenu(false); - widget->setDrawBorder(true); + FancyTabWidget *widget = new FancyTabWidget(this, false, true); #endif server = new ServerSettings(widget); diff --git a/widgets/fancytabwidget.cpp b/widgets/fancytabwidget.cpp index 4a8b70ec7..30329ab52 100644 --- a/widgets/fancytabwidget.cpp +++ b/widgets/fancytabwidget.cpp @@ -278,8 +278,9 @@ void FancyTab::setFader(float value) tabbar->update(); } -FancyTabBar::FancyTabBar(QWidget *parent, bool text, int iSize) +FancyTabBar::FancyTabBar(QWidget *parent, bool hasBorder, bool text, int iSize) : QWidget(parent) + , m_hasBorder(hasBorder) , m_showText(text) , m_iconSize(iSize) { @@ -440,6 +441,9 @@ void FancyTabBar::paintTab(QPainter *painter, int tabIndex) const QRect rect = tabRect(tabIndex); bool selected = (tabIndex == m_currentIndex); + if (m_hasBorder) { + rect.adjust(2, 0, -2, 0); + } QStyleOptionViewItemV4 styleOpt; styleOpt.initFrom(this); styleOpt.state&=~(QStyle::State_Selected|QStyle::State_MouseOver); @@ -527,7 +531,7 @@ void FancyTabBar::setCurrentIndex(int index) { // FancyTabWidget ////// -FancyTabWidget::FancyTabWidget(QWidget* parent) +FancyTabWidget::FancyTabWidget(QWidget* parent, bool allowContext, bool drawBorder) : QWidget(parent), mode_(Mode_None), tab_bar_(NULL), @@ -538,8 +542,8 @@ FancyTabWidget::FancyTabWidget(QWidget* parent) // use_background_(false), menu_(NULL), proxy_style_(new FancyTabProxyStyle), - allowContext_(true), - drawBorder_(false) + allowContext_(allowContext), + drawBorder_(drawBorder) { side_layout_->setSpacing(0); side_layout_->setMargin(0); @@ -718,7 +722,7 @@ void FancyTabWidget::SetMode(Mode mode) { case Mode_IconOnlySmallSidebar: case Mode_IconOnlyLargeSidebar: case Mode_LargeSidebar: { - FancyTabBar* bar = new FancyTabBar(this, Mode_LargeSidebar==mode, Mode_IconOnlySmallSidebar==mode ? 16 : 32); + FancyTabBar* bar = new FancyTabBar(this, drawBorder_, Mode_LargeSidebar==mode, Mode_IconOnlySmallSidebar==mode ? 16 : 32); side_layout_->insertWidget(0, bar); tab_bar_ = bar; diff --git a/widgets/fancytabwidget.h b/widgets/fancytabwidget.h index 6eba478a7..df14297d4 100644 --- a/widgets/fancytabwidget.h +++ b/widgets/fancytabwidget.h @@ -103,7 +103,7 @@ class FancyTabBar : public QWidget Q_OBJECT public: - FancyTabBar(QWidget *parent, bool text, int iSize ); + FancyTabBar(QWidget *parent, bool hasBorder, bool text, int iSize ); ~FancyTabBar(); void paintEvent(QPaintEvent *event); @@ -148,6 +148,7 @@ private: QList m_tabs; QTimer m_triggerTimer; QSize tabSizeHint() const; + bool m_hasBorder; bool m_showText; int m_iconSize; }; @@ -156,7 +157,7 @@ class FancyTabWidget : public QWidget { Q_OBJECT public: - FancyTabWidget(QWidget* parent = 0); + FancyTabWidget(QWidget *parent, bool allowContext=true, bool drawBorder=false); // Values are persisted - only add to the end enum Mode { @@ -208,8 +209,6 @@ public: int count() const; int visibleCount() const; Mode mode() const { return mode_; } - void setAllowContextMenu(bool a) { allowContext_=a; } - void setDrawBorder(bool b) { drawBorder_=b; } public slots: void SetCurrentIndex(int index);