Skip to content

Commit 057ce93

Browse files
authored
Merge pull request #933 from Murmele/autohide_sidebar
Autohide sidebar when opening repository
2 parents 5b2b07b + 4e155b6 commit 057ce93

File tree

4 files changed

+15
-5
lines changed

4 files changed

+15
-5
lines changed

docs/changelog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ Bug Fix and Feature release
66

77
* Add more information about the credential stores to give the user the possibility to easily see the tradeoffs of every credential store
88

9+
#### Changed
10+
11+
* Autohide sidebar when opening repository
12+
913
----
1014

1115
### v2.0.0 - 2025-11-30

src/ui/MainWindow.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ MainWindow::MainWindow(const git::Repository &repo, QWidget *parent,
142142
connect(tabs, QOverload<>::of(&TabWidget::tabRemoved), this,
143143
&MainWindow::updateTabNames);
144144

145-
splitter->addWidget(new SideBar(tabs, splitter));
145+
splitter->addWidget(new SideBar(tabs, this, splitter));
146146
splitter->addWidget(tabs);
147147
splitter->setCollapsible(1, false);
148148
splitter->setStretchFactor(1, 1);

src/ui/SideBar.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -597,7 +597,8 @@ void restoreExpansionState(QTreeView *view) {
597597

598598
} // namespace
599599

600-
SideBar::SideBar(TabWidget *tabs, QWidget *parent) : QWidget(parent) {
600+
SideBar::SideBar(TabWidget *tabs, MainWindow *mainWindow, QWidget *parent)
601+
: QWidget(parent) {
601602
setStyleSheet(kStyleSheet);
602603

603604
QTreeView *view = new QTreeView(this);
@@ -638,16 +639,19 @@ SideBar::SideBar(TabWidget *tabs, QWidget *parent) : QWidget(parent) {
638639
});
639640

640641
connect(
641-
view, &QTreeView::doubleClicked, [tabs, this](const QModelIndex &index) {
642+
view, &QTreeView::doubleClicked,
643+
[tabs, this, mainWindow](const QModelIndex &index) {
642644
if (isRepoIndex(index)) {
643645
tabs->setCurrentIndex(index.row());
646+
mainWindow->setSideBarVisible(false);
644647
return;
645648
}
646649

647650
// Open existing path.
648651
QString path = index.data(PathRole).toString();
649652
if (!path.isEmpty()) {
650653
MainWindow::open(path);
654+
mainWindow->setSideBarVisible(false);
651655
return;
652656
}
653657

@@ -666,12 +670,13 @@ SideBar::SideBar(TabWidget *tabs, QWidget *parent) : QWidget(parent) {
666670
if (repoVariant.isValid()) {
667671
Repository *repo = repoVariant.value<Repository *>();
668672
CloneDialog *dialog = new CloneDialog(CloneDialog::Clone, this, repo);
669-
connect(dialog, &CloneDialog::accepted, [repo, dialog] {
673+
connect(dialog, &CloneDialog::accepted, [repo, dialog, mainWindow] {
670674
// Set local path.
671675
Account *account = repo->account();
672676
account->setRepositoryPath(account->indexOf(repo), dialog->path());
673677

674678
// Open the repo.
679+
mainWindow->setSideBarVisible(false);
675680
MainWindow::open(dialog->path());
676681
});
677682

src/ui/SideBar.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,13 @@
1414

1515
class Account;
1616
class TabWidget;
17+
class MainWindow;
1718

1819
class SideBar : public QWidget {
1920
Q_OBJECT
2021

2122
public:
22-
SideBar(TabWidget *tabs, QWidget *parent = nullptr);
23+
SideBar(TabWidget *tabs, MainWindow *mainWindow, QWidget *parent = nullptr);
2324

2425
QSize sizeHint() const override;
2526
QSize minimumSizeHint() const override;

0 commit comments

Comments
 (0)