forked from qt-creator/qt-creator
CppEditor: Inline cppquickfixprojectsettingswidget.ui
A practically empty grid. Change-Id: I6d23794244519de4c019aab6530482e28de964c5 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -80,7 +80,6 @@ add_qtc_plugin(CppEditor
|
|||||||
cppquickfixes.cpp cppquickfixes.h
|
cppquickfixes.cpp cppquickfixes.h
|
||||||
cppquickfixprojectsettings.cpp cppquickfixprojectsettings.h
|
cppquickfixprojectsettings.cpp cppquickfixprojectsettings.h
|
||||||
cppquickfixprojectsettingswidget.cpp cppquickfixprojectsettingswidget.h
|
cppquickfixprojectsettingswidget.cpp cppquickfixprojectsettingswidget.h
|
||||||
cppquickfixprojectsettingswidget.ui
|
|
||||||
cppquickfixsettings.cpp cppquickfixsettings.h
|
cppquickfixsettings.cpp cppquickfixsettings.h
|
||||||
cppquickfixsettingspage.cpp cppquickfixsettingspage.h
|
cppquickfixsettingspage.cpp cppquickfixsettingspage.h
|
||||||
cppquickfixsettingswidget.cpp cppquickfixsettingswidget.h cppquickfixsettingswidget.ui
|
cppquickfixsettingswidget.cpp cppquickfixsettingswidget.h cppquickfixsettingswidget.ui
|
||||||
|
|||||||
@@ -174,7 +174,6 @@ QtcPlugin {
|
|||||||
"cppquickfixprojectsettings.h",
|
"cppquickfixprojectsettings.h",
|
||||||
"cppquickfixprojectsettingswidget.cpp",
|
"cppquickfixprojectsettingswidget.cpp",
|
||||||
"cppquickfixprojectsettingswidget.h",
|
"cppquickfixprojectsettingswidget.h",
|
||||||
"cppquickfixprojectsettingswidget.ui",
|
|
||||||
"cppquickfixsettings.cpp",
|
"cppquickfixsettings.cpp",
|
||||||
"cppquickfixsettings.h",
|
"cppquickfixsettings.h",
|
||||||
"cppquickfixsettingspage.cpp",
|
"cppquickfixsettingspage.cpp",
|
||||||
|
|||||||
@@ -24,36 +24,46 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include "cppquickfixprojectsettingswidget.h"
|
#include "cppquickfixprojectsettingswidget.h"
|
||||||
|
|
||||||
#include "cppeditorconstants.h"
|
#include "cppeditorconstants.h"
|
||||||
#include "cppquickfixsettingswidget.h"
|
#include "cppquickfixsettingswidget.h"
|
||||||
#include "ui_cppquickfixprojectsettingswidget.h"
|
|
||||||
|
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
|
#include <QGridLayout>
|
||||||
|
#include <QPushButton>
|
||||||
|
|
||||||
using namespace CppEditor::Internal;
|
namespace CppEditor::Internal {
|
||||||
|
|
||||||
CppQuickFixProjectSettingsWidget::CppQuickFixProjectSettingsWidget(ProjectExplorer::Project *project,
|
CppQuickFixProjectSettingsWidget::CppQuickFixProjectSettingsWidget(ProjectExplorer::Project *project,
|
||||||
QWidget *parent)
|
QWidget *parent)
|
||||||
: ProjectExplorer::ProjectSettingsWidget(parent)
|
: ProjectExplorer::ProjectSettingsWidget(parent)
|
||||||
, ui(new Ui::CppQuickFixProjectSettingsWidget)
|
|
||||||
{
|
{
|
||||||
setGlobalSettingsId(CppEditor::Constants::QUICK_FIX_SETTINGS_ID);
|
setGlobalSettingsId(CppEditor::Constants::QUICK_FIX_SETTINGS_ID);
|
||||||
m_projectSettings = CppQuickFixProjectsSettings::getSettings(project);
|
m_projectSettings = CppQuickFixProjectsSettings::getSettings(project);
|
||||||
ui->setupUi(this);
|
|
||||||
m_settingsWidget = new CppEditor::Internal::CppQuickFixSettingsWidget(this);
|
m_pushButton = new QPushButton(this);
|
||||||
|
|
||||||
|
auto gridLayout = new QGridLayout(this);
|
||||||
|
gridLayout->setContentsMargins(0, 0, 0, 0);
|
||||||
|
gridLayout->addWidget(m_pushButton, 1, 0, 1, 1);
|
||||||
|
auto layout = new QVBoxLayout();
|
||||||
|
gridLayout->addLayout(layout, 2, 0, 1, 2);
|
||||||
|
|
||||||
|
m_settingsWidget = new CppQuickFixSettingsWidget(this);
|
||||||
m_settingsWidget->loadSettings(m_projectSettings->getSettings());
|
m_settingsWidget->loadSettings(m_projectSettings->getSettings());
|
||||||
|
|
||||||
if (QLayout *layout = m_settingsWidget->layout())
|
if (QLayout *layout = m_settingsWidget->layout())
|
||||||
layout->setContentsMargins(0, 0, 0, 0);
|
layout->setContentsMargins(0, 0, 0, 0);
|
||||||
ui->layout->addWidget(m_settingsWidget);
|
layout->addWidget(m_settingsWidget);
|
||||||
|
|
||||||
connect(this, &ProjectSettingsWidget::useGlobalSettingsChanged,
|
connect(this, &ProjectSettingsWidget::useGlobalSettingsChanged,
|
||||||
this, &CppQuickFixProjectSettingsWidget::currentItemChanged);
|
this, &CppQuickFixProjectSettingsWidget::currentItemChanged);
|
||||||
setUseGlobalSettings(m_projectSettings->isUsingGlobalSettings());
|
setUseGlobalSettings(m_projectSettings->isUsingGlobalSettings());
|
||||||
currentItemChanged(m_projectSettings->useCustomSettings());
|
currentItemChanged(m_projectSettings->useCustomSettings());
|
||||||
|
|
||||||
connect(ui->pushButton_custom, &QAbstractButton::clicked,
|
connect(m_pushButton, &QAbstractButton::clicked,
|
||||||
this, &CppQuickFixProjectSettingsWidget::buttonCustomClicked);
|
this, &CppQuickFixProjectSettingsWidget::buttonCustomClicked);
|
||||||
connect(m_settingsWidget, &CppEditor::Internal::CppQuickFixSettingsWidget::settingsChanged, this,
|
connect(m_settingsWidget, &CppQuickFixSettingsWidget::settingsChanged, this,
|
||||||
[this] {
|
[this] {
|
||||||
m_settingsWidget->saveSettings(m_projectSettings->getSettings());
|
m_settingsWidget->saveSettings(m_projectSettings->getSettings());
|
||||||
if (!useGlobalSettings())
|
if (!useGlobalSettings())
|
||||||
@@ -61,28 +71,25 @@ CppQuickFixProjectSettingsWidget::CppQuickFixProjectSettingsWidget(ProjectExplor
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
CppQuickFixProjectSettingsWidget::~CppQuickFixProjectSettingsWidget()
|
CppQuickFixProjectSettingsWidget::~CppQuickFixProjectSettingsWidget() = default;
|
||||||
{
|
|
||||||
delete ui;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CppQuickFixProjectSettingsWidget::currentItemChanged(bool useGlobalSettings)
|
void CppQuickFixProjectSettingsWidget::currentItemChanged(bool useGlobalSettings)
|
||||||
{
|
{
|
||||||
if (useGlobalSettings) {
|
if (useGlobalSettings) {
|
||||||
const auto &path = m_projectSettings->filePathOfSettingsFile();
|
const auto &path = m_projectSettings->filePathOfSettingsFile();
|
||||||
ui->pushButton_custom->setToolTip(tr("Custom settings are saved in a file. If you use the "
|
m_pushButton->setToolTip(tr("Custom settings are saved in a file. If you use the "
|
||||||
"global settings, you can delete that file."));
|
"global settings, you can delete that file."));
|
||||||
ui->pushButton_custom->setText(tr("Delete Custom Settings File"));
|
m_pushButton->setText(tr("Delete Custom Settings File"));
|
||||||
ui->pushButton_custom->setVisible(!path.isEmpty() && path.exists());
|
m_pushButton->setVisible(!path.isEmpty() && path.exists());
|
||||||
m_projectSettings->useGlobalSettings();
|
m_projectSettings->useGlobalSettings();
|
||||||
} else /*Custom*/ {
|
} else /*Custom*/ {
|
||||||
if (!m_projectSettings->useCustomSettings()) {
|
if (!m_projectSettings->useCustomSettings()) {
|
||||||
setUseGlobalSettings(!m_projectSettings->useCustomSettings());
|
setUseGlobalSettings(!m_projectSettings->useCustomSettings());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ui->pushButton_custom->setToolTip(tr("Resets all settings to the global settings."));
|
m_pushButton->setToolTip(tr("Resets all settings to the global settings."));
|
||||||
ui->pushButton_custom->setText(tr("Reset to Global"));
|
m_pushButton->setText(tr("Reset to Global"));
|
||||||
ui->pushButton_custom->setVisible(true);
|
m_pushButton->setVisible(true);
|
||||||
// otherwise you change the comboBox and exit and have no custom settings:
|
// otherwise you change the comboBox and exit and have no custom settings:
|
||||||
m_projectSettings->saveOwnSettings();
|
m_projectSettings->saveOwnSettings();
|
||||||
}
|
}
|
||||||
@@ -94,10 +101,12 @@ void CppQuickFixProjectSettingsWidget::buttonCustomClicked()
|
|||||||
if (useGlobalSettings()) {
|
if (useGlobalSettings()) {
|
||||||
// delete file
|
// delete file
|
||||||
QFile::remove(m_projectSettings->filePathOfSettingsFile().toString());
|
QFile::remove(m_projectSettings->filePathOfSettingsFile().toString());
|
||||||
ui->pushButton_custom->setVisible(false);
|
m_pushButton->setVisible(false);
|
||||||
} else /*Custom*/ {
|
} else /*Custom*/ {
|
||||||
m_projectSettings->resetOwnSettingsToGlobal();
|
m_projectSettings->resetOwnSettingsToGlobal();
|
||||||
m_projectSettings->saveOwnSettings();
|
m_projectSettings->saveOwnSettings();
|
||||||
m_settingsWidget->loadSettings(m_projectSettings->getSettings());
|
m_settingsWidget->loadSettings(m_projectSettings->getSettings());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // CppEditor::Internal
|
||||||
|
|||||||
@@ -28,16 +28,14 @@
|
|||||||
#include "cppquickfixprojectsettings.h"
|
#include "cppquickfixprojectsettings.h"
|
||||||
#include <projectexplorer/projectsettingswidget.h>
|
#include <projectexplorer/projectsettingswidget.h>
|
||||||
|
|
||||||
#include <QWidget>
|
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
namespace Ui { class CppQuickFixProjectSettingsWidget; }
|
class QPushButton;
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
namespace ProjectExplorer { class Project; }
|
namespace ProjectExplorer { class Project; }
|
||||||
|
|
||||||
namespace CppEditor {
|
namespace CppEditor::Internal {
|
||||||
namespace Internal {
|
|
||||||
class CppQuickFixSettingsWidget;
|
class CppQuickFixSettingsWidget;
|
||||||
class CppQuickFixProjectSettingsWidget : public ProjectExplorer::ProjectSettingsWidget
|
class CppQuickFixProjectSettingsWidget : public ProjectExplorer::ProjectSettingsWidget
|
||||||
{
|
{
|
||||||
@@ -48,15 +46,14 @@ public:
|
|||||||
QWidget *parent = nullptr);
|
QWidget *parent = nullptr);
|
||||||
~CppQuickFixProjectSettingsWidget();
|
~CppQuickFixProjectSettingsWidget();
|
||||||
|
|
||||||
private slots:
|
private:
|
||||||
void currentItemChanged(bool useGlobalSettings);
|
void currentItemChanged(bool useGlobalSettings);
|
||||||
void buttonCustomClicked();
|
void buttonCustomClicked();
|
||||||
|
|
||||||
private:
|
|
||||||
QT_PREPEND_NAMESPACE(Ui)::CppQuickFixProjectSettingsWidget *ui;
|
|
||||||
CppQuickFixSettingsWidget *m_settingsWidget;
|
CppQuickFixSettingsWidget *m_settingsWidget;
|
||||||
CppQuickFixProjectsSettings::CppQuickFixProjectsSettingsPtr m_projectSettings;
|
CppQuickFixProjectsSettings::CppQuickFixProjectsSettingsPtr m_projectSettings;
|
||||||
|
|
||||||
|
QPushButton *m_pushButton;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // CppEditor::Internal
|
||||||
} // namespace CppEditor
|
|
||||||
|
|||||||
@@ -1,40 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<ui version="4.0">
|
|
||||||
<class>CppQuickFixProjectSettingsWidget</class>
|
|
||||||
<widget class="QWidget" name="CppQuickFixProjectSettingsWidget">
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>0</x>
|
|
||||||
<y>0</y>
|
|
||||||
<width>532</width>
|
|
||||||
<height>345</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
|
||||||
<property name="leftMargin">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="topMargin">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="rightMargin">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="bottomMargin">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<item row="2" column="0" colspan="2">
|
|
||||||
<layout class="QVBoxLayout" name="layout"/>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="0">
|
|
||||||
<widget class="QPushButton" name="pushButton_custom">
|
|
||||||
<property name="text">
|
|
||||||
<string/>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
<resources/>
|
|
||||||
<connections/>
|
|
||||||
</ui>
|
|
||||||
Reference in New Issue
Block a user