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:
@@ -161,6 +161,8 @@ set( libGuiSources
|
||||
widgets/searchlineedit/LineEdit.cpp
|
||||
widgets/searchlineedit/SearchButton.cpp
|
||||
widgets/searchlineedit/SearchLineEdit.cpp
|
||||
widgets/SearchFieldQmlProxy.cpp
|
||||
|
||||
)
|
||||
|
||||
IF(QCA2_FOUND)
|
||||
|
@@ -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;
|
||||
|
@@ -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()
|
||||
|
12
src/libtomahawk/widgets/SearchFieldQmlProxy.cpp
Normal file
12
src/libtomahawk/widgets/SearchFieldQmlProxy.cpp
Normal 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);
|
||||
|
||||
}
|
18
src/libtomahawk/widgets/SearchFieldQmlProxy.h
Normal file
18
src/libtomahawk/widgets/SearchFieldQmlProxy.h
Normal 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
|
Reference in New Issue
Block a user