Adds "Hide Untracked Files" option to DoubleTreeWidget

Merge pull request #591 from pablovacatello/hideUntrackedFiles
This commit is contained in:
Murmele 2023-07-05 09:31:26 +02:00 committed by GitHub
commit 34625fb981
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 4 deletions

View File

@ -309,8 +309,11 @@ Diff Repository::status(const Index &index, Diff::Callbacks *callbacks,
Diff Repository::diffTreeToIndex(const Tree &tree, const Index &index,
bool ignoreWhitespace) const {
git_diff_options opts = GIT_DIFF_OPTIONS_INIT;
opts.flags |= GIT_DIFF_INCLUDE_UNTRACKED | GIT_DIFF_RECURSE_UNTRACKED_DIRS |
GIT_DIFF_INCLUDE_TYPECHANGE;
opts.flags |= GIT_DIFF_INCLUDE_TYPECHANGE;
if (!appConfig().value<bool>("untracked.hide", false))
opts.flags |= GIT_DIFF_INCLUDE_UNTRACKED | GIT_DIFF_RECURSE_UNTRACKED_DIRS;
if (ignoreWhitespace)
opts.flags |= GIT_DIFF_IGNORE_WHITESPACE;
@ -323,8 +326,11 @@ Diff Repository::diffIndexToWorkdir(const Index &index,
Diff::Callbacks *callbacks,
bool ignoreWhitespace) const {
git_diff_options opts = GIT_DIFF_OPTIONS_INIT;
opts.flags |= (GIT_DIFF_INCLUDE_UNTRACKED | GIT_DIFF_RECURSE_UNTRACKED_DIRS |
GIT_DIFF_DISABLE_MMAP | GIT_DIFF_INCLUDE_TYPECHANGE);
opts.flags |= (GIT_DIFF_DISABLE_MMAP | GIT_DIFF_INCLUDE_TYPECHANGE);
if (!appConfig().value<bool>("untracked.hide", false))
opts.flags |= GIT_DIFF_INCLUDE_UNTRACKED | GIT_DIFF_RECURSE_UNTRACKED_DIRS;
if (ignoreWhitespace)
opts.flags |= GIT_DIFF_IGNORE_WHITESPACE;

View File

@ -20,6 +20,7 @@
#include "conf/Settings.h"
#include "DiffView/DiffView.h"
#include "git/Index.h"
#include "git/Config.h"
#include <QVBoxLayout>
#include <QHBoxLayout>
@ -102,8 +103,19 @@ DoubleTreeWidget::DoubleTreeWidget(const git::Repository &repo, QWidget *parent)
checked);
RepoView::parentView(this)->refresh();
});
QAction *hideUntrackedFiles = new QAction(tr("Hide Untracked Files"));
hideUntrackedFiles->setCheckable(true);
hideUntrackedFiles->setChecked(
RepoView::parentView(parent)->repo().appConfig().value<bool>(
"untracked.hide", false));
connect(hideUntrackedFiles, &QAction::triggered, this, [this](bool checked) {
RepoView::parentView(this)->repo().appConfig().setValue("untracked.hide",
checked);
RepoView::parentView(this)->refresh();
});
contextMenu->addAction(singleTree);
contextMenu->addAction(listView);
contextMenu->addAction(hideUntrackedFiles);
QHBoxLayout *buttonLayout = new QHBoxLayout();
buttonLayout->addStretch();
buttonLayout->addWidget(segmentedButton);