From 3ce29c18fb643d34b86baab846bce2804479db48 Mon Sep 17 00:00:00 2001 From: Akos Polster Date: Sun, 26 Sep 2010 18:51:48 +0200 Subject: [PATCH] More Symbian fixes. --- bookmarkinfodialog.cpp | 10 +++----- devtools.cpp | 1 + infodialog.cpp | 10 +++----- mainwindow.cpp | 5 +++- settingswindow.cpp | 14 ++++++++--- widgets/adopterwindow.cpp | 6 ++++- widgets/dyalog.cpp | 59 +++++++++++++++++++++++++++++++++++++-------- widgets/dyalog.h | 14 ++++++++--- widgets/listwindow.cpp | 45 +++++++++++++++++++++++++--------- widgets/listwindow.h | 5 ++++ 10 files changed, 126 insertions(+), 43 deletions(-) diff --git a/bookmarkinfodialog.cpp b/bookmarkinfodialog.cpp index 7bdfb70..847cd3b 100644 --- a/bookmarkinfodialog.cpp +++ b/bookmarkinfodialog.cpp @@ -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() diff --git a/devtools.cpp b/devtools.cpp index cd8d270..49a32ad 100644 --- a/devtools.cpp +++ b/devtools.cpp @@ -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() diff --git a/infodialog.cpp b/infodialog.cpp index e541ceb..eadc647 100644 --- a/infodialog.cpp +++ b/infodialog.cpp @@ -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() diff --git a/mainwindow.cpp b/mainwindow.cpp index 850c070..6a539b9 100755 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -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("Dorian %1

Copyright © 2010 " "Akos Polster <akos@pipacs.com>
" "Licensed under GNU General Public License, Version 3
" "Source code: " "garage.maemo.org/projects/dorian").arg(DORIAN_VERSION)); aboutDialog->addWidget(label); + aboutDialog->addStretch(); aboutDialog->show(); } diff --git a/settingswindow.cpp b/settingswindow.cpp index 5c5dce4..f533e17 100644 --- a/settingswindow.cpp +++ b/settingswindow.cpp @@ -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 diff --git a/widgets/adopterwindow.cpp b/widgets/adopterwindow.cpp index 8ffb22d..98aa51c 100644 --- a/widgets/adopterwindow.cpp +++ b/widgets/adopterwindow.cpp @@ -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"); diff --git a/widgets/dyalog.cpp b/widgets/dyalog.cpp index 98dae5a..0e4d295 100644 --- a/widgets/dyalog.cpp +++ b/widgets/dyalog.cpp @@ -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 diff --git a/widgets/dyalog.h b/widgets/dyalog.h index 020ad70..9f9cfed 100644 --- a/widgets/dyalog.h +++ b/widgets/dyalog.h @@ -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 diff --git a/widgets/listwindow.cpp b/widgets/listwindow.cpp index 28a1e43..9317aa6 100644 --- a/widgets/listwindow.cpp +++ b/widgets/listwindow.cpp @@ -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 diff --git a/widgets/listwindow.h b/widgets/listwindow.h index 4a75974..956c447 100644 --- a/widgets/listwindow.h +++ b/widgets/listwindow.h @@ -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); -- 1.7.9.5