mirror of
https://github.com/YACReader/yacreader
synced 2025-06-04 01:28:55 -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:
parent
eb9075c917
commit
82719573b5
@ -35,8 +35,6 @@ void Configuration::load(QSettings *settings)
|
|||||||
settings->setValue(FLOW_TYPE, 0);
|
settings->setValue(FLOW_TYPE, 0);
|
||||||
if (!settings->contains(FULLSCREEN))
|
if (!settings->contains(FULLSCREEN))
|
||||||
settings->setValue(FULLSCREEN, false);
|
settings->setValue(FULLSCREEN, false);
|
||||||
if (!settings->contains(Y_WINDOW_SIZE))
|
|
||||||
settings->setValue(Y_WINDOW_SIZE, QSize(0, 0));
|
|
||||||
if (!settings->contains(MAXIMIZED))
|
if (!settings->contains(MAXIMIZED))
|
||||||
settings->setValue(MAXIMIZED, false);
|
settings->setValue(MAXIMIZED, false);
|
||||||
if (!settings->contains(DOUBLE_PAGE))
|
if (!settings->contains(DOUBLE_PAGE))
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
#ifndef __CONFIGURATION_H
|
#ifndef __CONFIGURATION_H
|
||||||
#define __CONFIGURATION_H
|
#define __CONFIGURATION_H
|
||||||
|
#include <QByteArray>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QSize>
|
#include <QSize>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QPoint>
|
|
||||||
#include <QColor>
|
#include <QColor>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include <QDate>
|
#include <QDate>
|
||||||
@ -66,10 +66,8 @@ public:
|
|||||||
bool getFullScreen() { return settings->value(FULLSCREEN).toBool(); }
|
bool getFullScreen() { return settings->value(FULLSCREEN).toBool(); }
|
||||||
void setFullScreen(bool f) { settings->setValue(FULLSCREEN, f); }
|
void setFullScreen(bool f) { settings->setValue(FULLSCREEN, f); }
|
||||||
|
|
||||||
QPoint getPos() { return settings->value(Y_WINDOW_POS).toPoint(); }
|
QByteArray getGeometry() const { return settings->value(Y_WINDOW_GEOMETRY).toByteArray(); }
|
||||||
void setPos(QPoint p) { settings->setValue(Y_WINDOW_POS, p); }
|
void setGeometry(const QByteArray &g) { settings->setValue(Y_WINDOW_GEOMETRY, g); }
|
||||||
QSize getSize() { return settings->value(Y_WINDOW_SIZE).toSize(); }
|
|
||||||
void setSize(QSize s) { settings->setValue(Y_WINDOW_SIZE, s); }
|
|
||||||
bool getMaximized() { return settings->value(MAXIMIZED).toBool(); }
|
bool getMaximized() { return settings->value(MAXIMIZED).toBool(); }
|
||||||
void setMaximized(bool b) { settings->setValue(MAXIMIZED, b); }
|
void setMaximized(bool b) { settings->setValue(MAXIMIZED, b); }
|
||||||
bool getDoublePage() { return settings->value(DOUBLE_PAGE).toBool(); }
|
bool getDoublePage() { return settings->value(DOUBLE_PAGE).toBool(); }
|
||||||
|
@ -142,12 +142,7 @@ void MainWindowViewer::setupUI()
|
|||||||
height = static_cast<int>(heightDesktopResolution * 0.84);
|
height = static_cast<int>(heightDesktopResolution * 0.84);
|
||||||
width = static_cast<int>(height * 0.70);
|
width = static_cast<int>(height * 0.70);
|
||||||
Configuration &conf = Configuration::getConfiguration();
|
Configuration &conf = Configuration::getConfiguration();
|
||||||
QPoint p = conf.getPos();
|
if (!restoreGeometry(conf.getGeometry())) {
|
||||||
QSize s = conf.getSize();
|
|
||||||
if (s.width() != 0) {
|
|
||||||
move(p);
|
|
||||||
resize(s);
|
|
||||||
} else {
|
|
||||||
move(QPoint((widthDesktopResolution - width) / 2, ((heightDesktopResolution - height) - 40) / 2));
|
move(QPoint((widthDesktopResolution - width) / 2, ((heightDesktopResolution - height) - 40) / 2));
|
||||||
resize(QSize(width, height));
|
resize(QSize(width, height));
|
||||||
}
|
}
|
||||||
@ -1438,10 +1433,8 @@ void MainWindowViewer::closeEvent(QCloseEvent *event)
|
|||||||
|
|
||||||
viewer->save();
|
viewer->save();
|
||||||
Configuration &conf = Configuration::getConfiguration();
|
Configuration &conf = Configuration::getConfiguration();
|
||||||
if (!fullscreen && !isMaximized()) {
|
if (!fullscreen && !isMaximized())
|
||||||
conf.setPos(pos());
|
conf.setGeometry(saveGeometry());
|
||||||
conf.setSize(size());
|
|
||||||
}
|
|
||||||
conf.setMaximized(isMaximized());
|
conf.setMaximized(isMaximized());
|
||||||
|
|
||||||
event->accept();
|
event->accept();
|
||||||
|
@ -15,8 +15,7 @@
|
|||||||
#define FITMODE "FITMODE"
|
#define FITMODE "FITMODE"
|
||||||
#define FLOW_TYPE "FLOW_TYPE"
|
#define FLOW_TYPE "FLOW_TYPE"
|
||||||
#define FULLSCREEN "FULLSCREEN"
|
#define FULLSCREEN "FULLSCREEN"
|
||||||
#define Y_WINDOW_POS "POS"
|
#define Y_WINDOW_GEOMETRY "GEOMETRY"
|
||||||
#define Y_WINDOW_SIZE "SIZE"
|
|
||||||
#define MAXIMIZED "MAXIMIZED"
|
#define MAXIMIZED "MAXIMIZED"
|
||||||
#define DOUBLE_PAGE "DOUBLE_PAGE"
|
#define DOUBLE_PAGE "DOUBLE_PAGE"
|
||||||
#define DOUBLE_MANGA_PAGE "DOUBLE_MANGA_PAGE"
|
#define DOUBLE_MANGA_PAGE "DOUBLE_MANGA_PAGE"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user