]> git.lyx.org Git - features.git/commitdiff
adjust text display width in windowed mode
authorchillenb <chillenb.lists@gmail.com>
Fri, 21 Oct 2022 22:11:12 +0000 (18:11 -0400)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Thu, 27 Oct 2022 15:49:43 +0000 (17:49 +0200)
lib/configure.py
lib/scripts/prefs2prefs_prefs.py
src/BufferView.cpp
src/LyXRC.cpp
src/LyXRC.h
src/frontends/qt/GuiPrefs.cpp
src/frontends/qt/GuiPrefs.h
src/frontends/qt/ui/PrefEditUi.ui

index 727fb03868a4325915d31eb5c7a78e5b75122af4..615d294df1e9a2cd8df91f073e13b2bac0f30a5b 100644 (file)
@@ -2002,7 +2002,7 @@ if __name__ == '__main__':
     lyx_check_config = True
     lyx_kpsewhich = True
     outfile = 'lyxrc.defaults'
-    lyxrc_fileformat = 36
+    lyxrc_fileformat = 37
     rc_entries = ''
     lyx_keep_temps = False
     version_suffix = ''
index 78870a3402f1039afc64011ff35b622579418470..a5a3a7dbf1bc418bffd00c0afce51047520dd82f 100644 (file)
 #   (the new default is true, so this keeps behavior the same for 
 #   existing users)
 
+# Incremented to format 37, by chillenb
+#  Remove \fullscreen_width
+#  Remove \fullscreen_limit
+#  Add \screen_width
+#  Add \screen_limit
+
 # NOTE: The format should also be updated in LYXRC.cpp and
 # in configure.py (search for lyxrc_fileformat).
 
@@ -492,6 +498,12 @@ def add_spellcheck_default(lines):
                        return
        lines.append("\\spellcheck_continuously false")
 
+def remove_fullscreen_widthlimit(line):
+       lower = line.lower()
+       if lower.startswith("\\fullscreen_width") or lower.startswith("\\fullscreen_limit"):
+               return (True, "")
+       return no_match
+
 # End conversions for LyX 2.3 to 2.4
 ####################################
 
@@ -542,5 +554,6 @@ conversions = [
        [ 33, []],
        [ 34, [rename_cyrillic_kmap_files]],
        [ 35, [add_dark_color]],
-       [ 36, [add_spellcheck_default]]
+       [ 36, [add_spellcheck_default]],
+       [ 37, [remove_fullscreen_widthlimit]]
 ]
index 52baf098effbc620d1b7482af0db482005799cfc..b36b8ee5b6a694fc226862fead4a719e370946bb 100644 (file)
@@ -342,11 +342,14 @@ int BufferView::defaultMargin() const
 
 int BufferView::rightMargin() const
 {
-       // The additional test for the case the outliner is opened.
-       if (full_screen_ && lyxrc.full_screen_limit)
-               return max(defaultMargin(), (width_ - lyxrc.full_screen_width) / 2);
+       const int screen_width = inPixels(lyxrc.screen_width);
 
-       return defaultMargin();
+       // The additional test for the case the outliner is opened.
+       if (!lyxrc.screen_limit || width_ < screen_width + 2 * defaultMargin()) {
+               return defaultMargin();
+       } else {
+               return (width_ - screen_width) / 2;
+       }
 }
 
 
index 13164373f68ff416bdeb2407756461ada94cd4e9..6e962c350628c05672106cc519f528e95c37c507 100644 (file)
@@ -60,7 +60,7 @@ namespace {
 
 // The format should also be updated in configure.py, and conversion code
 // should be added to prefs2prefs_prefs.py.
-static unsigned int const LYXRC_FILEFORMAT = 36; // rkh: spellcheck_continuously default
+static unsigned int const LYXRC_FILEFORMAT = 37; // chillenb: screen_width and screen_limit
 // when adding something to this array keep it sorted!
 LexerKeyword lyxrcTags[] = {
        { "\\accept_compound", LyXRC::RC_ACCEPT_COMPOUND },
@@ -116,13 +116,11 @@ LexerKeyword lyxrcTags[] = {
        { "\\format", LyXRC::RC_FILEFORMAT },
        { "\\forward_search_dvi", LyXRC::RC_FORWARD_SEARCH_DVI },
        { "\\forward_search_pdf", LyXRC::RC_FORWARD_SEARCH_PDF },
-       { "\\fullscreen_limit", LyXRC::RC_FULL_SCREEN_LIMIT },
        { "\\fullscreen_menubar", LyXRC::RC_FULL_SCREEN_MENUBAR },
        { "\\fullscreen_scrollbar", LyXRC::RC_FULL_SCREEN_SCROLLBAR },
        { "\\fullscreen_statusbar", LyXRC::RC_FULL_SCREEN_STATUSBAR },
        { "\\fullscreen_tabbar", LyXRC::RC_FULL_SCREEN_TABBAR },
        { "\\fullscreen_toolbars", LyXRC::RC_FULL_SCREEN_TOOLBARS },
-       { "\\fullscreen_width", LyXRC::RC_FULL_SCREEN_WIDTH },
        { "\\group_layouts", LyXRC::RC_GROUP_LAYOUTS },
        { "\\gui_language", LyXRC::RC_GUI_LANGUAGE },
        { "\\hunspelldir_path", LyXRC::RC_HUNSPELLDIR_PATH },
@@ -177,6 +175,8 @@ LexerKeyword lyxrcTags[] = {
        { "\\screen_font_sizes", LyXRC::RC_SCREEN_FONT_SIZES },
        { "\\screen_font_typewriter", LyXRC::RC_SCREEN_FONT_TYPEWRITER },
        { "\\screen_font_typewriter_foundry", LyXRC::RC_SCREEN_FONT_TYPEWRITER_FOUNDRY },
+       { "\\screen_limit", LyXRC::RC_SCREEN_LIMIT },
+       { "\\screen_width", LyXRC::RC_SCREEN_WIDTH },
        { "\\screen_zoom", LyXRC::RC_SCREEN_ZOOM },
        { "\\scroll_below_document", LyXRC::RC_SCROLL_BELOW_DOCUMENT },
        { "\\scroll_wheel_zoom", LyXRC::RC_SCROLL_WHEEL_ZOOM },
@@ -1038,8 +1038,8 @@ LyXRC::ReturnValues LyXRC::read(Lexer & lexrc, bool check_format)
                case RC_GROUP_LAYOUTS:
                        lexrc >> group_layouts;
                        break;
-               case RC_FULL_SCREEN_LIMIT:
-                       lexrc >> full_screen_limit;
+               case RC_SCREEN_LIMIT:
+                       lexrc >> screen_limit;
                        break;
                case RC_FULL_SCREEN_TOOLBARS:
                        lexrc >> full_screen_toolbars;
@@ -1056,8 +1056,8 @@ LyXRC::ReturnValues LyXRC::read(Lexer & lexrc, bool check_format)
                case RC_FULL_SCREEN_MENUBAR:
                        lexrc >> full_screen_menubar;
                        break;
-               case RC_FULL_SCREEN_WIDTH:
-                       lexrc >> full_screen_width;
+               case RC_SCREEN_WIDTH:
+                       lexrc >> screen_width;
                        break;
                case RC_OPEN_BUFFERS_IN_TABS:
                        lexrc >> open_buffers_in_tabs;
@@ -1920,11 +1920,11 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) c
                if (tag != RC_LAST)
                        break;
                // fall through
-       case RC_FULL_SCREEN_LIMIT:
+       case RC_SCREEN_LIMIT:
                if (ignore_system_lyxrc ||
-                   full_screen_limit != system_lyxrc.full_screen_limit) {
-                       os << "\\fullscreen_limit "
-                          << convert<string>(full_screen_limit)
+                   screen_limit != system_lyxrc.screen_limit) {
+                       os << "\\screen_limit "
+                          << convert<string>(screen_limit)
                           << '\n';
                }
                if (tag != RC_LAST)
@@ -1980,11 +1980,11 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) c
                if (tag != RC_LAST)
                        break;
                // fall through
-       case RC_FULL_SCREEN_WIDTH:
+       case RC_SCREEN_WIDTH:
                if (ignore_system_lyxrc ||
-                   full_screen_width != system_lyxrc.full_screen_width) {
-                       os << "\\fullscreen_width "
-                          << convert<string>(full_screen_width)
+                   screen_width != system_lyxrc.screen_width) {
+                       os << "\\screen_width "
+                          << screen_width.asString()
                           << '\n';
                }
                if (tag != RC_LAST)
@@ -3064,13 +3064,13 @@ void actOnUpdatedPrefs(LyXRC const & lyxrc_orig, LyXRC const & lyxrc_new)
        case LyXRC::RC_SINGLE_CLOSE_TAB_BUTTON:
        case LyXRC::RC_SINGLE_INSTANCE:
        case LyXRC::RC_SORT_LAYOUTS:
-       case LyXRC::RC_FULL_SCREEN_LIMIT:
+       case LyXRC::RC_SCREEN_LIMIT:
        case LyXRC::RC_FULL_SCREEN_SCROLLBAR:
        case LyXRC::RC_FULL_SCREEN_MENUBAR:
        case LyXRC::RC_FULL_SCREEN_STATUSBAR:
        case LyXRC::RC_FULL_SCREEN_TABBAR:
        case LyXRC::RC_FULL_SCREEN_TOOLBARS:
-       case LyXRC::RC_FULL_SCREEN_WIDTH:
+       case LyXRC::RC_SCREEN_WIDTH:
        case LyXRC::RC_VISUAL_CURSOR:
        case LyXRC::RC_CLOSE_BUFFER_WITH_LAST_VIEW:
        case LyXRC::RC_VIEWER:
index 6e82a6def98e9db9ba5e6c07225616d60a02f17c..1119b181c3349df589e673ca8e4dc89e0c3f88ec 100644 (file)
@@ -90,13 +90,13 @@ public:
                RC_FILEFORMAT,
                RC_FORWARD_SEARCH_DVI,
                RC_FORWARD_SEARCH_PDF,
-               RC_FULL_SCREEN_LIMIT,
+               RC_SCREEN_LIMIT,
                RC_FULL_SCREEN_SCROLLBAR,
                RC_FULL_SCREEN_STATUSBAR,
                RC_FULL_SCREEN_TABBAR,
                RC_FULL_SCREEN_MENUBAR,
                RC_FULL_SCREEN_TOOLBARS,
-               RC_FULL_SCREEN_WIDTH,
+               RC_SCREEN_WIDTH,
                RC_GEOMETRY_SESSION,
                RC_GROUP_LAYOUTS,
                RC_GUI_LANGUAGE,
@@ -511,9 +511,9 @@ public:
        /// Toggle statusbar in fullscreen mode?
        bool full_screen_statusbar = true;
        /// Limit the text width?
-       bool full_screen_limit = false;
-       /// Width of limited screen (in pixels) in fullscreen mode
-       int full_screen_width = 700;
+       bool screen_limit = false;
+    /// Width of limited screen width 
+       Length screen_width = Length(7, Length::IN); 
        ///
        bool completion_cursor_text = true;
        ///
index 5fa3b940d475c1983e5fccf3d7411b1fba701f91..3b2a1c2c3517fe054c7ef710a3e4fa92fab51130 100644 (file)
@@ -33,6 +33,7 @@
 #include "FuncRequest.h"
 #include "KeySequence.h"
 #include "Language.h"
+#include "LengthCombo.h"
 #include "LyXAction.h"
 #include "LyX.h"
 #include "PanelStack.h"
@@ -2812,7 +2813,9 @@ PrefEdit::PrefEdit(GuiPreferences * form)
                this, SIGNAL(changed()));
        connect(citationSearchLE, SIGNAL(textChanged(QString)),
                this, SIGNAL(changed()));
-       connect(fullscreenWidthSB, SIGNAL(valueChanged(int)),
+       connect(screenWidthLE, SIGNAL(textChanged(QString)),
+               this, SIGNAL(changed()));
+       connect(screenWidthUnitCO, SIGNAL(selectionChanged(lyx::Length::UNIT)), 
                this, SIGNAL(changed()));
        connect(toggleTabbarCB, SIGNAL(toggled(bool)),
                this, SIGNAL(changed()));
@@ -2827,10 +2830,11 @@ PrefEdit::PrefEdit(GuiPreferences * form)
 }
 
 
-void PrefEdit::on_fullscreenLimitCB_toggled(bool const state)
+void PrefEdit::on_screenLimitCB_toggled(bool const state)
 {
-       fullscreenWidthSB->setEnabled(state);
-       fullscreenWidthLA->setEnabled(state);
+       screenWidthLE->setEnabled(state);
+       screenWidthLA->setEnabled(state);
+       screenWidthUnitCO->setEnabled(state);
        changed();
 }
 
@@ -2864,8 +2868,8 @@ void PrefEdit::applyRC(LyXRC & rc) const
        rc.full_screen_statusbar = toggleStatusbarCB->isChecked();
        rc.full_screen_tabbar = toggleTabbarCB->isChecked();
        rc.full_screen_menubar = toggleMenubarCB->isChecked();
-       rc.full_screen_width = fullscreenWidthSB->value();
-       rc.full_screen_limit = fullscreenLimitCB->isChecked();
+    rc.screen_width = Length(widgetsToLength(screenWidthLE, screenWidthUnitCO)); 
+    rc.screen_limit = screenLimitCB->isChecked(); 
 }
 
 
@@ -2888,10 +2892,11 @@ void PrefEdit::updateRC(LyXRC const & rc)
        toggleToolbarsCB->setChecked(rc.full_screen_toolbars);
        toggleTabbarCB->setChecked(rc.full_screen_tabbar);
        toggleMenubarCB->setChecked(rc.full_screen_menubar);
-       fullscreenWidthSB->setValue(rc.full_screen_width);
-       fullscreenLimitCB->setChecked(rc.full_screen_limit);
-       fullscreenWidthSB->setEnabled(rc.full_screen_limit);
-       fullscreenWidthLA->setEnabled(rc.full_screen_limit);
+       lengthToWidgets(screenWidthLE, screenWidthUnitCO, rc.screen_width, Length::defaultUnit());
+       screenWidthUnitCO->setEnabled(rc.screen_limit);
+       screenLimitCB->setChecked(rc.screen_limit);
+       screenWidthLE->setEnabled(rc.screen_limit);
+       screenWidthLA->setEnabled(rc.screen_limit); 
 }
 
 
index 5fac6bc5e9a9b8ff67d3d9d6e079e15cac7def34..d23759089e6160f915d8879e4022600cc6cd5eb9 100644 (file)
@@ -451,7 +451,7 @@ public:
        void updateRC(LyXRC const & rc) override;
 
 public Q_SLOTS:
-       void on_fullscreenLimitCB_toggled(bool);
+       void on_screenLimitCB_toggled(bool);
        void on_citationSearchCB_toggled(bool);
 };
 
index bcedaf8c517736ed325ab2be63f687786501beb8..7a7e30bae1beaa5f9be1efa1608e0cd9c0f0d300 100644 (file)
         </property>
        </widget>
       </item>
+      <item row="10" column="0" colspan="3">
+        <layout class="QHBoxLayout" name="horizontalLayout_4">
+         <item>
+          <widget class="QCheckBox" name="screenLimitCB">
+           <property name="text">
+            <string>&amp;Limit text width</string>
+           </property>
+          </widget>
+         </item>
+         <item>
+          <spacer name="horizontalSpacer_9">
+           <property name="orientation">
+            <enum>Qt::Horizontal</enum>
+           </property>
+           <property name="sizeType">
+            <enum>QSizePolicy::Fixed</enum>
+           </property>
+           <property name="sizeHint" stdset="0">
+            <size>
+             <width>10</width>
+             <height>20</height>
+            </size>
+           </property>
+          </spacer>
+         </item>
+         <item>
+           <widget class="QLabel" name="screenWidthLA">
+             <property name="text">
+               <string>Screen used:</string>
+             </property>
+           </widget>
+         </item>
+         <item>
+           <widget class="lyx::frontend::LengthCombo" name="screenWidthUnitCO" />
+         </item>
+         <item>
+           <widget class="QLineEdit" name="screenWidthLE" />
+         </item>
+         <item>
+          <spacer name="horizontalSpacer_2">
+           <property name="orientation">
+            <enum>Qt::Horizontal</enum>
+           </property>
+           <property name="sizeHint" stdset="0">
+            <size>
+             <width>157</width>
+             <height>20</height>
+            </size>
+           </property>
+          </spacer>
+         </item>
+        </layout>
+       </item>
      </layout>
     </widget>
    </item>
         </property>
        </spacer>
       </item>
-      <item row="2" column="0" colspan="6">
-       <layout class="QHBoxLayout" name="horizontalLayout_4">
-        <item>
-         <widget class="QCheckBox" name="fullscreenLimitCB">
-          <property name="text">
-           <string>&amp;Limit text width</string>
-          </property>
-         </widget>
-        </item>
-        <item>
-         <spacer name="horizontalSpacer_9">
-          <property name="orientation">
-           <enum>Qt::Horizontal</enum>
-          </property>
-          <property name="sizeType">
-           <enum>QSizePolicy::Fixed</enum>
-          </property>
-          <property name="sizeHint" stdset="0">
-           <size>
-            <width>10</width>
-            <height>20</height>
-           </size>
-          </property>
-         </spacer>
-        </item>
-        <item>
-         <widget class="QLabel" name="fullscreenWidthLA">
-          <property name="text">
-           <string>Screen used (pi&amp;xels):</string>
-          </property>
-          <property name="buddy">
-           <cstring>fullscreenWidthSB</cstring>
-          </property>
-         </widget>
-        </item>
-        <item>
-         <widget class="QSpinBox" name="fullscreenWidthSB">
-          <property name="minimum">
-           <number>0</number>
-          </property>
-          <property name="maximum">
-           <number>10000</number>
-          </property>
-          <property name="singleStep">
-           <number>10</number>
-          </property>
-          <property name="value">
-           <number>700</number>
-          </property>
-         </widget>
-        </item>
-        <item>
-         <spacer name="horizontalSpacer_2">
-          <property name="orientation">
-           <enum>Qt::Horizontal</enum>
-          </property>
-          <property name="sizeHint" stdset="0">
-           <size>
-            <width>157</width>
-            <height>20</height>
-           </size>
-          </property>
-         </spacer>
-        </item>
-       </layout>
-      </item>
       <item row="0" column="0">
        <widget class="QCheckBox" name="toggleToolbarsCB">
         <property name="sizePolicy">
   </layout>
  </widget>
  <layoutdefault spacing="4" margin="9"/>
+ <customwidgets> 
+  <customwidget> 
+    <class>lyx::frontend::LengthCombo</class> 
+    <extends>QComboBox</extends> 
+    <header>LengthCombo.h</header> 
+  </customwidget> 
+ </customwidgets> 
  <tabstops>
   <tabstop>cursorFollowsCB</tabstop>
   <tabstop>cursorWidthSB</tabstop>