mirror of
				https://github.com/YACReader/yacreader
				synced 2025-10-31 00:04:26 -04:00 
			
		
		
		
	Reader: store geometry instead of pos&size in Configuration
Qt documentation recommends calling saveGeometry() in closeEvent().
This commit fixes the following bug on my GNU/Linux with Xfce system:
    1. Move the top of the YACReader window to the top of the screen.
    2. Restart YACReader (exit and run again).
    2. Enter full screen mode.
    4. Restart YACReader.
    5. Exit full screen mode.
At this point YACReader's title bar is hidden beyond the top of the
screen, i.e. the window has moved up.
			
			
This commit is contained in:
		
				
					committed by
					
						 Luis Ángel San Martín
						Luis Ángel San Martín
					
				
			
			
				
	
			
			
			
						parent
						
							eb9075c917
						
					
				
				
					commit
					82719573b5
				
			| @ -35,8 +35,6 @@ void Configuration::load(QSettings *settings) | ||||
|         settings->setValue(FLOW_TYPE, 0); | ||||
|     if (!settings->contains(FULLSCREEN)) | ||||
|         settings->setValue(FULLSCREEN, false); | ||||
|     if (!settings->contains(Y_WINDOW_SIZE)) | ||||
|         settings->setValue(Y_WINDOW_SIZE, QSize(0, 0)); | ||||
|     if (!settings->contains(MAXIMIZED)) | ||||
|         settings->setValue(MAXIMIZED, false); | ||||
|     if (!settings->contains(DOUBLE_PAGE)) | ||||
|  | ||||
| @ -1,9 +1,9 @@ | ||||
| #ifndef __CONFIGURATION_H | ||||
| #define __CONFIGURATION_H | ||||
| #include <QByteArray> | ||||
| #include <QString> | ||||
| #include <QSize> | ||||
| #include <QObject> | ||||
| #include <QPoint> | ||||
| #include <QColor> | ||||
| #include <QSettings> | ||||
| #include <QDate> | ||||
| @ -66,10 +66,8 @@ public: | ||||
|     bool getFullScreen() { return settings->value(FULLSCREEN).toBool(); } | ||||
|     void setFullScreen(bool f) { settings->setValue(FULLSCREEN, f); } | ||||
|  | ||||
|     QPoint getPos() { return settings->value(Y_WINDOW_POS).toPoint(); } | ||||
|     void setPos(QPoint p) { settings->setValue(Y_WINDOW_POS, p); } | ||||
|     QSize getSize() { return settings->value(Y_WINDOW_SIZE).toSize(); } | ||||
|     void setSize(QSize s) { settings->setValue(Y_WINDOW_SIZE, s); } | ||||
|     QByteArray getGeometry() const { return settings->value(Y_WINDOW_GEOMETRY).toByteArray(); } | ||||
|     void setGeometry(const QByteArray &g) { settings->setValue(Y_WINDOW_GEOMETRY, g); } | ||||
|     bool getMaximized() { return settings->value(MAXIMIZED).toBool(); } | ||||
|     void setMaximized(bool b) { settings->setValue(MAXIMIZED, b); } | ||||
|     bool getDoublePage() { return settings->value(DOUBLE_PAGE).toBool(); } | ||||
|  | ||||
| @ -142,12 +142,7 @@ void MainWindowViewer::setupUI() | ||||
|     height = static_cast<int>(heightDesktopResolution * 0.84); | ||||
|     width = static_cast<int>(height * 0.70); | ||||
|     Configuration &conf = Configuration::getConfiguration(); | ||||
|     QPoint p = conf.getPos(); | ||||
|     QSize s = conf.getSize(); | ||||
|     if (s.width() != 0) { | ||||
|         move(p); | ||||
|         resize(s); | ||||
|     } else { | ||||
|     if (!restoreGeometry(conf.getGeometry())) { | ||||
|         move(QPoint((widthDesktopResolution - width) / 2, ((heightDesktopResolution - height) - 40) / 2)); | ||||
|         resize(QSize(width, height)); | ||||
|     } | ||||
| @ -1438,10 +1433,8 @@ void MainWindowViewer::closeEvent(QCloseEvent *event) | ||||
|  | ||||
|     viewer->save(); | ||||
|     Configuration &conf = Configuration::getConfiguration(); | ||||
|     if (!fullscreen && !isMaximized()) { | ||||
|         conf.setPos(pos()); | ||||
|         conf.setSize(size()); | ||||
|     } | ||||
|     if (!fullscreen && !isMaximized()) | ||||
|         conf.setGeometry(saveGeometry()); | ||||
|     conf.setMaximized(isMaximized()); | ||||
|  | ||||
|     event->accept(); | ||||
|  | ||||
| @ -15,8 +15,7 @@ | ||||
| #define FITMODE "FITMODE" | ||||
| #define FLOW_TYPE "FLOW_TYPE" | ||||
| #define FULLSCREEN "FULLSCREEN" | ||||
| #define Y_WINDOW_POS "POS" | ||||
| #define Y_WINDOW_SIZE "SIZE" | ||||
| #define Y_WINDOW_GEOMETRY "GEOMETRY" | ||||
| #define MAXIMIZED "MAXIMIZED" | ||||
| #define DOUBLE_PAGE "DOUBLE_PAGE" | ||||
| #define DOUBLE_MANGA_PAGE "DOUBLE_MANGA_PAGE" | ||||
|  | ||||
		Reference in New Issue
	
	Block a user