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()
box->toggle(Trace::level);
connect(box, SIGNAL(buttonClicked(int)),
this, SLOT(onLevelButtonClicked(int)));
+ addStretch();
}
void DevTools::onClear()
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()
void MainWindow::showInfo()
{
if (mCurrent.isValid()) {
- (new InfoDialog(Library::instance()->book(mCurrent), this, false))->exec();
+ (new InfoDialog(Library::instance()->book(mCurrent), this, false))->
+ exec();
}
}
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 © 2010 "
"Akos Polster <akos@pipacs.com><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();
}
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) {
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);
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 &)),
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
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");
#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);
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);
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
}
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
class QPushButton;
class QScrollArea;
class QVBoxLayout;
+class QMenu;
/** Maemo- and Mac-friendly dialog box. */
class Dyalog: public QDialog
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
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)
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
}
#endif // Q_WS_MAEMO_5
+
+#ifdef Q_OS_SYMBIAN
+
+void ListWindow::show()
+{
+ showMaximized();
+}
+
+#endif // Q_OS_SYMBIAN
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);