Commit aabd27a5 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Modernize code

parent 36c930b6
......@@ -87,7 +87,7 @@ bool WinIdEmbedder::eventFilter(QObject *o, QEvent *e)
{
if (e->type() == QEvent::Show && o->isWidgetType()
&& o->inherits("QDialog")) {
QWidget *w = static_cast<QWidget *>(o);
auto *w = static_cast<QWidget *>(o);
if (print) {
cout << "winId: " << w->winId() << endl;
}
......@@ -396,7 +396,7 @@ int main(int argc, char *argv[])
}
// --yesno and other message boxes
KMessageBox::DialogType type = static_cast<KMessageBox::DialogType>(0);
auto type = static_cast<KMessageBox::DialogType>(0);
QMessageBox::Icon icon = QMessageBox::Question;
QByteArray option;
if (parser.isSet(QStringLiteral("yesno"))) {
......@@ -479,7 +479,7 @@ int main(int argc, char *argv[])
QDialog dialog;
dialog.setWindowTitle(title);
QDialogButtonBox *buttonBox = new QDialogButtonBox(&dialog);
auto *buttonBox = new QDialogButtonBox(&dialog);
KMessageBox::Options options = KMessageBox::NoExec;
switch (type) {
......@@ -523,7 +523,7 @@ int main(int argc, char *argv[])
if (!dontagain.isEmpty()) {
// We use NoExec in order to call handleXGeometry before exec
// But that means we need to query the state of the dontShowAgain checkbox ourselves too...
QCheckBox *cb = dialog.findChild<QCheckBox *>();
auto *cb = dialog.findChild<QCheckBox *>();
Q_ASSERT(cb);
if (cb && cb->isChecked()) {
if (type == KMessageBox::WarningContinueCancel) {
......@@ -615,7 +615,7 @@ int main(int argc, char *argv[])
passiveicon,
(QWidget *)nullptr, // parent
timeout);
QTimer *timer = new QTimer();
auto *timer = new QTimer();
QObject::connect(timer, SIGNAL(timeout()), qApp, SLOT(quit()));
QObject::connect(popup, QOverload<>::of(&KPassivePopup::clicked), qApp, &QApplication::quit);
timer->setSingleShot(true);
......
......@@ -11,7 +11,7 @@ KListBoxDialog::KListBoxDialog(const QString &text, QWidget *parent)
: QDialog(parent)
{
setModal(true);
QVBoxLayout *vLayout = new QVBoxLayout(this);
auto *vLayout = new QVBoxLayout(this);
label = new QLabel(text, this);
vLayout->addWidget(label);
......@@ -21,7 +21,7 @@ KListBoxDialog::KListBoxDialog(const QString &text, QWidget *parent)
vLayout->addWidget(table);
table->setFocus();
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
auto *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
vLayout->addWidget(buttonBox);
connect(buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept);
......
......@@ -31,7 +31,7 @@
static void addButtonBox(QDialog &dlg, QDialogButtonBox::StandardButtons buttons = QDialogButtonBox::Ok | QDialogButtonBox::Cancel)
{
QDialogButtonBox *buttonBox = new QDialogButtonBox(buttons, &dlg);
auto *buttonBox = new QDialogButtonBox(buttons, &dlg);
dlg.layout()->addWidget(buttonBox);
QObject::connect(buttonBox, &QDialogButtonBox::accepted, &dlg, &QDialog::accept);
QObject::connect(buttonBox, &QDialogButtonBox::rejected, &dlg, &QDialog::reject);
......@@ -88,9 +88,9 @@ int Widgets::textBox(QWidget *parent, int width, int height, const QString &titl
QDialog dlg(parent);
dlg.setWindowTitle(title);
QVBoxLayout *mainLayout = new QVBoxLayout(&dlg);
auto *mainLayout = new QVBoxLayout(&dlg);
KTextEdit *edit = new KTextEdit(&dlg);
auto *edit = new KTextEdit(&dlg);
mainLayout->addWidget(edit);
edit->setReadOnly(true);
edit->setFocus();
......@@ -130,9 +130,9 @@ int Widgets::imgBox(QWidget *parent, const QString &title, const QString &file)
QDialog dlg(parent);
dlg.setWindowTitle(title);
QVBoxLayout *mainLayout = new QVBoxLayout(&dlg);
auto *mainLayout = new QVBoxLayout(&dlg);
QLabel *label = new QLabel(&dlg);
auto *label = new QLabel(&dlg);
mainLayout->addWidget(label);
addButtonBox(dlg, QDialogButtonBox::Ok);
......@@ -159,20 +159,20 @@ int Widgets::imgInputBox(QWidget *parent, const QString &title, const QString &f
QDialog dlg(parent);
dlg.setWindowTitle(title);
QVBoxLayout *mainLayout = new QVBoxLayout(&dlg);
auto *mainLayout = new QVBoxLayout(&dlg);
if (!text.isEmpty()) {
QLabel *head = new QLabel(&dlg);
auto *head = new QLabel(&dlg);
head->setText(text);
mainLayout->addWidget(head);
}
QLabel *label = new QLabel(&dlg);
auto *label = new QLabel(&dlg);
mainLayout->addWidget(label);
label->setPixmap(QPixmap(file));
QLineEdit *edit = new QLineEdit(&dlg);
auto *edit = new QLineEdit(&dlg);
mainLayout->addWidget(edit);
edit->setReadOnly(false);
edit->setFocus();
......@@ -193,15 +193,15 @@ int Widgets::textInputBox(QWidget *parent, int width, int height, const QString
{
QDialog dlg(parent);
dlg.setWindowTitle(title);
QVBoxLayout *mainLayout = new QVBoxLayout(&dlg);
auto *mainLayout = new QVBoxLayout(&dlg);
if (!text.isEmpty()) {
QLabel *label = new QLabel(&dlg);
auto *label = new QLabel(&dlg);
mainLayout->addWidget(label);
label->setText(text);
}
KTextEdit *edit = new KTextEdit(&dlg);
auto *edit = new KTextEdit(&dlg);
mainLayout->addWidget(edit);
edit->setReadOnly(false);
edit->setFocus();
......@@ -225,12 +225,12 @@ bool Widgets::comboBox(QWidget *parent, const QString &title, const QString &tex
QDialog dlg(parent);
dlg.setWindowTitle(title);
QVBoxLayout *mainLayout = new QVBoxLayout(&dlg);
auto *mainLayout = new QVBoxLayout(&dlg);
QLabel *label = new QLabel(&dlg);
auto *label = new QLabel(&dlg);
label->setText(text);
mainLayout->addWidget(label);
QComboBox *combo = new QComboBox(&dlg);
auto *combo = new QComboBox(&dlg);
combo->addItems(args);
combo->setCurrentIndex(combo->findText(defaultEntry));
combo->setFocus();
......@@ -353,12 +353,12 @@ bool Widgets::slider(QWidget *parent, const QString &title, const QString &text,
QDialog dlg(parent);
dlg.setWindowTitle(title);
QVBoxLayout *mainLayout = new QVBoxLayout(&dlg);
auto *mainLayout = new QVBoxLayout(&dlg);
QLabel *label = new QLabel(&dlg);
auto *label = new QLabel(&dlg);
mainLayout->addWidget(label);
label->setText(text);
QSlider *slider = new QSlider(&dlg);
auto *slider = new QSlider(&dlg);
mainLayout->addWidget(slider);
slider->setMinimum(minValue);
slider->setMaximum(maxValue);
......@@ -385,12 +385,12 @@ bool Widgets::calendar(QWidget *parent, const QString &title, const QString &tex
QDialog dlg(parent);
dlg.setWindowTitle(title);
QVBoxLayout *mainLayout = new QVBoxLayout(&dlg);
auto *mainLayout = new QVBoxLayout(&dlg);
QLabel *label = new QLabel(&dlg);
auto *label = new QLabel(&dlg);
mainLayout->addWidget(label);
label->setText(text);
KDatePicker *dateWidget = new KDatePicker(defaultEntry, &dlg);
auto *dateWidget = new KDatePicker(defaultEntry, &dlg);
mainLayout->addWidget(dateWidget);
dateWidget->setFocus();
addButtonBox(dlg);
......
Supports Markdown
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