Added more settings
This commit is contained in:
6 files changed
+268
-74
No files matched your search
@@ -64,14 +64,44 @@ void AppState::setLastScrollOffset(qreal offset)
|
||||
emit lastScrollOffsetChanged();
|
||||
}
|
||||
|
||||
QString AppState::pageFlipMode() const { return m_pageFlipMode; }
|
||||
int AppState::horizontalMargin() const { return m_horizontalMargin; }
|
||||
|
||||
void AppState::setPageFlipMode(const QString &mode)
|
||||
void AppState::setHorizontalMargin(int margin)
|
||||
{
|
||||
if (m_pageFlipMode == mode)
|
||||
if (m_horizontalMargin == margin)
|
||||
return;
|
||||
m_pageFlipMode = mode;
|
||||
emit pageFlipModeChanged();
|
||||
m_horizontalMargin = margin;
|
||||
emit horizontalMarginChanged();
|
||||
}
|
||||
|
||||
int AppState::verticalMargin() const { return m_verticalMargin; }
|
||||
|
||||
void AppState::setVerticalMargin(int margin)
|
||||
{
|
||||
if (m_verticalMargin == margin)
|
||||
return;
|
||||
m_verticalMargin = margin;
|
||||
emit verticalMarginChanged();
|
||||
}
|
||||
|
||||
int AppState::fontSize() const { return m_fontSize; }
|
||||
|
||||
void AppState::setFontSize(int size)
|
||||
{
|
||||
if (m_fontSize == size)
|
||||
return;
|
||||
m_fontSize = size;
|
||||
emit fontSizeChanged();
|
||||
}
|
||||
|
||||
qreal AppState::lineSpacing() const { return m_lineSpacing; }
|
||||
|
||||
void AppState::setLineSpacing(qreal spacing)
|
||||
{
|
||||
if (qFuzzyCompare(m_lineSpacing, spacing))
|
||||
return;
|
||||
m_lineSpacing = spacing;
|
||||
emit lineSpacingChanged();
|
||||
}
|
||||
|
||||
int AppState::windowWidth() const { return m_windowWidth; }
|
||||
@@ -250,7 +280,10 @@ void AppState::save()
|
||||
s.setValue(QStringLiteral("session/lastScrollOffset"), m_lastScrollOffset);
|
||||
s.setValue(QStringLiteral("session/lastPage"), m_lastPage);
|
||||
s.setValue(QStringLiteral("session/sidebarOpen"), m_sidebarOpen);
|
||||
s.setValue(QStringLiteral("preferences/pageFlipMode"), m_pageFlipMode);
|
||||
s.setValue(QStringLiteral("preferences/horizontalMargin"), m_horizontalMargin);
|
||||
s.setValue(QStringLiteral("preferences/verticalMargin"), m_verticalMargin);
|
||||
s.setValue(QStringLiteral("preferences/fontSize"), m_fontSize);
|
||||
s.setValue(QStringLiteral("preferences/lineSpacing"), m_lineSpacing);
|
||||
s.setValue(QStringLiteral("window/width"), m_windowWidth);
|
||||
s.setValue(QStringLiteral("window/height"), m_windowHeight);
|
||||
s.setValue(QStringLiteral("window/x"), m_windowX);
|
||||
@@ -268,7 +301,10 @@ void AppState::restore()
|
||||
m_lastScrollOffset = s.value(QStringLiteral("session/lastScrollOffset"), 0.0).toDouble();
|
||||
m_lastPage = s.value(QStringLiteral("session/lastPage"), QStringLiteral("starter")).toString();
|
||||
m_sidebarOpen = s.value(QStringLiteral("session/sidebarOpen"), false).toBool();
|
||||
m_pageFlipMode = s.value(QStringLiteral("preferences/pageFlipMode"), QStringLiteral("scroll")).toString();
|
||||
m_horizontalMargin = s.value(QStringLiteral("preferences/horizontalMargin"), 32).toInt();
|
||||
m_verticalMargin = s.value(QStringLiteral("preferences/verticalMargin"), 8).toInt();
|
||||
m_fontSize = s.value(QStringLiteral("preferences/fontSize"), 16).toInt();
|
||||
m_lineSpacing = s.value(QStringLiteral("preferences/lineSpacing"), 1.6).toDouble();
|
||||
m_windowWidth = s.value(QStringLiteral("window/width"), 1024).toInt();
|
||||
m_windowHeight = s.value(QStringLiteral("window/height"), 768).toInt();
|
||||
m_windowX = s.value(QStringLiteral("window/x"), -1).toInt();
|
||||
|
||||
+23
-5
@@ -14,7 +14,10 @@ class AppState : public QObject {
|
||||
Q_PROPERTY(qreal lastScrollPosition READ lastScrollPosition WRITE setLastScrollPosition NOTIFY lastScrollPositionChanged)
|
||||
Q_PROPERTY(int lastScrollIndex READ lastScrollIndex WRITE setLastScrollIndex NOTIFY lastScrollIndexChanged)
|
||||
Q_PROPERTY(qreal lastScrollOffset READ lastScrollOffset WRITE setLastScrollOffset NOTIFY lastScrollOffsetChanged)
|
||||
Q_PROPERTY(QString pageFlipMode READ pageFlipMode WRITE setPageFlipMode NOTIFY pageFlipModeChanged)
|
||||
Q_PROPERTY(int horizontalMargin READ horizontalMargin WRITE setHorizontalMargin NOTIFY horizontalMarginChanged)
|
||||
Q_PROPERTY(int verticalMargin READ verticalMargin WRITE setVerticalMargin NOTIFY verticalMarginChanged)
|
||||
Q_PROPERTY(int fontSize READ fontSize WRITE setFontSize NOTIFY fontSizeChanged)
|
||||
Q_PROPERTY(qreal lineSpacing READ lineSpacing WRITE setLineSpacing NOTIFY lineSpacingChanged)
|
||||
Q_PROPERTY(int windowWidth READ windowWidth WRITE setWindowWidth NOTIFY windowWidthChanged)
|
||||
Q_PROPERTY(int windowHeight READ windowHeight WRITE setWindowHeight NOTIFY windowHeightChanged)
|
||||
Q_PROPERTY(int windowX READ windowX WRITE setWindowX NOTIFY windowXChanged)
|
||||
@@ -41,8 +44,17 @@ public:
|
||||
qreal lastScrollOffset() const;
|
||||
void setLastScrollOffset(qreal offset);
|
||||
|
||||
QString pageFlipMode() const;
|
||||
void setPageFlipMode(const QString &mode);
|
||||
int horizontalMargin() const;
|
||||
void setHorizontalMargin(int margin);
|
||||
|
||||
int verticalMargin() const;
|
||||
void setVerticalMargin(int margin);
|
||||
|
||||
int fontSize() const;
|
||||
void setFontSize(int size);
|
||||
|
||||
qreal lineSpacing() const;
|
||||
void setLineSpacing(qreal spacing);
|
||||
|
||||
int windowWidth() const;
|
||||
void setWindowWidth(int width);
|
||||
@@ -80,7 +92,10 @@ signals:
|
||||
void lastScrollPositionChanged();
|
||||
void lastScrollIndexChanged();
|
||||
void lastScrollOffsetChanged();
|
||||
void pageFlipModeChanged();
|
||||
void horizontalMarginChanged();
|
||||
void verticalMarginChanged();
|
||||
void fontSizeChanged();
|
||||
void lineSpacingChanged();
|
||||
void stateRestored();
|
||||
void windowWidthChanged();
|
||||
void windowHeightChanged();
|
||||
@@ -98,7 +113,10 @@ private:
|
||||
qreal m_lastScrollPosition = 0.0;
|
||||
int m_lastScrollIndex = 0;
|
||||
qreal m_lastScrollOffset = 0.0;
|
||||
QString m_pageFlipMode = QStringLiteral("scroll");
|
||||
int m_horizontalMargin = 32;
|
||||
int m_verticalMargin = 8;
|
||||
int m_fontSize = 16;
|
||||
qreal m_lineSpacing = 1.6;
|
||||
int m_windowWidth = 1024;
|
||||
int m_windowHeight = 768;
|
||||
int m_windowX = -1;
|
||||
|
||||
@@ -99,14 +99,9 @@ void ReadingModel::setScrollInfo(int topChunkIndex, qreal offsetInChunk, bool at
|
||||
|
||||
void ReadingModel::computeChunkHeights()
|
||||
{
|
||||
// Text width matches the QML delegate:
|
||||
// ListView left margin: 12, delegate rightPadding: 2
|
||||
// delegate width = listView.width - 18 (hardcoded in QML)
|
||||
// text layout width = delegate.width - rightPadding = listView.width - 20
|
||||
// m_viewportWidth = chunkListView.width = parent.width - leftMargin(12)
|
||||
// so delegate.width = m_viewportWidth - 18
|
||||
// text width = delegate.width - rightPadding(2) = m_viewportWidth - 20
|
||||
qreal textWidth = m_viewportWidth - 20.0;
|
||||
// Caller passes effective text width:
|
||||
// chunkListView.width - 18 (scrollbar) - 2 * horizontalMargin (delegate padding)
|
||||
qreal textWidth = m_viewportWidth;
|
||||
if (textWidth <= 0)
|
||||
textWidth = 1;
|
||||
|
||||
|
||||
Reference in new issue
Block a user