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#include <optional>
27
28#include <wx/weakref.h>
29
33
34class EDA_BASE_FRAME;
36
37class GIT_COMMIT_PANE;
38class KIGIT_COMMON;
45class PANEL_GIT_TAGS;
46class wxSplitterWindow;
48
49
61
62
70{
71public:
73 ~GIT_ADVANCED_DIALOG() override;
74
79 static void ShowForFrame( EDA_BASE_FRAME* aParent, GIT_COMMIT_PANE* aPane,
80 std::optional<GIT_ADVANCED_PAGE> aPage = std::nullopt );
81
84
86 static void ShowHistoryForFile( EDA_BASE_FRAME* aParent, GIT_COMMIT_PANE* aPane, const wxString& aPath );
87
90 void ShowHistoryForFile( const wxString& aPath );
91
93 void ShowAmend( const wxString& aCommitHash );
94
96 static void CloseActive();
97
99 static void CloseForPane( GIT_COMMIT_PANE* aPane );
100
101 void ReloadPages();
102
104 void ShowTransferProgress( const wxString& aText );
105
110 void RunGitAction( const std::function<bool( KIGIT_COMMON& )>& aFn, const wxString& aError,
111 bool aRewritesWorkingTree = false );
112
115 void RunGitAction( const std::function<bool( KIGIT_COMMON&, wxString& aDetail )>& aFn, const wxString& aError,
116 bool aRewritesWorkingTree = false );
117
120 bool SessionStillCurrent();
121
125
128 bool ConfirmWorkingTreeChange( const GIT_WORKTREE_STATUS& aStatus );
129
132 void RefuseOverUncommittedWork( std::function<void( const GIT_WORKTREE_STATUS& )> aReady );
133
135 void SwitchToBranch( const wxString& aBranch );
136
137private:
139 void setIcons();
140
141 void selectPage( GIT_ADVANCED_PAGE aPage );
142
144 wxWindow* buildChangesPage( wxWindow* aBook );
145
147 void showWorkingDiff( const wxString& aPath );
148 void hideWorkingDiff();
149
151 void populateTopBar();
152
154 void optOutOfTextPersistence( wxWindow* aWindow );
155
158 void onFetch( bool aRetriedAfterTrust = false );
159 void startFetch( std::shared_ptr<KIGIT_COMMON> aCommon, bool aRetriedAfterTrust );
160
163
165 void endFetch( const wxString& aStatus );
166
170
171
174
176
178 wxWeakRef<GIT_COMMIT_PANE> m_pane;
179
182
189
190 // Changes page
191 wxSplitterWindow* m_changesSplitter;
194
197 void syncListener();
198
199 std::weak_ptr<KIGIT_COMMON> m_listenerSession;
200 bool m_listenerAttached = false;
201
204
208
210 bool m_fetchPreflight = false;
211
213 unsigned m_fetchRequest = 0;
214
217
220};
221
222#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
bool abandonFetchPreflight()
Stop a pending remote check and release what the fetch holds. False when none is pending.
GIT_ADVANCED_DIALOG(EDA_BASE_FRAME *aParent, GIT_COMMIT_PANE *aPane)
int m_credentialPrompts
Keyring reads and credential prompts the current fetch has shown, reset when it ends.
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 ...
void selectPage(GIT_ADVANCED_PAGE aPage)
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
void endFetch(const wxString &aStatus)
Restore the Fetch button and release the fetch's hold, then show aStatus on the commit panel.
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.
PANEL_GIT_STASHES * m_stashesPage
void syncListener()
Attach once to the project's session.
bool m_fetchPreflight
The fetch is checking its remote, before its transfer starts, and holds the panes busy.
KIGIT_QUERY m_actionQuery
Preflight reads for actions that may replace the working tree.
bool SessionStillCurrent()
True while the frame's git session is still the one this window's lists were filled from.
GIT_TRANSFER_BUSY::HOLD m_fetchBusy
The top bar fetch's hold on its repository, from its remote check until it ends.
static void ShowForFrame(EDA_BASE_FRAME *aParent, GIT_COMMIT_PANE *aPane, std::optional< GIT_ADVANCED_PAGE > aPage=std::nullopt)
Raise the one window for this session, creating it on first use.
unsigned m_fetchRequest
Counts the fetches begun, so a keyring read finishing late starts only its own.
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.
wxWeakRef< GIT_COMMIT_PANE > m_pane
Weak because the pane can be destroyed before this dialog's deferred delete runs.
void optOutOfTextPersistence(wxWindow *aWindow)
Keep every text box in aWindow out of the dialog's saved control state.
void setIcons()
The page and toolbar icons, again after a light or dark switch.
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 onFetch(bool aRetriedAfterTrust=false)
Fetch from the remote on a worker, then refresh every surface.
void startFetch(std::shared_ptr< KIGIT_COMMON > aCommon, bool aRetriedAfterTrust)
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,...
One transfer's hold on its repository, released when reset, begun again or destroyed.
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...
GIT_ADVANCED_PAGE
The advanced window's pages, in the order its sidebar lists them.
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.