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
This commit is contained in:
Vincent van Ravesteijn 2011-01-04 09:49:30 +00:00
parent 5052b03d46
commit 68422fbb85
3 changed files with 33 additions and 18 deletions

View File

@ -1124,7 +1124,7 @@ void GuiWorkArea::updateWindowTitle()
Buffer & buf = buffer_view_->buffer(); Buffer & buf = buffer_view_->buffer();
FileName const fileName = buf.fileName(); FileName const fileName = buf.fileName();
if (!fileName.empty()) { if (!fileName.empty()) {
maximize_title = fileName.displayName(30); maximize_title = fileName.displayName(130);
minimize_title = from_utf8(fileName.onlyFileName()); minimize_title = from_utf8(fileName.onlyFileName());
if (buf.lyxvc().inUse()) { if (buf.lyxvc().inUse()) {
if (buf.lyxvc().locker().empty()) if (buf.lyxvc().locker().empty())
@ -1615,12 +1615,14 @@ void TabWorkArea::updateTabTexts()
// set new tab titles // set new tab titles
for (It it = paths.begin(); it != paths.end(); ++it) { for (It it = paths.begin(); it != paths.end(); ++it) {
GuiWorkArea * i_wa = dynamic_cast<GuiWorkArea *>(widget(it->tab())); int const tab_index = it->tab();
Buffer & buf = i_wa->bufferView().buffer(); GuiWorkArea * i_wa = dynamic_cast<GuiWorkArea *>(widget(tab_index));
Buffer const & buf = i_wa->bufferView().buffer();
QString tab_text = it->displayString();
if (!buf.fileName().empty() && !buf.isClean()) if (!buf.fileName().empty() && !buf.isClean())
setTabText(it->tab(), it->displayString() + "*"); tab_text += "*";
else setTabText(tab_index, tab_text);
setTabText(it->tab(), it->displayString()); setTabToolTip(tab_index, it->abs());
} }
} }

View File

@ -151,8 +151,10 @@ public:
MenuItem(Kind kind, MenuItem(Kind kind,
QString const & label, QString const & label,
QString const & submenu = QString(), QString const & submenu = QString(),
QString const & tooltip = QString(),
bool optional = false) bool optional = false)
: kind_(kind), label_(label), submenuname_(submenu), optional_(optional) : kind_(kind), label_(label), submenuname_(submenu),
tooltip_(tooltip), optional_(optional)
{ {
LASSERT(kind == Submenu, /**/); LASSERT(kind == Submenu, /**/);
} }
@ -160,8 +162,10 @@ public:
MenuItem(Kind kind, MenuItem(Kind kind,
QString const & label, QString const & label,
FuncRequest const & func, FuncRequest const & func,
QString const & tooltip = QString(),
bool optional = false) 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; func_.origin = FuncRequest::MENU;
} }
@ -183,12 +187,14 @@ public:
return index == -1 ? QString() : label_.mid(index + 1); return index == -1 ? QString() : label_.mid(index + 1);
} }
/// The complete label, with label and shortcut separated by a '|' /// The complete label, with label and shortcut separated by a '|'
QString fulllabel() const { return label_;} QString fulllabel() const { return label_; }
/// The kind of entry /// The kind of entry
Kind kind() const { return kind_; } Kind kind() const { return kind_; }
/// the action (if relevant) /// the action (if relevant)
FuncRequest const & func() const { return func_; } 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_; } bool optional() const { return optional_; }
/// returns the status of the lfun associated with this entry /// returns the status of the lfun associated with this entry
FuncStatus const & status() const { return status_; } FuncStatus const & status() const { return status_; }
@ -240,6 +246,8 @@ private:
/// ///
QString submenuname_; QString submenuname_;
/// ///
QString tooltip_;
///
bool optional_; bool optional_;
/// ///
FuncStatus status_; FuncStatus status_;
@ -448,7 +456,7 @@ void MenuDefinition::read(Lexer & lex)
lex.next(true); lex.next(true);
string const command = lex.getString(); string const command = lex.getString();
FuncRequest func = lyxaction.lookupFunc(command); FuncRequest func = lyxaction.lookupFunc(command);
add(MenuItem(MenuItem::Command, toqstr(name), func, optional)); add(MenuItem(MenuItem::Command, toqstr(name), func, QString(), optional));
optional = false; optional = false;
break; break;
} }
@ -538,7 +546,7 @@ void MenuDefinition::read(Lexer & lex)
lex.next(true); lex.next(true);
docstring const mname = lex.getDocString(); docstring const mname = lex.getDocString();
add(MenuItem(MenuItem::Submenu, add(MenuItem(MenuItem::Submenu,
toqstr(mlabel), toqstr(mname), optional)); toqstr(mlabel), toqstr(mname), QString(), optional));
optional = false; optional = false;
break; break;
} }
@ -667,14 +675,15 @@ void MenuDefinition::expandLastfiles()
for (; lfit != lf.end() && ii <= lyxrc.num_lastfiles; ++lfit, ++ii) { for (; lfit != lf.end() && ii <= lyxrc.num_lastfiles; ++lfit, ++ii) {
string const file = lfit->absFilename(); string const file = lfit->absFilename();
QString const short_path = toqstr(makeDisplayPath(file, 30));
QString const long_path = toqstr(makeDisplayPath(file));
QString label; QString label;
if (ii < 10) if (ii < 10)
label = QString("%1. %2|%3").arg(ii) label = QString("%1. %2|%3").arg(ii).arg(short_path).arg(ii);
.arg(toqstr(makeDisplayPath(file, 30))).arg(ii);
else else
label = QString("%1. %2").arg(ii) label = QString("%1. %2").arg(ii).arg(short_path);
.arg(toqstr(makeDisplayPath(file, 30))); add(MenuItem(MenuItem::Command, label,
add(MenuItem(MenuItem::Command, label, FuncRequest(LFUN_FILE_OPEN, file))); FuncRequest(LFUN_FILE_OPEN, file), long_path));
} }
} }
@ -1209,7 +1218,7 @@ void Menu::Impl::populate(QMenu & qMenu, MenuDefinition const & menu)
} else { } else {
// we have a MenuItem::Command // we have a MenuItem::Command
qMenu.addAction(new Action(view, QIcon(), label(*m), qMenu.addAction(new Action(view, QIcon(), label(*m),
m->func(), QString(), &qMenu)); m->func(), m->tooltip(), &qMenu));
} }
} }
} }

View File

@ -159,6 +159,10 @@ What's new
- Allow to undo the insertion of math macros (bug 7125). - 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 * DOCUMENTATION AND LOCALIZATION