]> git.lyx.org Git - features.git/blobdiff - src/frontends/qt/GuiDocument.cpp
Re-initiate module filter after dialog re-opening (#12128)
[features.git] / src / frontends / qt / GuiDocument.cpp
index 281bab38703f38243886db6dce49f3c5ee42862e..515d30f592fcc36218f76bcfc7b01db9ddca285c 100644 (file)
@@ -4,7 +4,7 @@
  * Licence details can be found in the file COPYING.
  *
  * \author Edwin Leuven
- * \author Richard Heck (modules)
+ * \author Richard Kimberly Heck (modules)
  *
  * Full author contact details are available in file CREDITS.
  */
@@ -162,7 +162,9 @@ bool is_backgroundcolor;
 lyx::RGBColor set_fontcolor;
 bool is_fontcolor;
 lyx::RGBColor set_notefontcolor;
+bool is_notefontcolor;
 lyx::RGBColor set_boxbgcolor;
+bool is_boxbgcolor;
 bool forced_fontspec_activation;
 
 } // anonymous namespace
@@ -1673,7 +1675,7 @@ GuiDocument::GuiDocument(GuiView & lv)
                modulesModule->availableLV, SLOT(setFocus()));
 #else
        connect(filter_, &FancyLineEdit::downPressed,
-               modulesModule->availableLV, [=](){ focusAndHighlight(modulesModule->availableLV); });
+               modulesModule->availableLV, [this](){ focusAndHighlight(modulesModule->availableLV); });
 #endif
 
 
@@ -1894,6 +1896,7 @@ void GuiDocument::filterModules(QString const & str)
                        item->setData(m.name, Qt::DisplayRole);
                        item->setData(toqstr(m.id), Qt::UserRole);
                        item->setData(m.description, Qt::ToolTipRole);
+                       item->setEditable(false);
                        if (m.local)
                                item->setIcon(user_icon);
                        else
@@ -2079,6 +2082,30 @@ void GuiDocument::setMargins()
                marginsModule->marginCB->setChecked(!bp_.use_geometry);
                setCustomMargins(!bp_.use_geometry);
        }
+
+       // set some placeholder text that hint on defaults
+       QString const placeholder = marginsModule->marginCB->isChecked() ?
+               qt_("Class defaults") : qt_("Package defaults");
+       // set tooltip depending on gemoetry state
+       QString const tooltip = marginsModule->marginCB->isChecked() ?
+               qt_("If no value is given, the defaults as set by the class are used.")
+               : qt_("If no value is given, the defaults as set by the geometry package or a package/class overriding geometry's defaults are used.");
+       marginsModule->topLE->setPlaceholderText(placeholder);
+       marginsModule->bottomLE->setPlaceholderText(placeholder);
+       marginsModule->innerLE->setPlaceholderText(placeholder);
+       marginsModule->outerLE->setPlaceholderText(placeholder);
+       marginsModule->headheightLE->setPlaceholderText(placeholder);
+       marginsModule->headsepLE->setPlaceholderText(placeholder);
+       marginsModule->footskipLE->setPlaceholderText(placeholder);
+       marginsModule->columnsepLE->setPlaceholderText(placeholder);
+       marginsModule->topLE->setToolTip(tooltip);
+       marginsModule->bottomLE->setToolTip(tooltip);
+       marginsModule->innerLE->setToolTip(tooltip);
+       marginsModule->outerLE->setToolTip(tooltip);
+       marginsModule->headheightLE->setToolTip(tooltip);
+       marginsModule->headsepLE->setToolTip(tooltip);
+       marginsModule->footskipLE->setToolTip(tooltip);
+       marginsModule->columnsepLE->setToolTip(tooltip);
 }
 
 
@@ -2141,6 +2168,31 @@ void GuiDocument::setCustomMargins(bool custom)
        marginsModule->columnsepL->setEnabled(enableColSep);
        marginsModule->columnsepLE->setEnabled(enableColSep);
        marginsModule->columnsepUnit->setEnabled(enableColSep);
+
+       // set some placeholder text that hint on defaults
+       QString const placeholder = marginsModule->marginCB->isChecked() ?
+               qt_("Class defaults") : qt_("Package defaults");
+       // set tooltip depending on gemoetry state
+       QString const tooltip = marginsModule->marginCB->isChecked() ?
+               qt_("If no value is given, the defaults as set by the class are used.")
+               : qt_("If no value is given, the defaults as set by the geometry package or a package/class overriding geometry's defaults are used.");
+       marginsModule->topLE->setPlaceholderText(placeholder);
+       marginsModule->bottomLE->setPlaceholderText(placeholder);
+       marginsModule->innerLE->setPlaceholderText(placeholder);
+       marginsModule->outerLE->setPlaceholderText(placeholder);
+       marginsModule->headheightLE->setPlaceholderText(placeholder);
+       marginsModule->headsepLE->setPlaceholderText(placeholder);
+       marginsModule->footskipLE->setPlaceholderText(placeholder);
+       marginsModule->columnsepLE->setPlaceholderText(placeholder);
+       marginsModule->topLE->setToolTip(tooltip);
+       marginsModule->bottomLE->setToolTip(tooltip);
+       marginsModule->innerLE->setToolTip(tooltip);
+       marginsModule->outerLE->setToolTip(tooltip);
+       marginsModule->headheightLE->setToolTip(tooltip);
+       marginsModule->headsepLE->setToolTip(tooltip);
+       marginsModule->footskipLE->setToolTip(tooltip);
+       marginsModule->columnsepLE->setToolTip(tooltip);
+
 }
 
 
@@ -2215,6 +2267,7 @@ void GuiDocument::changeNoteFontColor()
                colorButtonStyleSheet(newColor));
        // save color
        set_notefontcolor = rgbFromHexName(fromqstr(newColor.name()));
+       is_notefontcolor = true;
        change_adaptor();
 }
 
@@ -2225,6 +2278,7 @@ void GuiDocument::deleteNoteFontColor()
        theApp()->getRgbColor(Color_greyedouttext, set_notefontcolor);
        colorModule->noteFontColorPB->setStyleSheet(
                colorButtonStyleSheet(rgb2qcolor(set_notefontcolor)));
+       is_notefontcolor = false;
        change_adaptor();
 }
 
@@ -2240,6 +2294,7 @@ void GuiDocument::changeBoxBackgroundColor()
                colorButtonStyleSheet(newColor));
        // save color
        set_boxbgcolor = rgbFromHexName(fromqstr(newColor.name()));
+       is_boxbgcolor = true;
        change_adaptor();
 }
 
@@ -2250,6 +2305,7 @@ void GuiDocument::deleteBoxBackgroundColor()
        theApp()->getRgbColor(Color_shadedbg, set_boxbgcolor);
        colorModule->boxBackgroundPB->setStyleSheet(
                colorButtonStyleSheet(rgb2qcolor(set_boxbgcolor)));
+       is_boxbgcolor = false;
        change_adaptor();
 }
 
@@ -2267,7 +2323,7 @@ void GuiDocument::updateQuoteStyles(bool const set)
        bool has_default = false;
        for (int i = 0; i < quoteparams.stylescount(); ++i) {
                QuoteStyle qs = QuoteStyle(i);
-               if (qs == QuoteStyle::DynamicQuotes)
+               if (qs == QuoteStyle::Dynamic)
                        continue;
                bool const langdef = (qs == def);
                if (langdef) {
@@ -3467,7 +3523,9 @@ void GuiDocument::applyView()
        bp_.fontcolor = set_fontcolor;
        bp_.isfontcolor = is_fontcolor;
        bp_.notefontcolor = set_notefontcolor;
+       bp_.isnotefontcolor = is_notefontcolor;
        bp_.boxbgcolor = set_boxbgcolor;
+       bp_.isboxbgcolor = is_boxbgcolor;
 
        // numbering
        if (bp_.documentClass().hasTocLevels()) {
@@ -3985,6 +4043,7 @@ void GuiDocument::paramsToDialog()
        colorModule->noteFontColorPB->setStyleSheet(
                colorButtonStyleSheet(rgb2qcolor(bp_.notefontcolor)));
        set_notefontcolor = bp_.notefontcolor;
+       is_notefontcolor = bp_.isnotefontcolor;
 
        if (bp_.isbackgroundcolor) {
                colorModule->backgroundPB->setStyleSheet(
@@ -3996,6 +4055,7 @@ void GuiDocument::paramsToDialog()
        colorModule->boxBackgroundPB->setStyleSheet(
                colorButtonStyleSheet(rgb2qcolor(bp_.boxbgcolor)));
        set_boxbgcolor = bp_.boxbgcolor;
+       is_boxbgcolor = bp_.isboxbgcolor;
 
        // numbering
        int const min_toclevel = documentClass().min_toclevel();
@@ -4470,6 +4530,10 @@ void GuiDocument::paramsToDialog()
        // clear changed branches cache
        changedBranches_.clear();
 
+       // re-initiate module filter
+       if (!filter_->text().isEmpty())
+               moduleFilterPressed();
+
        // reset trackers
        nonModuleChanged_ = false;
        shellescapeChanged_ = false;
@@ -4930,7 +4994,7 @@ void GuiDocument::dispatchParams()
                FileName const master_file = support::makeAbsPath(params().master,
                           support::onlyPath(buffer().absFileName()));
                if (isLyXFileName(master_file.absFileName())) {
-                       Buffer * master = checkAndLoadLyXFile(master_file);
+                       Buffer * master = checkAndLoadLyXFile(master_file, true);
                        if (master) {
                                if (master->isChild(const_cast<Buffer *>(&buffer())))
                                        const_cast<Buffer &>(buffer()).setParent(master);
@@ -4959,7 +5023,13 @@ void GuiDocument::dispatchParams()
                for (; it != end; ++it) {
                        docstring const & current_branch = it->branch();
                        Branch const * branch = branchlist.find(current_branch);
-                       string const x11hexname = X11hexname(branch->color());
+                       string const bcolor = branch->color();
+                       RGBColor rgbcol;
+                       if (bcolor.size() == 7 && bcolor[0] == '#')
+                               rgbcol = lyx::rgbFromHexName(bcolor);
+                       else
+                               guiApp->getRgbColor(lcolor.getFromLyXName(bcolor), rgbcol);
+                       string const x11hexname = X11hexname(rgbcol);
                        // display the new color
                        docstring const str = current_branch + ' ' + from_ascii(x11hexname);
                        dispatch(FuncRequest(LFUN_SET_COLOR, str));
@@ -5207,10 +5277,6 @@ void GuiDocument::setOutputSync(bool on)
 }
 
 
-
-Dialog * createGuiDocument(GuiView & lv) { return new GuiDocument(lv); }
-
-
 } // namespace frontend
 } // namespace lyx