Skip to content

Commit c94e13c

Browse files
keizieequeim
authored andcommitted
Refactor free space label in status bar update
1 parent e0d51c1 commit c94e13c

File tree

2 files changed

+10
-16
lines changed

2 files changed

+10
-16
lines changed

src/rpc/rpc.cpp

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -580,13 +580,10 @@ namespace tremotesf {
580580
}
581581

582582
Coroutine<std::optional<qint64>> Rpc::getDownloadDirFreeSpace() {
583-
if (isConnected()) {
584-
if (mServerSettings->data().canShowFreeSpaceForPath()) {
585-
co_return co_await getFreeSpaceForPathImpl(mServerSettings->data().downloadDirectory);
586-
}
587-
co_return co_await getDownloadDirFreeSpaceImpl();
583+
if (mServerSettings->data().canShowFreeSpaceForPath()) {
584+
co_return co_await getFreeSpaceForPathImpl(mServerSettings->data().downloadDirectory);
588585
}
589-
cancelCoroutine();
586+
co_return co_await getDownloadDirFreeSpaceImpl();
590587
}
591588

592589
Coroutine<std::optional<qint64>> Rpc::getDownloadDirFreeSpaceImpl() {
@@ -610,13 +607,11 @@ namespace tremotesf {
610607
}
611608

612609
Coroutine<std::optional<qint64>> Rpc::getFreeSpaceForPath(QString path) {
613-
if (isConnected()) {
614-
if (mServerSettings->data().canShowFreeSpaceForPath()) {
615-
co_return co_await getFreeSpaceForPathImpl(std::move(path));
616-
}
617-
if (path == mServerSettings->data().downloadDirectory) {
618-
co_return co_await getDownloadDirFreeSpaceImpl();
619-
}
610+
if (mServerSettings->data().canShowFreeSpaceForPath()) {
611+
co_return co_await getFreeSpaceForPathImpl(std::move(path));
612+
}
613+
if (path == mServerSettings->data().downloadDirectory) {
614+
co_return co_await getDownloadDirFreeSpaceImpl();
620615
}
621616
cancelCoroutine();
622617
}

src/ui/screens/mainwindow/mainwindowstatusbar.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,8 @@ namespace tremotesf {
103103
QObject::connect(mRpc->serverStats(), &ServerStats::updated, this, [=, this] {
104104
mDownloadSpeedLabel->setText(formatutils::formatByteSpeed(mRpc->serverStats()->downloadSpeed()));
105105
mUploadSpeedLabel->setText(formatutils::formatByteSpeed(mRpc->serverStats()->uploadSpeed()));
106-
mFreeSpaceLabel->setText(
107-
QObject::tr("Free space: %1").arg(formatutils::formatByteSize(mRpc->serverStats()->freeSpace()))
108-
);
106+
mFreeSpaceLabel->setText(qApp->translate("tremotesf", "Free space: %1")
107+
.arg(formatutils::formatByteSize(mRpc->serverStats()->freeSpace())));
109108
});
110109
}
111110

0 commit comments

Comments
 (0)