forked from qt-creator/qt-creator
Make adding variable support to textcontrol easier.
Add convenience method in variable chooser and move magic constant to the place where it's used. Change-Id: Ie93acb98e13efcacb77d1a478df927a11b16926b Reviewed-by: Daniel Teske <daniel.teske@digia.com>
This commit is contained in:
@@ -221,8 +221,6 @@ const char SETTINGS_DEFAULTTEXTENCODING[] = "General/DefaultFileEncoding";
|
||||
|
||||
const char ALL_FILES_FILTER[] = QT_TRANSLATE_NOOP("Core", "All Files (*)");
|
||||
|
||||
const char VARIABLE_SUPPORT_PROPERTY[] = "QtCreator.VariableSupport";
|
||||
|
||||
const char TR_CLEAR_MENU[] = QT_TRANSLATE_NOOP("Core", "Clear Menu");
|
||||
|
||||
const char DEFAULT_BUILD_DIRECTORY[] = "../build-%{CurrentProject:Name}-%{CurrentKit:FileSystemName}-%{CurrentBuild:Name}";
|
||||
|
||||
@@ -409,10 +409,10 @@ ExternalToolConfig::ExternalToolConfig(QWidget *parent) :
|
||||
connect(ui->toolTree->selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)),
|
||||
this, SLOT(handleCurrentChanged(QModelIndex,QModelIndex)));
|
||||
|
||||
ui->executable->lineEdit()->setProperty(Constants::VARIABLE_SUPPORT_PROPERTY, true);
|
||||
ui->arguments->setProperty(Constants::VARIABLE_SUPPORT_PROPERTY, true);
|
||||
ui->workingDirectory->lineEdit()->setProperty(Constants::VARIABLE_SUPPORT_PROPERTY, true);
|
||||
ui->inputText->setProperty(Constants::VARIABLE_SUPPORT_PROPERTY, true);
|
||||
Core::VariableChooser::addVariableSupport(ui->executable->lineEdit());
|
||||
Core::VariableChooser::addVariableSupport(ui->arguments);
|
||||
Core::VariableChooser::addVariableSupport(ui->workingDirectory->lineEdit());
|
||||
Core::VariableChooser::addVariableSupport(ui->inputText);
|
||||
|
||||
connect(ui->description, SIGNAL(editingFinished()), this, SLOT(updateCurrentItem()));
|
||||
connect(ui->executable, SIGNAL(editingFinished()), this, SLOT(updateCurrentItem()));
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
#include "coreconstants.h"
|
||||
|
||||
#include <utils/fancylineedit.h> // IconButton
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
#include <QTimer>
|
||||
#include <QLineEdit>
|
||||
@@ -42,6 +43,8 @@
|
||||
|
||||
using namespace Core;
|
||||
|
||||
const char VariableChooser::kVariableSupportProperty[] = "QtCreator.VariableSupport";
|
||||
|
||||
VariableChooser::VariableChooser(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
ui(new Internal::Ui::VariableChooser),
|
||||
@@ -76,6 +79,12 @@ VariableChooser::~VariableChooser()
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void VariableChooser::addVariableSupport(QWidget *textcontrol)
|
||||
{
|
||||
QTC_ASSERT(textcontrol, return);
|
||||
textcontrol->setProperty(kVariableSupportProperty, true);
|
||||
}
|
||||
|
||||
void VariableChooser::updateDescription(const QString &variable)
|
||||
{
|
||||
if (variable.isNull())
|
||||
@@ -109,7 +118,7 @@ void VariableChooser::updateCurrentEditor(QWidget *old, QWidget *widget)
|
||||
m_lineEdit = 0;
|
||||
m_textEdit = 0;
|
||||
m_plainTextEdit = 0;
|
||||
QVariant variablesSupportProperty = widget->property(Constants::VARIABLE_SUPPORT_PROPERTY);
|
||||
QVariant variablesSupportProperty = widget->property(kVariableSupportProperty);
|
||||
bool supportsVariables = (variablesSupportProperty.isValid()
|
||||
? variablesSupportProperty.toBool() : false);
|
||||
if (QLineEdit *lineEdit = qobject_cast<QLineEdit *>(widget))
|
||||
|
||||
@@ -56,6 +56,9 @@ public:
|
||||
explicit VariableChooser(QWidget *parent = 0);
|
||||
~VariableChooser();
|
||||
|
||||
static const char kVariableSupportProperty[];
|
||||
static void addVariableSupport(QWidget *textcontrol);
|
||||
|
||||
protected:
|
||||
void keyPressEvent(QKeyEvent *ke);
|
||||
bool eventFilter(QObject *, QEvent *event);
|
||||
|
||||
@@ -47,12 +47,11 @@ ProjectExplorerSettingsWidget::ProjectExplorerSettingsWidget(QWidget *parent) :
|
||||
QWidget(parent)
|
||||
{
|
||||
m_ui.setupUi(this);
|
||||
m_ui.buildDirectoryEdit->setProperty(Core::Constants::VARIABLE_SUPPORT_PROPERTY, true);
|
||||
new Core::VariableChooser(this);
|
||||
Core::VariableChooser::addVariableSupport(m_ui.buildDirectoryEdit);
|
||||
setJomVisible(Utils::HostOsInfo::isWindowsHost());
|
||||
m_ui.directoryButtonGroup->setId(m_ui.currentDirectoryRadioButton, UseCurrentDirectory);
|
||||
m_ui.directoryButtonGroup->setId(m_ui.directoryRadioButton, UseProjectDirectory);
|
||||
m_ui.buildDirectoryEdit->setProperty(Core::Constants::VARIABLE_SUPPORT_PROPERTY, true);
|
||||
|
||||
connect(m_ui.directoryButtonGroup, SIGNAL(buttonClicked(int)),
|
||||
this, SLOT(slotDirectoryButtonGroupChanged()));
|
||||
|
||||
Reference in New Issue
Block a user