X-Git-Url: http://git.maemo.org/git/?a=blobdiff_plain;f=settingswindow.cpp;h=f09f9b24b5481f87769bf8379295a88c76a2eb80;hb=4f302c4427507fec544f32b9003035e93f32b2e2;hp=4bece6138b4e929c839ccb2cb2047f82f2ea9ab9;hpb=91982ba06cca87105e1174e5e167c0b1771cf159;p=dorian diff --git a/settingswindow.cpp b/settingswindow.cpp index 4bece61..f09f9b2 100644 --- a/settingswindow.cpp +++ b/settingswindow.cpp @@ -3,18 +3,18 @@ #include "settingswindow.h" #include "settings.h" #include "toolbuttonbox.h" +#include "platform.h" +#include "trace.h" #ifdef Q_OS_SYMBIAN -const char *DEFAULT_ORIENTATION = "portrait"; -#else -const char *DEFAULT_ORIENTATION = "landscape"; +# include "flickcharm.h" #endif const int ZOOM_MIN = 75; const int ZOOM_MAX = 250; const int ZOOM_STEP = 25; -SettingsWindow::SettingsWindow(QWidget *parent): QMainWindow(parent) +SettingsWindow::SettingsWindow(QWidget *parent): AdopterWindow(parent) { #ifdef Q_WS_MAEMO_5 setAttribute(Qt::WA_Maemo5StackedWindow, true); @@ -23,10 +23,15 @@ SettingsWindow::SettingsWindow(QWidget *parent): QMainWindow(parent) setWindowTitle("Settings"); Settings *settings = Settings::instance(); + Platform *platform = Platform::instance(); + QScrollArea *scroller = new QScrollArea(this); -#ifdef Q_WS_MAEMO_5 +#if defined(Q_WS_MAEMO_5) scroller->setProperty("FingerScrollable", true); scroller->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); +#elif defined(Q_OS_SYMBIAN) + FlickCharm *charm = new FlickCharm(this); + charm->activateOn(scroller); #else scroller->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); #endif @@ -37,18 +42,18 @@ SettingsWindow::SettingsWindow(QWidget *parent): QMainWindow(parent) QVBoxLayout *layout = new QVBoxLayout(contents); contents->setLayout(layout); +#ifndef Q_OS_SYMBIAN QCheckBox *backlight = new QCheckBox(tr("Keep backlight on"), contents); layout->addWidget(backlight); 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) { @@ -66,9 +71,7 @@ SettingsWindow::SettingsWindow(QWidget *parent): QMainWindow(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); @@ -78,10 +81,13 @@ SettingsWindow::SettingsWindow(QWidget *parent): QMainWindow(parent) layout->addWidget(colorLabel); ToolButtonBox *box = new ToolButtonBox(this); layout->addWidget(box); - box->addButton(SchemeDefault, tr("Default"), ":/icons/style-default.png"); - box->addButton(SchemeNight, tr("Night"), ":/icons/style-night.png"); - box->addButton(SchemeDay, tr("Day"), ":/icons/style-day.png"); - box->addButton(SchemeSand, tr("Sand"), ":/icons/style-sand.png"); + box->addButton(SchemeDefault, tr("Default"), + 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") { @@ -94,6 +100,7 @@ SettingsWindow::SettingsWindow(QWidget *parent): QMainWindow(parent) box->toggle(SchemeDefault); } +#if defined(Q_WS_MAEMO_5) || defined(Q_OS_SYMBIAN) QLabel *orientationLabel = new QLabel(tr("Orientation:"), contents); layout->addWidget(orientationLabel); orientationBox = new ToolButtonBox(this); @@ -104,12 +111,13 @@ SettingsWindow::SettingsWindow(QWidget *parent): QMainWindow(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 { orientationBox->toggle(OrientationLandscape); } +#endif // defined(Q_WS_MAEMO_5) || defined(Q_OS_SYMBIAN) layout->addStretch(); scroller->setWidget(contents); @@ -118,20 +126,22 @@ SettingsWindow::SettingsWindow(QWidget *parent): QMainWindow(parent) setCentralWidget(scroller); +#ifndef Q_OS_SYMBIAN connect(backlight, SIGNAL(toggled(bool)), this, SLOT(onLightsToggled(bool))); -#ifndef Q_OS_SYMBIAN +#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 &)), 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); @@ -149,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) @@ -179,9 +180,6 @@ void SettingsWindow::onSchemeButtonClicked(int id) void SettingsWindow::onOrientationButtonClicked(int id) { -#ifdef Q_WS_MAEMO_5 - Q_UNUSED(id); -#else QString orientation; switch (id) { case OrientationLandscape: @@ -192,13 +190,11 @@ void SettingsWindow::onOrientationButtonClicked(int id) break; } Settings::instance()->setValue("orientation", orientation); -#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()); @@ -208,8 +204,6 @@ void SettingsWindow::closeEvent(QCloseEvent *e) e->accept(); } -#endif // Q_WS_MAEMO_5 - void SettingsWindow::onLightsToggled(bool value) { Settings::instance()->setValue("lightson", value);