1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-06 06:07:37 +02:00

* Added HeaderLabel to replace our old ugly labels.

This commit is contained in:
Christian Muehlhaeuser
2011-06-26 07:21:14 +02:00
parent e0c72c911a
commit fe7c79ff31
7 changed files with 209 additions and 52 deletions

View File

@@ -171,7 +171,9 @@ set( libSources
widgets/welcomewidget.cpp
widgets/welcomeplaylistmodel.cpp
widgets/overlaywidget.cpp
widgets/HeaderLabel.cpp
widgets/infowidgets/sourceinfowidget.cpp
# widgets/infowidgets/ArtistInfoWidget.cpp
kdsingleapplicationguard/kdsingleapplicationguard.cpp
kdsingleapplicationguard/kdsharedmemorylocker.cpp
@@ -338,7 +340,9 @@ set( libHeaders
widgets/welcomewidget.h
widgets/welcomeplaylistmodel.h
widgets/overlaywidget.h
widgets/HeaderLabel.h
widgets/infowidgets/sourceinfowidget.h
# widgets/infowidgets/ArtistInfoWidget.h
kdsingleapplicationguard/kdsingleapplicationguard.h
)
@@ -360,6 +364,7 @@ set( libUI ${libUI}
widgets/searchwidget.ui
widgets/welcomewidget.ui
widgets/infowidgets/sourceinfowidget.ui
widgets/infowidgets/ArtistInfoWidget.ui
playlist/topbar/topbar.ui
playlist/infobar/infobar.ui
)

View File

@@ -0,0 +1,86 @@
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
*
* Copyright 2010-2011, 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 "HeaderLabel.h"
#include <QDebug>
#include <QPainter>
#define FONT_SIZE 16
HeaderLabel::HeaderLabel( QWidget* parent )
: QLabel( parent )
, m_parent( parent )
{
QFont f( font() );
f.setBold( true );
f.setPointSize( 11 );
#ifdef Q_WS_MAC
f.setPointSize( f.pointSize() - 2 );
#endif
setFont( f );
setFixedHeight( sizeHint().height() + 6 );
qDebug() << "FOOBAR:" << minimumSize();
}
HeaderLabel::~HeaderLabel()
{
}
QSize
HeaderLabel::sizeHint() const
{
return QLabel::sizeHint();
}
void
HeaderLabel::paintEvent( QPaintEvent* event )
{
QPainter p( this );
QRect r = contentsRect();
// p.setRenderHint( QPainter::Antialiasing );
QRect upperHalf( 0, 0, r.width(), r.height() / 2 );
QRect lowerHalf( 0, upperHalf.height(), r.width(), r.height() );
p.fillRect( upperHalf, QColor( 80, 80, 80 ) );
p.fillRect( lowerHalf, QColor( 72, 72, 72 ) );
{
QColor lineColor( 100, 100, 100 );
QLine line( 0, 0, r.width(), 0 );
p.setPen( lineColor );
p.drawLine( line );
}
{
QColor lineColor( 63, 63, 63 );
QLine line( 0, r.height() - 1, r.width(), r.height() - 1 );
p.setPen( lineColor );
p.drawLine( line );
}
r.adjust( 8, 3, -8, -3 );
p.setPen( Qt::white );
p.drawText( r, text() );
}

View File

@@ -0,0 +1,47 @@
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
*
* Copyright 2010-2011, 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 HEADERLABEL_H
#define HEADERLABEL_H
#include <QLabel>
#include "dllmacro.h"
class DLLEXPORT HeaderLabel : public QLabel
{
Q_OBJECT
public:
HeaderLabel( QWidget* parent );
~HeaderLabel();
QSize minimumSizeHint() const { return sizeHint(); }
QSize sizeHint() const;
public slots:
protected:
// void changeEvent( QEvent* e );
void paintEvent( QPaintEvent* event );
private:
QWidget* m_parent;
};
#endif // HEADERLABEL_H

View File

@@ -38,6 +38,30 @@ SourceInfoWidget::SourceInfoWidget( const Tomahawk::source_ptr& source, QWidget*
{
ui->setupUi( this );
ui->historyView->setFrameShape( QFrame::NoFrame );
ui->historyView->setAttribute( Qt::WA_MacShowFocusRect, 0 );
ui->recentAlbumView->setFrameShape( QFrame::NoFrame );
ui->recentAlbumView->setAttribute( Qt::WA_MacShowFocusRect, 0 );
ui->recentCollectionView->setFrameShape( QFrame::NoFrame );
ui->recentCollectionView->setAttribute( Qt::WA_MacShowFocusRect, 0 );
ui->horizontalLayout->setContentsMargins( 0, 0, 0, 0 );
ui->horizontalLayout->setMargin( 0 );
ui->horizontalLayout->setSpacing( 0 );
ui->verticalLayout->setContentsMargins( 0, 0, 0, 0 );
ui->verticalLayout->setMargin( 0 );
ui->verticalLayout->setSpacing( 0 );
ui->verticalLayout_2->setContentsMargins( 0, 0, 0, 0 );
ui->verticalLayout_2->setMargin( 0 );
ui->verticalLayout_2->setSpacing( 0 );
ui->verticalLayout_3->setContentsMargins( 0, 0, 0, 0 );
ui->verticalLayout_3->setMargin( 0 );
ui->verticalLayout_3->setSpacing( 0 );
ui->verticalLayout_4->setContentsMargins( 0, 0, 0, 0 );
ui->verticalLayout_4->setMargin( 0 );
ui->verticalLayout_4->setSpacing( 0 );
ui->historyView->overlay()->setEnabled( false );
m_recentCollectionModel = new CollectionFlatModel( ui->recentCollectionView );

View File

@@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>985</width>
<width>831</width>
<height>460</height>
</rect>
</property>
@@ -14,14 +14,7 @@
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="label_2">
<property name="font">
<font>
<pointsize>13</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<widget class="HeaderLabel" name="label_2">
<property name="text">
<string>Recent Albums</string>
</property>
@@ -56,14 +49,7 @@
<item>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QLabel" name="label">
<property name="font">
<font>
<pointsize>13</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<widget class="HeaderLabel" name="label">
<property name="text">
<string>Latest Additions to their Collection</string>
</property>
@@ -77,14 +63,7 @@
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QLabel" name="label_3">
<property name="font">
<font>
<pointsize>13</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<widget class="HeaderLabel" name="label_3">
<property name="text">
<string>Recently played Tracks</string>
</property>
@@ -100,21 +79,26 @@
</layout>
</widget>
<customwidgets>
<customwidget>
<class>HeaderLabel</class>
<extends>QLabel</extends>
<header location="global">widgets/HeaderLabel.h</header>
</customwidget>
<customwidget>
<class>PlaylistView</class>
<extends>QTreeView</extends>
<header>playlist/playlistview.h</header>
</customwidget>
<customwidget>
<class>CollectionView</class>
<extends>QTreeView</extends>
<header>playlist/collectionview.h</header>
</customwidget>
<customwidget>
<class>AlbumView</class>
<extends>QListView</extends>
<header>playlist/albumview.h</header>
</customwidget>
<customwidget>
<class>CollectionView</class>
<extends>QTreeView</extends>
<header>playlist/collectionview.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>

View File

@@ -52,6 +52,27 @@ WelcomeWidget::WelcomeWidget( QWidget* parent )
WelcomePlaylistModel* model = new WelcomePlaylistModel( this );
model->setMaxPlaylists( HISTORY_PLAYLIST_ITEMS );
ui->playlistWidget->setFrameShape( QFrame::NoFrame );
ui->playlistWidget->setAttribute( Qt::WA_MacShowFocusRect, 0 );
ui->tracksView->setFrameShape( QFrame::NoFrame );
ui->tracksView->setAttribute( Qt::WA_MacShowFocusRect, 0 );
ui->additionsView->setFrameShape( QFrame::NoFrame );
ui->additionsView->setAttribute( Qt::WA_MacShowFocusRect, 0 );
ui->horizontalLayout->setContentsMargins( 0, 0, 0, 0 );
ui->horizontalLayout->setMargin( 0 );
ui->horizontalLayout->setSpacing( 0 );
ui->verticalLayout->setContentsMargins( 0, 0, 0, 0 );
ui->verticalLayout->setMargin( 0 );
ui->verticalLayout->setSpacing( 0 );
ui->verticalLayout_2->setContentsMargins( 0, 0, 0, 0 );
ui->verticalLayout_2->setMargin( 0 );
ui->verticalLayout_2->setSpacing( 0 );
ui->verticalLayout_3->setContentsMargins( 0, 0, 0, 0 );
ui->verticalLayout_3->setMargin( 0 );
ui->verticalLayout_3->setSpacing( 0 );
ui->playlistWidget->setItemDelegate( new PlaylistDelegate() );
ui->playlistWidget->setModel( model );
ui->playlistWidget->overlay()->resize( 380, 86 );

View File

@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>985</width>
<height>459</height>
<width>875</width>
<height>513</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout" stretch="2,1">
@@ -16,15 +16,10 @@
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<widget class="QWidget" name="">
<widget class="QWidget" name="layoutWidget1">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="label_4">
<property name="font">
<font>
<pointsize>14</pointsize>
</font>
</property>
<widget class="HeaderLabel" name="label_4">
<property name="text">
<string>Recent Additions</string>
</property>
@@ -35,15 +30,10 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="">
<widget class="QWidget" name="layoutWidget2">
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QLabel" name="label_2">
<property name="font">
<font>
<pointsize>14</pointsize>
</font>
</property>
<widget class="HeaderLabel" name="label_2">
<property name="text">
<string>Newest Stations &amp; Playlists</string>
</property>
@@ -59,18 +49,13 @@
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QLabel" name="label_3">
<widget class="HeaderLabel" name="label_3">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="font">
<font>
<pointsize>14</pointsize>
</font>
</property>
<property name="text">
<string>Recently Played Tracks</string>
</property>
@@ -91,6 +76,11 @@
</layout>
</widget>
<customwidgets>
<customwidget>
<class>HeaderLabel</class>
<extends>QLabel</extends>
<header location="global">widgets/HeaderLabel.h</header>
</customwidget>
<customwidget>
<class>PlaylistView</class>
<extends>QTreeView</extends>