]> git.lyx.org Git - features.git/commitdiff
Fix part 2 of bug #7182: LyX truncates file names to about 25 chars.
authorVincent van Ravesteijn <vfr@lyx.org>
Mon, 3 Jan 2011 18:44:52 +0000 (18:44 +0000)
committerVincent van Ravesteijn <vfr@lyx.org>
Mon, 3 Jan 2011 18:44:52 +0000 (18:44 +0000)
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

src/frontends/qt4/Menus.cpp

index bd2e35c6d7a220e0800febdfcc19735f0885d3b4..54636e666ccbac34337caca85aa1b11124b39264 100644 (file)
@@ -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));
                }
        }
 }