From 0b572ed64e3c29f71e5e48506f16978886997f09 Mon Sep 17 00:00:00 2001 From: Mavridis Philippe Date: Wed, 17 May 2023 15:30:03 +0300 Subject: [PATCH] Switch to system TDEMultiTabBar There is no reason to keep the custom classes as the modifications they contain are no longer relevant and seem to be implemented on the player's side. This is what tests show anyway. Signed-off-by: Mavridis Philippe --- kaffeine/src/kaffeine.cpp | 2 +- kaffeine/src/tdemultitabbar.cpp | 999 -------------------------------- kaffeine/src/tdemultitabbar.h | 251 -------- kaffeine/src/tdemultitabbar_p.h | 69 --- 4 files changed, 1 insertion(+), 1320 deletions(-) delete mode 100644 kaffeine/src/tdemultitabbar.cpp delete mode 100644 kaffeine/src/tdemultitabbar.h delete mode 100644 kaffeine/src/tdemultitabbar_p.h diff --git a/kaffeine/src/kaffeine.cpp b/kaffeine/src/kaffeine.cpp index f2caf6f..14d70b8 100644 --- a/kaffeine/src/kaffeine.cpp +++ b/kaffeine/src/kaffeine.cpp @@ -80,7 +80,7 @@ #endif #include "cdwidget.h" #include "inputmanager.h" -#include "tdemultitabbar.h" +#include #include "disc.h" #define DEFAULT_FILTER "*.anx *.axa *.axv *.vob *.png *.y4m *.rm *.ram *.rmvb *.pva *.nsv *.ogg *.ogm *.spx *.png *.mng *.pes *.iff *.svx *.8svx *.16sv *.ilbm *.pic *.anim *.wav *.vox *.voc *.snd *.au *.ra *.nsf *.flac *.aif *.aiff *.aud *.flv *.fli *.flc *.avi *.asf *.wmv *.wma *.asx *.wvx *.wax *.mkv *.vmd *.4xm *.mjpg *.cpk *.cak *.film *.str *.iki *.ik2 *.dps *.dat *.xa *.xa1 *.xa2 *.xas *.xap *.roq *.mve *.vqa *.mve *.mv8 *.cin *.wve *.mov *.qt *.mp4 *.ts *.m2t *.trp *.mpg *.mpeg *.dv *.dif *.flac *.mp3 *.mp2 *.mpa *.mpega *.ac3 *.aac *.asc *. *.sub *.srt *.smi *.ssa *.mpv *.m4a *.m4v *.mpc *.mp+ *.iso *.ANX *.AXA *.AXV *.VOB *.PNG *.Y4M *.RM *.RAM *.RMVB *.PVA *.NSV *.OGG *.OGM *.SPX *.PNG *.MNG *.PES *.IFF *.SVX *.8SVX *.16SV *.ILBM *.PIC *.ANIM *.WAV *.VOX *.VOC *.SND *.AU *.RA *.NSF *.FLAC *.AIF *.AIFF *.AUD *.FLV *.FLI *.FLC *.AVI *.ASF *.WMV *.WMA *.ASX *.WVX *.WAX *.MKV *.VMD *.4XM *.MJPG *.CPK *.CAK *.FILM *.STR *.IKI *.IK2 *.DPS *.DAT *.XA *.XA1 *.XA2 *.XAS *.XAP *.ROQ *.MVE *.VQA *.MVE *.MV8 *.CIN *.WVE *.MOV *.QT *.MP4 *.TS *.M2T *.TRP *.MPG *.MPEG *.DV *.DIF *.FLAC *.MP3 *.MP2 *.MPA *.MPEGA *.AC3 *.AAC *.ASC *. *.SUB *.SRT *.SMI *.SSA *.MPV *.M4A *.M4V *.MPC *.MP+ *.ISO" diff --git a/kaffeine/src/tdemultitabbar.cpp b/kaffeine/src/tdemultitabbar.cpp deleted file mode 100644 index 16d769d..0000000 --- a/kaffeine/src/tdemultitabbar.cpp +++ /dev/null @@ -1,999 +0,0 @@ -/* - * tdemultitabbar.cpp - * - * Copyright (C) 2001,2002,2003 Joseph Wenninger - * Copyright (C) 2005 Christophe Thommeret - * - * 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; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include "tdemultitabbar.h" -#include "tdemultitabbar.moc" -#include "tdemultitabbar_p.h" -#include "tdemultitabbar_p.moc" -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#define NEARBYINT(i) ((int(float(i) + 0.5))) - -class KMultiTabBarTabPrivate { -public: - TQPixmap pix; -}; - - -KMultiTabBarInternal::KMultiTabBarInternal(TQWidget *parent, KMultiTabBar::KMultiTabBarMode bm):TQScrollView(parent) -{ - m_expandedTabSize=-1; - m_showActiveTabTexts=false; - m_tabs.setAutoDelete(true); - m_barMode=bm; - setHScrollBarMode(AlwaysOff); - setVScrollBarMode(AlwaysOff); - if (bm==KMultiTabBar::Vertical) - { - box=new TQWidget(viewport()); - mainLayout=new TQVBoxLayout(box); - mainLayout->setAutoAdd(true); - box->setFixedWidth(24); - setFixedWidth(24); - } - else - { - box=new TQWidget(viewport()); - mainLayout=new TQHBoxLayout(box); - mainLayout->setAutoAdd(true); - box->setFixedHeight(24); - setFixedHeight(24); - } - addChild(box); - setFrameStyle(NoFrame); - viewport()->setBackgroundMode(TQt::PaletteBackground); -/* box->setPaletteBackgroundColor(TQt::red); - setPaletteBackgroundColor(TQt::green);*/ -} - -void KMultiTabBarInternal::setStyle(enum KMultiTabBar::KMultiTabBarStyle style) -{ - m_style=style; - for (uint i=0;isetStyle(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 TQWidget(viewport()); - mainLayout=new TQVBoxLayout(box); - box->setFixedWidth(24); - setFixedWidth(24); - } - else - { - box=new TQWidget(viewport()); - mainLayout=new TQHBoxLayout(box); - box->setFixedHeight(24); - setFixedHeight(24); - } - addChild(box); - for (uint i=0;iadd(m_tabs.at(i)); - mainLayout->setAutoAdd(true); - - } - viewport()->repaint(); -} - -void KMultiTabBarInternal::drawContents ( TQPainter * paint, int clipx, int clipy, int clipw, int cliph ) -{ - TQScrollView::drawContents (paint , clipx, clipy, clipw, cliph ); - - if (m_position==KMultiTabBar::Right) - { - - paint->setPen(colorGroup().shadow()); - paint->drawLine(0,0,0,viewport()->height()); - paint->setPen(colorGroup().background().dark(120)); - paint->drawLine(1,0,1,viewport()->height()); - - - } - else - if (m_position==KMultiTabBar::Left) - { - paint->setPen(colorGroup().light()); - paint->drawLine(23,0,23,viewport()->height()); - paint->drawLine(22,0,22,viewport()->height()); - - paint->setPen(colorGroup().shadow()); - paint->drawLine(0,0,0,viewport()->height()); - } - else - if (m_position==KMultiTabBar::Bottom) - { - paint->setPen(colorGroup().shadow()); - paint->drawLine(0,0,viewport()->width(),0); - paint->setPen(colorGroup().background().dark(120)); - paint->drawLine(0,1,viewport()->width(),1); - } - else - { - paint->setPen(colorGroup().light()); - paint->drawLine(0,23,viewport()->width(),23); - paint->drawLine(0,22,viewport()->width(),22); - -/* paint->setPen(colorGroup().shadow()); - paint->drawLine(0,0,0,viewport()->height());*/ - - } - - -} - -void KMultiTabBarInternal::contentsMousePressEvent(TQMouseEvent *ev) -{ - ev->ignore(); -} - -void KMultiTabBarInternal::mousePressEvent(TQMouseEvent *ev) -{ - ev->ignore(); -} - - -#define CALCDIFF(m_tabs,diff,i) if (m_lines>(int)lines) {\ - /*kdDebug()<<"i="<geometry()<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 uint tabCount=m_tabs.count(); - for (uint i=0;ineededSize(); - 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; - - //kdDebug()<<"m_lines recalculated="<neededSize()+diff; - if (tmp>space) { - //kdDebug()<<"about to start new line"<1) { - CALCDIFF(m_tabs,diff,i) - i--; - } - else { - //kdDebug()<<"placing line on old line"<neededSize()<<"/"<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 (TQPtrListIterator it(m_tabs);it.current();++it){ - if (it.current()->id()==id) return it.current(); - } - return 0; -} - -bool KMultiTabBarInternal::eventFilter(TQObject *, TQEvent *e) { - if (e->type()==TQEvent::Resize) resizeEvent(0); - return false; -} - -int KMultiTabBarInternal::appendTab(const TQPixmap &pic ,int id,const TQString& text) -{ - KMultiTabBarTab *tab; - m_tabs.append(tab= new KMultiTabBarTab(pic,text,id,box,m_position,m_style)); - tab->installEventFilter(this); - tab->showActiveTabText(m_showActiveTabTexts); - - if (m_style==KMultiTabBar::KONQSBC) - { - if (m_expandedTabSizeneededSize()) { - m_expandedTabSize=tab->neededSize(); - for (uint i=0;isetSize(m_expandedTabSize); - - } else tab->setSize(m_expandedTabSize); - } else tab->updateState(); - tab->show(); - resizeEvent(0); - return 0; -} - -void KMultiTabBarInternal::removeTab(int id) -{ - for (uint pos=0;posid()==id) - { - m_tabs.remove(pos); - resizeEvent(0); - break; - } - } -} - -void KMultiTabBarInternal::setPosition(enum KMultiTabBar::KMultiTabBarPosition pos) -{ - m_position=pos; - for (uint i=0;isetTabsPosition(m_position); - viewport()->repaint(); -} - - -KMultiTabBarButton::KMultiTabBarButton(const TQPixmap& pic,const TQString& text, TQPopupMenu *popup, - int id,TQWidget *parent,KMultiTabBar::KMultiTabBarPosition pos,KMultiTabBar::KMultiTabBarStyle style) - :TQPushButton(TQIconSet(),text,parent),m_style(style) -{ - setIconSet(pic); - setText(text); - m_position=pos; - if (popup) setPopup(popup); - setFlat(true); - setFixedHeight(24); - setFixedWidth(24); - m_id=id; - TQToolTip::add(this,text); - connect(this,TQT_SIGNAL(clicked()),this,TQT_SLOT(slotClicked())); -} - -KMultiTabBarButton::KMultiTabBarButton(const TQString& text, TQPopupMenu *popup, - int id,TQWidget *parent,KMultiTabBar::KMultiTabBarPosition pos,KMultiTabBar::KMultiTabBarStyle style) - :TQPushButton(TQIconSet(),text,parent),m_style(style) -{ - setText(text); - m_position=pos; - if (popup) setPopup(popup); - setFlat(true); - setFixedHeight(24); - setFixedWidth(24); - m_id=id; - TQToolTip::add(this,text); - connect(this,TQT_SIGNAL(clicked()),this,TQT_SLOT(slotClicked())); -} - -KMultiTabBarButton::~KMultiTabBarButton() { -} - -int KMultiTabBarButton::id() const{ - return m_id; -} - -void KMultiTabBarButton::setText(const TQString& text) -{ - TQPushButton::setText(text); - m_text=text; - TQToolTip::add(this,text); -} - -void KMultiTabBarButton::slotClicked() -{ - emit clicked(m_id); -} - -void KMultiTabBarButton::setPosition(KMultiTabBar::KMultiTabBarPosition pos) -{ - m_position=pos; - repaint(); -} - -void KMultiTabBarButton::setStyle(KMultiTabBar::KMultiTabBarStyle style) -{ - m_style=style; - repaint(); -} - -void KMultiTabBarButton::hideEvent( TQHideEvent* he) { - TQPushButton::hideEvent(he); - KMultiTabBar *tb=dynamic_cast(parentWidget()); - if (tb) tb->updateSeparator(); -} - -void KMultiTabBarButton::showEvent( TQShowEvent* he) { - TQPushButton::showEvent(he); - KMultiTabBar *tb=dynamic_cast(parentWidget()); - if (tb) tb->updateSeparator(); -} - - -TQSize KMultiTabBarButton::sizeHint() const -{ - constPolish(); - - int w = 0, h = 0; - - // calculate contents size... -#ifndef TQT_NO_ICONSET - if ( iconSet() && !iconSet()->isNull() ) { - int iw = iconSet()->pixmap( TQIconSet::Small, TQIconSet::Normal ).width() + 4; - int ih = iconSet()->pixmap( TQIconSet::Small, TQIconSet::Normal ).height(); - w += iw; - h = TQMAX( h, ih ); - } -#endif - if ( isMenuButton() ) - w += style().pixelMetric(TQStyle::PM_MenuButtonIndicator, this); - - if ( pixmap() ) { - TQPixmap *pm = (TQPixmap *)pixmap(); - w += pm->width(); - h += pm->height(); - } else { - TQString s( text() ); - bool empty = s.isEmpty(); - if ( empty ) - s = TQString::fromLatin1("XXXX"); - TQFontMetrics fm = fontMetrics(); - TQSize sz = fm.size( ShowPrefix, s ); - if(!empty || !w) - w += sz.width(); - if(!empty || !h) - h = TQMAX(h, sz.height()); - } - - return (style().tqsizeFromContents(TQStyle::CT_ToolButton, this, TQSize(w, h)). - expandedTo(TQApplication::globalStrut())); -} - - -KMultiTabBarTab::KMultiTabBarTab(const TQPixmap& pic, const TQString& text, - int id,TQWidget *parent,KMultiTabBar::KMultiTabBarPosition pos, - KMultiTabBar::KMultiTabBarStyle style) - :KMultiTabBarButton(text,0,id,parent,pos,style), - m_showActiveTabText(false) -{ - down = false; - d=new KMultiTabBarTabPrivate(); - setIcon(pic); - m_expandedSize=24; - //setToggleButton(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()) { - TQWMatrix temp;// (1.0F, 0.0F, 0.0F, -1.0F, 0.0F, 0.0F); - temp.rotate(180); - d->pix=d->pix.xForm(temp); - setIconSet(d->pix); - } - } - - setPosition(pos); -// repaint(); -} - -void KMultiTabBarTab::setIcon(const TQString& icon) -{ - TQPixmap pic=SmallIcon(icon); - setIcon(pic); -} - -void KMultiTabBarTab::setIcon(const TQPixmap& icon) -{ - - if (m_style!=KMultiTabBar::KDEV3) { - if ((m_position==KMultiTabBar::Left) || (m_position==KMultiTabBar::Right)) { - TQWMatrix rotateMatrix; - if (m_position==KMultiTabBar::Left) - rotateMatrix.rotate(90); - else - rotateMatrix.rotate(-90); - TQPixmap pic=icon.xForm(rotateMatrix); //TODO FIX THIS, THIS SHOWS WINDOW - d->pix=pic; - setIconSet(pic); - } else setIconSet(icon); - } -} - -void KMultiTabBarTab::slotClicked() -{ - down = true; - updateState(); - KMultiTabBarButton::slotClicked(); -} - -void KMultiTabBarTab::setState(bool b) -{ - down = b; - updateState(); -} - -void KMultiTabBarTab::updateState() -{ - - if (m_style!=KMultiTabBar::KONQSBC) { - if ((m_style==KMultiTabBar::KDEV3) || (m_style==KMultiTabBar::KDEV3ICON) || (down)) { - TQPushButton::setText(m_text); - } else { - //kdDebug()<<"KMultiTabBarTab::updateState(): setting text to an empty TQString***************"<height(),this->width());//KMultiTabBarButton::sizeHint(); - else sh=TQSize(this->width(),this->height()); - } - else - sh=TQSize(width,height); - - TQPixmap pixmap( sh.width(),height); ///,sh.height()); - pixmap.fill(eraseColor()); - TQPainter painter(&pixmap); - - - TQStyle::SFlags st=TQStyle::Style_Default; - - st|=TQStyle::Style_Enabled; - - if (down) st|=TQStyle::Style_On; - - style().drawControl(TQStyle::CE_PushButton,&painter,this, TQRect(0,0,pixmap.width(),pixmap.height()), colorGroup(),st); - style().drawControl(TQStyle::CE_PushButtonLabel,&painter,this, TQRect(0,0,pixmap.width(),pixmap.height()), colorGroup(),st); - - 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; - } -// style().drawControl(TQStyle::CE_PushButtonLabel,painter,this, TQRect(0,0,pixmap.width(),pixmap.height()), -// colorGroup(),TQStyle::Style_Enabled); - - -} - -void KMultiTabBarTab::drawButtonClassic(TQPainter *paint) -{ - TQPixmap pixmap; - if ( iconSet()) - pixmap = iconSet()->pixmap( TQIconSet::Small, TQIconSet::Normal ); - paint->fillRect(0, 0, 24, 24, colorGroup().background()); - - if (!down) - { - - if (m_position==KMultiTabBar::Right) - { - paint->fillRect(0,0,21,21,TQBrush(colorGroup().background())); - - paint->setPen(colorGroup().background().dark(150)); - paint->drawLine(0,22,23,22); - - paint->drawPixmap(12-pixmap.width()/2,12-pixmap.height()/2,pixmap); - - paint->setPen(colorGroup().shadow()); - paint->drawLine(0,0,0,23); - paint->setPen(colorGroup().background().dark(120)); - paint->drawLine(1,0,1,23); - - } - else - if ((m_position==KMultiTabBar::Bottom) || (m_position==KMultiTabBar::Top)) - { - paint->fillRect(0,1,23,22,TQBrush(colorGroup().background())); - - paint->drawPixmap(12-pixmap.width()/2,12-pixmap.height()/2,pixmap); - - paint->setPen(colorGroup().background().dark(120)); - paint->drawLine(23,0,23,23); - - - paint->setPen(colorGroup().light()); - paint->drawLine(0,22,23,22); - paint->drawLine(0,23,23,23); - paint->setPen(colorGroup().shadow()); - paint->drawLine(0,0,23,0); - paint->setPen(colorGroup().background().dark(120)); - paint->drawLine(0,1,23,1); - - } - else - { - paint->setPen(colorGroup().background().dark(120)); - paint->drawLine(0,23,23,23); - paint->fillRect(0,0,23,21,TQBrush(colorGroup().background())); - paint->drawPixmap(12-pixmap.width()/2,12-pixmap.height()/2,pixmap); - - paint->setPen(colorGroup().light()); - paint->drawLine(23,0,23,23); - paint->drawLine(22,0,22,23); - - paint->setPen(colorGroup().shadow()); - paint->drawLine(0,0,0,23); - - } - - - } - else - { - if (m_position==KMultiTabBar::Right) - { - paint->setPen(colorGroup().shadow()); - 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,TQBrush(colorGroup().light())); - paint->drawPixmap(10-pixmap.width()/2,10-pixmap.height()/2,pixmap); - - if (m_showActiveTabText) - { - if (height()<25+4) return; - - TQPixmap tpixmap(height()-25-3, width()-2); - TQPainter painter(&tpixmap); - - painter.fillRect(0,0,tpixmap.width(),tpixmap.height(),TQBrush(colorGroup().light())); - - painter.setPen(colorGroup().text()); - painter.drawText(0,+width()/2+TQFontMetrics(TQFont()).height()/2,m_text); - - paint->rotate(90); - kdDebug()<<"tpixmap.width:"<drawPixmap(25,-tpixmap.height()+1,tpixmap); - } - - } - else - if (m_position==KMultiTabBar::Top) - { - paint->fillRect(0,0,width()-1,23,TQBrush(colorGroup().light())); - paint->drawPixmap(10-pixmap.width()/2,10-pixmap.height()/2,pixmap); - if (m_showActiveTabText) - { - paint->setPen(colorGroup().text()); - paint->drawText(25,height()/2+TQFontMetrics(TQFont()).height()/2,m_text); - } - } - else - if (m_position==KMultiTabBar::Bottom) - { - paint->setPen(colorGroup().shadow()); - paint->drawLine(0,23,width()-1,23); - paint->drawLine(0,22,width()-1,22); - paint->fillRect(0,0,width()-1,21,TQBrush(colorGroup().light())); - paint->drawPixmap(10-pixmap.width()/2,10-pixmap.height()/2,pixmap); - if (m_showActiveTabText) - { - paint->setPen(colorGroup().text()); - paint->drawText(25,height()/2+TQFontMetrics(TQFont()).height()/2,m_text); - } - - } - else - { - - - paint->setPen(colorGroup().shadow()); - paint->drawLine(0,height()-1,23,height()-1); - paint->drawLine(0,height()-2,23,height()-2); - paint->fillRect(0,0,23,height()-3,TQBrush(colorGroup().light())); - paint->drawPixmap(10-pixmap.width()/2,10-pixmap.height()/2,pixmap); - if (m_showActiveTabText) - { - - if (height()<25+4) return; - - TQPixmap tpixmap(height()-25-3, width()-2); - TQPainter painter(&tpixmap); - - painter.fillRect(0,0,tpixmap.width(),tpixmap.height(),TQBrush(colorGroup().light())); - - painter.setPen(colorGroup().text()); - painter.drawText(tpixmap.width()-TQFontMetrics(TQFont()).width(m_text),+width()/2+TQFontMetrics(TQFont()).height()/2,m_text); - - paint->rotate(-90); - kdDebug()<<"tpixmap.width:"<drawPixmap(-24-tpixmap.width(),2,tpixmap); - - } - - } - - } -} - - - - - - - -KMultiTabBar::KMultiTabBar(KMultiTabBarMode bm, TQWidget *parent,const char *name):TQWidget(parent,name) -{ - m_buttons.setAutoDelete(false); - if (bm==Vertical) - { - m_l=new TQVBoxLayout(this); - setSizePolicy(TQSizePolicy::Fixed, TQSizePolicy::Expanding, true); -// setFixedWidth(24); - } - else - { - m_l=new TQHBoxLayout(this); - setSizePolicy(TQSizePolicy::Expanding, TQSizePolicy::Fixed, true); -// setFixedHeight(24); - } - m_l->setMargin(0); - m_l->setAutoAdd(false); - - m_internal=new KMultiTabBarInternal(this,bm); - setPosition((bm==KMultiTabBar::Vertical)?KMultiTabBar::Right:KMultiTabBar::Bottom); - setStyle(VSNET); - // setStyle(KDEV3); - //setStyle(KONQSBC); - m_l->insertWidget(0,m_internal); - m_l->insertWidget(0,m_btnTabSep=new TQFrame(this)); - m_btnTabSep->setFixedHeight(4); - m_btnTabSep->setFrameStyle(TQFrame::Panel | TQFrame::Sunken); - m_btnTabSep->setLineWidth(2); - m_btnTabSep->hide(); - - updateGeometry(); -} - -KMultiTabBar::~KMultiTabBar() { -} - -/*int KMultiTabBar::insertButton(TQPixmap pic,int id ,const TQString&) -{ - (new TDEToolbarButton(pic,id,m_internal))->show(); - return 0; -}*/ - -int KMultiTabBar::appendButton(const TQPixmap &pic ,int id,TQPopupMenu *popup,const TQString&) -{ - KMultiTabBarButton *btn; - m_buttons.append(btn= new KMultiTabBarButton(pic,TQString(), - 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 (TQPtrListIterator it(m_buttons);it.current();++it){ - if (it.current()->isVisibleTo(this)) { - hideSep=false; - break; - } - } - if (hideSep) m_btnTabSep->hide(); - else m_btnTabSep->show(); - -} - -int KMultiTabBar::appendTab(const TQPixmap &pic ,int id ,const TQString& text) -{ - m_internal->appendTab(pic,id,text); - connect( tab(id),TQT_SIGNAL(clicked(int)), this, TQT_SLOT(tabClicked(int)) ); - return 0; -} - -void KMultiTabBar::tabClicked( int id ) -{ - for (TQPtrListIterator it(m_internal->m_tabs);it.current();++it){ - if (it.current()->id()!=id && it.current()->down ) - it.current()->setState(false); - } -} - -KMultiTabBarButton* KMultiTabBar::button(int id) const -{ - for (TQPtrListIterator it(m_buttons);it.current();++it){ - if (it.current()->id()!=id) return it.current(); - } - return 0; -} - -KMultiTabBarTab* KMultiTabBar::tab(int id) const -{ - return m_internal->tab(id); -} - - - -void KMultiTabBar::removeButton(int id) -{ - for (uint pos=0;posid()==id) - { - m_buttons.take(pos)->deleteLater(); - 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->down; - } - - return false; -} - - -void KMultiTabBar::showActiveTabTexts(bool show) -{ - m_internal->showActiveTabTexts(show); -} - -void KMultiTabBar::setStyle(KMultiTabBarStyle style) -{ - m_internal->setStyle(style); -} - -void KMultiTabBar::setPosition(KMultiTabBarPosition pos) -{ - m_position=pos; - m_internal->setPosition(pos); - for (uint i=0;isetPosition(pos); -} -void KMultiTabBar::fontChange(const TQFont& /* oldFont */) -{ - for (uint i=0;icount();i++) - tabs()->at(i)->resize(); - repaint(); -} - -TQPtrList* KMultiTabBar::tabs() {return m_internal->tabs();} -TQPtrList* KMultiTabBar::buttons() {return &m_buttons;} diff --git a/kaffeine/src/tdemultitabbar.h b/kaffeine/src/tdemultitabbar.h deleted file mode 100644 index ccb9884..0000000 --- a/kaffeine/src/tdemultitabbar.h +++ /dev/null @@ -1,251 +0,0 @@ -/* - * tdemultitabbar.h - * - * Copyright (C) 2001,2002,2003 Joseph Wenninger - * Copyright (C) 2005 Christophe Thommeret - * - * 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; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#ifndef TDEMULTITABBAR_H -#define TDEMULTITABBAR_H - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include -#include -#include -#include -#include - -class TQPixmap; -class TQPainter; -class TQFrame; - -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 /*TDEUTILS_EXPORT*/ KMultiTabBar: public TQWidget -{ - Q_OBJECT - -public: - enum KMultiTabBarMode{Horizontal, Vertical}; - enum KMultiTabBarPosition{Left, Right, Top, Bottom}; - - /** - * 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), this one is disabled - * at the moment, but will be renabled soon too - */ - enum KMultiTabBarStyle{VSNET=0, KDEV3=1, KONQSBC=2, KDEV3ICON=3,STYLELAST=0xffff}; - - KMultiTabBar(KMultiTabBarMode bm,TQWidget *parent=0,const char *name=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 TQPixmap &pic,int id=-1,TQPopupMenu* popup=0,const TQString& not_used_yet=TQString()); - /** - * 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 TQPixmap &pic,int id=-1,const TQString& text=TQString()); - /** - * 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); - /** - * set the display style of the tabs - */ - void setStyle(KMultiTabBarStyle style); - /** - * be carefull, don't delete tabs yourself and don't delete the list itself - */ - TQPtrList* tabs(); - /** - * be carefull, don't delete buttons yourself and don't delete the list itself - */ - TQPtrList* buttons(); - - /** - * might vanish, not sure yet - */ - void showActiveTabTexts(bool show=true); -private slots: - void tabClicked(int id); -protected: - friend class KMultiTabBarButton; - virtual void fontChange( const TQFont& ); - void updateSeparator(); -private: - class KMultiTabBarInternal *m_internal; - TQBoxLayout *m_l; - TQFrame *m_btnTabSep; - TQPtrList m_buttons; - KMultiTabBarPosition m_position; - KMultiTabBarPrivate *d; -}; - -/** - * This class should never be created except with the appendButton call of KMultiTabBar - */ -class /*TDEUTILS_EXPORT*/ KMultiTabBarButton: public TQPushButton -{ - Q_OBJECT - -public: - KMultiTabBarButton(const TQPixmap& pic,const TQString&, TQPopupMenu *popup, - int id,TQWidget *parent, KMultiTabBar::KMultiTabBarPosition pos, KMultiTabBar::KMultiTabBarStyle style); - KMultiTabBarButton(const TQString&, TQPopupMenu *popup, - int id,TQWidget *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 TQString &); - - TQSize sizeHint() const; - -protected: - KMultiTabBar::KMultiTabBarPosition m_position; - KMultiTabBar::KMultiTabBarStyle m_style; - TQString m_text; - virtual void hideEvent( class TQHideEvent*); - virtual void showEvent( class TQShowEvent*); -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 /*TDEUTILS_EXPORT*/ KMultiTabBarTab: public KMultiTabBarButton -{ - Q_OBJECT - -public: - KMultiTabBarTab(const TQPixmap& pic,const TQString&,int id,TQWidget *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); - bool down; - /** - * 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 drawButton(TQPainter *); - virtual void drawButtonLabel(TQPainter *); - void drawButtonStyled(TQPainter *); - void drawButtonClassic(TQPainter *); -protected slots: - virtual void slotClicked(); - void setTabsPosition(KMultiTabBar::KMultiTabBarPosition); - -public slots: - virtual void setIcon(const TQString&); - virtual void setIcon(const TQPixmap&); -}; - -#endif /* TDEMULTITABBAR_H */ diff --git a/kaffeine/src/tdemultitabbar_p.h b/kaffeine/src/tdemultitabbar_p.h deleted file mode 100644 index c7fe1d8..0000000 --- a/kaffeine/src/tdemultitabbar_p.h +++ /dev/null @@ -1,69 +0,0 @@ -/* - * tdemultitabbar_p.h - * - * Copyright (C) 2003 Joseph Wenninger - * - * 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; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#ifndef TDEMULTITABBAR_P_H -#define TDEMULTITABBAR_P_H - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include - -class KMultiTabBarInternal: public TQScrollView -{ - Q_OBJECT - -public: - KMultiTabBarInternal(TQWidget *parent,KMultiTabBar::KMultiTabBarMode bm); - int appendTab(const TQPixmap &,int=-1,const TQString& =TQString()); - KMultiTabBarTab *tab(int) const; - void removeTab(int); - void setPosition(enum KMultiTabBar::KMultiTabBarPosition pos); - void setStyle(enum KMultiTabBar::KMultiTabBarStyle style); - void showActiveTabTexts(bool show); - TQPtrList* tabs(){return &m_tabs;} -private: - friend class KMultiTabBar; - TQWidget *box; - TQBoxLayout *mainLayout; - TQPtrList 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(TQObject *,TQEvent*); - virtual void drawContents ( TQPainter *, int, int, int, int); - - /** - * [contentsM|m]ousePressEvent are reimplemented from TQScrollView - * in order to ignore all mouseEvents on the viewport, so that the - * parent can handle them. - */ - virtual void contentsMousePressEvent(TQMouseEvent *); - virtual void mousePressEvent(TQMouseEvent *); - virtual void resizeEvent(TQResizeEvent *); -}; - -#endif /* TDEMULTITABBAR_P_H */