mirror of
https://github.com/YACReader/yacreader
synced 2025-05-28 03:10:27 -04:00
Merge pull request #66 from vedgy/store-geometry-in-reader-config
Store geometry instead of pos&size in Reader config
This commit is contained in:
commit
dbcd042e6c
@ -11,8 +11,6 @@
|
||||
|
||||
Configuration::Configuration()
|
||||
{
|
||||
//read configuration
|
||||
//load("/YACReader.conf");
|
||||
}
|
||||
|
||||
QSettings *Configuration::getSettings()
|
||||
@ -20,11 +18,6 @@ QSettings *Configuration::getSettings()
|
||||
return settings;
|
||||
}
|
||||
|
||||
/*Configuration::Configuration(const Configuration & conf)
|
||||
{
|
||||
//nothing
|
||||
}*/
|
||||
|
||||
void Configuration::load(QSettings *settings)
|
||||
{
|
||||
this->settings = settings;
|
||||
@ -42,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>
|
||||
@ -22,34 +22,14 @@ class Configuration : public QObject
|
||||
private:
|
||||
QSettings *settings;
|
||||
|
||||
QString defaultPath;
|
||||
//configuration properties
|
||||
QSize magnifyingGlassSize;
|
||||
QSize gotoSlideSize;
|
||||
float zoomLevel;
|
||||
bool adjustToWidth;
|
||||
bool fullScreen;
|
||||
FlowType flowType;
|
||||
float fitToWidthRatio;
|
||||
QPoint windowPos;
|
||||
QSize windowSize;
|
||||
bool maximized;
|
||||
bool doublePage;
|
||||
bool doubleMangaPage;
|
||||
bool alwaysOnTop;
|
||||
bool adjustToFullSize;
|
||||
QColor backgroundColor;
|
||||
|
||||
Configuration();
|
||||
//Configuration(const Configuration & conf);
|
||||
void load(const QString &path = CONF_FILE_PATH);
|
||||
|
||||
public:
|
||||
static Configuration &getConfiguration()
|
||||
{
|
||||
static Configuration configuration;
|
||||
return configuration;
|
||||
};
|
||||
}
|
||||
QSettings *getSettings();
|
||||
void load(QSettings *settings);
|
||||
QString getDefaultPath() { return settings->value(PATH).toString(); }
|
||||
@ -86,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));
|
||||
}
|
||||
@ -1433,20 +1428,16 @@ void MainWindowViewer::newVersion()
|
||||
|
||||
void MainWindowViewer::closeEvent(QCloseEvent *event)
|
||||
{
|
||||
Q_UNUSED(event)
|
||||
|
||||
if (isClient)
|
||||
sendComic();
|
||||
|
||||
viewer->save();
|
||||
Configuration &conf = Configuration::getConfiguration();
|
||||
if (!fullscreen && !isMaximized()) {
|
||||
conf.setPos(pos());
|
||||
conf.setSize(size());
|
||||
}
|
||||
if (!fullscreen && !isMaximized())
|
||||
conf.setGeometry(saveGeometry());
|
||||
conf.setMaximized(isMaximized());
|
||||
|
||||
emit(closed());
|
||||
event->accept();
|
||||
}
|
||||
|
||||
void MainWindowViewer::openPreviousComic()
|
||||
|
@ -174,8 +174,6 @@ private:
|
||||
Qt::WindowFlags previousWindowFlags;
|
||||
QPoint previousPos;
|
||||
QSize previousSize;
|
||||
signals:
|
||||
void closed();
|
||||
|
||||
protected:
|
||||
void closeEvent(QCloseEvent *event) override;
|
||||
|
@ -172,7 +172,6 @@ private:
|
||||
public:
|
||||
Viewer(QWidget *parent = nullptr);
|
||||
~Viewer();
|
||||
void toggleFullScreen();
|
||||
const QPixmap *pixmap();
|
||||
//Comic * getComic(){return comic;}
|
||||
const BookmarksDialog *getBookmarksDialog() { return bd; }
|
||||
|
@ -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"
|
||||
|
Loading…
Reference in New Issue
Block a user