Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add message box with keybindings bound to '?' key. #29

Merged
merged 3 commits into from Feb 8, 2015
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 5 additions & 2 deletions docs/dspdfviewer.1
Expand Up @@ -136,7 +136,7 @@ Toggle blanking of the audience screen
Go to specific page (a number entry window will pop up)
.TP
.B Home (also called Pos 1 on some keyboards), H
Go to first page and
Go to first page and
.B reset the presentation and the slide clock to zero
.TP
.B Escape, Q
Expand All @@ -152,10 +152,13 @@ Switch secondary screen's function
(Use this if you want to see the audience side on your screen, without
showing the notes to the audience. Pressing the button again will
switch back to normal operation.)
.TP
.B ?
Show message box with the available keybindings.

.SH SEE ALSO
.BR /usr/share/doc/latex-beamer/beameruserguide.pdf.gz
from the
from the
.B latex-beamer
package.

Expand Down
64 changes: 44 additions & 20 deletions pdfviewerwindow.cpp
Expand Up @@ -26,6 +26,7 @@
#include <QMouseEvent>
#include <QDebug>
#include <QInputDialog>
#include <QMessageBox>

void PDFViewerWindow::setMonitor(const unsigned int monitor)
{
Expand All @@ -41,7 +42,7 @@ unsigned int PDFViewerWindow::getMonitor() const
return m_monitor;
}

PDFViewerWindow::PDFViewerWindow(unsigned int monitor, PagePart myPart, bool showInformationLine, const RuntimeConfiguration& r, const QString& windowRole, bool enabled):
PDFViewerWindow::PDFViewerWindow(unsigned int monitor, PagePart myPart, bool showInformationLine, const RuntimeConfiguration& r, const QString& windowRole, bool enabled):
QWidget(),
m_enabled(enabled),
m_monitor(monitor),
Expand Down Expand Up @@ -85,9 +86,9 @@ void PDFViewerWindow::reposition()
move(rect.topLeft());
resize( rect.size() );
this->showFullScreen();
/* Note: The focus should be on the primary window, because at least
/* Note: The focus should be on the primary window, because at least
* Gnome draws the primary window's border onto the secondary.
*
*
* I dont mind the border on my helper screen, but the
* audience shouldnt see it.
*/
Expand All @@ -110,7 +111,7 @@ void PDFViewerWindow::displayImage(QImage image)
currentImage= image;
imageLabel->setPixmap(QPixmap::fromImage(image));
//imageArea->setWidgetResizable(true);

/*
if ( geometry().size() != getTargetImageSize() )
reposition();
Expand All @@ -121,7 +122,7 @@ void PDFViewerWindow::displayImage(QImage image)
void PDFViewerWindow::wheelEvent(QWheelEvent* e)
{
// QWidget::wheelEvent(e);

if ( e->delta() > 0 )
{
qDebug() << "Back";
Expand All @@ -136,9 +137,12 @@ void PDFViewerWindow::wheelEvent(QWheelEvent* e)
void PDFViewerWindow::keyPressEvent(QKeyEvent* e)
{
QWidget::keyPressEvent(e);

switch( e->key() )
{
case Qt::Key_Question:
keybindingsPopup();
break;
case Qt::Key_G:
changePageNumberDialog();
break;
Expand Down Expand Up @@ -243,16 +247,16 @@ void PDFViewerWindow::renderedPageIncoming(QSharedPointer< RenderedPage > render
// If we are not waiting for an image, ignore incoming answers.
if ( correntImageRendered )
return;

if ( renderedPage->getPageNumber() != this->currentPageNumber )
return; // This page is not for us. Ignore it.

if ( renderedPage->getPart() != this->myPart )
return; // This is not our part

// There is an image incoming that might fit.
displayImage(renderedPage->getImage());

// It was even the right size! Yeah!
if ( renderedPage->getIdentifier().requestedPageSize() == getTargetImageSize() ) {
this->correntImageRendered= true;
Expand All @@ -262,21 +266,21 @@ void PDFViewerWindow::renderedPageIncoming(QSharedPointer< RenderedPage > render
void PDFViewerWindow::showLoadingScreen(int pageNumberToWaitFor)
{
if ( !m_enabled )
return;
return;

/// FIXME Loading image

this->currentPageNumber = pageNumberToWaitFor;
this->correntImageRendered = false;
this->correntImageRendered = false;
this->currentImage = QImage();
imageLabel->setPixmap(QPixmap());
imageLabel->setText(QString("Loading page number %1").arg(pageNumberToWaitFor) );

/** Clear Thumbnails, they will come back in soon */
previousThumbnail->setPixmap( QPixmap() );
currentThumbnail->setPixmap( QPixmap() );
nextThumbnail->setPixmap( QPixmap() );

}


Expand All @@ -285,7 +289,7 @@ void PDFViewerWindow::renderedThumbnailIncoming(QSharedPointer< RenderedPage > r
{
if ( !m_enabled )
return;

/* If a thumbnail for the page we're waiting for is incoming and we have no page at all, its better than nothing */
if ( renderedThumbnail->getPageNumber() == currentPageNumber
&& currentImage.isNull() )
Expand All @@ -305,7 +309,7 @@ void PDFViewerWindow::renderedThumbnailIncoming(QSharedPointer< RenderedPage > r
}
displayImage(myHalf);
}

addThumbnail(renderedThumbnail->getPageNumber(), renderedThumbnail->getImage());
}

Expand All @@ -318,7 +322,7 @@ void PDFViewerWindow::resizeEvent(QResizeEvent* resizeEvent)
{
if ( !m_enabled )
return;

QWidget::resizeEvent(resizeEvent);
qDebug() << "Resize event" << resizeEvent;
qDebug() << "Resized from" << resizeEvent->oldSize() << "to" << resizeEvent->size() << ", requesting re-render.";
Expand Down Expand Up @@ -353,6 +357,28 @@ void PDFViewerWindow::updateWallClock(const QTime& wallClock)
this->wallClock->setText(timeToString(wallClock));
}

void PDFViewerWindow::keybindingsPopup()
{
QMessageBox *popup = new QMessageBox();
QString msg;
msg.append("<table>\n");
msg.append("<tr><th width=200 align=left>Key</th><th width=400 align=left>Action</th></tr>\n");
/* I skip some navigation bindings (they have to many alternatives) */
msg.append("<tr><td>N or Left/Down arrow</td><td>Next slide</td></tr>\n");
msg.append("<tr><td>P or RIght/Up arrow</td><td>Previous slide</td></tr>\n");
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo: RIght

msg.append("<tr><td>B or .</td><td>Blank/Unblank audience screen</td></tr>\n");
msg.append("<tr><td>G</td><td>Go to specific slide</td></tr>\n");
msg.append("<tr><td>H or Home</td><td>Go to first page and reset counters</td></tr>\n");
msg.append("<tr><td>Q or Esc</td><td>Quit</td></tr>\n");
msg.append("<tr><td>S or F12</td><td>Switch primary and secondary screens</td></tr>\n");
msg.append("<tr><td>T</td><td>Toggle between notes and slides in the secondary screen</td></tr>\n");
msg.append("<tr><td>?</td><td>Show that help box</td></tr>\n");
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe "this" help box would be better since the user is already on it

msg.append("</table>");
popup->setWindowTitle(QString("Keybindings"));
popup->setText(msg);
popup->show();
}

void PDFViewerWindow::changePageNumberDialog()
{
bool ok;
Expand Down Expand Up @@ -415,5 +441,3 @@ void PDFViewerWindow::setMyPagePart(const PagePart& newPagePart)


#include "pdfviewerwindow.moc"


65 changes: 33 additions & 32 deletions pdfviewerwindow.h
Expand Up @@ -28,7 +28,7 @@
#include "ui_pdfviewerwindow.h"

/** Shared base class for both windows (primary and secondary)
*
*
*/
class PDFViewerWindow : public QWidget, private Ui::Form
{
Expand All @@ -38,96 +38,97 @@ class PDFViewerWindow : public QWidget, private Ui::Form
unsigned int m_monitor;
QImage currentImage;
bool blank;

bool informationLineVisible;

uint currentPageNumber;
uint minimumPageNumber;
uint maximumPageNumber;
bool correntImageRendered;
PagePart myPart;

/** Display this image
*/
void displayImage(QImage image);

virtual void wheelEvent(QWheelEvent* e);

virtual void keyPressEvent(QKeyEvent* e);

virtual void mousePressEvent(QMouseEvent* e);

void addThumbnail(uint pageNumber, QImage thumbnail);


QString timeToString(const QTime& time) const;
QString timeToString(int milliseconds) const;


void keybindingsPopup();
void changePageNumberDialog();

public:
/** Standard constructor
* @param monitor monitor to start on (usually 0 for primary)
* @param dspdfviewer Pointer to the application (to handle next/prev commands)
*/
explicit PDFViewerWindow(unsigned int monitor, PagePart myPart, bool showInformationLine, const RuntimeConfiguration& r, const QString& windowRole, bool enabled=true);

/** Sets the monitor to display this window on
* Automatically calls reposition
*/
void setMonitor(const unsigned int monitor);

/** Gets the current monitor setting
*/
unsigned int getMonitor() const;

/** Reposition the window (for example after a monitor change)
*/
void reposition();

QSize getTargetImageSize() const;

PagePart getMyPagePart() const;

void showInformationLine();

void hideInformationLine();

bool isInformationLineVisible() const;

bool isBlank() const;

void showLoadingScreen(int pageNumberToWaitFor);

public slots:
void renderedPageIncoming( QSharedPointer<RenderedPage> renderedPage);
void renderedThumbnailIncoming( QSharedPointer<RenderedPage> renderedThumbnail);

void resizeEvent(QResizeEvent* resizeEvent);

void updateWallClock(const QTime& wallClock);
void updateSlideClock(const QTime& slideClock);
void updatePresentationClock(const QTime& presentationClock);

void setPageNumberLimits(uint minimumPageNumber, uint maximumPageNumber);

void setBlank(const bool blank);

void setMyPagePart(const PagePart& newPagePart);

signals:
void nextPageRequested();
void previousPageRequested();
void pageRequested(unsigned requestedPageNumber);
void restartRequested();

void screenSwapRequested();

void rerenderRequested();

void quitRequested();
void secondScreenFunctionToggleRequested();

void blankToggleRequested();
};

Expand Down