mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-15 10:33:59 +02:00
Do some scaling in AudioControls and SeekSlider
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
*
|
||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||
* Copyright 2010-2011, Jeff Mitchell <jeff@tomahawk-player.org>
|
||||
* Copyright 2013, Teo Mrnjavac <teo@kde.org>
|
||||
*
|
||||
* Tomahawk is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -28,26 +29,34 @@
|
||||
|
||||
SeekSlider::SeekSlider( QWidget* parent )
|
||||
: QSlider( parent )
|
||||
, TomahawkUtils::DpiScaler( this )
|
||||
, m_timeLine( 0 )
|
||||
{
|
||||
setFixedHeight( 20 );
|
||||
setStyleSheet( "QSlider::groove:horizontal {"
|
||||
"margin: 5px; border-width: 3px;"
|
||||
"border-image: url(" RESPATH "images/seek-slider-bkg.png) 3 3 3 3 stretch stretch;"
|
||||
setFixedHeight( scaledY( 20 ) );
|
||||
setStyleSheet( QString(
|
||||
"QSlider::groove:horizontal {"
|
||||
"margin: %1px; border-width: %2px;"
|
||||
"border-image: url(" RESPATH "images/seek-slider-bkg.png) %2 %2 %2 %2 stretch stretch;"
|
||||
"}"
|
||||
|
||||
"QSlider::sub-page:horizontal {"
|
||||
"margin: 5px; border-width: 3px;"
|
||||
"border-image: url(" RESPATH "images/seek-slider-level.png) 3 3 3 3 stretch stretch;"
|
||||
"}"
|
||||
|
||||
"margin: %1px; border-width: %2px;"
|
||||
"border-image: url(" RESPATH "images/seek-slider-level.png) %2 %2 %2 %2 stretch stretch;"
|
||||
"}" )
|
||||
.arg( 5 /*margin*/)
|
||||
.arg( 3 /*border*/) +
|
||||
QString(
|
||||
"QSlider::handle:horizontal {"
|
||||
"margin-bottom: -7px; margin-top: -7px;"
|
||||
"margin-left: -4px; margin-right: -4px;"
|
||||
"height: 17px; width: 16px;"
|
||||
"margin-bottom: -%1px; margin-top: -%1px;"
|
||||
"margin-left: -%2px; margin-right: -%2px;"
|
||||
"height: %3px; width: %4px;"
|
||||
"background-image: url(" RESPATH "images/seek-and-volume-knob-rest.png);"
|
||||
"background-repeat: no-repeat;"
|
||||
"}" );
|
||||
"}" )
|
||||
.arg( /*margin top&bottom*/ 7 )
|
||||
.arg( /*margin left&right*/ 4 )
|
||||
.arg( /*height*/ 17 )
|
||||
.arg( /*width*/ 16 ) );
|
||||
}
|
||||
|
||||
|
||||
|
@@ -21,12 +21,13 @@
|
||||
#define SEEKSLIDER_H
|
||||
|
||||
#include "DllMacro.h"
|
||||
#include "utils/DpiScaler.h"
|
||||
|
||||
#include <QSlider>
|
||||
|
||||
class QTimeLine;
|
||||
|
||||
class DLLEXPORT SeekSlider : public QSlider
|
||||
class DLLEXPORT SeekSlider : public QSlider, private TomahawkUtils::DpiScaler
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
@@ -48,6 +48,7 @@ using namespace Tomahawk;
|
||||
|
||||
AudioControls::AudioControls( QWidget* parent )
|
||||
: QWidget( parent )
|
||||
, TomahawkUtils::DpiScaler( this )
|
||||
, ui( new Ui::AudioControls )
|
||||
, m_repeatMode( PlaylistModes::NoRepeat )
|
||||
, m_shuffled( false )
|
||||
@@ -78,36 +79,38 @@ AudioControls::AudioControls( QWidget* parent )
|
||||
ui->timeLabel->setFont( font );
|
||||
ui->timeLeftLabel->setFont( font );
|
||||
|
||||
ui->ownerButton->setPixmap( TomahawkUtils::defaultPixmap( TomahawkUtils::DefaultResolver, TomahawkUtils::Original, QSize( 34, 34 ) ) );
|
||||
ui->prevButton->setPixmap( TomahawkUtils::defaultPixmap( TomahawkUtils::PrevButton, TomahawkUtils::Original, QSize( 35, 35 ) ) );
|
||||
ui->prevButton->setPixmap( TomahawkUtils::defaultPixmap( TomahawkUtils::PrevButtonPressed, TomahawkUtils::Original, QSize( 35, 35 ) ), QIcon::Off, QIcon::Active );
|
||||
ui->playPauseButton->setPixmap( TomahawkUtils::defaultPixmap( TomahawkUtils::PlayButton, TomahawkUtils::Original, QSize( 48, 48 ) ) );
|
||||
ui->playPauseButton->setPixmap( TomahawkUtils::defaultPixmap( TomahawkUtils::PlayButtonPressed, TomahawkUtils::Original, QSize( 48, 48 ) ), QIcon::Off, QIcon::Active );
|
||||
ui->pauseButton->setPixmap( TomahawkUtils::defaultPixmap( TomahawkUtils::PauseButton, TomahawkUtils::Original, QSize( 48, 48 ) ) );
|
||||
ui->pauseButton->setPixmap( TomahawkUtils::defaultPixmap( TomahawkUtils::PauseButtonPressed, TomahawkUtils::Original, QSize( 48, 48 ) ), QIcon::Off, QIcon::Active );
|
||||
ui->nextButton->setPixmap( TomahawkUtils::defaultPixmap( TomahawkUtils::NextButton, TomahawkUtils::Original, QSize( 35, 35 ) ) );
|
||||
ui->nextButton->setPixmap( TomahawkUtils::defaultPixmap( TomahawkUtils::NextButtonPressed, TomahawkUtils::Original, QSize( 35, 35 ) ), QIcon::Off, QIcon::Active );
|
||||
ui->shuffleButton->setPixmap( TomahawkUtils::defaultPixmap( TomahawkUtils::ShuffleOff, TomahawkUtils::Original, QSize( 34, 21 ) ) );
|
||||
ui->shuffleButton->setPixmap( TomahawkUtils::defaultPixmap( TomahawkUtils::ShuffleOffPressed, TomahawkUtils::Original, QSize( 34, 21 ) ), QIcon::Off, QIcon::Active );
|
||||
ui->repeatButton->setPixmap( TomahawkUtils::defaultPixmap( TomahawkUtils::RepeatOff, TomahawkUtils::Original, QSize( 34, 21 ) ) );
|
||||
ui->repeatButton->setPixmap( TomahawkUtils::defaultPixmap( TomahawkUtils::RepeatOffPressed, TomahawkUtils::Original, QSize( 34, 21 ) ), QIcon::Off, QIcon::Active );
|
||||
ui->volumeLowButton->setPixmap( TomahawkUtils::defaultPixmap( TomahawkUtils::VolumeMuted, TomahawkUtils::Original, QSize( 18, 18 ) ) );
|
||||
ui->volumeHighButton->setPixmap( TomahawkUtils::defaultPixmap( TomahawkUtils::VolumeFull, TomahawkUtils::Original, QSize( 22, 18 ) ) );
|
||||
ui->socialButton->setPixmap( TomahawkUtils::defaultPixmap( TomahawkUtils::Share, TomahawkUtils::Original, QSize( 20, 20 ) ) );
|
||||
ui->loveButton->setPixmap( TomahawkUtils::defaultPixmap( TomahawkUtils::NotLoved, TomahawkUtils::Original, QSize( 20, 20 ) ) );
|
||||
ui->ownerButton->setPixmap( TomahawkUtils::defaultPixmap( TomahawkUtils::DefaultResolver, TomahawkUtils::Original, scaled( 34, 34 ) ) );
|
||||
ui->prevButton->setPixmap( TomahawkUtils::defaultPixmap( TomahawkUtils::PrevButton, TomahawkUtils::Original, scaled( 35, 35 ) ) );
|
||||
ui->prevButton->setPixmap( TomahawkUtils::defaultPixmap( TomahawkUtils::PrevButtonPressed, TomahawkUtils::Original, scaled( 35, 35 ) ), QIcon::Off, QIcon::Active );
|
||||
ui->playPauseButton->setPixmap( TomahawkUtils::defaultPixmap( TomahawkUtils::PlayButton, TomahawkUtils::Original, scaled( 48, 48 ) ) );
|
||||
ui->playPauseButton->setPixmap( TomahawkUtils::defaultPixmap( TomahawkUtils::PlayButtonPressed, TomahawkUtils::Original, scaled( 48, 48 ) ), QIcon::Off, QIcon::Active );
|
||||
ui->pauseButton->setPixmap( TomahawkUtils::defaultPixmap( TomahawkUtils::PauseButton, TomahawkUtils::Original, scaled( 48, 48 ) ) );
|
||||
ui->pauseButton->setPixmap( TomahawkUtils::defaultPixmap( TomahawkUtils::PauseButtonPressed, TomahawkUtils::Original, scaled( 48, 48 ) ), QIcon::Off, QIcon::Active );
|
||||
ui->nextButton->setPixmap( TomahawkUtils::defaultPixmap( TomahawkUtils::NextButton, TomahawkUtils::Original, scaled( 35, 35 ) ) );
|
||||
ui->nextButton->setPixmap( TomahawkUtils::defaultPixmap( TomahawkUtils::NextButtonPressed, TomahawkUtils::Original, scaled( 35, 35 ) ), QIcon::Off, QIcon::Active );
|
||||
ui->shuffleButton->setPixmap( TomahawkUtils::defaultPixmap( TomahawkUtils::ShuffleOff, TomahawkUtils::Original, scaled( 34, 21 ) ) );
|
||||
ui->shuffleButton->setPixmap( TomahawkUtils::defaultPixmap( TomahawkUtils::ShuffleOffPressed, TomahawkUtils::Original, scaled( 34, 21 ) ), QIcon::Off, QIcon::Active );
|
||||
ui->repeatButton->setPixmap( TomahawkUtils::defaultPixmap( TomahawkUtils::RepeatOff, TomahawkUtils::Original, scaled( 34, 21 ) ) );
|
||||
ui->repeatButton->setPixmap( TomahawkUtils::defaultPixmap( TomahawkUtils::RepeatOffPressed, TomahawkUtils::Original, scaled( 34, 21 ) ), QIcon::Off, QIcon::Active );
|
||||
ui->volumeLowButton->setPixmap( TomahawkUtils::defaultPixmap( TomahawkUtils::VolumeMuted, TomahawkUtils::Original, scaled( 18, 18 ) ) );
|
||||
ui->volumeHighButton->setPixmap( TomahawkUtils::defaultPixmap( TomahawkUtils::VolumeFull, TomahawkUtils::Original, scaled( 22, 18 ) ) );
|
||||
ui->socialButton->setPixmap( TomahawkUtils::defaultPixmap( TomahawkUtils::Share, TomahawkUtils::Original, scaled( 20, 20 ) ) );
|
||||
ui->loveButton->setPixmap( TomahawkUtils::defaultPixmap( TomahawkUtils::NotLoved, TomahawkUtils::Original, scaled( 20, 20 ) ) );
|
||||
ui->loveButton->setCheckable( true );
|
||||
|
||||
ui->socialButton->setFixedSize( QSize( 20, 20 ) );
|
||||
ui->loveButton->setFixedSize( QSize( 20, 20 ) );
|
||||
ui->ownerButton->setFixedSize( QSize( 34, 34 ) );
|
||||
ui->socialButton->setFixedSize( scaled( 20, 20 ) );
|
||||
ui->loveButton->setFixedSize( scaled( 20, 20 ) );
|
||||
ui->ownerButton->setFixedSize( scaled( 34, 34 ) );
|
||||
|
||||
ui->metaDataArea->setStyleSheet( "QWidget#metaDataArea {\nborder-width: 4px;\nborder-image: url(" RESPATH "images/now-playing-panel.png) 4 4 4 4 stretch stretch; }" );
|
||||
ui->metaDataArea->setStyleSheet( QString( "QWidget#metaDataArea {\nborder-width: %1px;\nborder-image: url(" RESPATH "images/now-playing-panel.png) %1 %1 %1 %1 stretch stretch; }" ).arg( scaledX( 4 ) ) );
|
||||
|
||||
ui->seekSlider->setEnabled( true );
|
||||
ui->seekSlider->setTimeLine( &m_sliderTimeLine );
|
||||
ui->volumeSlider->setRange( 0, 100 );
|
||||
ui->volumeSlider->setValue( AudioEngine::instance()->volume() );
|
||||
|
||||
ui->horizontalLayout_3->setContentsMargins( scaledX( 10 ), 0, scaledX( 8 ), 0 );
|
||||
|
||||
m_phononTickCheckTimer.setSingleShot( true );
|
||||
|
||||
connect( &m_phononTickCheckTimer, SIGNAL( timeout() ), SLOT( phononTickCheckTimeout() ) );
|
||||
@@ -157,6 +160,16 @@ AudioControls::AudioControls( QWidget* parent )
|
||||
ui->pauseButton->setContentsMargins( 0, 0, 0, 0 );
|
||||
ui->stackedLayout->setSizeConstraint( QLayout::SetFixedSize );
|
||||
|
||||
// setFixedSize corrections for stuff in .ui :(
|
||||
ui->buttonArea->setFixedSize( scaled( 170, 66 ) );
|
||||
ui->coverImage->setFixedSize( scaled( 60, 60 ) );
|
||||
ui->metaDataArea->setMaximumHeight( scaledY( 74 ) );
|
||||
ui->widget_4->setFixedSize( scaled( 170, 66 ) );
|
||||
ui->volumeSlider->setFixedHeight( 20 );
|
||||
ui->verticalLayout->setContentsMargins( scaledX( 2 ), scaledY( 6 ),
|
||||
0, scaledY( 6 ) );
|
||||
setFixedHeight( scaledY( 80 ) );
|
||||
|
||||
connect( InfoSystem::InfoSystem::instance(), SIGNAL( updatedSupportedPushTypes( Tomahawk::InfoSystem::InfoTypeSet ) ),
|
||||
this, SLOT( onInfoSystemPushTypesUpdated( Tomahawk::InfoSystem::InfoTypeSet ) ) );
|
||||
onInfoSystemPushTypesUpdated( InfoSystem::InfoSystem::instance()->supportedPushTypes() );
|
||||
@@ -386,12 +399,12 @@ AudioControls::setSocialActions()
|
||||
{
|
||||
if ( m_currentTrack->track()->loved() )
|
||||
{
|
||||
ui->loveButton->setPixmap( TomahawkUtils::defaultPixmap( TomahawkUtils::Loved, TomahawkUtils::Original, QSize( 20, 20 ) ) );
|
||||
ui->loveButton->setPixmap( TomahawkUtils::defaultPixmap( TomahawkUtils::Loved, TomahawkUtils::Original, scaled( 20, 20 ) ) );
|
||||
ui->loveButton->setChecked( true );
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->loveButton->setPixmap( TomahawkUtils::defaultPixmap( TomahawkUtils::NotLoved, TomahawkUtils::Original, QSize( 20, 20 ) ) );
|
||||
ui->loveButton->setPixmap( TomahawkUtils::defaultPixmap( TomahawkUtils::NotLoved, TomahawkUtils::Original, scaled( 20, 20 ) ) );
|
||||
ui->loveButton->setChecked( false );
|
||||
}
|
||||
}
|
||||
@@ -561,24 +574,24 @@ AudioControls::onRepeatModeChanged( PlaylistModes::RepeatMode mode )
|
||||
case PlaylistModes::NoRepeat:
|
||||
{
|
||||
// switch to RepeatOne
|
||||
ui->repeatButton->setPixmap( TomahawkUtils::defaultPixmap( TomahawkUtils::RepeatOff, TomahawkUtils::Original, QSize( 34, 21 ) ) );
|
||||
ui->repeatButton->setPixmap( TomahawkUtils::defaultPixmap( TomahawkUtils::RepeatOffPressed, TomahawkUtils::Original, QSize( 34, 21 ) ), QIcon::Off, QIcon::Active );
|
||||
ui->repeatButton->setPixmap( TomahawkUtils::defaultPixmap( TomahawkUtils::RepeatOff, TomahawkUtils::Original, scaled( 34, 21 ) ) );
|
||||
ui->repeatButton->setPixmap( TomahawkUtils::defaultPixmap( TomahawkUtils::RepeatOffPressed, TomahawkUtils::Original, scaled( 34, 21 ) ), QIcon::Off, QIcon::Active );
|
||||
}
|
||||
break;
|
||||
|
||||
case PlaylistModes::RepeatOne:
|
||||
{
|
||||
// switch to RepeatAll
|
||||
ui->repeatButton->setPixmap( TomahawkUtils::defaultPixmap( TomahawkUtils::RepeatOne, TomahawkUtils::Original, QSize( 34, 21 ) ) );
|
||||
ui->repeatButton->setPixmap( TomahawkUtils::defaultPixmap( TomahawkUtils::RepeatOnePressed, TomahawkUtils::Original, QSize( 34, 21 ) ), QIcon::Off, QIcon::Active );
|
||||
ui->repeatButton->setPixmap( TomahawkUtils::defaultPixmap( TomahawkUtils::RepeatOne, TomahawkUtils::Original, scaled( 34, 21 ) ) );
|
||||
ui->repeatButton->setPixmap( TomahawkUtils::defaultPixmap( TomahawkUtils::RepeatOnePressed, TomahawkUtils::Original, scaled( 34, 21 ) ), QIcon::Off, QIcon::Active );
|
||||
}
|
||||
break;
|
||||
|
||||
case PlaylistModes::RepeatAll:
|
||||
{
|
||||
// switch to NoRepeat
|
||||
ui->repeatButton->setPixmap( TomahawkUtils::defaultPixmap( TomahawkUtils::RepeatAll, TomahawkUtils::Original, QSize( 34, 21 ) ) );
|
||||
ui->repeatButton->setPixmap( TomahawkUtils::defaultPixmap( TomahawkUtils::RepeatAllPressed, TomahawkUtils::Original, QSize( 34, 21 ) ), QIcon::Off, QIcon::Active );
|
||||
ui->repeatButton->setPixmap( TomahawkUtils::defaultPixmap( TomahawkUtils::RepeatAll, TomahawkUtils::Original, scaled( 34, 21 ) ) );
|
||||
ui->repeatButton->setPixmap( TomahawkUtils::defaultPixmap( TomahawkUtils::RepeatAllPressed, TomahawkUtils::Original, scaled( 34, 21 ) ), QIcon::Off, QIcon::Active );
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -629,15 +642,15 @@ AudioControls::onShuffleModeChanged( bool enabled )
|
||||
|
||||
if ( m_shuffled )
|
||||
{
|
||||
ui->shuffleButton->setPixmap( TomahawkUtils::defaultPixmap( TomahawkUtils::ShuffleOn, TomahawkUtils::Original, QSize( 34, 21 ) ) );
|
||||
ui->shuffleButton->setPixmap( TomahawkUtils::defaultPixmap( TomahawkUtils::ShuffleOnPressed, TomahawkUtils::Original, QSize( 34, 21 ) ), QIcon::Off, QIcon::Active );
|
||||
ui->shuffleButton->setPixmap( TomahawkUtils::defaultPixmap( TomahawkUtils::ShuffleOn, TomahawkUtils::Original, scaled( 34, 21 ) ) );
|
||||
ui->shuffleButton->setPixmap( TomahawkUtils::defaultPixmap( TomahawkUtils::ShuffleOnPressed, TomahawkUtils::Original, scaled( 34, 21 ) ), QIcon::Off, QIcon::Active );
|
||||
|
||||
ui->repeatButton->setEnabled( false );
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->shuffleButton->setPixmap( TomahawkUtils::defaultPixmap( TomahawkUtils::ShuffleOff, TomahawkUtils::Original, QSize( 34, 21 ) ) );
|
||||
ui->shuffleButton->setPixmap( TomahawkUtils::defaultPixmap( TomahawkUtils::ShuffleOffPressed, TomahawkUtils::Original, QSize( 34, 21 ) ), QIcon::Off, QIcon::Active );
|
||||
ui->shuffleButton->setPixmap( TomahawkUtils::defaultPixmap( TomahawkUtils::ShuffleOff, TomahawkUtils::Original, scaled( 34, 21 ) ) );
|
||||
ui->shuffleButton->setPixmap( TomahawkUtils::defaultPixmap( TomahawkUtils::ShuffleOffPressed, TomahawkUtils::Original, scaled( 34, 21 ) ), QIcon::Off, QIcon::Active );
|
||||
|
||||
ui->repeatButton->setEnabled( true );
|
||||
}
|
||||
@@ -727,7 +740,7 @@ AudioControls::onSocialButtonClicked()
|
||||
m_socialWidget = new SocialWidget( m_parent );
|
||||
QPoint socialWidgetPos = ui->socialButton->pos();
|
||||
socialWidgetPos.rx() += ui->socialButton->width() / 2;
|
||||
socialWidgetPos.ry() += 6;
|
||||
socialWidgetPos.ry() += scaled( 0, 6 ).height();
|
||||
|
||||
m_socialWidget.data()->setPosition( ui->metaDataArea->mapToGlobal( socialWidgetPos ) );
|
||||
m_socialWidget.data()->setQuery( m_currentTrack->toQuery() );
|
||||
@@ -740,13 +753,13 @@ AudioControls::onLoveButtonClicked( bool checked )
|
||||
{
|
||||
if ( checked )
|
||||
{
|
||||
ui->loveButton->setPixmap( TomahawkUtils::defaultPixmap( TomahawkUtils::Loved, TomahawkUtils::Original, QSize( 20, 20 ) ) );
|
||||
ui->loveButton->setPixmap( TomahawkUtils::defaultPixmap( TomahawkUtils::Loved, TomahawkUtils::Original, scaled( 20, 20 ) ) );
|
||||
|
||||
m_currentTrack->track()->setLoved( true );
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->loveButton->setPixmap( TomahawkUtils::defaultPixmap( TomahawkUtils::NotLoved, TomahawkUtils::Original, QSize( 20, 20 ) ) );
|
||||
ui->loveButton->setPixmap( TomahawkUtils::defaultPixmap( TomahawkUtils::NotLoved, TomahawkUtils::Original, scaled( 20, 20 ) ) );
|
||||
|
||||
m_currentTrack->track()->setLoved( false );
|
||||
}
|
||||
|
@@ -2,6 +2,7 @@
|
||||
*
|
||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||
* Copyright 2010-2011, Jeff Mitchell <jeff@tomahawk-player.org>
|
||||
* Copyright 2013, Teo Mrnjavac <teo@kde.org>
|
||||
*
|
||||
* Tomahawk is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -23,6 +24,7 @@
|
||||
#include "Result.h"
|
||||
#include "PlaylistInterface.h"
|
||||
#include "Query.h"
|
||||
#include "utils/DpiScaler.h"
|
||||
|
||||
#include <QWidget>
|
||||
#include <QTimer>
|
||||
@@ -38,7 +40,7 @@ namespace Ui
|
||||
class AudioControls;
|
||||
}
|
||||
|
||||
class AudioControls : public QWidget
|
||||
class AudioControls : public QWidget, private TomahawkUtils::DpiScaler
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
Reference in New Issue
Block a user