diff --git a/braindump/src/MainWindow.cpp b/braindump/src/MainWindow.cpp index 4e70c0b6850..a92b4dc58c0 100644 --- a/braindump/src/MainWindow.cpp +++ b/braindump/src/MainWindow.cpp @@ -1,245 +1,246 @@ /* * Copyright (c) 2009 Cyrille Berger * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; * either version 2, or (at your option) any later version of the License. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this library; see the file COPYING. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #include "MainWindow.h" #include #include #include #include #include #include +#include #include #include #include -#include -#include #include #include +#include +#include #include #include #include "RootSection.h" #include "View.h" #include "Canvas.h" #include "import/DockerManager.h" #include #include "StatusBarItem.h" MainWindow::MainWindow(RootSection* document) : m_doc(document), m_activeView(0), m_dockerManager(0) { // then, setup our actions setupActions(); // Create the docker manager after setting up the action m_dockerManager = new DockerManager(this); // Setup the view view = new View(m_doc, this); setCentralWidget(view); // a call to KXmlGuiWindow::setupGUI() populates the GUI // with actions, using KXMLGUI. // It also applies the saved mainwindow settings, if any, and ask the // mainwindow to automatically save settings if changed: window size, // toolbar position, icon size, etc. setupGUI(); activateView(view); setAutoSaveSettings(); const int scnum = QApplication::desktop()->screenNumber(parentWidget()); QRect desk = QApplication::desktop()->screenGeometry(scnum); // if the desktop is virtual then use virtual screen size if(QApplication::desktop()->isVirtualDesktop()) desk = QApplication::desktop()->screenGeometry(QApplication::desktop()->screen()); foreach(QDockWidget * wdg, m_dockWidgets) { if((wdg->features() & QDockWidget::DockWidgetClosable) == 0) { wdg->setVisible(true); } } forceDockTabFonts(); } MainWindow::~MainWindow() { // The view need to be deleted before the dockermanager delete view; } void MainWindow::setupActions() { KStandardAction::quit(qApp, SLOT(closeAllWindows()), actionCollection()); m_doc->createActions(actionCollection()); m_dockWidgetMenu = new KActionMenu(i18n("Dockers"), this); actionCollection()->addAction("settings_dockers_menu", m_dockWidgetMenu); m_dockWidgetMenu->setVisible(false); } QDockWidget* MainWindow::createDockWidget(KoDockFactoryBase* factory) { QDockWidget* dockWidget = 0; if(!m_dockWidgetMap.contains(factory->id())) { dockWidget = factory->createDockWidget(); // It is quite possible that a dock factory cannot create the dock; don't // do anything in that case. if(!dockWidget) return 0; m_dockWidgets.push_back(dockWidget); dockWidget->setObjectName(factory->id()); dockWidget->setParent(this); if(dockWidget->widget() && dockWidget->widget()->layout()) dockWidget->widget()->layout()->setContentsMargins(1, 1, 1, 1); Qt::DockWidgetArea side = Qt::RightDockWidgetArea; bool visible = true; switch(factory->defaultDockPosition()) { case KoDockFactoryBase::DockTornOff: dockWidget->setFloating(true); // position nicely? break; case KoDockFactoryBase::DockTop: side = Qt::TopDockWidgetArea; break; case KoDockFactoryBase::DockLeft: side = Qt::LeftDockWidgetArea; break; case KoDockFactoryBase::DockBottom: side = Qt::BottomDockWidgetArea; break; case KoDockFactoryBase::DockRight: side = Qt::RightDockWidgetArea; break; case KoDockFactoryBase::DockMinimized: visible = false; break; default:; } addDockWidget(side, dockWidget); if(dockWidget->features() & QDockWidget::DockWidgetClosable) { m_dockWidgetMenu->addAction(dockWidget->toggleViewAction()); if(!visible) dockWidget->hide(); } m_dockWidgetMap.insert(factory->id(), dockWidget); } else { dockWidget = m_dockWidgetMap[ factory->id()]; } - KConfigGroup group(KGlobal::config(), "GUI"); - QFont dockWidgetFont = KGlobalSettings::generalFont(); + KConfigGroup group(KSharedConfig::openConfig(), "GUI"); + QFont dockWidgetFont = QFontDatabase::systemFont(QFontDatabase::GeneralFont); qreal pointSize = group.readEntry("palettefontsize", dockWidgetFont.pointSize() * 0.75); - pointSize = qMax(pointSize, KGlobalSettings::smallestReadableFont().pointSizeF()); + pointSize = qMax(pointSize, QFontDatabase::systemFont(QFontDatabase::SmallestReadableFont).pointSizeF()); dockWidgetFont.setPointSizeF(pointSize); #ifdef Q_WS_MAC dockWidget->setAttribute(Qt::WA_MacSmallSize, true); #endif dockWidget->setFont(dockWidgetFont); connect(dockWidget, SIGNAL(dockLocationChanged(Qt::DockWidgetArea)), this, SLOT(forceDockTabFonts())); return dockWidget; } void MainWindow::forceDockTabFonts() { QObjectList chis = children(); for(int i = 0; i < chis.size(); ++i) { if(chis.at(i)->inherits("QTabBar")) { - QFont dockWidgetFont = KGlobalSettings::generalFont(); - qreal pointSize = KGlobalSettings::smallestReadableFont().pointSizeF(); + QFont dockWidgetFont = QFontDatabase::systemFont(QFontDatabase::GeneralFont); + qreal pointSize = QFontDatabase::systemFont(QFontDatabase::SmallestReadableFont).pointSizeF(); dockWidgetFont.setPointSizeF(pointSize); ((QTabBar *)chis.at(i))->setFont(dockWidgetFont); } } } DockerManager* MainWindow::dockerManager() { return m_dockerManager; } void MainWindow::activateView(View* view) { Q_ASSERT(factory()); // Desactivate previous view if(m_activeView) { factory()->removeClient(m_activeView); foreach(StatusBarItem * item, m_statusBarItems[m_activeView]) { item->ensureItemHidden(statusBar()); } } // Set the new view m_activeView = view; if(m_activeView) { factory()->addClient(view); // Show the status widget for the current view foreach(StatusBarItem * item, m_statusBarItems[m_activeView]) { item->ensureItemShown(statusBar()); } } } void MainWindow::addStatusBarItem(QWidget* _widget, int _stretch, View* _view) { Q_ASSERT(_widget); Q_ASSERT(_view); QList& list = m_statusBarItems[_view]; StatusBarItem* item = new StatusBarItem(_widget, _stretch, _view); if(_view == m_activeView) { item->ensureItemShown(statusBar()); } list.append(item); } void MainWindow::removeStatusBarItem(QWidget* _widget) { foreach(View * key, m_statusBarItems.keys()) { QList& list = m_statusBarItems[key]; foreach(StatusBarItem * item, list) { if(item->m_widget == _widget) { list.removeAll(item); item->ensureItemHidden(statusBar()); delete item; return; } } } qWarning() << "Widget " << _widget << " not found in the status bar"; } QList MainWindow::canvasObservers() const { QList observers; foreach(QDockWidget * docker, m_dockWidgets) { KoCanvasObserverBase *observer = dynamic_cast(docker); if(observer) { observers << observer; } } return observers; } diff --git a/braindump/src/import/ToolDocker.cpp b/braindump/src/import/ToolDocker.cpp index ff8d09fc736..c010147c53c 100644 --- a/braindump/src/import/ToolDocker.cpp +++ b/braindump/src/import/ToolDocker.cpp @@ -1,124 +1,125 @@ /* This file is part of the KDE project * * Copyright (c) 2010-2011 C. Boemann * Copyright (c) 2005-2006 Boudewijn Rempt * Copyright (c) 2006 Thomas Zander * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public License * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #include "ToolDocker.h" #include "ToolDocker_p.h" #include #include #include #include #include #include #include #include #include #include #include -#include +#include +#include #include #include ToolDocker::ToolDocker(QWidget *parent) : QDockWidget(i18n("Tool Options"), parent), d(new Private(this)) { setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea | Qt::TopDockWidgetArea); - KConfigGroup cfg = KGlobal::config()->group("DockWidget sharedtooldocker"); + KConfigGroup cfg(KSharedConfig::openConfig(), "DockWidget sharedtooldocker"); d->tabbed = cfg.readEntry("TabbedMode", false); d->hasTitle = cfg.readEntry("Locked", true); toggleViewAction()->setVisible(false); //should always be visible, so hide option in menu setFeatures(DockWidgetMovable | DockWidgetFloatable); if(d->hasTitle) { setTitleBarWidget(new KoDockWidgetTitleBar(this)); } else { setTitleBarWidget(new QWidget()); } connect(this, SIGNAL(dockLocationChanged(Qt::DockWidgetArea)), this, SLOT(locationChanged(Qt::DockWidgetArea))); d->housekeeperWidget = new QWidget(); d->housekeeperLayout = new QGridLayout(); d->housekeeperWidget->setLayout(d->housekeeperLayout); d->housekeeperLayout->setSizeConstraint(QLayout::SetMinAndMaxSize); d->hiderWidget = new QWidget(d->housekeeperWidget); d->hiderWidget->setVisible(false); d->scrollArea = new QScrollArea(); d->scrollArea->setWidget(d->housekeeperWidget); d->scrollArea->setFrameShape(QFrame::NoFrame); d->scrollArea->setWidgetResizable(true); setWidget(d->scrollArea); d->lockButton = new QToolButton(this); if(d->hasTitle) { d->lockButton->setIcon(d->unlockIcon); } else { d->lockButton->setIcon(d->lockIcon); } d->lockButton->setToolTip(i18n("Toggles showing a title bar")); d->lockButton->setAutoRaise(true); connect(d->lockButton, SIGNAL(clicked()), SLOT(toggleLock())); d->lockButton->setVisible(true); d->lockButton->resize(d->lockButton->sizeHint()); d->tabButton = new QToolButton(this); // parent hack in toggleLock to keep it clickable d->tabButton->setIcon(d->tabIcon); d->tabButton->setToolTip(i18n("Toggles organising the options in tabs or not")); d->tabButton->setAutoRaise(true); connect(d->tabButton, SIGNAL(clicked()), SLOT(toggleTab())); d->tabButton->resize(d->tabButton->sizeHint()); d->tabButton->setVisible(d->hasTitle); } ToolDocker::~ToolDocker() { - KConfigGroup cfg = KGlobal::config()->group("DockWidget sharedtooldocker"); + KConfigGroup cfg(KSharedConfig::openConfig(), "DockWidget sharedtooldocker"); cfg.writeEntry("TabbedMode", d->tabbed); cfg.writeEntry("Locked", d->hasTitle); cfg.sync(); delete d; } bool ToolDocker::hasOptionWidget() { return !d->currentWidgetList.isEmpty(); } void ToolDocker::setOptionWidgets(const QList > &optionWidgetList) { d->recreateLayout(optionWidgetList); } void ToolDocker::resizeEvent(QResizeEvent*) { int fw = isFloating() ? style()->pixelMetric(QStyle::PM_DockWidgetFrameWidth, 0, this) : 0; d->lockButton->move(width() - d->lockButton->width() - d->scrollArea->verticalScrollBar()->sizeHint().width(), fw); d->tabButton->move(d->lockButton->x() - d->tabButton->width() - 2, d->lockButton->y()); } #include