[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: extragear/multimedia/amarok/src/widgets
From: Nikolaj Hald Nielsen <nhnFreespirit () gmail ! com>
Date: 2009-06-30 7:32:08
Message-ID: 1246347128.880431.8966.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 989376 by nhnielsen:
Whoops! revert 989373 as I commited some files that should not have been comitted yet
M +13 -12 PixmapViewer.cpp
M +3 -3 PixmapViewer.h
M +8 -111 TokenWithLayout.cpp
M +1 -23 TokenWithLayout.h
--- trunk/extragear/multimedia/amarok/src/widgets/PixmapViewer.cpp #989375:989376
@@ -33,21 +33,22 @@
PixmapViewer::PixmapViewer( QWidget *widget, const QPixmap pix )
: QWidget( widget )
{
+
m_pixmap = new QPixmap( pix );
m_zoomFactor = 1.0; // initial zoom
if ( KApplication::desktop()->width() < m_pixmap->width() )
{
- m_zoomFactor = ( ( float ) KApplication::desktop()->width() /
+ m_zoomFactor = (( float ) KApplication::desktop()->width() /
( float ) m_pixmap->width() ) - 0.5;
}
- setMinimumSize( m_pixmap->width() * m_zoomFactor, m_pixmap->height() * \
m_zoomFactor ); + setMinimumSize( m_pixmap->width()*m_zoomFactor, \
m_pixmap->height()*m_zoomFactor );
// move window to the center of the screen
// (multiple screens: same screen as parent widget)
QWidget *p = dynamic_cast<QWidget*>( parent() );
- p->move( ( KApplication::desktop()->availableGeometry( p ).width()
+ p->move(( KApplication::desktop()->availableGeometry( p ).width()
- ( m_pixmap->width()*m_zoomFactor ) ) / 2,
( KApplication::desktop()->availableGeometry( p ).height()
- ( m_pixmap->height()*m_zoomFactor ) ) / 2 );
@@ -55,8 +56,7 @@
}
-void
-PixmapViewer::setZoomFactor( float f )
+void PixmapViewer::setZoomFactor( float f )
{
int w, h;
@@ -77,8 +77,7 @@
repaint();
}
-void
-PixmapViewer::paintEvent( QPaintEvent *event )
+void PixmapViewer::paintEvent( QPaintEvent *event )
{
int xoffset, yoffset;
bool drawBorder = false;
@@ -90,7 +89,9 @@
}
else
{
+
xoffset = 0;
+
}
if ( height() > m_pixmap->height()*m_zoomFactor )
@@ -100,11 +101,12 @@
}
else
{
+
yoffset = 0;
}
QWidget *parentWidget = dynamic_cast<QWidget*>( parent() );
- parentWidget->move( ( KApplication::desktop()->availableGeometry( parentWidget \
).width() + parentWidget->move(( KApplication::desktop()->availableGeometry( \
parentWidget ).width()
- ( m_pixmap->width()*m_zoomFactor ) ) / 2,
( KApplication::desktop()->availableGeometry( parentWidget \
).height()
- ( m_pixmap->height()*m_zoomFactor ) ) / 2 );
@@ -119,17 +121,16 @@
{
p.setPen( Qt::black );
p.drawRect( xoffset - 1, yoffset - 1, m_pixmap->width()*m_zoomFactor + 1,
- m_pixmap->height() * m_zoomFactor + 1 );
+ m_pixmap->height()*m_zoomFactor + 1 );
}
}
-void
-PixmapViewer::wheelEvent( QWheelEvent *event )
+void PixmapViewer::wheelEvent( QWheelEvent *event )
{
float f;
f = m_zoomFactor + 0.001 * event->delta();
- if( f < 32.0 / m_pixmap->width() )
+ if ( f < 32.0 / m_pixmap->width() )
f = 32.0 / m_pixmap->width();
setZoomFactor( f );
--- trunk/extragear/multimedia/amarok/src/widgets/PixmapViewer.h #989375:989376
@@ -35,14 +35,14 @@
PixmapViewer( QWidget *widget, const QPixmap pixmap );
public slots:
- void setZoomFactor( float f );
+ void setZoomFactor( float );
signals:
void zoomFactorChanged( float );
protected:
- void paintEvent( QPaintEvent *event );
- void wheelEvent( QWheelEvent *event );
+ void paintEvent( QPaintEvent* );
+ void wheelEvent( QWheelEvent* );
private:
QPixmap *m_pixmap;
--- trunk/extragear/multimedia/amarok/src/widgets/TokenWithLayout.cpp #989375:989376
@@ -21,123 +21,43 @@
#include "TokenDropTarget.h"
#include <KAction>
-#include <KColorScheme>
#include <KHBox>
-#include <KIcon>
#include <KLocale>
#include <QActionGroup>
#include <QContextMenuEvent>
#include <QLayout>
-#include <QLCDNumber>
#include <QMenu>
-#include <QPainter>
-#include <QPushButton>
#include <QSlider>
-#include <QTimerEvent>
+#include <QLCDNumber>
-Wrench::Wrench( QWidget *parent ) : QLabel( parent )
-{
- setCursor( Qt::ArrowCursor );
- setPixmap( KIcon( "configure" ).pixmap( 64 ) );
- setScaledContents( true );
- setMargin( 4 );
-}
-
-void Wrench::enterEvent( QEvent * )
-{
- setMargin( 1 );
- update();
-}
-
-void Wrench::leaveEvent( QEvent * )
-{
- setMargin( 4 );
- update();
-}
-
-void Wrench::mouseReleaseEvent( QMouseEvent * )
-{
- emit clicked();
-}
-
-void Wrench::paintEvent( QPaintEvent *pe )
-{
- QPainter p( this );
- QColor c = palette().color( backgroundRole() );
-// if ( underMouse() )
-// c = KColorScheme( QPalette::Active ).decoration( KColorScheme::HoverColor \
).color();
-// p.setPen( QPen ( c, 2 ) );
- p.setPen( Qt::NoPen );
- c = palette().color( backgroundRole() );
- c.setAlpha( 212 );
- p.setBrush( c );
- p.setRenderHint( QPainter::Antialiasing );
- p.drawEllipse( rect() );
- p.end();
- QLabel::paintEvent( pe );
-}
-
-
const QString ActionBoldName = QLatin1String( "ActionBold" );
const QString ActionItalicName = QLatin1String( "ActionItalic" );
const QString ActionAlignLeftName = QLatin1String( "ActionAlignLeft" );
const QString ActionAlignCenterName = QLatin1String( "ActionAlignCenter" );
const QString ActionAlignRightName = QLatin1String( "ActionAlignRight" );
-Token * TokenWithLayoutFactory::createToken( const QString &text, const QString \
&iconName, int value, QWidget *parent ) +Token * \
TokenWithLayoutFactory::createToken(const QString &text, const QString &iconName, int \
value, QWidget *parent) {
return new TokenWithLayout( text, iconName, value, parent );
}
TokenWithLayout::TokenWithLayout( const QString &text, const QString &iconName, int \
value, QWidget *parent ) : Token( text, iconName, value, parent )
- , m_width( 0.0 ), m_wrenchTimer( 0 )
+ , m_width( 0.0 )
{
m_widthForced = m_width > 0.0;
m_alignment = Qt::AlignCenter;
m_bold = false;
m_italic = false;
- m_wrench = new Wrench( this );
- m_wrench->installEventFilter( this );
- m_wrench->hide();
- connect ( m_wrench, SIGNAL( clicked() ), this, SLOT( showConfig() ) );
setFocusPolicy( Qt::ClickFocus );
}
TokenWithLayout::~TokenWithLayout()
{
- delete m_wrench;
}
-void TokenWithLayout::enterEvent( QEvent *e )
-{
- QWidget *win = window();
- const int sz = 2*height();
- QPoint pt = mapTo( win, rect().topLeft() );
-
- m_wrench->setParent( win );
- m_wrench->setFixedSize( sz, sz );
- m_wrench->move( pt - QPoint( m_wrench->width()/3, m_wrench->height()/3 ) );
- m_wrench->setCursor( Qt::PointingHandCursor );
- m_wrench->raise();
- m_wrench->show();
-
- Token::enterEvent( e );
-}
-
-bool TokenWithLayout::eventFilter( QObject *o, QEvent *e )
-{
- if ( e->type() == QEvent::Leave && o == m_wrench )
- {
- if ( m_wrenchTimer )
- killTimer( m_wrenchTimer );
- m_wrenchTimer = startTimer( 40 );
- }
- return false;
-}
-
void TokenWithLayout::fillMenu( QMenu * menu )
{
DEBUG_BLOCK
@@ -204,9 +124,9 @@
if ( row > -1 )
{
QList<Token*> tokens = editWidget->drags( row );
- foreach ( Token *t, tokens )
+ foreach (Token *t, tokens)
{
- if ( t == this )
+ if (t == this)
continue;
if ( TokenWithLayout *twl = qobject_cast<TokenWithLayout*>( t ) \
) spareWidth -= twl->width() * 100.0;
@@ -234,14 +154,6 @@
}
-void TokenWithLayout::leaveEvent( QEvent *e )
-{
- Token::leaveEvent( e );
- if ( m_wrenchTimer )
- killTimer( m_wrenchTimer );
- m_wrenchTimer = startTimer( 40 );
-}
-
void TokenWithLayout::menuExecuted( const QAction* action )
{
if( action->objectName() == ActionAlignLeftName )
@@ -256,7 +168,7 @@
setItalic( action->isChecked() );
}
-void TokenWithLayout::showConfig()
+void TokenWithLayout::contextMenuEvent( QContextMenuEvent * event )
{
QMenu* menu = new QMenu();
@@ -264,28 +176,13 @@
fillMenu( menu );
- QAction* action = menu->exec( QCursor::pos() - QPoint( menu->width()/2, -2 ) );
+ QAction* action = menu->exec( mapToGlobal( event->pos() ) );
if ( action )
menuExecuted( action );
delete menu;
}
-void TokenWithLayout::timerEvent( QTimerEvent *te )
-{
- if ( te->timerId() == m_wrenchTimer )
- {
- killTimer( m_wrenchTimer );
- m_wrenchTimer = 0;
- QRegion rgn;
- rgn |= QRect( mapToGlobal( QPoint( 0, 0 ) ), QWidget::size() );
- rgn |= QRect( m_wrench->mapToGlobal( QPoint( 0, 0 ) ), m_wrench->size() );
- if ( !rgn.contains( QCursor::pos() ) )
- m_wrench->hide();
- }
- Token::timerEvent( te );
-}
-
Qt::Alignment TokenWithLayout::alignment()
{
return m_alignment;
@@ -357,7 +254,7 @@
void TokenWithLayout::setWidth( int size )
{
m_width = qMax( qMin( 1.0, size/100.0 ), 0.0 ) ;
- if ( m_width > 0.0 )
+ if ( (m_width) > 0.0 )
m_widthForced = true;
emit changed();
--- trunk/extragear/multimedia/amarok/src/widgets/TokenWithLayout.h #989375:989376
@@ -21,20 +21,6 @@
class QMenu;
-class Wrench : public QLabel
-{
- Q_OBJECT
-public:
- Wrench( QWidget *parent );
-protected:
- void enterEvent(QEvent *);
- void leaveEvent(QEvent *);
- void mouseReleaseEvent( QMouseEvent *e );
- void paintEvent( QPaintEvent *pe );
-signals:
- void clicked();
-};
-
class TokenWithLayoutFactory : public TokenFactory
{
public:
@@ -76,16 +62,10 @@
void setWidthForced( bool );
protected:
- virtual void enterEvent(QEvent *);
- virtual bool eventFilter( QObject*, QEvent* );
virtual void fillMenu( QMenu * menu );
- virtual void leaveEvent(QEvent *);
virtual void menuExecuted( const QAction* action );
- virtual void timerEvent( QTimerEvent* );
+ virtual void contextMenuEvent( QContextMenuEvent * event );
-private slots:
- void showConfig();
-
private:
Qt::Alignment m_alignment;
@@ -94,8 +74,6 @@
bool m_widthForced;
qreal m_width;
QString m_prefix, m_suffix;
- Wrench *m_wrench;
- int m_wrenchTimer;
};
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic