Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: show info rggrip not found #211

Merged
merged 1 commit into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 41 additions & 1 deletion src/gui/findinfilespanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Contact KDAB at <[email protected]> for commercial licensing options.
#include <QHBoxLayout>
#include <QHeaderView>
#include <QLineEdit>
#include <QPainter>
#include <QToolButton>
#include <QTreeWidget>
#include <QTreeWidgetItem>
Expand All @@ -24,10 +25,23 @@ namespace Gui {

enum { LineRole = Qt::UserRole + 1, ColumnRole };

class FindInFilesTreeWidget : public QTreeWidget
{
Q_OBJECT
public:
explicit FindInFilesTreeWidget(QWidget *parent = nullptr);

protected:
void paintEvent(QPaintEvent *) override;

private:
const bool m_findInFilesAvailable;
};

FindInFilesPanel::FindInFilesPanel(QWidget *parent)
: QWidget(parent)
, m_toolBar(new QWidget(this))
, m_resultsDisplay(new QTreeWidget(this))
, m_resultsDisplay(new FindInFilesTreeWidget(this))
{
setWindowTitle(tr("Find in Files"));
setObjectName("FindInFilesPanel");
Expand All @@ -45,6 +59,8 @@ FindInFilesPanel::FindInFilesPanel(QWidget *parent)
connect(m_resultsDisplay, &QTreeWidget::itemActivated, this, [this](QTreeWidgetItem *item, int) {
openFileAtItem(item);
});
const bool available = Core::Project::instance()->isFindInFilesAvailable();
m_searchInput->setEnabled(available);
}

QWidget *FindInFilesPanel::toolBar() const
Expand Down Expand Up @@ -146,4 +162,28 @@ void FindInFilesPanel::openFileAtItem(QTreeWidgetItem *item)
}
}

FindInFilesTreeWidget::FindInFilesTreeWidget(QWidget *parent)
: QTreeWidget(parent)
, m_findInFilesAvailable(Core::Project::instance()->isFindInFilesAvailable())
{
}

void FindInFilesTreeWidget::paintEvent(QPaintEvent *event)
{
if (!m_findInFilesAvailable) {
QPainter p(viewport());

QFont font = p.font();
font.setItalic(true);
p.setFont(font);

p.drawText(QRect(0, 0, width(), height()), Qt::AlignCenter,
tr("Ripgrep (rg) executable not found.\nPlease ensure that ripgrep is installed and its location is "
"included in the PATH environment variable."));
} else {
QTreeWidget::paintEvent(event);
}
}

} // namespace Gui
#include "findinfilespanel.moc"
5 changes: 2 additions & 3 deletions src/gui/findinfilespanel.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@ Contact KDAB at <[email protected]> for commercial licensing options.

class QLineEdit;
class QToolButton;
class QTreeWidget;
class QTreeWidgetItem;

#include <QWidget>
#include <QTreeWidget>

namespace Gui {

Expand All @@ -35,7 +34,7 @@ class FindInFilesPanel : public QWidget
void setupToolBar();

QWidget *const m_toolBar;
QTreeWidget *m_resultsDisplay;
QTreeWidget *m_resultsDisplay = nullptr;
QLineEdit *m_searchInput;
};

Expand Down
Loading