File indexing completed on 2024-05-05 04:47:44

0001 /****************************************************************************************
0002  * Copyright (c) 2007 Leo Franchi <lfranchi@gmail.com>                                  *
0003  * Copyright (c) 2008 William Viana Soares <vianasw@gmail.com>                          *
0004  *                                                                                      *
0005  * This program is free software; you can redistribute it and/or modify it under        *
0006  * the terms of the GNU General Public License as published by the Free Software        *
0007  * Foundation; either version 2 of the License, or (at your option) any later           *
0008  * version.                                                                             *
0009  *                                                                                      *
0010  * This program is distributed in the hope that it will be useful, but WITHOUT ANY      *
0011  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A      *
0012  * PARTICULAR PURPOSE. See the GNU General Public License for more details.             *
0013  *                                                                                      *
0014  * You should have received a copy of the GNU General Public License along with         *
0015  * this program.  If not, see <http://www.gnu.org/licenses/>.                           *
0016  ****************************************************************************************/
0017 
0018 /*
0019   Significant parts of this code is inspired and/or copied from KDE Plasma sources,
0020   available at kdebase/workspace/libs/plasma
0021 */
0022 
0023 #ifndef AMAROK_CONTEXT_VIEW_H
0024 #define AMAROK_CONTEXT_VIEW_H
0025 
0026 
0027 #include "amarok_export.h"
0028 
0029 #include <QQuickWidget>
0030 
0031 
0032 class ContextUrlRunner;
0033 class QPalette;
0034 
0035 namespace Context
0036 {
0037 
0038 class AppletLoader;
0039 class AppletModel;
0040 class AppletProxyModel;
0041 
0042 class AMAROK_EXPORT ContextView : public QQuickWidget
0043 {
0044     Q_OBJECT
0045 
0046 public:
0047      explicit ContextView( QWidget *parent = nullptr );
0048     ~ContextView() override;
0049 
0050     /**
0051      * Singleton pattern accessor. May return 0 if the view was not yet constructed.
0052      */
0053     static ContextView *self() { return s_self; }
0054 
0055     /**
0056      * Get the plugin names, in order, of the applets currently in the contextView.
0057     */
0058     QStringList currentApplets() const;
0059 
0060     /**
0061      * Get the user visible applet names, in order, of the applets currently in the contextView.
0062     */
0063     QStringList currentAppletNames() const;
0064 
0065     /**
0066      * Get the Context::AppletModel instance in use.
0067      * It can be used to show, hide enable or disable applets among other things.
0068      */
0069     AppletProxyModel *appletModel() const { return m_proxyModel; }
0070 
0071     Q_INVOKABLE void runLink( const QUrl &link ) const;
0072     Q_INVOKABLE void debug( const QString &error ) const;
0073     Q_INVOKABLE void warning( const QString &error ) const;
0074     Q_INVOKABLE void error( const QString &error ) const;
0075 
0076 private Q_SLOTS:
0077     void slotStatusChanged( QQuickWidget::Status status );
0078     void updatePalette( const QPalette &palette );
0079 
0080 private:
0081     static ContextView *s_self;
0082 
0083     ContextUrlRunner *m_urlRunner;
0084     AppletLoader *m_loader;
0085     AppletModel *m_appletModel;
0086     AppletProxyModel *m_proxyModel;
0087 };
0088 
0089 } // Context namespace
0090 
0091 #endif