mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-03 08:28:25 +00:00
GuiCharacter: Add menu to Restore button
and allow for resetting all widgets to "No Change" besides "Default"
(cherry picked from commit ac8aac5b36
)
This commit is contained in:
parent
714b731e39
commit
4480b72a9d
@ -35,6 +35,7 @@
|
||||
|
||||
#include <QAbstractItemModel>
|
||||
#include <QComboBox>
|
||||
#include <QMenu>
|
||||
#include <QModelIndex>
|
||||
#include <QSettings>
|
||||
#include <QVariant>
|
||||
@ -266,6 +267,18 @@ GuiCharacter::GuiCharacter(GuiView & lv)
|
||||
bc().addReadOnly(colorCO);
|
||||
bc().addReadOnly(autoapplyCB);
|
||||
|
||||
// Add button menu to restore button to reset
|
||||
// all widgets to "Defaults" or "No Change"
|
||||
resetdefault_ = new QAction(qt_("Reset All To &Default"), this);
|
||||
resetnochange_ = new QAction(qt_("Reset All To No Chan&ge"), this);
|
||||
QMenu * resetmenu = new QMenu();
|
||||
resetmenu->addAction(resetdefault_);
|
||||
resetmenu->addAction(resetnochange_);
|
||||
restorePB->setMenu(resetmenu);
|
||||
restorePB->setText(qt_("&Reset All Fields"));
|
||||
connect(resetdefault_, SIGNAL(triggered()), this, SLOT(resetToDefault()));
|
||||
connect(resetnochange_, SIGNAL(triggered()), this, SLOT(resetToNoChange()));
|
||||
|
||||
#ifdef Q_OS_MAC
|
||||
// On Mac it's common to have tool windows which are always in the
|
||||
// foreground and are hidden when the main window is not focused.
|
||||
@ -297,7 +310,7 @@ void GuiCharacter::on_nounCB_clicked()
|
||||
}
|
||||
|
||||
|
||||
void GuiCharacter::on_restorePB_clicked()
|
||||
void GuiCharacter::resetToDefault()
|
||||
{
|
||||
Font font(inherit_font);
|
||||
font.setLanguage(reset_language);
|
||||
@ -306,6 +319,15 @@ void GuiCharacter::on_restorePB_clicked()
|
||||
}
|
||||
|
||||
|
||||
void GuiCharacter::resetToNoChange()
|
||||
{
|
||||
Font font(ignore_font);
|
||||
font.setLanguage(ignore_language);
|
||||
paramsToDialog(font);
|
||||
change_adaptor();
|
||||
}
|
||||
|
||||
|
||||
template<class P, class B>
|
||||
static int findPos2nd(QList<P> const & vec, B const & val)
|
||||
{
|
||||
@ -406,8 +428,15 @@ void GuiCharacter::change_adaptor()
|
||||
|
||||
void GuiCharacter::checkRestoreDefaults()
|
||||
{
|
||||
// (De)Activate Restore Defaults button
|
||||
restorePB->setEnabled(
|
||||
if (familyCO->currentIndex() == -1 || seriesCO->currentIndex() == -1
|
||||
|| shapeCO->currentIndex() == -1 || sizeCO->currentIndex() == -1
|
||||
|| ulineCO->currentIndex() == -1 || strikeCO->currentIndex() == -1
|
||||
|| colorCO->currentIndex() == -1 || langCO->currentIndex() == -1)
|
||||
// dialog not yet built
|
||||
return;
|
||||
|
||||
// (De)Activate Restore Defaults menu items
|
||||
resetdefault_->setEnabled(
|
||||
family[familyCO->currentIndex()].second != INHERIT_FAMILY
|
||||
|| series[seriesCO->currentIndex()].second != INHERIT_SERIES
|
||||
|| shape[shapeCO->currentIndex()].second != INHERIT_SHAPE
|
||||
@ -418,6 +447,18 @@ void GuiCharacter::checkRestoreDefaults()
|
||||
|| strike[strikeCO->currentIndex()].second != INHERIT
|
||||
|| lcolor.getFromLyXName(fromqstr(colorCO->itemData(colorCO->currentIndex()).toString())) != Color_inherit
|
||||
|| languages.getLanguage(fromqstr(language[langCO->currentIndex()].second)) != reset_language);
|
||||
|
||||
resetnochange_->setEnabled(
|
||||
family[familyCO->currentIndex()].second != IGNORE_FAMILY
|
||||
|| series[seriesCO->currentIndex()].second != IGNORE_SERIES
|
||||
|| shape[shapeCO->currentIndex()].second != IGNORE_SHAPE
|
||||
|| size[sizeCO->currentIndex()].second != FONT_SIZE_IGNORE
|
||||
|| setMarkupState(emphCB->checkState()) != FONT_IGNORE
|
||||
|| setMarkupState(nounCB->checkState()) != FONT_IGNORE
|
||||
|| bar[ulineCO->currentIndex()].second != IGNORE
|
||||
|| strike[strikeCO->currentIndex()].second != IGNORE
|
||||
|| lcolor.getFromLyXName(fromqstr(colorCO->itemData(colorCO->currentIndex()).toString())) != Color_ignore
|
||||
|| languages.getLanguage(fromqstr(language[langCO->currentIndex()].second)) != ignore_language);
|
||||
}
|
||||
|
||||
|
||||
|
@ -18,6 +18,8 @@
|
||||
#include "ui_CharacterUi.h"
|
||||
#include "Font.h"
|
||||
|
||||
#include <QAction>
|
||||
|
||||
#include <utility>
|
||||
|
||||
#ifdef IGNORE
|
||||
@ -65,7 +67,8 @@ protected Q_SLOTS:
|
||||
void change_adaptor();
|
||||
void on_emphCB_clicked();
|
||||
void on_nounCB_clicked();
|
||||
void on_restorePB_clicked();
|
||||
void resetToDefault();
|
||||
void resetToNoChange();
|
||||
void checkRestoreDefaults();
|
||||
|
||||
private:
|
||||
@ -104,6 +107,11 @@ private:
|
||||
bool emph_;
|
||||
///
|
||||
bool noun_;
|
||||
|
||||
///
|
||||
QAction * resetdefault_ = new QAction(this);
|
||||
///
|
||||
QAction * resetnochange_ = new QAction(this);
|
||||
};
|
||||
|
||||
} // namespace frontend
|
||||
|
@ -34,7 +34,7 @@ What's new
|
||||
|
||||
- Make tab movement visible (bug 10733).
|
||||
|
||||
- Add "Reset" and "Restore Defaults" buttons to Text Properties
|
||||
- Add "Reset" and "Reset All Fields" buttons to Text Properties
|
||||
dialog (bug 11415).
|
||||
|
||||
- Insert new graphics inset on the correct cursor position.
|
||||
|
Loading…
Reference in New Issue
Block a user