Changeset View
Changeset View
Standalone View
Standalone View
src/context/ContextDock.cpp
Show All 12 Lines | |||||
13 | * You should have received a copy of the GNU General Public License along with * | 13 | * You should have received a copy of the GNU General Public License along with * | ||
14 | * this program. If not, see <http://www.gnu.org/licenses/>. * | 14 | * this program. If not, see <http://www.gnu.org/licenses/>. * | ||
15 | ****************************************************************************************/ | 15 | ****************************************************************************************/ | ||
16 | 16 | | |||
17 | #define DEBUG_PREFIX "ContextDock" | 17 | #define DEBUG_PREFIX "ContextDock" | ||
18 | 18 | | |||
19 | #include "ContextDock.h" | 19 | #include "ContextDock.h" | ||
20 | 20 | | |||
21 | #include "amarokconfig.h" | | |||
22 | #include "context/ContextScene.h" | | |||
23 | #include "context/ContextView.h" | 21 | #include "context/ContextView.h" | ||
24 | #include "context/ToolbarView.h" | | |||
25 | #include "core/support/Debug.h" | 22 | #include "core/support/Debug.h" | ||
26 | 23 | | |||
27 | #include <KVBox> | 24 | #include <KLocalizedString> | ||
28 | 25 | | |||
29 | ContextDock::ContextDock( QWidget *parent ) | 26 | ContextDock::ContextDock( QWidget *parent ) | ||
30 | : AmarokDockWidget( i18n( "&Context" ), parent ) | 27 | : AmarokDockWidget( i18n( "&Context" ), parent ) | ||
31 | { | 28 | { | ||
32 | setObjectName( "Context dock" ); | 29 | setObjectName( "Context dock" ); | ||
33 | setAllowedAreas( Qt::AllDockWidgetAreas ); | 30 | setAllowedAreas( Qt::AllDockWidgetAreas ); | ||
34 | setMinimumWidth( 50 ); | 31 | setMinimumWidth( 50 ); | ||
35 | setContentsMargins( 0, 0, 0, 0 ); | 32 | setContentsMargins( 0, 0, 0, 0 ); | ||
36 | 33 | | |||
37 | m_mainWidget = new KVBox( this ); | 34 | createContextView(); | ||
38 | m_mainWidget->setMinimumWidth( 400 ); | | |||
39 | m_mainWidget->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ); | | |||
40 | m_mainWidget->setSpacing( 0 ); | | |||
41 | m_mainWidget->setContentsMargins( 0, 0, 0, 0 ); | | |||
42 | m_mainWidget->setFrameShape( QFrame::NoFrame ); | | |||
43 | setWidget( m_mainWidget ); | | |||
44 | | ||||
45 | m_corona = new Context::ContextScene( this ); | | |||
46 | connect( m_corona.data(), SIGNAL(containmentAdded(Plasma::Containment*)), | | |||
47 | this, SLOT(createContextView(Plasma::Containment*)) ); | | |||
48 | | ||||
49 | m_corona.data()->loadDefaultSetup(); // this method adds our containment to the scene | | |||
50 | } | 35 | } | ||
51 | 36 | | |||
52 | void ContextDock::polish() | 37 | void ContextDock::polish() | ||
53 | { | 38 | { | ||
54 | } | 39 | } | ||
55 | 40 | | |||
56 | void | 41 | void | ||
57 | ContextDock::createContextView( Plasma::Containment *containment ) | 42 | ContextDock::createContextView() | ||
58 | { | 43 | { | ||
59 | disconnect( m_corona.data(), SIGNAL(containmentAdded(Plasma::Containment*)), | 44 | auto mainWidget = new Context::ContextView(); | ||
60 | this, SLOT(createContextView(Plasma::Containment*)) ); | 45 | mainWidget->setMinimumWidth( 400 ); | ||
46 | mainWidget->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ); | ||||
47 | mainWidget->setContentsMargins( 0, 0, 0, 0 ); | ||||
48 | setWidget( mainWidget ); | ||||
61 | 49 | | |||
62 | debug() << "Creating context view on containmend" << containment->name(); | | |||
63 | PERF_LOG( "Creating ContexView" ) | | |||
64 | m_contextView = new Context::ContextView( containment, m_corona.data(), m_mainWidget ); | | |||
65 | m_contextView.data()->setFrameShape( QFrame::NoFrame ); | | |||
66 | m_contextToolbarView = new Context::ToolbarView( containment, m_corona.data(), m_mainWidget ); | | |||
67 | PERF_LOG( "Created ContexToolbarView" ) | | |||
68 | | ||||
69 | connect( m_corona.data(), SIGNAL(sceneRectChanged(QRectF)), m_contextView.data(), SLOT(updateSceneRect(QRectF)) ); | | |||
70 | connect( m_contextToolbarView.data(), SIGNAL(hideAppletExplorer()), m_contextView.data(), SLOT(hideAppletExplorer()) ); | | |||
71 | connect( m_contextToolbarView.data(), SIGNAL(showAppletExplorer()), m_contextView.data(), SLOT(showAppletExplorer()) ); | | |||
72 | m_contextView.data()->showHome(); | | |||
73 | PERF_LOG( "ContexView created" ) | 50 | PERF_LOG( "ContexView created" ) | ||
74 | } | 51 | } | ||
75 | 52 | | |||
76 | 53 | |