Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Save and restore window position for AttributeTable, Bookmarks and He…
…lpViewer.

git-svn-id: http://svn.osgeo.org/qgis/trunk@7782 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
telwertowski committed Dec 14, 2007
1 parent 0d2c1e8 commit 2554f17
Show file tree
Hide file tree
Showing 8 changed files with 84 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/app/qgisapp.cpp
Expand Up @@ -5141,6 +5141,7 @@ void QgisApp::showBookmarks()
{
bookmarks = new QgsBookmarks(this, Qt::WindowMinMaxButtonsHint);
}
bookmarks->restorePosition();
bookmarks->show();
bookmarks->raise();
bookmarks->setActiveWindow();
Expand Down
15 changes: 15 additions & 0 deletions src/app/qgsattributetabledisplay.cpp
Expand Up @@ -36,6 +36,7 @@
#include <QMessageBox>
#include <QIcon>
#include <QPixmap>
#include <QSettings>
#include <QToolButton>

QgsAttributeTableDisplay::QgsAttributeTableDisplay(QgsVectorLayer* layer, QgisApp * qgisApp)
Expand All @@ -44,6 +45,7 @@ QgsAttributeTableDisplay::QgsAttributeTableDisplay(QgsVectorLayer* layer, QgisAp
mQgisApp(qgisApp)
{
setupUi(this);
restorePosition();
setTheme();
connect(mRemoveSelectionButton, SIGNAL(clicked()), this, SLOT(removeSelection()));
connect(mSelectedToTopButton, SIGNAL(clicked()), this, SLOT(selectedToTop()));
Expand Down Expand Up @@ -374,11 +376,24 @@ void QgsAttributeTableDisplay::doSearch(const QString& searchString)

void QgsAttributeTableDisplay::closeEvent(QCloseEvent* ev)
{
saveWindowLocation();
ev->ignore();
emit deleted();
delete this;
}

void QgsAttributeTableDisplay::restorePosition()
{
QSettings settings;
restoreGeometry(settings.value("/Windows/AttributeTable/geometry").toByteArray());
}

void QgsAttributeTableDisplay::saveWindowLocation()
{
QSettings settings;
settings.setValue("/Windows/AttributeTable/geometry", saveGeometry());
}

void QgsAttributeTableDisplay::on_btnHelp_clicked()
{
showHelp();
Expand Down
5 changes: 4 additions & 1 deletion src/app/qgsattributetabledisplay.h
Expand Up @@ -78,7 +78,10 @@ class QgsAttributeTableDisplay:public QDialog, private Ui::QgsAttributeTableBase
private:
/** Set the icon theme for this dialog */
void setTheme();


void restorePosition();
void saveWindowLocation();

QString mSearchString;

static const int context_id = 831088384;
Expand Down
15 changes: 14 additions & 1 deletion src/app/qgsbookmarks.cpp
Expand Up @@ -25,6 +25,7 @@
#include <QDir>
#include <QFileInfo>
#include <QMessageBox>
#include <QSettings>

//standard includes
#include <iostream>
Expand All @@ -37,7 +38,8 @@ QgsBookmarks::QgsBookmarks(QWidget *parent, Qt::WFlags fl)
mParent(parent)
{
setupUi(this);
connect(btnClose, SIGNAL(clicked()), this, SLOT(reject()));
connect(btnClose, SIGNAL(clicked()), this, SLOT(close()));
connect(this, SIGNAL(finished(int)), this, SLOT(saveWindowLocation()));

// user database is created at QGIS startup in QgisApp::createDB
// we just check whether there is our database [MD]
Expand Down Expand Up @@ -116,6 +118,17 @@ void QgsBookmarks::initialise()
}
}

void QgsBookmarks::restorePosition()
{
QSettings settings;
restoreGeometry(settings.value("/Windows/Bookmarks/geometry").toByteArray());
}

void QgsBookmarks::saveWindowLocation()
{
QSettings settings;
settings.setValue("/Windows/Bookmarks/geometry", saveGeometry());
}

void QgsBookmarks::on_btnDelete_clicked()
{
Expand Down
5 changes: 3 additions & 2 deletions src/app/qgsbookmarks.h
Expand Up @@ -30,13 +30,14 @@ class QgsBookmarks : public QDialog, private Ui::QgsBookmarksBase
public:
QgsBookmarks(QWidget *parent = 0, Qt::WFlags fl = 0);
~QgsBookmarks();
public slots:
void restorePosition();
private slots:
void saveWindowLocation();
void on_btnDelete_clicked();
void on_btnZoomTo_clicked();
void on_lstBookmarks_doubleClicked(Q3ListViewItem *);
void on_btnHelp_clicked();
void refreshBookmarks();

private:
QWidget *mParent;
void initialise();
Expand Down
7 changes: 7 additions & 0 deletions src/helpviewer/main.cpp
Expand Up @@ -18,6 +18,7 @@
#include <iostream>
#include <qgsapplication.h>
#include <qstring.h>
#include <QSettings>
#include <QTextCodec>
#include <QTranslator>
#include "qgshelpserver.h"
Expand All @@ -27,6 +28,12 @@
int main( int argc, char ** argv )
{
QgsApplication a( argc, argv, true );

// Set up the QSettings environment must be done after qapp is created
QCoreApplication::setOrganizationName("QuantumGIS");
QCoreApplication::setOrganizationDomain("qgis.org");
QCoreApplication::setApplicationName("qgis");

QString context = QString::null;
QString myTranslationCode="";

Expand Down
36 changes: 35 additions & 1 deletion src/helpviewer/qgshelpviewer.cpp
Expand Up @@ -24,6 +24,7 @@
#include <QApplication>
#include <QMessageBox>
#include <QFileInfo>
#include <QSettings>
#include <QTextCodec>
#include <QTextStream>
#include <QFile>
Expand All @@ -39,6 +40,7 @@ QgsHelpViewer::QgsHelpViewer(const QString &contextId, QWidget *parent,
: QDialog(parent, fl)
{
setupUi(this);
restorePosition();
loadContext(contextId);
}
QgsHelpViewer::~QgsHelpViewer()
Expand All @@ -50,13 +52,45 @@ void QgsHelpViewer::setContext(const QString &contextId)
setWindowState(windowState() & ~Qt::WindowMinimized);
#endif
raise();
setActiveWindow();
activateWindow();
loadContext(contextId);
}
void QgsHelpViewer::fileExit()
{
QApplication::exit();
}

/*
* Window geometry is saved during move and resize events rather then when
* the window is closed because HelpViewer is a subprocess which could be
* closed by the parent process invoking QProcess::terminate(). When this
* happens, the HelpViewer process receives the signal WM_CLOSE on Windows
* and SIGTERM on Mac and Unix. There is no way to catch these using Qt;
* OS specific code must be written. To avoid OS specific code, the window
* geometry is saved as it changes.
*/
void QgsHelpViewer::moveEvent(QMoveEvent *event)
{
saveWindowLocation();
}

void QgsHelpViewer::resizeEvent(QResizeEvent *event)
{
saveWindowLocation();
}

void QgsHelpViewer::restorePosition()
{
QSettings settings;
restoreGeometry(settings.value("/HelpViewer/geometry").toByteArray());
}

void QgsHelpViewer::saveWindowLocation()
{
QSettings settings;
settings.setValue("/HelpViewer/geometry", saveGeometry());
}

/*
* Read the help file and populate the viewer
*/
Expand Down
5 changes: 5 additions & 0 deletions src/helpviewer/qgshelpviewer.h
Expand Up @@ -31,7 +31,12 @@ class QgsHelpViewer : public QDialog, private Ui::QgsHelpViewerBase
public slots:
void setContext(const QString &contextId);
void fileExit();
protected:
void moveEvent(QMoveEvent *event);
void resizeEvent(QResizeEvent *event);
private:
void restorePosition();
void saveWindowLocation();
void loadContext(const QString &contextId);
void loadContextFromSqlite(const QString &contextId);
int connectDb(const QString &helpDbPath);
Expand Down

0 comments on commit 2554f17

Please sign in to comment.