Add option to control scroll tabs on mouse wheel

pull/16/head
Michele Calgaro 11 years ago committed by Slávek Banko
parent cced03e1d4
commit 6b1b515330

@ -16,6 +16,11 @@
along with this library; see the file COPYING.LIB. If not, write to along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA. Boston, MA 02110-1301, USA.
--------------------------------------------------------------
Additional changes:
- 2013/10/14 Michele Calgaro:
add "scroll tabs on mouse wheel event" functionality
*/ */
#include <tqapplication.h> #include <tqapplication.h>
@ -32,16 +37,16 @@
class KTabWidgetPrivate { class KTabWidgetPrivate {
public: public:
bool m_automaticResizeTabs; bool m_automaticResizeTabs;
int m_maxLength; int m_maxLength;
int m_minLength; int m_minLength;
unsigned int m_CurrentMaxLength; unsigned int m_CurrentMaxLength;
bool m_mouseWheelScroll;
//holds the full names of the tab, otherwise all we // Holds the full names of the tab, otherwise all we know about is the shortened name
//know about is the shortened name
TQStringList m_tabNames; TQStringList m_tabNames;
KTabWidgetPrivate() { KTabWidgetPrivate() : m_automaticResizeTabs(false), m_mouseWheelScroll(true)
m_automaticResizeTabs = false; {
TDEConfigGroupSaver groupsaver(TDEGlobal::config(), "General"); TDEConfigGroupSaver groupsaver(TDEGlobal::config(), "General");
m_maxLength = TDEGlobal::config()->readNumEntry("MaximumTabLength", 30); m_maxLength = TDEGlobal::config()->readNumEntry("MaximumTabLength", 30);
m_minLength = TDEGlobal::config()->readNumEntry("MinimumTabLength", 3); m_minLength = TDEGlobal::config()->readNumEntry("MinimumTabLength", 3);
@ -122,6 +127,11 @@ bool KTabWidget::isTabBarHidden() const
return !( tabBar()->isVisible() ); return !( tabBar()->isVisible() );
} }
void KTabWidget::setMouseWheelScroll(bool mouseWheelScroll)
{
d->m_mouseWheelScroll = mouseWheelScroll;
}
void KTabWidget::setTabColor( TQWidget *w, const TQColor& color ) void KTabWidget::setTabColor( TQWidget *w, const TQColor& color )
{ {
TQTab *t = tabBar()->tabAt( indexOf( w ) ); TQTab *t = tabBar()->tabAt( indexOf( w ) );
@ -332,20 +342,21 @@ void KTabWidget::wheelEvent( TQWheelEvent *e )
e->ignore(); e->ignore();
} }
void KTabWidget::wheelDelta( int delta ) void KTabWidget::wheelDelta(int delta)
{ {
if ( count() < 2 ) if (count()<2 || !d->m_mouseWheelScroll)
return; return;
int page = currentPageIndex(); int page = currentPageIndex();
if ( delta < 0 ) if (delta<0)
page = (page + 1) % count(); page = (page + 1) % count();
else { else
page--; {
if ( page < 0 ) page--;
page = count() - 1; if (page<0)
page = count() - 1;
} }
setCurrentPage( page ); setCurrentPage(page);
} }
#endif #endif

@ -16,6 +16,11 @@
along with this library; see the file COPYING.LIB. If not, write to along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA. Boston, MA 02110-1301, USA.
--------------------------------------------------------------
Additional changes:
- 2013/10/14 Michele Calgaro:
add "scroll tabs on mouse wheel event" functionality
*/ */
#ifndef KTABWIDGET_H #ifndef KTABWIDGET_H
@ -44,14 +49,17 @@ class TDEUI_EXPORT KTabWidget : public TQTabWidget
public: public:
KTabWidget( TQWidget *parent = 0, const char *name = 0, WFlags f = 0 ); KTabWidget( TQWidget *parent = 0, const char *name = 0, WFlags f = 0 );
/** /**
* Destructor. * Destructor.
*/ */
virtual ~KTabWidget(); virtual ~KTabWidget();
/*! /*!
Set the tab of the given widget to \a color. Set the tab of the given widget to \a color.
*/ */
void setTabColor( TQWidget *, const TQColor& color ); void setTabColor( TQWidget *, const TQColor& color );
/*! /*!
Returns the tab color for the given widget. Returns the tab color for the given widget.
*/ */
@ -102,6 +110,13 @@ public:
*/ */
bool isTabBarHidden() const; bool isTabBarHidden() const;
/*!
Enable/disable "scroll tabs on mouse wheel event" functionality
\a mouseWheelScroll true -> scroll enabled, false -> scroll disabled
@since 14.0
*/
void setMouseWheelScroll(bool mouseWheelScroll);
/*! /*!
Reimplemented for internal reasons. Reimplemented for internal reasons.
*/ */

Loading…
Cancel
Save