diff --git a/src/plugins/cmakeprojectmanager/cmakeproject.qrc b/src/plugins/cmakeprojectmanager/cmakeproject.qrc
index 708223bf895..5749507adfb 100644
--- a/src/plugins/cmakeprojectmanager/cmakeproject.qrc
+++ b/src/plugins/cmakeprojectmanager/cmakeproject.qrc
@@ -2,5 +2,6 @@
images/fileoverlay_cmake.png
images/fileoverlay_cmake@2x.png
+ images/project_type_settings_icon.png
diff --git a/src/plugins/cmakeprojectmanager/cmakeprojectmanager.pro b/src/plugins/cmakeprojectmanager/cmakeprojectmanager.pro
index 7467e7dbc54..1b80127ace6 100644
--- a/src/plugins/cmakeprojectmanager/cmakeprojectmanager.pro
+++ b/src/plugins/cmakeprojectmanager/cmakeprojectmanager.pro
@@ -30,6 +30,8 @@ HEADERS = builddirmanager.h \
cmakebuildsettingswidget.h \
cmakeindenter.h \
cmakeautocompleter.h \
+ cmakespecificsettings.h \
+ cmakespecificsettingspage.h \
configmodel.h \
configmodelitemdelegate.h \
servermode.h \
@@ -63,11 +65,16 @@ SOURCES = builddirmanager.cpp \
cmakebuildsettingswidget.cpp \
cmakeindenter.cpp \
cmakeautocompleter.cpp \
+ cmakespecificsettings.cpp \
+ cmakespecificsettingspage.cpp \
configmodel.cpp \
configmodelitemdelegate.cpp \
servermode.cpp \
servermodereader.cpp \
tealeafreader.cpp \
- treescanner.cpp
+ treescanner.cpp \
RESOURCES += cmakeproject.qrc
+
+FORMS += \
+ cmakespecificsettingspage.ui
diff --git a/src/plugins/cmakeprojectmanager/cmakeprojectnodes.cpp b/src/plugins/cmakeprojectmanager/cmakeprojectnodes.cpp
index d471910d47f..f5e176f3ec2 100644
--- a/src/plugins/cmakeprojectmanager/cmakeprojectnodes.cpp
+++ b/src/plugins/cmakeprojectmanager/cmakeprojectnodes.cpp
@@ -26,10 +26,12 @@
#include "cmakeprojectnodes.h"
#include "cmakeprojectconstants.h"
-
+#include "cmakeprojectplugin.h"
#include
+#include
#include
#include
+#include
#include
#include
@@ -43,6 +45,15 @@ using namespace CMakeProjectManager;
using namespace CMakeProjectManager::Internal;
namespace {
+void copySourcePathToClipboard(Utils::optional srcPath,
+ const ProjectExplorer::ProjectNode *node)
+{
+ QClipboard *clip = QGuiApplication::clipboard();
+
+ QDir projDir{node->filePath().toFileInfo().absoluteFilePath()};
+ clip->setText(QDir::cleanPath(projDir.relativeFilePath(srcPath.value())));
+}
+
void noAutoAdditionNotify(const QStringList &filePaths, const ProjectExplorer::ProjectNode *node)
{
Utils::optional srcPath{};
@@ -55,17 +66,40 @@ void noAutoAdditionNotify(const QStringList &filePaths, const ProjectExplorer::P
}
if (srcPath) {
- QMessageBox::StandardButton reply =
- QMessageBox::question(nullptr, QMessageBox::tr("Copy to Clipboard?"),
- QMessageBox::tr("Files are not automatically added to the CMakeLists.txt file of the CMake project."
- "\nCopy the path to the source files to the clipboard?"),
- QMessageBox::Yes | QMessageBox::No);
+ CMakeSpecificSettings *settings = CMakeProjectPlugin::projectTypeSpecificSettings();
+ switch (settings->afterAddFileSetting()) {
+ case CMakeProjectManager::Internal::ASK_USER: {
+ bool checkValue{false};
+ QDialogButtonBox::StandardButton reply =
+ Utils::CheckableMessageBox::question(nullptr,
+ QMessageBox::tr("Copy to Clipboard?"),
+ QMessageBox::tr("Files are not automatically added to the "
+ "CMakeLists.txt file of the CMake project."
+ "\nCopy the path to the source files to the clipboard?"),
+ "Remember My Choice", &checkValue, QDialogButtonBox::Yes | QDialogButtonBox::No,
+ QDialogButtonBox::Yes);
+ if (true == checkValue) {
+ if (QDialogButtonBox::Yes == reply)
+ settings->setAfterAddFileSetting(AfterAddFileAction::COPY_FILE_PATH);
+ else if (QDialogButtonBox::No == reply)
+ settings->setAfterAddFileSetting(AfterAddFileAction::NEVER_COPY_FILE_PATH);
- if (QMessageBox::Yes == reply) {
- QClipboard *clip = QGuiApplication::clipboard();
+ settings->toSettings(Core::ICore::settings());
+ }
- QDir projDir{node->filePath().toFileInfo().absoluteFilePath()};
- clip->setText(QDir::cleanPath(projDir.relativeFilePath(srcPath.value())));
+ if (QDialogButtonBox::Yes == reply) {
+ copySourcePathToClipboard(srcPath, node);
+ }
+ break;
+ }
+
+ case CMakeProjectManager::Internal::COPY_FILE_PATH: {
+ copySourcePathToClipboard(srcPath, node);
+ break;
+ }
+
+ case CMakeProjectManager::Internal::NEVER_COPY_FILE_PATH:
+ break;
}
}
}
diff --git a/src/plugins/cmakeprojectmanager/cmakeprojectplugin.cpp b/src/plugins/cmakeprojectmanager/cmakeprojectplugin.cpp
index 2c578ea27e6..da3b80d5702 100644
--- a/src/plugins/cmakeprojectmanager/cmakeprojectplugin.cpp
+++ b/src/plugins/cmakeprojectmanager/cmakeprojectplugin.cpp
@@ -42,11 +42,10 @@
#include
#include
#include
-
+#include
#include
#include
#include
-
#include
#include
@@ -64,6 +63,7 @@ public:
QMetaObject::Connection m_actionConnect;
CMakeSettingsPage settingsPage;
+ static const std::unique_ptr projectTypeSpecificSettings;
CMakeManager manager;
CMakeBuildStepFactory buildStepFactory;
CMakeRunConfigurationFactory runConfigFactory;
@@ -72,6 +72,14 @@ public:
CMakeLocatorFilter locatorFiler;
};
+const std::unique_ptr
+CMakeProjectPluginPrivate::projectTypeSpecificSettings{std::make_unique()};
+
+CMakeSpecificSettings *CMakeProjectPlugin::projectTypeSpecificSettings()
+{
+ return CMakeProjectPluginPrivate::projectTypeSpecificSettings.get();
+}
+
CMakeProjectPlugin::~CMakeProjectPlugin()
{
delete d;
@@ -82,11 +90,15 @@ bool CMakeProjectPlugin::initialize(const QStringList & /*arguments*/, QString *
Q_UNUSED(errorMessage)
d = new CMakeProjectPluginPrivate;
+ CMakeProjectPluginPrivate::projectTypeSpecificSettings->fromSettings(ICore::settings());
+ new CMakeSpecificSettingsPage(CMakeProjectPluginPrivate::projectTypeSpecificSettings.get(),
+ this); //do not store as this will be cleaned after program close
const Context projectContext(CMakeProjectManager::Constants::CMAKEPROJECT_ID);
Core::FileIconProvider::registerIconOverlayForSuffix(Constants::FILEOVERLAY_CMAKE, "cmake");
- Core::FileIconProvider::registerIconOverlayForFilename(Constants::FILEOVERLAY_CMAKE, "CMakeLists.txt");
+ Core::FileIconProvider::registerIconOverlayForFilename(Constants::FILEOVERLAY_CMAKE,
+ "CMakeLists.txt");
TextEditor::SnippetProvider::registerGroup(Constants::CMAKE_SNIPPETS_GROUP_ID,
tr("CMake", "SnippetProvider"));
@@ -108,7 +120,8 @@ bool CMakeProjectPlugin::initialize(const QStringList & /*arguments*/, QString *
d->m_buildTargetContextAction = new Utils::ParameterAction(tr("Build"), tr("Build \"%1\""),
Utils::ParameterAction::AlwaysEnabled/*handled manually*/,
this);
- command = ActionManager::registerAction(d->m_buildTargetContextAction, Constants::BUILD_TARGET_CONTEXTMENU, projectContext);
+ command = ActionManager::registerAction(d->m_buildTargetContextAction,
+ Constants::BUILD_TARGET_CONTEXTMENU, projectContext);
command->setAttribute(Command::CA_Hide);
command->setAttribute(Command::CA_UpdateText);
command->setDescription(d->m_buildTargetContextAction->text());
@@ -143,7 +156,9 @@ void CMakeProjectPlugin::updateContextActions()
d->m_buildTargetContextAction->setVisible(targetNode);
if (cmProject && targetNode) {
d->m_actionConnect = connect(d->m_buildTargetContextAction, &Utils::ParameterAction::triggered,
- cmProject, [cmProject, targetDisplayName]() { cmProject->buildCMakeTarget(targetDisplayName); });
+ cmProject, [cmProject, targetDisplayName]() {
+ cmProject->buildCMakeTarget(targetDisplayName);
+ });
}
}
diff --git a/src/plugins/cmakeprojectmanager/cmakeprojectplugin.h b/src/plugins/cmakeprojectmanager/cmakeprojectplugin.h
index b3ad316e96e..4652078d746 100644
--- a/src/plugins/cmakeprojectmanager/cmakeprojectplugin.h
+++ b/src/plugins/cmakeprojectmanager/cmakeprojectplugin.h
@@ -25,8 +25,9 @@
#pragma once
+#include "cmakespecificsettingspage.h"
#include
-
+#include
namespace CMakeProjectManager {
namespace Internal {
@@ -36,6 +37,7 @@ class CMakeProjectPlugin : public ExtensionSystem::IPlugin
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QtCreatorPlugin" FILE "CMakeProjectManager.json")
public:
+ static CMakeSpecificSettings *projectTypeSpecificSettings();
~CMakeProjectPlugin() override;
#ifdef WITH_TESTS
diff --git a/src/plugins/cmakeprojectmanager/cmakespecificsettings.cpp b/src/plugins/cmakeprojectmanager/cmakespecificsettings.cpp
new file mode 100644
index 00000000000..53f69dac90b
--- /dev/null
+++ b/src/plugins/cmakeprojectmanager/cmakespecificsettings.cpp
@@ -0,0 +1,51 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** 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 The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+****************************************************************************/
+
+#include "cmakespecificsettings.h"
+
+namespace CMakeProjectManager {
+namespace Internal {
+
+namespace {
+static const char SETTINGS_KEY[] = "CMakeSpecificSettings";
+static const char AFTER_ADD_FILE_ACTION_KEY[] = "ProjectPopupSetting";
+}
+
+void CMakeSpecificSettings::fromSettings(QSettings *settings)
+{
+ const QString rootKey = QString(SETTINGS_KEY) + '/';
+ afterAddFileToProjectSetting = static_cast(
+ settings->value(rootKey + AFTER_ADD_FILE_ACTION_KEY,
+ static_cast(AfterAddFileAction::ASK_USER)).toInt());
+}
+
+void CMakeSpecificSettings::toSettings(QSettings *settings) const
+{
+ settings->beginGroup(QString(SETTINGS_KEY));
+ settings->setValue(QString(AFTER_ADD_FILE_ACTION_KEY), static_cast(afterAddFileToProjectSetting));
+ settings->endGroup();
+}
+}
+}
diff --git a/src/plugins/cmakeprojectmanager/cmakespecificsettings.h b/src/plugins/cmakeprojectmanager/cmakespecificsettings.h
new file mode 100644
index 00000000000..fe4d222593a
--- /dev/null
+++ b/src/plugins/cmakeprojectmanager/cmakespecificsettings.h
@@ -0,0 +1,53 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** 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 The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+****************************************************************************/
+
+#pragma once
+#include
+
+namespace CMakeProjectManager {
+namespace Internal {
+
+enum AfterAddFileAction : int {
+ ASK_USER,
+ COPY_FILE_PATH,
+ NEVER_COPY_FILE_PATH
+};
+
+class CMakeSpecificSettings
+{
+public:
+ CMakeSpecificSettings() = default;
+ void fromSettings(QSettings *settings);
+ void toSettings(QSettings *settings) const;
+
+ void setAfterAddFileSetting(AfterAddFileAction settings) { afterAddFileToProjectSetting = settings; }
+ AfterAddFileAction afterAddFileSetting() const { return afterAddFileToProjectSetting; }
+
+private:
+ AfterAddFileAction afterAddFileToProjectSetting;
+};
+
+}
+}
diff --git a/src/plugins/cmakeprojectmanager/cmakespecificsettingspage.cpp b/src/plugins/cmakeprojectmanager/cmakespecificsettingspage.cpp
new file mode 100644
index 00000000000..f05de3bab4f
--- /dev/null
+++ b/src/plugins/cmakeprojectmanager/cmakespecificsettingspage.cpp
@@ -0,0 +1,110 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** 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 The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+****************************************************************************/
+
+#include "cmakespecificsettingspage.h"
+#include
+
+namespace CMakeProjectManager {
+namespace Internal {
+
+namespace {
+const char PROJECT_TYPE_ICON[] = ":/cmakeproject/images/project_type_settings_icon.png";
+}
+
+CMakeSpecificSettingWidget::CMakeSpecificSettingWidget(QWidget *parent):
+ QWidget(parent)
+{
+ m_ui.setupUi(this);
+ m_ui.newFileAddedCopyToCpliSettingGroup->setId(m_ui.alwaysAskRadio,
+ AfterAddFileAction::ASK_USER);
+ m_ui.newFileAddedCopyToCpliSettingGroup->setId(m_ui.neverCopyRadio,
+ AfterAddFileAction::NEVER_COPY_FILE_PATH);
+ m_ui.newFileAddedCopyToCpliSettingGroup->setId(m_ui.alwaysCopyRadio,
+ AfterAddFileAction::COPY_FILE_PATH);
+}
+
+void CMakeSpecificSettingWidget::setSettings(const CMakeSpecificSettings &settings)
+{
+ setProjectPopupSetting(settings.afterAddFileSetting());
+}
+
+CMakeSpecificSettings CMakeSpecificSettingWidget::settings() const
+{
+ CMakeSpecificSettings set;
+
+ int popupSetting = m_ui.newFileAddedCopyToCpliSettingGroup->checkedId();
+ set.setAfterAddFileSetting( (popupSetting == -1) ? AfterAddFileAction::ASK_USER :
+ static_cast(popupSetting));
+ return set;
+
+}
+
+void CMakeSpecificSettingWidget::setProjectPopupSetting(AfterAddFileAction mode)
+{
+ switch (mode) {
+ case CMakeProjectManager::Internal::ASK_USER:
+ m_ui.alwaysAskRadio->setChecked(true);
+ break;
+ case CMakeProjectManager::Internal::COPY_FILE_PATH:
+ m_ui.alwaysCopyRadio->setChecked(true);
+ break;
+ case CMakeProjectManager::Internal::NEVER_COPY_FILE_PATH:
+ m_ui.neverCopyRadio->setChecked(true);
+ break;
+ }
+}
+
+CMakeSpecificSettingsPage::CMakeSpecificSettingsPage(CMakeSpecificSettings *settings,
+ QObject *parent):
+ Core::IOptionsPage{parent}, m_settings{settings}
+{
+ setCategory("ProjectTypeSettingsPage");
+ setDisplayName("Project-Type Settings");
+ setCategoryIcon(Utils::Icon((PROJECT_TYPE_ICON)));
+ setId("CMakeSpecificSettings");
+ setDisplayName(tr("CMake"));
+}
+
+QWidget *CMakeSpecificSettingsPage::widget()
+{
+ if (!m_widget) {
+ m_widget = new CMakeSpecificSettingWidget();
+ m_widget->setSettings(*m_settings);
+ }
+ return m_widget;
+}
+
+void CMakeSpecificSettingsPage::apply()
+{
+ if (!m_widget) // page was never shown
+ return;
+ const CMakeSpecificSettings newSettings = m_widget->settings();
+ *m_settings = newSettings;
+ m_settings->toSettings(Core::ICore::settings());
+
+}
+
+}
+}
diff --git a/src/plugins/cmakeprojectmanager/cmakespecificsettingspage.h b/src/plugins/cmakeprojectmanager/cmakespecificsettingspage.h
new file mode 100644
index 00000000000..1eb71e75dc8
--- /dev/null
+++ b/src/plugins/cmakeprojectmanager/cmakespecificsettingspage.h
@@ -0,0 +1,70 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** 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 The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+****************************************************************************/
+
+#pragma once
+
+#include
+#include "cmakespecificsettings.h"
+#include
+#include "ui_cmakespecificsettingspage.h"
+
+namespace CMakeProjectManager {
+namespace Internal {
+
+
+class CMakeSpecificSettingWidget : public QWidget
+{
+ Q_OBJECT
+
+public:
+ explicit CMakeSpecificSettingWidget(QWidget *parent = 0);
+ void setSettings(const CMakeSpecificSettings &settings);
+ CMakeSpecificSettings settings() const;
+
+private:
+ Ui::CMakeSpecificSettingForm m_ui;
+
+ void setProjectPopupSetting(AfterAddFileAction mode);
+};
+
+
+class CMakeSpecificSettingsPage : public Core::IOptionsPage
+{
+public:
+ CMakeSpecificSettingsPage(CMakeSpecificSettings *settings, QObject *parent);
+
+ QWidget *widget() override;
+ void apply() override;
+ void finish() override { }
+
+private:
+ CMakeSpecificSettings * const m_settings;
+ QPointer m_widget;
+};
+
+}
+}
+
+
diff --git a/src/plugins/cmakeprojectmanager/cmakespecificsettingspage.ui b/src/plugins/cmakeprojectmanager/cmakespecificsettingspage.ui
new file mode 100644
index 00000000000..e1feb670069
--- /dev/null
+++ b/src/plugins/cmakeprojectmanager/cmakespecificsettingspage.ui
@@ -0,0 +1,83 @@
+
+
+ CMakeProjectManager::Internal::CMakeSpecificSettingForm
+
+
+
+ 0
+ 0
+ 852
+ 567
+
+
+
+ Form
+
+
+ -
+
+
+ Determines whether file paths are copied to the clipboard for pasting to the CMakeLists.txt file when you add new files to CMake projects.
+
+
+ Adding Files
+
+
+
-
+
+
-
+
+
+ Ask about copying file paths
+
+
+ newFileAddedCopyToCpliSettingGroup
+
+
+
+ -
+
+
+ Do not copy file paths
+
+
+ newFileAddedCopyToCpliSettingGroup
+
+
+
+ -
+
+
+ Copy file paths
+
+
+ newFileAddedCopyToCpliSettingGroup
+
+
+
+
+
+
+
+
+ -
+
+
+ Qt::Vertical
+
+
+
+ 20
+ 40
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/plugins/cmakeprojectmanager/images/project_type_settings_icon.png b/src/plugins/cmakeprojectmanager/images/project_type_settings_icon.png
new file mode 100644
index 00000000000..7065a516862
Binary files /dev/null and b/src/plugins/cmakeprojectmanager/images/project_type_settings_icon.png differ