KUserFeedback

feedbackconfigdialog.cpp
1/*
2 SPDX-FileCopyrightText: 2016 Volker Krause <vkrause@kde.org>
3
4 SPDX-License-Identifier: MIT
5*/
6
7#include "feedbackconfigdialog.h"
8#include "ui_feedbackconfigdialog.h"
9
10#include <provider.h>
11
12#include <QDebug>
13#include <QPushButton>
14
15using namespace KUserFeedback;
16
17namespace KUserFeedback {
18class FeedbackConfigDialogPrivate {
19public:
20 void updateButtonState();
21
22 std::unique_ptr<Ui::FeedbackConfigDialog> ui;
23};
24}
25
27 QDialog(parent),
28 d(new FeedbackConfigDialogPrivate)
29{
30 d->ui.reset(new Ui::FeedbackConfigDialog);
31 d->ui->setupUi(this);
32 d->ui->buttonBox->button(QDialogButtonBox::Ok)->setText(tr("Contribute!"));
33 d->ui->buttonBox->button(QDialogButtonBox::Close)->setText(tr("No, I do not want to contribute."));
34}
35
36FeedbackConfigDialog::~FeedbackConfigDialog()
37{
38}
39
41{
42 d->ui->configWidget->setFeedbackProvider(provider);
43 connect(d->ui->configWidget, &FeedbackConfigWidget::configurationChanged, this, [this]() { d->updateButtonState(); });
44 d->updateButtonState();
45}
46
48{
49 auto p = d->ui->configWidget->feedbackProvider();
50 p->setTelemetryMode(d->ui->configWidget->telemetryMode());
51 p->setSurveyInterval(d->ui->configWidget->surveyInterval());
53}
54
55void FeedbackConfigDialogPrivate::updateButtonState()
56{
57 const auto any = ui->configWidget->surveyInterval() >= 0
58 || ui->configWidget->telemetryMode() != Provider::NoTelemetry;
59
60 ui->buttonBox->button(QDialogButtonBox::Ok)->setVisible(any);
61 ui->buttonBox->button(QDialogButtonBox::Close)->setVisible(!any);
62}
63
64#include "moc_feedbackconfigdialog.cpp"
void setFeedbackProvider(KUserFeedback::Provider *provider)
Set the feedback provider that this dialog configures.
FeedbackConfigDialog(QWidget *parent=nullptr)
Create a new feedback configuration dialog.
void accept() override
Accepts the dialog and write changes made by the user to the feedback provider.
void configurationChanged()
Emitted when any changes are made to the configuration represented in this widget.
The central object managing data sources and transmitting feedback to the server.
Definition provider.h:32
@ NoTelemetry
Transmit no data at all.
Definition provider.h:103
Classes for integrating telemetry collection, survey targeting, and contribution encouragenemt and co...
virtual void accept()
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
QString tr(const char *sourceText, const char *disambiguation, int n)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Nov 29 2024 11:48:42 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.