forked from qt-creator/qt-creator
CMakePM: Allow copy / editing of build directory
This reverts 69b0a2cafc
The build directory is preset and by having the ability to edit, you can
easily do a new build by appending a number.
When you have a new build directory a dialog will warn you that you'll
start from scratch. This is enough of a hinderniss to the user to start
typing and get lots of build directories. No need to have it read only.
Fixes: QTCREATORBUG-24451
Change-Id: Id1bc77d0fbcb071608f5ac83ddd6b8af943fdac5
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -958,13 +958,6 @@ void StringAspect::setExpectedKind(const PathChooser::Kind expectedKind)
|
|||||||
d->m_pathChooserDisplay->setExpectedKind(expectedKind);
|
d->m_pathChooserDisplay->setExpectedKind(expectedKind);
|
||||||
}
|
}
|
||||||
|
|
||||||
void StringAspect::setFileDialogOnly(bool requireFileDialog)
|
|
||||||
{
|
|
||||||
d->m_fileDialogOnly = requireFileDialog;
|
|
||||||
if (d->m_pathChooserDisplay)
|
|
||||||
d->m_pathChooserDisplay->setFileDialogOnly(requireFileDialog);
|
|
||||||
}
|
|
||||||
|
|
||||||
void StringAspect::setEnvironment(const Environment &env)
|
void StringAspect::setEnvironment(const Environment &env)
|
||||||
{
|
{
|
||||||
d->m_environment = env;
|
d->m_environment = env;
|
||||||
@@ -1060,7 +1053,6 @@ void StringAspect::addToLayout(LayoutBuilder &builder)
|
|||||||
d->m_pathChooserDisplay->setHistoryCompleter(d->m_historyCompleterKey);
|
d->m_pathChooserDisplay->setHistoryCompleter(d->m_historyCompleterKey);
|
||||||
d->m_pathChooserDisplay->setEnvironment(d->m_environment);
|
d->m_pathChooserDisplay->setEnvironment(d->m_environment);
|
||||||
d->m_pathChooserDisplay->setBaseDirectory(d->m_baseFileName);
|
d->m_pathChooserDisplay->setBaseDirectory(d->m_baseFileName);
|
||||||
d->m_pathChooserDisplay->setFileDialogOnly(d->m_fileDialogOnly);
|
|
||||||
d->m_pathChooserDisplay->setOpenTerminalHandler(d->m_openTerminal);
|
d->m_pathChooserDisplay->setOpenTerminalHandler(d->m_openTerminal);
|
||||||
d->m_pathChooserDisplay->setFilePath(FilePath::fromString(displayedString));
|
d->m_pathChooserDisplay->setFilePath(FilePath::fromString(displayedString));
|
||||||
d->updateWidgetFromCheckStatus(this, d->m_pathChooserDisplay.data());
|
d->updateWidgetFromCheckStatus(this, d->m_pathChooserDisplay.data());
|
||||||
|
@@ -298,7 +298,6 @@ public:
|
|||||||
void setPlaceHolderText(const QString &placeHolderText);
|
void setPlaceHolderText(const QString &placeHolderText);
|
||||||
void setHistoryCompleter(const QString &historyCompleterKey);
|
void setHistoryCompleter(const QString &historyCompleterKey);
|
||||||
void setExpectedKind(const Utils::PathChooser::Kind expectedKind);
|
void setExpectedKind(const Utils::PathChooser::Kind expectedKind);
|
||||||
void setFileDialogOnly(bool requireFileDialog);
|
|
||||||
void setEnvironment(const Utils::Environment &env);
|
void setEnvironment(const Utils::Environment &env);
|
||||||
void setBaseFileName(const Utils::FilePath &baseFileName);
|
void setBaseFileName(const Utils::FilePath &baseFileName);
|
||||||
void setUndoRedoEnabled(bool readOnly);
|
void setUndoRedoEnabled(bool readOnly);
|
||||||
|
@@ -196,9 +196,6 @@ public:
|
|||||||
QList<QAbstractButton *> m_buttons;
|
QList<QAbstractButton *> m_buttons;
|
||||||
MacroExpander *m_macroExpander = globalMacroExpander();
|
MacroExpander *m_macroExpander = globalMacroExpander();
|
||||||
std::function<void()> m_openTerminal;
|
std::function<void()> m_openTerminal;
|
||||||
|
|
||||||
bool m_isReadOnly = false;
|
|
||||||
bool m_isFileDialogOnly = false;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
PathChooserPrivate::PathChooserPrivate()
|
PathChooserPrivate::PathChooserPrivate()
|
||||||
@@ -245,10 +242,9 @@ PathChooser::PathChooser(QWidget *parent) :
|
|||||||
{
|
{
|
||||||
d->m_hLayout->setContentsMargins(0, 0, 0, 0);
|
d->m_hLayout->setContentsMargins(0, 0, 0, 0);
|
||||||
|
|
||||||
setContextMenuPolicy(Qt::CustomContextMenu);
|
d->m_lineEdit->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||||
d->m_lineEdit->setContextMenuPolicy(Qt::NoContextMenu);
|
|
||||||
|
|
||||||
connect(this,
|
connect(d->m_lineEdit,
|
||||||
&FancyLineEdit::customContextMenuRequested,
|
&FancyLineEdit::customContextMenuRequested,
|
||||||
this,
|
this,
|
||||||
&PathChooser::contextMenuRequested);
|
&PathChooser::contextMenuRequested);
|
||||||
@@ -294,7 +290,6 @@ void PathChooser::insertButton(int index, const QString &text, QObject *context,
|
|||||||
connect(button, &QAbstractButton::clicked, context, callback);
|
connect(button, &QAbstractButton::clicked, context, callback);
|
||||||
d->m_hLayout->insertWidget(index + 1/*line edit*/, button);
|
d->m_hLayout->insertWidget(index + 1/*line edit*/, button);
|
||||||
d->m_buttons.insert(index, button);
|
d->m_buttons.insert(index, button);
|
||||||
updateReadOnlyStateOfSubwidgets();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QString PathChooser::browseButtonLabel()
|
QString PathChooser::browseButtonLabel()
|
||||||
@@ -371,24 +366,15 @@ void PathChooser::setFilePath(const FilePath &fn)
|
|||||||
|
|
||||||
bool PathChooser::isReadOnly() const
|
bool PathChooser::isReadOnly() const
|
||||||
{
|
{
|
||||||
return d->m_isReadOnly;
|
return d->m_lineEdit->isReadOnly();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PathChooser::setReadOnly(bool b)
|
void PathChooser::setReadOnly(bool b)
|
||||||
{
|
{
|
||||||
d->m_isReadOnly = b;
|
d->m_lineEdit->setReadOnly(b);
|
||||||
updateReadOnlyStateOfSubwidgets();
|
const auto buttons = d->m_buttons;
|
||||||
}
|
for (QAbstractButton *button : buttons)
|
||||||
|
button->setEnabled(!b);
|
||||||
bool PathChooser::isFileDialogOnly() const
|
|
||||||
{
|
|
||||||
return d->m_isFileDialogOnly;
|
|
||||||
}
|
|
||||||
|
|
||||||
void PathChooser::setFileDialogOnly(bool b)
|
|
||||||
{
|
|
||||||
d->m_isFileDialogOnly = b;
|
|
||||||
updateReadOnlyStateOfSubwidgets();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PathChooser::slotBrowse()
|
void PathChooser::slotBrowse()
|
||||||
@@ -478,29 +464,14 @@ void PathChooser::slotBrowse()
|
|||||||
|
|
||||||
void PathChooser::contextMenuRequested(const QPoint &pos)
|
void PathChooser::contextMenuRequested(const QPoint &pos)
|
||||||
{
|
{
|
||||||
if (!d->m_lineEdit->rect().contains(pos))
|
if (QMenu *menu = d->m_lineEdit->createStandardContextMenu()) {
|
||||||
return;
|
menu->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
QMenu *menu = d->m_lineEdit->createStandardContextMenu();
|
|
||||||
if (!menu)
|
|
||||||
menu = new QMenu;
|
|
||||||
if (s_aboutToShowContextMenuHandler)
|
if (s_aboutToShowContextMenuHandler)
|
||||||
s_aboutToShowContextMenuHandler(this, menu);
|
s_aboutToShowContextMenuHandler(this, menu);
|
||||||
if (!menu->actions().isEmpty()) {
|
|
||||||
menu->setAttribute(Qt::WA_DeleteOnClose);
|
|
||||||
menu->popup(mapToGlobal(pos));
|
|
||||||
} else {
|
|
||||||
delete menu;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void PathChooser::updateReadOnlyStateOfSubwidgets()
|
menu->popup(d->m_lineEdit->mapToGlobal(pos));
|
||||||
{
|
}
|
||||||
const bool readOnlyLineEdit = d->m_isReadOnly || d->m_isFileDialogOnly;
|
|
||||||
d->m_lineEdit->setEnabled(!readOnlyLineEdit);
|
|
||||||
d->m_lineEdit->setReadOnly(readOnlyLineEdit);
|
|
||||||
setFocusPolicy(d->m_lineEdit->focusPolicy());
|
|
||||||
for (QAbstractButton *button : qAsConst(d->m_buttons))
|
|
||||||
button->setEnabled(!d->m_isReadOnly);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PathChooser::isValid() const
|
bool PathChooser::isValid() const
|
||||||
|
@@ -138,9 +138,6 @@ public:
|
|||||||
bool isReadOnly() const;
|
bool isReadOnly() const;
|
||||||
void setReadOnly(bool b);
|
void setReadOnly(bool b);
|
||||||
|
|
||||||
bool isFileDialogOnly() const;
|
|
||||||
void setFileDialogOnly(bool b);
|
|
||||||
|
|
||||||
void triggerChanged();
|
void triggerChanged();
|
||||||
|
|
||||||
// global handler for adding context menus to ALL pathchooser
|
// global handler for adding context menus to ALL pathchooser
|
||||||
@@ -164,7 +161,6 @@ private:
|
|||||||
QString makeDialogTitle(const QString &title);
|
QString makeDialogTitle(const QString &title);
|
||||||
void slotBrowse();
|
void slotBrowse();
|
||||||
void contextMenuRequested(const QPoint &pos);
|
void contextMenuRequested(const QPoint &pos);
|
||||||
void updateReadOnlyStateOfSubwidgets();
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void validChanged(bool validState);
|
void validChanged(bool validState);
|
||||||
|
@@ -844,9 +844,7 @@ CMakeBuildConfiguration::CMakeBuildConfiguration(Target *target, Id id)
|
|||||||
{
|
{
|
||||||
m_buildSystem = new CMakeBuildSystem(this);
|
m_buildSystem = new CMakeBuildSystem(this);
|
||||||
|
|
||||||
buildDirectoryAspect()->setFileDialogOnly(true);
|
|
||||||
const auto buildDirAspect = aspect<BuildDirectoryAspect>();
|
const auto buildDirAspect = aspect<BuildDirectoryAspect>();
|
||||||
buildDirAspect->setFileDialogOnly(true);
|
|
||||||
buildDirAspect->setValueAcceptor(
|
buildDirAspect->setValueAcceptor(
|
||||||
[](const QString &oldDir, const QString &newDir) -> Utils::optional<QString> {
|
[](const QString &oldDir, const QString &newDir) -> Utils::optional<QString> {
|
||||||
if (oldDir.isEmpty())
|
if (oldDir.isEmpty())
|
||||||
|
Reference in New Issue
Block a user