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

wrapped QSearchField for use in QML

This commit is contained in:
Michael Zanetti
2012-12-15 18:26:57 +01:00
parent d90a10b51b
commit 1bd6ebef9c
5 changed files with 36 additions and 1 deletions

View File

@@ -161,6 +161,8 @@ set( libGuiSources
widgets/searchlineedit/LineEdit.cpp
widgets/searchlineedit/SearchButton.cpp
widgets/searchlineedit/SearchLineEdit.cpp
widgets/SearchFieldQmlProxy.cpp
)
IF(QCA2_FOUND)

View File

@@ -14,7 +14,7 @@ class DLLEXPORT QSearchField : public QWidget
Q_PROPERTY(QString placeholderText READ placeholderText WRITE setPlaceholderText);
public:
explicit QSearchField(QWidget *parent);
explicit QSearchField(QWidget *parent = 0);
QString text() const;
QString placeholderText() const;

View File

@@ -20,6 +20,7 @@
#include "playlist/PlayableItem.h"
#include "DeclarativeCoverArtProvider.h"
#include "utils/TomahawkUtilsGui.h"
#include "widgets/SearchFieldQmlProxy.h"
#include <qdeclarative.h>
#include <QDeclarativeEngine>
@@ -37,6 +38,7 @@ DeclarativeView::DeclarativeView( QWidget *parent ):
// This types seem to be needed everywhere anyways, lets the register here
qmlRegisterType<PlayableItem>( "tomahawk", 1, 0, "PlayableItem");
qmlRegisterType<SearchFieldQmlProxy>("tomahawk", 1, 0, "SearchField");
// QML image providers will be deleted by the view
engine()->addImageProvider( "albumart", new DeclarativeCoverArtProvider() );
@@ -46,6 +48,7 @@ DeclarativeView::DeclarativeView( QWidget *parent ):
rootContext()->setContextProperty( "defaultFontSize", TomahawkUtils::defaultFontSize() );
rootContext()->setContextProperty( "defaultFontHeight", TomahawkUtils::defaultFontHeight() );
}
DeclarativeView::~DeclarativeView()

View File

@@ -0,0 +1,12 @@
#include "SearchFieldQmlProxy.h"
#include "thirdparty/Qocoa/qsearchfield.h"
SearchFieldQmlProxy::SearchFieldQmlProxy(QGraphicsItem *parent) :
QGraphicsProxyWidget(parent)
{
m_searchField = new QSearchField();
m_searchField->setAttribute(Qt::WA_NoSystemBackground);
setWidget(m_searchField);
}

View File

@@ -0,0 +1,18 @@
#ifndef SEARCHFIELDQMLPROXY
#define SEARCHFIELDQMLPROXY
#include <QGraphicsProxyWidget>
class QSearchField;
class SearchFieldQmlProxy: public QGraphicsProxyWidget
{
Q_OBJECT
public:
SearchFieldQmlProxy(QGraphicsItem* parent = 0);
private:
QSearchField *m_searchField;
};
#endif