KiCad PCB EDA Suite
Loading...
Searching...
No Matches
git_advanced_dialog.h
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 3
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
20#ifndef GIT_ADVANCED_DIALOG_H
21#define GIT_ADVANCED_DIALOG_H
22
23#include <atomic>
24#include <functional>
25#include <memory>
26
29
30class EDA_BASE_FRAME;
32
33class GIT_COMMIT_PANE;
34class KIGIT_COMMON;
41class PANEL_GIT_TAGS;
42class wxSplitterWindow;
44
45
53{
54public:
56 ~GIT_ADVANCED_DIALOG() override;
57
61 static void ShowForFrame( EDA_BASE_FRAME* aParent, GIT_COMMIT_PANE* aPane );
62
65
67 static void ShowHistoryForFile( EDA_BASE_FRAME* aParent, GIT_COMMIT_PANE* aPane, const wxString& aPath );
68
71 void ShowHistoryForFile( const wxString& aPath );
72
74 void ShowAmend( const wxString& aCommitHash );
75
77 static void CloseActive();
78
80 static void CloseForPane( GIT_COMMIT_PANE* aPane );
81
82 void ReloadPages();
83
86 void SetPaneTransferBusy( bool aBusy, const wxString& aStatus = wxEmptyString );
87
89 void ShowTransferProgress( const wxString& aText );
90
95 void RunGitAction( const std::function<bool( KIGIT_COMMON& )>& aFn, const wxString& aError,
96 bool aRewritesWorkingTree = false );
97
100 void RunGitAction( const std::function<bool( KIGIT_COMMON&, wxString& aDetail )>& aFn, const wxString& aError,
101 bool aRewritesWorkingTree = false );
102
105 bool SessionStillCurrent();
106
110
113 bool ConfirmWorkingTreeChange( const GIT_WORKTREE_STATUS& aStatus );
114
117 void RefuseOverUncommittedWork( std::function<void( const GIT_WORKTREE_STATUS& )> aReady );
118
120 void SwitchToBranch( const wxString& aBranch );
121
122private:
124 wxWindow* buildChangesPage( wxWindow* aBook );
125
127 void showWorkingDiff( const wxString& aPath );
128 void hideWorkingDiff();
129
131 void populateTopBar();
132
134 void optOutOfTextPersistence( wxWindow* aWindow );
135
137 void onFetch();
138 void startFetch( std::shared_ptr<KIGIT_COMMON> aCommon );
139
143
144
147
150
157
158 // Changes page
159 wxSplitterWindow* m_changesSplitter;
162
165 void syncListener();
166
167 std::weak_ptr<KIGIT_COMMON> m_listenerSession;
168 bool m_listenerAttached = false;
169
172
176
179};
180
181#endif // GIT_ADVANCED_DIALOG_H
DIALOG_GIT_ADVANCED_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxString &title=_("Advanced Git"), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(-1,-1), long style=wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER)
The base frame for deriving all KiCad main window classes.
EDA_BASE_FRAME * m_parent
GIT_ADVANCED_DIALOG(EDA_BASE_FRAME *aParent, GIT_COMMIT_PANE *aPane)
static void ShowHistoryForFile(EDA_BASE_FRAME *aParent, GIT_COMMIT_PANE *aPane, const wxString &aPath)
Open the window on its History page, narrowed to the commits that changed aPath.
PANEL_GIT_BRANCHES * m_branchesPage
void RefuseOverUncommittedWork(std::function< void(const GIT_WORKTREE_STATUS &)> aReady)
Check the working tree and LFS on a worker, then continue on the UI thread only when nothing is uncom...
void ShowTransferProgress(const wxString &aText)
Show a line of transfer progress on the hosted commit panel's status line.
void showWorkingDiff(const wxString &aPath)
Show the working copy of aPath against its committed version, or hide that area.
GIT_FILE_DIFF_AREA * m_workingDiff
void SwitchToBranch(const wxString &aBranch)
Switch the working tree to the named branch, after confirming, then refresh.
static void CloseForPane(GIT_COMMIT_PANE *aPane)
Close the live window if the given pane opened it, for when that pane goes away.
PANEL_GIT_REPOSITORY * m_repositoryPage
PANEL_GIT_HISTORY * m_historyPage
PANEL_GIT_REMOTES * m_remotesPage
EDITOR_SNAPSHOT m_docsBeforeChange
On-disk identity of the open documents, taken by ConfirmWorkingTreeChange() so only the documents an ...
bool ConfirmWorkingTreeChange()
After the asynchronous LFS check, save the open editors and snapshot their documents before an action...
static void CloseActive()
Close the live window, for when the project it was filled from goes away.
wxSplitterWindow * m_changesSplitter
KIGIT_QUERY m_reloadQuery
Reads the top bar and history branch choices without holding up the UI.
std::weak_ptr< KIGIT_COMMON > m_listenerSession
static GIT_ADVANCED_DIALOG * Active()
The live window, or null when none is open.
void RunGitAction(const std::function< bool(KIGIT_COMMON &)> &aFn, const wxString &aError, bool aRewritesWorkingTree=false)
Run a repository write under the action lock, then refresh every surface on success.
void startFetch(std::shared_ptr< KIGIT_COMMON > aCommon)
PANEL_GIT_STASHES * m_stashesPage
void syncListener()
Attach once to the project's session.
static void ShowForFrame(EDA_BASE_FRAME *aParent, GIT_COMMIT_PANE *aPane)
Raise the one window for this session, creating it on first use.
KIGIT_QUERY m_actionQuery
Preflight reads for actions that may replace the working tree.
GIT_COMMIT_PANE * m_pane
bool SessionStillCurrent()
True while the frame's git session is still the one this window's lists were filled from.
void onFetch()
Fetch from the remote on a worker, then refresh every surface.
void SetPaneTransferBusy(bool aBusy, const wxString &aStatus=wxEmptyString)
Put the hosted commit panel into, or out of, its transfer state, for a transfer this window or one of...
wxWindow * buildChangesPage(wxWindow *aBook)
The Changes page: the docked panel's commit controls with the selected file's diff below.
GIT_COMMIT_PANE * m_changesPane
int m_changesSashPos
Where the user left the sash between the Changes page's list and its diff area.
void optOutOfTextPersistence(wxWindow *aWindow)
Keep every text box in aWindow out of the dialog's saved control state.
void RunGitAction(const std::function< bool(KIGIT_COMMON &, wxString &aDetail)> &aFn, const wxString &aError, bool aRewritesWorkingTree=false)
As above, for an action with a message of its own: what it writes to aDetail is shown in place of lib...
void ShowAmend(const wxString &aCommitHash)
Open the Changes page to amend the selected history commit.
KIGIT_TRANSFER m_fetch
The fetch the top bar started.
PANEL_GIT_TAGS * m_tagsPage
void populateTopBar()
Fill the top bar's repository name and branch list.
Docked panel for committing: the branch to commit to, a summary and description, the commit options,...
Shows what changed in one file: the old and new drawing side by side for a schematic or board,...
The project's git session.
Read repository state without blocking the UI.
The advanced git window's Branches page: a searchable list beside the selected branch's detail,...
The advanced git window's History page: filters above a list of commits beside the selected commit's ...
The advanced git window's Remotes page: the list beside the selected remote's detail,...
Show the repository's author and open the shared identity editor.
The advanced git window's Stashes page: the list beside the selected stash's detail,...
The advanced git window's Tags page: the list beside the selected tag's detail, with the actions that...
What the open editors and the project settings looked like on disk before an operation that may rewri...
Repository state used before an operation that requires a clean working tree.