mirror of
https://github.com/YACReader/yacreader
synced 2025-06-03 17:18:23 -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()
|
Configuration::Configuration()
|
||||||
{
|
{
|
||||||
//read configuration
|
|
||||||
//load("/YACReader.conf");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QSettings *Configuration::getSettings()
|
QSettings *Configuration::getSettings()
|
||||||
@ -20,11 +18,6 @@ QSettings *Configuration::getSettings()
|
|||||||
return settings;
|
return settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*Configuration::Configuration(const Configuration & conf)
|
|
||||||
{
|
|
||||||
//nothing
|
|
||||||
}*/
|
|
||||||
|
|
||||||
void Configuration::load(QSettings *settings)
|
void Configuration::load(QSettings *settings)
|
||||||
{
|
{
|
||||||
this->settings = settings;
|
this->settings = settings;
|
||||||
@ -42,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>
|
||||||
@ -22,34 +22,14 @@ class Configuration : public QObject
|
|||||||
private:
|
private:
|
||||||
QSettings *settings;
|
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();
|
||||||
//Configuration(const Configuration & conf);
|
|
||||||
void load(const QString &path = CONF_FILE_PATH);
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static Configuration &getConfiguration()
|
static Configuration &getConfiguration()
|
||||||
{
|
{
|
||||||
static Configuration configuration;
|
static Configuration configuration;
|
||||||
return configuration;
|
return configuration;
|
||||||
};
|
}
|
||||||
QSettings *getSettings();
|
QSettings *getSettings();
|
||||||
void load(QSettings *settings);
|
void load(QSettings *settings);
|
||||||
QString getDefaultPath() { return settings->value(PATH).toString(); }
|
QString getDefaultPath() { return settings->value(PATH).toString(); }
|
||||||
@ -86,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));
|
||||||
}
|
}
|
||||||
@ -1433,20 +1428,16 @@ void MainWindowViewer::newVersion()
|
|||||||
|
|
||||||
void MainWindowViewer::closeEvent(QCloseEvent *event)
|
void MainWindowViewer::closeEvent(QCloseEvent *event)
|
||||||
{
|
{
|
||||||
Q_UNUSED(event)
|
|
||||||
|
|
||||||
if (isClient)
|
if (isClient)
|
||||||
sendComic();
|
sendComic();
|
||||||
|
|
||||||
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());
|
||||||
|
|
||||||
emit(closed());
|
event->accept();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindowViewer::openPreviousComic()
|
void MainWindowViewer::openPreviousComic()
|
||||||
|
@ -174,8 +174,6 @@ private:
|
|||||||
Qt::WindowFlags previousWindowFlags;
|
Qt::WindowFlags previousWindowFlags;
|
||||||
QPoint previousPos;
|
QPoint previousPos;
|
||||||
QSize previousSize;
|
QSize previousSize;
|
||||||
signals:
|
|
||||||
void closed();
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void closeEvent(QCloseEvent *event) override;
|
void closeEvent(QCloseEvent *event) override;
|
||||||
|
@ -172,7 +172,6 @@ private:
|
|||||||
public:
|
public:
|
||||||
Viewer(QWidget *parent = nullptr);
|
Viewer(QWidget *parent = nullptr);
|
||||||
~Viewer();
|
~Viewer();
|
||||||
void toggleFullScreen();
|
|
||||||
const QPixmap *pixmap();
|
const QPixmap *pixmap();
|
||||||
//Comic * getComic(){return comic;}
|
//Comic * getComic(){return comic;}
|
||||||
const BookmarksDialog *getBookmarksDialog() { return bd; }
|
const BookmarksDialog *getBookmarksDialog() { return bd; }
|
||||||
|
@ -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