SideBar: rewritten to use QToolBar instead of KMultiTabBar
Rewrote implementation of class SideBar to use QToolBar instead of
KMultiTabBar. We can style the SideBar now easily via CSS and do not
have to ship 3rd party KDE code with LMMS. Also the QToolBar based
SideBar integrates much better into the according widget style.
Furthermore renamed SideBar related classes and files to match new
coding style.
(cherry picked from commit 822a22ca37)
This commit is contained in:
@@ -128,6 +128,14 @@ QToolButton:checked {
|
||||
padding: 3px 0px 0px 3px;
|
||||
}
|
||||
|
||||
SideBar {
|
||||
background: qlineargradient(x1:0, y1:0, x2:1, y2:0, stop: 0 #66728c, stop: 1.0 #38404e);
|
||||
}
|
||||
|
||||
SideBar QToolButton {
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
FxMixerView QPushButton, EffectRackView QPushButton, ControllerRackView QPushButton {
|
||||
font-size: 10px;
|
||||
}
|
||||
|
||||
57
include/SideBar.h
Normal file
57
include/SideBar.h
Normal file
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* SideBar.h - side-bar in LMMS' MainWindow
|
||||
*
|
||||
* Copyright (c) 2004-2009 Tobias Doerffel <tobydox/at/users.sourceforge.net>
|
||||
*
|
||||
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public
|
||||
* License along with this program (see COPYING); if not, write to the
|
||||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301 USA.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _SIDE_BAR_H
|
||||
#define _SIDE_BAR_H
|
||||
|
||||
#include <QtCore/QMap>
|
||||
#include <QtGui/QButtonGroup>
|
||||
#include <QtGui/QToolBar>
|
||||
|
||||
class QToolButton;
|
||||
class SideBarWidget;
|
||||
|
||||
|
||||
class SideBar : public QToolBar
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
SideBar( Qt::Orientation _orientation, QWidget * _parent );
|
||||
virtual ~SideBar();
|
||||
|
||||
void appendTab( SideBarWidget * _sbw );
|
||||
|
||||
|
||||
private slots:
|
||||
void toggleButton( QAbstractButton * _btn );
|
||||
|
||||
|
||||
private:
|
||||
QButtonGroup m_btnGroup;
|
||||
typedef QMap<QToolButton *, QWidget *> ButtonMap;
|
||||
ButtonMap m_widgets;
|
||||
|
||||
} ;
|
||||
|
||||
#endif
|
||||
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* side_bar_widget.h - base-class for all side-bar-widgets
|
||||
* SideBarWidget.h - base-class for all side-bar-widgets
|
||||
*
|
||||
* Copyright (c) 2004-2009 Tobias Doerffel <tobydox/at/users.sourceforge.net>
|
||||
*
|
||||
* Copyright (c) 2004-2007 Tobias Doerffel <tobydox/at/users.sourceforge.net>
|
||||
*
|
||||
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
@@ -22,7 +22,6 @@
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _SIDE_BAR_WIDGET_H
|
||||
#define _SIDE_BAR_WIDGET_H
|
||||
|
||||
@@ -31,39 +30,46 @@
|
||||
#include <QtGui/QWidget>
|
||||
|
||||
|
||||
class sideBarWidget : public QWidget
|
||||
class SideBarWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
sideBarWidget( const QString & _title, const QPixmap & _icon,
|
||||
SideBarWidget( const QString & _title, const QPixmap & _icon,
|
||||
QWidget * _parent );
|
||||
virtual ~sideBarWidget();
|
||||
virtual ~SideBarWidget();
|
||||
|
||||
inline const QPixmap & icon() const
|
||||
{
|
||||
return( m_icon );
|
||||
return m_icon;
|
||||
}
|
||||
inline const QString & title() const
|
||||
{
|
||||
return( m_title );
|
||||
return m_title;
|
||||
}
|
||||
|
||||
|
||||
protected:
|
||||
virtual void paintEvent( QPaintEvent * _pe );
|
||||
virtual void resizeEvent( QResizeEvent * _re );
|
||||
inline virtual void contextMenuEvent( QContextMenuEvent * )
|
||||
virtual void contextMenuEvent( QContextMenuEvent * )
|
||||
{
|
||||
}
|
||||
|
||||
inline QWidget * contentParent()
|
||||
QWidget * contentParent()
|
||||
{
|
||||
return( m_contents );
|
||||
return m_contents;
|
||||
}
|
||||
inline void addContentWidget( QWidget * _w )
|
||||
|
||||
void addContentWidget( QWidget * _w )
|
||||
{
|
||||
m_layout->addWidget( _w );
|
||||
}
|
||||
|
||||
void addContentLayout( QLayout * _l )
|
||||
{
|
||||
m_layout->addLayout( _l );
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
QWidget * m_contents;
|
||||
@@ -73,5 +79,4 @@ private:
|
||||
|
||||
} ;
|
||||
|
||||
|
||||
#endif
|
||||
@@ -31,7 +31,7 @@
|
||||
#include <QtGui/QTreeWidget>
|
||||
|
||||
|
||||
#include "side_bar_widget.h"
|
||||
#include "SideBarWidget.h"
|
||||
|
||||
|
||||
class QLineEdit;
|
||||
@@ -44,7 +44,7 @@ class trackContainer;
|
||||
|
||||
|
||||
|
||||
class fileBrowser : public sideBarWidget
|
||||
class fileBrowser : public SideBarWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
||||
@@ -1,309 +0,0 @@
|
||||
/***************************************************************************
|
||||
kmultitabbar.h - description
|
||||
-------------------
|
||||
begin : 2001
|
||||
copyright : (C) 2001,2002,2003 by Joseph Wenninger <jowenn@kde.org>
|
||||
***************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public License
|
||||
along with this library; see the file COPYING.LIB. If not, write to
|
||||
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA.
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef _KMultitabbar_h_
|
||||
#define _KMultitabbar_h_
|
||||
|
||||
#include <QtCore/QString>
|
||||
#include <QtCore/QList>
|
||||
#include <QtGui/QLayout>
|
||||
#include <QtGui/QPushButton>
|
||||
|
||||
class QPixmap;
|
||||
class QPainter;
|
||||
class QFrame;
|
||||
class QMenu;
|
||||
|
||||
class KMultiTabBarPrivate;
|
||||
class KMultiTabBarTabPrivate;
|
||||
class KMultiTabBarButtonPrivate;
|
||||
class KMultiTabBarInternal;
|
||||
|
||||
/**
|
||||
* A Widget for horizontal and vertical tabs.
|
||||
* It is possible to add normal buttons to the top/left
|
||||
* The handling if only one tab at a time or multiple tabs
|
||||
* should be raisable is left to the "user".
|
||||
*@author Joseph Wenninger
|
||||
*/
|
||||
class KMultiTabBar: public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum KMultiTabBarMode{Horizontal, Vertical};
|
||||
enum KMultiTabBarPosition{Left, Right, Top, Bottom};
|
||||
|
||||
/**
|
||||
* The list of available styles for KMultiTabBar
|
||||
* - VSNET - Visual Studio .Net like (only show the text of active tabs
|
||||
* - KDEV3 - Kdevelop 3 like (always show the text)
|
||||
* - KONQSBC - konqy's classic sidebar style (unthemed) (currently disabled)
|
||||
*/
|
||||
enum KMultiTabBarStyle{VSNET=0, KDEV3=1, KONQSBC=2, KDEV3ICON=3,STYLELAST=0xffff};
|
||||
|
||||
KMultiTabBar(KMultiTabBarMode bm,QWidget *parent=0 );
|
||||
virtual ~KMultiTabBar();
|
||||
|
||||
/**
|
||||
* append a new button to the button area. The button can later on be accessed with button(ID)
|
||||
* eg for connecting signals to it
|
||||
* @param pic a pixmap for the button
|
||||
* @param id an arbitraty ID value. It will be emitted in the clicked signal for identifying the button
|
||||
* if more than one button is connected to a signals.
|
||||
* @param popup A popup menu which should be displayed if the button is clicked
|
||||
* @param not_used_yet will be used for a popup text in the future
|
||||
*/
|
||||
int appendButton(const QPixmap &pic,int id=-1,QMenu* popup=0,const QString& not_used_yet=QString());
|
||||
/**
|
||||
* remove a button with the given ID
|
||||
*/
|
||||
void removeButton(int id);
|
||||
/**
|
||||
* append a new tab to the tab area. It can be accessed lateron with tabb(id);
|
||||
* @param pic a bitmap for the tab
|
||||
* @param id an arbitrary ID which can be used later on to identify the tab
|
||||
* @param text if a mode with text is used it will be the tab text, otherwise a mouse over hint
|
||||
*/
|
||||
int appendTab(const QPixmap &pic,int id=-1,const QString& text=QString());
|
||||
/**
|
||||
* remove a tab with a given ID
|
||||
*/
|
||||
void removeTab(int id);
|
||||
/**
|
||||
* set a tab to "raised"
|
||||
* @param id The ID of the tab to manipulate
|
||||
* @param state true == activated/raised, false == not active
|
||||
*/
|
||||
void setTab(int id ,bool state);
|
||||
/**
|
||||
* return the state of a tab, identified by it's ID
|
||||
*/
|
||||
bool isTabRaised(int id) const;
|
||||
/**
|
||||
* get a pointer to a button within the button area identified by its ID
|
||||
*/
|
||||
class KMultiTabBarButton *button(int id) const;
|
||||
|
||||
/**
|
||||
* get a pointer to a tab within the tab area, identiifed by its ID
|
||||
*/
|
||||
class KMultiTabBarTab *tab(int id) const;
|
||||
/**
|
||||
* set the real position of the widget.
|
||||
* @param pos if the mode is horizontal, only use top, bottom, if it is vertical use left or right
|
||||
*/
|
||||
void setPosition(KMultiTabBarPosition pos);
|
||||
/**
|
||||
* get the tabbar position.
|
||||
* @return position
|
||||
*/
|
||||
KMultiTabBarPosition position() const;
|
||||
/**
|
||||
* set the display style of the tabs
|
||||
*/
|
||||
void setStyle(KMultiTabBarStyle style);
|
||||
/**
|
||||
* get the display style of the tabs
|
||||
* @return display style
|
||||
*/
|
||||
KMultiTabBarStyle tabStyle() const;
|
||||
/**
|
||||
* be carefull, don't delete tabs yourself and don't delete the list itself
|
||||
*/
|
||||
QList<KMultiTabBarTab *>* tabs();
|
||||
/**
|
||||
* be carefull, don't delete buttons yourself and don't delete the list itself
|
||||
*/
|
||||
QList<KMultiTabBarButton *>* buttons();
|
||||
|
||||
/**
|
||||
* might vanish, not sure yet
|
||||
*/
|
||||
void showActiveTabTexts(bool show=true);
|
||||
protected:
|
||||
friend class KMultiTabBarButton;
|
||||
virtual void fontChange( const QFont& );
|
||||
void updateSeparator();
|
||||
private:
|
||||
class KMultiTabBarInternal *m_internal;
|
||||
QBoxLayout *m_l;
|
||||
QFrame *m_btnTabSep;
|
||||
QList<KMultiTabBarButton *> m_buttons;
|
||||
KMultiTabBarPosition m_position;
|
||||
KMultiTabBarPrivate *d;
|
||||
};
|
||||
|
||||
/**
|
||||
* This class should never be created except with the appendButton call of KMultiTabBar
|
||||
*/
|
||||
class KMultiTabBarButton: public QPushButton
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
KMultiTabBarButton(const QPixmap& pic,const QString&, QMenu *popup,
|
||||
int id,QWidget *parent, KMultiTabBar::KMultiTabBarPosition pos, KMultiTabBar::KMultiTabBarStyle style);
|
||||
KMultiTabBarButton(const QString&, QMenu *popup,
|
||||
int id,QWidget *parent, KMultiTabBar::KMultiTabBarPosition pos, KMultiTabBar::KMultiTabBarStyle style);
|
||||
virtual ~KMultiTabBarButton();
|
||||
int id() const;
|
||||
|
||||
public slots:
|
||||
/**
|
||||
* this is used internaly, but can be used by the user, if (s)he wants to
|
||||
* It the according call of KMultiTabBar is invoked though this modifications will be overwritten
|
||||
*/
|
||||
void setPosition(KMultiTabBar::KMultiTabBarPosition);
|
||||
/**
|
||||
* this is used internaly, but can be used by the user, if (s)he wants to
|
||||
* It the according call of KMultiTabBar is invoked though this modifications will be overwritten
|
||||
*/
|
||||
void setStyle(KMultiTabBar::KMultiTabBarStyle);
|
||||
|
||||
/**
|
||||
* modify the text of the button
|
||||
*/
|
||||
void setText(const QString &);
|
||||
|
||||
QSize sizeHint() const;
|
||||
|
||||
protected:
|
||||
KMultiTabBar::KMultiTabBarPosition m_position;
|
||||
KMultiTabBar::KMultiTabBarStyle m_style;
|
||||
QString m_text;
|
||||
virtual void hideEvent( class QHideEvent*);
|
||||
virtual void showEvent( class QShowEvent*);
|
||||
private:
|
||||
int m_id;
|
||||
KMultiTabBarButtonPrivate *d;
|
||||
signals:
|
||||
/**
|
||||
* this is emitted if the button is clicked
|
||||
* @param id the ID identifying the button
|
||||
*/
|
||||
void clicked(int id);
|
||||
protected slots:
|
||||
virtual void slotClicked();
|
||||
};
|
||||
|
||||
/**
|
||||
* This class should never be created except with the appendTab call of KMultiTabBar
|
||||
*/
|
||||
class KMultiTabBarTab: public KMultiTabBarButton
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
KMultiTabBarTab(const QPixmap& pic,const QString&,int id,QWidget *parent,
|
||||
KMultiTabBar::KMultiTabBarPosition pos,KMultiTabBar::KMultiTabBarStyle style);
|
||||
virtual ~KMultiTabBarTab();
|
||||
/**
|
||||
* set the active state of the tab
|
||||
* @param state true==active false==not active
|
||||
*/
|
||||
void setState(bool state);
|
||||
/**
|
||||
* choose if the text should always be displayed
|
||||
* this is only used in classic mode if at all
|
||||
*/
|
||||
void showActiveTabText(bool show);
|
||||
void resize(){ setSize( neededSize() ); }
|
||||
private:
|
||||
bool m_showActiveTabText;
|
||||
int m_expandedSize;
|
||||
KMultiTabBarTabPrivate *d;
|
||||
protected:
|
||||
friend class KMultiTabBarInternal;
|
||||
void setSize(int);
|
||||
int neededSize();
|
||||
void updateState();
|
||||
virtual void paintEvent(QPaintEvent *);
|
||||
virtual void drawButton(QPainter *);
|
||||
virtual void drawButtonLabel(QPainter *);
|
||||
void drawButtonStyled(QPainter *);
|
||||
void drawButtonClassic(QPainter *);
|
||||
protected slots:
|
||||
virtual void slotClicked();
|
||||
void setTabsPosition(KMultiTabBar::KMultiTabBarPosition);
|
||||
|
||||
public slots:
|
||||
virtual void setIcon(const QString&);
|
||||
virtual void setIcon(const QPixmap&);
|
||||
};
|
||||
/***************************************************************************
|
||||
kmultitabbar_p.h - description
|
||||
-------------------
|
||||
begin : 2003
|
||||
copyright : (C) 2003 by Joseph Wenninger <jowenn@kde.org>
|
||||
***************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public License
|
||||
along with this library; see the file COPYING.LIB. If not, write to
|
||||
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA.
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
class KMultiTabBarInternal: public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
KMultiTabBarInternal(QWidget *parent,KMultiTabBar::KMultiTabBarMode bm);
|
||||
int appendTab(const QPixmap &,int=-1,const QString& =QString());
|
||||
KMultiTabBarTab *tab(int) const;
|
||||
void removeTab(int);
|
||||
void setPosition(enum KMultiTabBar::KMultiTabBarPosition pos);
|
||||
void setStyle(enum KMultiTabBar::KMultiTabBarStyle style);
|
||||
void showActiveTabTexts(bool show);
|
||||
QList<KMultiTabBarTab *>* tabs(){return &m_tabs;}
|
||||
private:
|
||||
friend class KMultiTabBar;
|
||||
QWidget *box;
|
||||
QBoxLayout *mainLayout;
|
||||
QList<KMultiTabBarTab *> m_tabs;
|
||||
enum KMultiTabBar::KMultiTabBarPosition m_position;
|
||||
bool m_showActiveTabTexts;
|
||||
enum KMultiTabBar::KMultiTabBarStyle m_style;
|
||||
int m_expandedTabSize;
|
||||
int m_lines;
|
||||
KMultiTabBar::KMultiTabBarMode m_barMode;
|
||||
protected:
|
||||
virtual bool eventFilter(QObject *,QEvent*);
|
||||
// virtual void paintEvent( QPaintEvent * );
|
||||
|
||||
virtual void resizeEvent(QResizeEvent *);
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
@@ -28,14 +28,14 @@
|
||||
#include <QtCore/QTimer>
|
||||
#include <QtGui/QPixmap>
|
||||
|
||||
#include "side_bar_widget.h"
|
||||
#include "SideBarWidget.h"
|
||||
#include "Plugin.h"
|
||||
|
||||
|
||||
class trackContainer;
|
||||
|
||||
|
||||
class pluginBrowser : public sideBarWidget
|
||||
class pluginBrowser : public SideBarWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
||||
@@ -1,97 +0,0 @@
|
||||
/*
|
||||
* side_bar.h - code for side-bar in LMMS
|
||||
*
|
||||
* Copyright (c) 2004-2008 Tobias Doerffel <tobydox/at/users.sourceforge.net>
|
||||
*
|
||||
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public
|
||||
* License along with this program (see COPYING); if not, write to the
|
||||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301 USA.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _SIDE_BAR_H
|
||||
#define _SIDE_BAR_H
|
||||
|
||||
#include <QtCore/QMap>
|
||||
|
||||
#include "kmultitabbar.h"
|
||||
#include "side_bar_widget.h"
|
||||
|
||||
|
||||
class sideBar : public KMultiTabBar
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
sideBar( KMultiTabBarMode _m, QWidget * _parent ) :
|
||||
KMultiTabBar( _m, _parent )
|
||||
{
|
||||
}
|
||||
|
||||
virtual ~sideBar()
|
||||
{
|
||||
}
|
||||
|
||||
inline int appendTab( sideBarWidget * _sbw, int _id )
|
||||
{
|
||||
int ret = KMultiTabBar::appendTab( _sbw->icon(), _id,
|
||||
_sbw->title() );
|
||||
m_widgets[_id] = _sbw;
|
||||
_sbw->hide();
|
||||
_sbw->setMinimumWidth( 200 );
|
||||
connect( tab( _id ), SIGNAL( clicked( int ) ), this,
|
||||
SLOT( tabClicked( int ) ) );
|
||||
return( ret );
|
||||
}
|
||||
|
||||
|
||||
private slots:
|
||||
inline void tabClicked( int _id )
|
||||
{
|
||||
// disable all other tabbar-buttons
|
||||
QMap<int, QWidget *>::Iterator it;
|
||||
for( it = m_widgets.begin(); it != m_widgets.end(); ++it )
|
||||
{
|
||||
if( it.key() != _id/* && isTabRaised(it.key()) == true*/ )
|
||||
{
|
||||
setTab( it.key(), false );
|
||||
}
|
||||
if( m_widgets[it.key()] != NULL )
|
||||
{
|
||||
m_widgets[it.key()]->hide();
|
||||
}
|
||||
}
|
||||
if( m_widgets[_id] != NULL )
|
||||
{
|
||||
if( isTabRaised( _id ) )
|
||||
{
|
||||
m_widgets[_id]->show();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_widgets[_id]->hide();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
QMap<int, QWidget *> m_widgets;
|
||||
|
||||
} ;
|
||||
|
||||
|
||||
#endif
|
||||
@@ -49,7 +49,7 @@
|
||||
#include "ControllerRackView.h"
|
||||
#include "file_browser.h"
|
||||
#include "plugin_browser.h"
|
||||
#include "side_bar.h"
|
||||
#include "SideBar.h"
|
||||
#include "config_mgr.h"
|
||||
#include "mixer.h"
|
||||
#include "PluginView.h"
|
||||
@@ -84,47 +84,44 @@ MainWindow::MainWindow( void ) :
|
||||
hbox->setSpacing( 0 );
|
||||
hbox->setMargin( 0 );
|
||||
|
||||
sideBar * side_bar = new sideBar( sideBar::Vertical, w );
|
||||
side_bar->setStyle( sideBar::VSNET/*KDEV3ICON*/ );
|
||||
side_bar->setPosition( sideBar::Left );
|
||||
SideBar * sideBar = new SideBar( Qt::Vertical, w );
|
||||
|
||||
QSplitter * splitter = new QSplitter( Qt::Horizontal, w );
|
||||
splitter->setChildrenCollapsible( FALSE );
|
||||
|
||||
int id = 0;
|
||||
QString wdir = configManager::inst()->workingDir();
|
||||
side_bar->appendTab( new pluginBrowser( splitter ), ++id );
|
||||
side_bar->appendTab( new fileBrowser(
|
||||
sideBar->appendTab( new pluginBrowser( splitter ) );
|
||||
sideBar->appendTab( new fileBrowser(
|
||||
configManager::inst()->userProjectsDir() + "*" +
|
||||
configManager::inst()->factoryProjectsDir(),
|
||||
"*.mmp *.mmpz *.xml *.mid *.flp",
|
||||
tr( "My projects" ),
|
||||
embed::getIconPixmap( "project_file" ),
|
||||
splitter ), ++id );
|
||||
side_bar->appendTab( new fileBrowser(
|
||||
splitter ) );
|
||||
sideBar->appendTab( new fileBrowser(
|
||||
configManager::inst()->userSamplesDir() + "*" +
|
||||
configManager::inst()->factorySamplesDir(),
|
||||
"*", tr( "My samples" ),
|
||||
embed::getIconPixmap( "sample_file" ),
|
||||
splitter ), ++id );
|
||||
side_bar->appendTab( new fileBrowser(
|
||||
splitter ) );
|
||||
sideBar->appendTab( new fileBrowser(
|
||||
configManager::inst()->userPresetsDir() + "*" +
|
||||
configManager::inst()->factoryPresetsDir(),
|
||||
"*.xpf *.cs.xml *.xiz",
|
||||
tr( "My presets" ),
|
||||
embed::getIconPixmap( "preset_file" ),
|
||||
splitter ), ++id );
|
||||
side_bar->appendTab( new fileBrowser( QDir::homePath(), "*",
|
||||
splitter ) );
|
||||
sideBar->appendTab( new fileBrowser( QDir::homePath(), "*",
|
||||
tr( "My home" ),
|
||||
embed::getIconPixmap( "home" ),
|
||||
splitter ), ++id );
|
||||
splitter ) );
|
||||
QFileInfoList drives = QDir::drives();
|
||||
QStringList root_paths;
|
||||
foreach( const QFileInfo & drive, drives )
|
||||
{
|
||||
root_paths += drive.absolutePath();
|
||||
}
|
||||
side_bar->appendTab( new fileBrowser( root_paths.join( "*" ), "*",
|
||||
sideBar->appendTab( new fileBrowser( root_paths.join( "*" ), "*",
|
||||
#ifdef LMMS_BUILD_WIN32
|
||||
tr( "My computer" ),
|
||||
#else
|
||||
@@ -137,7 +134,7 @@ MainWindow::MainWindow( void ) :
|
||||
#else
|
||||
false
|
||||
#endif
|
||||
), ++id );
|
||||
) );
|
||||
|
||||
m_workspace = new QMdiArea( splitter );
|
||||
|
||||
@@ -161,7 +158,7 @@ MainWindow::MainWindow( void ) :
|
||||
m_workspace->setHorizontalScrollBarPolicy( Qt::ScrollBarAsNeeded );
|
||||
m_workspace->setVerticalScrollBarPolicy( Qt::ScrollBarAsNeeded );
|
||||
|
||||
hbox->addWidget( side_bar );
|
||||
hbox->addWidget( sideBar );
|
||||
hbox->addWidget( splitter );
|
||||
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ enum TreeWidgetItemTypes
|
||||
fileBrowser::fileBrowser( const QString & _directories, const QString & _filter,
|
||||
const QString & _title, const QPixmap & _pm,
|
||||
QWidget * _parent, bool _dirs_as_items ) :
|
||||
sideBarWidget( _title, _pm, _parent ),
|
||||
SideBarWidget( _title, _pm, _parent ),
|
||||
m_directories( _directories ),
|
||||
m_filter( _filter ),
|
||||
m_dirsAsItems( _dirs_as_items )
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
|
||||
|
||||
pluginBrowser::pluginBrowser( QWidget * _parent ) :
|
||||
sideBarWidget( tr( "Instrument plugins" ),
|
||||
SideBarWidget( tr( "Instrument plugins" ),
|
||||
embed::getIconPixmap( "plugins" ), _parent )
|
||||
{
|
||||
setWindowTitle( tr( "Instrument browser" ) );
|
||||
|
||||
160
src/gui/widgets/SideBar.cpp
Normal file
160
src/gui/widgets/SideBar.cpp
Normal file
@@ -0,0 +1,160 @@
|
||||
/*
|
||||
* SideBar.cpp - side-bar in LMMS' MainWindow
|
||||
*
|
||||
* Copyright (c) 2004-2009 Tobias Doerffel <tobydox/at/users.sourceforge.net>
|
||||
*
|
||||
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public
|
||||
* License along with this program (see COPYING); if not, write to the
|
||||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301 USA.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <QtGui/QStyleOptionToolButton>
|
||||
#include <QtGui/QStylePainter>
|
||||
#include <QtGui/QToolButton>
|
||||
|
||||
#include "SideBar.h"
|
||||
#include "SideBarWidget.h"
|
||||
|
||||
|
||||
// internal helper class allowing to create QToolButtons with
|
||||
// vertical orientation
|
||||
class SideBarButton : public QToolButton
|
||||
{
|
||||
public:
|
||||
SideBarButton( Qt::Orientation _orientation, QWidget * _parent ) :
|
||||
QToolButton( _parent ),
|
||||
m_orientation( _orientation )
|
||||
{
|
||||
}
|
||||
virtual ~SideBarButton()
|
||||
{
|
||||
}
|
||||
|
||||
Qt::Orientation orientation() const
|
||||
{
|
||||
return m_orientation;
|
||||
}
|
||||
|
||||
virtual QSize sizeHint() const
|
||||
{
|
||||
QSize s = QToolButton::sizeHint();
|
||||
s.setWidth( s.width() + 8 );
|
||||
if( orientation() == Qt::Horizontal )
|
||||
{
|
||||
return s;
|
||||
}
|
||||
return QSize( s.height(), s.width() );
|
||||
}
|
||||
|
||||
|
||||
protected:
|
||||
virtual void paintEvent( QPaintEvent * )
|
||||
{
|
||||
QStylePainter p( this );
|
||||
QStyleOptionToolButton opt;
|
||||
initStyleOption( &opt );
|
||||
if( orientation() == Qt::Vertical )
|
||||
{
|
||||
const QSize s = sizeHint();
|
||||
p.rotate( 270 );
|
||||
p.translate( -s.height(), 0 );
|
||||
opt.rect = QRect( 0, 0, s.height(), s.width() );
|
||||
}
|
||||
p.drawComplexControl( QStyle::CC_ToolButton, opt );
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
Qt::Orientation m_orientation;
|
||||
|
||||
} ;
|
||||
|
||||
|
||||
SideBar::SideBar( Qt::Orientation _orientation, QWidget * _parent ) :
|
||||
QToolBar( _parent ),
|
||||
m_btnGroup( this )
|
||||
{
|
||||
setOrientation( _orientation );
|
||||
setIconSize( QSize( 16, 16 ) );
|
||||
|
||||
m_btnGroup.setExclusive( false );
|
||||
connect( &m_btnGroup, SIGNAL( buttonClicked( QAbstractButton * ) ),
|
||||
this, SLOT( toggleButton( QAbstractButton * ) ) );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
SideBar::~SideBar()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void SideBar::appendTab( SideBarWidget * _sbw )
|
||||
{
|
||||
SideBarButton * btn = new SideBarButton( orientation(), this );
|
||||
btn->setText( _sbw->title() );
|
||||
btn->setIcon( _sbw->icon() );
|
||||
btn->setCheckable( true );
|
||||
m_widgets[btn] = _sbw;
|
||||
m_btnGroup.addButton( btn );
|
||||
addWidget( btn );
|
||||
|
||||
_sbw->hide();
|
||||
_sbw->setMinimumWidth( 200 );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void SideBar::toggleButton( QAbstractButton * _btn )
|
||||
{
|
||||
QToolButton * toolButton = NULL;
|
||||
QWidget * activeWidget = NULL;
|
||||
for( ButtonMap::Iterator it = m_widgets.begin();
|
||||
it != m_widgets.end(); ++it )
|
||||
{
|
||||
QToolButton * curBtn = it.key();
|
||||
if( curBtn != _btn )
|
||||
{
|
||||
curBtn->setChecked( false );
|
||||
curBtn->setToolButtonStyle( Qt::ToolButtonIconOnly );
|
||||
}
|
||||
else
|
||||
{
|
||||
toolButton = it.key();
|
||||
activeWidget = it.value();
|
||||
}
|
||||
if( it.value() )
|
||||
{
|
||||
it.value()->hide();
|
||||
}
|
||||
}
|
||||
|
||||
if( toolButton && activeWidget )
|
||||
{
|
||||
activeWidget->setVisible( _btn->isChecked() );
|
||||
toolButton->setToolButtonStyle( _btn->isChecked() ?
|
||||
Qt::ToolButtonTextBesideIcon : Qt::ToolButtonIconOnly );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#include "moc_SideBar.cxx"
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* side_bar_widget.cpp - implementation of base-widget for side-bar
|
||||
* SideBarWidget.cpp - implementation of base-widget for side-bar
|
||||
*
|
||||
* Copyright (c) 2004-2009 Tobias Doerffel <tobydox/at/users.sourceforge.net>
|
||||
*
|
||||
* Copyright (c) 2004-2008 Tobias Doerffel <tobydox/at/users.sourceforge.net>
|
||||
*
|
||||
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
@@ -22,17 +22,16 @@
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include <QtGui/QApplication>
|
||||
#include <QtGui/QFontMetrics>
|
||||
#include <QtGui/QPainter>
|
||||
|
||||
#include "side_bar_widget.h"
|
||||
#include "SideBarWidget.h"
|
||||
#include "gui_templates.h"
|
||||
|
||||
|
||||
|
||||
sideBarWidget::sideBarWidget( const QString & _title, const QPixmap & _icon,
|
||||
SideBarWidget::SideBarWidget( const QString & _title, const QPixmap & _icon,
|
||||
QWidget * _parent ) :
|
||||
QWidget( _parent ),
|
||||
m_title( _title ),
|
||||
@@ -47,14 +46,14 @@ sideBarWidget::sideBarWidget( const QString & _title, const QPixmap & _icon,
|
||||
|
||||
|
||||
|
||||
sideBarWidget::~sideBarWidget()
|
||||
SideBarWidget::~SideBarWidget()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void sideBarWidget::paintEvent( QPaintEvent * )
|
||||
void SideBarWidget::paintEvent( QPaintEvent * )
|
||||
{
|
||||
const int TITLE_FONT_HEIGHT = 13;
|
||||
|
||||
@@ -77,7 +76,7 @@ void sideBarWidget::paintEvent( QPaintEvent * )
|
||||
|
||||
|
||||
|
||||
void sideBarWidget::resizeEvent( QResizeEvent * )
|
||||
void SideBarWidget::resizeEvent( QResizeEvent * )
|
||||
{
|
||||
const int MARGIN = 6;
|
||||
m_contents->setGeometry( MARGIN, 40 + MARGIN, width() - MARGIN * 2,
|
||||
@@ -86,6 +85,5 @@ void sideBarWidget::resizeEvent( QResizeEvent * )
|
||||
|
||||
|
||||
|
||||
#include "moc_side_bar.cxx"
|
||||
#include "moc_side_bar_widget.cxx"
|
||||
#include "moc_SideBarWidget.cxx"
|
||||
|
||||
@@ -1,917 +0,0 @@
|
||||
/*
|
||||
* kmultitabbar.cpp - widget for horizontal and vertical tabs
|
||||
*
|
||||
* Copyright (c) 2001-2003 Joseph Wenninger <jowenn@kde.org>
|
||||
* Copyright (c) 2004-2007 Tobias Doerffel <tobydox/at/users.sourceforge.net>
|
||||
*
|
||||
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public
|
||||
* License along with this program (see COPYING); if not, write to the
|
||||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301 USA.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include "kmultitabbar.h"
|
||||
|
||||
#include <QtCore/QEvent>
|
||||
#include <QtGui/QApplication>
|
||||
#include <QtGui/QFontMetrics>
|
||||
#include <QtGui/QFrame>
|
||||
#include <QtGui/QLayout>
|
||||
#include <QtGui/QPainter>
|
||||
#include <QtGui/QStyle>
|
||||
#include <QtGui/QStyleOptionButton>
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#include "templates.h"
|
||||
#include "tooltip.h"
|
||||
|
||||
#define NEARBYINT(i) ((int(float(i) + 0.5)))
|
||||
|
||||
class KMultiTabBarTabPrivate {
|
||||
public:
|
||||
QPixmap pix;
|
||||
};
|
||||
|
||||
|
||||
KMultiTabBarInternal::KMultiTabBarInternal(QWidget *parent, KMultiTabBar::KMultiTabBarMode bm):QWidget(parent)
|
||||
{
|
||||
m_expandedTabSize=-1;
|
||||
m_showActiveTabTexts=false;
|
||||
m_barMode=bm;
|
||||
if (bm==KMultiTabBar::Vertical)
|
||||
{
|
||||
box=new QWidget(this);
|
||||
mainLayout=new QVBoxLayout(box);
|
||||
box->setFixedWidth(24);
|
||||
setFixedWidth(24);
|
||||
}
|
||||
else
|
||||
{
|
||||
box=new QWidget(this);
|
||||
mainLayout=new QHBoxLayout(box);
|
||||
box->setFixedHeight(24);
|
||||
setFixedHeight(24);
|
||||
}
|
||||
mainLayout->setMargin(0);
|
||||
mainLayout->setSpacing(0);
|
||||
}
|
||||
|
||||
void KMultiTabBarInternal::setStyle(enum KMultiTabBar::KMultiTabBarStyle style)
|
||||
{
|
||||
m_style=style;
|
||||
for (int i=0;i<m_tabs.count();i++)
|
||||
m_tabs.at(i)->setStyle(m_style);
|
||||
|
||||
if ( (m_style==KMultiTabBar::KDEV3) ||
|
||||
(m_style==KMultiTabBar::KDEV3ICON ) ) {
|
||||
delete mainLayout;
|
||||
mainLayout=0;
|
||||
resizeEvent(0);
|
||||
} else if (mainLayout==0) {
|
||||
if (m_barMode==KMultiTabBar::Vertical)
|
||||
{
|
||||
box=new QWidget(this);
|
||||
mainLayout=new QVBoxLayout(box);
|
||||
box->setFixedWidth(24);
|
||||
setFixedWidth(24);
|
||||
}
|
||||
else
|
||||
{
|
||||
box=new QWidget(this);
|
||||
mainLayout=new QHBoxLayout(box);
|
||||
box->setFixedHeight(24);
|
||||
setFixedHeight(24);
|
||||
}
|
||||
for (int i=0;i<m_tabs.count();i++)
|
||||
mainLayout->addWidget(m_tabs.at(i));
|
||||
|
||||
}
|
||||
update();
|
||||
}
|
||||
|
||||
|
||||
|
||||
#define CALCDIFF(m_tabs,diff,i) if (m_lines>(int)lines) {\
|
||||
int ulen=0;\
|
||||
diff=0; \
|
||||
for (int i2=i;i2<tabCount;i2++) {\
|
||||
int l1=m_tabs.at(i2)->neededSize();\
|
||||
if ((ulen+l1)>(int)space){\
|
||||
if (ulen==0) diff=0;\
|
||||
else diff=((float)(space-ulen))/(i2-i);\
|
||||
break;\
|
||||
}\
|
||||
ulen+=l1;\
|
||||
}\
|
||||
} else {diff=0; }
|
||||
|
||||
|
||||
void KMultiTabBarInternal::resizeEvent(QResizeEvent *ev) {
|
||||
if (ev) QWidget::resizeEvent(ev);
|
||||
|
||||
if ( (m_style==KMultiTabBar::KDEV3) ||
|
||||
(m_style==KMultiTabBar::KDEV3ICON) ){
|
||||
box->setGeometry(0,0,width(),height());
|
||||
int lines=1;
|
||||
uint space;
|
||||
float tmp=0;
|
||||
if ((m_position==KMultiTabBar::Bottom) || (m_position==KMultiTabBar::Top))
|
||||
space=width();
|
||||
else
|
||||
space=height();
|
||||
|
||||
int cnt=0;
|
||||
//CALCULATE LINES
|
||||
const int tabCount=m_tabs.count();
|
||||
for (int i=0;i<tabCount;i++) {
|
||||
cnt++;
|
||||
tmp+=m_tabs.at(i)->neededSize();
|
||||
if (tmp>space) {
|
||||
if (cnt>1)i--;
|
||||
else if (i==(tabCount-1)) break;
|
||||
cnt=0;
|
||||
tmp=0;
|
||||
lines++;
|
||||
}
|
||||
}
|
||||
//SET SIZE & PLACE
|
||||
float diff=0;
|
||||
cnt=0;
|
||||
|
||||
if ((m_position==KMultiTabBar::Bottom) || (m_position==KMultiTabBar::Top)) {
|
||||
|
||||
setFixedHeight(lines*24);
|
||||
box->setFixedHeight(lines*24);
|
||||
m_lines=height()/24-1;
|
||||
lines=0;
|
||||
CALCDIFF(m_tabs,diff,0)
|
||||
tmp=-diff;
|
||||
|
||||
for (int i=0;i<tabCount;i++) {
|
||||
KMultiTabBarTab *tab=m_tabs.at(i);
|
||||
cnt++;
|
||||
tmp+=tab->neededSize()+diff;
|
||||
if (tmp>space) {
|
||||
if (cnt>1) {
|
||||
CALCDIFF(m_tabs,diff,i)
|
||||
i--;
|
||||
}
|
||||
else {
|
||||
tab->removeEventFilter(this);
|
||||
tab->move(NEARBYINT(tmp-tab->neededSize()),lines*24);
|
||||
tab->setFixedWidth(NEARBYINT(tmp+diff)-tab->x());;
|
||||
tab->installEventFilter(this);
|
||||
CALCDIFF(m_tabs,diff,(i+1))
|
||||
|
||||
}
|
||||
tmp=-diff;
|
||||
cnt=0;
|
||||
lines++;
|
||||
|
||||
} else {
|
||||
tab->removeEventFilter(this);
|
||||
tab->move(NEARBYINT(tmp-tab->neededSize()),lines*24);
|
||||
tab->setFixedWidth(NEARBYINT(tmp+diff)-tab->x());;
|
||||
|
||||
tab->installEventFilter(this);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
setFixedWidth(lines*24);
|
||||
box->setFixedWidth(lines*24);
|
||||
m_lines=lines=width()/24;
|
||||
lines=0;
|
||||
CALCDIFF(m_tabs,diff,0)
|
||||
tmp=-diff;
|
||||
|
||||
for (int i=0;i<tabCount;i++) {
|
||||
KMultiTabBarTab *tab=m_tabs.at(i);
|
||||
cnt++;
|
||||
tmp+=tab->neededSize()+diff;
|
||||
if (tmp>space) {
|
||||
if (cnt>1) {
|
||||
CALCDIFF(m_tabs,diff,i);
|
||||
tmp=-diff;
|
||||
i--;
|
||||
}
|
||||
else {
|
||||
tab->removeEventFilter(this);
|
||||
tab->move(lines*24,NEARBYINT(tmp-tab->neededSize()));
|
||||
tab->setFixedHeight(NEARBYINT(tmp+diff)-tab->y());;
|
||||
tab->installEventFilter(this);
|
||||
}
|
||||
cnt=0;
|
||||
tmp=-diff;
|
||||
lines++;
|
||||
} else {
|
||||
tab->removeEventFilter(this);
|
||||
tab->move(lines*24,NEARBYINT(tmp-tab->neededSize()));
|
||||
tab->setFixedHeight(NEARBYINT(tmp+diff)-tab->y());;
|
||||
tab->installEventFilter(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
int size=0; /*move the calculation into another function and call it only on add tab and tab click events*/
|
||||
for (int i=0;i<(int)m_tabs.count();i++)
|
||||
size+=(m_barMode==KMultiTabBar::Vertical?m_tabs.at(i)->height():m_tabs.at(i)->width());
|
||||
if ((m_position==KMultiTabBar::Bottom) || (m_position==KMultiTabBar::Top))
|
||||
box->setGeometry(0,0,size,height());
|
||||
else box->setGeometry(0,0,width(),size);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void KMultiTabBarInternal::showActiveTabTexts(bool show)
|
||||
{
|
||||
m_showActiveTabTexts=show;
|
||||
}
|
||||
|
||||
|
||||
KMultiTabBarTab* KMultiTabBarInternal::tab(int id) const
|
||||
{
|
||||
for (QListIterator<KMultiTabBarTab *> it(m_tabs);it.hasNext();it.next()){
|
||||
if (it.peekNext()->id()==id) return it.peekNext();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool KMultiTabBarInternal::eventFilter(QObject *, QEvent *e) {
|
||||
if (e->type()==QEvent::Resize) resizeEvent(0);
|
||||
return false;
|
||||
}
|
||||
|
||||
int KMultiTabBarInternal::appendTab(const QPixmap &pic ,int id,const QString& text)
|
||||
{
|
||||
KMultiTabBarTab *tab;
|
||||
m_tabs.append(tab= new KMultiTabBarTab(pic,text,id,box,m_position,m_style));
|
||||
mainLayout->addWidget( tab );
|
||||
tab->installEventFilter(this);
|
||||
tab->showActiveTabText(m_showActiveTabTexts);
|
||||
|
||||
if (m_style==KMultiTabBar::KONQSBC)
|
||||
{
|
||||
if (m_expandedTabSize<tab->neededSize()) {
|
||||
m_expandedTabSize=tab->neededSize();
|
||||
for (int i=0;i<m_tabs.count();i++)
|
||||
m_tabs.at(i)->setSize(m_expandedTabSize);
|
||||
|
||||
} else tab->setSize(m_expandedTabSize);
|
||||
} else tab->updateState();
|
||||
tab->show();
|
||||
resizeEvent(0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void KMultiTabBarInternal::removeTab(int id)
|
||||
{
|
||||
for (int pos=0;pos<m_tabs.count();pos++)
|
||||
{
|
||||
if (m_tabs.at(pos)->id()==id)
|
||||
{
|
||||
delete m_tabs.at(pos);
|
||||
m_tabs.removeAt(pos);
|
||||
resizeEvent(0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void KMultiTabBarInternal::setPosition(enum KMultiTabBar::KMultiTabBarPosition pos)
|
||||
{
|
||||
m_position=pos;
|
||||
for (int i=0;i<m_tabs.count();i++)
|
||||
m_tabs.at(i)->setTabsPosition(m_position);
|
||||
update();
|
||||
}
|
||||
|
||||
KMultiTabBarButton::KMultiTabBarButton(const QPixmap& pic,const QString& text, QMenu *popup,
|
||||
int id,QWidget *parent,KMultiTabBar::KMultiTabBarPosition pos,KMultiTabBar::KMultiTabBarStyle style)
|
||||
:QPushButton(QIcon(),text,parent),m_style(style)
|
||||
{
|
||||
setIcon(pic);
|
||||
setText(text);
|
||||
m_position=pos;
|
||||
if (popup) setMenu(popup);
|
||||
setFlat(true);
|
||||
setFixedHeight(24);
|
||||
setFixedWidth(24);
|
||||
m_id=id;
|
||||
setToolTip(text);
|
||||
connect(this,SIGNAL(clicked()),this,SLOT(slotClicked()));
|
||||
}
|
||||
|
||||
KMultiTabBarButton::KMultiTabBarButton(const QString& text, QMenu *popup,
|
||||
int id,QWidget *parent,KMultiTabBar::KMultiTabBarPosition pos,KMultiTabBar::KMultiTabBarStyle style)
|
||||
:QPushButton(QIcon(),text,parent),m_style(style)
|
||||
{
|
||||
setText(text);
|
||||
m_position=pos;
|
||||
if (popup) setMenu(popup);
|
||||
setFlat(true);
|
||||
setFixedHeight(24);
|
||||
setFixedWidth(24);
|
||||
m_id=id;
|
||||
setToolTip(text);
|
||||
connect(this,SIGNAL(clicked()),this,SLOT(slotClicked()));
|
||||
}
|
||||
|
||||
KMultiTabBarButton::~KMultiTabBarButton() {
|
||||
}
|
||||
|
||||
int KMultiTabBarButton::id() const{
|
||||
return m_id;
|
||||
}
|
||||
|
||||
void KMultiTabBarButton::setText(const QString& text)
|
||||
{
|
||||
QPushButton::setText(text);
|
||||
m_text=text;
|
||||
setToolTip(text);
|
||||
}
|
||||
|
||||
void KMultiTabBarButton::slotClicked()
|
||||
{
|
||||
emit clicked(m_id);
|
||||
}
|
||||
|
||||
void KMultiTabBarButton::setPosition(KMultiTabBar::KMultiTabBarPosition pos)
|
||||
{
|
||||
m_position=pos;
|
||||
update();
|
||||
}
|
||||
|
||||
void KMultiTabBarButton::setStyle(KMultiTabBar::KMultiTabBarStyle style)
|
||||
{
|
||||
m_style=style;
|
||||
update();
|
||||
}
|
||||
|
||||
void KMultiTabBarButton::hideEvent( QHideEvent* he) {
|
||||
QPushButton::hideEvent(he);
|
||||
KMultiTabBar *tb=dynamic_cast<KMultiTabBar*>(parentWidget());
|
||||
if (tb) tb->updateSeparator();
|
||||
}
|
||||
|
||||
void KMultiTabBarButton::showEvent( QShowEvent* he) {
|
||||
QPushButton::showEvent(he);
|
||||
KMultiTabBar *tb=dynamic_cast<KMultiTabBar*>(parentWidget());
|
||||
if (tb) tb->updateSeparator();
|
||||
}
|
||||
|
||||
|
||||
QSize KMultiTabBarButton::sizeHint() const
|
||||
{
|
||||
//constPolish();
|
||||
|
||||
int w = 0, h = 0;
|
||||
|
||||
// calculate contents size...
|
||||
int iw = 0, ih = 0;
|
||||
if ( !icon().isNull() ) {
|
||||
iw = 20;
|
||||
ih = 16;
|
||||
w += iw;
|
||||
h = qMax( h, ih );
|
||||
}
|
||||
QStyleOptionButton sob;
|
||||
if ( menu() != 0 )
|
||||
w += style()->pixelMetric(QStyle::PM_MenuButtonIndicator, &sob, this);
|
||||
|
||||
QString s( text() );
|
||||
bool empty = s.isEmpty();
|
||||
if ( empty )
|
||||
s = QLatin1String("XXXX");
|
||||
QFontMetrics fm = fontMetrics();
|
||||
QSize sz = fm.size( Qt::TextShowMnemonic, s );
|
||||
if(!empty || !w)
|
||||
w += sz.width();
|
||||
if(!empty || !h)
|
||||
h = qMax(h, sz.height());
|
||||
|
||||
|
||||
QStyleOptionToolButton opt;
|
||||
opt.init(this);
|
||||
opt.rect = QRect(0, 0, w, h);
|
||||
opt.subControls = QStyle::SC_All;
|
||||
opt.activeSubControls = 0;
|
||||
opt.text = text();
|
||||
opt.font = font();
|
||||
opt.icon = icon();
|
||||
opt.iconSize = QSize(iw, ih);
|
||||
return (style()->sizeFromContents(QStyle::CT_ToolButton, &opt, QSize(w, h), this).
|
||||
expandedTo(QApplication::globalStrut()));
|
||||
}
|
||||
|
||||
|
||||
KMultiTabBarTab::KMultiTabBarTab(const QPixmap& pic, const QString& text,
|
||||
int id,QWidget *parent,KMultiTabBar::KMultiTabBarPosition pos,
|
||||
KMultiTabBar::KMultiTabBarStyle style)
|
||||
:KMultiTabBarButton(text,0,id,parent,pos,style),
|
||||
m_showActiveTabText(false)
|
||||
{
|
||||
d=new KMultiTabBarTabPrivate();
|
||||
setIcon(pic);
|
||||
m_expandedSize=24;
|
||||
setCheckable(true);
|
||||
setAttribute( Qt::WA_OpaquePaintEvent, true );
|
||||
}
|
||||
|
||||
KMultiTabBarTab::~KMultiTabBarTab() {
|
||||
delete d;
|
||||
}
|
||||
|
||||
|
||||
void KMultiTabBarTab::setTabsPosition(KMultiTabBar::KMultiTabBarPosition pos)
|
||||
{
|
||||
if ((pos!=m_position) && ((pos==KMultiTabBar::Left) || (pos==KMultiTabBar::Right))) {
|
||||
if (!d->pix.isNull()) {
|
||||
QMatrix temp;// (1.0F, 0.0F, 0.0F, -1.0F, 0.0F, 0.0F);
|
||||
temp.rotate(180);
|
||||
d->pix=d->pix.transformed(temp);
|
||||
setIcon(d->pix);
|
||||
}
|
||||
}
|
||||
setPosition(pos);
|
||||
}
|
||||
|
||||
void KMultiTabBarTab::setIcon(const QString& icon)
|
||||
{
|
||||
QPixmap pic(icon);
|
||||
setIcon(pic);
|
||||
}
|
||||
|
||||
void KMultiTabBarTab::setIcon(const QPixmap& icon)
|
||||
{
|
||||
|
||||
if (m_style!=KMultiTabBar::KDEV3) {
|
||||
if ((m_position==KMultiTabBar::Left) || (m_position==KMultiTabBar::Right)) {
|
||||
QMatrix rotateMatrix;
|
||||
/* if (m_position==KMultiTabBar::Left)
|
||||
rotateMatrix.rotate(-270);
|
||||
else*/
|
||||
rotateMatrix.rotate(90);
|
||||
d->pix=icon.transformed(rotateMatrix); //TODO FIX THIS, THIS SHOWS WINDOW
|
||||
KMultiTabBarButton::setIcon(d->pix);
|
||||
} else KMultiTabBarButton::setIcon(icon);
|
||||
}
|
||||
}
|
||||
|
||||
void KMultiTabBarTab::slotClicked()
|
||||
{
|
||||
updateState();
|
||||
KMultiTabBarButton::slotClicked();
|
||||
}
|
||||
|
||||
void KMultiTabBarTab::setState(bool b)
|
||||
{
|
||||
setChecked(b);
|
||||
updateState();
|
||||
}
|
||||
|
||||
void KMultiTabBarTab::updateState()
|
||||
{
|
||||
|
||||
if (m_style!=KMultiTabBar::KONQSBC) {
|
||||
if ((m_style==KMultiTabBar::KDEV3) || (m_style==KMultiTabBar::KDEV3ICON) || (isChecked())) {
|
||||
QPushButton::setText(m_text);
|
||||
} else {
|
||||
QPushButton::setText(QString());
|
||||
}
|
||||
|
||||
if ((m_position==KMultiTabBar::Right || m_position==KMultiTabBar::Left)) {
|
||||
setFixedWidth(24);
|
||||
if ((m_style==KMultiTabBar::KDEV3) || (m_style==KMultiTabBar::KDEV3ICON) || (isChecked())) {
|
||||
setFixedHeight(KMultiTabBarButton::sizeHint().width());
|
||||
} else setFixedHeight(36);
|
||||
} else {
|
||||
setFixedHeight(24);
|
||||
if ((m_style==KMultiTabBar::KDEV3) || (m_style==KMultiTabBar::KDEV3ICON) || (isChecked())) {
|
||||
setFixedWidth(KMultiTabBarButton::sizeHint().width());
|
||||
} else setFixedWidth(36);
|
||||
}
|
||||
} else {
|
||||
if ((!isChecked()) || (!m_showActiveTabText))
|
||||
{
|
||||
setFixedWidth(24);
|
||||
setFixedHeight(24);
|
||||
return;
|
||||
}
|
||||
if ((m_position==KMultiTabBar::Right || m_position==KMultiTabBar::Left))
|
||||
setFixedHeight(m_expandedSize);
|
||||
else
|
||||
setFixedWidth(m_expandedSize);
|
||||
}
|
||||
}
|
||||
|
||||
int KMultiTabBarTab::neededSize()
|
||||
{
|
||||
return (((m_style!=KMultiTabBar::KDEV3)?24:0)+QFontMetrics(QFont()).width(m_text)+6);
|
||||
}
|
||||
|
||||
void KMultiTabBarTab::setSize(int size)
|
||||
{
|
||||
m_expandedSize=size;
|
||||
updateState();
|
||||
}
|
||||
|
||||
void KMultiTabBarTab::showActiveTabText(bool show)
|
||||
{
|
||||
m_showActiveTabText=show;
|
||||
}
|
||||
|
||||
void KMultiTabBarTab::paintEvent(QPaintEvent *) {
|
||||
QPainter painter(this);
|
||||
drawButton(&painter);
|
||||
}
|
||||
|
||||
void KMultiTabBarTab::drawButtonLabel(QPainter *p) {
|
||||
drawButton(p);
|
||||
}
|
||||
void KMultiTabBarTab::drawButton(QPainter *paint)
|
||||
{
|
||||
if (m_style!=KMultiTabBar::KONQSBC) drawButtonStyled(paint);
|
||||
else drawButtonClassic(paint);
|
||||
}
|
||||
|
||||
void KMultiTabBarTab::drawButtonStyled(QPainter *paint) {
|
||||
|
||||
QSize sh;
|
||||
const int width = 36; // rotated
|
||||
const int height = 24;
|
||||
if ((m_style==KMultiTabBar::KDEV3) || (m_style==KMultiTabBar::KDEV3ICON) || (isChecked())) {
|
||||
if ((m_position==KMultiTabBar::Left) || (m_position==KMultiTabBar::Right))
|
||||
sh=QSize(this->height(),this->width());//KMultiTabBarButton::sizeHint();
|
||||
else sh=QSize(this->width(),this->height());
|
||||
}
|
||||
else
|
||||
sh=QSize(width,height);
|
||||
|
||||
QPixmap pixmap( sh.width(),height); ///,sh.height());
|
||||
pixmap.fill(backgroundRole());
|
||||
QPainter painter(&pixmap);
|
||||
|
||||
|
||||
QStyle::State st=QStyle::State_None;
|
||||
|
||||
st|=QStyle::State_Enabled;
|
||||
|
||||
if (isChecked()) st|=QStyle::State_On;
|
||||
|
||||
QStyleOptionButton options;
|
||||
options.init(this);
|
||||
options.state = st;
|
||||
options.rect = QRect(0,0,pixmap.width(),pixmap.height());
|
||||
options.palette = palette();
|
||||
options.text = text();
|
||||
options.icon = icon();
|
||||
options.iconSize = iconSize();
|
||||
|
||||
style()->drawControl(QStyle::CE_PushButton, &options, &painter, this);
|
||||
|
||||
switch (m_position) {
|
||||
case KMultiTabBar::Left:
|
||||
paint->rotate(-90);
|
||||
paint->drawPixmap(1-pixmap.width(),0,pixmap);
|
||||
break;
|
||||
case KMultiTabBar::Right:
|
||||
paint->rotate(90);
|
||||
paint->drawPixmap(0,1-pixmap.height(),pixmap);
|
||||
break;
|
||||
|
||||
default:
|
||||
paint->drawPixmap(0,0,pixmap);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void KMultiTabBarTab::drawButtonClassic(QPainter *paint)
|
||||
{
|
||||
QPixmap pixmap;
|
||||
if( !icon().isNull() )
|
||||
pixmap = icon().pixmap( 16, 16 );
|
||||
paint->fillRect(0, 0, 24, 24, palette().background().color());
|
||||
|
||||
if (!isChecked())
|
||||
{
|
||||
|
||||
if (m_position==KMultiTabBar::Right)
|
||||
{
|
||||
paint->fillRect(0,0,21,21,QBrush(palette().background().color()));
|
||||
|
||||
paint->setPen(palette().background().color().dark(150));
|
||||
paint->drawLine(0,22,23,22);
|
||||
|
||||
paint->drawPixmap(12-pixmap.width()/2,12-pixmap.height()/2,pixmap);
|
||||
|
||||
paint->setPen(palette().shadow().color());
|
||||
paint->drawLine(0,0,0,23);
|
||||
paint->setPen(palette().background().color().dark(120));
|
||||
paint->drawLine(1,0,1,23);
|
||||
|
||||
}
|
||||
else
|
||||
if ((m_position==KMultiTabBar::Bottom) || (m_position==KMultiTabBar::Top))
|
||||
{
|
||||
paint->fillRect(0,1,23,22,QBrush(palette().background().color()));
|
||||
|
||||
paint->drawPixmap(12-pixmap.width()/2,12-pixmap.height()/2,pixmap);
|
||||
|
||||
paint->setPen(palette().background().color().dark(120));
|
||||
paint->drawLine(23,0,23,23);
|
||||
|
||||
|
||||
paint->setPen(palette().light().color());
|
||||
paint->drawLine(0,22,23,22);
|
||||
paint->drawLine(0,23,23,23);
|
||||
paint->setPen(palette().shadow().color());
|
||||
paint->drawLine(0,0,23,0);
|
||||
paint->setPen(palette().background().color().dark(120));
|
||||
paint->drawLine(0,1,23,1);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
paint->setPen(palette().background().color().dark(120));
|
||||
paint->drawLine(0,23,23,23);
|
||||
paint->fillRect(0,0,23,21,QBrush(palette().background()));
|
||||
paint->drawPixmap(12-pixmap.width()/2,12-pixmap.height()/2,pixmap);
|
||||
|
||||
paint->setPen(palette().light().color());
|
||||
paint->drawLine(23,0,23,23);
|
||||
paint->drawLine(22,0,22,23);
|
||||
|
||||
paint->setPen(palette().shadow().color());
|
||||
paint->drawLine(0,0,0,23);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_position==KMultiTabBar::Right)
|
||||
{
|
||||
paint->setPen(palette().shadow().color());
|
||||
paint->drawLine(0,height()-1,23,height()-1);
|
||||
paint->drawLine(0,height()-2,23,height()-2);
|
||||
paint->drawLine(23,0,23,height()-1);
|
||||
paint->drawLine(22,0,22,height()-1);
|
||||
paint->fillRect(0,0,21,height()-3,QBrush(palette().light().color()));
|
||||
paint->drawPixmap(10-pixmap.width()/2,10-pixmap.height()/2,pixmap);
|
||||
|
||||
if (m_showActiveTabText)
|
||||
{
|
||||
if (height()<25+4) return;
|
||||
|
||||
QPixmap tpixmap(height()-25-3, width()-2);
|
||||
QPainter painter(&tpixmap);
|
||||
|
||||
painter.fillRect(0,0,tpixmap.width(),tpixmap.height(),QBrush(palette().light().color()));
|
||||
|
||||
painter.setPen(palette().text().color());
|
||||
painter.drawText(0,+width()/2+QFontMetrics(QFont()).height()/2,m_text);
|
||||
|
||||
paint->rotate(90);
|
||||
paint->drawPixmap(25,-tpixmap.height()+1,tpixmap);
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
if (m_position==KMultiTabBar::Top)
|
||||
{
|
||||
paint->fillRect(0,0,width()-1,23,QBrush(palette().light().color()));
|
||||
paint->drawPixmap(10-pixmap.width()/2,10-pixmap.height()/2,pixmap);
|
||||
if (m_showActiveTabText)
|
||||
{
|
||||
paint->setPen(palette().text().color());
|
||||
paint->drawText(25,height()/2+QFontMetrics(QFont()).height()/2,m_text);
|
||||
}
|
||||
}
|
||||
else
|
||||
if (m_position==KMultiTabBar::Bottom)
|
||||
{
|
||||
paint->setPen(palette().shadow().color());
|
||||
paint->drawLine(0,23,width()-1,23);
|
||||
paint->drawLine(0,22,width()-1,22);
|
||||
paint->fillRect(0,0,width()-1,21,QBrush(palette().light().color()));
|
||||
paint->drawPixmap(10-pixmap.width()/2,10-pixmap.height()/2,pixmap);
|
||||
if (m_showActiveTabText)
|
||||
{
|
||||
paint->setPen(palette().text().color());
|
||||
paint->drawText(25,height()/2+QFontMetrics(QFont()).height()/2,m_text);
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
|
||||
paint->setPen(palette().shadow().color());
|
||||
paint->drawLine(0,height()-1,23,height()-1);
|
||||
paint->drawLine(0,height()-2,23,height()-2);
|
||||
paint->fillRect(0,0,23,height()-3,QBrush(palette().light().color()));
|
||||
paint->drawPixmap(10-pixmap.width()/2,10-pixmap.height()/2,pixmap);
|
||||
if (m_showActiveTabText)
|
||||
{
|
||||
|
||||
if (height()<25+4) return;
|
||||
|
||||
QPixmap tpixmap(height()-25-3, width()-2);
|
||||
QPainter painter(&tpixmap);
|
||||
|
||||
painter.fillRect(0,0,tpixmap.width(),tpixmap.height(),QBrush(palette().light().color()));
|
||||
|
||||
painter.setPen(palette().text().color());
|
||||
painter.drawText(tpixmap.width()-QFontMetrics(QFont()).width(m_text),+width()/2+QFontMetrics(QFont()).height()/2,m_text);
|
||||
|
||||
paint->rotate(-90);
|
||||
|
||||
paint->drawPixmap(-24-tpixmap.width(),2,tpixmap);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
KMultiTabBar::KMultiTabBar(KMultiTabBarMode bm, QWidget *parent)
|
||||
: QWidget(parent)
|
||||
{
|
||||
if (bm==Vertical)
|
||||
{
|
||||
m_l=new QVBoxLayout(this);
|
||||
setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding));
|
||||
}
|
||||
else
|
||||
{
|
||||
m_l=new QHBoxLayout(this);
|
||||
setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed));
|
||||
}
|
||||
m_l->setMargin(0);
|
||||
|
||||
m_internal=new KMultiTabBarInternal(this,bm);
|
||||
setPosition((bm==KMultiTabBar::Vertical)?KMultiTabBar::Right:KMultiTabBar::Bottom);
|
||||
setStyle(VSNET);
|
||||
m_l->insertWidget(0,m_internal);
|
||||
m_l->insertWidget(0,m_btnTabSep=new QFrame(this));
|
||||
m_btnTabSep->setFixedHeight(4);
|
||||
m_btnTabSep->setFrameStyle(QFrame::Panel | QFrame::Sunken);
|
||||
m_btnTabSep->setLineWidth(2);
|
||||
m_btnTabSep->hide();
|
||||
|
||||
updateGeometry();
|
||||
}
|
||||
|
||||
KMultiTabBar::~KMultiTabBar() {
|
||||
}
|
||||
|
||||
int KMultiTabBar::appendButton(const QPixmap &pic ,int id,QMenu *popup,const QString&)
|
||||
{
|
||||
KMultiTabBarButton *btn;
|
||||
m_buttons.append(btn= new KMultiTabBarButton(pic,QString(),
|
||||
popup,id,this,m_position,m_internal->m_style));
|
||||
m_l->insertWidget(0,btn);
|
||||
btn->show();
|
||||
m_btnTabSep->show();
|
||||
return 0;
|
||||
}
|
||||
|
||||
void KMultiTabBar::updateSeparator() {
|
||||
bool hideSep=true;
|
||||
for (QListIterator<KMultiTabBarButton *> it(m_buttons);it.hasNext();){
|
||||
if (it.next()->isVisibleTo(this)) {
|
||||
hideSep=false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (hideSep) m_btnTabSep->hide();
|
||||
else m_btnTabSep->show();
|
||||
|
||||
}
|
||||
|
||||
int KMultiTabBar::appendTab(const QPixmap &pic ,int id ,const QString& text)
|
||||
{
|
||||
m_internal->appendTab(pic,id,text);
|
||||
return 0;
|
||||
}
|
||||
|
||||
KMultiTabBarButton* KMultiTabBar::button(int id) const
|
||||
{
|
||||
for (QListIterator<KMultiTabBarButton *> it(m_buttons);it.hasNext();it.next()){
|
||||
if (it.peekNext()->id()==id) return it.peekNext();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
KMultiTabBarTab* KMultiTabBar::tab(int id) const
|
||||
{
|
||||
return m_internal->tab(id);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void KMultiTabBar::removeButton(int id)
|
||||
{
|
||||
for (int pos=0;pos<m_buttons.count();pos++)
|
||||
{
|
||||
if (m_buttons.at(pos)->id()==id)
|
||||
{
|
||||
m_buttons.at(pos)->deleteLater();
|
||||
m_buttons.removeAt(pos);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (m_buttons.count()==0) m_btnTabSep->hide();
|
||||
}
|
||||
|
||||
void KMultiTabBar::removeTab(int id)
|
||||
{
|
||||
m_internal->removeTab(id);
|
||||
}
|
||||
|
||||
void KMultiTabBar::setTab(int id,bool state)
|
||||
{
|
||||
KMultiTabBarTab *ttab=tab(id);
|
||||
if (ttab)
|
||||
{
|
||||
ttab->setState(state);
|
||||
}
|
||||
}
|
||||
|
||||
bool KMultiTabBar::isTabRaised(int id) const
|
||||
{
|
||||
KMultiTabBarTab *ttab=tab(id);
|
||||
if (ttab)
|
||||
{
|
||||
return ttab->isChecked();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void KMultiTabBar::showActiveTabTexts(bool show)
|
||||
{
|
||||
m_internal->showActiveTabTexts(show);
|
||||
}
|
||||
|
||||
void KMultiTabBar::setStyle(KMultiTabBarStyle style)
|
||||
{
|
||||
m_internal->setStyle(style);
|
||||
}
|
||||
|
||||
KMultiTabBar::KMultiTabBarStyle KMultiTabBar::tabStyle() const
|
||||
{
|
||||
return m_internal->m_style;
|
||||
}
|
||||
|
||||
void KMultiTabBar::setPosition(KMultiTabBarPosition pos)
|
||||
{
|
||||
m_position=pos;
|
||||
m_internal->setPosition(pos);
|
||||
for (int i=0;i<m_buttons.count();i++)
|
||||
m_buttons.at(i)->setPosition(pos);
|
||||
}
|
||||
|
||||
KMultiTabBar::KMultiTabBarPosition KMultiTabBar::position() const
|
||||
{
|
||||
return m_position;
|
||||
}
|
||||
void KMultiTabBar::fontChange(const QFont& /* oldFont */)
|
||||
{
|
||||
for (int i=0;i<tabs()->count();i++)
|
||||
tabs()->at(i)->resize();
|
||||
update();
|
||||
}
|
||||
|
||||
QList<KMultiTabBarTab *>* KMultiTabBar::tabs() {return m_internal->tabs();}
|
||||
QList<KMultiTabBarButton *>* KMultiTabBar::buttons() {return &m_buttons;}
|
||||
|
||||
|
||||
#include "moc_kmultitabbar.cxx"
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user