X-Git-Url: http://vcs.maemo.org/git/?a=blobdiff_plain;f=settingswindow.cpp;h=a390363409b7fe50da9a4fced11174df8fa8041a;hb=HEAD;hp=1bf3b8d2acbdfbed4180b2d721fec8397a2275f4;hpb=43016b923e18dff40c53a116316110f2fe5c4820;p=dorian diff --git a/settingswindow.cpp b/settingswindow.cpp index 1bf3b8d..a390363 100644 --- a/settingswindow.cpp +++ b/settingswindow.cpp @@ -7,13 +7,7 @@ #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; @@ -29,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); @@ -46,18 +42,20 @@ SettingsWindow::SettingsWindow(QWidget *parent): AdopterWindow(parent) QVBoxLayout *layout = new QVBoxLayout(contents); contents->setLayout(layout); -#ifndef Q_OS_SYMBIAN +#if defined(Q_WS_MAEMO_5) QCheckBox *backlight = new QCheckBox(tr("Keep backlight on"), contents); layout->addWidget(backlight); backlight->setChecked(settings->value("lightson", false).toBool()); #endif +#if defined(Q_WS_MAEMO_5) || defined(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) { @@ -75,9 +73,8 @@ 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(); + settings->value("font", platform->defaultFont()).toString(); fontButton = new QFontComboBox(contents); fontButton->setCurrentFont(QFont(family)); fontButton->setEditable(false); @@ -87,41 +84,21 @@ SettingsWindow::SettingsWindow(QWidget *parent): AdopterWindow(parent) layout->addWidget(colorLabel); 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")); + box->addButton(SchemeDay, tr("Day"), + Platform::instance()->icon("style-day")); + box->addButton(SchemeNight, tr("Night"), + Platform::instance()->icon("style-night")); + box->addButton(SchemeSand, tr("Sand"), + Platform::instance()->icon("style-sand")); box->addStretch(); - QString scheme = settings->value("scheme", "default").toString(); + QString scheme = settings->value("scheme", "day").toString(); if (scheme == "night") { box->toggle(SchemeNight); - } else if (scheme == "day") { - box->toggle(SchemeDay); } else if (scheme == "sand") { box->toggle(SchemeSand); } else { - box->toggle(SchemeDefault); - } - -#ifndef Q_OS_SYMBIAN - QLabel *orientationLabel = new QLabel(tr("Orientation:"), contents); - layout->addWidget(orientationLabel); - orientationBox = new ToolButtonBox(this); - layout->addWidget(orientationBox); - orientationBox->addButton(OrientationPortrait, tr("Portrait"), - ":/icons/settings-portrait.png"); - orientationBox->addButton(OrientationLandscape, tr("Landscape"), - ":/icons/settings-landscape.png"); - orientationBox->addStretch(); - QString orientation = - settings->value("orientation", DEFAULT_ORIENTATION).toString(); - if (orientation == "portrait") { - orientationBox->toggle(OrientationPortrait); - } else { - orientationBox->toggle(OrientationLandscape); + box->toggle(SchemeDay); } -#endif // !Q_OS_SYMBIAN layout->addStretch(); scroller->setWidget(contents); @@ -130,22 +107,20 @@ SettingsWindow::SettingsWindow(QWidget *parent): AdopterWindow(parent) setCentralWidget(scroller); -#ifndef Q_OS_SYMBIAN +#if defined(Q_WS_MAEMO_5) connect(backlight, SIGNAL(toggled(bool)), this, SLOT(onLightsToggled(bool))); #endif +#if defined(Q_WS_MAEMO_5) || defined(Q_OS_SYMBIAN) 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 &)), this, SLOT(onCurrentFontChanged(const QFont &))); connect(box, SIGNAL(buttonClicked(int)), this, SLOT(onSchemeButtonClicked(int))); -#ifndef Q_OS_SYMBIAN - connect(orientationBox, SIGNAL(buttonClicked(int)), - this, SLOT(onOrientationButtonClicked(int))); -#endif #ifdef Q_OS_SYMBIAN QAction *closeAction = new QAction(parent? tr("Back"): tr("Exit"), this); @@ -163,39 +138,33 @@ 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 +#if !defined(Q_WS_MAEMO_5) && !defined(Q_OS_SYMBIAN) + Settings::instance()->setValue("zoom", zoomSlider->value()); +#endif } void SettingsWindow::onCurrentFontChanged(const QFont &font) { -#ifdef Q_WS_MAEMO_5 - Q_UNUSED(font); -#else +#if !defined(Q_WS_MAEMO_5) && !defined(Q_OS_SYMBIAN) Settings::instance()->setValue("font", font.family()); -#endif // Q_WS_MAEMO_5 +#else + Q_UNUSED(font); +#endif } void SettingsWindow::onSchemeButtonClicked(int id) { QString scheme; switch (id) { - case SchemeDay: scheme = "day"; break; case SchemeNight: scheme = "night"; break; case SchemeSand: scheme = "sand"; break; - default: scheme = "default"; break; + default: scheme = "day"; break; } Settings::instance()->setValue("scheme", scheme); } void SettingsWindow::onOrientationButtonClicked(int id) { -#ifdef Q_WS_MAEMO_5 - Q_UNUSED(id); -#else QString orientation; switch (id) { case OrientationLandscape: @@ -206,27 +175,17 @@ void SettingsWindow::onOrientationButtonClicked(int id) break; } Settings::instance()->setValue("orientation", orientation); -#endif // Q_WS_MAEMO_5 } -#if defined(Q_WS_MAEMO_5) || defined(Q_OS_SYMBIAN) - 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 || Q_OS_SYMBIAN - void SettingsWindow::onLightsToggled(bool value) { Settings::instance()->setValue("lightson", value);