More Symbian fixes.
authorAkos Polster <akos@pipacs.com>
Sun, 26 Sep 2010 16:51:48 +0000 (18:51 +0200)
committerAkos Polster <akos@pipacs.com>
Sun, 26 Sep 2010 16:51:48 +0000 (18:51 +0200)
bookmarkinfodialog.cpp
devtools.cpp
infodialog.cpp
mainwindow.cpp
settingswindow.cpp
widgets/adopterwindow.cpp
widgets/dyalog.cpp
widgets/dyalog.h
widgets/listwindow.cpp
widgets/listwindow.h

index 7bdfb70..847cd3b 100644 (file)
@@ -22,13 +22,9 @@ BookmarkInfoDialog::BookmarkInfoDialog(Book *b, int i, QWidget *parent):
     QLabel *info = new QLabel(label, this);
     addWidget(info);
     addStretch();
-
-    QPushButton *read = new QPushButton(tr("Go to"), this);
-    QPushButton *remove = new QPushButton(tr("Delete"), this);
-    connect(read, SIGNAL(clicked()), this, SLOT(onRead()));
-    connect(remove, SIGNAL(clicked()), this, SLOT(onRemove()));
-    addButton(read, QDialogButtonBox::ActionRole);
-    addButton(remove, QDialogButtonBox::DestructiveRole);
+    addButton(tr("Go to"), this, SLOT(onRead()), QDialogButtonBox::ActionRole);
+    addButton(tr("Delete"), this, SLOT(onRemove()),
+              QDialogButtonBox::DestructiveRole);
 }
 
 void BookmarkInfoDialog::onRead()
index cd8d270..49a32ad 100644 (file)
@@ -25,6 +25,7 @@ DevTools::DevTools(QWidget *parent): Dyalog(parent, false)
     box->toggle(Trace::level);
     connect(box, SIGNAL(buttonClicked(int)),
             this, SLOT(onLevelButtonClicked(int)));
+    addStretch();
 }
 
 void DevTools::onClear()
index e541ceb..eadc647 100644 (file)
@@ -43,12 +43,10 @@ InfoDialog::InfoDialog(Book *b, QWidget *parent, bool showButtons):
         addStretch();
     }
 
-    QPushButton *read = new QPushButton(tr("Read"), this);
-    QPushButton *remove = new QPushButton(tr("Delete"), this);
-    connect(read, SIGNAL(clicked()), this, SLOT(onReadBook()));
-    connect(remove, SIGNAL(clicked()), this, SLOT(onRemoveBook()));
-    addButton(read, QDialogButtonBox::ActionRole);
-    addButton(remove, QDialogButtonBox::DestructiveRole);
+    addButton(tr("Read"), this, SLOT(onReadBook()),
+              QDialogButtonBox::ActionRole);
+    addButton(tr("Delete"), this, SLOT(onRemoveBook()),
+              QDialogButtonBox::DestructiveRole);
 }
 
 void InfoDialog::onReadBook()
index 850c070..6a539b9 100755 (executable)
@@ -251,7 +251,8 @@ void MainWindow::showSettings()
 void MainWindow::showInfo()
 {
     if (mCurrent.isValid()) {
-        (new InfoDialog(Library::instance()->book(mCurrent), this, false))->exec();
+        (new InfoDialog(Library::instance()->book(mCurrent), this, false))->
+                exec();
     }
 }
 
@@ -423,12 +424,14 @@ void MainWindow::about()
     QLabel *label = new QLabel(aboutDialog);
     label->setTextFormat(Qt::RichText);
     label->setOpenExternalLinks(true);
+    label->setWordWrap(true);
     label->setText(tr("<b>Dorian %1</b><br><br>Copyright &copy; 2010 "
         "Akos Polster &lt;akos@pipacs.com&gt;<br>"
         "Licensed under GNU General Public License, Version 3<br>"
         "Source code: <a href='https://garage.maemo.org/projects/dorian/'>"
         "garage.maemo.org/projects/dorian</a>").arg(DORIAN_VERSION));
     aboutDialog->addWidget(label);
+    aboutDialog->addStretch();
     aboutDialog->show();
 }
 
index 5c5dce4..f533e17 100644 (file)
@@ -41,10 +41,12 @@ SettingsWindow::SettingsWindow(QWidget *parent):  QMainWindow(parent)
     layout->addWidget(backlight);
     backlight->setChecked(settings->value("lightson", false).toBool());
 
+#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();
     if (zoom < ZOOM_MIN) {
@@ -65,7 +67,8 @@ 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::instance()->value("font", defaultFamily).toString();
     fontButton = new QFontComboBox(contents);
     fontButton->setCurrentFont(QFont(family));
     fontButton->setEditable(false);
@@ -115,9 +118,12 @@ SettingsWindow::SettingsWindow(QWidget *parent):  QMainWindow(parent)
 
     setCentralWidget(scroller);
 
-    connect(backlight, SIGNAL(toggled(bool)), this, SLOT(onLightsToggled(bool)));
+    connect(backlight, SIGNAL(toggled(bool)),
+            this, SLOT(onLightsToggled(bool)));
+#ifndef 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 &)),
@@ -136,8 +142,8 @@ void SettingsWindow::onSliderValueChanged(int value)
         return;
     }
     zoomLabel->setText(tr("Zoom level: %1%").arg(value));
-#ifdef Q_WS_MAEMO_5
-    // Re-scaling the book view is too much for the N900
+#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
index 8ffb22d..98aa51c 100644 (file)
@@ -30,7 +30,11 @@ AdopterWindow::AdopterWindow(QWidget *parent):
     frame->setLayout(layout);
     setCentralWidget(frame);
 
-#ifndef Q_OS_SYMBIAN
+#ifdef Q_OS_SYMBIAN
+    QAction *closeAction = new QAction(parent? tr("Back"): tr("Exit"), this);
+    closeAction->setSoftKeyRole(QAction::NegativeSoftKey);
+    connect(closeAction, SIGNAL(triggered()), this, SLOT(close()));
+#else
     // Tool bar
     setUnifiedTitleAndToolBarOnMac(true);
     toolBar = addToolBar("controls");
index 98dae5a..0e4d295 100644 (file)
@@ -2,9 +2,10 @@
 
 #include "dyalog.h"
 
-Dyalog::Dyalog(QWidget *parent, bool showButtons):
+Dyalog::Dyalog(QWidget *parent, bool showButtons_):
     QDialog(parent, Qt::Dialog | Qt::WindowTitleHint |
-                    Qt::CustomizeWindowHint | Qt::WindowCloseButtonHint)
+                    Qt::CustomizeWindowHint | Qt::WindowCloseButtonHint),
+    showButtons(showButtons_)
 {
     scroller = new QScrollArea(this);
 
@@ -25,18 +26,26 @@ Dyalog::Dyalog(QWidget *parent, bool showButtons):
     QBoxLayout *boxLayout;
     QRect screenGeometry = QApplication::desktop()->screenGeometry();
     if (screenGeometry.width() < screenGeometry.height()) {
-        buttonBox = new QDialogButtonBox(Qt::Horizontal, this);
+#ifndef Q_OS_SYMBIAN
+        if (showButtons) {
+            buttonBox = new QDialogButtonBox(Qt::Horizontal, this);
+        }
+#endif
         boxLayout = new QVBoxLayout(this);
     } else {
-        buttonBox = new QDialogButtonBox(Qt::Vertical, this);
+#ifndef Q_OS_SYMBIAN
+        if (showButtons) {
+            buttonBox = new QDialogButtonBox(Qt::Vertical, this);
+        }
+#endif
         boxLayout = new QHBoxLayout(this);
     }
     boxLayout->addWidget(scroller);
+#ifndef Q_OS_SYMBIAN
     if (showButtons) {
         boxLayout->addWidget(buttonBox);
-    } else {
-        buttonBox->hide();
     }
+#endif
     setLayout(boxLayout);
 
     scroller->setWidget(content);
@@ -44,10 +53,11 @@ Dyalog::Dyalog(QWidget *parent, bool showButtons):
     scroller->setWidgetResizable(true);
 
 #ifdef Q_OS_SYMBIAN
-    QAction *closeAction = new QAction(tr("Close"), this);
+    QAction *closeAction = new QAction(tr("Back"), this);
     closeAction->setSoftKeyRole(QAction::NegativeSoftKey);
     connect(closeAction, SIGNAL(triggered()), this, SLOT(reject()));
     addAction(closeAction);
+    menu = 0;
 #endif // Q_OS_SYMBIAN
 }
 
@@ -61,12 +71,41 @@ void Dyalog::addStretch(int stretch)
     contentLayout->addStretch(stretch);
 }
 
-void Dyalog::addButton(QPushButton *button, QDialogButtonBox::ButtonRole role)
+void Dyalog::addButton(const QString &label, QObject *receiver,
+                       const char *slot, QDialogButtonBox::ButtonRole role)
 {
+    if (!showButtons) {
+        return;
+    }
+#ifdef Q_OS_SYMBIAN
+    Q_UNUSED(role);
+    if (!menu) {
+        QAction *menuAction = new QAction(tr("Options"), this);
+        menuAction->setSoftKeyRole(QAction::PositiveSoftKey);
+        menu = new QMenu(this);
+        menuAction->setMenu(menu);
+    }
+    QAction *action = new QAction(label, this);
+    connect(action, SIGNAL(triggered()), receiver, slot);
+    menu->addAction(action);
+#else
+    QPushButton *button = new QPushButton(label, this);
+    connect(button, SIGNAL(clicked()), receiver, slot);
     buttonBox->addButton(button, role);
+#endif // Q_OS_SYMBIAN
+}
+
+#ifdef Q_OS_SYMBIAN
+
+void Dyalog::show()
+{
+    showMaximized();
 }
 
-QPushButton *Dyalog::addButton(QDialogButtonBox::StandardButton button)
+int Dyalog::exec()
 {
-    return buttonBox->addButton(button);
+    showMaximized();
+    return QDialog::exec();
 }
+
+#endif // Q_OS_SYMBIAN
index 020ad70..9f9cfed 100644 (file)
@@ -8,6 +8,7 @@ class QWidget;
 class QPushButton;
 class QScrollArea;
 class QVBoxLayout;
+class QMenu;
 
 /** Maemo- and Mac-friendly dialog box. */
 class Dyalog: public QDialog
@@ -24,17 +25,24 @@ public:
     void addStretch(int stretch = 0);
 
     /** Add button to the dialog button box. */
-    void addButton(QPushButton *button,
+    void addButton(const QString &label, QObject *receiver, const char *slot,
         QDialogButtonBox::ButtonRole role = QDialogButtonBox::AcceptRole);
 
-    /** Add standard button to the dialog button box. */
-    QPushButton *addButton(QDialogButtonBox::StandardButton button);
+public slots:
+#ifdef Q_OS_SYMBIAN
+    void show();
+    int exec();
+#endif
 
 protected:
     QScrollArea *scroller;
     QWidget *content;
     QVBoxLayout *contentLayout;
     QDialogButtonBox *buttonBox;
+    bool showButtons;
+#ifdef Q_OS_SYMBIAN
+    QMenu *menu;
+#endif
 };
 
 #endif // DYALOG_H
index 28a1e43..9317aa6 100644 (file)
@@ -31,9 +31,11 @@ ListWindow::ListWindow(QWidget *parent): QMainWindow(parent), list(0)
     setCentralWidget(frame);
     contentLayout = new QHBoxLayout();
     frame->setLayout(contentLayout);
+#ifndef Q_OS_SYMBIAN
     buttonBox = new QDialogButtonBox(Qt::Vertical, this);
     contentLayout->addWidget(buttonBox);
-#endif
+#endif // Q_OS_SYMBIAN
+#endif // Q_WS_MAEMO_5
 }
 
 void ListWindow::addList(ListView *listView)
@@ -64,31 +66,43 @@ void ListWindow::addAction(const QString &title, QObject *receiver,
                            QDialogButtonBox::ButtonRole role)
 {
     Trace t("ListWindow::addAction");
-#ifndef Q_WS_MAEMO_5
-    Q_UNUSED(iconPath);
-    QPushButton *button = buttonBox->addButton(title, role);
-    connect(button, SIGNAL(clicked()), receiver, slot);
-#else
+#ifdef Q_WS_MAEMO_5
     Q_UNUSED(role);
     QPushButton *button = new QPushButton(QIcon(iconPath), title, this);
     contentLayout->addWidget(button);
     connect(button, SIGNAL(clicked()), receiver, slot);
-#endif // ! Q_WS_MAEMO_5
+#elif defined(Q_OS_SYMBIAN)
+    Q_UNUSED(role);
+    QAction *action = new QAction(title, this);
+    connect(action, SIGNAL(triggered()), receiver, slot);
+    action->setSoftKeyRole(QAction::PositiveSoftKey);
+    menuBar()->addAction(action);
+#else
+    Q_UNUSED(iconPath);
+    QPushButton *button = buttonBox->addButton(title, role);
+    connect(button, SIGNAL(clicked()), receiver, slot);
+#endif // Q_WS_MAEMO_5
 }
 
 void ListWindow::addItemAction(const QString &title, QObject *receiver,
                                const char *slot)
 {
     Trace t("ListWindow::addItemAction");
-#ifndef Q_WS_MAEMO_5
+#ifdef Q_WS_MAEMO
+    popup->addAction(title, receiver, slot);
+#elif defined Q_OS_SYMBIAN
+    QAction *action = new QAction(title, this);
+    connect(action, SIGNAL(triggered()), receiver, slot);
+    action->setSoftKeyRole(QAction::PositiveSoftKey);
+    menuBar()->addAction(action);
+    // FIXME: Add action to the list of item specific actions
+#else
     QPushButton *button =
             buttonBox->addButton(title, QDialogButtonBox::ActionRole);
     connect(button, SIGNAL(clicked()), receiver, slot);
     itemButtons.append(button);
     activateItemButtons();
-#else
-    popup->addAction(title, receiver, slot);
-#endif // ! Q_WS_MAEMO_5
+#endif // Q_WS_MAEMO_5
 }
 
 #ifdef Q_WS_MAEMO_5
@@ -155,3 +169,12 @@ void ListWindow::onModelChanged()
 }
 
 #endif // Q_WS_MAEMO_5
+
+#ifdef Q_OS_SYMBIAN
+
+void ListWindow::show()
+{
+    showMaximized();
+}
+
+#endif // Q_OS_SYMBIAN
index 4a75974..956c447 100644 (file)
@@ -43,6 +43,11 @@ public:
     void addItemAction(const QString &title, QObject *receiver,
                        const char *slot);
 
+public slots:
+#ifdef Q_OS_SYMBIAN
+    void show();
+#endif
+
 protected slots:
     void onSelectionChanged(const QItemSelection &selected,
                             const QItemSelection &deselected);