diff --git a/rkward/dialogs/CMakeLists.txt b/rkward/dialogs/CMakeLists.txt index d5074048..2c97eb90 100644 --- a/rkward/dialogs/CMakeLists.txt +++ b/rkward/dialogs/CMakeLists.txt @@ -1,15 +1,15 @@ INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ) SET(dialogs_STAT_SRCS startupdialog.cpp rkloadlibsdialog.cpp rkreadlinedialog.cpp rkimportdialog.cpp rkselectlistdialog.cpp rkrecoverdialog.cpp rkerrordialog.cpp rksetupwizard.cpp ) ADD_LIBRARY(dialogs STATIC ${dialogs_STAT_SRCS}) -TARGET_LINK_LIBRARIES(dialogs Qt5::Widgets KF5::Parts KF5::ConfigWidgets) +TARGET_LINK_LIBRARIES(dialogs Qt5::Widgets KF5::Parts KF5::ConfigWidgets KF5::TextEditor) diff --git a/rkward/dialogs/rksetupwizard.cpp b/rkward/dialogs/rksetupwizard.cpp index aa7fc093..b14c981e 100644 --- a/rkward/dialogs/rksetupwizard.cpp +++ b/rkward/dialogs/rksetupwizard.cpp @@ -1,80 +1,205 @@ /*************************************************************************** rksetupwizard - description ------------------- begin : Fri May 25 20200 copyright : (C) 2020 by Thomas Friedrichsmeier email : thomas.friedrichsmeier@kdemail.net ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #include "rksetupwizard.h" +#include + +#include +#include +#include +#include +#include +#include + +#include +#include + #include "../settings/rksettingsmoduleplugins.h" #include "../settings/rksettingsmodulegeneral.h" #include "../misc/rkcommonfunctions.h" +#include "../misc/rkstandardicons.h" #include "../windows/katepluginintegration.h" #include "../plugin/rkcomponentmap.h" +#include "../rbackend/rkrinterface.h" +#include "../rkglobals.h" #include "../rkward.h" #include "../debug.h" -#include - -RKSetupWizard::has_been_run = false; +bool RKSetupWizard::has_been_run = false; + +class RKSetupWizardItem { +public: + enum Status { + Error, + Warning, + Good + }; + RKSetupWizardItem(const QString &shortlabel, const QString &longlabel=QString(), Status status=Good, const QString &shortstatuslabel=QString()) : status(status), shortlabel(shortlabel), longlabel(longlabel), shortstatuslabel(shortstatuslabel), box(nullptr) {}; + ~RKSetupWizardItem() {}; + void createWidget(QGridLayout *layout, int row) { + QString icon_id; + if (status == Good) icon_id = QLatin1String("dialog-positive"); + else if (status == Warning) icon_id = QLatin1String("dialog-warning"); + else icon_id = QLatin1String("dialog_error"); + auto label = new QLabel(); + label->setPixmap(QIcon::fromTheme(icon_id).pixmap(32, 32)); // TODO: Correct way to not hardcode size? + layout->addWidget(label, row, 0); + + layout->addWidget(new QLabel(shortlabel + ": " + shortstatuslabel), row, 1); + + box = new QComboBox(); + if (!options.isEmpty()) { + for (int i = 0; i < options.size(); ++i) { + box->addItem(options[i].shortlabel); + } + layout->addWidget(box, row, 2); + } + + if (!(longlabel.isEmpty() && options.isEmpty())) { + QString details = longlabel; + for (int i = 0; i < options.size(); ++i) { + details += QString("

%1: %2

").arg(options[i].shortlabel).arg(options[i].longlabel); + } + auto info = new QPushButton(); + info->setIcon(RKStandardIcons::getIcon(RKStandardIcons::WindowHelp)); + QObject::connect(info, &QPushButton::clicked, [details, layout]() { KMessageBox::information(layout->parentWidget(), details); }); + layout->addWidget(info, row, 3); + } + } + void addOption(const QString &shortlabel, const QString &longlabel, std::function callback); + void setStatus(Status _status, const QString &_shortstatuslabel) { status = _status; shortstatuslabel = _shortstatuslabel; }; + void setShortLabel(const QString &label) { shortlabel = label; }; + void setLongLabel(const QString &label) { longlabel = label; }; +private: + struct Option { + QString shortlabel; + QString longlabel; + std::function callback; + }; + QList