1
0
Fork 0
mirror of https://github.com/borgbase/vorta synced 2024-12-22 07:43:09 +00:00

Fix copying the current repo to the clipboard. By@real-yfprojects (#1313)

This commit is contained in:
yfprojects 2022-05-22 07:32:57 +00:00 committed by GitHub
parent efe710540a
commit 4b6d080f05
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,6 +1,8 @@
import os
from pathlib import PurePath
from PyQt5 import QtCore, uic
from PyQt5.QtCore import QMimeData, QUrl
from PyQt5.QtWidgets import QApplication, QMenu, QMessageBox
from vorta.store.models import ArchiveModel, BackupProfileMixin, RepoModel
@ -266,12 +268,21 @@ def repo_unlink_action(self):
self.init_repo_stats()
def copy_URL_action(self):
if self.repoSelector.currentIndex() > 2:
URL = self.repoSelector.currentText()
QApplication.clipboard().setText(URL)
selected_repo_id = self.repoSelector.currentData()
if not selected_repo_id:
# QComboBox is empty
return
repo = RepoModel.get(id=selected_repo_id)
url = repo.url
data = QMimeData()
if not repo.is_remote_repo():
path = PurePath(url)
data.setUrls([QUrl(path.as_uri())])
data.setText(str(path))
else:
msg = QMessageBox()
msg.setStandardButtons(QMessageBox.Ok)
msg.setParent(self, QtCore.Qt.Sheet)
msg.setText(self.tr("Select a repository from the dropdown first."))
msg.show()
data.setText(url)
QApplication.clipboard().setMimeData(data)