forked from qt-creator/qt-creator
Coco: Merge settings related file pairs
A step towards the standard pattern. Change-Id: I5443d0ffb4c8cb6911a99a3238b6377ed3a068f6 Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
This commit is contained in:
@@ -39,8 +39,6 @@ add_qtc_plugin(Coco
|
|||||||
files/cocoplugin.prf
|
files/cocoplugin.prf
|
||||||
globalsettings.cpp
|
globalsettings.cpp
|
||||||
globalsettings.h
|
globalsettings.h
|
||||||
globalsettingspage.cpp
|
|
||||||
globalsettingspage.h
|
|
||||||
images/SquishCoco_48x48.png
|
images/SquishCoco_48x48.png
|
||||||
modificationfile.cpp
|
modificationfile.cpp
|
||||||
modificationfile.h
|
modificationfile.h
|
||||||
|
@@ -45,8 +45,6 @@ QtcPlugin {
|
|||||||
"files/cocoplugin.prf",
|
"files/cocoplugin.prf",
|
||||||
"globalsettings.cpp",
|
"globalsettings.cpp",
|
||||||
"globalsettings.h",
|
"globalsettings.h",
|
||||||
"globalsettingspage.cpp",
|
|
||||||
"globalsettingspage.h",
|
|
||||||
"images/SquishCoco_48x48.png",
|
"images/SquishCoco_48x48.png",
|
||||||
"modificationfile.cpp",
|
"modificationfile.cpp",
|
||||||
"modificationfile.h",
|
"modificationfile.h",
|
||||||
|
@@ -7,7 +7,6 @@
|
|||||||
#include "cocoprojectsettingswidget.h"
|
#include "cocoprojectsettingswidget.h"
|
||||||
#include "cocotr.h"
|
#include "cocotr.h"
|
||||||
#include "globalsettings.h"
|
#include "globalsettings.h"
|
||||||
#include "globalsettingspage.h"
|
|
||||||
|
|
||||||
#include <coreplugin/actionmanager/actioncontainer.h>
|
#include <coreplugin/actionmanager/actioncontainer.h>
|
||||||
#include <coreplugin/actionmanager/actionmanager.h>
|
#include <coreplugin/actionmanager/actionmanager.h>
|
||||||
|
@@ -7,7 +7,7 @@
|
|||||||
#include "cococommon.h"
|
#include "cococommon.h"
|
||||||
#include "cocopluginconstants.h"
|
#include "cocopluginconstants.h"
|
||||||
#include "cocotr.h"
|
#include "cocotr.h"
|
||||||
#include "globalsettingspage.h"
|
#include "globalsettings.h"
|
||||||
|
|
||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
#include <projectexplorer/buildsystem.h>
|
#include <projectexplorer/buildsystem.h>
|
||||||
|
@@ -5,9 +5,13 @@
|
|||||||
|
|
||||||
#include "cocoinstallation.h"
|
#include "cocoinstallation.h"
|
||||||
#include "cocopluginconstants.h"
|
#include "cocopluginconstants.h"
|
||||||
|
#include "cocotr.h"
|
||||||
|
|
||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
|
|
||||||
|
#include <utils/fancylineedit.h>
|
||||||
#include <utils/filepath.h>
|
#include <utils/filepath.h>
|
||||||
|
#include <utils/layoutbuilder.h>
|
||||||
|
|
||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
@@ -50,4 +54,108 @@ void save()
|
|||||||
}
|
}
|
||||||
|
|
||||||
} // namespace GlobalSettings
|
} // namespace GlobalSettings
|
||||||
|
|
||||||
|
GlobalSettingsWidget::GlobalSettingsWidget(QFrame *parent)
|
||||||
|
: QFrame(parent)
|
||||||
|
{
|
||||||
|
m_cocoPathAspect.setDefaultPathValue(m_coco.directory());
|
||||||
|
m_cocoPathAspect.setExpectedKind(Utils::PathChooser::ExistingDirectory);
|
||||||
|
m_cocoPathAspect.setPromptDialogTitle(Tr::tr("Coco Installation Directory"));
|
||||||
|
|
||||||
|
connect(
|
||||||
|
&m_cocoPathAspect,
|
||||||
|
&Utils::FilePathAspect::changed,
|
||||||
|
this,
|
||||||
|
&GlobalSettingsWidget::onCocoPathChanged);
|
||||||
|
|
||||||
|
using namespace Layouting;
|
||||||
|
Form{
|
||||||
|
Column{
|
||||||
|
Row{Tr::tr("Coco Directory"), m_cocoPathAspect},
|
||||||
|
Row{m_messageLabel}}
|
||||||
|
}.attachTo(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
void GlobalSettingsWidget::onCocoPathChanged()
|
||||||
|
{
|
||||||
|
if (!verifyCocoDirectory(m_cocoPathAspect()))
|
||||||
|
m_cocoPathAspect.setValue(m_previousCocoDir, Utils::BaseAspect::BeQuiet);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool GlobalSettingsWidget::verifyCocoDirectory(const Utils::FilePath &cocoDir)
|
||||||
|
{
|
||||||
|
m_coco.setDirectory(cocoDir);
|
||||||
|
m_messageLabel.setText(m_coco.errorMessage());
|
||||||
|
if (m_coco.isValid())
|
||||||
|
m_messageLabel.setIconType(Utils::InfoLabel::None);
|
||||||
|
else
|
||||||
|
m_messageLabel.setIconType(Utils::InfoLabel::Error);
|
||||||
|
return m_coco.isValid();
|
||||||
|
}
|
||||||
|
|
||||||
|
void GlobalSettingsWidget::apply()
|
||||||
|
{
|
||||||
|
if (!verifyCocoDirectory(widgetCocoDir()))
|
||||||
|
return;
|
||||||
|
|
||||||
|
m_coco.setDirectory(widgetCocoDir());
|
||||||
|
GlobalSettings::save();
|
||||||
|
|
||||||
|
emit updateCocoDir();
|
||||||
|
}
|
||||||
|
|
||||||
|
void GlobalSettingsWidget::cancel()
|
||||||
|
{
|
||||||
|
m_coco.setDirectory(m_previousCocoDir);
|
||||||
|
}
|
||||||
|
|
||||||
|
void GlobalSettingsWidget::setVisible(bool visible)
|
||||||
|
{
|
||||||
|
QFrame::setVisible(visible);
|
||||||
|
m_previousCocoDir = m_coco.directory();
|
||||||
|
}
|
||||||
|
|
||||||
|
Utils::FilePath GlobalSettingsWidget::widgetCocoDir() const
|
||||||
|
{
|
||||||
|
return Utils::FilePath::fromUserInput(m_cocoPathAspect.value());
|
||||||
|
}
|
||||||
|
|
||||||
|
GlobalSettingsPage::GlobalSettingsPage()
|
||||||
|
: m_widget(nullptr)
|
||||||
|
{
|
||||||
|
setId(Constants::COCO_SETTINGS_PAGE_ID);
|
||||||
|
setDisplayName(QCoreApplication::translate("Coco", "Coco"));
|
||||||
|
setCategory("I.Coco"); // Category I contains also the C++ settings.
|
||||||
|
}
|
||||||
|
|
||||||
|
GlobalSettingsPage &GlobalSettingsPage::instance()
|
||||||
|
{
|
||||||
|
static GlobalSettingsPage instance;
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
GlobalSettingsWidget *GlobalSettingsPage::widget()
|
||||||
|
{
|
||||||
|
if (!m_widget)
|
||||||
|
m_widget = new GlobalSettingsWidget;
|
||||||
|
return m_widget;
|
||||||
|
}
|
||||||
|
|
||||||
|
void GlobalSettingsPage::apply()
|
||||||
|
{
|
||||||
|
if (m_widget)
|
||||||
|
m_widget->apply();
|
||||||
|
}
|
||||||
|
|
||||||
|
void GlobalSettingsPage::cancel()
|
||||||
|
{
|
||||||
|
if (m_widget)
|
||||||
|
m_widget->cancel();
|
||||||
|
}
|
||||||
|
|
||||||
|
void GlobalSettingsPage::finish()
|
||||||
|
{
|
||||||
|
delete m_widget;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Coco::Internal
|
} // namespace Coco::Internal
|
||||||
|
@@ -3,11 +3,64 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "cocoinstallation.h"
|
||||||
|
|
||||||
|
#include <coreplugin/dialogs/ioptionspage.h>
|
||||||
|
|
||||||
|
#include <QPointer>
|
||||||
|
|
||||||
namespace Coco::Internal {
|
namespace Coco::Internal {
|
||||||
namespace GlobalSettings {
|
namespace GlobalSettings {
|
||||||
|
|
||||||
void read();
|
void read();
|
||||||
void save();
|
void save();
|
||||||
|
|
||||||
} // namespace GlobalSettings
|
} // GlobalSettings
|
||||||
|
|
||||||
|
|
||||||
|
class GlobalSettingsWidget : public QFrame
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
GlobalSettingsWidget(QFrame *parent = nullptr);
|
||||||
|
|
||||||
|
void apply();
|
||||||
|
void cancel();
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void updateCocoDir();
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void setVisible(bool visible) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
void onCocoPathChanged();
|
||||||
|
|
||||||
|
Utils::FilePath widgetCocoDir() const;
|
||||||
|
bool verifyCocoDirectory(const Utils::FilePath &cocoDir);
|
||||||
|
|
||||||
|
Utils::FilePathAspect m_cocoPathAspect;
|
||||||
|
Utils::TextDisplay m_messageLabel;
|
||||||
|
|
||||||
|
CocoInstallation m_coco;
|
||||||
|
Utils::FilePath m_previousCocoDir;
|
||||||
|
};
|
||||||
|
|
||||||
|
class GlobalSettingsPage : public Core::IOptionsPage
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static GlobalSettingsPage &instance();
|
||||||
|
|
||||||
|
GlobalSettingsWidget *widget() override;
|
||||||
|
void apply() override;
|
||||||
|
void cancel() override;
|
||||||
|
void finish() override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
GlobalSettingsPage();
|
||||||
|
|
||||||
|
QPointer<GlobalSettingsWidget> m_widget;
|
||||||
|
};
|
||||||
|
|
||||||
} // namespace Coco::Internal
|
} // namespace Coco::Internal
|
||||||
|
@@ -1,119 +0,0 @@
|
|||||||
// Copyright (C) 2024 The Qt Company Ltd.
|
|
||||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
|
||||||
|
|
||||||
#include "globalsettingspage.h"
|
|
||||||
|
|
||||||
#include "cocoinstallation.h"
|
|
||||||
#include "cocopluginconstants.h"
|
|
||||||
#include "cocotr.h"
|
|
||||||
#include "globalsettings.h"
|
|
||||||
|
|
||||||
#include <utils/fancylineedit.h>
|
|
||||||
#include <utils/layoutbuilder.h>
|
|
||||||
|
|
||||||
namespace Coco::Internal {
|
|
||||||
|
|
||||||
GlobalSettingsWidget::GlobalSettingsWidget(QFrame *parent)
|
|
||||||
: QFrame(parent)
|
|
||||||
{
|
|
||||||
m_cocoPathAspect.setDefaultPathValue(m_coco.directory());
|
|
||||||
m_cocoPathAspect.setExpectedKind(Utils::PathChooser::ExistingDirectory);
|
|
||||||
m_cocoPathAspect.setPromptDialogTitle(Tr::tr("Coco Installation Directory"));
|
|
||||||
|
|
||||||
connect(
|
|
||||||
&m_cocoPathAspect,
|
|
||||||
&Utils::FilePathAspect::changed,
|
|
||||||
this,
|
|
||||||
&GlobalSettingsWidget::onCocoPathChanged);
|
|
||||||
|
|
||||||
using namespace Layouting;
|
|
||||||
Form{
|
|
||||||
Column{
|
|
||||||
Row{Tr::tr("Coco Directory"), m_cocoPathAspect},
|
|
||||||
Row{m_messageLabel}}
|
|
||||||
}.attachTo(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GlobalSettingsWidget::onCocoPathChanged()
|
|
||||||
{
|
|
||||||
if (!verifyCocoDirectory(m_cocoPathAspect()))
|
|
||||||
m_cocoPathAspect.setValue(m_previousCocoDir, Utils::BaseAspect::BeQuiet);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool GlobalSettingsWidget::verifyCocoDirectory(const Utils::FilePath &cocoDir)
|
|
||||||
{
|
|
||||||
m_coco.setDirectory(cocoDir);
|
|
||||||
m_messageLabel.setText(m_coco.errorMessage());
|
|
||||||
if (m_coco.isValid())
|
|
||||||
m_messageLabel.setIconType(Utils::InfoLabel::None);
|
|
||||||
else
|
|
||||||
m_messageLabel.setIconType(Utils::InfoLabel::Error);
|
|
||||||
return m_coco.isValid();
|
|
||||||
}
|
|
||||||
|
|
||||||
void GlobalSettingsWidget::apply()
|
|
||||||
{
|
|
||||||
if (!verifyCocoDirectory(widgetCocoDir()))
|
|
||||||
return;
|
|
||||||
|
|
||||||
m_coco.setDirectory(widgetCocoDir());
|
|
||||||
GlobalSettings::save();
|
|
||||||
|
|
||||||
emit updateCocoDir();
|
|
||||||
}
|
|
||||||
|
|
||||||
void GlobalSettingsWidget::cancel()
|
|
||||||
{
|
|
||||||
m_coco.setDirectory(m_previousCocoDir);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GlobalSettingsWidget::setVisible(bool visible)
|
|
||||||
{
|
|
||||||
QFrame::setVisible(visible);
|
|
||||||
m_previousCocoDir = m_coco.directory();
|
|
||||||
}
|
|
||||||
|
|
||||||
Utils::FilePath GlobalSettingsWidget::widgetCocoDir() const
|
|
||||||
{
|
|
||||||
return Utils::FilePath::fromUserInput(m_cocoPathAspect.value());
|
|
||||||
}
|
|
||||||
|
|
||||||
GlobalSettingsPage::GlobalSettingsPage()
|
|
||||||
: m_widget(nullptr)
|
|
||||||
{
|
|
||||||
setId(Constants::COCO_SETTINGS_PAGE_ID);
|
|
||||||
setDisplayName(QCoreApplication::translate("Coco", "Coco"));
|
|
||||||
setCategory("I.Coco"); // Category I contains also the C++ settings.
|
|
||||||
}
|
|
||||||
|
|
||||||
GlobalSettingsPage &GlobalSettingsPage::instance()
|
|
||||||
{
|
|
||||||
static GlobalSettingsPage instance;
|
|
||||||
return instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
GlobalSettingsWidget *GlobalSettingsPage::widget()
|
|
||||||
{
|
|
||||||
if (!m_widget)
|
|
||||||
m_widget = new GlobalSettingsWidget;
|
|
||||||
return m_widget;
|
|
||||||
}
|
|
||||||
|
|
||||||
void GlobalSettingsPage::apply()
|
|
||||||
{
|
|
||||||
if (m_widget)
|
|
||||||
m_widget->apply();
|
|
||||||
}
|
|
||||||
|
|
||||||
void GlobalSettingsPage::cancel()
|
|
||||||
{
|
|
||||||
if (m_widget)
|
|
||||||
m_widget->cancel();
|
|
||||||
}
|
|
||||||
|
|
||||||
void GlobalSettingsPage::finish()
|
|
||||||
{
|
|
||||||
delete m_widget;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace Coco::Internal
|
|
@@ -1,59 +0,0 @@
|
|||||||
// Copyright (C) 2024 The Qt Company Ltd.
|
|
||||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "cocoinstallation.h"
|
|
||||||
|
|
||||||
#include <coreplugin/dialogs/ioptionspage.h>
|
|
||||||
|
|
||||||
#include <QPointer>
|
|
||||||
|
|
||||||
namespace Coco::Internal {
|
|
||||||
|
|
||||||
class GlobalSettingsWidget : public QFrame
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
GlobalSettingsWidget(QFrame *parent = nullptr);
|
|
||||||
|
|
||||||
void apply();
|
|
||||||
void cancel();
|
|
||||||
|
|
||||||
signals:
|
|
||||||
void updateCocoDir();
|
|
||||||
|
|
||||||
public slots:
|
|
||||||
void setVisible(bool visible) override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
void onCocoPathChanged();
|
|
||||||
|
|
||||||
Utils::FilePath widgetCocoDir() const;
|
|
||||||
bool verifyCocoDirectory(const Utils::FilePath &cocoDir);
|
|
||||||
|
|
||||||
Utils::FilePathAspect m_cocoPathAspect;
|
|
||||||
Utils::TextDisplay m_messageLabel;
|
|
||||||
|
|
||||||
CocoInstallation m_coco;
|
|
||||||
Utils::FilePath m_previousCocoDir;
|
|
||||||
};
|
|
||||||
|
|
||||||
class GlobalSettingsPage : public Core::IOptionsPage
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
static GlobalSettingsPage &instance();
|
|
||||||
|
|
||||||
GlobalSettingsWidget *widget() override;
|
|
||||||
void apply() override;
|
|
||||||
void cancel() override;
|
|
||||||
void finish() override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
GlobalSettingsPage();
|
|
||||||
|
|
||||||
QPointer<GlobalSettingsWidget> m_widget;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace Coco::Internal
|
|
Reference in New Issue
Block a user