extragear/multimedia/amarok/src/context/popupdropper/libpud
Seb Ruiz
ruiz at kde.org
Mon Apr 13 00:45:28 CEST 2009
2009/4/13 Jeff Mitchell <mitchell at kde.org>:
> SVN commit 952842 by mitchell:
>
> Sync changes against playground. PLEASE let me know of regressions...I had totally forgot I made these changes, and I know a part of what I had intended to do is incomplete (but I don't think should affect Amarok). This does fix some wishlist items though.
JEFF!
We are but a couple of weeks away from 2.1 release. I do not think it
is acceptable to be merging "playground" changes to a major component
of Amarok.
Can we revert and merge back in for 2.2?
>
>
> M +12 -13 PopupDropper.cpp
> M +0 -2 PopupDropper.h
> M +40 -13 PopupDropperAction.cpp
> M +13 -5 PopupDropperAction.h
> M +42 -1 PopupDropperItem.cpp
> M +1 -0 PopupDropperItem.h
>
>
> --- trunk/extragear/multimedia/amarok/src/context/popupdropper/libpud/PopupDropper.cpp #952841:952842
> @@ -623,17 +623,6 @@
> d->deleteTimeout = msecs;
> }
>
> -void PopupDropper::textUpdated()
> -{
> - //qDebug() << "In textUpdated";
> - foreach( PopupDropperItem *pdi, d->pdiItems )
> - {
> - //qDebug() << "Setting " << pdi->textItem()->toPlainText() << " to " << pdi->action()->text();
> - pdi->textItem()->setPlainText( pdi->action()->text() );
> - }
> - updateAllOverlays();
> -}
> -
> QColor PopupDropper::windowColor() const
> {
> return d->windowColor;
> @@ -864,9 +853,19 @@
> //qDebug() << "Action is not a separator!";
> return;
> }
> +
> + if( separator && separator->separatorStyle() == PopupDropperAction::TextSeparator )
> + {
> + //qDebug() << "Separator style is text";
> + PopupDropperItem* pdi = new PopupDropperItem();
> + pdi->setAction( separator );
> + addItem( pdi );
> + }
> +
> + //qDebug() << "Separator style is line";
> QPen linePen;
> - if( separator && separator->hasSeparatorPen() )
> - linePen = separator->separatorPen();
> + if( separator && separator->hasLineSeparatorPen() )
> + linePen = separator->lineSeparatorPen();
> else
> {
> linePen.setWidth( 2 );
> --- trunk/extragear/multimedia/amarok/src/context/popupdropper/libpud/PopupDropper.h #952841:952842
> @@ -98,8 +98,6 @@
> void setDeleteTimeout( int msecs );
> int deleteTimeout() const;
>
> - void textUpdated();
> -
> QColor windowColor() const;
> void setWindowColor( const QColor &window );
> QBrush windowBackgroundBrush() const;
> --- trunk/extragear/multimedia/amarok/src/context/popupdropper/libpud/PopupDropperAction.cpp #952841:952842
> @@ -33,8 +33,9 @@
> , elementId( QString() )
> , ownRenderer( false )
> , separator( false )
> - , hasSeparatorPen( false )
> - , separatorPen()
> + , separatorStyle( PopupDropperAction::TextSeparator )
> + , hasLineSeparatorPen( false )
> + , lineSeparatorPen()
> {}
>
> ~PopupDropperActionPrivate()
> @@ -47,8 +48,9 @@
> QString elementId;
> bool ownRenderer;
> bool separator;
> - bool hasSeparatorPen;
> - QPen separatorPen;
> + PopupDropperAction::SeparatorStyle separatorStyle;
> + bool hasLineSeparatorPen;
> + QPen lineSeparatorPen;
> };
>
> /////////////////////////////////////////////////////////////////////////
> @@ -63,12 +65,14 @@
> : QAction( text, parent )
> , d( new PopupDropperActionPrivate )
> {
> + d->separatorStyle = PopupDropperAction::TextSeparator;
> }
>
> PopupDropperAction::PopupDropperAction( const QIcon & icon, const QString & text, QObject * parent )
> : QAction( icon, text, parent )
> , d( new PopupDropperActionPrivate )
> {
> + d->separatorStyle = PopupDropperAction::TextSeparator;
> }
>
> PopupDropperAction::PopupDropperAction( const QString &elementId, const QString &text, QObject *parent )
> @@ -76,6 +80,7 @@
> , d( new PopupDropperActionPrivate )
> {
> d->elementId = elementId;
> + d->separatorStyle = PopupDropperAction::TextSeparator;
> }
>
> PopupDropperAction::PopupDropperAction( const QString &elementId, const QIcon &icon, const QString &text, QObject *parent )
> @@ -83,6 +88,7 @@
> , d( new PopupDropperActionPrivate )
> {
> d->elementId = elementId;
> + d->separatorStyle = PopupDropperAction::TextSeparator;
> }
>
> PopupDropperAction::PopupDropperAction( QSvgRenderer* renderer, const QString &text, QObject *parent )
> @@ -90,6 +96,7 @@
> , d( new PopupDropperActionPrivate )
> {
> d->renderer = renderer;
> + d->separatorStyle = PopupDropperAction::TextSeparator;
> }
>
> PopupDropperAction::PopupDropperAction( QSvgRenderer* renderer, const QIcon &icon, const QString &text, QObject *parent )
> @@ -97,6 +104,7 @@
> , d( new PopupDropperActionPrivate )
> {
> d->renderer = renderer;
> + d->separatorStyle = PopupDropperAction::TextSeparator;
> }
>
> //note that the elementId cannot be used by this directly; it is only here so that you can use it as a reference
> @@ -107,6 +115,7 @@
> {
> d->renderer = renderer;
> d->elementId = elementId;
> + d->separatorStyle = PopupDropperAction::TextSeparator;
> }
>
> //note that the elementId cannot be used by this directly; it is only here so that you can use it as a reference
> @@ -117,6 +126,7 @@
> {
> d->renderer = renderer;
> d->elementId = elementId;
> + d->separatorStyle = PopupDropperAction::TextSeparator;
> }
>
> PopupDropperAction::~PopupDropperAction()
> @@ -158,6 +168,12 @@
> d->elementId = id;;
> }
>
> +void PopupDropperAction::setText( const QString &text )
> +{
> + QAction::setText( text );
> + d->separatorStyle = PopupDropperAction::TextSeparator;
> +}
> +
> bool PopupDropperAction::isSeparator() const
> {
> return d->separator;
> @@ -169,26 +185,37 @@
> QAction::setSeparator( separator );
> }
>
> -bool PopupDropperAction::hasSeparatorPen() const
> +PopupDropperAction::SeparatorStyle PopupDropperAction::separatorStyle() const
> {
> - return d->hasSeparatorPen;
> + return d->separatorStyle;
> }
>
> -QPen PopupDropperAction::separatorPen() const
> +void PopupDropperAction::setSeparatorStyle( PopupDropperAction::SeparatorStyle style )
> {
> - return d->separatorPen;
> + d->separatorStyle = style;
> }
>
> -void PopupDropperAction::setSeparatorPen( const QPen &pen )
> +bool PopupDropperAction::hasLineSeparatorPen() const
> {
> - d->hasSeparatorPen = true;
> - d->separatorPen = pen;
> + return d->hasLineSeparatorPen;
> }
>
> +QPen PopupDropperAction::lineSeparatorPen() const
> +{
> + return d->lineSeparatorPen;
> +}
> +
> +void PopupDropperAction::setLineSeparatorPen( const QPen &pen )
> +{
> + d->hasLineSeparatorPen = true;
> + d->lineSeparatorPen = pen;
> + d->separatorStyle = PopupDropperAction::LineSeparator;
> +}
> +
> void PopupDropperAction::clearSeparatorPen()
> {
> - d->hasSeparatorPen = false;
> - d->separatorPen = QPen();
> + d->hasLineSeparatorPen = false;
> + d->lineSeparatorPen = QPen();
> }
>
> PopupDropperAction* PopupDropperAction::from( QAction* action )
> --- trunk/extragear/multimedia/amarok/src/context/popupdropper/libpud/PopupDropperAction.h #952841:952842
> @@ -39,10 +39,14 @@
> Q_PROPERTY( QSvgRenderer* renderer READ renderer WRITE setRenderer )
> Q_PROPERTY( QString elementId READ elementId WRITE setElementId )
> Q_PROPERTY( bool separator READ isSeparator WRITE setSeparator )
> - Q_PROPERTY( bool hasSeparatorPen READ hasSeparatorPen )
> - Q_PROPERTY( QPen separatorPen READ separatorPen WRITE setSeparatorPen )
> + Q_PROPERTY( PopupDropperAction::SeparatorStyle separatorStyle READ separatorStyle WRITE setSeparatorStyle )
> + Q_PROPERTY( bool hasLineSeparatorPen READ hasLineSeparatorPen )
> + Q_PROPERTY( QPen lineSeparatorPen READ lineSeparatorPen WRITE setLineSeparatorPen )
>
> public:
> + enum SeparatorStyle{TextSeparator, LineSeparator};
> + Q_ENUMS( separatorStyle )
> +
> PopupDropperAction( QObject *parent );
> PopupDropperAction( const QString &text, QObject *parent );
> PopupDropperAction( const QIcon &icon, const QString &text, QObject *parent );
> @@ -61,13 +65,17 @@
> void setRenderer( const QByteArray &contents );
> QString elementId() const;
> void setElementId( const QString &id );
> + void setText( const QString &text );
>
> bool isSeparator() const;
> void setSeparator( bool separator );
>
> - bool hasSeparatorPen() const;
> - QPen separatorPen() const;
> - void setSeparatorPen( const QPen &pen );
> + PopupDropperAction::SeparatorStyle separatorStyle() const;
> + void setSeparatorStyle( PopupDropperAction::SeparatorStyle style );
> +
> + bool hasLineSeparatorPen() const;
> + QPen lineSeparatorPen() const;
> + void setLineSeparatorPen( const QPen &pen );
> void clearSeparatorPen();
>
> //quick and dirty function for getting a PopupDropperAction from a QAction.
> --- trunk/extragear/multimedia/amarok/src/context/popupdropper/libpud/PopupDropperItem.cpp #952841:952842
> @@ -117,6 +117,8 @@
> //and element id, if they exist in the action!
> void PopupDropperItem::setAction( PopupDropperAction *action )
> {
> + if( !action )
> + return;
> //note that this also sets the text
> d->action = action;
> d->text = action->text();
> @@ -213,8 +215,20 @@
> void PopupDropperItem::setText( const QString &text )
> {
> d->text = text;
> + if( d->textItem )
> + d->textItem->setPlainText( text );
> + reposTextItem();
> }
>
> +//Note: constructor assumes plain text; this function must be called later
> +void PopupDropperItem::setHtmlText( const QString &text )
> +{
> + d->text = text;
> + if( d->textItem )
> + d->textItem->setPlainText( text );
> + reposTextItem();
> +}
> +
> QFont PopupDropperItem::font() const
> {
> return d->font;
> @@ -383,6 +397,13 @@
> if( !d->svgItem || !d->borderRectItem )
> return;
>
> + if( d->separator )
> + {
> + d->svgItem->scale( 0, 0 );
> + d->svgItem->setPos( 0, 0 );
> + return;
> + }
> +
> //Need to scale if it is too tall or wide
> qreal maxheight = d->svgElementRect.height() - ( d->borderRectItem ? ( 2 * d->borderRectItem->pen().width() ) : 0 );
> qreal maxwidth = d->svgElementRect.width() - ( d->borderRectItem ? ( 2 * d->borderRectItem->pen().width() ) : 0 );
> @@ -418,8 +439,22 @@
> if( !d->textItem || !d->borderRectItem )
> return;
>
> + d->textItem->setFont( d->font );
> +
> qreal item_vert_center = ( d->borderRectItem->sceneBoundingRect().height() / 2 ) + d->borderRectItem->pos().y();
>
> + if( d->separator )
> + {
> + if( d->text.isEmpty() )
> + return;
> + qreal width = d->textItem->textWidth();
> + if( width > d->borderRectItem->sceneBoundingRect().width() )
> + d->textItem->setTextWidth( d->borderRectItem->sceneBoundingRect().width() );
> + qreal offset = ( d->borderRectItem->sceneBoundingRect().width() - width ) / 2;
> + d->textItem->setPos( offset, item_vert_center - ( d->textItem->sceneBoundingRect().height() / 2 ) );
> + return;
> + }
> +
> int rightside;
> if( !d->pd || d->pd->viewSize().width() == 0 )
> rightside = sceneBoundingRect().width();
> @@ -433,7 +468,6 @@
> : d->borderRectItem->sceneBoundingRect().width() - offsetPos - d->textItem->sceneBoundingRect().width()
> )
> , item_vert_center - ( d->textItem->sceneBoundingRect().height() / 2 ) );
> - d->textItem->setFont( d->font );
> }
>
> void PopupDropperItem::reposHoverFillRects()
> @@ -441,6 +475,13 @@
> if( !d->hoverIndicatorRectItem || !d->hoverIndicatorRectFillItem || !d->textItem || !d->borderRectItem )
> return;
>
> + if( d->separator )
> + {
> + d->hoverIndicatorRectItem->setRect( 0, 0, 0, 0 );
> + d->hoverIndicatorRectFillItem->setRect( 0, 0, 0, 0 );
> + return;
> + }
> +
> //qDebug() << "\n\nPUDItem boundingRect().width() = " << boundingRect().width();
> qreal startx, starty, endx, endy, item_center;
> int rightside;
> --- trunk/extragear/multimedia/amarok/src/context/popupdropper/libpud/PopupDropperItem.h #952841:952842
> @@ -86,6 +86,7 @@
>
> QString text() const;
> void setText( const QString &text );
> + void setHtmlText( const QString &text );
> QFont font() const;
> void setFont( const QFont &font );
> QColor baseTextColor() const;
>
--
Seb Ruiz
http://www.sebruiz.net/
http://amarok.kde.org/
More information about the Amarok-devel
mailing list