Commit d01627bb authored by Orgad Shaneh's avatar Orgad Shaneh Committed by Orgad Shaneh
Browse files

TextEditor: Disable Search & Replace buttons when folder doesn't exist



In case of searching in scope: "Files on File System" when specified
directory does not exist, "Search" and "Search & Replace" buttons
should be disabled.

Task-number: QTCREATORBUG-5959
Change-Id: I1905cbea08aa07d72b96e9ad893ef3928d633c4f
Reviewed-by: default avatarRobert Loehning <robert.loehning@theqtcompany.com>
parent 5b792834
......@@ -92,6 +92,7 @@ bool FindToolWindow::event(QEvent *event)
if ((ke->key() == Qt::Key_Return || ke->key() == Qt::Key_Enter)
&& (ke->modifiers() == Qt::NoModifier || ke->modifiers() == Qt::KeypadModifier)) {
ke->accept();
if (m_ui.searchButton->isEnabled())
search();
return true;
}
......@@ -115,7 +116,7 @@ bool FindToolWindow::eventFilter(QObject *obj, QEvent *event)
void FindToolWindow::updateButtonStates()
{
bool filterEnabled = m_currentFilter && m_currentFilter->isEnabled();
bool enabled = !m_ui.searchTerm->text().isEmpty() && filterEnabled;
bool enabled = !m_ui.searchTerm->text().isEmpty() && filterEnabled && m_currentFilter->isValid();
m_ui.searchButton->setEnabled(enabled);
m_ui.replaceButton->setEnabled(m_currentFilter
&& m_currentFilter->isReplaceSupported() && enabled);
......
......@@ -48,6 +48,7 @@ public:
virtual QString displayName() const = 0;
///
virtual bool isEnabled() const = 0;
virtual bool isValid() const { return true; }
virtual QKeySequence defaultShortcut() const;
virtual bool isReplaceSupported() const { return false; }
virtual FindFlags supportedFindFlags() const;
......
......@@ -62,6 +62,11 @@ FindInFiles::~FindInFiles()
{
}
bool FindInFiles::isValid() const
{
return m_directory->isValid();
}
QString FindInFiles::id() const
{
return QLatin1String("Files on Disk");
......
......@@ -52,6 +52,7 @@ public:
QWidget *createConfigWidget();
void writeSettings(QSettings *settings);
void readSettings(QSettings *settings);
bool isValid() const;
void setDirectory(const Utils::FileName &directory);
static void findOnFileSystem(const QString &path);
......
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