#include "ConverterCache.h"
#include "FontEnums.h"
#include "FuncRequest.h"
-#include "KeyMap.h"
#include "KeySequence.h"
#include "Language.h"
+#include "LengthCombo.h"
#include "LyXAction.h"
#include "LyX.h"
#include "PanelStack.h"
#include "support/os.h"
#include "support/Package.h"
-#include "graphics/GraphicsTypes.h"
-
#include "frontends/alert.h"
#include "frontends/Application.h"
#include "frontends/FontLoader.h"
toqstr(makeRelPath(qstring_to_ucs4(outname), qstring_to_ucs4(relpath)));
QString testname = reloutname;
- testname.remove(QRegExp("^(\\.\\./)+"));
+ testname.remove(QRegularExpression("^(\\.\\./)+"));
if (testname.contains("/"))
return outname;
name = mangled;
foundry.clear();
} else {
- name = mangled.substr(0, idx - 1),
+ name = mangled.substr(0, idx - 1);
foundry = mangled.substr(idx + 1, mangled.size() - idx - 2);
}
}
/////////////////////////////////////////////////////////////////////
PrefOutput::PrefOutput(GuiPreferences * form)
- : PrefModule(catOutput, N_("General"), form)
+ : PrefModule(catOutput, N_("General[[settings]]"), form)
{
setupUi(this);
this, SIGNAL(changed()));
// reveal checkbox for switching Ctrl and Meta on Mac:
- bool swapcb = false;
#ifdef Q_OS_MAC
-#if QT_VERSION > 0x040600
- swapcb = true;
-#endif
+ dontswapCB->setVisible(true);
+#else
+ dontswapCB->setVisible(false);
#endif
- dontswapCB->setVisible(swapcb);
}
{
setupUi(this);
+#if QT_VERSION < 0x050e00
connect(screenRomanCO, SIGNAL(activated(QString)),
this, SLOT(selectRoman(QString)));
connect(screenSansCO, SIGNAL(activated(QString)),
this, SLOT(selectSans(QString)));
connect(screenTypewriterCO, SIGNAL(activated(QString)),
this, SLOT(selectTypewriter(QString)));
+#else
+ connect(screenRomanCO, SIGNAL(textActivated(QString)),
+ this, SLOT(selectRoman(QString)));
+ connect(screenSansCO, SIGNAL(textActivated(QString)),
+ this, SLOT(selectSans(QString)));
+ connect(screenTypewriterCO, SIGNAL(textActivated(QString)),
+ this, SLOT(selectTypewriter(QString)));
+#endif
+#if QT_VERSION >= 0x060000
+ const QStringList families(QFontDatabase::families());
+#else
QFontDatabase fontdb;
- QStringList families(fontdb.families());
- for (QStringList::Iterator it = families.begin(); it != families.end(); ++it) {
- screenRomanCO->addItem(*it);
- screenSansCO->addItem(*it);
- screenTypewriterCO->addItem(*it);
+ const QStringList families(fontdb.families());
+#endif
+ for (auto const & family : families) {
+ screenRomanCO->addItem(family);
+ screenSansCO->addItem(family);
+ screenTypewriterCO->addItem(family);
}
+#if QT_VERSION < 0x050e00
connect(screenRomanCO, SIGNAL(activated(QString)),
this, SIGNAL(changed()));
connect(screenSansCO, SIGNAL(activated(QString)),
this, SIGNAL(changed()));
connect(screenTypewriterCO, SIGNAL(activated(QString)),
this, SIGNAL(changed()));
+#else
+ connect(screenRomanCO, SIGNAL(textActivated(QString)),
+ this, SIGNAL(changed()));
+ connect(screenSansCO, SIGNAL(textActivated(QString)),
+ this, SIGNAL(changed()));
+ connect(screenTypewriterCO, SIGNAL(textActivated(QString)),
+ this, SIGNAL(changed()));
+#endif
connect(screenZoomSB, SIGNAL(valueChanged(int)),
this, SIGNAL(changed()));
connect(screenTinyED, SIGNAL(textChanged(QString)),
continue;
lcolors_.push_back(lc);
}
- qSort(lcolors_.begin(), lcolors_.end(), ColorSorter);
+ sort(lcolors_.begin(), lcolors_.end(), ColorSorter);
vector<ColorCode>::const_iterator cit = lcolors_.begin();
vector<ColorCode>::const_iterator const end = lcolors_.end();
for (; cit != end; ++cit) {
void PrefColors::updateRC(LyXRC const & rc)
{
for (size_type i = 0; i < lcolors_.size(); ++i) {
- QColor color = QColor(guiApp->colorCache().get(lcolors_[i], false));
+ QColor color = guiApp->colorCache().get(lcolors_[i], false);
QPixmap coloritem(32, 32);
coloritem.fill(color);
lyxObjectsLW->item(int(i))->setIcon(QIcon(coloritem));
}
-bool PrefColors::setColor(int const row, QColor const new_color,
- QString const old_color)
+bool PrefColors::setColor(int const row, QColor const & new_color,
+ QString const & old_color)
{
if (new_color.isValid() && new_color.name() != old_color) {
newcolors_[size_t(row)] = new_color.name();
}
-bool PrefColors::isDefaultColor(int const row, QString const color)
+bool PrefColors::isDefaultColor(int const row, QString const & color)
{
return color == getDefaultColorByRow(row).name();
}
QColor PrefColors::getDefaultColorByRow(int const row)
{
ColorSet const defaultcolor;
- return defaultcolor.getX11Name(lcolors_[size_t(row)]).c_str();
+ return defaultcolor.getX11HexName(lcolors_[size_t(row)],
+ guiApp->colorCache().isDarkMode()).c_str();
}
connect(instantPreviewCO, SIGNAL(activated(int)), this, SIGNAL(changed()));
connect(previewSizeSB, SIGNAL(valueChanged(double)), this, SIGNAL(changed()));
connect(paragraphMarkerCB, SIGNAL(toggled(bool)), this, SIGNAL(changed()));
+ connect(ctAdditionsUnderlinedCB, SIGNAL(toggled(bool)), this, SIGNAL(changed()));
}
rc.display_graphics = displayGraphicsCB->isChecked();
rc.preview_scale_factor = previewSizeSB->value();
rc.paragraph_markers = paragraphMarkerCB->isChecked();
+ rc.ct_additions_underlined = ctAdditionsUnderlinedCB->isChecked();
// FIXME!! The graphics cache no longer has a changeDisplay method.
#if 0
displayGraphicsCB->setChecked(rc.display_graphics);
previewSizeSB->setValue(rc.preview_scale_factor);
paragraphMarkerCB->setChecked(rc.paragraph_markers);
+ ctAdditionsUnderlinedCB->setChecked(rc.ct_additions_underlined);
previewSizeSB->setEnabled(
rc.display_graphics
&& rc.preview != LyXRC::PREVIEW_OFF);
this, SLOT(updateConverter()));
connect(convertersLW, SIGNAL(currentRowChanged(int)),
this, SLOT(switchConverter()));
+#if QT_VERSION < 0x050e00
connect(converterFromCO, SIGNAL(activated(QString)),
this, SLOT(changeConverter()));
connect(converterToCO, SIGNAL(activated(QString)),
this, SLOT(changeConverter()));
+#else
+ connect(converterFromCO, SIGNAL(textActivated(QString)),
+ this, SLOT(changeConverter()));
+ connect(converterToCO, SIGNAL(textActivated(QString)),
+ this, SLOT(changeConverter()));
+#endif
connect(converterED, SIGNAL(textEdited(QString)),
this, SLOT(changeConverter()));
connect(converterFlagED, SIGNAL(textEdited(QString)),
}
int ret = frontend::Alert::prompt(
- _("SECURITY WARNING!"), _("Unchecking this option has the effect that potentially harmful converters would be run without asking your permission first. This is UNSAFE and NOT recommended, unless you know what you are doing. Are you sure you would like to proceed ? The recommended and safe answer is NO!"),
+ _("SECURITY WARNING!"), _("Unchecking this option has the effect that potentially harmful converters would be run without asking your permission first. This is UNSAFE and NOT recommended, unless you know what you are doing. Are you sure you would like to proceed? The recommended and safe answer is NO!"),
0, 0, _("&No"), _("&Yes"));
if (ret == 1)
changed();
{
public:
FormatValidator(QWidget *, Formats const & f);
- void fixup(QString & input) const;
- QValidator::State validate(QString & input, int & pos) const;
+ void fixup(QString & input) const override;
+ QValidator::State validate(QString & input, int & pos) const override;
private:
virtual QString toString(Format const & format) const = 0;
int nr() const;
: FormatValidator(parent, f)
{}
private:
- QString toString(Format const & format) const
+ QString toString(Format const & format) const override
{
return toqstr(format.name());
}
: FormatValidator(parent, f)
{}
private:
- QString toString(Format const & format) const
+ QString toString(Format const & format) const override
{
return toqstr(translateIfPossible(format.prettyname()));
}
this, SLOT(updatePrettyname()));
connect(formatsCB->lineEdit(), SIGNAL(textEdited(QString)),
this, SIGNAL(changed()));
+#if QT_VERSION < 0x050e00
connect(defaultFormatCB, SIGNAL(activated(QString)),
this, SIGNAL(changed()));
connect(defaultOTFFormatCB, SIGNAL(activated(QString)),
this, SIGNAL(changed()));
connect(defaultPlatexFormatCB, SIGNAL(activated(QString)),
this, SIGNAL(changed()));
+#else
+ connect(defaultFormatCB, SIGNAL(textActivated(QString)),
+ this, SIGNAL(changed()));
+ connect(defaultOTFFormatCB, SIGNAL(textActivated(QString)),
+ this, SIGNAL(changed()));
+ connect(defaultPlatexFormatCB, SIGNAL(textActivated(QString)),
+ this, SIGNAL(changed()));
+#endif
connect(viewerCO, SIGNAL(activated(int)),
this, SIGNAL(changed()));
connect(editorCO, SIGNAL(activated(int)),
viewerCO->blockSignals(true);
viewerCO->clear();
viewerCO->addItem(qt_("None"), QString());
+ if (os::canAutoOpenFile(f.extension(), os::VIEW))
+ viewerCO->addItem(qt_("System Default"), QString("auto"));
updateComboBox(viewer_alternatives, f.name(), viewerCO);
viewerCO->addItem(qt_("Custom"), QString("custom viewer"));
viewerCO->blockSignals(false);
editorCO->blockSignals(true);
editorCO->clear();
editorCO->addItem(qt_("None"), QString());
+ if (os::canAutoOpenFile(f.extension(), os::EDIT))
+ editorCO->addItem(qt_("System Default"), QString("auto"));
updateComboBox(editor_alternatives, f.name(), editorCO);
editorCO->addItem(qt_("Custom"), QString("custom editor"));
editorCO->blockSignals(false);
this, SIGNAL(changed()));
connect(uiLanguageCO, SIGNAL(activated(int)),
this, SIGNAL(changed()));
- connect(defaultDecimalPointLE, SIGNAL(textChanged(QString)),
+ connect(defaultDecimalSepED, SIGNAL(textChanged(QString)),
+ this, SIGNAL(changed()));
+ connect(defaultDecimalSepCO, SIGNAL(activated(int)),
this, SIGNAL(changed()));
connect(defaultLengthUnitCO, SIGNAL(activated(int)),
this, SIGNAL(changed()));
startCommandED->setValidator(new NoNewLineValidator(startCommandED));
endCommandED->setValidator(new NoNewLineValidator(endCommandED));
- defaultDecimalPointLE->setInputMask("X; ");
- defaultDecimalPointLE->setMaxLength(1);
+ defaultDecimalSepED->setValidator(new QRegularExpressionValidator(QRegularExpression("\\S"), this));
+ defaultDecimalSepED->setMaxLength(1);
defaultLengthUnitCO->addItem(lyx::qt_(unit_name_gui[Length::CM]), Length::CM);
defaultLengthUnitCO->addItem(lyx::qt_(unit_name_gui[Length::IN]), Length::IN);
index.data(Qt::UserRole).toString());
}
uiLanguageCO->blockSignals(false);
+
+ // FIXME: restore this when it works (see discussion in #6450).
+ respectOSkbdCB->hide();
}
void PrefLanguage::on_languagePackageCO_currentIndexChanged(int i)
{
- languagePackageED->setEnabled(i == 2);
+ if (i == 2)
+ languagePackageED->setText(save_langpack_);
+ else if (!languagePackageED->text().isEmpty()) {
+ save_langpack_ = languagePackageED->text();
+ languagePackageED->clear();
+ }
+ languagePackageED->setEnabled(i == 2);
+}
+
+
+void PrefLanguage::on_defaultDecimalSepCO_currentIndexChanged(int i)
+{
+ defaultDecimalSepED->setEnabled(i == 1);
}
rc.language_command_end = fromqstr(endCommandED->text());
rc.gui_language = fromqstr(
uiLanguageCO->itemData(uiLanguageCO->currentIndex()).toString());
- rc.default_decimal_point = fromqstr(defaultDecimalPointLE->text());
+ if (defaultDecimalSepCO->currentIndex() == 0)
+ rc.default_decimal_sep = "locale";
+ else
+ rc.default_decimal_sep = fromqstr(defaultDecimalSepED->text());
rc.default_length_unit = (Length::UNIT) defaultLengthUnitCO->itemData(defaultLengthUnitCO->currentIndex()).toInt();
}
explicitDocLangBeginCB->setChecked(!rc.language_auto_begin);
explicitDocLangEndCB->setChecked(!rc.language_auto_end);
languagePackageCO->setCurrentIndex(rc.language_package_selection);
- languagePackageED->setText(toqstr(rc.language_custom_package));
- languagePackageED->setEnabled(languagePackageCO->currentIndex() == 2);
+ if (languagePackageCO->currentIndex() == 2) {
+ languagePackageED->setText(toqstr(rc.language_custom_package));
+ languagePackageED->setEnabled(true);
+ } else {
+ languagePackageED->clear();
+ save_langpack_ = toqstr(rc.language_custom_package);
+ languagePackageED->setEnabled(false);
+ }
+ defaultDecimalSepED->setEnabled(defaultDecimalSepCO->currentIndex() == 1);
globalCB->setChecked(rc.language_global_options);
startCommandED->setText(toqstr(rc.language_command_begin));
endCommandED->setText(toqstr(rc.language_command_end));
- defaultDecimalPointLE->setText(toqstr(rc.default_decimal_point));
+ if (rc.default_decimal_sep == "locale") {
+ defaultDecimalSepCO->setCurrentIndex(0);
+ defaultDecimalSepED->clear();
+ } else {
+ defaultDecimalSepCO->setCurrentIndex(1);
+ defaultDecimalSepED->setText(toqstr(rc.default_decimal_sep));
+ }
int pos = defaultLengthUnitCO->findData(int(rc.default_length_unit));
defaultLengthUnitCO->setCurrentIndex(pos);
this, SIGNAL(changed()));
connect(tooltipCB, SIGNAL(toggled(bool)),
this, SIGNAL(changed()));
+ connect(toggleTabbarCB, SIGNAL(toggled(bool)),
+ this, SIGNAL(changed()));
+ connect(toggleMenubarCB, SIGNAL(toggled(bool)),
+ this, SIGNAL(changed()));
+ connect(toggleScrollbarCB, SIGNAL(toggled(bool)),
+ this, SIGNAL(changed()));
+ connect(toggleStatusbarCB, SIGNAL(toggled(bool)),
+ this, SIGNAL(changed()));
+ connect(toggleToolbarsCB, SIGNAL(toggled(bool)),
+ this, SIGNAL(changed()));
lastfilesSB->setMaximum(maxlastfiles);
iconSetCO->addItem(qt_("Default"), QString());
iconSetCO->addItem(qt_("Classic"), "classic");
iconSetCO->addItem(qt_("Oxygen"), "oxygen");
-#if (!(defined Q_WS_X11 || defined(QPA_XCB)) || QT_VERSION < 0x040600)
- useSystemThemeIconsCB->hide();
-#endif
+ if (guiApp->platformName() != "xcb"
+ && !guiApp->platformName().contains("wayland"))
+ useSystemThemeIconsCB->hide();
}
rc.use_system_theme_icons = useSystemThemeIconsCB->isChecked();
rc.num_lastfiles = lastfilesSB->value();
rc.use_tooltip = tooltipCB->isChecked();
+ rc.full_screen_toolbars = toggleToolbarsCB->isChecked();
+ rc.full_screen_scrollbar = toggleScrollbarCB->isChecked();
+ rc.full_screen_statusbar = toggleStatusbarCB->isChecked();
+ rc.full_screen_tabbar = toggleTabbarCB->isChecked();
+ rc.full_screen_menubar = toggleMenubarCB->isChecked();
}
uiFileED->setText(toqstr(external_path(rc.ui_file)));
lastfilesSB->setValue(rc.num_lastfiles);
tooltipCB->setChecked(rc.use_tooltip);
+ toggleScrollbarCB->setChecked(rc.full_screen_scrollbar);
+ toggleStatusbarCB->setChecked(rc.full_screen_statusbar);
+ toggleToolbarsCB->setChecked(rc.full_screen_toolbars);
+ toggleTabbarCB->setChecked(rc.full_screen_tabbar);
+ toggleMenubarCB->setChecked(rc.full_screen_menubar);
}
closeLastViewCO->setCurrentIndex(1);
else if (rc.close_buffer_with_last_view == "ask")
closeLastViewCO->setCurrentIndex(2);
+ if (rc.backupdir_path.empty())
+ backupCB->setToolTip(qt_("If this is checked, a backup of the document is created "
+ "in the current working directory. "
+ "The backup file has the same name but the suffix '.lyx~'. "
+ "Note that these files are hidden by default by some file managers. "
+ "A dedicated backup directory can be set in the 'Paths' section."));
+ else {
+ docstring const tip = bformat(_("If this is checked, a backup of the document is created "
+ "in the backup directory (%1$s). "
+ "The backup file has the full original path and name as file name "
+ "and the suffix \'.lyx~\' (e.g., !mydir!filename.lyx~). "
+ "Note that these files are hidden by default by some file managers."),
+ FileName(rc.backupdir_path).absoluteFilePath());
+ backupCB->setToolTip(toqstr(tip));
+ }
}
this, SIGNAL(changed()));
connect(macLikeCursorMovementCB, SIGNAL(clicked()),
this, SIGNAL(changed()));
+ connect(copyCTMarkupCB, SIGNAL(clicked()),
+ this, SIGNAL(changed()));
connect(sortEnvironmentsCB, SIGNAL(clicked()),
this, SIGNAL(changed()));
connect(groupEnvironmentsCB, SIGNAL(clicked()),
this, SIGNAL(changed()));
connect(cursorWidthSB, SIGNAL(valueChanged(int)),
this, SIGNAL(changed()));
- connect(fullscreenLimitGB, SIGNAL(clicked()),
- this, SIGNAL(changed()));
- connect(fullscreenWidthSB, SIGNAL(valueChanged(int)),
+ connect(citationSearchLE, SIGNAL(textChanged(QString)),
this, SIGNAL(changed()));
- connect(toggleTabbarCB, SIGNAL(toggled(bool)),
- this, SIGNAL(changed()));
- connect(toggleMenubarCB, SIGNAL(toggled(bool)),
+ connect(screenWidthLE, SIGNAL(textChanged(QString)),
this, SIGNAL(changed()));
- connect(toggleScrollbarCB, SIGNAL(toggled(bool)),
- this, SIGNAL(changed()));
- connect(toggleStatusbarCB, SIGNAL(toggled(bool)),
- this, SIGNAL(changed()));
- connect(toggleToolbarsCB, SIGNAL(toggled(bool)),
+ connect(screenWidthUnitCO, SIGNAL(selectionChanged(lyx::Length::UNIT)),
this, SIGNAL(changed()));
}
+void PrefEdit::on_screenLimitCB_toggled(bool const state)
+{
+ screenWidthLE->setEnabled(state);
+ screenWidthUnitCO->setEnabled(state);
+ changed();
+}
+
+
+void PrefEdit::on_citationSearchCB_toggled(bool const state)
+{
+ citationSearchLE->setEnabled(state);
+ citationSearchLA->setEnabled(state);
+ changed();
+}
+
+
void PrefEdit::applyRC(LyXRC & rc) const
{
rc.cursor_follows_scrollbar = cursorFollowsCB->isChecked();
rc.scroll_below_document = scrollBelowCB->isChecked();
rc.mac_like_cursor_movement = macLikeCursorMovementCB->isChecked();
+ rc.ct_markup_copied = copyCTMarkupCB->isChecked();
rc.sort_layouts = sortEnvironmentsCB->isChecked();
rc.group_layouts = groupEnvironmentsCB->isChecked();
switch (macroEditStyleCO->currentIndex()) {
case 2: rc.macro_edit_style = LyXRC::MACRO_EDIT_LIST; break;
}
rc.cursor_width = cursorWidthSB->value();
- rc.full_screen_toolbars = toggleToolbarsCB->isChecked();
- rc.full_screen_scrollbar = toggleScrollbarCB->isChecked();
- 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 = fullscreenLimitGB->isChecked();
+ rc.citation_search = citationSearchCB->isChecked();
+ rc.citation_search_pattern = fromqstr(citationSearchLE->text());
+ rc.screen_width = Length(widgetsToLength(screenWidthLE, screenWidthUnitCO));
+ rc.screen_limit = screenLimitCB->isChecked();
}
cursorFollowsCB->setChecked(rc.cursor_follows_scrollbar);
scrollBelowCB->setChecked(rc.scroll_below_document);
macLikeCursorMovementCB->setChecked(rc.mac_like_cursor_movement);
+ copyCTMarkupCB->setChecked(rc.ct_markup_copied);
sortEnvironmentsCB->setChecked(rc.sort_layouts);
groupEnvironmentsCB->setChecked(rc.group_layouts);
macroEditStyleCO->setCurrentIndex(rc.macro_edit_style);
cursorWidthSB->setValue(rc.cursor_width);
- toggleScrollbarCB->setChecked(rc.full_screen_scrollbar);
- toggleStatusbarCB->setChecked(rc.full_screen_statusbar);
- toggleToolbarsCB->setChecked(rc.full_screen_toolbars);
- toggleTabbarCB->setChecked(rc.full_screen_tabbar);
- toggleMenubarCB->setChecked(rc.full_screen_menubar);
- fullscreenWidthSB->setValue(rc.full_screen_width);
- fullscreenLimitGB->setChecked(rc.full_screen_limit);
+ citationSearchCB->setChecked(rc.citation_search);
+ citationSearchLE->setText(toqstr(rc.citation_search_pattern));
+ citationSearchLE->setEnabled(rc.citation_search);
+ citationSearchLA->setEnabled(rc.citation_search);
+ lengthToWidgets(screenWidthLE, screenWidthUnitCO, rc.screen_width, Length::defaultUnit());
+ screenWidthUnitCO->setEnabled(rc.screen_limit);
+ screenLimitCB->setChecked(rc.screen_limit);
+ screenWidthLE->setEnabled(rc.screen_limit);
}
{
Ui::shortcutUi::setupUi(this);
QDialog::setModal(true);
+ lfunLE->setValidator(new NoNewLineValidator(lfunLE));
}
PrefShortcuts::PrefShortcuts(GuiPreferences * form)
: PrefModule(catEditing, N_("Shortcuts"), form),
- editItem_(0), mathItem_(0), bufferItem_(0), layoutItem_(0),
- systemItem_(0)
+ editItem_(nullptr), mathItem_(nullptr), bufferItem_(nullptr), layoutItem_(nullptr),
+ systemItem_(nullptr)
{
setupUi(this);
// The good thing is that the menus are updated automatically.
theTopLevelKeymap().clear();
theTopLevelKeymap().read("site");
- theTopLevelKeymap().read(rc.bind_file, 0, KeyMap::Fallback);
- theTopLevelKeymap().read("user", 0, KeyMap::MissingOK);
+ theTopLevelKeymap().read(rc.bind_file, nullptr, KeyMap::Fallback);
+ theTopLevelKeymap().read("user", nullptr, KeyMap::MissingOK);
}
+ ' ' + lfun.argument());
QString const shortcut = toqstr(seq.print(KeySequence::ForGui));
- QTreeWidgetItem * newItem = 0;
+ QTreeWidgetItem * newItem = nullptr;
// for unbind items, try to find an existing item in the system bind list
if (tag == KeyMap::UserUnbind) {
- QList<QTreeWidgetItem*> const items = shortcutsTW->findItems(lfun_name,
- Qt::MatchFlags(Qt::MatchExactly | Qt::MatchRecursive), 0);
- for (int i = 0; i < items.size(); ++i) {
- if (items[i]->text(1) == shortcut) {
- newItem = items[i];
+ QList<QTreeWidgetItem*> const items = shortcutsTW->findItems(shortcut,
+ Qt::MatchFlags(Qt::MatchExactly | Qt::MatchRecursive), 1);
+ for (auto const & item : items) {
+ if (item->text(0) == lfun_name || lfun == FuncRequest::unknown) {
+ newItem = item;
break;
}
}
// Such an item is not displayed to avoid confusion (what is
// unmatched removed?).
if (!newItem) {
- return 0;
+ return nullptr;
}
}
if (!newItem) {
switch(lyxaction.getActionType(action)) {
case LyXAction::Hidden:
- return 0;
+ return nullptr;
case LyXAction::Edit:
newItem = new QTreeWidgetItem(editItem_);
break;
// this should not happen
newItem = new QTreeWidgetItem(shortcutsTW);
}
+ newItem->setText(0, lfun_name);
+ newItem->setText(1, shortcut);
}
- newItem->setText(0, lfun_name);
- newItem->setText(1, shortcut);
// record BindFile representation to recover KeySequence when needed.
newItem->setData(1, Qt::UserRole, toqstr(seq.print(KeySequence::BindFile)));
setItemType(newItem, tag);
// list of items that match lfun
QList<QTreeWidgetItem*> items = shortcutsTW->findItems(lfun,
Qt::MatchFlags(Qt::MatchExactly | Qt::MatchRecursive), 0);
- for (int i = 0; i < items.size(); ++i) {
- QTreeWidgetItem * item = items[i];
+ for (auto const & item : items) {
if (isAlwaysHidden(*item)) {
setItemType(item, KeyMap::System);
if (select)
// it seems that only one item can be selected, but I am
// removing all selected items anyway.
QList<QTreeWidgetItem*> items = shortcutsTW->selectedItems();
- for (int i = 0; i < items.size(); ++i) {
- string shortcut = fromqstr(items[i]->data(1, Qt::UserRole).toString());
- string lfun = fromqstr(items[i]->text(0));
- FuncRequest func = lyxaction.lookupFunc(lfun);
+ for (auto & item : items) {
+ string shortcut = fromqstr(item->data(1, Qt::UserRole).toString());
+ string lfun = fromqstr(item->text(0));
+ FuncRequest const func = lyxaction.lookupFunc(lfun);
- switch (itemType(*items[i])) {
+ switch (itemType(*item)) {
case KeyMap::System: {
// for system bind, we do not touch the item
// but add an user unbind item
user_unbind_.bind(shortcut, func);
- setItemType(items[i], KeyMap::UserUnbind);
+ setItemType(item, KeyMap::UserUnbind);
removePB->setText(qt_("Res&tore"));
break;
}
case KeyMap::UserBind: {
// for user_bind, we remove this bind
- QTreeWidgetItem * parent = items[i]->parent();
- int itemIdx = parent->indexOfChild(items[i]);
+ QTreeWidgetItem * parent = item->parent();
+ int itemIdx = parent->indexOfChild(item);
parent->takeChild(itemIdx);
if (itemIdx > 0)
shortcutsTW->scrollToItem(parent->child(itemIdx - 1));
user_bind_.unbind(shortcut, func);
// If this user binding hid an empty system binding, unhide the
// latter and select it.
- unhideEmpty(items[i]->text(0), true);
+ unhideEmpty(item->text(0), true);
break;
}
case KeyMap::UserUnbind: {
if (!validateNewShortcut(func, seq, QString()))
break;
user_unbind_.unbind(shortcut, func);
- setItemType(items[i], KeyMap::System);
+ setItemType(item, KeyMap::System);
removePB->setText(qt_("Remo&ve"));
break;
}
case KeyMap::UserExtraUnbind: {
// for user unbind that is not in system bind file,
// remove this unbind file
- QTreeWidgetItem * parent = items[i]->parent();
- parent->takeChild(parent->indexOfChild(items[i]));
+ QTreeWidgetItem * parent = item->parent();
+ parent->takeChild(parent->indexOfChild(item));
user_unbind_.unbind(shortcut, func);
}
}
void PrefShortcuts::deactivateShortcuts(QList<QTreeWidgetItem*> const & items)
{
- for (int i = 0; i < items.size(); ++i) {
- string shortcut = fromqstr(items[i]->data(1, Qt::UserRole).toString());
- string lfun = fromqstr(items[i]->text(0));
- FuncRequest func = lyxaction.lookupFunc(lfun);
+ for (auto item : items) {
+ string shortcut = fromqstr(item->data(1, Qt::UserRole).toString());
+ string lfun = fromqstr(item->text(0));
+ FuncRequest const func = lyxaction.lookupFunc(lfun);
- switch (itemType(*items[i])) {
+ switch (itemType(*item)) {
case KeyMap::System:
// for system bind, we do not touch the item
// but add an user unbind item
user_unbind_.bind(shortcut, func);
- setItemType(items[i], KeyMap::UserUnbind);
+ setItemType(item, KeyMap::UserUnbind);
break;
case KeyMap::UserBind: {
// for user_bind, we remove this bind
- QTreeWidgetItem * parent = items[i]->parent();
- int itemIdx = parent->indexOfChild(items[i]);
+ QTreeWidgetItem * parent = item->parent();
+ int itemIdx = parent->indexOfChild(item);
parent->takeChild(itemIdx);
user_bind_.unbind(shortcut, func);
- unhideEmpty(items[i]->text(0), false);
+ unhideEmpty(item->text(0), false);
break;
}
default:
// show all hidden items
QTreeWidgetItemIterator it(shortcutsTW, QTreeWidgetItemIterator::Hidden);
for (; *it; ++it)
- shortcutsTW->setItemHidden(*it, isAlwaysHidden(**it));
+ (*it)->setHidden(isAlwaysHidden(**it));
// close all categories
for (int i = 0; i < shortcutsTW->topLevelItemCount(); ++i)
shortcutsTW->collapseItem(shortcutsTW->topLevelItem(i));
// hide everyone (to avoid searching in matched QList repeatedly
QTreeWidgetItemIterator it(shortcutsTW, QTreeWidgetItemIterator::Selectable);
while (*it)
- shortcutsTW->setItemHidden(*it++, true);
+ (*it++)->setHidden(true);
// show matched items
- for (int i = 0; i < matched.size(); ++i)
- if (!isAlwaysHidden(*matched[i])) {
- shortcutsTW->setItemHidden(matched[i], false);
- shortcutsTW->setItemExpanded(matched[i]->parent(), true);
+ for (auto & item : matched)
+ if (!isAlwaysHidden(*item)) {
+ item->setHidden(false);
+ if (item->parent())
+ item->parent()->setExpanded(true);
}
}
FuncRequest PrefShortcuts::currentBinding(KeySequence const & k)
{
FuncRequest res = user_bind_.getBinding(k);
- if (res.action() != LFUN_UNKNOWN_ACTION)
+ if (res != FuncRequest::unknown)
return res;
res = system_bind_.getBinding(k);
+
// Check if it is unbound. Note: user_unbind_ can only unbind one
// FuncRequest per key sequence.
if (user_unbind_.getBinding(k) == res)
// nothing to change
return false;
+ // Check whether the key sequence is a prefix for other shortcuts.
+ if (oldBinding == FuncRequest::prefix) {
+ docstring const new_action_string = makeCmdString(func);
+ docstring const text = bformat(_("Shortcut `%1$s' is already a prefix for other commands.\n"
+ "Are you sure you want to unbind these commands and bind it to %2$s?"),
+ k.print(KeySequence::ForGui), new_action_string);
+ int ret = Alert::prompt(_("Redefine shortcut?"),
+ text, 0, 1, _("&Redefine"), _("&Cancel"));
+ if (ret != 0)
+ return false;
+ QString const sequence_text = toqstr(k.print(KeySequence::ForGui));
+ QList<QTreeWidgetItem*> items = shortcutsTW->findItems(sequence_text,
+ Qt::MatchFlags(Qt::MatchStartsWith | Qt::MatchRecursive), 1);
+ deactivateShortcuts(items);
+ return true;
+ }
+
// make sure this key isn't already bound---and, if so, prompt user
// (exclude the lfun the user already wants to modify)
docstring const action_string = makeCmdString(oldBinding);
void PrefShortcuts::shortcutOkPressed()
{
QString const new_lfun = shortcut_->lfunLE->text();
- FuncRequest func = lyxaction.lookupFunc(fromqstr(new_lfun));
+ FuncRequest const func = lyxaction.lookupFunc(fromqstr(new_lfun));
KeySequence k = shortcut_->shortcutWG->getKeySequence();
// save_lfun_ contains the text of the lfun to modify, if the user clicked
if (item) {
user_bind_.bind(&k, func);
shortcutsTW->sortItems(0, Qt::AscendingOrder);
- shortcutsTW->setItemExpanded(item->parent(), true);
+ if (item->parent())
+ item->parent()->setExpanded(true);
shortcutsTW->setCurrentItem(item);
shortcutsTW->scrollToItem(item);
} else {
this, SIGNAL(changed()));
connect(emailED, SIGNAL(textChanged(QString)),
this, SIGNAL(changed()));
+ connect(initialsED, SIGNAL(textChanged(QString)),
+ this, SIGNAL(changed()));
nameED->setValidator(new NoNewLineValidator(nameED));
emailED->setValidator(new NoNewLineValidator(emailED));
+ initialsED->setValidator(new NoNewLineValidator(initialsED));
}
{
rc.user_name = fromqstr(nameED->text());
rc.user_email = fromqstr(emailED->text());
+ rc.user_initials = fromqstr(initialsED->text());
}
{
nameED->setText(toqstr(rc.user_name));
emailED->setText(toqstr(rc.user_email));
+ initialsED->setText(toqstr(rc.user_initials));
}
addModule(formats);
prefsPS->setCurrentPanel("User Interface");
-// FIXME: hack to work around resizing bug in Qt >= 4.2
-// bug verified with Qt 4.2.{0-3} (JSpitzm)
-#if QT_VERSION >= 0x040200
- prefsPS->updateGeometry();
-#endif
bc().setPolicy(ButtonPolicy::PreferencesPolicy);
bc().setOK(buttonBox->button(QDialogButtonBox::Ok));
// FIXME: these need lfuns
// FIXME UNICODE
Author const & author =
- Author(from_utf8(rc_.user_name), from_utf8(rc_.user_email));
+ Author(from_utf8(rc_.user_name), from_utf8(rc_.user_email),
+ from_utf8(rc_.user_initials));
theBufferList().recordCurrentAuthor(author);
theFormats() = formats_;
}
-Dialog * createGuiPreferences(GuiView & lv) { return new GuiPreferences(lv); }
-
-
} // namespace frontend
} // namespace lyx