forked from qt-creator/qt-creator
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: Robert Loehning <robert.loehning@theqtcompany.com>
This commit is contained in:
committed by
Orgad Shaneh
parent
5b792834f5
commit
d01627bb01
@@ -92,7 +92,8 @@ 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();
|
||||
search();
|
||||
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);
|
||||
|
||||
Reference in New Issue
Block a user