diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/getsuyomi.cpp | 6 | ||||
-rw-r--r-- | src/getsuyomi.hpp | 2 | ||||
-rw-r--r-- | src/main_window.cpp | 24 | ||||
-rw-r--r-- | src/main_window.hpp | 1 |
4 files changed, 21 insertions, 12 deletions
diff --git a/src/getsuyomi.cpp b/src/getsuyomi.cpp index 5593758..4e1e91e 100644 --- a/src/getsuyomi.cpp +++ b/src/getsuyomi.cpp @@ -5,11 +5,15 @@ namespace getsuyomi { Getsuyomi::Getsuyomi() { - m_layout = new QVBoxLayout(); + m_layout = new QHBoxLayout(); + + m_layout->addStretch(); m_layout->addWidget(&m_pageLeft); m_layout->addWidget(&m_pageRight); + m_layout->addStretch(); + setLayout(m_layout); } diff --git a/src/getsuyomi.hpp b/src/getsuyomi.hpp index 3f4da25..8fb9f4a 100644 --- a/src/getsuyomi.hpp +++ b/src/getsuyomi.hpp @@ -39,7 +39,7 @@ class Getsuyomi : public QWidget { void setPagesManga(); void setPages(QLabel& label1, QLabel& label2); - QLayout* m_layout{nullptr}; + QBoxLayout* m_layout{nullptr}; Archive* m_archive{nullptr}; diff --git a/src/main_window.cpp b/src/main_window.cpp index 5c0c401..4feb240 100644 --- a/src/main_window.cpp +++ b/src/main_window.cpp @@ -21,8 +21,9 @@ std::optional<std::string> getEnvVar(const char* envVar); void getEnvVar(const std::string envVar, std::string& envValue, const char* backup); GetEnvResult getEnvironment(); -GetsuyomiApp::GetsuyomiApp() : m_getsuyomi{new Getsuyomi()}, m_qtSettings{new QSettings(AppVendor, AppName)} +GetsuyomiApp::GetsuyomiApp() : m_getsuyomi{new Getsuyomi()} { + readSettings(); } FudStatus GetsuyomiApp::setup() @@ -46,8 +47,6 @@ FudStatus GetsuyomiApp::setup() constexpr int minimumHeight = 480; setMinimumSize(minimumWidth, minimumHeight); - readSettings(); - show(); return FudStatus::Success; @@ -124,6 +123,7 @@ void GetsuyomiApp::openFile() } filename = filenames[0]; m_lastOpenedDirectory = dialog.directory().absolutePath(); + qDebug("Last opened directory is %s", qPrintable(m_lastOpenedDirectory)); } else { qWarning("File dialog did not execute"); return; @@ -186,22 +186,28 @@ void GetsuyomiApp::back() void GetsuyomiApp::closeEvent(QCloseEvent* event) { + writeSettings(); QMainWindow::closeEvent(event); } void GetsuyomiApp::readSettings() { - restoreGeometry(m_qtSettings->value("geometry").toByteArray()); - restoreState(m_qtSettings->value("windowState").toByteArray()); - m_lastOpenedDirectory = m_qtSettings->value("lastOpenedDirectory", QDir::homePath()).toString(); + + QSettings settings{AppVendor, AppName}; + restoreGeometry(settings.value("geometry").toByteArray()); + restoreState(settings.value("windowState").toByteArray()); + m_lastOpenedDirectory = settings.value("lastOpenedDirectory", QDir::homePath()).toString(); qDebug("ReadSettings - last directory is %s", qPrintable(m_lastOpenedDirectory)); } void GetsuyomiApp::writeSettings() { - m_qtSettings->setValue("geometry", saveGeometry()); - m_qtSettings->setValue("windowState", saveState()); - m_qtSettings->setValue("lastOpenedDirectory", m_lastOpenedDirectory); + QSettings settings{AppVendor, AppName}; + settings.setValue("geometry", saveGeometry()); + settings.setValue("windowState", saveState()); + settings.setValue("lastOpenedDirectory", m_lastOpenedDirectory); + settings.sync(); + qDebug() << "Called writeSettings, last dir is " << settings.value("lastOpenedDirectory"); } std::optional<std::string> getEnvVar(const char* envVar) diff --git a/src/main_window.hpp b/src/main_window.hpp index de1cb28..98af5a2 100644 --- a/src/main_window.hpp +++ b/src/main_window.hpp @@ -46,7 +46,6 @@ class GetsuyomiApp : public QMainWindow { QMenu* m_menuBar{nullptr}; QToolBar* m_toolBar{nullptr}; - QSettings* m_qtSettings{nullptr}; QString m_lastOpenedDirectory{}; private slots: |