return QString( "%1 (%2)" ).arg( v ).arg( texts[v] );
}
+VLCQDial::VLCQDial( QWidget *parent ) : QDial( parent )
+{
+
+}
+
+void VLCQDial::paintEvent( QPaintEvent *event )
+{
+ QDial::paintEvent( event );
+ QPainter painter( this );
+ painter.setPen( QPen( palette().color( QPalette::WindowText ) ) );
+ float radius = 0.5 * 0.707106 * qMin( size().width(), size().height() );
+ painter.drawText( QRectF( rect().center().x() + radius,
+ rect().center().y() + radius,
+ size().width(),
+ size().height() ),
+ 0, QString::number( value() ), 0 );
+ painter.end();
+}
+
/***************************************************************************
* Hotkeys converters
***************************************************************************/
{ Qt::Key_Enter, '\r' }, // numeric pad
{ Qt::Key_Insert, KEY_INSERT },
{ Qt::Key_Delete, KEY_DELETE },
- // Qt::Key_Pause
- // Qt::Key_Print
+ { Qt::Key_Pause, KEY_PAUSE },
+ { Qt::Key_Print, KEY_PRINT },
// Qt::Key_SysReq
// Qt::Key_Clear
{ Qt::Key_Home, KEY_HOME },
// Qt::Key_LaunchMail
// Qt::Key_LaunchMedia
/* Qt::Key_Launch0 through Qt::Key_LaunchF */
- // Qt::Key_MediaLast
+ /* ... */
+ { Qt::Key_Reload, KEY_BROWSER_REFRESH },
};
static int keycmp( const void *a, const void *b )
return i_vlck;
}
-QString VLCKeyToString( unsigned val )
+QString VLCKeyToString( unsigned val, bool locale )
{
- char *base = vlc_keycode2str (val, true);
+ char *base = vlc_keycode2str (val, locale);
if (base == NULL)
return qtr( "Unset" );
return r;
}
-
/* Animated Icon implementation */
-
-AnimatedIcon::AnimatedIcon( QWidget *parent )
- : QLabel( parent ), mTimer( this ), mIdleFrame( NULL )
-{
- mCurrentFrame = mRemainingLoops = 0;
- connect( &mTimer, SIGNAL( timeout() ), this, SLOT( onTimerTick() ) );
-}
-
-AnimatedIcon::~AnimatedIcon()
-{
- // We don't need to destroy the timer, he's our child
- delete mIdleFrame;
- foreach( QPixmap *frame, mFrames )
- delete frame;
-}
-
-void AnimatedIcon::addFrame( const QPixmap &pxm, int index )
-{
- if( index == 0 )
- {
- // Replace idle frame
- delete mIdleFrame;
- mIdleFrame = new QPixmap( pxm );
- setPixmap( *mIdleFrame );
- return;
- }
- QPixmap *copy = new QPixmap( pxm );
- mFrames.insert( ( index < 0 || index > mFrames.count() ) ? mFrames.count() :
- index, copy );
- if( !pixmap() )
- setPixmap( *copy );
-}
-
-void AnimatedIcon::play( int loops, int interval )
+SpinningIcon::SpinningIcon( QWidget *parent ) : QLabel( parent )
{
- if( interval < 20 )
- {
- interval = 20;
- }
-
- if( !mIdleFrame && (mFrames.isEmpty() || loops != 0 ) )
- {
- return;
- }
-
- if( loops == 0 )
- {
- // Stop playback
- mCurrentFrame = mRemainingLoops = 0;
- mTimer.stop();
- setPixmap( mIdleFrame != NULL ? *mIdleFrame : *mFrames.last() );
- return;
- }
-
- if( loops <= -1 )
- loops = -1;
-
- mCurrentFrame = 1;
- mRemainingLoops = loops;
- mTimer.start( interval );
- setPixmap( *mFrames.first() );
-}
-
-// private slot
-void AnimatedIcon::onTimerTick()
-{
- //assert( !mFrames.isEmpty() );
- if( ++mCurrentFrame > mFrames.count() )
- {
- if( mRemainingLoops != -1 )
- {
- if( --mRemainingLoops == 0 )
- {
- mTimer.stop();
- setPixmap( mIdleFrame ? *mIdleFrame : *mFrames.last() );
- return;
- }
- }
- mCurrentFrame = 1;
- }
- //assert( mCurrentFrame >= 1 && mCurrentFrame <= mFrames.count() );
- setPixmap( *mFrames.at( mCurrentFrame - 1 ) );
-}
-
-
-/* SpinningIcon implementation */
-
-SpinningIcon::SpinningIcon( QWidget *parent, bool noIdleFrame )
- : AnimatedIcon( parent )
-{
- if( noIdleFrame )
- addFrame( QPixmap(), 0 );
- else
- addFrame( QPixmap( ":/util/wait0" ), 0 );
- addFrame( QPixmap( ":/util/wait1" ) );
- addFrame( QPixmap( ":/util/wait2" ) );
- addFrame( QPixmap( ":/util/wait3" ) );
- addFrame( QPixmap( ":/util/wait4" ) );
+ QList<QString> frames;
+ frames << ":/util/wait1";
+ frames << ":/util/wait2";
+ frames << ":/util/wait3";
+ frames << ":/util/wait4";
+ animator = new PixmapAnimator( this, frames );
+ CONNECT( animator, pixmapReady( const QPixmap & ), this, setPixmap( const QPixmap & ) );
+ CONNECT( animator, pixmapReady( const QPixmap & ), this, repaint() );
setScaledContents( true );
setFixedSize( 16, 16 );
+ animator->setCurrentTime( 0 );
}
QToolButtonExt::QToolButtonExt(QWidget *parent, int ms )
else if( shortClick )
emit shortClicked();
}
+
+YesNoCheckBox::YesNoCheckBox( QWidget *parent ) : QCheckBox( parent )
+{
+ setEnabled( false );
+ setStyleSheet("\
+ QCheckBox::indicator:unchecked:hover,\
+ QCheckBox::indicator:unchecked {\
+ image: url(:/menu/quit);\
+ }\
+ QCheckBox::indicator:checked:hover,\
+ QCheckBox::indicator:checked {\
+ image: url(:/valid);\
+ }\
+ ");
+}