00001 /****************************************************************************** 00002 * This file is part of the Gluon Development Platform 00003 * Copyright (c) 2010 Arjen Hiemstra <ahiemstra@heimr.nl> 00004 * 00005 * This library is free software; you can redistribute it and/or 00006 * modify it under the terms of the GNU Lesser General Public 00007 * License as published by the Free Software Foundation; either 00008 * version 2.1 of the License, or (at your option) any later version. 00009 * 00010 * This library is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 * Lesser General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU Lesser General Public 00016 * License along with this library; if not, write to the Free Software 00017 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 00018 * 02110-1301 USA 00019 */ 00020 00021 #include "dockmanager.h" 00022 00023 #include <QtGui/QDockWidget> 00024 #include <KDE/KXmlGuiWindow> 00025 00026 using namespace GluonCreator; 00027 00028 class DockManager::DockManagerPrivate 00029 { 00030 public: 00031 QList<QDockWidget*> docks; 00032 KXmlGuiWindow* mainWindow; 00033 }; 00034 00035 template<> GLUON_CREATOR_VISIBILITY DockManager* GluonCore::Singleton<DockManager>::m_instance = 0; 00036 00037 void DockManager::addDock( QDockWidget* dock, Qt::DockWidgetArea area, Qt::Orientation orient ) 00038 { 00039 if( d->mainWindow ) 00040 { 00041 d->mainWindow->addDockWidget( area, dock, orient ); 00042 d->docks.append( dock ); 00043 } 00044 } 00045 00046 void DockManager::removeDock( QDockWidget* dock ) 00047 { 00048 if( d->docks.indexOf( dock ) != -1 ) 00049 { 00050 d->mainWindow->removeDockWidget( dock ); 00051 d->docks.removeOne( dock ); 00052 } 00053 } 00054 00055 void DockManager::setDocksEnabled( bool enabled ) 00056 { 00057 foreach( QDockWidget * dock, d->docks ) 00058 { 00059 dock->setEnabled( enabled ); 00060 } 00061 } 00062 00063 void DockManager::setDocksLocked( bool locked ) 00064 { 00065 foreach( QDockWidget * dock, d->docks ) 00066 { 00067 if( locked ) 00068 { 00069 dock->setFeatures( QDockWidget::NoDockWidgetFeatures ); 00070 } 00071 else 00072 { 00073 dock->setFeatures( QDockWidget::AllDockWidgetFeatures ); 00074 } 00075 } 00076 } 00077 00078 KXmlGuiWindow* DockManager::mainWindow() 00079 { 00080 return d->mainWindow; 00081 } 00082 00083 void DockManager::setMainWindow( KXmlGuiWindow* window ) 00084 { 00085 d->mainWindow = window; 00086 } 00087 00088 DockManager::DockManager() 00089 : d( new DockManagerPrivate ) 00090 { 00091 00092 } 00093 00094 DockManager::~DockManager() 00095 { 00096 delete d; 00097 } 00098 00099 //#include "dockmanager.moc"