Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
30 changed files
with
1,551 additions
and
256 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
/* === 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 "ContextPage.h" | ||
|
||
#include <QGraphicsLinearLayout> | ||
|
||
using namespace Tomahawk; | ||
|
||
|
||
void | ||
ContextProxyPage::paint( QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget ) | ||
{ | ||
painter->save(); | ||
|
||
painter->setRenderHint( QPainter::Antialiasing, true ); | ||
painter->setPen( StyleHelper::headerHighlightColor() ); | ||
painter->setBrush( StyleHelper::headerHighlightColor() ); | ||
painter->drawRoundedRect( option->rect, 4.0, 4.0 ); | ||
|
||
QFont f( font() ); | ||
f.setBold( true ); | ||
f.setPixelSize( 14 ); | ||
painter->setFont( f ); | ||
painter->setPen( Qt::white ); | ||
|
||
QRect r( 1, 1, option->rect.width(), 19 ); | ||
QTextOption to( Qt::AlignCenter ); | ||
painter->drawText( r, m_page->title(), to ); | ||
|
||
painter->restore(); | ||
|
||
QGraphicsWidget::paint( painter, option, widget ); | ||
} | ||
|
||
|
||
void | ||
ContextProxyPage::setPage( Tomahawk::ContextPage* page ) | ||
{ | ||
m_page = page; | ||
|
||
QGraphicsWebView* testWebView = qobject_cast<QGraphicsWebView*>( page->widget() ); | ||
if ( testWebView ) | ||
{ | ||
setContentsMargins( 4, 4, 4, 4 ); | ||
} | ||
|
||
QGraphicsLinearLayout* layout = new QGraphicsLinearLayout(); | ||
layout->setContentsMargins( 4, 20, 4, 4 ); | ||
layout->addItem( page->widget() ); | ||
setLayout( layout ); | ||
|
||
page->widget()->installEventFilter( this ); | ||
page->widget()->installSceneEventFilter( this ); | ||
} | ||
|
||
|
||
bool | ||
ContextProxyPage::eventFilter( QObject* watched, QEvent* event ) | ||
{ | ||
if ( event->type() == QEvent::GrabMouse ) | ||
{ | ||
emit focused(); | ||
} | ||
|
||
return QGraphicsWidget::eventFilter( watched, event ); | ||
} | ||
|
||
|
||
bool | ||
ContextProxyPage::sceneEvent( QEvent* event ) | ||
{ | ||
if ( event->type() == QEvent::GrabMouse ) | ||
{ | ||
emit focused(); | ||
} | ||
|
||
return QGraphicsWidget::sceneEvent( event ); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
/* === 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 CONTEXTPAGE_H | ||
#define CONTEXTPAGE_H | ||
|
||
#include <QGraphicsProxyWidget> | ||
#include <QGraphicsWebView> | ||
#include <QStyleOptionGraphicsItem> | ||
|
||
#include "typedefs.h" | ||
#include "playlistinterface.h" | ||
#include "utils/stylehelper.h" | ||
#include "utils/tomahawkutils.h" | ||
|
||
#include "dllmacro.h" | ||
#include <signal.h> | ||
|
||
namespace Tomahawk | ||
{ | ||
|
||
class DLLEXPORT ContextPage : public QObject | ||
{ | ||
Q_OBJECT | ||
|
||
public: | ||
ContextPage() {} | ||
virtual ~ContextPage() {} | ||
|
||
virtual QGraphicsWidget* widget() = 0; | ||
virtual Tomahawk::PlaylistInterface* playlistInterface() const = 0; | ||
|
||
virtual QString title() const = 0; | ||
virtual QString description() const = 0; | ||
virtual QPixmap pixmap() const { return QPixmap( RESPATH "icons/tomahawk-icon-128x128.png" ); } | ||
|
||
virtual bool jumpToCurrentTrack() = 0; | ||
|
||
public slots: | ||
virtual void setQuery( const Tomahawk::query_ptr& query ) = 0; | ||
|
||
signals: | ||
void nameChanged( const QString& ); | ||
void descriptionChanged( const QString& ); | ||
void pixmapChanged( const QPixmap& ); | ||
void destroyed( QWidget* widget ); | ||
}; | ||
|
||
|
||
class DLLEXPORT ContextProxyPage : public QGraphicsWidget | ||
{ | ||
Q_OBJECT | ||
|
||
public: | ||
ContextProxyPage() : QGraphicsWidget() | ||
{} | ||
|
||
Tomahawk::ContextPage* page() const { return m_page; } | ||
void setPage( Tomahawk::ContextPage* page ); | ||
|
||
virtual bool eventFilter( QObject* watched, QEvent* event ); | ||
|
||
signals: | ||
void focused(); | ||
|
||
protected: | ||
virtual void paint( QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget ); | ||
virtual bool sceneEvent( QEvent* event ); | ||
|
||
private: | ||
Tomahawk::ContextPage* m_page; | ||
}; | ||
|
||
}; // ns | ||
|
||
#endif //CONTEXTPAGE_H |
Oops, something went wrong.