mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-09-02 18:33:16 +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/LineEdit.cpp
|
||||||
widgets/searchlineedit/SearchButton.cpp
|
widgets/searchlineedit/SearchButton.cpp
|
||||||
widgets/searchlineedit/SearchLineEdit.cpp
|
widgets/searchlineedit/SearchLineEdit.cpp
|
||||||
|
widgets/SearchFieldQmlProxy.cpp
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
IF(QCA2_FOUND)
|
IF(QCA2_FOUND)
|
||||||
|
@@ -14,7 +14,7 @@ class DLLEXPORT QSearchField : public QWidget
|
|||||||
Q_PROPERTY(QString placeholderText READ placeholderText WRITE setPlaceholderText);
|
Q_PROPERTY(QString placeholderText READ placeholderText WRITE setPlaceholderText);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit QSearchField(QWidget *parent);
|
explicit QSearchField(QWidget *parent = 0);
|
||||||
|
|
||||||
QString text() const;
|
QString text() const;
|
||||||
QString placeholderText() const;
|
QString placeholderText() const;
|
||||||
|
@@ -20,6 +20,7 @@
|
|||||||
#include "playlist/PlayableItem.h"
|
#include "playlist/PlayableItem.h"
|
||||||
#include "DeclarativeCoverArtProvider.h"
|
#include "DeclarativeCoverArtProvider.h"
|
||||||
#include "utils/TomahawkUtilsGui.h"
|
#include "utils/TomahawkUtilsGui.h"
|
||||||
|
#include "widgets/SearchFieldQmlProxy.h"
|
||||||
|
|
||||||
#include <qdeclarative.h>
|
#include <qdeclarative.h>
|
||||||
#include <QDeclarativeEngine>
|
#include <QDeclarativeEngine>
|
||||||
@@ -37,6 +38,7 @@ DeclarativeView::DeclarativeView( QWidget *parent ):
|
|||||||
|
|
||||||
// This types seem to be needed everywhere anyways, lets the register here
|
// This types seem to be needed everywhere anyways, lets the register here
|
||||||
qmlRegisterType<PlayableItem>( "tomahawk", 1, 0, "PlayableItem");
|
qmlRegisterType<PlayableItem>( "tomahawk", 1, 0, "PlayableItem");
|
||||||
|
qmlRegisterType<SearchFieldQmlProxy>("tomahawk", 1, 0, "SearchField");
|
||||||
|
|
||||||
// QML image providers will be deleted by the view
|
// QML image providers will be deleted by the view
|
||||||
engine()->addImageProvider( "albumart", new DeclarativeCoverArtProvider() );
|
engine()->addImageProvider( "albumart", new DeclarativeCoverArtProvider() );
|
||||||
@@ -46,6 +48,7 @@ DeclarativeView::DeclarativeView( QWidget *parent ):
|
|||||||
|
|
||||||
rootContext()->setContextProperty( "defaultFontSize", TomahawkUtils::defaultFontSize() );
|
rootContext()->setContextProperty( "defaultFontSize", TomahawkUtils::defaultFontSize() );
|
||||||
rootContext()->setContextProperty( "defaultFontHeight", TomahawkUtils::defaultFontHeight() );
|
rootContext()->setContextProperty( "defaultFontHeight", TomahawkUtils::defaultFontHeight() );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DeclarativeView::~DeclarativeView()
|
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