]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/GuiViewSource.cpp
Use QFontMetrics information for underlines (and friends) width and position
[lyx.git] / src / frontends / qt4 / GuiViewSource.cpp
index 70d932466edd91968657ac140998b1b875fbcca8..3fcaed984a97337dbe0c670ee529e9c4931232f1 100644 (file)
@@ -32,6 +32,7 @@
 
 #include <boost/crc.hpp>
 
+#include <QBoxLayout>
 #include <QSettings>
 #include <QTextCursor>
 #include <QTextDocument>
@@ -71,7 +72,6 @@ ViewSourceWidget::ViewSourceWidget()
        ///dialog_->viewSourceTV->setAcceptRichText(false);
        // this is personal. I think source code should be in fixed-size font
        QFont font(guiApp->typewriterFontName());
-       font.setKerning(false);
        font.setFixedPitch(true);
        font.setStyleHint(QFont::TypeWriter);
        viewSourceTV->setFont(font);
@@ -93,7 +93,7 @@ static size_t crcCheck(docstring const & s)
        \return true if the content has changed since last call.
  */
 static bool getContent(BufferView const * view, Buffer::OutputWhat output,
-                      QString & qstr, string const format, bool force_getcontent,
+                      QString & qstr, string const format, bool force_getcontent,
                       bool master)
 {
        // get the *top* level paragraphs that contain the cursor,
@@ -114,6 +114,9 @@ static bool getContent(BufferView const * view, Buffer::OutputWhat output,
        view->buffer().getSourceCode(ostr, format, par_begin, par_end + 1,
                                     output, master);
        docstring s = ostr.str();
+       // FIXME THREAD
+       // Could this be private to this particular dialog? We could have
+       // more than one of these, in different windows.
        static size_t crc = 0;
        size_t newcrc = crcCheck(s);
        if (newcrc == crc && !force_getcontent)
@@ -227,6 +230,19 @@ void ViewSourceWidget::updateDefaultFormat()
 }
 
 
+void ViewSourceWidget::resizeEvent (QResizeEvent * event)
+{
+       QSize const & formSize = formLayout->sizeHint();
+       // minimize the size of the part that contains the buttons
+       if (width() * formSize.height() < height() * formSize.width()) {
+               layout_->setDirection(QBoxLayout::TopToBottom);
+       } else {
+               layout_->setDirection(QBoxLayout::LeftToRight);
+       }
+       QWidget::resizeEvent(event);
+}
+
+
 GuiViewSource::GuiViewSource(GuiView & parent,
                Qt::DockWidgetArea area, Qt::WindowFlags flags)
        : DockView(parent, "view-source", qt_("LaTeX Source"), area, flags)