Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add reset local changes #537

Merged
merged 11 commits into from
Dec 7, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 23 additions & 1 deletion Mergin/project_status_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from qgis.utils import OverrideCursor
from .diff_dialog import DiffViewerDialog
from .validation import MultipleLayersWarning, warning_display_string, MerginProjectValidator
from .utils import is_versioned_file, icon_path, unsaved_project_check, UnsavedChangesStrategy
from .utils import is_versioned_file, icon_path, unsaved_project_check, UnsavedChangesStrategy, create_mergin_client
JanCaha marked this conversation as resolved.
Show resolved Hide resolved
from .repair import fix_datum_shift_grids


Expand Down Expand Up @@ -83,6 +83,13 @@ def __init__(

self.validate_project()

self.btn_reset_local_changes.clicked.connect(self.reset_local_changes)

if len(push_changes["added"]) > 0 or len(push_changes["removed"]) > 0 or len(push_changes["updated"]) > 0:
self.btn_reset_local_changes.setEnabled(True)
else:
self.btn_reset_local_changes.setEnabled(False)

def _get_info_text(self, has_files_to_replace, has_write_permissions, has_unfinished_pull):
msg = []
if not has_write_permissions:
Expand Down Expand Up @@ -231,3 +238,18 @@ def validate_project(self):
else:
self.show_validation_results(results)
self.btn_sync.setStyleSheet("background-color: #ffc800")

def reset_local_changes(self):
btn_reply = QMessageBox.question(
None,
"Remove local changes",
"Local changes will be reverted to previous uploaded version. Some files might be removed or modified! Do you want to proceed?",
JanCaha marked this conversation as resolved.
Show resolved Hide resolved
QMessageBox.Yes | QMessageBox.No,
QMessageBox.Yes,
)
if btn_reply == QMessageBox.No:
JanCaha marked this conversation as resolved.
Show resolved Hide resolved
return
mc = create_mergin_client()
mc.reset_local_changes(self.mp.dir)
JanCaha marked this conversation as resolved.
Show resolved Hide resolved
QMessageBox.information(None, "Remove local changes", "Local changes have been reverted.")
self.close()
13 changes: 10 additions & 3 deletions Mergin/ui/ui_status_dialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<string>Project status</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0" colspan="2">
<item row="0" column="0" colspan="3">
<widget class="QgsMessageBar" name="messageBar">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
Expand All @@ -24,7 +24,7 @@
</property>
</widget>
</item>
<item row="1" column="0" colspan="2">
<item row="1" column="0" colspan="3">
<widget class="QTreeView" name="treeStatus">
<property name="editTriggers">
<set>QAbstractItemView::NoEditTriggers</set>
Expand All @@ -41,7 +41,7 @@
</property>
</widget>
</item>
<item row="3" column="0" colspan="2">
<item row="3" column="0" colspan="3">
<widget class="QTextBrowser" name="txtWarnings">
<property name="readOnly">
<bool>true</bool>
Expand All @@ -62,6 +62,13 @@
</widget>
</item>
<item row="4" column="1">
<widget class="QPushButton" name="btn_reset_local_changes">
<property name="text">
<string>Reset Local Changes</string>
JanCaha marked this conversation as resolved.
Show resolved Hide resolved
</property>
</widget>
</item>
<item row="4" column="2">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
Expand Down