Commit 5331b09a authored by Laurent Montel's avatar Laurent Montel 😁

By default debug is enabled. Add more categories. Fix enabled/disable ok

parent d51181a3
......@@ -22,6 +22,7 @@
#include "../src/configurecustomsettingdialog.h"
#include "../src/configurecustomsettingwidget.h"
#include <QDialogButtonBox>
#include <QPushButton>
#include <qtest.h>
ConfigureCustomSettingDialogTest::ConfigureCustomSettingDialogTest(QObject *parent)
: QObject(parent)
......@@ -39,8 +40,10 @@ void ConfigureCustomSettingDialogTest::shouldHaveDefaultValue()
ConfigureCustomSettingDialog dlg;
QDialogButtonBox *buttonBox = dlg.findChild<QDialogButtonBox *>(QStringLiteral("buttonbox"));
QVERIFY(buttonBox);
QVERIFY(!buttonBox->button(QDialogButtonBox::Ok)->isEnabled());
ConfigureCustomSettingWidget *widget = dlg.findChild<ConfigureCustomSettingWidget *>(QStringLiteral("customsettingwidget"));
QVERIFY(widget);
}
QTEST_MAIN(ConfigureCustomSettingDialogTest)
......@@ -23,6 +23,7 @@
#include <QComboBox>
#include <QLabel>
#include <QLineEdit>
#include <QSignalSpy>
#include <qcheckbox.h>
#include <qtest.h>
......@@ -75,4 +76,22 @@ void ConfigureCustomSettingWidgetTest::shouldRestoreRules()
QCOMPARE(input, w.rule());
}
void ConfigureCustomSettingWidgetTest::shouldEmitSignalWhenWeChangeLogName()
{
ConfigureCustomSettingWidget w;
QLineEdit *categoryLineEdit = w.findChild<QLineEdit *>(QStringLiteral("category_lineedit"));
QVERIFY(categoryLineEdit);
QSignalSpy spy(&w, SIGNAL(enableButton(bool)));
categoryLineEdit->setText(QStringLiteral("bla"));
QCOMPARE(spy.count(), 1);
QCOMPARE(spy.at(0).at(0).value<bool>(), true);
categoryLineEdit->clear();
QCOMPARE(spy.count(), 2);
QCOMPARE(spy.at(1).at(0).value<bool>(), false);
categoryLineEdit->setText(QStringLiteral(" "));
QCOMPARE(spy.count(), 3);
QCOMPARE(spy.at(2).at(0).value<bool>(), false);
}
QTEST_MAIN(ConfigureCustomSettingWidgetTest)
......@@ -33,6 +33,7 @@ private Q_SLOTS:
void shouldHaveDefaultValue();
void shouldRestoreRules_data();
void shouldRestoreRules();
void shouldEmitSignalWhenWeChangeLogName();
};
#endif // CONFIGURECUSTOMSETTINGWIDGETTEST_H
# Format : logname<space>description
#kdepimlibs
log_kldap kioslave (kldap)
log_sieve kioslave (sieve)
log_smtp kioslave (smtp)
log_pop3 kioslave (pop3)
log_kcalutils kcalutils (pim lib)
log_kimap kimap (pim lib)
log_kidentitymanagement kidentitymanagement (pim lib)
log_kcontacts kcontacts (pim lib)
log_ktnef ktnef (pim lib)
log_mailtransport mailtransport (pim lib)
log_kmbox kmbox (pim lib)
log_kblog kblog (pim lib)
log_kcalcore kcalcore (pim lib)
log_kalarmcal kalarmcal (pim lib)
log_kontactinterface kontactinterface (pim lib)
log_kxmlrpcclient kxmlrpcclient (pim lib)
log_ldap ldap (pim lib)
log_akonadicalendar akonadicalendar (pim lib)
# kdepim
log_sieveeditor kdepim (sieveeditor)
log_ldapclient kdepim (ldapclient)
......@@ -43,3 +63,18 @@ log_messageviewer kdepim (messageviewer)
log_pimsettingexporter kdepim (pimsettingexporter)
log_kaddressbook kdepim (kaddressbook)
log_importwizard kdepim (importwizard)
#kdegames
log_granatier kdegames (granatier)
log_ksirkskineditor kdegames (ksirk)
ksnakeduel_smtp kdegames (ksnakeduel)
log_kgoldrunner kdegames (kgoldrunner)
log_kshisen kdegames (kshisen)
log_libkmahjongg lib kdegames (libkmahjongg)
LOG_KUBRICK kdegames (kubrick)
log_lskat kdegames (lskat)
log_fourinline kdegames (kfourinline)
#kdeedu
log_klettres kdeedu (kletters)
......@@ -24,6 +24,7 @@
#include <qboxlayout.h>
#include <KLocalizedString>
#include <qdialogbuttonbox.h>
#include <QPushButton>
ConfigureCustomSettingDialog::ConfigureCustomSettingDialog(QWidget *parent)
: QDialog(parent)
......@@ -39,7 +40,11 @@ ConfigureCustomSettingDialog::ConfigureCustomSettingDialog(QWidget *parent)
buttonBox->setObjectName(QStringLiteral("buttonbox"));
connect(buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept);
connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject);
QPushButton *buttonOk = buttonBox->button(QDialogButtonBox::Ok);
buttonOk->setEnabled(false);
connect(mCustomSettingWidget, SIGNAL(enableButton(bool)), buttonOk, SLOT(setEnabled(bool)));
mainLayout->addWidget(buttonBox);
}
ConfigureCustomSettingDialog::~ConfigureCustomSettingDialog()
......
......@@ -39,6 +39,7 @@ ConfigureCustomSettingWidget::ConfigureCustomSettingWidget(QWidget *parent)
lab->setObjectName(QStringLiteral("category_label"));
mCategoryLineEdit = new QLineEdit;
mCategoryLineEdit->setObjectName(QStringLiteral("category_lineedit"));
connect(mCategoryLineEdit, SIGNAL(textChanged(QString)), SLOT(slotTextChanged(QString)));
QHBoxLayout *categoryLayout = new QHBoxLayout;
vbox->addLayout(categoryLayout);
categoryLayout->addWidget(lab);
......@@ -69,6 +70,12 @@ ConfigureCustomSettingWidget::~ConfigureCustomSettingWidget()
}
void ConfigureCustomSettingWidget::slotTextChanged(const QString &text)
{
const bool state = !text.trimmed().isEmpty();
Q_EMIT enableButton(state);
}
void ConfigureCustomSettingWidget::setRule(const QString &rule)
{
const Category cat = KDebugSettingsUtil::parseLineLoggingQtCategory(rule);
......@@ -90,7 +97,7 @@ void ConfigureCustomSettingWidget::setRule(const QString &rule)
QString ConfigureCustomSettingWidget::rule()
{
QString ruleStr = mCategoryLineEdit->text();
QString ruleStr = mCategoryLineEdit->text().trimmed();
if (!ruleStr.isEmpty()) {
const QString type = mCategoryType->currentData().toString();
if (!type.isEmpty()) {
......
......@@ -31,8 +31,16 @@ class ConfigureCustomSettingWidget : public QWidget
public:
explicit ConfigureCustomSettingWidget(QWidget *parent = Q_NULLPTR);
~ConfigureCustomSettingWidget();
QString rule();
void setRule(const QString &rule);
Q_SIGNALS:
void enableButton(bool state);
private Q_SLOTS:
void slotTextChanged(const QString &);
private:
QLineEdit *mCategoryLineEdit;
QCheckBox *mEnableCategory;
......
......@@ -77,6 +77,7 @@ KDeApplicationListWidgetItem::KDeApplicationListWidgetItem(QListWidget *parent)
: QListWidgetItem(parent)
{
setFlags(flags() | Qt::ItemIsUserCheckable);
setCheckState(Qt::Checked);
}
KDeApplicationListWidgetItem::~KDeApplicationListWidgetItem()
......
......@@ -29,7 +29,7 @@ class KDEApplicationDebugSettingPage;
class CustomDebugSettingsPage;
struct Category {
Category()
: enabled(false)
: enabled(true)
{
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment