Cloud storage: better window title

This makes it clear that we are working with the cloud storage and removes
the (in that case, redundant) branch name from the title.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2015-06-12 06:53:00 -07:00
parent ef95bd9a27
commit f442358915
2 changed files with 14 additions and 4 deletions

View file

@ -1415,6 +1415,18 @@ NotificationWidget *MainWindow::getNotificationWidget()
return ui.mainErrorMessage; return ui.mainErrorMessage;
} }
QString MainWindow::displayedFilename(QString fullFilename)
{
QFile f(fullFilename);
QFileInfo fileInfo(f);
QString fileName(fileInfo.fileName());
if (fullFilename.contains("https://cloud.subsurface-divelog.org"))
return tr("[cloud storage for] %1").arg(fileName.left(fileName.indexOf('[')));
else
return fileName;
}
void MainWindow::setTitle(enum MainWindowTitleFormat format) void MainWindow::setTitle(enum MainWindowTitleFormat format)
{ {
switch (format) { switch (format) {
@ -1426,11 +1438,8 @@ void MainWindow::setTitle(enum MainWindowTitleFormat format)
setTitle(MWTF_DEFAULT); setTitle(MWTF_DEFAULT);
return; return;
} }
QFile f(existing_filename);
QFileInfo fileInfo(f);
QString fileName(fileInfo.fileName());
QString unsaved = (unsaved_changes() ? " *" : ""); QString unsaved = (unsaved_changes() ? " *" : "");
setWindowTitle("Subsurface: " + fileName + unsaved); setWindowTitle("Subsurface: " + displayedFilename(existing_filename) + unsaved);
break; break;
} }
} }

View file

@ -195,6 +195,7 @@ private:
CurrentState state; CurrentState state;
QString filter(); QString filter();
static MainWindow *m_Instance; static MainWindow *m_Instance;
QString displayedFilename(QString fullFilename);
bool askSaveChanges(); bool askSaveChanges();
bool okToClose(QString message); bool okToClose(QString message);
void closeCurrentFile(); void closeCurrentFile();