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:
@@ -196,9 +196,6 @@ public:
|
||||
QList<QAbstractButton *> m_buttons;
|
||||
MacroExpander *m_macroExpander = globalMacroExpander();
|
||||
std::function<void()> m_openTerminal;
|
||||
|
||||
bool m_isReadOnly = false;
|
||||
bool m_isFileDialogOnly = false;
|
||||
};
|
||||
|
||||
PathChooserPrivate::PathChooserPrivate()
|
||||
@@ -245,10 +242,9 @@ PathChooser::PathChooser(QWidget *parent) :
|
||||
{
|
||||
d->m_hLayout->setContentsMargins(0, 0, 0, 0);
|
||||
|
||||
setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
d->m_lineEdit->setContextMenuPolicy(Qt::NoContextMenu);
|
||||
d->m_lineEdit->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
|
||||
connect(this,
|
||||
connect(d->m_lineEdit,
|
||||
&FancyLineEdit::customContextMenuRequested,
|
||||
this,
|
||||
&PathChooser::contextMenuRequested);
|
||||
@@ -294,7 +290,6 @@ void PathChooser::insertButton(int index, const QString &text, QObject *context,
|
||||
connect(button, &QAbstractButton::clicked, context, callback);
|
||||
d->m_hLayout->insertWidget(index + 1/*line edit*/, button);
|
||||
d->m_buttons.insert(index, button);
|
||||
updateReadOnlyStateOfSubwidgets();
|
||||
}
|
||||
|
||||
QString PathChooser::browseButtonLabel()
|
||||
@@ -371,24 +366,15 @@ void PathChooser::setFilePath(const FilePath &fn)
|
||||
|
||||
bool PathChooser::isReadOnly() const
|
||||
{
|
||||
return d->m_isReadOnly;
|
||||
return d->m_lineEdit->isReadOnly();
|
||||
}
|
||||
|
||||
void PathChooser::setReadOnly(bool b)
|
||||
{
|
||||
d->m_isReadOnly = b;
|
||||
updateReadOnlyStateOfSubwidgets();
|
||||
}
|
||||
|
||||
bool PathChooser::isFileDialogOnly() const
|
||||
{
|
||||
return d->m_isFileDialogOnly;
|
||||
}
|
||||
|
||||
void PathChooser::setFileDialogOnly(bool b)
|
||||
{
|
||||
d->m_isFileDialogOnly = b;
|
||||
updateReadOnlyStateOfSubwidgets();
|
||||
d->m_lineEdit->setReadOnly(b);
|
||||
const auto buttons = d->m_buttons;
|
||||
for (QAbstractButton *button : buttons)
|
||||
button->setEnabled(!b);
|
||||
}
|
||||
|
||||
void PathChooser::slotBrowse()
|
||||
@@ -478,29 +464,14 @@ void PathChooser::slotBrowse()
|
||||
|
||||
void PathChooser::contextMenuRequested(const QPoint &pos)
|
||||
{
|
||||
if (!d->m_lineEdit->rect().contains(pos))
|
||||
return;
|
||||
QMenu *menu = d->m_lineEdit->createStandardContextMenu();
|
||||
if (!menu)
|
||||
menu = new QMenu;
|
||||
if (s_aboutToShowContextMenuHandler)
|
||||
s_aboutToShowContextMenuHandler(this, menu);
|
||||
if (!menu->actions().isEmpty()) {
|
||||
if (QMenu *menu = d->m_lineEdit->createStandardContextMenu()) {
|
||||
menu->setAttribute(Qt::WA_DeleteOnClose);
|
||||
menu->popup(mapToGlobal(pos));
|
||||
} else {
|
||||
delete menu;
|
||||
}
|
||||
}
|
||||
|
||||
void PathChooser::updateReadOnlyStateOfSubwidgets()
|
||||
{
|
||||
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);
|
||||
if (s_aboutToShowContextMenuHandler)
|
||||
s_aboutToShowContextMenuHandler(this, menu);
|
||||
|
||||
menu->popup(d->m_lineEdit->mapToGlobal(pos));
|
||||
}
|
||||
}
|
||||
|
||||
bool PathChooser::isValid() const
|
||||
|
||||
Reference in New Issue
Block a user