aboutsummaryrefslogtreecommitdiff
path: root/lumina-fm
diff options
context:
space:
mode:
Diffstat (limited to 'lumina-fm')
-rw-r--r--lumina-fm/MainUI.cpp16
-rw-r--r--lumina-fm/MainUI.h10
2 files changed, 20 insertions, 6 deletions
diff --git a/lumina-fm/MainUI.cpp b/lumina-fm/MainUI.cpp
index a9dda19e..2e226e12 100644
--- a/lumina-fm/MainUI.cpp
+++ b/lumina-fm/MainUI.cpp
@@ -30,11 +30,17 @@ MainUI::MainUI() : QMainWindow(), ui(new Ui::MainUI){
//syncTimer->setInterval(200); //1/5 second (collect as many signals/slots as necessary
//syncTimer->setSingleShot(true);
//Reset the UI to the previously used size (if possible)
- if(DEBUG){ qDebug() << " - Reset window size"; }
- int height = settings->value("geometry/height",-1).toInt();
- if(height>100 && height <= QApplication::desktop()->availableGeometry(this).height()){ this->resize(this->width(), height); }
- int width = settings->value("geometry/width",-1).toInt();
- if(width>100 && width <= QApplication::desktop()->availableGeometry(this).width()){ this->resize(width, this->height() ); }
+QSize orig = settings->value("preferences/MainWindowSize", QSize()).toSize();
+ if(!orig.isEmpty() && orig.isValid()){
+ //Make sure the old size is larger than the default size hint
+ if(orig.width() < this->sizeHint().width()){ orig.setWidth(this->sizeHint().width()); }
+ if(orig.height() < this->sizeHint().height()){ orig.setHeight(this->sizeHint().height()); }
+ //Also ensure the old size is smaller than the current screen size
+ QSize screen = QApplication::desktop()->availableGeometry(this).size();
+ if(orig.width() > screen.width()){ orig.setWidth(screen.width()); }
+ if(orig.height() > screen.height()){ orig.setHeight(screen.height()); }
+ //Now resize the window
+ this->resize(orig);
//initialize the non-ui widgets
if(DEBUG){ qDebug() << " - Tab Bar Setup"; }
tabBar = new QTabBar(this);
diff --git a/lumina-fm/MainUI.h b/lumina-fm/MainUI.h
index 92d1457b..2a711e8f 100644
--- a/lumina-fm/MainUI.h
+++ b/lumina-fm/MainUI.h
@@ -162,7 +162,15 @@ signals:
void Si_AdaptStatusBar(QFileInfoList fileList, QString path, QString messageFolders, QString messageFiles);
protected:
- void resizeEvent(QResizeEvent*);
+ void closeEvent(QCloseEvent *ev){
+ emit ClientClosed(this);
+ QMainWindow::closeEvent(ev);
+ }
+ void resizeEvent(QResizeEvent *ev){
+ //Save the new size to the settings file for later
+ settings->setValue("preferences/MainWindowSize", ev->size());
+ QMainWindow::resizeEvent(ev); //just in case the window needs to see the event too
+ }
};
bgstack15