KarbonSmallStylePreview::KarbonSmallStylePreview(QWidget* parent) : QWidget(parent) { setFont(KGlobalSettings::smallestReadableFont()); /* Create widget layout */ QHBoxLayout *layout = new QHBoxLayout(this); QLabel * strokeLabel = new QLabel(i18n("Stroke:"), this); strokeLabel->setMinimumHeight(FRAMEHEIGHT); m_strokeFrame = new KarbonStrokeStyleWidget(this); m_strokeFrame->setMinimumSize(QSize(FRAMEWIDTH, FRAMEHEIGHT)); QLabel * fillLabel = new QLabel(i18n("Fill:"), this); fillLabel->setMinimumHeight(FRAMEHEIGHT); m_fillFrame = new KarbonFillStyleWidget(this); m_fillFrame->setMinimumSize(QSize(FRAMEWIDTH, FRAMEHEIGHT)); layout->addWidget(strokeLabel); layout->addWidget(m_strokeFrame); layout->addWidget(fillLabel); layout->addWidget(m_fillFrame); layout->setContentsMargins(0, 0, 0, 0); setLayout(layout); connect(KoToolManager::instance(), SIGNAL(changedCanvas(const KoCanvasBase *)), this, SLOT(canvasChanged(const KoCanvasBase *))); connect(m_strokeFrame, SIGNAL(clicked()), this, SIGNAL(strokeApplied())); connect(m_fillFrame, SIGNAL(clicked()), this, SIGNAL(fillApplied())); }
KarbonView::KarbonView( KarbonPart* p, QWidget* parent ) : KoView( p, parent ), KXMLGUIBuilder( shell() ), d( new Private( p ) ) { debugView("KarbonView::KarbonView"); setComponentData( KarbonFactory::componentData(), true ); setClientBuilder( this ); if( !p->isReadWrite() ) setXMLFile( QString::fromLatin1( "karbon_readonly.rc" ) ); else setXMLFile( QString::fromLatin1( "karbon.rc" ) ); const int viewMargin = 250; d->canvas = new KarbonCanvas( p ); d->canvas->setParent( this ); d->canvas->setDocumentViewMargin( viewMargin ); connect( d->canvas->shapeManager()->selection(), SIGNAL( selectionChanged() ), this, SLOT( selectionChanged() ) ); d->canvasController = new KoCanvasController(this); d->canvasController->setMinimumSize( QSize(viewMargin+50,viewMargin+50) ); d->canvasController->setCanvas(d->canvas); d->canvasController->setCanvasMode( KoCanvasController::Infinite ); // always show srollbars which fixes some nasty infinite // recursion when scrollbars are disabled during resizing d->canvasController->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOn ); d->canvasController->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOn ); d->canvasController->show(); // set up status bar message d->status = new QLabel( QString(), statusBar() ); 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->cursorCoords = new QLabel( QString(), statusBar() ); d->cursorCoords->setAlignment( Qt::AlignLeft | Qt::AlignVCenter ); d->cursorCoords->setMinimumWidth( 50 ); addStatusBarItem( d->cursorCoords, 0 ); // TODO maybe the zoomHandler should be a member of the view and not the canvas. // set up the zoom controller KarbonZoomController * zoomController = new KarbonZoomController( d->canvasController, actionCollection() ); zoomController->setPageSize( d->part->document().pageSize() ); addStatusBarItem( zoomController->zoomAction()->createWidget( statusBar() ), 0 ); zoomController->setZoomMode( KoZoomMode::ZOOM_PAGE ); connect( zoomController, SIGNAL(zoomedToSelection()), this, SLOT(zoomSelection())); connect( zoomController, SIGNAL(zoomedToAll()), this, SLOT(zoomDrawing())); KarbonSmallStylePreview * smallPreview = new KarbonSmallStylePreview( statusBar() ); connect( smallPreview, SIGNAL(fillApplied()), this, SLOT(applyFillToSelection()) ); connect( smallPreview, SIGNAL(strokeApplied()), this, SLOT(applyStrokeToSelection()) ); addStatusBarItem( smallPreview, 0 ); // layout: QGridLayout *layout = new QGridLayout(); layout->setMargin(0); layout->addWidget(d->canvasController, 1, 1); initActions(); unsigned int max = part()->maxRecentFiles(); setNumberOfRecentFiles( max ); // widgets: d->horizRuler = new KoRuler( this, Qt::Horizontal, d->canvas->viewConverter() ); d->horizRuler->setShowMousePosition(true); d->horizRuler->setUnit(p->unit()); d->horizRuler->setRightToLeft(false); d->horizRuler->setVisible(false); new KoRulerController( d->horizRuler, d->canvas->resourceProvider() ); layout->addWidget( d->horizRuler, 0, 1 ); connect( p, SIGNAL( unitChanged( KoUnit ) ), this, SLOT( updateUnit( KoUnit ) ) ); d->vertRuler = new KoRuler( this, Qt::Vertical, d->canvas->viewConverter() ); d->vertRuler->setShowMousePosition(true); d->vertRuler->setUnit(p->unit()); d->vertRuler->setVisible(false); layout->addWidget( d->vertRuler, 1, 0 ); connect( d->canvas, SIGNAL(documentOriginChanged( const QPoint &)), this, SLOT(pageOffsetChanged())); connect( d->canvasController, SIGNAL(canvasOffsetXChanged(int)), this, SLOT(pageOffsetChanged())); connect( d->canvasController, SIGNAL(canvasOffsetYChanged(int)), this, SLOT(pageOffsetChanged())); connect( d->canvasController, SIGNAL(canvasMousePositionChanged(const QPoint &)), this, SLOT(mousePositionChanged(const QPoint&))); connect( d->vertRuler, SIGNAL(guideLineCreated(Qt::Orientation,int)), d->canvasController, SLOT( addGuideLine(Qt::Orientation,int) ) ); connect( d->horizRuler, SIGNAL(guideLineCreated(Qt::Orientation,int)), d->canvasController, SLOT( addGuideLine(Qt::Orientation,int) ) ); updateRuler(); if( shell() ) { KoToolManager::instance()->addController( d->canvasController ); KoToolManager::instance()->registerTools( actionCollection(), d->canvasController ); // set the first layer active d->canvasController->canvas()->shapeManager()->selection()->setActiveLayer( part()->document().layers().first() ); //Create Dockers createLayersTabDock(); KoToolBoxFactory toolBoxFactory(d->canvasController, i18n( "Tools" ) ); createDockWidget( &toolBoxFactory ); KoDockerManager *dockerMng = dockerManager(); if (!dockerMng) { dockerMng = new KoDockerManager(this); setDockerManager(dockerMng); } connect( d->canvasController, SIGNAL( toolOptionWidgetsChanged(const QMap<QString, QWidget *> &, KoView *) ), dockerMng, SLOT( newOptionWidgets(const QMap<QString, QWidget *> &, KoView *) ) ); KoToolManager::instance()->requestToolActivation( d->canvasController ); bool b = d->showRulerAction->isChecked(); d->horizRuler->setVisible( b ); d->vertRuler->setVisible( b ); } setLayout(layout); reorganizeGUI(); setFocusPolicy(Qt::NoFocus); }