Make plasma libs build.
[amarok.git] / src / popupdropper / PopupDropper.cpp
blob77ad109ae50567cec10432233a05b460124bb83d
1 /*
2 * Copyright (c) 2007 Jeff Mitchell <kde-dev@emailgoeshere.com>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 #include "PopupDropper.h"
21 #include "app.h"
22 #include "debug.h"
23 #include "contextview/contextview.h"
24 #include "PopupDropperScene.h"
25 #include "PopupDropperView.h"
27 #include <QBrush>
28 #include <QColor>
30 static bool ENABLED = true;
32 using namespace PopupDropperNS;
34 PopupDropper* PopupDropper::s_instance = 0;
36 PopupDropper*
37 PopupDropper::instance()
39 static PopupDropper pd;
40 return &pd;
43 PopupDropper::PopupDropper() : QObject()
44 , m_scene( 0 )
45 , m_view( 0 )
46 , m_enabled( ENABLED )
47 , m_initialized( false )
49 DEBUG_BLOCK
50 s_instance = this;
53 PopupDropper::~PopupDropper()
55 DEBUG_BLOCK
56 //m_scene.setPDV( 0 );
57 //delete m_view;
58 //m_view = 0;
61 void
62 PopupDropper::initialize( QWidget* window )
64 DEBUG_BLOCK
65 if( !window )
66 return;
67 m_scene.setParent( window );
68 m_scene.setSceneRect( QRectF( window->rect() ) );
69 m_view = new PopupDropperView( &m_scene, window );
70 m_scene.setPDV( m_view );
71 m_initialized = true;
74 void
75 PopupDropper::create()
77 DEBUG_BLOCK
78 if( !m_initialized )
79 initialize( ContextView::instance() );
80 if( !m_scene.isShown() )
82 const QWidget *parent = static_cast<QWidget *>( m_scene.parent() );
83 m_scene.setSceneRect( QRectF( parent->rect() ) );
84 m_view->resize( parent->size() + QSize( 2, 2 ) );
85 m_scene.startPDV();
89 void
90 PopupDropper::destroy()
92 DEBUG_BLOCK
93 if( m_scene.isShown() )
94 m_scene.stopPDV();
97 namespace The {
98 PopupDropperNS::PopupDropper* PopupDropper() { return PopupDropperNS::PopupDropper::instance(); }
101 #include "PopupDropper.moc"