Allow editing bookmarks.
[dorian] / settingswindow.cpp
index 1150271..524dc7d 100644 (file)
@@ -4,15 +4,10 @@
 #include "settings.h"
 #include "toolbuttonbox.h"
 #include "platform.h"
+#include "trace.h"
 
 #ifdef Q_OS_SYMBIAN
-#include "flickcharm.h"
-#endif
-
-#ifdef Q_OS_SYMBIAN
-const char *DEFAULT_ORIENTATION = "portrait";
-#else
-const char *DEFAULT_ORIENTATION = "landscape";
+#   include "flickcharm.h"
 #endif
 
 const int ZOOM_MIN = 75;
@@ -28,6 +23,8 @@ SettingsWindow::SettingsWindow(QWidget *parent):  AdopterWindow(parent)
     setWindowTitle("Settings");
 
     Settings *settings = Settings::instance();
+    Platform *platform = Platform::instance();
+
     QScrollArea *scroller = new QScrollArea(this);
 #if defined(Q_WS_MAEMO_5)
     scroller->setProperty("FingerScrollable", true);
@@ -51,14 +48,12 @@ SettingsWindow::SettingsWindow(QWidget *parent):  AdopterWindow(parent)
     backlight->setChecked(settings->value("lightson", false).toBool());
 #endif
 
-#ifndef Q_OS_SYMBIAN
     QCheckBox *grabVolume =
             new QCheckBox(tr("Navigate with volume keys"), contents);
     layout->addWidget(grabVolume);
     grabVolume->setChecked(settings->value("usevolumekeys", false).toBool());
-#endif
 
-    int zoom = Settings::instance()->value("zoom").toInt();
+    int zoom = settings->value("zoom", platform->defaultZoom()).toInt();
     if (zoom < ZOOM_MIN) {
         zoom = ZOOM_MIN;
     } else if (zoom > ZOOM_MAX) {
@@ -76,9 +71,7 @@ SettingsWindow::SettingsWindow(QWidget *parent):  AdopterWindow(parent)
 
     QLabel *fontLabel = new QLabel(tr("Font:"), contents);
     layout->addWidget(fontLabel);
-    QString defaultFamily = fontLabel->fontInfo().family();
-    QString family =
-            Settings::instance()->value("font", defaultFamily).toString();
+    QString family = settings->value("font", platform->defaultFont()).toString();
     fontButton = new QFontComboBox(contents);
     fontButton->setCurrentFont(QFont(family));
     fontButton->setEditable(false);
@@ -89,10 +82,12 @@ SettingsWindow::SettingsWindow(QWidget *parent):  AdopterWindow(parent)
     ToolButtonBox *box = new ToolButtonBox(this);
     layout->addWidget(box);
     box->addButton(SchemeDefault, tr("Default"),
-                   Platform::icon("style-default"));
-    box->addButton(SchemeNight, tr("Night"), Platform::icon("style-night"));
-    box->addButton(SchemeDay, tr("Day"), Platform::icon("style-day"));
-    box->addButton(SchemeSand, tr("Sand"), Platform::icon("style-sand"));
+                   Platform::instance()->icon("style-default"));
+    box->addButton(SchemeNight, tr("Night"),
+                   Platform::instance()->icon("style-night"));
+    box->addButton(SchemeDay, tr("Day"), Platform::instance()->icon("style-day"));
+    box->addButton(SchemeSand, tr("Sand"),
+                   Platform::instance()->icon("style-sand"));
     box->addStretch();
     QString scheme = settings->value("scheme", "default").toString();
     if (scheme == "night") {
@@ -116,7 +111,7 @@ SettingsWindow::SettingsWindow(QWidget *parent):  AdopterWindow(parent)
                               ":/icons/settings-landscape.png");
     orientationBox->addStretch();
     QString orientation =
-        settings->value("orientation", DEFAULT_ORIENTATION).toString();
+        settings->value("orientation", platform->defaultOrientation()).toString();
     if (orientation == "portrait") {
         orientationBox->toggle(OrientationPortrait);
     } else {
@@ -134,9 +129,9 @@ SettingsWindow::SettingsWindow(QWidget *parent):  AdopterWindow(parent)
 #ifndef Q_OS_SYMBIAN
     connect(backlight, SIGNAL(toggled(bool)),
             this, SLOT(onLightsToggled(bool)));
+#endif
     connect(grabVolume, SIGNAL(toggled(bool)),
             this, SLOT(onGrabVolumeToggled(bool)));
-#endif
     connect(zoomSlider, SIGNAL(valueChanged(int)),
             this, SLOT(onSliderValueChanged(int)));
     connect(fontButton, SIGNAL(currentFontChanged(const QFont &)),
@@ -164,20 +159,11 @@ void SettingsWindow::onSliderValueChanged(int value)
         return;
     }
     zoomLabel->setText(tr("Zoom level: %1%").arg(value));
-#if defined(Q_WS_MAEMO_5) || defined(Q_OS_SYMBIAN)
-    // Constant re-scaling of the book view is too much for mobiles
-#else
-    Settings::instance()->setValue("zoom", value);
-#endif // Q_WS_MAEMO_5
 }
 
 void SettingsWindow::onCurrentFontChanged(const QFont &font)
 {
-#ifdef Q_WS_MAEMO_5
     Q_UNUSED(font);
-#else
-    Settings::instance()->setValue("font", font.family());
-#endif // Q_WS_MAEMO_5
 }
 
 void SettingsWindow::onSchemeButtonClicked(int id)
@@ -210,21 +196,20 @@ void SettingsWindow::onOrientationButtonClicked(int id)
 #endif // Q_WS_MAEMO_5
 }
 
-#ifdef Q_WS_MAEMO_5
-
 void SettingsWindow::closeEvent(QCloseEvent *e)
 {
+    TRACE;
     Settings *settings = Settings::instance();
     settings->setValue("zoom", zoomSlider->value());
     settings->setValue("font", fontButton->currentFont().family());
+#ifndef Q_OS_SYMBIAN
     settings->setValue("orientation",
         (orientationBox->checkedId() == OrientationLandscape)?
         "landscape": "portrait");
+#endif // Q_OS_SYMBIAN
     e->accept();
 }
 
-#endif // Q_WS_MAEMO_5
-
 void SettingsWindow::onLightsToggled(bool value)
 {
     Settings::instance()->setValue("lightson", value);