gridLayout->setMargin(0); gridLayout->setSpacing(0); setLayout(gridLayout); m_canvasController = new KoCanvasControllerWidget(actionCollection(), this); m_canvasController->setCanvasMode(KoCanvasController::Infinite); createCanvas(0); KoToolManager::instance()->addController(m_canvasController); KoToolManager::instance()->registerTools(actionCollection(), m_canvasController); m_zoomController = new KoZoomController(m_canvasController, &m_zoomHandler, actionCollection()); connect(m_zoomController, SIGNAL(zoomChanged(KoZoomMode::Mode,qreal)), this, SLOT(slotZoomChanged(KoZoomMode::Mode,qreal))); m_zoomAction = m_zoomController->zoomAction(); m_mainWindow->addStatusBarItem(m_zoomAction->createWidget(m_mainWindow->statusBar()), 0, this); m_zoomController->setZoomMode(KoZoomMode::ZOOM_WIDTH); gridLayout->addWidget(m_canvasController, 1, 1); connect(m_canvasController->proxyObject, SIGNAL(canvasMousePositionChanged(QPoint)), this, SLOT(updateMousePosition(QPoint))); KoToolBoxFactory toolBoxFactory; m_mainWindow->createDockWidget(&toolBoxFactory); connect(m_canvasController, SIGNAL(toolOptionWidgetsChanged(QList<QPointer<QWidget> >)), m_mainWindow->dockerManager(), SLOT(newOptionWidgets(QList<QPointer<QWidget> >)));
void KoPAView::initGUI() { QGridLayout * gridLayout = new QGridLayout( this ); gridLayout->setMargin( 0 ); gridLayout->setSpacing( 0 ); setLayout( gridLayout ); d->canvas = new KoPACanvas( this, d->doc, this ); KoCanvasControllerWidget *canvasController = new KoCanvasControllerWidget( this ); d->canvasController = canvasController; d->canvasController->setCanvas( d->canvas ); KoToolManager::instance()->addController( d->canvasController ); KoToolManager::instance()->registerTools( actionCollection(), d->canvasController ); d->zoomController = new KoZoomController( d->canvasController, zoomHandler(), actionCollection()); connect( d->zoomController, SIGNAL( zoomChanged( KoZoomMode::Mode, qreal ) ), this, SLOT( slotZoomChanged( KoZoomMode::Mode, qreal ) ) ); d->zoomAction = d->zoomController->zoomAction(); // set up status bar message d->status = new QLabel( QString() ); d->status->setAlignment( Qt::AlignLeft | Qt::AlignVCenter ); d->status->setMinimumWidth( 300 ); addStatusBarItem( d->status, 1 ); connect( KoToolManager::instance(), SIGNAL( changedStatusText( const QString & ) ), d->status, SLOT( setText( const QString & ) ) ); d->zoomActionWidget = d->zoomAction->createWidget( statusBar() ); addStatusBarItem( d->zoomActionWidget, 0 ); d->zoomController->setZoomMode( KoZoomMode::ZOOM_PAGE ); d->viewModeNormal = new KoPAViewModeNormal( this, d->canvas ); setViewMode(d->viewModeNormal); // The rulers d->horizontalRuler = new KoRuler(this, Qt::Horizontal, viewConverter( d->canvas )); d->horizontalRuler->setShowMousePosition(true); d->horizontalRuler->setUnit(d->doc->unit()); d->verticalRuler = new KoRuler(this, Qt::Vertical, viewConverter( d->canvas )); d->verticalRuler->setUnit(d->doc->unit()); d->verticalRuler->setShowMousePosition(true); new KoRulerController(d->horizontalRuler, d->canvas->resourceManager()); connect(d->doc, SIGNAL(unitChanged(const KoUnit&)), d->horizontalRuler, SLOT(setUnit(const KoUnit&))); connect(d->doc, SIGNAL(unitChanged(const KoUnit&)), d->verticalRuler, SLOT(setUnit(const KoUnit&))); gridLayout->addWidget(d->horizontalRuler, 0, 1); gridLayout->addWidget(d->verticalRuler, 1, 0); gridLayout->addWidget(canvasController, 1, 1 ); connect(d->canvasController->proxyObject, SIGNAL(canvasOffsetXChanged(int)), this, SLOT(pageOffsetChanged())); connect(d->canvasController->proxyObject, SIGNAL(canvasOffsetYChanged(int)), this, SLOT(pageOffsetChanged())); connect(d->canvasController->proxyObject, SIGNAL(sizeChanged(const QSize&)), this, SLOT(pageOffsetChanged())); connect(d->canvasController->proxyObject, SIGNAL(canvasMousePositionChanged(const QPoint&)), this, SLOT(updateMousePosition(const QPoint&))); d->verticalRuler->createGuideToolConnection(d->canvas); d->horizontalRuler->createGuideToolConnection(d->canvas); KoToolBoxFactory toolBoxFactory(d->canvasController, i18n("Tools") ); if (shell()) { shell()->createDockWidget( &toolBoxFactory ); connect( canvasController, SIGNAL( toolOptionWidgetsChanged(const QMap<QString, QWidget *> &, QWidget*) ), shell()->dockerManager(), SLOT( newOptionWidgets(const QMap<QString, QWidget *> &, QWidget*) ) ); } connect(shapeManager(), SIGNAL(selectionChanged()), this, SLOT(selectionChanged())); connect(d->canvas, SIGNAL(documentSize(const QSize&)), d->canvasController->proxyObject, SLOT(updateDocumentSize(const QSize&))); connect(d->canvasController->proxyObject, SIGNAL(moveDocumentOffset(const QPoint&)), d->canvas, SLOT(slotSetDocumentOffset(const QPoint&))); if (shell()) { KoPADocumentStructureDockerFactory structureDockerFactory( KoDocumentSectionView::ThumbnailMode, d->doc->pageType() ); d->documentStructureDocker = qobject_cast<KoPADocumentStructureDocker*>( shell()->createDockWidget( &structureDockerFactory ) ); connect( shell()->partManager(), SIGNAL( activePartChanged( KParts::Part * ) ), d->documentStructureDocker, SLOT( setPart( KParts::Part * ) ) ); connect(d->documentStructureDocker, SIGNAL(pageChanged(KoPAPageBase*)), proxyObject, SLOT(updateActivePage(KoPAPageBase*))); connect(d->documentStructureDocker, SIGNAL(dockerReset()), this, SLOT(reinitDocumentDocker())); KoToolManager::instance()->requestToolActivation( d->canvasController ); } }