From 4e2b92105c7d452618718602fa8082d60cadd93b Mon Sep 17 00:00:00 2001 From: Tobias Doerffel Date: Fri, 13 Feb 2009 11:32:08 +0000 Subject: [PATCH] reverted some of the changes from 2008-11-10 which caused distorted graphics when running LMMS with Qt 4.5 git-svn-id: https://lmms.svn.sf.net/svnroot/lmms/trunk/lmms@2030 0778d3d1-df1d-0410-868b-ea421aaaa00d --- ChangeLog | 13 + src/core/track.cpp | 4 +- src/gui/widgets/combobox.cpp | 3 +- src/gui/widgets/controller_view.cpp | 2 - src/gui/widgets/effect_rack_view.cpp | 3 +- src/gui/widgets/envelope_and_lfo_view.cpp | 4 +- src/gui/widgets/group_box.cpp | 3 +- src/gui/widgets/kmultitabbar.cpp | 920 ---------------------- src/gui/widgets/lcd_spinbox.cpp | 3 +- src/gui/widgets/side_bar_widget.cpp | 91 --- src/gui/widgets/tab_widget.cpp | 4 +- 11 files changed, 20 insertions(+), 1030 deletions(-) delete mode 100644 src/gui/widgets/kmultitabbar.cpp delete mode 100644 src/gui/widgets/side_bar_widget.cpp diff --git a/ChangeLog b/ChangeLog index 112168b9d..12c0eca5c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2009-02-13 Tobias Doerffel + + * src/gui/widgets/combobox.cpp: + * src/gui/widgets/tab_widget.cpp: + * src/gui/widgets/envelope_and_lfo_view.cpp: + * src/gui/widgets/group_box.cpp: + * src/gui/widgets/lcd_spinbox.cpp: + * src/gui/widgets/controller_view.cpp: + * src/gui/widgets/effect_rack_view.cpp: + * src/core/track.cpp: + reverted some of the changes from 2008-11-10 which caused distorted + graphics when running LMMS with Qt 4.5 + 2009-02-12 Tobias Doerffel * src/gui/fluiq/collapsible_widget.cpp: diff --git a/src/core/track.cpp b/src/core/track.cpp index cd7fbf798..14343ba35 100644 --- a/src/core/track.cpp +++ b/src/core/track.cpp @@ -4,7 +4,7 @@ * track.cpp - implementation of classes concerning tracks -> neccessary for * all track-like objects (beat/bassline, sample-track...) * - * Copyright (c) 2004-2008 Tobias Doerffel + * Copyright (c) 2004-2009 Tobias Doerffel * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * @@ -1361,8 +1361,6 @@ trackOperationsWidget::trackOperationsWidget( trackView * _parent ) : m_trackView->getTrackContainerView(), SLOT( deleteTrackView( trackView * ) ), Qt::QueuedConnection ); - - setAttribute( Qt::WA_OpaquePaintEvent, true ); } diff --git a/src/gui/widgets/combobox.cpp b/src/gui/widgets/combobox.cpp index 3661b274c..46362f496 100644 --- a/src/gui/widgets/combobox.cpp +++ b/src/gui/widgets/combobox.cpp @@ -3,7 +3,7 @@ /* * combobox.cpp - implementation of LMMS-combobox * - * Copyright (c) 2006-2008 Tobias Doerffel + * Copyright (c) 2006-2009 Tobias Doerffel * Copyright (c) 2008-2009 Paul Giblock * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net @@ -81,7 +81,6 @@ comboBox::comboBox( QWidget * _parent, const QString & _name ) : connect( &m_menu, SIGNAL( triggered( QAction * ) ), this, SLOT( setItem( QAction * ) ) ); - setAttribute( Qt::WA_OpaquePaintEvent, true ); setAccessibleName( _name ); doConnections(); } diff --git a/src/gui/widgets/controller_view.cpp b/src/gui/widgets/controller_view.cpp index b75239f85..1ab53f36f 100644 --- a/src/gui/widgets/controller_view.cpp +++ b/src/gui/widgets/controller_view.cpp @@ -55,8 +55,6 @@ controllerView::controllerView( controller * _model, QWidget * _parent ) : { setFixedSize( 210, 32 ); - setAttribute( Qt::WA_OpaquePaintEvent, TRUE ); - QPushButton * ctls_btn = new QPushButton( tr( "Controls" ), this ); QFont f = ctls_btn->font(); diff --git a/src/gui/widgets/effect_rack_view.cpp b/src/gui/widgets/effect_rack_view.cpp index 0fb2ae5c6..1a0df38b9 100644 --- a/src/gui/widgets/effect_rack_view.cpp +++ b/src/gui/widgets/effect_rack_view.cpp @@ -4,7 +4,7 @@ * effect_rack_view.cpp - view for effectChain-model * * Copyright (c) 2006-2007 Danny McRae - * Copyright (c) 2008 Tobias Doerffel + * Copyright (c) 2008-2009 Tobias Doerffel * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * @@ -42,7 +42,6 @@ effectRackView::effectRackView( effectChain * _model, QWidget * _parent ) : QWidget( _parent ), modelView( NULL, this ) { - setAttribute( Qt::WA_OpaquePaintEvent, true ); setFixedSize( 250, 250 ); m_mainLayout = new QVBoxLayout( this ); diff --git a/src/gui/widgets/envelope_and_lfo_view.cpp b/src/gui/widgets/envelope_and_lfo_view.cpp index 3a9bd1ab9..81a732bc3 100644 --- a/src/gui/widgets/envelope_and_lfo_view.cpp +++ b/src/gui/widgets/envelope_and_lfo_view.cpp @@ -4,7 +4,7 @@ * envelope_and_lfo_view.cpp - widget which is m_used by envelope/lfo/filter- * tab of channel-window * - * Copyright (c) 2004-2008 Tobias Doerffel + * Copyright (c) 2004-2009 Tobias Doerffel * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * @@ -102,8 +102,6 @@ envelopeAndLFOView::envelopeAndLFOView( QWidget * _parent ) : s_lfoGraph = new QPixmap( embed::getIconPixmap( "lfo_graph" ) ); } - setAttribute( Qt::WA_OpaquePaintEvent, true ); - m_predelayKnob = new knob( knobBright_26, this ); m_predelayKnob->setLabel( tr( "DEL" ) ); m_predelayKnob->move( PREDELAY_KNOB_X, ENV_KNOBS_Y ); diff --git a/src/gui/widgets/group_box.cpp b/src/gui/widgets/group_box.cpp index e14767ffa..64df7b0c7 100644 --- a/src/gui/widgets/group_box.cpp +++ b/src/gui/widgets/group_box.cpp @@ -3,7 +3,7 @@ /* * group_box.cpp - groupbox for LMMS * - * Copyright (c) 2005-2008 Tobias Doerffel + * Copyright (c) 2005-2009 Tobias Doerffel * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * @@ -47,7 +47,6 @@ groupBox::groupBox( const QString & _caption, QWidget * _parent ) : boolModelView( NULL, this ), m_caption( _caption ) { - setAttribute( Qt::WA_OpaquePaintEvent, true ); updatePixmap(); m_led = new pixmapButton( this, _caption ); diff --git a/src/gui/widgets/kmultitabbar.cpp b/src/gui/widgets/kmultitabbar.cpp deleted file mode 100644 index 04c7ad850..000000000 --- a/src/gui/widgets/kmultitabbar.cpp +++ /dev/null @@ -1,920 +0,0 @@ -#ifndef SINGLE_SOURCE_COMPILE - -/* - * kmultitabbar.cpp - widget for horizontal and vertical tabs - * - * Copyright (c) 2001-2003 Joseph Wenninger - * Copyright (c) 2004-2007 Tobias Doerffel - * - * 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 -#include -#include -#include -#include -#include -#include -#include - -#include - -#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;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 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;iaddWidget(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;i2neededSize();\ - 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;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; - - for (int i=0;ineededSize()+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;ineededSize()+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 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_expandedTabSizeneededSize()) { - m_expandedTabSize=tab->neededSize(); - for (int 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 (int pos=0;posid()==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;isetTabsPosition(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(parentWidget()); - if (tb) tb->updateSeparator(); -} - -void KMultiTabBarButton::showEvent( QShowEvent* he) { - QPushButton::showEvent(he); - KMultiTabBar *tb=dynamic_cast(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 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 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;posid()==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;isetPosition(pos); -} - -KMultiTabBar::KMultiTabBarPosition KMultiTabBar::position() const -{ - return m_position; -} -void KMultiTabBar::fontChange(const QFont& /* oldFont */) -{ - for (int i=0;icount();i++) - tabs()->at(i)->resize(); - update(); -} - -QList* KMultiTabBar::tabs() {return m_internal->tabs();} -QList* KMultiTabBar::buttons() {return &m_buttons;} - - -#include "moc_kmultitabbar.cxx" - - - -#endif diff --git a/src/gui/widgets/lcd_spinbox.cpp b/src/gui/widgets/lcd_spinbox.cpp index 537b28dbb..a368c9755 100644 --- a/src/gui/widgets/lcd_spinbox.cpp +++ b/src/gui/widgets/lcd_spinbox.cpp @@ -3,7 +3,7 @@ /* * lcd_spinbox.cpp - class lcdSpinBox, an improved QLCDNumber * - * Copyright (c) 2005-2008 Tobias Doerffel + * Copyright (c) 2005-2009 Tobias Doerffel * Copyright (c) 2008-2009 Paul Giblock * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net @@ -52,7 +52,6 @@ lcdSpinBox::lcdSpinBox( int _num_digits, QWidget * _parent, m_numDigits( _num_digits ), m_origMousePos() { - setAttribute( Qt::WA_OpaquePaintEvent, true ); setEnabled( true ); setAccessibleName( _name ); diff --git a/src/gui/widgets/side_bar_widget.cpp b/src/gui/widgets/side_bar_widget.cpp deleted file mode 100644 index fea3491b2..000000000 --- a/src/gui/widgets/side_bar_widget.cpp +++ /dev/null @@ -1,91 +0,0 @@ -/* - * side_bar_widget.cpp - implementation of base-widget for side-bar - * - * Copyright (c) 2004-2008 Tobias Doerffel - * - * 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 -#include -#include - -#include "side_bar_widget.h" -#include "gui_templates.h" - - - -sideBarWidget::sideBarWidget( const QString & _title, const QPixmap & _icon, - QWidget * _parent ) : - QWidget( _parent ), - m_title( _title ), - m_icon( _icon ) -{ - m_contents = new QWidget( this ); - m_layout = new QVBoxLayout( m_contents ); - m_layout->setSpacing( 5 ); - m_layout->setMargin( 0 ); -} - - - - -sideBarWidget::~sideBarWidget() -{ -} - - - - -void sideBarWidget::paintEvent( QPaintEvent * ) -{ - const int TITLE_FONT_HEIGHT = 13; - - QPainter p( this ); - p.fillRect( 0, 0, width(), 27, palette().highlight().color() ); - - QFont f = p.font(); - f.setBold( TRUE ); - p.setFont( pointSize( f ) ); - - p.setPen( palette().highlightedText().color() ); - - const int tx = m_icon.width()+4; - const int ty = 2+TITLE_FONT_HEIGHT; - p.drawText( tx, ty, m_title ); - p.drawLine( tx, ty+4, width()-4, ty+4 ); - - p.drawPixmap( 2, 2, m_icon ); -} - - - -void sideBarWidget::resizeEvent( QResizeEvent * ) -{ - const int MARGIN = 6; - m_contents->setGeometry( MARGIN, 40 + MARGIN, width() - MARGIN * 2, - height() - MARGIN * 2 - 40 ); -} - - - -#include "moc_side_bar.cxx" -#include "moc_side_bar_widget.cxx" - diff --git a/src/gui/widgets/tab_widget.cpp b/src/gui/widgets/tab_widget.cpp index 518015db4..bd6f637e4 100644 --- a/src/gui/widgets/tab_widget.cpp +++ b/src/gui/widgets/tab_widget.cpp @@ -3,7 +3,7 @@ /* * tab_widget.cpp - tabwidget for LMMS * - * Copyright (c) 2005-2008 Tobias Doerffel + * Copyright (c) 2005-2009 Tobias Doerffel * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * @@ -50,8 +50,6 @@ tabWidget::tabWidget( const QString & _caption, QWidget * _parent ) : QPalette pal = palette(); pal.setColor( QPalette::Background, bg_color ); setPalette( pal ); - - setAttribute( Qt::WA_OpaquePaintEvent, true ); }