1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-03-25 02:09:48 +01:00

* Added ColumnViewPreviewWidget.

This commit is contained in:
Christian Muehlhaeuser 2013-06-12 06:16:05 +02:00
parent 7c1ac3f75d
commit 4cc3b850ff
3 changed files with 361 additions and 0 deletions

View File

@ -0,0 +1,108 @@
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
*
* Copyright 2013, Christian Muehlhaeuser <muesli@tomahawk-player.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
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Tomahawk is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
*/
#include "ColumnViewPreviewWidget.h"
#include "ui_ColumnViewPreviewWidget.h"
#include <QVBoxLayout>
#include <boost/concept_check.hpp>
#include "ColumnView.h"
#include "utils/Logger.h"
#include "Source.h"
#include "utils/TomahawkUtilsGui.h"
using namespace Tomahawk;
ColumnViewPreviewWidget::ColumnViewPreviewWidget( ColumnView* parent )
: QWidget( parent )
, ui( new Ui::ColumnViewPreviewWidget )
{
setVisible( false );
ui->setupUi( this );
ui->cover->setPixmap( TomahawkUtils::defaultPixmap( TomahawkUtils::DefaultTrackImage, TomahawkUtils::Grid, ui->cover->size() ) );
ui->cover->setShowText( false );
ui->artistLabel->setContentsMargins( 6, 2, 6, 2 );
ui->artistLabel->setElideMode( Qt::ElideMiddle );
ui->artistLabel->setType( QueryLabel::Artist );
connect( ui->artistLabel, SIGNAL( clickedArtist() ), SLOT( onArtistClicked() ) );
}
ColumnViewPreviewWidget::~ColumnViewPreviewWidget()
{
tDebug( LOGVERBOSE ) << Q_FUNC_INFO;
}
void
ColumnViewPreviewWidget::changeEvent( QEvent* e )
{
QWidget::changeEvent( e );
switch ( e->type() )
{
case QEvent::LanguageChange:
ui->retranslateUi( this );
break;
default:
break;
}
}
void
ColumnViewPreviewWidget::setQuery( const Tomahawk::query_ptr& query )
{
if ( !m_query.isNull() )
{
disconnect( m_query->track().data(), SIGNAL( updated() ), this, SLOT( onCoverUpdated() ) );
}
m_query = query;
connect( m_query->track().data(), SIGNAL( updated() ), SLOT( onCoverUpdated() ) );
onCoverUpdated();
ui->cover->setQuery( query );
ui->trackLabel->setText( query->track()->track() );
ui->artistLabel->setArtist( query->track()->artistPtr() );
setVisible( true );
}
void
ColumnViewPreviewWidget::onCoverUpdated()
{
if ( m_query->track()->cover( QSize( 0, 0 ) ).isNull() )
return;
ui->cover->setPixmap( TomahawkUtils::createRoundedImage( m_query->track()->cover( ui->cover->size() ), QSize( 0, 0 ) ) );
}
QSize
ColumnViewPreviewWidget::minimumSize() const
{
int minWidth = qMax( ui->trackLabel->sizeHint().width() + 32, ui->artistLabel->sizeHint().width() + 32 );
return QSize( qMax( minWidth, 348 ), minimumHeight() );
}

View File

@ -0,0 +1,58 @@
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
*
* Copyright 2013, Christian Muehlhaeuser <muesli@tomahawk-player.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
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Tomahawk is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef COLUMNVIEWPREVIEWWIDGET_H
#define COLUMNVIEWPREVIEWWIDGET_H
#include <QWidget>
#include "Query.h"
#include "DllMacro.h"
class ColumnView;
namespace Ui
{
class ColumnViewPreviewWidget;
}
class DLLEXPORT ColumnViewPreviewWidget : public QWidget
{
Q_OBJECT
public:
explicit ColumnViewPreviewWidget( ColumnView* parent );
~ColumnViewPreviewWidget();
QSize minimumSize() const;
public slots:
void setQuery( const Tomahawk::query_ptr& query );
protected:
void changeEvent( QEvent* e );
private slots:
void onCoverUpdated();
private:
Ui::ColumnViewPreviewWidget* ui;
Tomahawk::query_ptr m_query;
};
#endif // COLUMNVIEWPREVIEWWIDGET_H

View File

@ -0,0 +1,195 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ColumnViewPreviewWidget</class>
<widget class="QWidget" name="ColumnViewPreviewWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>378</width>
<height>422</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>348</width>
<height>378</height>
</size>
</property>
<property name="windowTitle">
<string notr="true" extracomment="not translatable because not shown to the user">InfoBar</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="margin">
<number>0</number>
</property>
<item>
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>8</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="margin">
<number>0</number>
</property>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="PlayableCover" name="cover">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>260</width>
<height>260</height>
</size>
</property>
<property name="text">
<string notr="true" extracomment="not translatable because is placeholder test">Cover</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>16</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="trackLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<pointsize>18</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string notr="true" extracomment="not translatable because not shown to the user">TrackName</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="indent">
<number>4</number>
</property>
</widget>
</item>
<item>
<widget class="QueryLabel" name="artistLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<pointsize>14</pointsize>
</font>
</property>
<property name="text">
<string notr="true" extracomment="not translatable because not shown to the user">ArtistName</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>17</width>
<height>70</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>PlayableCover</class>
<extends>QLabel</extends>
<header>widgets/PlayableCover.h</header>
</customwidget>
<customwidget>
<class>QueryLabel</class>
<extends>QLabel</extends>
<header>widgets/QueryLabel.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>