#include <QtGui>
+#include <QDebug>
#include "devtools.h"
+#include "trace.h"
+#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);
- contents->setLayout(layout);
- scroller->setWidget(contents);
+ QLabel *level = new QLabel(tr("Trace level:"), this);
+ addWidget(level);
- QHBoxLayout *dialogLayout = new QHBoxLayout();
- dialogLayout->addWidget(scroller);
- setLayout(dialogLayout);
+ 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)));
}
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::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);
}
}
+
+void DevTools::onLevelButtonClicked(int level) {
+ Trace::level = (QtMsgType)level;
+ Settings::instance()->setValue("tracelevel", level);
+}