Skip to content
Permalink
Browse files
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 2554f172406efb713d70fe23143a7745afdda52f
@@ -5141,6 +5141,7 @@ void QgisApp::showBookmarks()
{
bookmarks = new QgsBookmarks(this, Qt::WindowMinMaxButtonsHint);
}
bookmarks->restorePosition();
bookmarks->show();
bookmarks->raise();
bookmarks->setActiveWindow();
@@ -36,6 +36,7 @@
#include <QMessageBox>
#include <QIcon>
#include <QPixmap>
#include <QSettings>
#include <QToolButton>

QgsAttributeTableDisplay::QgsAttributeTableDisplay(QgsVectorLayer* layer, QgisApp * qgisApp)
@@ -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()));
@@ -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();
@@ -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;
@@ -25,6 +25,7 @@
#include <QDir>
#include <QFileInfo>
#include <QMessageBox>
#include <QSettings>

//standard includes
#include <iostream>
@@ -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]
@@ -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()
{
@@ -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();
@@ -18,6 +18,7 @@
#include <iostream>
#include <qgsapplication.h>
#include <qstring.h>
#include <QSettings>
#include <QTextCodec>
#include <QTranslator>
#include "qgshelpserver.h"
@@ -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="";

@@ -24,6 +24,7 @@
#include <QApplication>
#include <QMessageBox>
#include <QFileInfo>
#include <QSettings>
#include <QTextCodec>
#include <QTextStream>
#include <QFile>
@@ -39,6 +40,7 @@ QgsHelpViewer::QgsHelpViewer(const QString &contextId, QWidget *parent,
: QDialog(parent, fl)
{
setupUi(this);
restorePosition();
loadContext(contextId);
}
QgsHelpViewer::~QgsHelpViewer()
@@ -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
*/
@@ -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);

0 comments on commit 2554f17

Please sign in to comment.