Exemplo n.º 1
0
void KPrPageLayoutDocker::slotActivePageChanged()
{
    Q_ASSERT( m_view );

    KPrPage * page = dynamic_cast<KPrPage*>( m_view->activePage() );
    if ( page ) {
        KPrPageLayout * layout = page->layout();
        QListWidgetItem * item = m_layout2item.value( layout, 0 );
        if ( item == 0 && layout != 0 && layout->type() == KPrPageLayout::Page ) {
            item = addLayout( layout );
        }

        if ( item ) {
            m_layoutsView->blockSignals( true );
            item->setSelected( true );
            m_layoutsView->blockSignals( false );
            m_layoutsView->scrollToItem( item );
        }
        else {
            QList<QListWidgetItem*> items = m_layoutsView->selectedItems();
            foreach ( QListWidgetItem * i, items ) {
                m_layoutsView->blockSignals( true );
                i->setSelected( false );
                m_layoutsView->blockSignals( false );
            }
        }
    }
Exemplo n.º 2
0
void KPrViewModeNotes::updateActivePage( KoPAPageBase *page )
{
    if ( m_view->activePage() != page ) {
        m_view->setActivePage( page );
    }

    KPrPage *prPage = dynamic_cast<KPrPage *>( page );
    if ( !prPage ) return;

    KPrNotes *notes = prPage->pageNotes();
    notes->updatePageThumbnail();
    KoShapeLayer* layer = dynamic_cast<KoShapeLayer*>( notes->childShapes().last() );

    KoPageLayout &layout = notes->pageLayout();
    QSize size(layout.width, layout.height);
    
    m_view->horizontalRuler()->setRulerLength(layout.width);
    m_view->verticalRuler()->setRulerLength(layout.height);
    m_view->horizontalRuler()->setActiveRange(layout.left, layout.width - layout.right);
    m_view->verticalRuler()->setActiveRange(layout.top, layout.height - layout.bottom);

    m_view->zoomController()->setPageSize(size);
    m_view->zoomController()->setDocumentSize(size);
    m_canvas->update();

    m_canvas->shapeManager()->setShapes( layer->childShapes() );
    m_canvas->masterShapeManager()->setShapes(QList<KoShape*>());

    KoSelection *selection = m_canvas->shapeManager()->selection();
    selection->select(notes->textShape());
    selection->setActiveLayer( layer );
    QString tool = KoToolManager::instance()->preferredToolForSelection(selection->selectedShapes());
    KoToolManager::instance()->switchToolRequested(tool);
}
Exemplo n.º 3
0
void KPrViewModeNotes::removeShape( KoShape *shape )
{
    KoShape *parent = shape;
    KPrNotes *notes = 0;
    while ( !notes && ( parent = parent->parent() ) ) {
        notes = dynamic_cast<KPrNotes *>( parent );
    }

    if ( notes ) {
        KPrPage *activePage = static_cast<KPrPage *>( m_view->activePage() );
        if ( notes == activePage->pageNotes() ) {
            m_view->kopaCanvas()->shapeManager()->remove( shape );
        }
    }
}
Exemplo n.º 4
0
void KPrViewModeNotes::addShape( KoShape *shape )
{
    KoShape *parent = shape;
    KPrNotes *notes = 0;
    // similar to KoPADocument::pageByShape()
    while ( !notes && ( parent = parent->parent() ) ) {
        notes = dynamic_cast<KPrNotes *>( parent );
    }

    if ( notes ) {
        KPrPage *activePage = static_cast<KPrPage *>( m_view->activePage() );
        if ( notes == activePage->pageNotes() ) {
            m_view->kopaCanvas()->shapeManager()->addShape( shape );
        }
    }
}
Exemplo n.º 5
0
void KPrAnimationDirector::updateActivePage( KoPAPageBase * page )
{
    deactivate();

    if ( m_canvas == m_view->kopaCanvas() ) {
        m_view->viewMode()->updateActivePage( page );
    }
    else {
        QList<KoShape*> shapes = page->shapes();
        m_canvas->shapeManager()->setShapes(shapes, KoShapeManager::AddWithoutRepaint);
        //Make the top most layer active
        if ( !shapes.isEmpty() ) {
            KoShapeLayer* layer = dynamic_cast<KoShapeLayer*>( shapes.last() );
            m_canvas->shapeManager()->selection()->setActiveLayer( layer );
        }

        // if the page is not a master page itself set shapes of the master page
        KoPAPage * paPage = dynamic_cast<KoPAPage *>( page );

        Q_ASSERT( paPage );
        KoPAMasterPage * masterPage = paPage->masterPage();
        QList<KoShape*> masterShapes = masterPage->shapes();
        m_canvas->masterShapeManager()->setShapes(masterShapes, KoShapeManager::AddWithoutRepaint);
        // Make the top most layer active
        if ( !masterShapes.isEmpty() ) {
            KoShapeLayer* layer = dynamic_cast<KoShapeLayer*>( masterShapes.last() );
            m_canvas->masterShapeManager()->selection()->setActiveLayer( layer );
        }
    }

    KPrPage * kprPage = dynamic_cast<KPrPage *>( page );
    Q_ASSERT( kprPage );
    if (m_pageIndex > m_pages.size() || m_pageIndex < 0) {
        m_pageIndex = m_pages.indexOf(page);
    }
    m_animations = kprPage->animations().steps();

    // it can be that the pages have different sizes. So we need to recalulate
    // the zoom when we change the page
    updateZoom( m_canvas->size() );
}
Exemplo n.º 6
0
KPrTransEffectDia::KPrTransEffectDia( QWidget *parent, const char *name,
                                    KPrDocument *_doc, KPrView *_view )
    : KDialogBase( parent, name, true, "", KDialogBase::User1|Ok|Cancel ),
      doc( _doc ), view( _view ), soundPlayer( 0 )
{
    enableButtonSeparator( true );

    QWidget *page = new QWidget( this );
    setMainWidget(page);

    QBoxLayout *topLayout = new QHBoxLayout( page, KDialog::marginHint(), KDialog::spacingHint() );
    QWidget* leftpart = new QWidget( page );
    topLayout->addWidget( leftpart );
    QWidget* rightpart = new QWidget( page );
    topLayout->addWidget( rightpart );

    // right-side of the dialog, for showing effect preview

    QVBoxLayout *rightlayout = new QVBoxLayout( rightpart, KDialog::marginHint(), KDialog::spacingHint() );
    rightlayout->setAutoAdd( true );

    effectPreview = new KPrEffectPreview( rightpart, doc, view );

    int pgnum = view->getCurrPgNum() - 1;  // getCurrPgNum() is 1-based
    KPrPage* pg = doc->pageList().at( pgnum );

    // pixmap for effect preview
    QRect rect= pg->getZoomPageRect();
    QPixmap pix( rect.size() );
    pix.fill( Qt::white );
    view->getCanvas()->drawPageInPix( pix, pgnum, 100 );
    effectPreview->setPixmap( pix );

    pageEffect = pg->getPageEffect();
    speed = pg->getPageEffectSpeed();

    QVBoxLayout *leftlayout = new QVBoxLayout( leftpart, KDialog::marginHint(), KDialog::spacingHint() );
    leftlayout->setAutoAdd( true );

    new QLabel( i18n("Effect:"), leftpart );

    effectList = new QListBox( leftpart );
    effectList->insertItem( i18n( "No Effect" ) );
    effectList->insertItem( i18n( "Close Horizontal" ) );
    effectList->insertItem( i18n( "Close Vertical" ) );
    effectList->insertItem( i18n( "Close From All Directions" ) );
    effectList->insertItem( i18n( "Open Horizontal" ) );
    effectList->insertItem( i18n( "Open Vertical" ) );
    effectList->insertItem( i18n( "Open From All Directions" ) );
    effectList->insertItem( i18n( "Interlocking Horizontal 1" ) );
    effectList->insertItem( i18n( "Interlocking Horizontal 2" ) );
    effectList->insertItem( i18n( "Interlocking Vertical 1" ) );
    effectList->insertItem( i18n( "Interlocking Vertical 2" ) );
    effectList->insertItem( i18n( "Surround 1" ) );
    effectList->insertItem( i18n( "Fly Away 1" ) );
    effectList->insertItem( i18n( "Blinds Horizontal" ) );
    effectList->insertItem( i18n( "Blinds Vertical" ) );
    effectList->insertItem( i18n( "Box In" ) );
    effectList->insertItem( i18n( "Box Out" ) );
    effectList->insertItem( i18n( "Checkerboard Across" ) );
    effectList->insertItem( i18n( "Checkerboard Down" ) );
    effectList->insertItem( i18n( "Cover Down" ) );
    effectList->insertItem( i18n( "Uncover Down" ) );
    effectList->insertItem( i18n( "Cover Up" ) );
    effectList->insertItem( i18n( "Uncover Up" ) );
    effectList->insertItem( i18n( "Cover Left" ) );
    effectList->insertItem( i18n( "Uncover Left" ) );
    effectList->insertItem( i18n( "Cover Right" ) );
    effectList->insertItem( i18n( "Uncover Right" ) );
    effectList->insertItem( i18n( "Cover Left-Up" ) );
    effectList->insertItem( i18n( "Uncover Left-Up" ) );
    effectList->insertItem( i18n( "Cover Left-Down" ) );
    effectList->insertItem( i18n( "Uncover Left-Down" ) );
    effectList->insertItem( i18n( "Cover Right-Up" ) );
    effectList->insertItem( i18n( "Uncover Right-Up" ) );
    effectList->insertItem( i18n( "Cover Right-Bottom" ) );
    effectList->insertItem( i18n( "Uncover Right-Bottom" ) );
    effectList->insertItem( i18n( "Dissolve" ) );
    effectList->insertItem( i18n( "Strips Left-Up" ) );
    effectList->insertItem( i18n( "Strips Left-Down" ) );
    effectList->insertItem( i18n( "Strips Right-Up" ) );
    effectList->insertItem( i18n( "Strips Right-Down" ) );
    effectList->insertItem( i18n( "Melting" ) );
    effectList->insertItem( i18n( "Random Transition" ) );
    effectList->setCurrentItem( static_cast<int>( pageEffect ) );

    // workaround, because Random Effect is always negative
    if( pageEffect == PEF_RANDOM )
        effectList->setCurrentItem( effectList->count()-1 );

    connect( effectList, SIGNAL(highlighted(int)), this, SLOT(effectChanged(int)) );
    connect( effectList, SIGNAL( doubleClicked ( QListBoxItem *) ), this, SLOT( effectChanged()) );

    new QLabel( i18n("Speed:"), leftpart );

    QWidget* sp = new QWidget( leftpart );
    QBoxLayout* speedLayout = new QHBoxLayout( sp, KDialog::marginHint(), KDialog::spacingHint() );
    speedLayout->setAutoAdd( true );

    speedCombo = new QComboBox( sp );
    speedCombo->insertItem(i18n("Slow") );
    speedCombo->insertItem(i18n("Medium") );
    speedCombo->insertItem(i18n("Fast") );


    speedCombo->setCurrentItem( speed );

    connect( speedCombo, SIGNAL(activated(int)), this, SLOT(speedChanged(int)) );


    QWidget* previewgrp = new QWidget( leftpart );
    QBoxLayout* previewLayout = new QHBoxLayout( previewgrp, KDialog::marginHint(), KDialog::spacingHint() );
    previewLayout->setAutoAdd( true );

    automaticPreview = new QCheckBox( i18n( "Automatic preview" ), previewgrp );
    automaticPreview->setChecked( true );

    QWidget* previewspacer = new QWidget( previewgrp );
    previewspacer->setSizePolicy( QSizePolicy( QSizePolicy::Expanding,
                                               QSizePolicy::Expanding ) );

    previewButton = new QPushButton( previewgrp );
    previewButton->setText( i18n("Preview") );
    connect( previewButton, SIGNAL(clicked()), this, SLOT(preview()) );

    QFrame* line = new QFrame( leftpart );
    line->setFrameStyle( QFrame::HLine | QFrame::Sunken );

    soundFileName = pg->getPageSoundFileName();
    soundEffect = pg->getPageSoundEffect();

    checkSoundEffect = new QCheckBox( i18n( "Sound effect" ), leftpart );
    checkSoundEffect->setChecked( soundEffect );
    connect( checkSoundEffect, SIGNAL( clicked() ), this, SLOT( soundEffectChanged() ) );

    QWidget* soundgrp = new QWidget( leftpart );
    QBoxLayout* soundLayout = new QHBoxLayout( soundgrp, KDialog::marginHint(), KDialog::spacingHint() );
    soundLayout->setAutoAdd( true );

    lSoundEffect = new QLabel( i18n( "File name:" ), soundgrp );
    requester = new KURLRequester( soundgrp );
    requester->setURL( soundFileName );
    connect( requester, SIGNAL( openFileDialog( KURLRequester * ) ),
             this, SLOT( slotRequesterClicked( KURLRequester * ) ) );
    connect( requester, SIGNAL( textChanged( const QString& ) ),
             this, SLOT( slotSoundFileChanged( const QString& ) ) );

    buttonTestPlaySoundEffect = new QPushButton( soundgrp );
    buttonTestPlaySoundEffect->setPixmap( BarIcon("1rightarrow", KIcon::SizeSmall) );
    QToolTip::add( buttonTestPlaySoundEffect, i18n("Play") );

    connect( buttonTestPlaySoundEffect, SIGNAL( clicked() ), this, SLOT( playSound() ) );

    buttonTestStopSoundEffect = new QPushButton( soundgrp );
    buttonTestStopSoundEffect->setPixmap( BarIcon("player_stop", KIcon::SizeSmall) );
    QToolTip::add( buttonTestStopSoundEffect, i18n("Stop") );

    connect( buttonTestStopSoundEffect, SIGNAL( clicked() ), this, SLOT( stopSound() ) );

    soundEffect = pg->getPageSoundEffect();
    setButtonText(KDialogBase::User1,i18n( "Apply &Global" ));

    slideTime = pg->getPageTimer();

    new QLabel( i18n("Automatically advance to the next slide after:"), rightpart );

    timeSlider = new KIntNumInput( slideTime, rightpart );
    timeSlider->setRange( 1, 600, 1 );
    timeSlider->setSuffix( i18n( " seconds" ) );
    connect( timeSlider, SIGNAL(valueChanged(int)), this, SLOT(timeChanged(int)) );

    QWidget* rspacer = new QWidget( rightpart );
    rspacer->setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Expanding ) );

    QWidget* lspacer = new QWidget( leftpart );
    lspacer->setMinimumSize( 10, spacingHint() );

    soundEffectChanged();
}