Skip to content

Commit

Permalink
Improve code structures
Browse files Browse the repository at this point in the history
  • Loading branch information
rumtid committed Jan 26, 2024
1 parent c68b796 commit c3d4bfa
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 35 deletions.
23 changes: 11 additions & 12 deletions src/ui/create-repo-dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,17 @@ void CreateRepoDialog::createAction()
if (!validateInputs()) {
return;
}
#ifdef Q_OS_WIN32
if (utils::win::isNetworkDevice(path_)) {
bool ok = seafApplet->yesOrCancelBox(
tr("File changes on network drives may not be synced automatically. You can set sync intervals to enable periodic sync. Do you want to sync with this folder?"),
this, true);
if (!ok) {
return;
}
}
#endif // Q_OS_WIN32

mStatusText->setText(tr("Creating..."));

setAllInputsEnabled(false);
Expand Down Expand Up @@ -187,18 +198,6 @@ bool CreateRepoDialog::validateInputs()

name_ = mName->text().trimmed();
path_ = mDirectory->text();

#ifdef Q_OS_WIN32
if (utils::win::isNetworkDevice(path_)) {
bool ok = seafApplet->detailedYesOrNoBox(
tr("File changes on network drives may not be synced automatically. Do you want to sync with this folder?"),
tr("You can set sync intervals to enable periodic sync."), this);
if (!ok) {
return false;
}
}
#endif // Q_OS_WIN32

return true;
}

Expand Down
37 changes: 14 additions & 23 deletions src/ui/download-repo-dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,19 @@ void DownloadRepoDialog::onOkBtnClicked()
if (!validateInputs()) {
return;
}
#ifdef Q_OS_WIN32
QString worktree = alternative_path_.isEmpty() ?
QDir(mDirectory->text()).absoluteFilePath(repo_.name) :
alternative_path_;
if (utils::win::isNetworkDevice(worktree)) {
bool ok = seafApplet->yesOrCancelBox(
tr("File changes on network drives may not be synced automatically. You can set sync intervals to enable periodic sync. Do you want to sync with this folder?"),
this, true);
if (!ok) {
return;
}
}
#endif // Q_OS_WIN32

setAllInputsEnabled(false);

Expand Down Expand Up @@ -280,25 +293,14 @@ bool DownloadRepoDialog::validateInputs()
return false;
}

QString path = QDir(mDirectory->text()).absoluteFilePath(repo_.name);

if (manual_merge_mode_) {
#ifdef Q_OS_WIN32
if (utils::win::isNetworkDevice(path)) {
bool ok = seafApplet->detailedYesOrNoBox(
tr("File changes on network drives may not be synced automatically. Do you want to sync with this folder?"),
tr("You can set sync intervals to enable periodic sync."), this);
if (!ok) {
return false;
}
}
#endif // Q_OS_WIN32
return true;
}

sync_with_existing_ = false;
alternative_path_ = "";

QString path = QDir(mDirectory->text()).absoluteFilePath(repo_.name);
QFileInfo fileinfo = QFileInfo(path);
if (fileinfo.exists()) {
sync_with_existing_ = true;
Expand Down Expand Up @@ -333,17 +335,6 @@ bool DownloadRepoDialog::validateInputs()
}
}

#ifdef Q_OS_WIN32
if (utils::win::isNetworkDevice(path)) {
bool ok = seafApplet->detailedYesOrNoBox(
tr("File changes on network drives may not be synced automatically. Do you want to sync with this folder?"),
tr("You can set sync intervals to enable periodic sync."), this);
if (!ok) {
return false;
}
}
#endif // Q_OS_WIN32

return true;
}

Expand Down

0 comments on commit c3d4bfa

Please sign in to comment.