diff --git a/app/MainWindow.cpp b/app/MainWindow.cpp index 879c3a8..256121a 100644 --- a/app/MainWindow.cpp +++ b/app/MainWindow.cpp @@ -21,7 +21,8 @@ #include "MainWindow.h" #include -#include +#include +#include #include @@ -40,6 +41,7 @@ namespace gLabels createActions(); createMenus(); createToolBars(); + createStatusBar(); setDocVerbsEnabled( false ); setPasteVerbsEnabled( false ); @@ -463,6 +465,27 @@ namespace gLabels } + void MainWindow::createStatusBar() + { + zoomInfoLabel = new QLabel( " 999% " ); + zoomInfoLabel->setAlignment( Qt::AlignHCenter ); + zoomInfoLabel->setMinimumSize( zoomInfoLabel->sizeHint() ); + zoomInfoLabel->setFrameStyle( QFrame::Panel | QFrame::Sunken ); + + cursorInfoLabel = new QLabel; + cursorInfoLabel->setIndent( 3 ); + cursorInfoLabel->setFrameStyle( QFrame::Panel | QFrame::Sunken ); + + statusBar()->addWidget( zoomInfoLabel ); + statusBar()->addWidget( cursorInfoLabel, 1 ); + + updateZoomInfo( 1, false, false ); + updateCursorInfo(); + + /* TODO: connect cursor and zoom signals to appropriate slots. */ + } + + /* * Set enabled state of actions associated with a document. */ @@ -920,5 +943,29 @@ namespace gLabels Help::displayAbout( this ); } + + void MainWindow::updateZoomInfo( double zoom, bool min_flag, bool max_flag ) + { + zoomInfoLabel->setText( QString( " %1% " ).arg(100*zoom, 0, 'f', 0) ); + + viewZoomInAction->setEnabled( !max_flag ); + viewZoomOutAction->setEnabled( !min_flag ); + } + + + void MainWindow::updateCursorInfo( double x, double y ) + { + /* TODO: convert x,y to locale units and set precision accordingly. */ + cursorInfoLabel->setText( QString( "%1, %2" ).arg(x).arg(y) ); + } + + + /* Clears cursor info. E.g. when pointer exits view. */ + void MainWindow::updateCursorInfo() + { + cursorInfoLabel->setText( "" ); + } + + } diff --git a/app/MainWindow.h b/app/MainWindow.h index aead3af..e4d32f4 100644 --- a/app/MainWindow.h +++ b/app/MainWindow.h @@ -27,6 +27,7 @@ #include #include #include +#include namespace gLabels @@ -102,11 +103,16 @@ namespace gLabels void helpContents(); void helpAbout(); + void updateZoomInfo( double, bool, bool ); + void updateCursorInfo(); + void updateCursorInfo( double, double ); + private: void createActions(); void createMenus(); void createToolBars(); + void createStatusBar(); void setDocVerbsEnabled( bool ); void setDocModifiedVerbsEnabled( bool ); @@ -134,6 +140,9 @@ namespace gLabels QToolBar *editToolBar; QToolBar *viewToolBar; + QLabel *zoomInfoLabel; + QLabel *cursorInfoLabel; + QAction *fileNewAction; QAction *fileOpenAction; QAction *fileSaveAction;