]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/GuiWorkArea.cpp
fix completion painting for RTL (inline completion and completion list)
[lyx.git] / src / frontends / qt4 / GuiWorkArea.cpp
index 3794296b6715db5e3a016311f28ae3f912cd6a3f..d7d597021cfae7c4d4c3ca1b028f922e62dbab89 100644 (file)
 
 #include "GuiWorkArea.h"
 
+#include "ColorCache.h"
+#include "FontLoader.h"
+#include "Menus.h"
+
 #include "Buffer.h"
 #include "BufferParams.h"
 #include "BufferView.h"
@@ -60,6 +64,7 @@
 #include <QTimer>
 #include <QToolButton>
 #include <QToolTip>
+#include <QMenuBar>
 
 #include <boost/bind.hpp>
 
@@ -406,6 +411,12 @@ void GuiWorkArea::redraw()
 
 void GuiWorkArea::processKeySym(KeySymbol const & key, KeyModifier mod)
 {
+       if (lyx_view_->isFullScreen() && lyx_view_->menuBar()->isVisible()) {
+               // FIXME HACK: we should not have to do this here. See related comment
+               // in GuiView::event() (QEvent::ShortcutOverride)
+               lyx_view_->menuBar()->hide();
+       }
+
        // In order to avoid bad surprise in the middle of an operation,
        // we better stop the blinking cursor...
        // the cursor gets restarted in GuiView::restartCursor()
@@ -452,8 +463,7 @@ void GuiWorkArea::dispatch(FuncRequest const & cmd0, KeyModifier mod)
        // Skip these when selecting
        if (cmd.action != LFUN_MOUSE_MOTION) {
                completer_->updateVisibility(false, false);
-               lyx_view_->updateLayoutList();
-               lyx_view_->updateToolbars();
+               lyx_view_->updateDialogs();
        }
 
        // GUI tweaks except with mouse motion with no button pressed.
@@ -1220,6 +1230,7 @@ TabWorkArea::TabWorkArea(QWidget * parent)
        QTabBar* tb = new DragTabBar;
        connect(tb, SIGNAL(tabMoveRequested(int, int)),
                this, SLOT(moveTab(int, int)));
+       tb->setElideMode(Qt::ElideNone);
        setTabBar(tb);
 
        // make us responsible for the context menu of the tabbar
@@ -1406,7 +1417,8 @@ public:
                : tab_(tab)
        {
                filename_ = toqstr(filename.onlyFileNameWithoutExt());
-               postfix_ = toqstr(filename.absoluteFilePath()).split("/", QString::SkipEmptyParts);
+               postfix_ = toqstr(filename.absoluteFilePath()).
+                       split("/", QString::SkipEmptyParts);
                postfix_.pop_back();
                abs_ = toqstr(filename.absoluteFilePath());
                dottedPrefix_ = false;
@@ -1422,51 +1434,40 @@ public:
        /// when really needed.
        void shiftPathSegment(bool dotted)
        {
-               if (postfix_.count() > 0) {
-                       if (!dotted) {
-                               if (dottedPrefix_ && !prefix_.isEmpty())
-                                       prefix_ += ".../";
-                               prefix_ += postfix_.front() + "/";
-                       }
-                       dottedPrefix_ = dotted && !prefix_.isEmpty();
-                       postfix_.pop_front();
+               if (postfix_.count() <= 0)
+                       return;
+
+               if (!dotted) {
+                       if (dottedPrefix_ && !prefix_.isEmpty())
+                               prefix_ += ".../";
+                       prefix_ += postfix_.front() + "/";
                }
+               dottedPrefix_ = dotted && !prefix_.isEmpty();
+               postfix_.pop_front();
        }
        ///
        QString displayString() const
        {
                if (prefix_.isEmpty())
                        return filename_;
-               else {
-                       bool dots = dottedPrefix_ || !postfix_.isEmpty();
-                       return prefix_
-                               + (dots ? ".../" : "")
-                               + filename_;
-               }
+
+               bool dots = dottedPrefix_ || !postfix_.isEmpty();
+               return prefix_ + (dots ? ".../" : "") + filename_;
        }
        ///
-       QString forecastDisplayString() const
+       QString forecastPathString() const
        {
                if (postfix_.count() == 0)
                        return displayString();
                
-               bool postfixLeft = postfix_.count() > 1;
                return prefix_
                        + (dottedPrefix_ ? ".../" : "")
-                       + postfix_.front() + "/"
-                       + (postfixLeft ? ".../" : "")
-                       + filename_;
+                       + postfix_.front() + "/";
        }
        ///
-       bool final() const
-       {
-               return postfix_.empty();
-       }
+       bool final() const { return postfix_.empty(); }
        ///
-       int tab() const
-       {
-               return tab_;
-       }
+       int tab() const { return tab_; }
        
 private:
        ///
@@ -1536,8 +1537,8 @@ void TabWorkArea::updateTabTexts()
                        // final?
                        allFinal = allFinal && it->final();
                        
-                       LYXERR(Debug::GUI, "it = " << fromqstr(it->abs())
-                              << " => " << fromqstr(it->displayString()));
+                       LYXERR(Debug::GUI, "it = " << it->abs()
+                              << " => " << it->displayString());
                        
                        // still the same segment?
                        QString nextString;
@@ -1559,26 +1560,20 @@ void TabWorkArea::updateTabTexts()
                        // that it makes the path more unique.
                        somethingChanged = true;
                        It sit = segStart;
-                       QString dspString = sit->forecastDisplayString();
+                       QString dspString = sit->forecastPathString();
                        LYXERR(Debug::GUI, "first forecast found for "
-                              << fromqstr(sit->abs())
-                              << " => " << fromqstr(dspString));
+                              << sit->abs() << " => " << dspString);
                        ++sit;
                        bool moreUnique = false;
                        for (; sit != next; ++sit) {
-                               if (sit->forecastDisplayString() != dspString) {
+                               if (sit->forecastPathString() != dspString) {
                                        LYXERR(Debug::GUI, "different forecast found for "
-                                              << fromqstr(sit->abs())
-                                              << " => "
-                                              << fromqstr(sit->forecastDisplayString()));
+                                               << sit->abs() << " => " << sit->forecastPathString());
                                        moreUnique = true;
                                        break;
-                               } else {
-                                       LYXERR(Debug::GUI, "same forecast found for "
-                                              << fromqstr(sit->abs())
-                                              << " => "
-                                              << fromqstr(sit->forecastDisplayString()));
                                }
+                               LYXERR(Debug::GUI, "same forecast found for "
+                                       << sit->abs() << " => " << dspString);
                        }
                        
                        // if the path segment helped, add it. Otherwise add dots
@@ -1586,9 +1581,8 @@ void TabWorkArea::updateTabTexts()
                        LYXERR(Debug::GUI, "using dots = " << dots);
                        for (sit = segStart; sit != next; ++sit) {
                                sit->shiftPathSegment(dots);
-                               LYXERR(Debug::GUI, "shifting " << fromqstr(sit->abs())
-                                      << " => "
-                                      << fromqstr(sit->displayString()));
+                               LYXERR(Debug::GUI, "shifting "
+                                       << sit->abs() << " => " << sit->displayString());
                        }
 
                        // start new segment
@@ -1613,17 +1607,18 @@ void TabWorkArea::showContextMenu(const QPoint & pos)
 {
        // which tab?
        clicked_tab_ = static_cast<DragTabBar *>(tabBar())->tabAt(pos);
-       if (clicked_tab_ != -1) {
-               // show tab popup
-               QMenu popup;
-               popup.addAction(QIcon(":/images/hidetab.png"),
-                        qt_("Hide tab"), this, SLOT(closeCurrentTab()));
-               popup.addAction(QIcon(":/images/closetab.png"),
-                        qt_("Close tab"), this, SLOT(closeCurrentBuffer()));
-               popup.exec(tabBar()->mapToGlobal(pos));
-               
-               clicked_tab_ = -1;
-       }
+       if (clicked_tab_ == -1)
+               return;
+       
+       // show tab popup
+       QMenu popup;
+       popup.addAction(QIcon(":/images/hidetab.png"),
+               qt_("Hide tab"), this, SLOT(closeCurrentTab()));
+       popup.addAction(QIcon(":/images/closetab.png"),
+               qt_("Close tab"), this, SLOT(closeCurrentBuffer()));
+       popup.exec(tabBar()->mapToGlobal(pos));
+
+       clicked_tab_ = -1;
 }