-rw-r--r-- | microkde/KDGanttMinimizeSplitter.cpp | 10 | ||||
-rw-r--r-- | microkde/kdialogbase.cpp | 8 |
2 files changed, 7 insertions, 11 deletions
diff --git a/microkde/KDGanttMinimizeSplitter.cpp b/microkde/KDGanttMinimizeSplitter.cpp index 253175e..2a30346 100644 --- a/microkde/KDGanttMinimizeSplitter.cpp +++ b/microkde/KDGanttMinimizeSplitter.cpp @@ -180,212 +180,208 @@ void KDGanttSplitterHandle::mouseReleaseEvent( QMouseEvent *e ) } _activeButton = 0; updateCursor( e->pos() ); } else { if ( !opaque() && e->button() == LeftButton ) { QCOORD pos = s->pick(parentWidget()->mapFromGlobal(e->globalPos())) - mouseOffset; s->setRubberband( -1 ); s->moveSplitter( pos, id() ); } } if ( s->rubberBand() ) s->rubberBand()->hide(); repaint(); } int KDGanttSplitterHandle::onButton( const QPoint& p ) { QValueList<QPointArray> list = buttonRegions(); int index = 1; int add = 12; for( QValueList<QPointArray>::Iterator it = list.begin(); it != list.end(); ++it ) { QRect rect = (*it).boundingRect(); rect.setLeft( rect.left()- add ); rect.setRight( rect.right() + add); rect.setTop( rect.top()- add ); rect.setBottom( rect.bottom() + add); if ( rect.contains( p ) ) { return index; } index++; } return 0; } QValueList<QPointArray> KDGanttSplitterHandle::buttonRegions() { QValueList<QPointArray> list; int sw = 8; int yyy = 1; int xxx = 1; int voffset[] = { (int) -sw*3, (int) sw*3 }; for ( int i = 0; i < 2; i++ ) { QPointArray arr; if ( !_collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Right || _collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Left) { int mid = height()/2 + voffset[i]; arr.setPoints( 3, 1-xxx, mid - sw + 4, sw-3-xxx, mid, 1-xxx, mid + sw -4); } else if ( !_collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Left || _collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Right ) { int mid = height()/2 + voffset[i]; arr.setPoints( 3, sw-4, mid - sw + 4, 0, mid, sw-4, mid + sw - 4); } else if ( !_collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Up || _collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Down) { int mid = width()/2 + voffset[i]; arr.setPoints( 3, mid - sw + 4, sw-4, mid, 0, mid + sw - 4, sw-4 ); } else if ( !_collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Down || _collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Up ) { int mid = width()/2 + voffset[i]; arr.setPoints( 3, mid - sw + 4, 1-yyy, mid, sw-3-yyy, mid + sw -4, 1-yyy); } list.append( arr ); } return list; } void KDGanttSplitterHandle::paintEvent( QPaintEvent * ) { QPixmap buffer( size() ); QPainter p( &buffer ); //LR // Draw the splitter rectangle p.setBrush( colorGroup().background() ); p.setPen( colorGroup().foreground() ); //p.drawRect( rect() ); #ifndef DESKTOP_VERSION if ( mMouseDown ) - buffer.fill( QColor( 242,27,255 ) ); + buffer.fill( colorGroup().background().dark() ); else #endif buffer.fill( colorGroup().background() ); //buffer.fill( backgroundColor() ); // parentWidget()->style().drawPrimitive( QStyle::PE_Panel, &p, rect(), parentWidget()->colorGroup()); int sw = 8; // Hardcoded, given I didn't use styles anymore, I didn't like to use their size // arrow color QColor col; if ( _activeButton ) col = colorGroup().background().dark( 250 ); else { if ( mMouseDown ) -#ifndef DESKTOP_VERSION - col = QColor( 178,18,188);//QColor( 242,27,255 );//Qt::white; -#else - col = Qt::white; -#endif + col = Qt::white; else col = colorGroup().background().dark( 150 ); } //QColor col = backgroundColor().dark( 130 ); p.setBrush( col ); p.setPen( col ); QValueList<QPointArray> list = buttonRegions(); int index = 1; if ( mUseOffset ) p.translate( 0, 1 ); for ( QValueList<QPointArray>::Iterator it = list.begin(); it != list.end(); ++it ) { if ( index == _activeButton ) { /* if ( ! _collapsed ) { p.save(); // p.translate( parentWidget()->style().pixelMetric( QStyle::PM_ButtonShiftHorizontal ), // parentWidget()->style().pixelMetric( QStyle::PM_ButtonShiftVertical ) ); p.translate( -1, 0 ); p.drawPolygon( *it, true ); p.restore(); } else */ p.drawPolygon( *it, true ); } else { /* if ( ! _collapsed ) { p.save(); p.translate( -1, 0 ); p.drawPolygon( *it, true ); p.restore(); } else */ p.drawPolygon( *it, true ); } index++; } // Draw the lines between the arrows if ( s->minimizeDirection() == KDGanttMinimizeSplitter::Left || s->minimizeDirection() == KDGanttMinimizeSplitter::Right ) { int mid = height()/2; p.drawLine ( 1, mid - sw, 1, mid + sw ); p.drawLine ( 3, mid - sw, 3, mid + sw ); } else if ( s->minimizeDirection() == KDGanttMinimizeSplitter::Up || s->minimizeDirection() == KDGanttMinimizeSplitter::Down ) { int mid = width()/2; p.drawLine( mid -sw, 1, mid +sw, 1 ); p.drawLine( mid -sw, 3, mid +sw, 3 ); } bitBlt( this, 0, 0, &buffer ); } #endif class QSplitterLayoutStruct { public: KDGanttMinimizeSplitter::ResizeMode mode; QCOORD sizer; bool isSplitter; QWidget *wid; }; class QSplitterData { public: QSplitterData() : opaque( FALSE ), firstShow( TRUE ) {} QPtrList<QSplitterLayoutStruct> list; bool opaque; bool firstShow; }; void kdganttGeomCalc( QMemArray<QLayoutStruct> &chain, int start, int count, int pos, int space, int spacer ); #endif // DOXYGEN_SKIP_INTERNAL /*! \class KDGanttMinimizeSplitter KDGanttMinimizeSplitter.h \brief The KDGanttMinimizeSplitter class implements a splitter widget with minimize buttons. This class (and its documentation) is largely a copy of Qt's QSplitter; the copying was necessary because QSplitter is not extensible at all. QSplitter and its documentation are licensed according to the GPL and the Qt Professional License (if you hold such a license) and are (C) Trolltech AS. A splitter lets the user control the size of child widgets by dragging the boundary between the children. Any number of widgets @@ -595,193 +591,193 @@ QSplitterLayoutStruct *KDGanttMinimizeSplitter::addWidget( QWidget *w, bool firs s->sizer = pick( w->size() ); s->isSplitter = FALSE; if ( first ) data->list.insert( 0, s ); else data->list.append( s ); if ( newHandle && isVisible() ) newHandle->show(); //will trigger sending of post events return s; } /*! Tells the splitter that a child widget has been inserted or removed. The event is passed in \a c. */ void KDGanttMinimizeSplitter::childEvent( QChildEvent *c ) { if ( c->type() == QEvent::ChildInserted ) { if ( !c->child()->isWidgetType() ) return; if ( ((QWidget*)c->child())->testWFlags( WType_TopLevel ) ) return; QSplitterLayoutStruct *s = data->list.first(); while ( s ) { if ( s->wid == c->child() ) return; s = data->list.next(); } addWidget( (QWidget*)c->child() ); recalc( isVisible() ); } else if ( c->type() == QEvent::ChildRemoved ) { QSplitterLayoutStruct *p = 0; if ( data->list.count() > 1 ) p = data->list.at(1); //remove handle _after_ first widget. QSplitterLayoutStruct *s = data->list.first(); while ( s ) { if ( s->wid == c->child() ) { data->list.removeRef( s ); delete s; if ( p && p->isSplitter ) { data->list.removeRef( p ); delete p->wid; //will call childEvent delete p; } recalcId(); doResize(); return; } p = s; s = data->list.next(); } } } /*! Shows a rubber band at position \a p. If \a p is negative, the rubber band is removed. */ void KDGanttMinimizeSplitter::setRubberband( int p ) { #ifdef DESKTOP_VERSION QPainter paint( this ); paint.setPen( gray ); paint.setBrush( gray ); paint.setRasterOp( XorROP ); QRect r = contentsRect(); const int rBord = 3; //Themable???? #if QT_VERSION >= 0x030000 int sw = style().pixelMetric(QStyle::PM_SplitterWidth, this); #else int sw = style().splitterWidth(); #endif if ( orient == Horizontal ) { if ( opaqueOldPos >= 0 ) paint.drawRect( opaqueOldPos + sw/2 - rBord , r.y(), 2*rBord, r.height() ); if ( p >= 0 ) paint.drawRect( p + sw/2 - rBord, r.y(), 2*rBord, r.height() ); } else { if ( opaqueOldPos >= 0 ) paint.drawRect( r.x(), opaqueOldPos + sw/2 - rBord, r.width(), 2*rBord ); if ( p >= 0 ) paint.drawRect( r.x(), p + sw/2 - rBord, r.width(), 2*rBord ); } opaqueOldPos = p; #else if ( !mRubberBand ) { mRubberBand = new QFrame( 0, "rubber", WStyle_NoBorder | WStyle_Customize | WStyle_StaysOnTop); mRubberBand->setFrameStyle( Box | Raised ); //mRubberBand->setPalette( QPalette ( Qt::red.light(),Qt::red.dark() ) ); - mRubberBand->setPalette( QPalette ( QColor( 178,18,188), QColor( 242,27,255 ) )); + mRubberBand->setPalette( QPalette ( colorGroup().background().light(), colorGroup().background().dark() )); } QRect r = contentsRect(); static int rBord = 0; //Themable???? if ( !rBord ) { if (QApplication::desktop()->width() <= 320 ) rBord = 3; else rBord = 4; } int sw = style().splitterWidth(); if ( orient == Horizontal ) { if ( p >= 0 ) { QPoint geo = mapToGlobal (QPoint ( p + sw/2 - rBord, r.y())); mRubberBand->setGeometry( geo.x(), geo.y(), 2*rBord, r.height() ); } } else { if ( p >= 0 ) { QPoint geo = mapToGlobal (QPoint ( r.x(), p + sw/2 - rBord)); mRubberBand->setGeometry( geo.x(), geo.y(), r.width(), 2*rBord); } } opaqueOldPos = p; if ( ! mRubberBand->isVisible() ) { mRubberBand->show(); } #endif } /*! \reimp */ bool KDGanttMinimizeSplitter::event( QEvent *e ) { if ( e->type() == QEvent::LayoutHint || ( e->type() == QEvent::Show && data->firstShow ) ) { recalc( isVisible() ); if ( e->type() == QEvent::Show ) data->firstShow = FALSE; } return QWidget::event( e ); } /*! \obsolete Draws the splitter handle in the rectangle described by \a x, \a y, \a w, \a h using painter \a p. \sa QStyle::drawPrimitive() */ void KDGanttMinimizeSplitter::drawSplitter( QPainter *p, QCOORD x, QCOORD y, QCOORD w, QCOORD h ) { #if 0 // LR style().drawPrimitive(QStyle::PE_Splitter, p, QRect(x, y, w, h), colorGroup(), (orientation() == Qt::Horizontal ? QStyle::Style_Horizontal : 0)); #endif } /*! Returns the id of the splitter to the right of or below the widget \a w, or 0 if there is no such splitter (i.e. it is either not in this KDGanttMinimizeSplitter or it is at the end). */ int KDGanttMinimizeSplitter::idAfter( QWidget* w ) const { QSplitterLayoutStruct *s = data->list.first(); bool seen_w = FALSE; while ( s ) { if ( s->isSplitter && seen_w ) return data->list.at(); if ( !s->isSplitter && s->wid == w ) seen_w = TRUE; s = data->list.next(); } return 0; } /*! Moves the left/top edge of the splitter handle with id \a id as close as possible to position \a p, which is the distance from the left (or top) edge of the widget. For Arabic and Hebrew the layout is reversed, and using this function to set the position of the splitter might lead to unexpected results, since in Arabic and Hebrew the position of splitter one is to the left of the position of splitter zero. \sa idAfter() */ void KDGanttMinimizeSplitter::moveSplitter( QCOORD p, int id ) { p = adjustPos( p, id ); QSplitterLayoutStruct *s = data->list.at(id); diff --git a/microkde/kdialogbase.cpp b/microkde/kdialogbase.cpp index e6144de..11635e1 100644 --- a/microkde/kdialogbase.cpp +++ b/microkde/kdialogbase.cpp @@ -43,209 +43,209 @@ KDialogBase::KDialogBase( int dialogFace, const QString &caption, if (findButton( defaultButton ) ) { (findButton( defaultButton ) )->setFocus(); (findButton( defaultButton ) )->setDefault( true ); } } KDialogBase::~KDialogBase() { } void KDialogBase::init( const QString &caption, int buttonMask, const QString &user1 ,const QString &user2 ) { mMainWidget = 0; mTabWidget = 0; mPlainPage = 0; mTopLayout = 0; if ( !caption.isEmpty() ) { setCaption( caption ); } if ( buttonMask & User1 ) { mUser1Button = new QPushButton( user1, this ); connect( mUser1Button, SIGNAL( clicked() ), SLOT( slotUser1() ) ); } else { mUser1Button = 0; } if ( buttonMask & User2 ) { mUser2Button = new QPushButton( user2, this ); connect( mUser2Button, SIGNAL( clicked() ), SLOT( slotUser2() ) ); } else { mUser2Button = 0; } if ( buttonMask & Ok ) { mOkButton = new QPushButton( i18n("Ok"), this ); connect( mOkButton, SIGNAL( clicked() ), SLOT( slotOk() ) ); //mOkButton->setDefault( true ); } else { mOkButton = 0; } if ( buttonMask & Default ) { mDefaultButton = new QPushButton( i18n("Default"), this ); connect( mDefaultButton, SIGNAL( clicked() ), SIGNAL( defaultClicked() ) ); } else { mDefaultButton = 0; } if ( buttonMask & Apply ) { mApplyButton = new QPushButton( i18n("Apply"), this ); connect( mApplyButton, SIGNAL( clicked() ), SLOT( slotApply() ) ); } else { mApplyButton = 0; } if ( buttonMask & Cancel ) { mCancelButton = new QPushButton( i18n("Cancel"), this ); connect( mCancelButton, SIGNAL( clicked() ), SLOT( slotCancel() ) ); } else { mCancelButton = 0; } if ( buttonMask & Close ) { mCloseButton = new QPushButton( i18n("Close"), this ); connect( mCloseButton, SIGNAL( clicked() ), SLOT( slotClose() ) ); } else { mCloseButton = 0; } } QTabWidget *KDialogBase::tabWidget() { if ( !mTabWidget ) { mTabWidget = new QTabWidget( this ); setMainWidget( mTabWidget ); } return mTabWidget; } void KDialogBase::hideButtons() { if ( mUser1Button ) mUser1Button->hide() ; if ( mUser2Button ) mUser2Button->hide() ; if ( mOkButton ) mOkButton->hide() ; if ( mApplyButton ) mApplyButton->hide() ; if ( mDefaultButton ) mDefaultButton->hide(); if ( mCancelButton ) mCancelButton->hide() ; if ( mCloseButton ) mCloseButton->hide() ; } void KDialogBase::initLayout() { delete mTopLayout; mTopLayout = new QVBoxLayout( this ); - mTopLayout->setMargin( marginHint() ); - mTopLayout->setSpacing( spacingHint() ); + mTopLayout->setMargin( marginHintSmall() ); + mTopLayout->setSpacing( spacingHintSmall() ); mTopLayout->addWidget( mMainWidget ); QBoxLayout *buttonLayout = new QHBoxLayout; mTopLayout->addLayout( buttonLayout ); if ( mUser1Button ) buttonLayout->addWidget( mUser1Button ); if ( mUser2Button ) buttonLayout->addWidget( mUser2Button ); if ( mOkButton ) buttonLayout->addWidget( mOkButton ); if ( mApplyButton ) buttonLayout->addWidget( mApplyButton ); if ( mDefaultButton ) buttonLayout->addWidget( mDefaultButton ); if ( mCancelButton ) buttonLayout->addWidget( mCancelButton ); if ( mCloseButton ) buttonLayout->addWidget( mCloseButton ); - buttonLayout->setMargin( 0 ); - buttonLayout->setSpacing( spacingHint() ); + buttonLayout->setMargin( marginHintSmall() ); + buttonLayout->setSpacing( spacingHintSmall() ); } QFrame *KDialogBase::addPage( const QString &name ) { // kdDebug() << "KDialogBase::addPage(): " << name << endl; QFrame *frame = new QFrame( tabWidget() ); tabWidget()->addTab( frame, name ); return frame; } QFrame *KDialogBase::addPage( const QString &name, int, const QPixmap & ) { return addPage( name ); } void KDialogBase::setMainWidget( QWidget *widget ) { kdDebug() << "KDialogBase::setMainWidget()" << endl; mMainWidget = widget; initLayout(); } void KDialogBase::setButtonText( ButtonCode id, const QString &text ) { QPushButton *button = findButton( id ); if ( button ) { button->setText( text ); } } void KDialogBase::enableButton( ButtonCode id, bool state ) { QPushButton *button = findButton( id ); if ( button ) { button->setEnabled( state ); } } QPushButton *KDialogBase::findButton( ButtonCode id ) { QPushButton *button = 0; switch ( id ) { case Ok: button = mOkButton; break; case Apply: button = mApplyButton; break; case User1: button = mUser1Button; break; case User2: button = mUser2Button; break; case Cancel: button = mCancelButton; break; case Default: button = mDefaultButton; break; case Close: button = mCloseButton; break; default: break; } return button; } void KDialogBase::enableButtonOK( bool state ) { enableButton( Ok, state ); } void KDialogBase::enableButtonApply( bool state ) { enableButton( Apply, state ); } void KDialogBase::showButton( ButtonCode id, bool show ) { QPushButton *button = findButton( id ); if ( button ) { if ( show ) button->show(); else button->hide(); } } int KDialogBase::pageIndex( QWidget *widget ) const { return 0; } |