From 80a58cd729acc6b4f4579ec64c149dd945f6377a Mon Sep 17 00:00:00 2001 From: Felix Ulber Date: Wed, 25 Feb 2015 23:27:09 +0100 Subject: [PATCH] Fixed Issue #235 --HG-- branch : develop --- src/app/core/vsettings.cpp | 13 + src/app/core/vsettings.h | 4 + .../app/configpages/configurationpage.cpp | 18 + .../app/configpages/configurationpage.h | 2 + src/app/tools/drawTools/vtoolsinglepoint.cpp | 2 +- src/app/tools/vabstracttool.cpp | 41 +- src/app/tools/vtooldetail.cpp | 2 +- .../vpropertyexplorer/checkablemessagebox.cpp | 441 ++++++++++++++++++ .../vpropertyexplorer/checkablemessagebox.h | 141 ++++++ .../vpropertyexplorer/vpropertyexplorer.pri | 150 +++--- 10 files changed, 723 insertions(+), 91 deletions(-) create mode 100644 src/libs/vpropertyexplorer/checkablemessagebox.cpp create mode 100644 src/libs/vpropertyexplorer/checkablemessagebox.h diff --git a/src/app/core/vsettings.cpp b/src/app/core/vsettings.cpp index 884695fc2..456fffd5b 100644 --- a/src/app/core/vsettings.cpp +++ b/src/app/core/vsettings.cpp @@ -40,6 +40,7 @@ const QString VSettings::SettingConfigurationSendReportState = QStringLiteral(" const QString VSettings::SettingConfigurationLocale = QStringLiteral("configuration/locale"); const QString VSettings::SettingConfigurationUnit = QStringLiteral("configuration/unit"); const QString VSettings::SettingConfigurationLabelLanguage = QStringLiteral("configuration/label_language"); +const QString VSettings::SettingConfigurationConfirmItemDeletion= QStringLiteral("configuration/confirm_item_deletion"); const QString VSettings::SettingPathsIndividualMeasurements = QStringLiteral("paths/individual_measurements"); const QString VSettings::SettingPathsStandardMeasurements = QStringLiteral("paths/standard_measurements"); @@ -164,6 +165,18 @@ void VSettings::SetLabelLanguage(const QString &value) setValue(SettingConfigurationLabelLanguage, value); } +//--------------------------------------------------------------------------------------------------------------------- +bool VSettings::GetConfirmItemDelete() const +{ + return value(SettingConfigurationConfirmItemDeletion, 1).toBool(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VSettings::SetConfirmItemDelete(const bool &value) +{ + setValue(SettingConfigurationConfirmItemDeletion, value); +} + //--------------------------------------------------------------------------------------------------------------------- QString VSettings::GetPathIndividualMeasurements() const { diff --git a/src/app/core/vsettings.h b/src/app/core/vsettings.h index c00fe4b6a..80e8dc500 100644 --- a/src/app/core/vsettings.h +++ b/src/app/core/vsettings.h @@ -61,6 +61,9 @@ public: QString GetLabelLanguage() const; void SetLabelLanguage(const QString &value); + bool GetConfirmItemDelete() const; + void SetConfirmItemDelete(const bool &value); + QString GetPathIndividualMeasurements() const; void SetPathIndividualMeasurements(const QString &value); @@ -133,6 +136,7 @@ private: static const QString SettingConfigurationLocale; static const QString SettingConfigurationUnit; static const QString SettingConfigurationLabelLanguage; + static const QString SettingConfigurationConfirmItemDeletion; static const QString SettingPathsIndividualMeasurements; static const QString SettingPathsStandardMeasurements; diff --git a/src/app/dialogs/app/configpages/configurationpage.cpp b/src/app/dialogs/app/configpages/configurationpage.cpp index 06e39023a..1f0e713d0 100644 --- a/src/app/dialogs/app/configpages/configurationpage.cpp +++ b/src/app/dialogs/app/configpages/configurationpage.cpp @@ -51,11 +51,13 @@ ConfigurationPage::ConfigurationPage(QWidget *parent) QGroupBox *saveGroup = SaveGroup(); QGroupBox *langGroup = LangGroup(); QGroupBox *sendGroup = SendGroup(); + QGroupBox *drawGroup = DrawGroup(); QVBoxLayout *mainLayout = new QVBoxLayout; mainLayout->addWidget(saveGroup); mainLayout->addWidget(langGroup); mainLayout->addWidget(sendGroup); + mainLayout->addWidget(drawGroup); mainLayout->addStretch(1); setLayout(mainLayout); } @@ -73,6 +75,7 @@ void ConfigurationPage::Apply() qApp->getSettings()->SetOsSeparator(osOptionCheck->isChecked()); qApp->getSettings()->SetSendReportState(sendReportCheck->isChecked()); + qApp->getSettings()->SetConfirmItemDelete(askPointDeletionCheck->isChecked()); if (langChanged) { @@ -271,6 +274,21 @@ QGroupBox *ConfigurationPage::SendGroup() return sendGroup; } +//--------------------------------------------------------------------------------------------------------------------- +QGroupBox *ConfigurationPage::DrawGroup() +{ + QGroupBox *drawGroup = new QGroupBox(tr("Pattern Editing")); + + askPointDeletionCheck = new QCheckBox(tr("Confirm item deletion")); + askPointDeletionCheck->setChecked(qApp->getSettings()->GetConfirmItemDelete()); + + QVBoxLayout *editLayout = new QVBoxLayout; + editLayout->addWidget(askPointDeletionCheck); + + drawGroup->setLayout(editLayout); + return drawGroup; +} + //--------------------------------------------------------------------------------------------------------------------- void ConfigurationPage::SetLabelComboBox(const QStringList &list) { diff --git a/src/app/dialogs/app/configpages/configurationpage.h b/src/app/dialogs/app/configpages/configurationpage.h index 3b83e2996..12f549464 100644 --- a/src/app/dialogs/app/configpages/configurationpage.h +++ b/src/app/dialogs/app/configpages/configurationpage.h @@ -59,10 +59,12 @@ private: bool unitChanged; bool labelLangChanged; QCheckBox *sendReportCheck; + QCheckBox *askPointDeletionCheck; QGroupBox *SaveGroup(); QGroupBox *LangGroup(); QGroupBox *SendGroup(); + QGroupBox *DrawGroup(); void SetLabelComboBox(const QStringList &list); }; diff --git a/src/app/tools/drawTools/vtoolsinglepoint.cpp b/src/app/tools/drawTools/vtoolsinglepoint.cpp index dde2a162c..a8abd0336 100644 --- a/src/app/tools/drawTools/vtoolsinglepoint.cpp +++ b/src/app/tools/drawTools/vtoolsinglepoint.cpp @@ -173,7 +173,7 @@ void VToolSinglePoint::DeleteTool(bool ask) qApp->getSceneView()->itemClicked(nullptr); if (ask) { - if (ConfirmDeletion() == QMessageBox::Cancel) + if (ConfirmDeletion() == QMessageBox::No) { return; } diff --git a/src/app/tools/vabstracttool.cpp b/src/app/tools/vabstracttool.cpp index d01708581..fd33c7b41 100644 --- a/src/app/tools/vabstracttool.cpp +++ b/src/app/tools/vabstracttool.cpp @@ -28,13 +28,15 @@ #include "vabstracttool.h" #include -#include +#include +#include +#include "checkablemessagebox.h" #include "../undocommands/deltool.h" #include "../core/vapplication.h" #include "../geometry/vpointf.h" #include "../undocommands/savetooloptions.h" #include "../widgets/vmaingraphicsview.h" -#include +#include "../core/vsettings.h" const QString VAbstractTool::AttrType = QStringLiteral("type"); const QString VAbstractTool::AttrMx = QStringLiteral("mx"); @@ -154,7 +156,7 @@ void VAbstractTool::DeleteTool(bool ask) qApp->getSceneView()->itemClicked(nullptr); if (ask) { - if (ConfirmDeletion() == QMessageBox::Cancel) + if (ConfirmDeletion() == QMessageBox::No) { return; } @@ -165,6 +167,27 @@ void VAbstractTool::DeleteTool(bool ask) } } +//--------------------------------------------------------------------------------------------------------------------- +int VAbstractTool::ConfirmDeletion() +{ + if (false == qApp->getSettings()->GetConfirmItemDelete()) + return QMessageBox::Yes; + + Utils::CheckableMessageBox msgBox(qApp->getMainWindow()); + msgBox.setWindowTitle(tr("Confirm deletion")); + msgBox.setText(tr("Do you really want to delete?")); + msgBox.setStandardButtons(QDialogButtonBox::Yes | QDialogButtonBox::No); + msgBox.setDefaultButton(QDialogButtonBox::No); + msgBox.setIconPixmap(qApp->style()->standardIcon(QStyle::SP_MessageBoxQuestion).pixmap(32,32) ); + + int dialogResult = msgBox.exec(); + + if (dialogResult == QDialog::Accepted) + qApp->getSettings()->SetConfirmItemDelete(not msgBox.isChecked()); + + return dialogResult == QDialog::Accepted ? QMessageBox::Yes : QMessageBox::No; +} + //--------------------------------------------------------------------------------------------------------------------- /** * @brief LineStyle return pen style for current line style. @@ -294,18 +317,6 @@ QMap VAbstractTool::PointsList() const return list; } -//--------------------------------------------------------------------------------------------------------------------- -int VAbstractTool::ConfirmDeletion() -{ - QMessageBox msgBox; - msgBox.setText(tr("Confirm the deletion.")); - msgBox.setInformativeText(tr("Do you really want delete?")); - msgBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel); - msgBox.setDefaultButton(QMessageBox::Ok); - msgBox.setIcon(QMessageBox::Question); - return msgBox.exec(); -} - //--------------------------------------------------------------------------------------------------------------------- void VAbstractTool::SaveOption(QSharedPointer &obj) { diff --git a/src/app/tools/vtooldetail.cpp b/src/app/tools/vtooldetail.cpp index cab1ed4b5..27d42fd6a 100644 --- a/src/app/tools/vtooldetail.cpp +++ b/src/app/tools/vtooldetail.cpp @@ -522,7 +522,7 @@ void VToolDetail::DeleteTool(bool ask) DeleteDetail *delDet = new DeleteDetail(doc, id); if (ask) { - if (ConfirmDeletion() == QMessageBox::Cancel) + if (ConfirmDeletion() == QMessageBox::No) { return; } diff --git a/src/libs/vpropertyexplorer/checkablemessagebox.cpp b/src/libs/vpropertyexplorer/checkablemessagebox.cpp new file mode 100644 index 000000000..205d07b67 --- /dev/null +++ b/src/libs/vpropertyexplorer/checkablemessagebox.cpp @@ -0,0 +1,441 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** Modified work Copyright 2015 Felix Ulber +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://www.qt.io/licensing. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "checkablemessagebox.h" + +#include +#include +#include +#include +#include +#include + +/*! + \class Utils::CheckableMessageBox + + \brief The CheckableMessageBox class implements a message box suitable for + questions with a + "Do not ask me again" checkbox. + + Emulates the QMessageBox API with + static conveniences. The message label can open external URLs. +*/ + +static const char kDoNotAskAgainKey[] = "DoNotAskAgain"; + +namespace Utils { + +class CheckableMessageBoxPrivate +{ +public: + CheckableMessageBoxPrivate(QDialog *q) + : clickedButton(0) + { + QSizePolicy sizePolicy(QSizePolicy::Minimum, QSizePolicy::Preferred); + + pixmapLabel = new QLabel(q); + sizePolicy.setHorizontalStretch(0); + sizePolicy.setVerticalStretch(0); + sizePolicy.setHeightForWidth(pixmapLabel->sizePolicy().hasHeightForWidth()); + pixmapLabel->setSizePolicy(sizePolicy); + pixmapLabel->setVisible(false); + + QSpacerItem *pixmapSpacer = + new QSpacerItem(0, 5, QSizePolicy::Minimum, QSizePolicy::MinimumExpanding); + + messageLabel = new QLabel(q); + messageLabel->setMinimumSize(QSize(300, 0)); + messageLabel->setWordWrap(true); + messageLabel->setOpenExternalLinks(true); + messageLabel->setTextInteractionFlags(Qt::LinksAccessibleByKeyboard|Qt::LinksAccessibleByMouse); + + QSpacerItem *checkBoxRightSpacer = + new QSpacerItem(1, 1, QSizePolicy::Expanding, QSizePolicy::Minimum); + QSpacerItem *buttonSpacer = + new QSpacerItem(0, 1, QSizePolicy::Minimum, QSizePolicy::Minimum); + + checkBox = new QCheckBox(q); + checkBox->setText(CheckableMessageBox::tr("Do not ask again")); + + buttonBox = new QDialogButtonBox(q); + buttonBox->setOrientation(Qt::Horizontal); + buttonBox->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::Ok); + + QVBoxLayout *verticalLayout = new QVBoxLayout(); + verticalLayout->addWidget(pixmapLabel); + verticalLayout->addItem(pixmapSpacer); + + QHBoxLayout *horizontalLayout_2 = new QHBoxLayout(); + horizontalLayout_2->addLayout(verticalLayout); + horizontalLayout_2->addWidget(messageLabel); + + QHBoxLayout *horizontalLayout = new QHBoxLayout(); + horizontalLayout->addWidget(checkBox); + horizontalLayout->addItem(checkBoxRightSpacer); + + QVBoxLayout *verticalLayout_2 = new QVBoxLayout(q); + verticalLayout_2->addLayout(horizontalLayout_2); + verticalLayout_2->addLayout(horizontalLayout); + verticalLayout_2->addItem(buttonSpacer); + verticalLayout_2->addWidget(buttonBox); + } + + QLabel *pixmapLabel; + QLabel *messageLabel; + QCheckBox *checkBox; + QDialogButtonBox *buttonBox; + QAbstractButton *clickedButton; +}; + +CheckableMessageBox::CheckableMessageBox(QWidget *parent) : + QDialog(parent), + d(new CheckableMessageBoxPrivate(this)) +{ + setModal(true); + setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); + connect(d->buttonBox, SIGNAL(accepted()), SLOT(accept())); + connect(d->buttonBox, SIGNAL(rejected()), SLOT(reject())); + connect(d->buttonBox, SIGNAL(clicked(QAbstractButton*)), + SLOT(slotClicked(QAbstractButton*))); +} + +CheckableMessageBox::~CheckableMessageBox() +{ + delete d; +} + +void CheckableMessageBox::slotClicked(QAbstractButton *b) +{ + d->clickedButton = b; +} + +QAbstractButton *CheckableMessageBox::clickedButton() const +{ + return d->clickedButton; +} + +QDialogButtonBox::StandardButton CheckableMessageBox::clickedStandardButton() const +{ + if (d->clickedButton) + return d->buttonBox->standardButton(d->clickedButton); + return QDialogButtonBox::NoButton; +} + +QString CheckableMessageBox::text() const +{ + return d->messageLabel->text(); +} + +void CheckableMessageBox::setText(const QString &t) +{ + d->messageLabel->setText(t); +} + +QPixmap CheckableMessageBox::iconPixmap() const +{ + if (const QPixmap *p = d->pixmapLabel->pixmap()) + return QPixmap(*p); + return QPixmap(); +} + +void CheckableMessageBox::setIconPixmap(const QPixmap &p) +{ + d->pixmapLabel->setPixmap(p); + d->pixmapLabel->setVisible(!p.isNull()); +} + +bool CheckableMessageBox::isChecked() const +{ + return d->checkBox->isChecked(); +} + +void CheckableMessageBox::setChecked(bool s) +{ + d->checkBox->setChecked(s); +} + +QString CheckableMessageBox::checkBoxText() const +{ + return d->checkBox->text(); +} + +void CheckableMessageBox::setCheckBoxText(const QString &t) +{ + d->checkBox->setText(t); +} + +bool CheckableMessageBox::isCheckBoxVisible() const +{ + return d->checkBox->isVisible(); +} + +void CheckableMessageBox::setCheckBoxVisible(bool v) +{ + d->checkBox->setVisible(v); +} + +QDialogButtonBox::StandardButtons CheckableMessageBox::standardButtons() const +{ + return d->buttonBox->standardButtons(); +} + +void CheckableMessageBox::setStandardButtons(QDialogButtonBox::StandardButtons s) +{ + d->buttonBox->setStandardButtons(s); +} + +QPushButton *CheckableMessageBox::button(QDialogButtonBox::StandardButton b) const +{ + return d->buttonBox->button(b); +} + +QPushButton *CheckableMessageBox::addButton(const QString &text, QDialogButtonBox::ButtonRole role) +{ + return d->buttonBox->addButton(text, role); +} + +QDialogButtonBox::StandardButton CheckableMessageBox::defaultButton() const +{ + foreach (QAbstractButton *b, d->buttonBox->buttons()) + if (QPushButton *pb = qobject_cast(b)) + if (pb->isDefault()) + return d->buttonBox->standardButton(pb); + return QDialogButtonBox::NoButton; +} + +void CheckableMessageBox::setDefaultButton(QDialogButtonBox::StandardButton s) +{ + if (QPushButton *b = d->buttonBox->button(s)) { + b->setDefault(true); + b->setFocus(); + } +} + +QDialogButtonBox::StandardButton +CheckableMessageBox::question(QWidget *parent, + const QString &title, + const QString &question, + const QString &checkBoxText, + bool *checkBoxSetting, + QDialogButtonBox::StandardButtons buttons, + QDialogButtonBox::StandardButton defaultButton) +{ + CheckableMessageBox mb(parent); + mb.setWindowTitle(title); + mb.setIconPixmap(QMessageBox::standardIcon(QMessageBox::Question)); + mb.setText(question); + mb.setCheckBoxText(checkBoxText); + mb.setChecked(*checkBoxSetting); + mb.setStandardButtons(buttons); + mb.setDefaultButton(defaultButton); + mb.exec(); + *checkBoxSetting = mb.isChecked(); + return mb.clickedStandardButton(); +} + +QDialogButtonBox::StandardButton +CheckableMessageBox::information(QWidget *parent, + const QString &title, + const QString &text, + const QString &checkBoxText, + bool *checkBoxSetting, + QDialogButtonBox::StandardButtons buttons, + QDialogButtonBox::StandardButton defaultButton) +{ + CheckableMessageBox mb(parent); + mb.setWindowTitle(title); + mb.setIconPixmap(QMessageBox::standardIcon(QMessageBox::Information)); + mb.setText(text); + mb.setCheckBoxText(checkBoxText); + mb.setChecked(*checkBoxSetting); + mb.setStandardButtons(buttons); + mb.setDefaultButton(defaultButton); + mb.exec(); + *checkBoxSetting = mb.isChecked(); + return mb.clickedStandardButton(); +} + +QMessageBox::StandardButton CheckableMessageBox::dialogButtonBoxToMessageBoxButton(QDialogButtonBox::StandardButton db) +{ + return static_cast(int(db)); +} + +bool askAgain(QSettings *settings, const QString &settingsSubKey) +{ + //QTC_CHECK(settings); + if (settings) { + settings->beginGroup(QLatin1String(kDoNotAskAgainKey)); + bool shouldNotAsk = settings->value(settingsSubKey, false).toBool(); + settings->endGroup(); + if (shouldNotAsk) + return false; + } + return true; +} + +enum DoNotAskAgainType{Question, Information}; + +void initDoNotAskAgainMessageBox(CheckableMessageBox &messageBox, const QString &title, + const QString &text, QDialogButtonBox::StandardButtons buttons, + QDialogButtonBox::StandardButton defaultButton, + DoNotAskAgainType type) +{ + messageBox.setWindowTitle(title); + messageBox.setIconPixmap(QMessageBox::standardIcon(type == Information + ? QMessageBox::Information + : QMessageBox::Question)); + messageBox.setText(text); + messageBox.setCheckBoxVisible(true); + messageBox.setCheckBoxText(type == Information ? CheckableMessageBox::msgDoNotShowAgain() + : CheckableMessageBox::msgDoNotAskAgain()); + messageBox.setChecked(false); + messageBox.setStandardButtons(buttons); + messageBox.setDefaultButton(defaultButton); +} + +void doNotAskAgain(QSettings *settings, const QString &settingsSubKey) +{ + if (!settings) + return; + + settings->beginGroup(QLatin1String(kDoNotAskAgainKey)); + settings->setValue(settingsSubKey, true); + settings->endGroup(); +} + +/*! + Shows a message box with given \a title and \a text, and a \gui {Do not ask again} check box. + If the user checks the check box and accepts the dialog with the \a acceptButton, + further invocations of this function with the same \a settings and \a settingsSubKey will not + show the dialog, but instantly return \a acceptButton. + + Returns the clicked button, or QDialogButtonBox::NoButton if the user rejects the dialog + with the escape key, or \a acceptButton if the dialog is suppressed. +*/ +QDialogButtonBox::StandardButton +CheckableMessageBox::doNotAskAgainQuestion(QWidget *parent, const QString &title, + const QString &text, QSettings *settings, + const QString &settingsSubKey, + QDialogButtonBox::StandardButtons buttons, + QDialogButtonBox::StandardButton defaultButton, + QDialogButtonBox::StandardButton acceptButton) + +{ + if (!askAgain(settings, settingsSubKey)) + return acceptButton; + + CheckableMessageBox messageBox(parent); + initDoNotAskAgainMessageBox(messageBox, title, text, buttons, defaultButton, Question); + messageBox.exec(); + if (messageBox.isChecked() && (messageBox.clickedStandardButton() == acceptButton)) + doNotAskAgain(settings, settingsSubKey); + + return messageBox.clickedStandardButton(); +} + +/*! + Shows a message box with given \a title and \a text, and a \gui {Do not show again} check box. + If the user checks the check box and quits the dialog, further invocations of this + function with the same \a settings and \a settingsSubKey will not show the dialog, but instantly return. + + Returns the clicked button, or QDialogButtonBox::NoButton if the user rejects the dialog + with the escape key, or \a defaultButton if the dialog is suppressed. +*/ +QDialogButtonBox::StandardButton +CheckableMessageBox::doNotShowAgainInformation(QWidget *parent, const QString &title, + const QString &text, QSettings *settings, + const QString &settingsSubKey, + QDialogButtonBox::StandardButtons buttons, + QDialogButtonBox::StandardButton defaultButton) + +{ + if (!askAgain(settings, settingsSubKey)) + return defaultButton; + + CheckableMessageBox messageBox(parent); + initDoNotAskAgainMessageBox(messageBox, title, text, buttons, defaultButton, Information); + messageBox.exec(); + if (messageBox.isChecked()) + doNotAskAgain(settings, settingsSubKey); + + return messageBox.clickedStandardButton(); +} + +/*! + Resets all suppression settings for doNotAskAgainQuestion() found in \a settings, + so all these message boxes are shown again. + */ +void CheckableMessageBox::resetAllDoNotAskAgainQuestions(QSettings *settings) +{ + //Q_ASSERT(settings, return); + settings->beginGroup(QLatin1String(kDoNotAskAgainKey)); + settings->remove(QString()); + settings->endGroup(); +} + +/*! + Returns whether any message boxes from doNotAskAgainQuestion() are suppressed + in the \a settings. +*/ +bool CheckableMessageBox::hasSuppressedQuestions(QSettings *settings) +{ + //Q_ASSERT(settings, return false); + bool hasSuppressed = false; + settings->beginGroup(QLatin1String(kDoNotAskAgainKey)); + foreach (const QString &subKey, settings->childKeys()) { + if (settings->value(subKey, false).toBool()) { + hasSuppressed = true; + break; + } + } + settings->endGroup(); + return hasSuppressed; +} + +/*! + Returns the standard \gui {Do not ask again} check box text. + \sa doNotAskAgainQuestion() +*/ +QString CheckableMessageBox::msgDoNotAskAgain() +{ + return QApplication::translate("Utils::CheckableMessageBox", "Do not &ask again"); +} + +/*! + Returns the standard \gui {Do not show again} check box text. + \sa doNotShowAgainInformation() +*/ +QString CheckableMessageBox::msgDoNotShowAgain() +{ + return QApplication::translate("Utils::CheckableMessageBox", "Do not &show again"); +} + +} // namespace Utils diff --git a/src/libs/vpropertyexplorer/checkablemessagebox.h b/src/libs/vpropertyexplorer/checkablemessagebox.h new file mode 100644 index 000000000..233b505d6 --- /dev/null +++ b/src/libs/vpropertyexplorer/checkablemessagebox.h @@ -0,0 +1,141 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** Modified work Copyright 2015 Felix Ulber +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://www.qt.io/licensing. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef CHECKABLEMESSAGEBOX_H +#define CHECKABLEMESSAGEBOX_H + +#include +#include + +QT_BEGIN_NAMESPACE +class QSettings; +QT_END_NAMESPACE + +namespace Utils { + +class CheckableMessageBoxPrivate; + +class Q_DECL_EXPORT CheckableMessageBox : public QDialog +{ + Q_OBJECT + Q_PROPERTY(QString text READ text WRITE setText) + Q_PROPERTY(QPixmap iconPixmap READ iconPixmap WRITE setIconPixmap) + Q_PROPERTY(bool isChecked READ isChecked WRITE setChecked) + Q_PROPERTY(QString checkBoxText READ checkBoxText WRITE setCheckBoxText) + Q_PROPERTY(QDialogButtonBox::StandardButtons buttons READ standardButtons WRITE setStandardButtons) + Q_PROPERTY(QDialogButtonBox::StandardButton defaultButton READ defaultButton WRITE setDefaultButton) + +public: + explicit CheckableMessageBox(QWidget *parent); + virtual ~CheckableMessageBox(); + + static QDialogButtonBox::StandardButton + question(QWidget *parent, + const QString &title, + const QString &question, + const QString &checkBoxText, + bool *checkBoxSetting, + QDialogButtonBox::StandardButtons buttons = QDialogButtonBox::Yes|QDialogButtonBox::No, + QDialogButtonBox::StandardButton defaultButton = QDialogButtonBox::No); + + static QDialogButtonBox::StandardButton + information(QWidget *parent, + const QString &title, + const QString &text, + const QString &checkBoxText, + bool *checkBoxSetting, + QDialogButtonBox::StandardButtons buttons = QDialogButtonBox::Ok, + QDialogButtonBox::StandardButton defaultButton = QDialogButtonBox::NoButton); + + static QDialogButtonBox::StandardButton + doNotAskAgainQuestion(QWidget *parent, + const QString &title, + const QString &text, + QSettings *settings, + const QString &settingsSubKey, + QDialogButtonBox::StandardButtons buttons = QDialogButtonBox::Yes|QDialogButtonBox::No, + QDialogButtonBox::StandardButton defaultButton = QDialogButtonBox::No, + QDialogButtonBox::StandardButton acceptButton = QDialogButtonBox::Yes); + + static QDialogButtonBox::StandardButton + doNotShowAgainInformation(QWidget *parent, + const QString &title, + const QString &text, + QSettings *settings, + const QString &settingsSubKey, + QDialogButtonBox::StandardButtons buttons = QDialogButtonBox::Ok, + QDialogButtonBox::StandardButton defaultButton = QDialogButtonBox::NoButton); + + QString text() const; + void setText(const QString &); + + bool isChecked() const; + void setChecked(bool s); + + QString checkBoxText() const; + void setCheckBoxText(const QString &); + + bool isCheckBoxVisible() const; + void setCheckBoxVisible(bool); + + QDialogButtonBox::StandardButtons standardButtons() const; + void setStandardButtons(QDialogButtonBox::StandardButtons s); + QPushButton *button(QDialogButtonBox::StandardButton b) const; + QPushButton *addButton(const QString &text, QDialogButtonBox::ButtonRole role); + + QDialogButtonBox::StandardButton defaultButton() const; + void setDefaultButton(QDialogButtonBox::StandardButton s); + + // See static QMessageBox::standardPixmap() + QPixmap iconPixmap() const; + void setIconPixmap (const QPixmap &p); + + // Query the result + QAbstractButton *clickedButton() const; + QDialogButtonBox::StandardButton clickedStandardButton() const; + + // Conversion convenience + static QMessageBox::StandardButton dialogButtonBoxToMessageBoxButton(QDialogButtonBox::StandardButton); + static void resetAllDoNotAskAgainQuestions(QSettings *settings); + static bool hasSuppressedQuestions(QSettings *settings); + static QString msgDoNotAskAgain(); + static QString msgDoNotShowAgain(); + +private slots: + void slotClicked(QAbstractButton *b); + +private: + CheckableMessageBoxPrivate *d; +}; + +} // namespace Utils + +#endif // CHECKABLEMESSAGEBOX_H diff --git a/src/libs/vpropertyexplorer/vpropertyexplorer.pri b/src/libs/vpropertyexplorer/vpropertyexplorer.pri index 6f11c2705..eb38f6dcc 100644 --- a/src/libs/vpropertyexplorer/vpropertyexplorer.pri +++ b/src/libs/vpropertyexplorer/vpropertyexplorer.pri @@ -1,74 +1,76 @@ -# ADD TO EACH PATH $$PWD VARIABLE!!!!!! -# This need for corect working file translations.pro - -SOURCES += \ - $$PWD/vproperty.cpp \ - $$PWD/vpropertydelegate.cpp \ - $$PWD/vpropertyfactorymanager.cpp \ - $$PWD/vpropertyformview.cpp \ - $$PWD/vpropertyformwidget.cpp \ - $$PWD/vpropertymodel.cpp \ - $$PWD/vpropertyset.cpp \ - $$PWD/vpropertytreeview.cpp \ - $$PWD/vserializedproperty.cpp \ - $$PWD/plugins/vwidgetproperty.cpp \ - $$PWD/plugins/vemptyproperty.cpp \ - $$PWD/plugins/vboolproperty.cpp \ - $$PWD/plugins/vshortcutproperty.cpp \ - $$PWD/plugins/vcolorproperty.cpp \ - $$PWD/plugins/vshortcutpropertyeditor.cpp \ - $$PWD/plugins/venumproperty.cpp \ - $$PWD/plugins/vfileproperty.cpp \ - $$PWD/plugins/vcolorpropertyeditor.cpp \ - $$PWD/plugins/vfilepropertyeditor.cpp \ - $$PWD/plugins/vnumberproperty.cpp \ - $$PWD/plugins/Vector3d/vvector3dproperty.cpp \ - $$PWD/vstandardpropertyfactory.cpp \ - $$PWD/plugins/vstringproperty.cpp \ - $$PWD/plugins/vpointfproperty.cpp \ - $$PWD/plugins/vobjectproperty.cpp \ - $$PWD/stable.cpp \ - $$PWD/plugins/vlinetypeproperty.cpp \ - $$PWD/plugins/vlinecolorproperty.cpp - -HEADERS +=\ - $$PWD/vpropertyexplorer_global.h \ - $$PWD/vpropertyfactorymanager_p.h \ - $$PWD/vpropertytreeview_p.h \ - $$PWD/vpropertyset_p.h \ - $$PWD/vabstractpropertyfactory.h \ - $$PWD/vfileproperty_p.h \ - $$PWD/vwidgetproperty_p.h \ - $$PWD/vpropertymodel_p.h \ - $$PWD/vstandardpropertyfactory.h \ - $$PWD/vpropertyformview_p.h \ - $$PWD/vpropertytreeview.h \ - $$PWD/vpropertyformwidget_p.h \ - $$PWD/vpropertydelegate.h \ - $$PWD/vproperty_p.h \ - $$PWD/vpropertyformwidget.h \ - $$PWD/vpropertyformview.h \ - $$PWD/vpropertyset.h \ - $$PWD/vpropertymodel.h \ - $$PWD/vproperty.h \ - $$PWD/plugins/vwidgetproperty.h \ - $$PWD/plugins/vcolorproperty.h \ - $$PWD/plugins/vboolproperty.h \ - $$PWD/plugins/vcolorpropertyeditor.h \ - $$PWD/plugins/vshortcutpropertyeditor.h \ - $$PWD/plugins/vemptyproperty.h \ - $$PWD/plugins/vshortcutproperty.h \ - $$PWD/plugins/venumproperty.h \ - $$PWD/plugins/vfilepropertyeditor.h \ - $$PWD/plugins/vfileproperty.h \ - $$PWD/plugins/vnumberproperty.h \ - $$PWD/plugins/Vector3d/vvector3dproperty.h \ - $$PWD/vpropertyfactorymanager.h \ - $$PWD/vserializedproperty.h \ - $$PWD/plugins/vstringproperty.h \ - $$PWD/plugins/vpointfproperty.h \ - $$PWD/plugins/vobjectproperty.h \ - $$PWD/vproperties.h \ - $$PWD/stable.h \ - $$PWD/plugins/vlinetypeproperty.h \ - $$PWD/plugins/vlinecolorproperty.h +# ADD TO EACH PATH $$PWD VARIABLE!!!!!! +# This need for corect working file translations.pro + +SOURCES += \ + $$PWD/vproperty.cpp \ + $$PWD/vpropertydelegate.cpp \ + $$PWD/vpropertyfactorymanager.cpp \ + $$PWD/vpropertyformview.cpp \ + $$PWD/vpropertyformwidget.cpp \ + $$PWD/vpropertymodel.cpp \ + $$PWD/vpropertyset.cpp \ + $$PWD/vpropertytreeview.cpp \ + $$PWD/vserializedproperty.cpp \ + $$PWD/plugins/vwidgetproperty.cpp \ + $$PWD/plugins/vemptyproperty.cpp \ + $$PWD/plugins/vboolproperty.cpp \ + $$PWD/plugins/vshortcutproperty.cpp \ + $$PWD/plugins/vcolorproperty.cpp \ + $$PWD/plugins/vshortcutpropertyeditor.cpp \ + $$PWD/plugins/venumproperty.cpp \ + $$PWD/plugins/vfileproperty.cpp \ + $$PWD/plugins/vcolorpropertyeditor.cpp \ + $$PWD/plugins/vfilepropertyeditor.cpp \ + $$PWD/plugins/vnumberproperty.cpp \ + $$PWD/plugins/Vector3d/vvector3dproperty.cpp \ + $$PWD/vstandardpropertyfactory.cpp \ + $$PWD/plugins/vstringproperty.cpp \ + $$PWD/plugins/vpointfproperty.cpp \ + $$PWD/plugins/vobjectproperty.cpp \ + $$PWD/stable.cpp \ + $$PWD/plugins/vlinetypeproperty.cpp \ + $$PWD/plugins/vlinecolorproperty.cpp \ + $$PWD/checkablemessagebox.cpp + +HEADERS +=\ + $$PWD/vpropertyexplorer_global.h \ + $$PWD/vpropertyfactorymanager_p.h \ + $$PWD/vpropertytreeview_p.h \ + $$PWD/vpropertyset_p.h \ + $$PWD/vabstractpropertyfactory.h \ + $$PWD/vfileproperty_p.h \ + $$PWD/vwidgetproperty_p.h \ + $$PWD/vpropertymodel_p.h \ + $$PWD/vstandardpropertyfactory.h \ + $$PWD/vpropertyformview_p.h \ + $$PWD/vpropertytreeview.h \ + $$PWD/vpropertyformwidget_p.h \ + $$PWD/vpropertydelegate.h \ + $$PWD/vproperty_p.h \ + $$PWD/vpropertyformwidget.h \ + $$PWD/vpropertyformview.h \ + $$PWD/vpropertyset.h \ + $$PWD/vpropertymodel.h \ + $$PWD/vproperty.h \ + $$PWD/plugins/vwidgetproperty.h \ + $$PWD/plugins/vcolorproperty.h \ + $$PWD/plugins/vboolproperty.h \ + $$PWD/plugins/vcolorpropertyeditor.h \ + $$PWD/plugins/vshortcutpropertyeditor.h \ + $$PWD/plugins/vemptyproperty.h \ + $$PWD/plugins/vshortcutproperty.h \ + $$PWD/plugins/venumproperty.h \ + $$PWD/plugins/vfilepropertyeditor.h \ + $$PWD/plugins/vfileproperty.h \ + $$PWD/plugins/vnumberproperty.h \ + $$PWD/plugins/Vector3d/vvector3dproperty.h \ + $$PWD/vpropertyfactorymanager.h \ + $$PWD/vserializedproperty.h \ + $$PWD/plugins/vstringproperty.h \ + $$PWD/plugins/vpointfproperty.h \ + $$PWD/plugins/vobjectproperty.h \ + $$PWD/vproperties.h \ + $$PWD/stable.h \ + $$PWD/plugins/vlinetypeproperty.h \ + $$PWD/plugins/vlinecolorproperty.h \ + $$PWD/checkablemessagebox.h