From 6152ce4187d253fc2495e5d87093df3ca18be582 Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Tue, 11 Aug 2015 15:12:43 +0200 Subject: [PATCH] UI: Avoid showing folder alias #783 #3576 --- src/gui/folder.cpp | 13 +++++++++++++ src/gui/folder.h | 1 + src/gui/folderstatusmodel.cpp | 2 +- src/gui/owncloudgui.cpp | 2 +- 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/gui/folder.cpp b/src/gui/folder.cpp index f7a6448e5..9e02e98e1 100644 --- a/src/gui/folder.cpp +++ b/src/gui/folder.cpp @@ -177,6 +177,19 @@ void Folder::checkLocalPath() } } +QString Folder::aliasGui() const +{ + if (remotePath().length() > 0 && remotePath() != QLatin1String("/")) { + QString a = QFile(remotePath()).fileName(); + if (a.startsWith('/')) { + a = a.remove(0, 1); + } + return a; + } else { + return Theme::instance()->appNameGUI(); + } +} + QString Folder::alias() const { return _definition.alias; diff --git a/src/gui/folder.h b/src/gui/folder.h index fa48973d6..49ae3b5b2 100644 --- a/src/gui/folder.h +++ b/src/gui/folder.h @@ -101,6 +101,7 @@ public: * alias or nickname */ QString alias() const; + QString aliasGui() const; // since 2.0 we don't want to show aliases anymore, show the path instead /** * local folder path diff --git a/src/gui/folderstatusmodel.cpp b/src/gui/folderstatusmodel.cpp index ec7e8f9a5..b9ec10986 100644 --- a/src/gui/folderstatusmodel.cpp +++ b/src/gui/folderstatusmodel.cpp @@ -156,7 +156,7 @@ QVariant FolderStatusModel::data(const QModelIndex &index, int role) const switch (role) { case FolderStatusDelegate::FolderPathRole : return f->nativePath(); case FolderStatusDelegate::FolderSecondPathRole : return f->remotePath(); - case FolderStatusDelegate::FolderAliasRole : return f->alias(); + case FolderStatusDelegate::FolderAliasRole : return f->aliasGui(); case FolderStatusDelegate::FolderSyncPaused : return f->syncPaused(); case FolderStatusDelegate::FolderAccountConnected : return accountConnected; case Qt::ToolTipRole: diff --git a/src/gui/owncloudgui.cpp b/src/gui/owncloudgui.cpp index 16cd53544..457956370 100644 --- a/src/gui/owncloudgui.cpp +++ b/src/gui/owncloudgui.cpp @@ -342,7 +342,7 @@ void ownCloudGui::addAccountContextMenu(AccountStatePtr accountState, QMenu *men folderName = Theme::instance()->appNameGUI(); } - QAction *action = new QAction( tr("Open folder '%1'").arg(folder->alias()), this ); + QAction *action = new QAction( tr("Open folder '%1'").arg(folder->path()), this ); connect(action, SIGNAL(triggered()),_folderOpenActionMapper, SLOT(map())); _folderOpenActionMapper->setMapping( action, folder->alias() ); menu->addAction(action);