#include <QtGui>
#include "devtools.h"
+#include "trace.h"
+#include "settings.h"
+#include "toolbuttonbox.h"
+#include "bookdb.h"
+#include "platform.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);
+ addWidget(new QLabel(tr("Qt API version %1").arg(QT_VERSION_STR), this));
+ addWidget(new QLabel(tr("Qt runtime version %1").arg(qVersion()), this));
QPushButton *clearSettings = new QPushButton("Clear persistent data", this);
connect(clearSettings, SIGNAL(clicked()), this, SLOT(onClear()));
- layout->addWidget(clearSettings);
+ addWidget(clearSettings);
- contents->setLayout(layout);
- scroller->setWidget(contents);
+ addWidget(new QLabel(tr("Trace level:"), this));
+ ToolButtonBox *box = new ToolButtonBox(this);
+ addWidget(box);
+ box->addButton(QtDebugMsg, tr("Debug"));
+ box->addButton(QtWarningMsg, tr("Warning"));
+ box->addButton(QtCriticalMsg, tr("Critical"));
+ box->addButton(QtFatalMsg, tr("Fatal"));
+ box->toggle(Trace::level);
+ connect(box, SIGNAL(buttonClicked(int)),
+ this, SLOT(onLevelButtonClicked(int)));
- QHBoxLayout *dialogLayout = new QHBoxLayout();
- dialogLayout->addWidget(scroller);
- setLayout(dialogLayout);
+ QCheckBox *traceToFile = new QCheckBox(tr("Trace to file"), this);
+ addWidget(traceToFile);
+ traceToFile->setChecked(!Trace::fileName().isEmpty());
+ connect(traceToFile, SIGNAL(toggled(bool)),
+ this, SLOT(onTraceToFileToggled(bool)));
+
+ addStretch();
}
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();
+ BookDb::instance()->removeAll();
QApplication::exit(1000);
}
}
+
+void DevTools::onLevelButtonClicked(int level)
+{
+ Trace::level = (QtMsgType)level;
+ Settings::instance()->setValue("tracelevel", level);
+}
+
+void DevTools::onTraceToFileToggled(bool enable)
+{
+ QString name = enable? Platform::instance()->traceFileName(): QString();
+ Trace::setFileName(name);
+ Settings::instance()->setValue("tracefilename", name);
+}