diff options
author | Christian Kamm <mail@ckamm.de> | 2019-04-16 10:47:55 +0300 |
---|---|---|
committer | Christian Kamm <mail@ckamm.de> | 2019-04-23 10:21:17 +0300 |
commit | ac19fab71aaee448a3f588ba01f06b2f5dca26b8 (patch) | |
tree | b7d7f035bddc57731923b1d68140840e2ddfe81b /src | |
parent | 1e1340b4578c9af13a9ea2cd4fe1dfd21e7f0a6d (diff) |
Vfs: Adjust and centralise action text #7143
Saying "Currently available locally" sounds more like an indicator than
"Availably locally" does. Centralizing translations avoids consistency
issues between shell context menus and sync folder context menu.
Diffstat (limited to 'src')
-rw-r--r-- | src/common/vfs.cpp | 19 | ||||
-rw-r--r-- | src/common/vfs.h | 3 | ||||
-rw-r--r-- | src/gui/accountsettings.cpp | 6 | ||||
-rw-r--r-- | src/gui/guiutility.cpp | 31 | ||||
-rw-r--r-- | src/gui/guiutility.h | 14 | ||||
-rw-r--r-- | src/gui/socketapi.cpp | 6 |
6 files changed, 51 insertions, 28 deletions
diff --git a/src/common/vfs.cpp b/src/common/vfs.cpp index 5f170daf1..54f6cb6bd 100644 --- a/src/common/vfs.cpp +++ b/src/common/vfs.cpp @@ -205,22 +205,3 @@ std::unique_ptr<Vfs> OCC::createVfsFromPlugin(Vfs::Mode mode) qCInfo(lcPlugin) << "Created VFS instance from plugin" << pluginPath; return vfs; } - -QString OCC::vfsItemAvailabilityToString(VfsItemAvailability availability, bool forFolder) -{ - switch(availability) { - case VfsItemAvailability::AlwaysLocal: - return Vfs::tr("Always available locally"); - case VfsItemAvailability::AllHydrated: - return Vfs::tr("Available locally"); - case VfsItemAvailability::SomeDehydrated: - if (forFolder) { - return Vfs::tr("Some available online only"); - } else { - return Vfs::tr("Available online only"); - } - case VfsItemAvailability::OnlineOnly: - return Vfs::tr("Available online only"); - } - ENFORCE(false); -} diff --git a/src/common/vfs.h b/src/common/vfs.h index a8765d793..59153024a 100644 --- a/src/common/vfs.h +++ b/src/common/vfs.h @@ -300,7 +300,4 @@ OCSYNC_EXPORT Vfs::Mode bestAvailableVfsMode(); /// Create a VFS instance for the mode, returns nullptr on failure. OCSYNC_EXPORT std::unique_ptr<Vfs> createVfsFromPlugin(Vfs::Mode mode); -/// Convert availability to translated string -OCSYNC_EXPORT QString vfsItemAvailabilityToString(VfsItemAvailability availability, bool forFolder); - } // namespace OCC diff --git a/src/gui/accountsettings.cpp b/src/gui/accountsettings.cpp index b848330a2..775b916ce 100644 --- a/src/gui/accountsettings.cpp +++ b/src/gui/accountsettings.cpp @@ -342,15 +342,15 @@ void AccountSettings::slotCustomContextMenuRequested(const QPoint &pos) auto availabilityMenu = menu->addMenu(tr("Availability")); auto availability = folder->vfs().availability(QString()); if (availability) { - ac = availabilityMenu->addAction(vfsItemAvailabilityToString(*availability, true)); + ac = availabilityMenu->addAction(Utility::vfsCurrentAvailabilityText(*availability, true)); ac->setEnabled(false); } - ac = availabilityMenu->addAction(tr("Make always available locally")); + ac = availabilityMenu->addAction(Utility::vfsPinActionText()); ac->setEnabled(!availability || *availability != VfsItemAvailability::AlwaysLocal); connect(ac, &QAction::triggered, this, [this]() { slotSetCurrentFolderAvailability(PinState::AlwaysLocal); }); - ac = availabilityMenu->addAction(tr("Free up local space")); + ac = availabilityMenu->addAction(Utility::vfsFreeSpaceActionText()); ac->setEnabled(!availability || *availability != VfsItemAvailability::OnlineOnly); connect(ac, &QAction::triggered, this, [this]() { slotSetCurrentFolderAvailability(PinState::OnlineOnly); }); diff --git a/src/gui/guiutility.cpp b/src/gui/guiutility.cpp index 8f71b1cda..545f56bff 100644 --- a/src/gui/guiutility.cpp +++ b/src/gui/guiutility.cpp @@ -21,6 +21,8 @@ #include <QMessageBox> #include <QUrlQuery> +#include "common/asserts.h" + using namespace OCC; Q_LOGGING_CATEGORY(lcUtility, "gui.utility", QtInfoMsg) @@ -66,3 +68,32 @@ bool Utility::openEmailComposer(const QString &subject, const QString &body, QWi } return true; } + +QString Utility::vfsCurrentAvailabilityText(VfsItemAvailability availability, bool forFolder) +{ + switch(availability) { + case VfsItemAvailability::AlwaysLocal: + return QCoreApplication::translate("utility", "Currently always available locally"); + case VfsItemAvailability::AllHydrated: + return QCoreApplication::translate("utility", "Currently available locally"); + case VfsItemAvailability::SomeDehydrated: + if (forFolder) { + return QCoreApplication::translate("utility", "Currently some available online only"); + } else { + return QCoreApplication::translate("utility", "Currently available online only"); + } + case VfsItemAvailability::OnlineOnly: + return QCoreApplication::translate("utility", "Currently available online only"); + } + ENFORCE(false); +} + +QString Utility::vfsPinActionText() +{ + return QCoreApplication::translate("utility", "Make always available locally"); +} + +QString Utility::vfsFreeSpaceActionText() +{ + return QCoreApplication::translate("utility", "Free up local space"); +} diff --git a/src/gui/guiutility.h b/src/gui/guiutility.h index 55f808ac2..b25ecc937 100644 --- a/src/gui/guiutility.h +++ b/src/gui/guiutility.h @@ -19,6 +19,8 @@ #include <QUrl> #include <QWidget> +#include "common/pinstate.h" + namespace OCC { namespace Utility { @@ -35,6 +37,18 @@ namespace Utility { bool openEmailComposer(const QString &subject, const QString &body, QWidget *errorWidgetParent); + /** Returns a translated string indicating the current availability. + * + * This will be used in context menus to describe the current state. + */ + QString vfsCurrentAvailabilityText(VfsItemAvailability availability, bool forFolder); + + /** Translated text for "making items always available locally" */ + QString vfsPinActionText(); + + /** Translated text for "free up local space" (and unpinning the item) */ + QString vfsFreeSpaceActionText(); + } // namespace Utility } // namespace OCC diff --git a/src/gui/socketapi.cpp b/src/gui/socketapi.cpp index c727b869a..baf9473e9 100644 --- a/src/gui/socketapi.cpp +++ b/src/gui/socketapi.cpp @@ -979,13 +979,13 @@ void SocketApi::command_GET_MENU_ITEMS(const QString &argument, OCC::SocketListe // TODO: Should be a submenu, should use icons auto makePinContextMenu = [&](bool makeAvailableLocally, bool freeSpace) { listener->sendMessage(QLatin1String("MENU_ITEM:CURRENT_PIN:d:") - + vfsItemAvailabilityToString(*combined, isFolderOrMultiple)); + + Utility::vfsCurrentAvailabilityText(*combined, isFolderOrMultiple)); listener->sendMessage(QLatin1String("MENU_ITEM:MAKE_AVAILABLE_LOCALLY:") + (makeAvailableLocally ? QLatin1String(":") : QLatin1String("d:")) - + tr("Make always available locally")); + + Utility::vfsPinActionText()); listener->sendMessage(QLatin1String("MENU_ITEM:MAKE_ONLINE_ONLY:") + (freeSpace ? QLatin1String(":") : QLatin1String("d:")) - + tr("Free up local space")); + + Utility::vfsFreeSpaceActionText()); }; switch (*combined) { |