~ubuntu-branches/debian/sid/qpdfview/sid

« back to all changes in this revision

Viewing changes to sources/presentationview.cpp

  • Committer: Package Import Robot
  • Author(s): Benjamin Eltzner
  • Date: 2013-05-26 13:52:50 UTC
  • mfrom: (1.2.8)
  • Revision ID: package-import@ubuntu.com-20130526135250-s1rhw935iqd8fcfs
Tags: 0.4.3-1
* New upstream release.
* Added menu file and fetch xpm icon file in debian folder.

Show diffs side-by-side

added added

removed removed

Lines of Context:
57
57
    setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
58
58
    setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
59
59
 
60
 
    new QShortcut(QKeySequence(Qt::Key_Return), this, SLOT(jumpBackward()));
61
 
    new QShortcut(QKeySequence(Qt::SHIFT + Qt::Key_Return), this, SLOT(jumpForward()));
62
 
 
63
 
    new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_Left), this, SLOT(rotateLeft()));
64
 
    new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_Right), this, SLOT(rotateRight()));
65
 
 
66
 
    // pages
67
 
 
68
60
    setScene(new QGraphicsScene(this));
69
61
 
70
 
    for(int index = 0; index < m_pages.count(); ++index)
71
 
    {
72
 
        PageItem* page = new PageItem(m_pages.at(index), index, true);
73
 
 
74
 
        page->setPhysicalDpi(physicalDpiX(), physicalDpiY());
75
 
 
76
 
        scene()->addItem(page);
77
 
        m_pageItems.append(page);
78
 
 
79
 
        connect(page, SIGNAL(linkClicked(int,qreal,qreal)), SLOT(on_pages_linkClicked(int,qreal,qreal)));
80
 
    }
81
 
 
82
 
    scene()->setBackgroundBrush(QBrush(s_settings->pageItem().paperColor()));
 
62
    preparePages();
 
63
    prepareBackground();
83
64
 
84
65
    // prefetch
85
66
 
156
137
            page->setInvertColors(m_invertColors);
157
138
        }
158
139
 
159
 
        QColor backgroundColor = s_settings->pageItem().paperColor();
160
 
 
161
 
        if(m_invertColors)
162
 
        {
163
 
            backgroundColor.setRgb(~backgroundColor.rgb());
164
 
        }
165
 
 
166
 
        scene()->setBackgroundBrush(QBrush(backgroundColor));
 
140
        prepareBackground();
167
141
 
168
142
        emit invertColorsChanged(m_invertColors);
169
143
    }
310
284
 
311
285
void PresentationView::keyPressEvent(QKeyEvent* event)
312
286
{
313
 
    switch(event->key())
 
287
    switch(event->modifiers() + event->key())
314
288
    {
315
289
    case Qt::Key_PageUp:
316
290
    case Qt::Key_Up:
338
312
 
339
313
        event->accept();
340
314
        return;
 
315
    case Qt::CTRL + Qt::Key_Return:
 
316
        jumpBackward();
 
317
 
 
318
        event->accept();
 
319
        return;
 
320
    case Qt::CTRL + Qt::SHIFT + Qt::Key_Return:
 
321
        jumpForward();
 
322
 
 
323
        event->accept();
 
324
        return;
 
325
    case Qt::CTRL + Qt::Key_Left:
 
326
        rotateLeft();
 
327
 
 
328
        event->accept();
 
329
        return;
 
330
    case Qt::CTRL + Qt::Key_Right:
 
331
        rotateRight();
 
332
 
 
333
        event->accept();
 
334
        return;
 
335
    case Qt::CTRL + Qt::Key_I:
 
336
        setInvertColors(!invertColors());
 
337
 
 
338
        event->accept();
 
339
        return;
341
340
    case Qt::Key_F12:
342
341
    case Qt::Key_Escape:
343
342
        close();
346
345
        return;
347
346
    }
348
347
 
349
 
    if(event->modifiers() == Qt::ControlModifier && event->key() == Qt::Key_I)
350
 
    {
351
 
        setInvertColors(!invertColors());
352
 
 
353
 
        event->accept();
354
 
        return;
355
 
    }
356
 
 
357
348
    QWidget::keyPressEvent(event);
358
349
}
359
350
 
394
385
    QGraphicsView::wheelEvent(event);
395
386
}
396
387
 
 
388
void PresentationView::preparePages()
 
389
{
 
390
    for(int index = 0; index < m_pages.count(); ++index)
 
391
    {
 
392
        PageItem* page = new PageItem(m_pages.at(index), index, true);
 
393
 
 
394
        page->setPhysicalDpi(physicalDpiX(), physicalDpiY());
 
395
 
 
396
        scene()->addItem(page);
 
397
        m_pageItems.append(page);
 
398
 
 
399
        connect(page, SIGNAL(linkClicked(int,qreal,qreal)), SLOT(on_pages_linkClicked(int,qreal,qreal)));
 
400
    }
 
401
}
 
402
 
 
403
void PresentationView::prepareBackground()
 
404
{
 
405
    QColor backgroundColor = s_settings->pageItem().paperColor();
 
406
 
 
407
    if(m_invertColors)
 
408
    {
 
409
        backgroundColor.setRgb(~backgroundColor.rgb());
 
410
    }
 
411
 
 
412
    scene()->setBackgroundBrush(QBrush(backgroundColor));
 
413
}
 
414
 
397
415
void PresentationView::prepareScene()
398
416
{
399
417
    for(int index = 0; index < m_pageItems.count(); ++index)
400
418
    {
401
419
        PageItem* page = m_pageItems.at(index);
402
420
 
403
 
        qreal visibleWidth = viewport()->width();
404
 
        qreal visibleHeight = viewport()->height();
 
421
        const qreal visibleWidth = viewport()->width();
 
422
        const qreal visibleHeight = viewport()->height();
405
423
 
406
424
        qreal pageWidth = 0.0;
407
425
        qreal pageHeight = 0.0;
421
439
            break;
422
440
        }
423
441
 
424
 
        qreal scaleFactor = qMin(visibleWidth / pageWidth, visibleHeight / pageHeight);
 
442
        const qreal scaleFactor = qMin(visibleWidth / pageWidth, visibleHeight / pageHeight);
425
443
 
426
444
        page->setScaleFactor(scaleFactor);
427
445
        page->setRotation(m_rotation);