From 68422fbb85b39cee4930fa02a52e56482cda2e53 Mon Sep 17 00:00:00 2001 From: Vincent van Ravesteijn Date: Tue, 4 Jan 2011 09:49:30 +0000 Subject: [PATCH] branch: Fix bug #7182: LyX truncates file names in the ui. Changes: - let filenames to be longer in window title (see r36950); - when hovering the lastfiles menu, the full file names are shown in the statusbar (see r37083); - when hovering the tabs, the longer name is shown as a tooltip (see r37101). git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH_1_6_X@37102 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/frontends/qt4/GuiWorkArea.cpp | 14 +++++++------ src/frontends/qt4/Menus.cpp | 33 ++++++++++++++++++++----------- status.16x | 4 ++++ 3 files changed, 33 insertions(+), 18 deletions(-) diff --git a/src/frontends/qt4/GuiWorkArea.cpp b/src/frontends/qt4/GuiWorkArea.cpp index b9ac27e892..f507c6f293 100644 --- a/src/frontends/qt4/GuiWorkArea.cpp +++ b/src/frontends/qt4/GuiWorkArea.cpp @@ -1124,7 +1124,7 @@ void GuiWorkArea::updateWindowTitle() Buffer & buf = buffer_view_->buffer(); FileName const fileName = buf.fileName(); if (!fileName.empty()) { - maximize_title = fileName.displayName(30); + maximize_title = fileName.displayName(130); minimize_title = from_utf8(fileName.onlyFileName()); if (buf.lyxvc().inUse()) { if (buf.lyxvc().locker().empty()) @@ -1615,12 +1615,14 @@ void TabWorkArea::updateTabTexts() // set new tab titles for (It it = paths.begin(); it != paths.end(); ++it) { - GuiWorkArea * i_wa = dynamic_cast(widget(it->tab())); - Buffer & buf = i_wa->bufferView().buffer(); + int const tab_index = it->tab(); + GuiWorkArea * i_wa = dynamic_cast(widget(tab_index)); + Buffer const & buf = i_wa->bufferView().buffer(); + QString tab_text = it->displayString(); if (!buf.fileName().empty() && !buf.isClean()) - setTabText(it->tab(), it->displayString() + "*"); - else - setTabText(it->tab(), it->displayString()); + tab_text += "*"; + setTabText(tab_index, tab_text); + setTabToolTip(tab_index, it->abs()); } } diff --git a/src/frontends/qt4/Menus.cpp b/src/frontends/qt4/Menus.cpp index c01d78825b..e62f82b685 100644 --- a/src/frontends/qt4/Menus.cpp +++ b/src/frontends/qt4/Menus.cpp @@ -151,8 +151,10 @@ public: MenuItem(Kind kind, QString const & label, QString const & submenu = QString(), + QString const & tooltip = QString(), bool optional = false) - : kind_(kind), label_(label), submenuname_(submenu), optional_(optional) + : kind_(kind), label_(label), submenuname_(submenu), + tooltip_(tooltip), optional_(optional) { LASSERT(kind == Submenu, /**/); } @@ -160,8 +162,10 @@ public: MenuItem(Kind kind, QString const & label, FuncRequest const & func, + QString const & tooltip = QString(), bool optional = false) - : kind_(kind), label_(label), func_(func), optional_(optional) + : kind_(kind), label_(label), func_(func), + tooltip_(tooltip), optional_(optional) { func_.origin = FuncRequest::MENU; } @@ -183,12 +187,14 @@ public: return index == -1 ? QString() : label_.mid(index + 1); } /// The complete label, with label and shortcut separated by a '|' - QString fulllabel() const { return label_;} + QString fulllabel() const { return label_; } /// The kind of entry Kind kind() const { return kind_; } /// the action (if relevant) FuncRequest const & func() const { return func_; } - /// returns true if the entry should be ommited when disabled + /// the tooltip + QString const & tooltip() const { return tooltip_; } + /// returns true if the entry should be omitted when disabled bool optional() const { return optional_; } /// returns the status of the lfun associated with this entry FuncStatus const & status() const { return status_; } @@ -240,6 +246,8 @@ private: /// QString submenuname_; /// + QString tooltip_; + /// bool optional_; /// FuncStatus status_; @@ -448,7 +456,7 @@ void MenuDefinition::read(Lexer & lex) lex.next(true); string const command = lex.getString(); FuncRequest func = lyxaction.lookupFunc(command); - add(MenuItem(MenuItem::Command, toqstr(name), func, optional)); + add(MenuItem(MenuItem::Command, toqstr(name), func, QString(), optional)); optional = false; break; } @@ -538,7 +546,7 @@ void MenuDefinition::read(Lexer & lex) lex.next(true); docstring const mname = lex.getDocString(); add(MenuItem(MenuItem::Submenu, - toqstr(mlabel), toqstr(mname), optional)); + toqstr(mlabel), toqstr(mname), QString(), optional)); optional = false; break; } @@ -667,14 +675,15 @@ void MenuDefinition::expandLastfiles() for (; lfit != lf.end() && ii <= lyxrc.num_lastfiles; ++lfit, ++ii) { string const file = lfit->absFilename(); + QString const short_path = toqstr(makeDisplayPath(file, 30)); + QString const long_path = toqstr(makeDisplayPath(file)); QString label; if (ii < 10) - label = QString("%1. %2|%3").arg(ii) - .arg(toqstr(makeDisplayPath(file, 30))).arg(ii); + label = QString("%1. %2|%3").arg(ii).arg(short_path).arg(ii); else - label = QString("%1. %2").arg(ii) - .arg(toqstr(makeDisplayPath(file, 30))); - add(MenuItem(MenuItem::Command, label, FuncRequest(LFUN_FILE_OPEN, file))); + label = QString("%1. %2").arg(ii).arg(short_path); + add(MenuItem(MenuItem::Command, label, + FuncRequest(LFUN_FILE_OPEN, file), long_path)); } } @@ -1209,7 +1218,7 @@ void Menu::Impl::populate(QMenu & qMenu, MenuDefinition const & menu) } else { // we have a MenuItem::Command qMenu.addAction(new Action(view, QIcon(), label(*m), - m->func(), QString(), &qMenu)); + m->func(), m->tooltip(), &qMenu)); } } } diff --git a/status.16x b/status.16x index fca88428d3..af020a5da7 100644 --- a/status.16x +++ b/status.16x @@ -159,6 +159,10 @@ What's new - Allow to undo the insertion of math macros (bug 7125). +- Add some visual aids to distinguish opened files: full paths in + statusbar for recent files items; absolute paths in tooltips of + tabs; and longer paths in the window title (bug 7182). + * DOCUMENTATION AND LOCALIZATION