File indexing completed on 2025-01-05 05:14:47
0001 /* 0002 SPDX-FileCopyrightText: 2021 Hamed Masafi <hamed.masfi@gmail.com> 0003 0004 SPDX-License-Identifier: GPL-3.0-or-later 0005 */ 0006 0007 #include "commitactions.h" 0008 #include "dialogs/filestreedialog.h" 0009 #include "dialogs/runnerdialog.h" 0010 #include "windows/diffwindow.h" 0011 #include <entities/commit.h> 0012 0013 #include <QAction> 0014 0015 #include <KLocalizedString> 0016 0017 Git::Commit *CommitActions::commit() const 0018 { 0019 return mCommit; 0020 } 0021 0022 void CommitActions::setCommit(Git::Commit *commit) 0023 { 0024 mCommit = commit; 0025 0026 setActionEnabled(_actionBrowse, commit); 0027 setActionEnabled(_actionCheckout, commit); 0028 setActionEnabled(_actionDiff, commit); 0029 } 0030 0031 CommitActions::CommitActions(Git::Manager *git, QWidget *parent) 0032 : AbstractActions(git, parent) 0033 { 0034 _actionBrowse = addAction(i18n("Browse"), this, &CommitActions::browse, false, true); 0035 _actionCheckout = addAction(i18n("Checkout"), this, &CommitActions::checkout, false, true); 0036 _actionDiff = addAction(i18n("Diff with working dir"), this, &CommitActions::diff, false, true); 0037 } 0038 0039 void CommitActions::browse() 0040 { 0041 FilesTreeDialog d(mGit, mCommit->commitHash(), mParent); 0042 d.exec(); 0043 } 0044 0045 void CommitActions::checkout() 0046 { 0047 RunnerDialog d(mGit, mParent); 0048 d.run({QStringLiteral("checkout"), mCommit->commitHash()}); 0049 d.exec(); 0050 } 0051 0052 void CommitActions::diff() 0053 { 0054 auto d = new DiffWindow(mGit, mCommit->tree()); 0055 d->showModal(); 0056 } 0057 0058 #include "moc_commitactions.cpp"