From: Vincent van Ravesteijn Date: Mon, 3 Jan 2011 18:44:52 +0000 (+0000) Subject: Fix part 2 of bug #7182: LyX truncates file names to about 25 chars. X-Git-Tag: 2.0.0~1194 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=4579492569873900673bbb1b0681ec61a5eba9a7;p=features.git Fix part 2 of bug #7182: LyX truncates file names to about 25 chars. Now, when hovering the lastfiles menu, the full file names are shown in the statusbar. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@37083 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/frontends/qt4/Menus.cpp b/src/frontends/qt4/Menus.cpp index bd2e35c6d7..54636e666c 100644 --- a/src/frontends/qt4/Menus.cpp +++ b/src/frontends/qt4/Menus.cpp @@ -177,8 +177,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 || kind == Help || kind == Info, /**/); } @@ -186,9 +188,11 @@ public: MenuItem(Kind kind, QString const & label, FuncRequest const & func, + QString const & tooltip = QString(), bool optional = false, FuncRequest::Origin origin = FuncRequest::MENU) - : kind_(kind), label_(label), func_(func), optional_(optional) + : kind_(kind), label_(label), func_(func), + tooltip_(tooltip), optional_(optional) { func_.setOrigin(origin); } @@ -210,11 +214,13 @@ 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_; } + /// 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 @@ -267,6 +273,8 @@ private: /// QString submenuname_; /// + QString tooltip_; + /// bool optional_; /// FuncStatus status_; @@ -498,7 +506,7 @@ void MenuDefinition::read(Lexer & lex) FuncRequest::Origin origin = FuncRequest::MENU; if (name_.startsWith("context-toc-")) origin = FuncRequest::TOC; - add(MenuItem(MenuItem::Command, toqstr(name), func, optional, origin)); + add(MenuItem(MenuItem::Command, toqstr(name), func, QString(), optional, origin)); optional = false; break; } @@ -612,7 +620,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; } @@ -884,14 +892,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)); } } @@ -1540,7 +1549,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)); } } }