From 027b9815b89ec82b7ff46115df1c5e2ce0ac1c4d Mon Sep 17 00:00:00 2001 From: Lubos Dolezel Date: Thu, 11 Jun 2015 15:54:22 +0200 Subject: Save window state/geometry, incl. main splitter (resolves #7) --- src/gui/gui.cpp | 11 +++++++---- src/gui/mphoneform.cpp | 8 ++++++++ src/gui/mphoneform.ui | 4 ++-- 3 files changed, 17 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index 9c9762f..737379b 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -70,6 +70,7 @@ #include "qstring.h" #include "qtextcodec.h" #include "qtooltip.h" +#include extern string user_host; extern pthread_t thread_id_main; @@ -77,6 +78,8 @@ extern pthread_t thread_id_main; // External command arguments extern t_command_args g_cmd_args; +extern QSettings* g_gui_state; + QString str2html(const QString &s) { QString result(s); @@ -798,10 +801,10 @@ void t_gui::run(void) { mainWindow->populateBuddyList(); // Set width of window to width of tool bar - int widthToolBar = mainWindow->callToolbar->width(); - QSize sizeMainWin = mainWindow->size(); - sizeMainWin.setWidth(widthToolBar); - mainWindow->resize(sizeMainWin); + // int widthToolBar = mainWindow->callToolbar->width(); + // QSize sizeMainWin = mainWindow->size(); + // sizeMainWin.setWidth(widthToolBar); + // mainWindow->resize(sizeMainWin); // Start QApplication/KApplication if (qApp->isSessionRestored() && diff --git a/src/gui/mphoneform.cpp b/src/gui/mphoneform.cpp index 1fc86e2..d28d3e1 100644 --- a/src/gui/mphoneform.cpp +++ b/src/gui/mphoneform.cpp @@ -253,10 +253,18 @@ void MphoneForm::init() #ifndef WITH_DIAMONDCARD Diamondcard->menuAction()->setVisible(false); #endif + + restoreState(g_gui_state->value("mainwindow/state").toByteArray()); + restoreGeometry(g_gui_state->value("mainwindow/geometry").toByteArray()); + splitter2->restoreState(g_gui_state->value("mainwindow/mainsplitter").toByteArray()); } void MphoneForm::destroy() { + g_gui_state->setValue("mainwindow/state", saveState()); + g_gui_state->setValue("mainwindow/geometry", saveGeometry()); + g_gui_state->setValue("mainwindow/mainsplitter", splitter2->saveState()); + if (dtmfForm) { MEMMAN_DELETE(dtmfForm); delete dtmfForm; diff --git a/src/gui/mphoneform.ui b/src/gui/mphoneform.ui index 093945b..196b098 100644 --- a/src/gui/mphoneform.ui +++ b/src/gui/mphoneform.ui @@ -21,7 +21,7 @@ - 714 + 500 693 @@ -1058,7 +1058,7 @@ 0 0 733 - 20 + 17 -- cgit v1.2.3