Commit a2df8cb0 authored by Eike Ziller's avatar Eike Ziller
Browse files

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: default avatarDaniel Teske <daniel.teske@digia.com>
parent 02842c14
...@@ -221,8 +221,6 @@ const char SETTINGS_DEFAULTTEXTENCODING[] = "General/DefaultFileEncoding"; ...@@ -221,8 +221,6 @@ const char SETTINGS_DEFAULTTEXTENCODING[] = "General/DefaultFileEncoding";
const char ALL_FILES_FILTER[] = QT_TRANSLATE_NOOP("Core", "All Files (*)"); 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 TR_CLEAR_MENU[] = QT_TRANSLATE_NOOP("Core", "Clear Menu");
const char DEFAULT_BUILD_DIRECTORY[] = "../build-%{CurrentProject:Name}-%{CurrentKit:FileSystemName}-%{CurrentBuild:Name}"; const char DEFAULT_BUILD_DIRECTORY[] = "../build-%{CurrentProject:Name}-%{CurrentKit:FileSystemName}-%{CurrentBuild:Name}";
......
...@@ -409,10 +409,10 @@ ExternalToolConfig::ExternalToolConfig(QWidget *parent) : ...@@ -409,10 +409,10 @@ ExternalToolConfig::ExternalToolConfig(QWidget *parent) :
connect(ui->toolTree->selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)), connect(ui->toolTree->selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)),
this, SLOT(handleCurrentChanged(QModelIndex,QModelIndex))); this, SLOT(handleCurrentChanged(QModelIndex,QModelIndex)));
ui->executable->lineEdit()->setProperty(Constants::VARIABLE_SUPPORT_PROPERTY, true); Core::VariableChooser::addVariableSupport(ui->executable->lineEdit());
ui->arguments->setProperty(Constants::VARIABLE_SUPPORT_PROPERTY, true); Core::VariableChooser::addVariableSupport(ui->arguments);
ui->workingDirectory->lineEdit()->setProperty(Constants::VARIABLE_SUPPORT_PROPERTY, true); Core::VariableChooser::addVariableSupport(ui->workingDirectory->lineEdit());
ui->inputText->setProperty(Constants::VARIABLE_SUPPORT_PROPERTY, true); Core::VariableChooser::addVariableSupport(ui->inputText);
connect(ui->description, SIGNAL(editingFinished()), this, SLOT(updateCurrentItem())); connect(ui->description, SIGNAL(editingFinished()), this, SLOT(updateCurrentItem()));
connect(ui->executable, SIGNAL(editingFinished()), this, SLOT(updateCurrentItem())); connect(ui->executable, SIGNAL(editingFinished()), this, SLOT(updateCurrentItem()));
......
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#include "coreconstants.h" #include "coreconstants.h"
#include <utils/fancylineedit.h> // IconButton #include <utils/fancylineedit.h> // IconButton
#include <utils/qtcassert.h>
#include <QTimer> #include <QTimer>
#include <QLineEdit> #include <QLineEdit>
...@@ -42,6 +43,8 @@ ...@@ -42,6 +43,8 @@
using namespace Core; using namespace Core;
const char VariableChooser::kVariableSupportProperty[] = "QtCreator.VariableSupport";
VariableChooser::VariableChooser(QWidget *parent) : VariableChooser::VariableChooser(QWidget *parent) :
QWidget(parent), QWidget(parent),
ui(new Internal::Ui::VariableChooser), ui(new Internal::Ui::VariableChooser),
...@@ -76,6 +79,12 @@ VariableChooser::~VariableChooser() ...@@ -76,6 +79,12 @@ VariableChooser::~VariableChooser()
delete ui; delete ui;
} }
void VariableChooser::addVariableSupport(QWidget *textcontrol)
{
QTC_ASSERT(textcontrol, return);
textcontrol->setProperty(kVariableSupportProperty, true);
}
void VariableChooser::updateDescription(const QString &variable) void VariableChooser::updateDescription(const QString &variable)
{ {
if (variable.isNull()) if (variable.isNull())
...@@ -109,7 +118,7 @@ void VariableChooser::updateCurrentEditor(QWidget *old, QWidget *widget) ...@@ -109,7 +118,7 @@ void VariableChooser::updateCurrentEditor(QWidget *old, QWidget *widget)
m_lineEdit = 0; m_lineEdit = 0;
m_textEdit = 0; m_textEdit = 0;
m_plainTextEdit = 0; m_plainTextEdit = 0;
QVariant variablesSupportProperty = widget->property(Constants::VARIABLE_SUPPORT_PROPERTY); QVariant variablesSupportProperty = widget->property(kVariableSupportProperty);
bool supportsVariables = (variablesSupportProperty.isValid() bool supportsVariables = (variablesSupportProperty.isValid()
? variablesSupportProperty.toBool() : false); ? variablesSupportProperty.toBool() : false);
if (QLineEdit *lineEdit = qobject_cast<QLineEdit *>(widget)) if (QLineEdit *lineEdit = qobject_cast<QLineEdit *>(widget))
......
...@@ -56,6 +56,9 @@ public: ...@@ -56,6 +56,9 @@ public:
explicit VariableChooser(QWidget *parent = 0); explicit VariableChooser(QWidget *parent = 0);
~VariableChooser(); ~VariableChooser();
static const char kVariableSupportProperty[];
static void addVariableSupport(QWidget *textcontrol);
protected: protected:
void keyPressEvent(QKeyEvent *ke); void keyPressEvent(QKeyEvent *ke);
bool eventFilter(QObject *, QEvent *event); bool eventFilter(QObject *, QEvent *event);
......
...@@ -47,12 +47,11 @@ ProjectExplorerSettingsWidget::ProjectExplorerSettingsWidget(QWidget *parent) : ...@@ -47,12 +47,11 @@ ProjectExplorerSettingsWidget::ProjectExplorerSettingsWidget(QWidget *parent) :
QWidget(parent) QWidget(parent)
{ {
m_ui.setupUi(this); m_ui.setupUi(this);
m_ui.buildDirectoryEdit->setProperty(Core::Constants::VARIABLE_SUPPORT_PROPERTY, true);
new Core::VariableChooser(this); new Core::VariableChooser(this);
Core::VariableChooser::addVariableSupport(m_ui.buildDirectoryEdit);
setJomVisible(Utils::HostOsInfo::isWindowsHost()); setJomVisible(Utils::HostOsInfo::isWindowsHost());
m_ui.directoryButtonGroup->setId(m_ui.currentDirectoryRadioButton, UseCurrentDirectory); m_ui.directoryButtonGroup->setId(m_ui.currentDirectoryRadioButton, UseCurrentDirectory);
m_ui.directoryButtonGroup->setId(m_ui.directoryRadioButton, UseProjectDirectory); 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)), connect(m_ui.directoryButtonGroup, SIGNAL(buttonClicked(int)),
this, SLOT(slotDirectoryButtonGroupChanged())); this, SLOT(slotDirectoryButtonGroupChanged()));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment