aboutsummaryrefslogtreecommitdiff
path: root/lumina-fm/MainUI.cpp
diff options
context:
space:
mode:
authorKen Moore <moorekou@gmail.com>2016-03-31 12:13:18 -0400
committerKen Moore <moorekou@gmail.com>2016-03-31 12:13:18 -0400
commit2242ce9f0ce2621397483a80073ee03c8557f217 (patch)
tree3c57281caf87d0e54bb0a551ed28699d86341d82 /lumina-fm/MainUI.cpp
parentMerge pull request #212 from q5sys/master (diff)
parentUpdate MainUI.h (diff)
downloadlumina-2242ce9f0ce2621397483a80073ee03c8557f217.tar.gz
lumina-2242ce9f0ce2621397483a80073ee03c8557f217.tar.bz2
lumina-2242ce9f0ce2621397483a80073ee03c8557f217.zip
Merge pull request #213 from q5sys/patch-1
Initial resize event
Diffstat (limited to 'lumina-fm/MainUI.cpp')
-rw-r--r--lumina-fm/MainUI.cpp16
1 files changed, 11 insertions, 5 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);
bgstack15