1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-11 16:44:05 +02:00

Add TomahawkWindowDeclarative

This commit is contained in:
Dominik Schmidt
2011-09-06 11:19:18 +02:00
parent c2cd281445
commit 3e8bcabfbc
3 changed files with 165 additions and 0 deletions

30
src/active/CMakeLists.txt Normal file
View File

@@ -0,0 +1,30 @@
SET( touchmahawkSources ${final_src} )
#LIST( REMOVE_ITEM touchmahawkSources "main.cpp" )
SET( touchmahawkHeaders
active/tomahawkwindowdeclarative.h
)
SET( touchmahawkSources
${touchmahawkSources}
active/tomahawkwindowdeclarative.cpp
# active/main.cpp
)
qt4_wrap_cpp( touchmahawkMoc ${touchmahawkHeaders} )
SET( touchmahawkFinalSources ${touchmahawkMoc} ${touchmahawkSources} )
SET( touchmahawkLinkLibraries
kdeclarative
${tomahawkLinkLibraries}
) #${QT_QTDECLARATIVE_LIBRARY}
ADD_EXECUTABLE( active-tomahawk ${touchmahawkFinalSources} )
TARGET_LINK_LIBRARIES( active-tomahawk ${touchmahawkLinkLibraries} )
SET_TARGET_PROPERTIES( active-tomahawk PROPERTIES COMPILE_FLAGS -DTOUCHMAHAWK )
INSTALL( TARGETS active-tomahawk DESTINATION bin )

View File

@@ -0,0 +1,79 @@
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
*
* Copyright 2011, Dominik Schmidt <domme@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 "active/tomahawkwindowdeclarative.h"
#include "utils/logger.h"
#include "audio/audioengine.h"
#include "globalactionmanager.h"
#include <QFileSystemWatcher>
#include <QtDeclarative>
#define QMLGUI "/home/domme/dev/sources/tomahawk-qml"
TomahawkWindowDeclarative::TomahawkWindowDeclarative()
: m_view(0)
{
QFileSystemWatcher* watcher = new QFileSystemWatcher;
watcher->addPath( QMLGUI );
connect( watcher, SIGNAL( directoryChanged( QString ) ), SLOT( loadQml() ));
loadQml();
setCentralWidget( m_view );
setWindowTitle("Touch-ma-hawk");
}
TomahawkWindowDeclarative::~TomahawkWindowDeclarative()
{
}
void
TomahawkWindowDeclarative::loadQml()
{
tLog() << Q_FUNC_INFO;
qmlRegisterType<AudioEngine>("org.tomahawkplayer.qmlcomponents", 1, 0, "AudioEngine");
if( !m_view )
{
tLog()<< Q_FUNC_INFO << "create qml view";
m_view = new QDeclarativeView;
m_view->setResizeMode(QDeclarativeView::SizeRootObjectToView);
m_view->show();
}
tLog()<< Q_FUNC_INFO << "clear component cache";
m_view->engine()->clearComponentCache();
tLog()<< Q_FUNC_INFO << "set source";
m_view->setSource( QUrl::fromLocalFile( QMLGUI "/main.qml" ) );
tLog()<< Q_FUNC_INFO << "set context property";
QDeclarativeContext* context = m_view->rootContext();
//context->setContextProperty( "myModel", m_superCollectionProxyModel );
context->setContextProperty( "audioEngine", AudioEngine::instance() );
context->setContextProperty( "globalActionManager", GlobalActionManager::instance() );
tLog()<< Q_FUNC_INFO << "finished";
}

View File

@@ -0,0 +1,56 @@
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
*
* Copyright 2011, Dominik Schmidt <domme@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 TOMAHAWKWINDOWDECLARATIVE_H
#define TOMAHAWKWINDOWDECLARATIVE_H
#include <QtDeclarative>
#include <QMainWindow>
class TomahawkWindowDeclarative;
class QFileSystemWatcher;
class TomahawkWindowDeclarative : public QMainWindow
{
Q_OBJECT
public:
TomahawkWindowDeclarative();
~TomahawkWindowDeclarative();
public slots:
void play( const QModelIndex& index );
// protected:
// void changeEvent( QEvent* e );
// void closeEvent( QCloseEvent* e );
// void showEvent( QShowEvent* e );
// void hideEvent( QHideEvent* e );
private slots:
void loadQml();
private:
QDeclarativeView* m_view;
QFileSystemWatcher* m_watcher;
};
#endif // TOMAHAWKWINDOWDECLARATIVE_H