forked from qt-creator/qt-creator
Macro: Inline SaveDialog
Not worth the file pair. Also modernize MacroManager a bit. Change-Id: I88f6add3147390e3900beebacc4a3f5255eac7ea Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -14,6 +14,5 @@ add_qtc_plugin(Macros
|
||||
macrosplugin.cpp macrosplugin.h
|
||||
macrotextfind.cpp macrotextfind.h
|
||||
macrostr.h
|
||||
savedialog.cpp savedialog.h
|
||||
texteditormacrohandler.cpp texteditormacrohandler.h
|
||||
)
|
||||
|
||||
@@ -10,32 +10,34 @@
|
||||
#include "macroevent.h"
|
||||
#include "macrosconstants.h"
|
||||
#include "macrostr.h"
|
||||
#include "savedialog.h"
|
||||
#include "texteditormacrohandler.h"
|
||||
|
||||
#include <coreplugin/actionmanager/actioncontainer.h>
|
||||
#include <coreplugin/actionmanager/actionmanager.h>
|
||||
#include <coreplugin/actionmanager/command.h>
|
||||
#include <coreplugin/coreconstants.h>
|
||||
#include <coreplugin/editormanager/editormanager.h>
|
||||
#include <coreplugin/editormanager/ieditor.h>
|
||||
#include <coreplugin/icontext.h>
|
||||
#include <coreplugin/icore.h>
|
||||
|
||||
#include <texteditor/texteditorconstants.h>
|
||||
|
||||
#include <coreplugin/coreconstants.h>
|
||||
#include <coreplugin/actionmanager/actionmanager.h>
|
||||
#include <coreplugin/actionmanager/actioncontainer.h>
|
||||
#include <coreplugin/actionmanager/command.h>
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/icontext.h>
|
||||
#include <coreplugin/editormanager/editormanager.h>
|
||||
#include <coreplugin/editormanager/ieditor.h>
|
||||
#include <utils/layoutbuilder.h>
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
#include <QAction>
|
||||
#include <QDialogButtonBox>
|
||||
#include <QDir>
|
||||
#include <QFile>
|
||||
#include <QFileInfo>
|
||||
#include <QList>
|
||||
|
||||
#include <QAction>
|
||||
#include <QFileDialog>
|
||||
#include <QFileInfo>
|
||||
#include <QLineEdit>
|
||||
#include <QList>
|
||||
#include <QMessageBox>
|
||||
#include <QRegularExpressionValidator>
|
||||
|
||||
namespace Macros {
|
||||
namespace Internal {
|
||||
namespace Macros::Internal {
|
||||
|
||||
/*!
|
||||
\namespace Macros
|
||||
@@ -202,9 +204,47 @@ bool MacroManagerPrivate::executeMacro(Macro *macro)
|
||||
return !error;
|
||||
}
|
||||
|
||||
class SaveDialog : public QDialog
|
||||
{
|
||||
public:
|
||||
SaveDialog()
|
||||
: QDialog(Core::ICore::dialogParent())
|
||||
{
|
||||
resize(219, 91);
|
||||
setWindowTitle(Tr::tr("Save Macro"));
|
||||
|
||||
m_name = new QLineEdit;
|
||||
m_name->setValidator(new QRegularExpressionValidator(QRegularExpression("\\w*"), this));
|
||||
|
||||
m_description = new QLineEdit;
|
||||
|
||||
auto buttonBox = new QDialogButtonBox;
|
||||
buttonBox->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::Save);
|
||||
|
||||
using namespace Layouting;
|
||||
|
||||
Form {
|
||||
Tr::tr("Name:"), m_name, br,
|
||||
Tr::tr("Description:"), m_description, br,
|
||||
buttonBox
|
||||
}.attachTo(this);
|
||||
|
||||
connect(buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept);
|
||||
connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject);
|
||||
}
|
||||
|
||||
QString name() const { return m_name->text(); }
|
||||
|
||||
QString description() const { return m_description->text(); }
|
||||
|
||||
private:
|
||||
QLineEdit *m_name;
|
||||
QLineEdit *m_description;
|
||||
};
|
||||
|
||||
void MacroManagerPrivate::showSaveDialog()
|
||||
{
|
||||
SaveDialog dialog(Core::ICore::dialogParent());
|
||||
SaveDialog dialog;
|
||||
if (dialog.exec()) {
|
||||
if (dialog.name().isEmpty())
|
||||
return;
|
||||
@@ -376,5 +416,4 @@ QString MacroManager::macrosDirectory()
|
||||
return QString();
|
||||
}
|
||||
|
||||
} // Internal
|
||||
} // Macros
|
||||
} // Macros::Internal
|
||||
|
||||
@@ -6,20 +6,17 @@
|
||||
#include <QObject>
|
||||
#include <QMap>
|
||||
|
||||
namespace Macros {
|
||||
namespace Internal {
|
||||
namespace Macros::Internal {
|
||||
|
||||
class IMacroHandler;
|
||||
class Macro;
|
||||
class MacroOptionsWidget;
|
||||
|
||||
class MacroManager : public QObject
|
||||
class MacroManager final : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
MacroManager();
|
||||
~MacroManager() override;
|
||||
~MacroManager() final;
|
||||
|
||||
static MacroManager *instance();
|
||||
|
||||
@@ -35,15 +32,13 @@ public:
|
||||
bool executeMacro(const QString &name);
|
||||
void endMacro();
|
||||
|
||||
protected:
|
||||
private:
|
||||
friend class Internal::MacroOptionsWidget;
|
||||
|
||||
void deleteMacro(const QString &name);
|
||||
void changeMacro(const QString &name, const QString &description);
|
||||
|
||||
private:
|
||||
class MacroManagerPrivate *d;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace Macros
|
||||
} // namespace Macros::Internal
|
||||
|
||||
@@ -34,8 +34,6 @@ QtcPlugin {
|
||||
"macrostr.h",
|
||||
"macrotextfind.cpp",
|
||||
"macrotextfind.h",
|
||||
"savedialog.cpp",
|
||||
"savedialog.h",
|
||||
"texteditormacrohandler.cpp",
|
||||
"texteditormacrohandler.h",
|
||||
]
|
||||
|
||||
@@ -1,55 +0,0 @@
|
||||
// Copyright (C) 2016 Nicolas Arnaud-Cormos
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include "savedialog.h"
|
||||
|
||||
#include "macrostr.h"
|
||||
|
||||
#include <utils/layoutbuilder.h>
|
||||
|
||||
#include <QCheckBox>
|
||||
#include <QDialogButtonBox>
|
||||
#include <QLineEdit>
|
||||
#include <QRegularExpressionValidator>
|
||||
|
||||
namespace Macros::Internal {
|
||||
|
||||
SaveDialog::SaveDialog(QWidget *parent) :
|
||||
QDialog(parent)
|
||||
{
|
||||
resize(219, 91);
|
||||
setWindowTitle(Tr::tr("Save Macro"));
|
||||
|
||||
m_name = new QLineEdit;
|
||||
m_name->setValidator(new QRegularExpressionValidator(QRegularExpression(QLatin1String("\\w*")), this));
|
||||
|
||||
m_description = new QLineEdit;
|
||||
|
||||
auto buttonBox = new QDialogButtonBox;
|
||||
buttonBox->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::Save);
|
||||
|
||||
using namespace Layouting;
|
||||
|
||||
Form {
|
||||
Tr::tr("Name:"), m_name, br,
|
||||
Tr::tr("Description:"), m_description, br,
|
||||
buttonBox
|
||||
}.attachTo(this);
|
||||
|
||||
connect(buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept);
|
||||
connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject);
|
||||
}
|
||||
|
||||
SaveDialog::~SaveDialog() = default;
|
||||
|
||||
QString SaveDialog::name() const
|
||||
{
|
||||
return m_name->text();
|
||||
}
|
||||
|
||||
QString SaveDialog::description() const
|
||||
{
|
||||
return m_description->text();
|
||||
}
|
||||
|
||||
} // Macros::Internal
|
||||
@@ -1,30 +0,0 @@
|
||||
// Copyright (C) 2016 Nicolas Arnaud-Cormos
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QLineEdit;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace Macros::Internal {
|
||||
|
||||
class SaveDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit SaveDialog(QWidget *parent = nullptr);
|
||||
~SaveDialog() override;
|
||||
|
||||
QString name() const;
|
||||
QString description() const;
|
||||
|
||||
private:
|
||||
QLineEdit *m_name;
|
||||
QLineEdit *m_description;
|
||||
};
|
||||
|
||||
} // Macros::Internal
|
||||
Reference in New Issue
Block a user