Save/restore toolbar visibility in settings.
This commit is contained in:
+52
-24
@@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
#include "MainWindow.h"
|
#include "MainWindow.h"
|
||||||
|
|
||||||
|
#include <QSettings>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
@@ -39,12 +40,15 @@ namespace gLabels
|
|||||||
createActions();
|
createActions();
|
||||||
createMenus();
|
createMenus();
|
||||||
createToolBars();
|
createToolBars();
|
||||||
|
|
||||||
|
readSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MainWindow::closeEvent( QCloseEvent *event )
|
void MainWindow::closeEvent( QCloseEvent *event )
|
||||||
{
|
{
|
||||||
std::cout << "CLOSE EVENT" << std::endl;
|
std::cout << "CLOSE EVENT" << std::endl;
|
||||||
|
writeSettings();
|
||||||
event->accept();
|
event->accept();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -162,27 +166,23 @@ namespace gLabels
|
|||||||
/* View actions */
|
/* View actions */
|
||||||
viewFileToolBarAction = new QAction( tr("File"), this );
|
viewFileToolBarAction = new QAction( tr("File"), this );
|
||||||
viewFileToolBarAction->setCheckable( true );
|
viewFileToolBarAction->setCheckable( true );
|
||||||
viewFileToolBarAction->setChecked( true );
|
|
||||||
viewFileToolBarAction->setStatusTip( tr("Change visibility of file toolbar in current window") );
|
viewFileToolBarAction->setStatusTip( tr("Change visibility of file toolbar in current window") );
|
||||||
connect( viewFileToolBarAction, SIGNAL(triggered()), this, SLOT(viewFileToolBar()) );
|
connect( viewFileToolBarAction, SIGNAL(triggered(bool)), this, SLOT(viewFileToolBar(bool)) );
|
||||||
|
|
||||||
viewObjectsToolBarAction = new QAction( tr("Objects"), this );
|
viewObjectsToolBarAction = new QAction( tr("Objects"), this );
|
||||||
viewObjectsToolBarAction->setCheckable( true );
|
viewObjectsToolBarAction->setCheckable( true );
|
||||||
viewObjectsToolBarAction->setChecked( true );
|
|
||||||
viewObjectsToolBarAction->setStatusTip( tr("Change visibility of objects toolbar in current window") );
|
viewObjectsToolBarAction->setStatusTip( tr("Change visibility of objects toolbar in current window") );
|
||||||
connect( viewObjectsToolBarAction, SIGNAL(triggered()), this, SLOT(viewObjectsToolBar()) );
|
connect( viewObjectsToolBarAction, SIGNAL(triggered(bool)), this, SLOT(viewObjectsToolBar(bool)) );
|
||||||
|
|
||||||
viewEditToolBarAction = new QAction( tr("Edit"), this );
|
viewEditToolBarAction = new QAction( tr("Edit"), this );
|
||||||
viewEditToolBarAction->setCheckable( true );
|
viewEditToolBarAction->setCheckable( true );
|
||||||
viewEditToolBarAction->setChecked( true );
|
|
||||||
viewEditToolBarAction->setStatusTip( tr("Change visibility of edit toolbar in current window") );
|
viewEditToolBarAction->setStatusTip( tr("Change visibility of edit toolbar in current window") );
|
||||||
connect( viewEditToolBarAction, SIGNAL(triggered()), this, SLOT(viewEditToolBar()) );
|
connect( viewEditToolBarAction, SIGNAL(triggered(bool)), this, SLOT(viewEditToolBar(bool)) );
|
||||||
|
|
||||||
viewViewToolBarAction = new QAction( tr("View"), this );
|
viewViewToolBarAction = new QAction( tr("View"), this );
|
||||||
viewViewToolBarAction->setCheckable( true );
|
viewViewToolBarAction->setCheckable( true );
|
||||||
viewViewToolBarAction->setChecked( true );
|
|
||||||
viewViewToolBarAction->setStatusTip( tr("Change visibility of view toolbar in current window") );
|
viewViewToolBarAction->setStatusTip( tr("Change visibility of view toolbar in current window") );
|
||||||
connect( viewViewToolBarAction, SIGNAL(triggered()), this, SLOT(viewViewToolBar()) );
|
connect( viewViewToolBarAction, SIGNAL(triggered(bool)), this, SLOT(viewViewToolBar(bool)) );
|
||||||
|
|
||||||
viewGridAction = new QAction( tr("Grid"), this );
|
viewGridAction = new QAction( tr("Grid"), this );
|
||||||
viewGridAction->setCheckable( true );
|
viewGridAction->setCheckable( true );
|
||||||
@@ -434,7 +434,6 @@ namespace gLabels
|
|||||||
fileToolBar->addAction( fileSaveAction );
|
fileToolBar->addAction( fileSaveAction );
|
||||||
fileToolBar->addSeparator();
|
fileToolBar->addSeparator();
|
||||||
fileToolBar->addAction( filePrintAction );
|
fileToolBar->addAction( filePrintAction );
|
||||||
/* TODO: restore visibility from saved state. */
|
|
||||||
|
|
||||||
objectsToolBar = addToolBar( tr("&Objects") );
|
objectsToolBar = addToolBar( tr("&Objects") );
|
||||||
objectsToolBar->addAction( objectsArrowModeAction );
|
objectsToolBar->addAction( objectsArrowModeAction );
|
||||||
@@ -447,20 +446,53 @@ namespace gLabels
|
|||||||
objectsToolBar->addAction( objectsCreateBarcodeAction );
|
objectsToolBar->addAction( objectsCreateBarcodeAction );
|
||||||
objectsToolBar->addSeparator();
|
objectsToolBar->addSeparator();
|
||||||
objectsToolBar->addAction( objectsMergePropertiesAction );
|
objectsToolBar->addAction( objectsMergePropertiesAction );
|
||||||
/* TODO: restore visibility from saved state. */
|
|
||||||
|
|
||||||
editToolBar = addToolBar( tr("&Edit") );
|
editToolBar = addToolBar( tr("&Edit") );
|
||||||
editToolBar->addAction( editCutAction );
|
editToolBar->addAction( editCutAction );
|
||||||
editToolBar->addAction( editCopyAction );
|
editToolBar->addAction( editCopyAction );
|
||||||
editToolBar->addAction( editPasteAction );
|
editToolBar->addAction( editPasteAction );
|
||||||
/* TODO: restore visibility from saved state. */
|
|
||||||
|
|
||||||
viewToolBar = addToolBar( tr("&View") );
|
viewToolBar = addToolBar( tr("&View") );
|
||||||
viewToolBar->addAction( viewZoomInAction );
|
viewToolBar->addAction( viewZoomInAction );
|
||||||
viewToolBar->addAction( viewZoomOutAction );
|
viewToolBar->addAction( viewZoomOutAction );
|
||||||
viewToolBar->addAction( viewZoom1to1Action );
|
viewToolBar->addAction( viewZoom1to1Action );
|
||||||
viewToolBar->addAction( viewZoomToFitAction );
|
viewToolBar->addAction( viewZoomToFitAction );
|
||||||
/* TODO: restore visibility from saved state. */
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void MainWindow::readSettings()
|
||||||
|
{
|
||||||
|
QSettings settings;
|
||||||
|
|
||||||
|
settings.beginGroup( "MainWindow" );
|
||||||
|
bool showFileToolBar = settings.value( "showFileToolBar", true ).toBool();
|
||||||
|
bool showObjectsToolBar = settings.value( "showObjectsToolBar", true ).toBool();
|
||||||
|
bool showEditToolBar = settings.value( "showEditToolBar", true ).toBool();
|
||||||
|
bool showViewToolBar = settings.value( "showViewToolBar", true ).toBool();
|
||||||
|
settings.endGroup();
|
||||||
|
|
||||||
|
viewFileToolBarAction->setChecked( showFileToolBar );
|
||||||
|
viewObjectsToolBarAction->setChecked( showObjectsToolBar );
|
||||||
|
viewEditToolBarAction->setChecked( showEditToolBar );
|
||||||
|
viewViewToolBarAction->setChecked( showViewToolBar );
|
||||||
|
|
||||||
|
fileToolBar->setVisible( showFileToolBar );
|
||||||
|
objectsToolBar->setVisible( showObjectsToolBar );
|
||||||
|
editToolBar->setVisible( showEditToolBar );
|
||||||
|
viewToolBar->setVisible( showViewToolBar );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void MainWindow::writeSettings()
|
||||||
|
{
|
||||||
|
QSettings settings;
|
||||||
|
|
||||||
|
settings.beginGroup( "MainWindow" );
|
||||||
|
settings.setValue( "showFileToolBar", viewFileToolBarAction->isChecked() );
|
||||||
|
settings.setValue( "showObjectsToolBar", viewObjectsToolBarAction->isChecked() );
|
||||||
|
settings.setValue( "showEditToolBar", viewEditToolBarAction->isChecked() );
|
||||||
|
settings.setValue( "showViewToolBar", viewViewToolBarAction->isChecked() );
|
||||||
|
settings.endGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -572,31 +604,27 @@ namespace gLabels
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MainWindow::viewFileToolBar()
|
void MainWindow::viewFileToolBar( bool state )
|
||||||
{
|
{
|
||||||
fileToolBar->setVisible( viewFileToolBarAction->isChecked() );
|
fileToolBar->setVisible( state );
|
||||||
/* TODO: save state. */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MainWindow::viewObjectsToolBar()
|
void MainWindow::viewObjectsToolBar( bool state )
|
||||||
{
|
{
|
||||||
objectsToolBar->setVisible( viewObjectsToolBarAction->isChecked() );
|
objectsToolBar->setVisible( state );
|
||||||
/* TODO: save state. */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MainWindow::viewEditToolBar()
|
void MainWindow::viewEditToolBar( bool state )
|
||||||
{
|
{
|
||||||
editToolBar->setVisible( viewEditToolBarAction->isChecked() );
|
editToolBar->setVisible( state );
|
||||||
/* TODO: save state. */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MainWindow::viewViewToolBar()
|
void MainWindow::viewViewToolBar( bool state )
|
||||||
{
|
{
|
||||||
viewToolBar->setVisible( viewViewToolBarAction->isChecked() );
|
viewToolBar->setVisible( state );
|
||||||
/* TODO: save state. */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+7
-4
@@ -65,10 +65,10 @@ namespace gLabels
|
|||||||
void editUnSelectAll();
|
void editUnSelectAll();
|
||||||
void editPreferences();
|
void editPreferences();
|
||||||
|
|
||||||
void viewFileToolBar();
|
void viewFileToolBar( bool );
|
||||||
void viewObjectsToolBar();
|
void viewObjectsToolBar( bool );
|
||||||
void viewEditToolBar();
|
void viewEditToolBar( bool );
|
||||||
void viewViewToolBar();
|
void viewViewToolBar( bool );
|
||||||
void viewGrid();
|
void viewGrid();
|
||||||
void viewMarkup();
|
void viewMarkup();
|
||||||
void viewZoomIn();
|
void viewZoomIn();
|
||||||
@@ -108,6 +108,9 @@ namespace gLabels
|
|||||||
void createMenus();
|
void createMenus();
|
||||||
void createToolBars();
|
void createToolBars();
|
||||||
|
|
||||||
|
void readSettings();
|
||||||
|
void writeSettings();
|
||||||
|
|
||||||
QMenu *fileMenu;
|
QMenu *fileMenu;
|
||||||
QMenu *editMenu;
|
QMenu *editMenu;
|
||||||
QMenu *viewMenu;
|
QMenu *viewMenu;
|
||||||
|
|||||||
@@ -31,6 +31,10 @@ int main( int argc, char **argv )
|
|||||||
{
|
{
|
||||||
QApplication app( argc, argv );
|
QApplication app( argc, argv );
|
||||||
|
|
||||||
|
QCoreApplication::setOrganizationName( "glabels.org" );
|
||||||
|
QCoreApplication::setOrganizationDomain( "glabels.org" );
|
||||||
|
QCoreApplication::setApplicationName( "glabels-qt" );
|
||||||
|
|
||||||
MainWindow mainWin;
|
MainWindow mainWin;
|
||||||
mainWin.show();
|
mainWin.show();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user