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
|
||||
cppquickfixprojectsettings.cpp cppquickfixprojectsettings.h
|
||||
cppquickfixprojectsettingswidget.cpp cppquickfixprojectsettingswidget.h
|
||||
cppquickfixprojectsettingswidget.ui
|
||||
cppquickfixsettings.cpp cppquickfixsettings.h
|
||||
cppquickfixsettingspage.cpp cppquickfixsettingspage.h
|
||||
cppquickfixsettingswidget.cpp cppquickfixsettingswidget.h cppquickfixsettingswidget.ui
|
||||
|
||||
@@ -174,7 +174,6 @@ QtcPlugin {
|
||||
"cppquickfixprojectsettings.h",
|
||||
"cppquickfixprojectsettingswidget.cpp",
|
||||
"cppquickfixprojectsettingswidget.h",
|
||||
"cppquickfixprojectsettingswidget.ui",
|
||||
"cppquickfixsettings.cpp",
|
||||
"cppquickfixsettings.h",
|
||||
"cppquickfixsettingspage.cpp",
|
||||
|
||||
@@ -24,36 +24,46 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include "cppquickfixprojectsettingswidget.h"
|
||||
|
||||
#include "cppeditorconstants.h"
|
||||
#include "cppquickfixsettingswidget.h"
|
||||
#include "ui_cppquickfixprojectsettingswidget.h"
|
||||
|
||||
#include <QFile>
|
||||
#include <QGridLayout>
|
||||
#include <QPushButton>
|
||||
|
||||
using namespace CppEditor::Internal;
|
||||
namespace CppEditor::Internal {
|
||||
|
||||
CppQuickFixProjectSettingsWidget::CppQuickFixProjectSettingsWidget(ProjectExplorer::Project *project,
|
||||
QWidget *parent)
|
||||
: ProjectExplorer::ProjectSettingsWidget(parent)
|
||||
, ui(new Ui::CppQuickFixProjectSettingsWidget)
|
||||
{
|
||||
setGlobalSettingsId(CppEditor::Constants::QUICK_FIX_SETTINGS_ID);
|
||||
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());
|
||||
|
||||
if (QLayout *layout = m_settingsWidget->layout())
|
||||
layout->setContentsMargins(0, 0, 0, 0);
|
||||
ui->layout->addWidget(m_settingsWidget);
|
||||
layout->addWidget(m_settingsWidget);
|
||||
|
||||
connect(this, &ProjectSettingsWidget::useGlobalSettingsChanged,
|
||||
this, &CppQuickFixProjectSettingsWidget::currentItemChanged);
|
||||
setUseGlobalSettings(m_projectSettings->isUsingGlobalSettings());
|
||||
currentItemChanged(m_projectSettings->useCustomSettings());
|
||||
|
||||
connect(ui->pushButton_custom, &QAbstractButton::clicked,
|
||||
connect(m_pushButton, &QAbstractButton::clicked,
|
||||
this, &CppQuickFixProjectSettingsWidget::buttonCustomClicked);
|
||||
connect(m_settingsWidget, &CppEditor::Internal::CppQuickFixSettingsWidget::settingsChanged, this,
|
||||
connect(m_settingsWidget, &CppQuickFixSettingsWidget::settingsChanged, this,
|
||||
[this] {
|
||||
m_settingsWidget->saveSettings(m_projectSettings->getSettings());
|
||||
if (!useGlobalSettings())
|
||||
@@ -61,28 +71,25 @@ CppQuickFixProjectSettingsWidget::CppQuickFixProjectSettingsWidget(ProjectExplor
|
||||
});
|
||||
}
|
||||
|
||||
CppQuickFixProjectSettingsWidget::~CppQuickFixProjectSettingsWidget()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
CppQuickFixProjectSettingsWidget::~CppQuickFixProjectSettingsWidget() = default;
|
||||
|
||||
void CppQuickFixProjectSettingsWidget::currentItemChanged(bool useGlobalSettings)
|
||||
{
|
||||
if (useGlobalSettings) {
|
||||
const auto &path = m_projectSettings->filePathOfSettingsFile();
|
||||
ui->pushButton_custom->setToolTip(tr("Custom settings are saved in a file. If you use the "
|
||||
"global settings, you can delete that file."));
|
||||
ui->pushButton_custom->setText(tr("Delete Custom Settings File"));
|
||||
ui->pushButton_custom->setVisible(!path.isEmpty() && path.exists());
|
||||
m_pushButton->setToolTip(tr("Custom settings are saved in a file. If you use the "
|
||||
"global settings, you can delete that file."));
|
||||
m_pushButton->setText(tr("Delete Custom Settings File"));
|
||||
m_pushButton->setVisible(!path.isEmpty() && path.exists());
|
||||
m_projectSettings->useGlobalSettings();
|
||||
} else /*Custom*/ {
|
||||
if (!m_projectSettings->useCustomSettings()) {
|
||||
setUseGlobalSettings(!m_projectSettings->useCustomSettings());
|
||||
return;
|
||||
}
|
||||
ui->pushButton_custom->setToolTip(tr("Resets all settings to the global settings."));
|
||||
ui->pushButton_custom->setText(tr("Reset to Global"));
|
||||
ui->pushButton_custom->setVisible(true);
|
||||
m_pushButton->setToolTip(tr("Resets all settings to the global settings."));
|
||||
m_pushButton->setText(tr("Reset to Global"));
|
||||
m_pushButton->setVisible(true);
|
||||
// otherwise you change the comboBox and exit and have no custom settings:
|
||||
m_projectSettings->saveOwnSettings();
|
||||
}
|
||||
@@ -94,10 +101,12 @@ void CppQuickFixProjectSettingsWidget::buttonCustomClicked()
|
||||
if (useGlobalSettings()) {
|
||||
// delete file
|
||||
QFile::remove(m_projectSettings->filePathOfSettingsFile().toString());
|
||||
ui->pushButton_custom->setVisible(false);
|
||||
m_pushButton->setVisible(false);
|
||||
} else /*Custom*/ {
|
||||
m_projectSettings->resetOwnSettingsToGlobal();
|
||||
m_projectSettings->saveOwnSettings();
|
||||
m_settingsWidget->loadSettings(m_projectSettings->getSettings());
|
||||
}
|
||||
}
|
||||
|
||||
} // CppEditor::Internal
|
||||
|
||||
@@ -28,16 +28,14 @@
|
||||
#include "cppquickfixprojectsettings.h"
|
||||
#include <projectexplorer/projectsettingswidget.h>
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
namespace Ui { class CppQuickFixProjectSettingsWidget; }
|
||||
class QPushButton;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace ProjectExplorer { class Project; }
|
||||
|
||||
namespace CppEditor {
|
||||
namespace Internal {
|
||||
namespace CppEditor::Internal {
|
||||
|
||||
class CppQuickFixSettingsWidget;
|
||||
class CppQuickFixProjectSettingsWidget : public ProjectExplorer::ProjectSettingsWidget
|
||||
{
|
||||
@@ -48,15 +46,14 @@ public:
|
||||
QWidget *parent = nullptr);
|
||||
~CppQuickFixProjectSettingsWidget();
|
||||
|
||||
private slots:
|
||||
private:
|
||||
void currentItemChanged(bool useGlobalSettings);
|
||||
void buttonCustomClicked();
|
||||
|
||||
private:
|
||||
QT_PREPEND_NAMESPACE(Ui)::CppQuickFixProjectSettingsWidget *ui;
|
||||
CppQuickFixSettingsWidget *m_settingsWidget;
|
||||
CppQuickFixProjectsSettings::CppQuickFixProjectsSettingsPtr m_projectSettings;
|
||||
|
||||
QPushButton *m_pushButton;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace CppEditor
|
||||
} // CppEditor::Internal
|
||||
|
||||
@@ -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