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,7 +92,8 @@ bool FindToolWindow::event(QEvent *event) ...@@ -92,7 +92,8 @@ bool FindToolWindow::event(QEvent *event)
if ((ke->key() == Qt::Key_Return || ke->key() == Qt::Key_Enter) if ((ke->key() == Qt::Key_Return || ke->key() == Qt::Key_Enter)
&& (ke->modifiers() == Qt::NoModifier || ke->modifiers() == Qt::KeypadModifier)) { && (ke->modifiers() == Qt::NoModifier || ke->modifiers() == Qt::KeypadModifier)) {
ke->accept(); ke->accept();
search(); if (m_ui.searchButton->isEnabled())
search();
return true; return true;
} }
} }
...@@ -115,7 +116,7 @@ bool FindToolWindow::eventFilter(QObject *obj, QEvent *event) ...@@ -115,7 +116,7 @@ bool FindToolWindow::eventFilter(QObject *obj, QEvent *event)
void FindToolWindow::updateButtonStates() void FindToolWindow::updateButtonStates()
{ {
bool filterEnabled = m_currentFilter && m_currentFilter->isEnabled(); 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.searchButton->setEnabled(enabled);
m_ui.replaceButton->setEnabled(m_currentFilter m_ui.replaceButton->setEnabled(m_currentFilter
&& m_currentFilter->isReplaceSupported() && enabled); && m_currentFilter->isReplaceSupported() && enabled);
......
...@@ -48,6 +48,7 @@ public: ...@@ -48,6 +48,7 @@ public:
virtual QString displayName() const = 0; virtual QString displayName() const = 0;
/// ///
virtual bool isEnabled() const = 0; virtual bool isEnabled() const = 0;
virtual bool isValid() const { return true; }
virtual QKeySequence defaultShortcut() const; virtual QKeySequence defaultShortcut() const;
virtual bool isReplaceSupported() const { return false; } virtual bool isReplaceSupported() const { return false; }
virtual FindFlags supportedFindFlags() const; virtual FindFlags supportedFindFlags() const;
......
...@@ -62,6 +62,11 @@ FindInFiles::~FindInFiles() ...@@ -62,6 +62,11 @@ FindInFiles::~FindInFiles()
{ {
} }
bool FindInFiles::isValid() const
{
return m_directory->isValid();
}
QString FindInFiles::id() const QString FindInFiles::id() const
{ {
return QLatin1String("Files on Disk"); return QLatin1String("Files on Disk");
......
...@@ -52,6 +52,7 @@ public: ...@@ -52,6 +52,7 @@ public:
QWidget *createConfigWidget(); QWidget *createConfigWidget();
void writeSettings(QSettings *settings); void writeSettings(QSettings *settings);
void readSettings(QSettings *settings); void readSettings(QSettings *settings);
bool isValid() const;
void setDirectory(const Utils::FileName &directory); void setDirectory(const Utils::FileName &directory);
static void findOnFileSystem(const QString &path); 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