diff --git a/CMakeLists.txt b/CMakeLists.txt index a618a74..13366a5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,126 +1,125 @@ cmake_minimum_required(VERSION 3.5) set(KF5_VERSION "5.65.0") # handled by release scripts set(KF5_DEP_VERSION "5.64.0") # handled by release scripts project(KXmlGui VERSION ${KF5_VERSION}) # ECM setup include(FeatureSummary) find_package(ECM 5.64.0 NO_MODULE) set_package_properties(ECM PROPERTIES TYPE REQUIRED DESCRIPTION "Extra CMake Modules." URL "https://projects.kde.org/projects/kdesupport/extra-cmake-modules") feature_summary(WHAT REQUIRED_PACKAGES_NOT_FOUND FATAL_ON_MISSING_REQUIRED_PACKAGES) set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH}) include(ECMMarkNonGuiExecutable) include(ECMSetupVersion) include(ECMGenerateHeaders) include(ECMAddQch) include(ECMGenerateExportHeader) include(KDEInstallDirs) include(KDEFrameworkCompilerSettings NO_POLICY_SCOPE) include(KDECMakeSettings) include(ECMQtDeclareLoggingCategory) ecm_setup_version(PROJECT VARIABLE_PREFIX KXMLGUI VERSION_HEADER "${CMAKE_CURRENT_BINARY_DIR}/kxmlgui_version.h" PACKAGE_VERSION_FILE "${CMAKE_CURRENT_BINARY_DIR}/KF5XmlGuiConfigVersion.cmake" SOVERSION 5) set(EXCLUDE_DEPRECATED_BEFORE_AND_AT 0 CACHE STRING "Control the range of deprecated API excluded from the build [default=0].") option(FORCE_DISABLE_KGLOBALACCEL "Force building KXmlGui without KGlobalAccel. Doing this will break global shortcut support. [default=OFF]" OFF) option(BUILD_QCH "Build API documentation in QCH format (for e.g. Qt Assistant, Qt Creator & KDevelop)" OFF) add_feature_info(QCH ${BUILD_QCH} "API documentation in QCH format (for e.g. Qt Assistant, Qt Creator & KDevelop)") option(BUILD_DESIGNERPLUGIN "Build plugin for Qt Designer" ON) add_feature_info(DESIGNERPLUGIN ${BUILD_DESIGNERPLUGIN} "Build plugin for Qt Designer") # Dependencies set(REQUIRED_QT_VERSION 5.11.0) find_package(Qt5 ${REQUIRED_QT_VERSION} CONFIG REQUIRED Widgets Xml Network PrintSupport) if (NOT ANDROID) find_package(Qt5 ${REQUIRED_QT_VERSION} CONFIG REQUIRED DBus) endif() find_package(KF5CoreAddons ${KF5_DEP_VERSION} REQUIRED) find_package(KF5ItemViews ${KF5_DEP_VERSION} REQUIRED) find_package(KF5Config ${KF5_DEP_VERSION} REQUIRED) find_package(KF5ConfigWidgets ${KF5_DEP_VERSION} REQUIRED) find_package(KF5I18n ${KF5_DEP_VERSION} REQUIRED) find_package(KF5IconThemes ${KF5_DEP_VERSION} REQUIRED) -find_package(KF5TextWidgets ${KF5_DEP_VERSION} REQUIRED) find_package(KF5WidgetsAddons ${KF5_DEP_VERSION} REQUIRED) find_package(KF5WindowSystem ${KF5_DEP_VERSION} REQUIRED) find_package(KF5Attica ${KF5_DEP_VERSION}) set_package_properties(KF5Attica PROPERTIES DESCRIPTION "A Qt library that implements the Open Collaboration Services API" PURPOSE "Support for Get Hot New Stuff in KXMLGUI" URL "https://projects.kde.org/attica" TYPE OPTIONAL ) set (HAVE_ATTICA ${KF5Attica_FOUND}) if (NOT FORCE_DISABLE_KGLOBALACCEL) find_package(KF5GlobalAccel ${KF5_DEP_VERSION} REQUIRED) endif() set (HAVE_GLOBALACCEL ${KF5GlobalAccel_FOUND}) add_definitions(-DQT_DISABLE_DEPRECATED_BEFORE=0x050d00) add_definitions(-DKF_DISABLE_DEPRECATED_BEFORE_AND_AT=0x053f00) # Subdirectories add_definitions(-DTRANSLATION_DOMAIN=\"kxmlgui5\") if (IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/po") ki18n_install(po) endif() add_subdirectory(src) if (BUILD_TESTING) add_subdirectory(tests) add_subdirectory(autotests) endif() # create a Config.cmake and a ConfigVersion.cmake file and install them set(CMAKECONFIG_INSTALL_DIR "${KDE_INSTALL_CMAKEPACKAGEDIR}/KF5XmlGui") if (BUILD_QCH) ecm_install_qch_export( TARGETS KF5XmlGui_QCH FILE KF5XmlGuiQchTargets.cmake DESTINATION "${CMAKECONFIG_INSTALL_DIR}" COMPONENT Devel ) set(PACKAGE_INCLUDE_QCHTARGETS "include(\"\${CMAKE_CURRENT_LIST_DIR}/KF5XmlGuiQchTargets.cmake\")") endif() include(CMakePackageConfigHelpers) set(HAVE_DBUS FALSE) if (TARGET Qt5::DBus) set(HAVE_DBUS TRUE) endif() configure_package_config_file( "${CMAKE_CURRENT_SOURCE_DIR}/KF5XmlGuiConfig.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/KF5XmlGuiConfig.cmake" PATH_VARS KDE_INSTALL_DBUSINTERFACEDIR INSTALL_DESTINATION ${CMAKECONFIG_INSTALL_DIR} ) install(FILES "${CMAKE_CURRENT_BINARY_DIR}/KF5XmlGuiConfig.cmake" "${CMAKE_CURRENT_BINARY_DIR}/KF5XmlGuiConfigVersion.cmake" DESTINATION "${CMAKECONFIG_INSTALL_DIR}" COMPONENT Devel ) install(EXPORT KF5XmlGuiTargets DESTINATION "${CMAKECONFIG_INSTALL_DIR}" FILE KF5XmlGuiTargets.cmake NAMESPACE KF5:: ) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/kxmlgui_version.h DESTINATION ${KDE_INSTALL_INCLUDEDIR_KF5} COMPONENT Devel ) install(FILES kxmlgui.categories DESTINATION ${KDE_INSTALL_LOGGINGCATEGORIESDIR}) feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 36e6a84..f1de377 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,194 +1,193 @@ add_subdirectory(ksendbugmail) if (HAVE_ATTICA) set (XMLGUI_EXTRA_LIBS ${XMLGUI_EXTRA_LIBS} KF5::Attica) endif () if (HAVE_GLOBALACCEL) set (XMLGUI_EXTRA_LIBS ${XMLGUI_EXTRA_LIBS} KF5::GlobalAccel) endif () if(WIN32) set (XMLGUI_EXTRA_LIBS ${XMLGUI_EXTRA_LIBS} secur32) # GetUserNameEx() endif() configure_file(config-xmlgui.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-xmlgui.h ) configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/kaboutapplicationconfigattica_p.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/kaboutapplicationconfigattica_p.h ) set(kxmlgui_SRCS kaboutapplicationdialog.cpp kaboutapplicationpersonlistdelegate_p.cpp kaboutapplicationpersonlistview_p.cpp kaboutapplicationpersonmodel_p.cpp kaboutkdedialog_p.cpp kaboutplugindialog.cpp kabstractaboutdialog_p.cpp kactioncategory.cpp kactioncollection.cpp kactionconflictdetector.cpp kbugreport.cpp kedittoolbar.cpp kgesture.cpp kgesturemap.cpp khelpmenu.cpp kkeysequencewidget.cpp klicensedialog_p.cpp kmainwindow.cpp kmenumenuhandler_p.cpp kshortcuteditwidget.cpp kshortcutschemeseditor.cpp kshortcutschemeshelper.cpp kshortcutsdialog.cpp kshortcutseditor.cpp kshortcutseditordelegate.cpp kshortcutseditoritem.cpp kshortcutwidget.cpp kswitchlanguagedialog_p.cpp ktoggletoolbaraction.cpp ktoolbar.cpp ktoolbarhandler.cpp ktoolbarhelper.cpp kxmlguibuilder.cpp kxmlguiclient.cpp kxmlguifactory.cpp kxmlguifactory_p.cpp kxmlguiversionhandler.cpp kxmlguiwindow.cpp kundoactions.cpp kcheckaccelerators.cpp ) if (TARGET Qt5::DBus) list(APPEND kxmlgui_SRCS kmainwindowiface.cpp) endif() # add the resource file qt5_add_resources(kxmlgui_SRCS kxmlgui.qrc) ecm_qt_declare_logging_category(kxmlgui_SRCS HEADER debug.h IDENTIFIER DEBUG_KXMLGUI CATEGORY_NAME kf5.kxmlgui) set(kxmlgui_UI kshortcutsdialog.ui kshortcutwidget.ui ) ki18n_wrap_ui(kxmlgui_SRCS ${kxmlgui_UI} ) add_library(KF5XmlGui ${kxmlgui_SRCS}) ecm_generate_export_header(KF5XmlGui BASE_NAME KXmlGui GROUP_BASE_NAME KF VERSION ${KF5_VERSION} DEPRECATED_BASE_VERSION 0 DEPRECATION_VERSIONS 4.0 4.1 5.0 EXCLUDE_DEPRECATED_BEFORE_AND_AT ${EXCLUDE_DEPRECATED_BEFORE_AND_AT} ) add_library(KF5::XmlGui ALIAS KF5XmlGui) target_include_directories(KF5XmlGui INTERFACE "$") target_link_libraries(KF5XmlGui PUBLIC Qt5::Xml #To parse the configuration (QDomDocument etc) Qt5::Widgets #QWidget is used everywhere KF5::ConfigCore #Reading config for ToolbarIcons, Shortcut Schemes... KF5::ConfigWidgets #KStandardAction, KToggleAction... PRIVATE Qt5::Network #QNetworkAccessManager in kaboutapplicationpersonmodel_p Qt5::PrintSupport #QPrinter in kshortcutseditor Qt5::CorePrivate #QSystemLocale in initializeLanguages KF5::CoreAddons #KAboutData KF5::WidgetsAddons KF5::ItemViews #KWidgetItemDelegate in KAboutApplicationPersonListDelegate KF5::I18n #i18n and i18nc in many places KF5::IconThemes #KIconLoader and KIconThemes in KToolBar - KF5::TextWidgets #KTextEdit in kbugreport KF5::WindowSystem #KKeyServer in kkeysequencewidget ${XMLGUI_EXTRA_LIBS} ) if (TARGET Qt5::DBus) target_link_libraries(KF5XmlGui PUBLIC Qt5::DBus) #QDBus connect to signal in KToolBar endif() set_target_properties(KF5XmlGui PROPERTIES VERSION ${KXMLGUI_VERSION_STRING} SOVERSION ${KXMLGUI_SOVERSION} EXPORT_NAME XmlGui ) ecm_generate_headers(KXmlGui_HEADERS HEADER_NAMES KAboutApplicationDialog KAboutPluginDialog KActionCategory KActionCollection KBugReport KEditToolBar KHelpMenu KKeySequenceWidget KMainWindow KShortcutsDialog KShortcutsEditor KShortcutWidget KToggleToolBarAction KToolBar KXMLGUIBuilder KXMLGUIClient KXMLGUIFactory KXmlGuiWindow KUndoActions REQUIRED_HEADERS KXmlGui_HEADERS ) install(TARGETS KF5XmlGui EXPORT KF5XmlGuiTargets ${KF5_INSTALL_TARGETS_DEFAULT_ARGS}) install(FILES kgesture_p.h kgesturemap_p.h ${CMAKE_CURRENT_BINARY_DIR}/kxmlgui_export.h ${KXmlGui_HEADERS} DESTINATION ${KDE_INSTALL_INCLUDEDIR_KF5}/KXmlGui COMPONENT Devel ) # install this file to be compatible, it is bundled in the resource file, too install( FILES ui_standards.rc DESTINATION ${KDE_INSTALL_CONFDIR}/ui ) if(BUILD_DESIGNERPLUGIN) add_subdirectory(designer) endif() if (BUILD_QCH) ecm_add_qch( KF5XmlGui_QCH NAME KXmlGui BASE_NAME KF5XmlGui VERSION ${KF5_VERSION} ORG_DOMAIN org.kde SOURCES # using only public headers, to cover only public API ${KXmlGui_HEADERS} MD_MAINPAGE "${CMAKE_SOURCE_DIR}/README.md" IMAGE_DIRS "${CMAKE_SOURCE_DIR}/docs/pics" LINK_QCHS Qt5Xml_QCH Qt5DBus_QCH Qt5Widgets_QCH KF5Config_QCH KF5ConfigWidgets_QCH INCLUDE_DIRS ${CMAKE_CURRENT_BINARY_DIR} BLANK_MACROS KXMLGUI_EXPORT KXMLGUI_DEPRECATED_EXPORT KXMLGUI_DEPRECATED "KXMLGUI_DEPRECATED_VERSION(x, y, t)" TAGFILE_INSTALL_DESTINATION ${KDE_INSTALL_QTQCHDIR} QCH_INSTALL_DESTINATION ${KDE_INSTALL_QTQCHDIR} COMPONENT Devel ) endif() include(ECMGeneratePriFile) ecm_generate_pri_file(BASE_NAME KXmlGui LIB_NAME KF5XmlGui DEPS "dbus xml widgets KConfigCore KConfigWidgets" FILENAME_VAR PRI_FILENAME INCLUDE_INSTALL_DIR ${KDE_INSTALL_INCLUDEDIR_KF5}/KXmlGui) install(FILES ${PRI_FILENAME} DESTINATION ${ECM_MKSPECS_INSTALL_DIR}) diff --git a/src/kbugreport.cpp b/src/kbugreport.cpp index 4f00cad..647ea93 100644 --- a/src/kbugreport.cpp +++ b/src/kbugreport.cpp @@ -1,594 +1,592 @@ /* This file is part of the KDE project Copyright (C) 1999 David Faure This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "kbugreport.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include +#include #include #include #include #include #include #include #include #include #include -#include #include #include "kdepackages.h" #include "../kxmlgui_version.h" #include "systeminformation_p.h" #include "config-xmlgui.h" #include class KBugReportPrivate { public: KBugReportPrivate(KBugReport *q): q(q), m_aboutData(KAboutData::applicationData()) {} enum BugDestination { BugsKdeOrg, CustomEmail, CustomUrl }; void _k_slotConfigureEmail(); void _k_slotSetFrom(); void _k_appChanged(int); void _k_updateUrl(); KBugReport *q; QProcess *m_process; KAboutData m_aboutData; - KTextEdit *m_lineedit; + QTextEdit *m_lineedit; QLineEdit *m_subject; QLabel *m_from; QLabel *m_version; QString m_strVersion; QGroupBox *m_bgSeverity; QPushButton *m_configureEmail; QComboBox *appcombo; QString lastError; QString kde_version; QString appname; QString os; QUrl url; QList severityButtons; int currentSeverity() { for (int i = 0; i < severityButtons.count(); i++) if (severityButtons[i]->isChecked()) { return i; } return -1; } BugDestination bugDestination; }; KBugReport::KBugReport(const KAboutData &aboutData, QWidget *_parent) : QDialog(_parent), d(new KBugReportPrivate(this)) { setWindowTitle(i18n("Submit Bug Report")); QDialogButtonBox *buttonBox = new QDialogButtonBox(this); buttonBox->setStandardButtons(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); connect(buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept); connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject); d->m_aboutData = aboutData; d->m_process = nullptr; d->bugDestination = KBugReportPrivate::CustomEmail; const QString bugAddress = d->m_aboutData.bugAddress(); if (bugAddress == QLatin1String("submit@bugs.kde.org")) { // This is a core KDE application -> redirect to the web form d->bugDestination = KBugReportPrivate::BugsKdeOrg; } else if (!QUrl(bugAddress).scheme().isEmpty()) { // The bug reporting address is a URL -> redirect to that d->bugDestination = KBugReportPrivate::CustomUrl; } if (d->bugDestination != KBugReportPrivate::CustomEmail) { KGuiItem::assign(buttonBox->button(QDialogButtonBox::Cancel), KStandardGuiItem::close()); } QLabel *tmpLabel; QVBoxLayout *lay = new QVBoxLayout; setLayout(lay); KTitleWidget *title = new KTitleWidget(this); title->setText(i18n("Submit Bug Report")); title->setPixmap(QIcon::fromTheme(QStringLiteral("tools-report-bug")).pixmap(32)); lay->addWidget(title); QGridLayout *glay = new QGridLayout(); lay->addLayout(glay); int row = 0; if (d->bugDestination == KBugReportPrivate::CustomEmail) { // From QString qwtstr = i18n("Your email address. If incorrect, use the Configure Email button to change it"); tmpLabel = new QLabel(i18nc("Email sender address", "From:"), this); glay->addWidget(tmpLabel, row, 0); tmpLabel->setWhatsThis(qwtstr); d->m_from = new QLabel(this); glay->addWidget(d->m_from, row, 1); d->m_from->setWhatsThis(qwtstr); // Configure email button d->m_configureEmail = new QPushButton(i18n("Configure Email..."), this); connect(d->m_configureEmail, SIGNAL(clicked()), this, SLOT(_k_slotConfigureEmail())); glay->addWidget(d->m_configureEmail, 0, 2, 3, 1, Qt::AlignTop | Qt::AlignRight); // To qwtstr = i18n("The email address this bug report is sent to."); tmpLabel = new QLabel(i18nc("Email receiver address", "To:"), this); glay->addWidget(tmpLabel, ++row, 0); tmpLabel->setWhatsThis(qwtstr); tmpLabel = new QLabel(d->m_aboutData.bugAddress(), this); tmpLabel->setTextInteractionFlags(Qt::TextBrowserInteraction); glay->addWidget(tmpLabel, row, 1); tmpLabel->setWhatsThis(qwtstr); KGuiItem::assign(buttonBox->button(QDialogButtonBox::Ok), KGuiItem(i18n("&Send"), QStringLiteral("mail-send"), i18n("Send bug report."), i18n("Send this bug report to %1.", d->m_aboutData.bugAddress()))); row++; } else { d->m_configureEmail = nullptr; d->m_from = nullptr; } // Program name QString qwtstr = i18n("The application for which you wish to submit a bug report - if incorrect, please use the Report Bug menu item of the correct application"); tmpLabel = new QLabel(i18n("Application: "), this); glay->addWidget(tmpLabel, row, 0); tmpLabel->setWhatsThis(qwtstr); d->appcombo = new QComboBox(this); d->appcombo->setWhatsThis(qwtstr); QStringList packageList; for (int c = 0; packages[c]; ++c) { packageList << QString::fromLatin1(packages[c]); } d->appcombo->addItems(packageList); connect(d->appcombo, SIGNAL(activated(int)), SLOT(_k_appChanged(int))); d->appname = d->m_aboutData.productName(); glay->addWidget(d->appcombo, row, 1); int index = 0; for (; index < d->appcombo->count(); index++) { if (d->appcombo->itemText(index) == d->appname) { break; } } if (index == d->appcombo->count()) { // not present d->appcombo->addItem(d->appname); } d->appcombo->setCurrentIndex(index); tmpLabel->setWhatsThis(qwtstr); // Version qwtstr = i18n("The version of this application - please make sure that no newer version is available before sending a bug report"); tmpLabel = new QLabel(i18n("Version:"), this); glay->addWidget(tmpLabel, ++row, 0); tmpLabel->setWhatsThis(qwtstr); d->m_strVersion = d->m_aboutData.version(); if (d->m_strVersion.isEmpty()) { d->m_strVersion = i18n("no version set (programmer error)"); } d->kde_version = QStringLiteral(KXMLGUI_VERSION_STRING) + QLatin1String(", ") + QStringLiteral(XMLGUI_DISTRIBUTION_TEXT); if (d->bugDestination != KBugReportPrivate::BugsKdeOrg) { d->m_strVersion += QLatin1Char(' ') + d->kde_version; } d->m_version = new QLabel(d->m_strVersion, this); d->m_version->setTextInteractionFlags(Qt::TextBrowserInteraction); //glay->addWidget( d->m_version, row, 1 ); glay->addWidget(d->m_version, row, 1, 1, 2); d->m_version->setWhatsThis(qwtstr); tmpLabel = new QLabel(i18n("OS:"), this); glay->addWidget(tmpLabel, ++row, 0); d->os = SystemInformation::operatingSystemVersion(); tmpLabel = new QLabel(d->os, this); tmpLabel->setTextInteractionFlags(Qt::TextBrowserInteraction); glay->addWidget(tmpLabel, row, 1, 1, 2); tmpLabel = new QLabel(i18n("Compiler:"), this); glay->addWidget(tmpLabel, ++row, 0); tmpLabel = new QLabel(QLatin1String(XMLGUI_COMPILER_VERSION), this); tmpLabel->setTextInteractionFlags(Qt::TextBrowserInteraction); glay->addWidget(tmpLabel, row, 1, 1, 2); if (d->bugDestination == KBugReportPrivate::CustomEmail) { // Severity d->m_bgSeverity = new QGroupBox(i18n("Se&verity"), this); struct SeverityData { QString name; QString text; }; const std::array severityData = { { { QStringLiteral("critical"), i18n("Critical") }, { QStringLiteral("grave"), i18n("Grave") }, { QStringLiteral("normal"), i18nc("normal severity", "Normal") }, { QStringLiteral("wishlist"), i18n("Wishlist") }, { QStringLiteral("i18n"), i18n("Translation") }, } }; QHBoxLayout *severityLayout = new QHBoxLayout(d->m_bgSeverity); for (auto& severityDatum : severityData) { // Store the severity string as the name QRadioButton *rb = new QRadioButton(severityDatum.text, d->m_bgSeverity); rb->setObjectName(severityDatum.name); d->severityButtons.append(rb); severityLayout->addWidget(rb); } d->severityButtons[2]->setChecked(true); // default : "normal" lay->addWidget(d->m_bgSeverity); // Subject QHBoxLayout *hlay = new QHBoxLayout(); lay->addItem(hlay); tmpLabel = new QLabel(i18n("S&ubject: "), this); hlay->addWidget(tmpLabel); d->m_subject = new QLineEdit(this); d->m_subject->setClearButtonEnabled(true); d->m_subject->setFocus(); tmpLabel->setBuddy(d->m_subject); hlay->addWidget(d->m_subject); QString text = i18n("Enter the text (in English if possible) that you wish to submit for the " "bug report.\n" "If you press \"Send\", a mail message will be sent to the maintainer of " "this program.\n"); QLabel *label = new QLabel(this); label->setText(text); lay->addWidget(label); // The multiline-edit - d->m_lineedit = new KTextEdit(this); + d->m_lineedit = new QTextEdit(this); d->m_lineedit->setMinimumHeight(180); // make it big d->m_lineedit->setWordWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere); d->m_lineedit->setLineWrapMode(QTextEdit::WidgetWidth); - d->m_lineedit->setCheckSpellingEnabled(true); - d->m_lineedit->setSpellCheckingLanguage(QStringLiteral("en")); lay->addWidget(d->m_lineedit, 10 /*stretch*/); d->_k_slotSetFrom(); } else { // Point to the web form QString text; if (d->bugDestination == KBugReportPrivate::BugsKdeOrg) { text = i18n("To submit a bug report, click on the button below. This will open a web browser " "window on https://bugs.kde.org where you will find " "a form to fill in. The information displayed above will be transferred to that server."); d->_k_updateUrl(); } else { text = i18n("To submit a bug report, click on the button below. This will open a web browser " "window on %2.", bugAddress, bugAddress); d->url = QUrl(bugAddress); } lay->addSpacing(10); QLabel *label = new QLabel(text, this); label->setOpenExternalLinks(true); label->setTextInteractionFlags(Qt::LinksAccessibleByMouse | Qt::LinksAccessibleByKeyboard); label->setWordWrap(true); lay->addWidget(label); lay->addSpacing(10); d->appcombo->setFocus(); QPushButton *okButton = buttonBox->button(QDialogButtonBox::Ok); if (d->bugDestination == KBugReportPrivate::BugsKdeOrg) { okButton->setText(i18n("&Launch Bug Report Wizard")); } else { okButton->setText(i18n("&Submit Bug Report")); } okButton->setIcon(QIcon::fromTheme(QStringLiteral("tools-report-bug"))); } lay->addWidget(buttonBox); setMinimumHeight(sizeHint().height() + 20); // WORKAROUND: prevent "cropped" qcombobox } KBugReport::~KBugReport() { delete d; } QString KBugReport::messageBody() const { if (d->bugDestination == KBugReportPrivate::CustomEmail) { return d->m_lineedit->toPlainText(); } else { return QString(); } } void KBugReport::setMessageBody(const QString &messageBody) { if (d->bugDestination == KBugReportPrivate::CustomEmail) { d->m_lineedit->setPlainText(messageBody); } } void KBugReportPrivate::_k_updateUrl() { url = QUrl(QStringLiteral("https://bugs.kde.org/enter_bug.cgi")); QUrlQuery query; query.addQueryItem(QStringLiteral("format"), QStringLiteral("guided")); // use the guided form // the string format is product/component, where component is optional QStringList list = appcombo->currentText().split(QLatin1Char('/')); query.addQueryItem(QStringLiteral("product"), list[0]); if (list.size() == 2) { query.addQueryItem(QStringLiteral("component"), list[1]); } query.addQueryItem(QStringLiteral("version"), m_strVersion); url.setQuery(query); // TODO: guess and fill OS(sys_os) and Platform(rep_platform) fields } void KBugReportPrivate::_k_appChanged(int i) { QString appName = appcombo->itemText(i); int index = appName.indexOf(QLatin1Char('/')); if (index > 0) { appName.truncate(index); } //qCDebug(DEBUG_KXMLGUI) << "appName " << appName; QString strDisplayVersion; //Version string to show in the UI if (appname == appName && !m_aboutData.version().isEmpty()) { m_strVersion = m_aboutData.version(); strDisplayVersion = m_strVersion; } else { m_strVersion = QStringLiteral("unknown"); //English string to put in the bug report strDisplayVersion = i18nc("unknown program name", "unknown"); } if (bugDestination != KBugReportPrivate::BugsKdeOrg) { m_strVersion += QLatin1Char(' ') + kde_version; strDisplayVersion += QLatin1Char(' ') + kde_version; } m_version->setText(strDisplayVersion); if (bugDestination == KBugReportPrivate::BugsKdeOrg) { _k_updateUrl(); } } void KBugReportPrivate::_k_slotConfigureEmail() { if (m_process) { return; } m_process = new QProcess; QObject::connect(m_process, SIGNAL(finished(int,QProcess::ExitStatus)), q, SLOT(_k_slotSetFrom())); m_process->start(QStringLiteral("kcmshell5"), QStringList() << QStringLiteral("user_manager")); if (!m_process->waitForStarted()) { //qCDebug(DEBUG_KXMLGUI) << "Couldn't start kcmshell5.."; delete m_process; m_process = nullptr; return; } m_configureEmail->setEnabled(false); } void KBugReportPrivate::_k_slotSetFrom() { delete m_process; m_process = nullptr; m_configureEmail->setEnabled(true); KEMailSettings emailSettings; QString fromaddr = emailSettings.getSetting(KEMailSettings::EmailAddress); if (fromaddr.isEmpty()) { fromaddr = SystemInformation::userName(); } else { QString name = emailSettings.getSetting(KEMailSettings::RealName); if (!name.isEmpty()) { fromaddr = name + QLatin1String(" <") + fromaddr + QLatin1Char('>'); } } m_from->setText(fromaddr); } void KBugReport::accept() { if (d->bugDestination != KBugReportPrivate::CustomEmail) { QDesktopServices::openUrl(d->url); return; } if (d->m_lineedit->toPlainText().isEmpty() || d->m_subject->text().isEmpty()) { QString msg = i18n("You must specify both a subject and a description " "before the report can be sent."); KMessageBox::error(this, msg); return; } switch (d->currentSeverity()) { case 0: // critical if (KMessageBox::questionYesNo(this, i18n( "

You chose the severity Critical. " "Please note that this severity is intended only for bugs that:

" "
  • break unrelated software on the system (or the whole system)
  • " "
  • cause serious data loss
  • " "
  • introduce a security hole on the system where the affected package is installed
\n" "

Does the bug you are reporting cause any of the above damage? " "If it does not, please select a lower severity. Thank you.

"), QString(), KStandardGuiItem::cont(), KStandardGuiItem::cancel()) == KMessageBox::No) { return; } break; case 1: // grave if (KMessageBox::questionYesNo(this, i18n( "

You chose the severity Grave. " "Please note that this severity is intended only for bugs that:

" "
  • make the package in question unusable or mostly so
  • " "
  • cause data loss
  • " "
  • introduce a security hole allowing access to the accounts of users who use the affected package
\n" "

Does the bug you are reporting cause any of the above damage? " "If it does not, please select a lower severity. Thank you.

"), QString(), KStandardGuiItem::cont(), KStandardGuiItem::cancel()) == KMessageBox::No) { return; } break; default: break; } if (!sendBugReport()) { QString msg = i18n("Unable to send the bug report.\n" "Please submit a bug report manually....\n" "See https://bugs.kde.org/ for instructions."); KMessageBox::error(this, msg + QLatin1String("\n\n") + d->lastError); return; } KMessageBox::information(this, i18n("Bug report sent, thank you for your input.")); QDialog::accept(); } void KBugReport::closeEvent(QCloseEvent *e) { if (d->bugDestination == KBugReportPrivate::CustomEmail && ((d->m_lineedit->toPlainText().length() > 0) || d->m_subject->isModified())) { int rc = KMessageBox::warningYesNo(this, i18n("Close and discard\nedited message?"), i18n("Close Message"), KStandardGuiItem::discard(), KStandardGuiItem::cont()); if (rc == KMessageBox::No) { e->ignore(); return; } } QDialog::closeEvent(e); } QString KBugReport::text() const { //qCDebug(DEBUG_KXMLGUI) << d->severityButtons[d->currentSeverity()]->objectName(); // Prepend the pseudo-headers to the contents of the mail QString severity = d->severityButtons[d->currentSeverity()]->objectName(); QString appname = d->appcombo->currentText(); QString os = QStringLiteral("OS: %1 (%2)\n"). arg(QStringLiteral(XMLGUI_COMPILING_OS), QStringLiteral(XMLGUI_DISTRIBUTION_TEXT)); QString bodyText; /* for(int i = 0; i < m_lineedit->numLines(); i++) { QString line = m_lineedit->textLine(i); if (!line.endsWith("\n")) line += '\n'; bodyText += line; } */ bodyText = d->m_lineedit->toPlainText(); if (bodyText.length() > 0) if (bodyText[bodyText.length() - 1] != QLatin1Char('\n')) { bodyText += QLatin1Char('\n'); } if (severity == QLatin1String("i18n") && QLocale().language() != QLocale::system().language()) { // Case 1 : i18n bug QString package = QLatin1String("i18n_") + QLocale::languageToString(QLocale().language()); package.replace(QLatin1Char('_'), QLatin1Char('-')); return QLatin1String("Package: ") + package + QLatin1String("\nApplication: ") + appname + QLatin1String("\nVersion: ") + d->m_strVersion + // not really i18n's version, so better here IMHO QLatin1Char('\n') + os + QLatin1Char('\n') + bodyText; } else { appname.replace(QLatin1Char('_'), QLatin1Char('-')); // Case 2 : normal bug return QLatin1String("Package: ") + appname + QLatin1String("\nVersion: ") + d->m_strVersion + QLatin1String("\nSeverity: ") + severity + QLatin1String("\nCompiler: ") + QStringLiteral(XMLGUI_COMPILER_VERSION) + QLatin1Char('\n') + os + QLatin1Char('\n') + bodyText; } } bool KBugReport::sendBugReport() { QString recipient = d->m_aboutData.bugAddress(); if (recipient.isEmpty()) { recipient = QStringLiteral("submit@bugs.kde.org"); } QString command = QStandardPaths::findExecutable(QStringLiteral("ksendbugmail")); if (command.isEmpty()) { command = QFile::decodeName(CMAKE_INSTALL_PREFIX "/" KF5_LIBEXEC_INSTALL_DIR "/ksendbugmail"); } QProcess proc; QStringList args; args << QStringLiteral("--subject") << d->m_subject->text() << QStringLiteral("--recipient") << recipient; proc.start(command, args); //qCDebug(DEBUG_KXMLGUI) << command << args; if (!proc.waitForStarted()) { qCritical() << "Unable to open a pipe to " << command << endl; return false; } proc.write(text().toUtf8()); proc.closeWriteChannel(); proc.waitForFinished(); //qCDebug(DEBUG_KXMLGUI) << "kbugreport: sendbugmail exit, status " << proc.exitStatus() << " code " << proc.exitCode(); QByteArray line; if (proc.exitStatus() == QProcess::NormalExit && proc.exitCode() != 0) { // XXX not stderr? while (!proc.atEnd()) { line = proc.readLine(); } d->lastError = QString::fromUtf8(line); return false; } return true; } #include "moc_kbugreport.cpp" diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 3a5a42f..1125f12 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,25 +1,29 @@ include(ECMMarkAsTest) find_package(Qt5 ${REQUIRED_QT_VERSION} CONFIG REQUIRED Test) macro(xmlgui_executable_tests) foreach(_testname ${ARGN}) add_executable(${_testname} ${_testname}.cpp) target_link_libraries(${_testname} Qt5::Test KF5::CoreAddons KF5::WidgetsAddons KF5::I18n KF5::XmlGui) ecm_mark_as_test(${_testname}) endforeach(_testname) endmacro() xmlgui_executable_tests( kbugreporttest kmainwindowrestoretest kmainwindowtest krulertest ktoolbartest kxmlguitest kxmlguiwindowtest kwindowtest ) -add_subdirectory(krichtexteditor) +# KTextWidgets dependency is only needed for this test +find_package(KF5TextWidgets QUIET) +if(TARGET KF5::TextWidgets) + add_subdirectory(krichtexteditor) +endif()