#include "book.h"
BookmarkInfoDialog::BookmarkInfoDialog(Book *b, int i, QWidget *parent):
- Dyalog(parent),
+ Dyalog(parent, true),
book(b),
index(i)
{
if (!really) {
if (QMessageBox::Yes !=
QMessageBox::question(this, tr("Delete bookmark"),
- tr("Delete bookmark?"),
- QMessageBox::Yes | QMessageBox::No)) {
+ tr("Delete bookmark?"), QMessageBox::Yes | QMessageBox::No)) {
return;
}
}
#include "settings.h"
#include "toolbuttonbox.h"
-DevTools::DevTools(QWidget *parent):
- QDialog(parent, Qt::Dialog | Qt::WindowTitleHint |
- Qt::CustomizeWindowHint | Qt::WindowCloseButtonHint)
+DevTools::DevTools(QWidget *parent): Dyalog(parent, false)
{
setWindowTitle(tr("Developer"));
- QScrollArea *scroller = new QScrollArea(this);
- scroller->setFrameStyle(QFrame::NoFrame);
-#ifdef Q_WS_MAEMO_5
- scroller->setProperty("FingerScrollable", true);
- scroller->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
-#else
- scroller->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
- setSizeGripEnabled(true);
-#endif // Q_WS_MAEMO_5
- scroller->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
-
- QWidget *contents = new QWidget(scroller);
- QVBoxLayout *layout = new QVBoxLayout(contents);
-
QPushButton *clearSettings = new QPushButton("Clear persistent data", this);
connect(clearSettings, SIGNAL(clicked()), this, SLOT(onClear()));
- layout->addWidget(clearSettings);
+ addWidget(clearSettings);
- QLabel *level = new QLabel(tr("Trace level:"), contents);
- layout->addWidget(level);
+ QLabel *level = new QLabel(tr("Trace level:"), this);
+ addWidget(level);
ToolButtonBox *box = new ToolButtonBox(this);
- layout->addWidget(box);
+ addWidget(box);
box->addButton(QtDebugMsg, tr("Debug"));
box->addButton(QtWarningMsg, tr("Warning"));
box->addButton(QtCriticalMsg, tr("Critical"));
box->toggle(Trace::level);
connect(box, SIGNAL(buttonClicked(int)),
this, SLOT(onLevelButtonClicked(int)));
-
- contents->setLayout(layout);
- scroller->setWidget(contents);
-
- QHBoxLayout *dialogLayout = new QHBoxLayout();
- dialogLayout->addWidget(scroller);
- setLayout(dialogLayout);
}
void DevTools::onClear()
{
if (QMessageBox::Yes ==
- QMessageBox::question(this, "Clear persistent data?",
- "Library and settings data will be cleared, "
- "application will be restarted. Continue?",
- QMessageBox::Yes
-#ifndef Q_WS_MAEMO_5
- , QMessageBox::No
-#endif
- )) {
+ QMessageBox::question(this, tr("Clear persistent data?"),
+ tr("Library and settings will be cleared, "
+ "application will be restarted. Continue?"),
+ QMessageBox::Yes | QMessageBox::No)) {
QSettings().clear();
QApplication::exit(1000);
}
#ifndef DEVTOOLS_H
#define DEVTOOLS_H
-#include <QtGui>
+#include "dyalog.h"
+
+class QWidget;
/** Display developer tools. */
-class DevTools: public QDialog
+class DevTools: public Dyalog
{
Q_OBJECT
<RCC>
<qresource prefix="/">
- <file>icons/document-properties.png</file>
<file>icons/preferences-system.png</file>
<file>icons/system-file-manager.png</file>
<file>icons/developer.png</file>
<file>icons/view-fullscreen.png</file>
- <file>icons/mac/document-properties.png</file>
<file>icons/mac/preferences-system.png</file>
<file>icons/mac/system-file-manager.png</file>
<file>icons/mac/developer.png</file>
<file>icons/folder.png</file>
<file>icons/view-normal.png</file>
<file>icons/mac/view-normal.png</file>
+ <file>icons/info.png</file>
+ <file>icons/mac/info.png</file>
</qresource>
</RCC>
#include "book.h"
#include "library.h"
-InfoDialog::InfoDialog(Book *b, QWidget *parent): Dyalog(parent), book(b)
+InfoDialog::InfoDialog(Book *b, QWidget *parent, bool showButtons):
+ Dyalog(parent, showButtons), book(b)
{
setWindowTitle(tr("Book Details"));
Q_OBJECT
public:
- explicit InfoDialog(Book *book, QWidget *parent = 0);
+ explicit InfoDialog(Book *book, QWidget *parent, bool showButtons = true);
public slots:
void onReadBook();
toolBar->setIconSize(QSize(42, 42));
#endif
- previousAction = addToolBarAction(view, SLOT(goPrevious()), "previous");
- nextAction = addToolBarAction(view, SLOT(goNext()), "next");
chaptersAction = addToolBarAction(this, SLOT(showChapters()), "chapters");
bookmarksAction = addToolBarAction(this, SLOT(showBookmarks()), "bookmarks");
+ infoAction = addToolBarAction(this, SLOT(showInfo()), "info");
+ libraryAction = addToolBarAction(this, SLOT(showLibrary()), "library");
#ifdef Q_WS_MAEMO_5
- infoAction = menuBar()->addAction(tr("Book details"));
- connect(infoAction, SIGNAL(triggered()), this, SLOT(showInfo()));
- libraryAction = menuBar()->addAction(tr("Library"));
- connect(libraryAction, SIGNAL(triggered()), this, SLOT(showLibrary()));
settingsAction = menuBar()->addAction(tr("Settings"));
connect(settingsAction, SIGNAL(triggered()), this, SLOT(showSettings()));
devToolsAction = menuBar()->addAction(tr("Developer"));
QAction *aboutAction = menuBar()->addAction(tr("About"));
connect(aboutAction, SIGNAL(triggered()), this, SLOT(about()));
#else
- infoAction = addToolBarAction(this, SLOT(showInfo()), "document-properties");
- libraryAction = addToolBarAction(this, SLOT(showLibrary()),
- "system-file-manager");
settingsAction = addToolBarAction(this, SLOT(showSettings()),
"preferences-system");
devToolsAction = addToolBarAction(this, SLOT(showDevTools()), "developer");
void MainWindow::showInfo()
{
if (mCurrent.isValid()) {
- (new InfoDialog(Library::instance()->book(mCurrent), this))->exec();
+ (new InfoDialog(Library::instance()->book(mCurrent), this, false))->exec();
}
}
}
#ifdef Q_WS_MAEMO_5
setAttribute(Qt::WA_Maemo5ShowProgressIndicator, false);
- previousAction->setIcon(QIcon(enablePrevious?
- ":/icons/previous.png" : ":/icons/previous-disabled.png"));
- nextAction->setIcon(QIcon(enableNext?
- ":/icons/next.png": ":/icons/next-disabled.png"));
#endif // Q_WS_MAEMO_5
- previousAction->setEnabled(enablePrevious);
- nextAction->setEnabled(enableNext);
}
void MainWindow::onAddBookmark()
QAction *fullScreenAction;
QAction *forwardAction;
QAction *backwardAction;
- QAction *previousAction;
- QAction *nextAction;
QAction *chaptersAction;
QToolBar *toolBar;
QDialog *settings;
#include "dyalog.h"
-Dyalog::Dyalog(QWidget *parent) :
+Dyalog::Dyalog(QWidget *parent, bool showButtons):
QDialog(parent, Qt::Dialog | Qt::WindowTitleHint |
Qt::CustomizeWindowHint | Qt::WindowCloseButtonHint)
{
boxLayout = new QHBoxLayout(this);
}
boxLayout->addWidget(scroller);
- boxLayout->addWidget(buttonBox);
+ if (showButtons) {
+ boxLayout->addWidget(buttonBox);
+ } else {
+ buttonBox->hide();
+ }
setLayout(boxLayout);
scroller->setWidget(content);
Q_OBJECT
public:
- explicit Dyalog(QWidget *parent = 0);
+ explicit Dyalog(QWidget *parent, bool showButtons = true);
/** Add widget to the scrollable content pane. */
void addWidget(QWidget *widget);