mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-30 13:20:58 +00:00
Add the icon-size to the toolbar menu
- Adds LFUNs for setting the icon size - Adds icons sizes to the Toolbars menu - Uses the Toolbars menu as application context menu - The context menu can now be user defined in stdcontext.inc When the logical sizes differ and the icon set is changed, the correct sizes are established only after a restart. Fixes ticket #10428. (cherry picked from commite91572a00b
) (cherry picked from commit6c92075799
) (cherry picked from commit7971dc83ef
)
This commit is contained in:
parent
133c2c62ee
commit
060a9664f7
@ -658,4 +658,17 @@ Menuset
|
|||||||
Item "Settings...|S" "inset-settings"
|
Item "Settings...|S" "inset-settings"
|
||||||
End
|
End
|
||||||
|
|
||||||
|
#
|
||||||
|
# Toolbar context menu
|
||||||
|
#
|
||||||
|
Menu "context-toolbars"
|
||||||
|
Toolbars
|
||||||
|
Separator
|
||||||
|
Item "Small-sized Icons" "icon-size small"
|
||||||
|
Item "Normal-sized Icons" "icon-size normal"
|
||||||
|
Item "Big-sized Icons" "icon-size big"
|
||||||
|
Item "Huge-sized Icons" "icon-size huge"
|
||||||
|
Item "Giant-sized Icons" "icon-size giant"
|
||||||
|
End
|
||||||
|
|
||||||
End
|
End
|
||||||
|
@ -350,6 +350,12 @@ Menuset
|
|||||||
|
|
||||||
Menu "toolbars"
|
Menu "toolbars"
|
||||||
Toolbars
|
Toolbars
|
||||||
|
Separator
|
||||||
|
Item "Small-sized Icons" "icon-size small"
|
||||||
|
Item "Normal-sized Icons" "icon-size normal"
|
||||||
|
Item "Big-sized Icons" "icon-size big"
|
||||||
|
Item "Huge-sized Icons" "icon-size huge"
|
||||||
|
Item "Giant-sized Icons" "icon-size giant"
|
||||||
End
|
End
|
||||||
#
|
#
|
||||||
# INSERT MENU
|
# INSERT MENU
|
||||||
|
@ -465,6 +465,7 @@ enum FuncCode
|
|||||||
// 340
|
// 340
|
||||||
LFUN_BUFFER_MOVE_PREVIOUS, // skostysh 20150408
|
LFUN_BUFFER_MOVE_PREVIOUS, // skostysh 20150408
|
||||||
LFUN_TABULAR_FEATURE, // gm, 20151210
|
LFUN_TABULAR_FEATURE, // gm, 20151210
|
||||||
|
LFUN_ICON_SIZE, // daniel, 20160712
|
||||||
LFUN_LASTACTION // end of the table
|
LFUN_LASTACTION // end of the table
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -2727,6 +2727,17 @@ void LyXAction::init()
|
|||||||
* \endvar
|
* \endvar
|
||||||
*/
|
*/
|
||||||
{ LFUN_TOOLBAR_TOGGLE, "toolbar-toggle", NoBuffer, Buffer },
|
{ LFUN_TOOLBAR_TOGGLE, "toolbar-toggle", NoBuffer, Buffer },
|
||||||
|
/*!
|
||||||
|
* \var lyx::FuncCode lyx::LFUN_ICON_SIZE
|
||||||
|
* \li Action: Sets icon size of toolbars.
|
||||||
|
* \li Syntax: icon-size [<SIZE>]
|
||||||
|
* \li Params: <SIZE> : the icon size in px or one of the logical settings
|
||||||
|
small|normal|big|huge|giant, the default is normal
|
||||||
|
(whose size in px is icon set dependent).
|
||||||
|
* \li Origin: 11 July 2016
|
||||||
|
* \endvar
|
||||||
|
*/
|
||||||
|
{ LFUN_ICON_SIZE, "icon-size", NoBuffer, Buffer },
|
||||||
/*!
|
/*!
|
||||||
* \var lyx::FuncCode lyx::LFUN_MENU_OPEN
|
* \var lyx::FuncCode lyx::LFUN_MENU_OPEN
|
||||||
* \li Action: Opens the menu given by its name.
|
* \li Action: Opens the menu given by its name.
|
||||||
|
@ -328,62 +328,6 @@ public:
|
|||||||
delete stack_widget_;
|
delete stack_widget_;
|
||||||
}
|
}
|
||||||
|
|
||||||
QMenu * toolBarPopup(GuiView * parent)
|
|
||||||
{
|
|
||||||
// FIXME: translation
|
|
||||||
QMenu * menu = new QMenu(parent);
|
|
||||||
QActionGroup * iconSizeGroup = new QActionGroup(parent);
|
|
||||||
|
|
||||||
QAction * smallIcons = new QAction(iconSizeGroup);
|
|
||||||
smallIcons->setText(qt_("Small-sized icons"));
|
|
||||||
smallIcons->setCheckable(true);
|
|
||||||
QObject::connect(smallIcons, SIGNAL(triggered()),
|
|
||||||
parent, SLOT(smallSizedIcons()));
|
|
||||||
menu->addAction(smallIcons);
|
|
||||||
|
|
||||||
QAction * normalIcons = new QAction(iconSizeGroup);
|
|
||||||
normalIcons->setText(qt_("Normal-sized icons"));
|
|
||||||
normalIcons->setCheckable(true);
|
|
||||||
QObject::connect(normalIcons, SIGNAL(triggered()),
|
|
||||||
parent, SLOT(normalSizedIcons()));
|
|
||||||
menu->addAction(normalIcons);
|
|
||||||
|
|
||||||
QAction * bigIcons = new QAction(iconSizeGroup);
|
|
||||||
bigIcons->setText(qt_("Big-sized icons"));
|
|
||||||
bigIcons->setCheckable(true);
|
|
||||||
QObject::connect(bigIcons, SIGNAL(triggered()),
|
|
||||||
parent, SLOT(bigSizedIcons()));
|
|
||||||
menu->addAction(bigIcons);
|
|
||||||
|
|
||||||
QAction * hugeIcons = new QAction(iconSizeGroup);
|
|
||||||
hugeIcons->setText(qt_("Huge-sized icons"));
|
|
||||||
hugeIcons->setCheckable(true);
|
|
||||||
QObject::connect(hugeIcons, SIGNAL(triggered()),
|
|
||||||
parent, SLOT(hugeSizedIcons()));
|
|
||||||
menu->addAction(hugeIcons);
|
|
||||||
|
|
||||||
QAction * giantIcons = new QAction(iconSizeGroup);
|
|
||||||
giantIcons->setText(qt_("Giant-sized icons"));
|
|
||||||
giantIcons->setCheckable(true);
|
|
||||||
QObject::connect(giantIcons, SIGNAL(triggered()),
|
|
||||||
parent, SLOT(giantSizedIcons()));
|
|
||||||
menu->addAction(giantIcons);
|
|
||||||
|
|
||||||
unsigned int cur = parent->iconSize().width();
|
|
||||||
if ( cur == parent->d.smallIconSize)
|
|
||||||
smallIcons->setChecked(true);
|
|
||||||
else if (cur == parent->d.normalIconSize)
|
|
||||||
normalIcons->setChecked(true);
|
|
||||||
else if (cur == parent->d.bigIconSize)
|
|
||||||
bigIcons->setChecked(true);
|
|
||||||
else if (cur == parent->d.hugeIconSize)
|
|
||||||
hugeIcons->setChecked(true);
|
|
||||||
else if (cur == parent->d.giantIconSize)
|
|
||||||
giantIcons->setChecked(true);
|
|
||||||
|
|
||||||
return menu;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setBackground()
|
void setBackground()
|
||||||
{
|
{
|
||||||
stack_widget_->setCurrentWidget(bg_widget_);
|
stack_widget_->setCurrentWidget(bg_widget_);
|
||||||
@ -440,6 +384,60 @@ public:
|
|||||||
processing_thread_watcher_.setFuture(f);
|
processing_thread_watcher_.setFuture(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QSize iconSize(docstring const & icon_size)
|
||||||
|
{
|
||||||
|
unsigned int size;
|
||||||
|
if (icon_size == "small")
|
||||||
|
size = smallIconSize;
|
||||||
|
else if (icon_size == "normal")
|
||||||
|
size = normalIconSize;
|
||||||
|
else if (icon_size == "big")
|
||||||
|
size = bigIconSize;
|
||||||
|
else if (icon_size == "huge")
|
||||||
|
size = hugeIconSize;
|
||||||
|
else if (icon_size == "giant")
|
||||||
|
size = giantIconSize;
|
||||||
|
else
|
||||||
|
size = icon_size.empty() ? normalIconSize : convert<int>(icon_size);
|
||||||
|
|
||||||
|
if (size < smallIconSize)
|
||||||
|
size = smallIconSize;
|
||||||
|
|
||||||
|
return QSize(size, size);
|
||||||
|
}
|
||||||
|
|
||||||
|
QSize iconSize(QString const & icon_size)
|
||||||
|
{
|
||||||
|
return iconSize(qstring_to_ucs4(icon_size));
|
||||||
|
}
|
||||||
|
|
||||||
|
string & iconSize(QSize const & qsize)
|
||||||
|
{
|
||||||
|
LATTEST(qsize.width() == qsize.height());
|
||||||
|
|
||||||
|
static string icon_size;
|
||||||
|
|
||||||
|
unsigned int size = qsize.width();
|
||||||
|
|
||||||
|
if (size < smallIconSize)
|
||||||
|
size = smallIconSize;
|
||||||
|
|
||||||
|
if (size == smallIconSize)
|
||||||
|
icon_size = "small";
|
||||||
|
else if (size == normalIconSize)
|
||||||
|
icon_size = "normal";
|
||||||
|
else if (size == bigIconSize)
|
||||||
|
icon_size = "big";
|
||||||
|
else if (size == hugeIconSize)
|
||||||
|
icon_size = "huge";
|
||||||
|
else if (size == giantIconSize)
|
||||||
|
icon_size = "giant";
|
||||||
|
else
|
||||||
|
icon_size = convert<string>(size);
|
||||||
|
|
||||||
|
return icon_size;
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
GuiView * gv_;
|
GuiView * gv_;
|
||||||
GuiWorkArea * current_work_area_;
|
GuiWorkArea * current_work_area_;
|
||||||
@ -514,7 +512,7 @@ GuiView::GuiView(int id)
|
|||||||
command_execute_(false), minibuffer_focus_(false)
|
command_execute_(false), minibuffer_focus_(false)
|
||||||
{
|
{
|
||||||
// GuiToolbars *must* be initialised before the menu bar.
|
// GuiToolbars *must* be initialised before the menu bar.
|
||||||
normalSizedIcons(); // at least on Mac the default is 32 otherwise, which is huge
|
setIconSize(QSize(d.normalIconSize, d.normalIconSize)); // at least on Mac the default is 32 otherwise, which is huge
|
||||||
constructToolbars();
|
constructToolbars();
|
||||||
|
|
||||||
// set ourself as the current view. This is needed for the menu bar
|
// set ourself as the current view. This is needed for the menu bar
|
||||||
@ -606,6 +604,11 @@ GuiView::GuiView(int id)
|
|||||||
connect(this, SIGNAL(triggerShowDialog(QString const &, QString const &, Inset *)),
|
connect(this, SIGNAL(triggerShowDialog(QString const &, QString const &, Inset *)),
|
||||||
SLOT(doShowDialog(QString const &, QString const &, Inset *)));
|
SLOT(doShowDialog(QString const &, QString const &, Inset *)));
|
||||||
|
|
||||||
|
// set custom application bars context menu, e.g. tool bar and menu bar
|
||||||
|
setContextMenuPolicy(Qt::CustomContextMenu);
|
||||||
|
connect(this, SIGNAL(customContextMenuRequested(const QPoint &)),
|
||||||
|
SLOT(toolBarPopup(const QPoint &)));
|
||||||
|
|
||||||
// Forbid too small unresizable window because it can happen
|
// Forbid too small unresizable window because it can happen
|
||||||
// with some window manager under X11.
|
// with some window manager under X11.
|
||||||
setMinimumSize(300, 200);
|
setMinimumSize(300, 200);
|
||||||
@ -717,7 +720,7 @@ void GuiView::saveLayout() const
|
|||||||
settings.setValue("geometry", saveGeometry());
|
settings.setValue("geometry", saveGeometry());
|
||||||
#endif
|
#endif
|
||||||
settings.setValue("layout", saveState(0));
|
settings.setValue("layout", saveState(0));
|
||||||
settings.setValue("icon_size", iconSize());
|
settings.setValue("icon_size", toqstr(d.iconSize(iconSize())));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -744,17 +747,7 @@ bool GuiView::restoreLayout()
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
//code below is skipped when when ~/.config/LyX is (re)created
|
//code below is skipped when when ~/.config/LyX is (re)created
|
||||||
QSize icon_size = settings.value(icon_key).toSize();
|
setIconSize(d.iconSize(settings.value(icon_key).toString()));
|
||||||
// Check whether session size changed.
|
|
||||||
if (icon_size.width() != int(d.smallIconSize) &&
|
|
||||||
icon_size.width() != int(d.normalIconSize) &&
|
|
||||||
icon_size.width() != int(d.bigIconSize) &&
|
|
||||||
icon_size.width() != int(d.hugeIconSize) &&
|
|
||||||
icon_size.width() != int(d.giantIconSize)) {
|
|
||||||
icon_size.setWidth(d.normalIconSize);
|
|
||||||
icon_size.setHeight(d.normalIconSize);
|
|
||||||
}
|
|
||||||
setIconSize(icon_size);
|
|
||||||
|
|
||||||
#if defined(Q_WS_X11) || defined(QPA_XCB)
|
#if defined(Q_WS_X11) || defined(QPA_XCB)
|
||||||
QPoint pos = settings.value("pos", QPoint(50, 50)).toPoint();
|
QPoint pos = settings.value("pos", QPoint(50, 50)).toPoint();
|
||||||
@ -919,12 +912,6 @@ void GuiView::focusInEvent(QFocusEvent * e)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QMenu * GuiView::createPopupMenu()
|
|
||||||
{
|
|
||||||
return d.toolBarPopup(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void GuiView::showEvent(QShowEvent * e)
|
void GuiView::showEvent(QShowEvent * e)
|
||||||
{
|
{
|
||||||
LYXERR(Debug::GUI, "Passed Geometry "
|
LYXERR(Debug::GUI, "Passed Geometry "
|
||||||
@ -1112,36 +1099,6 @@ void GuiView::updateStatusBarMessage(QString const & str)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void GuiView::smallSizedIcons()
|
|
||||||
{
|
|
||||||
setIconSize(QSize(d.smallIconSize, d.smallIconSize));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void GuiView::normalSizedIcons()
|
|
||||||
{
|
|
||||||
setIconSize(QSize(d.normalIconSize, d.normalIconSize));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void GuiView::bigSizedIcons()
|
|
||||||
{
|
|
||||||
setIconSize(QSize(d.bigIconSize, d.bigIconSize));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void GuiView::hugeSizedIcons()
|
|
||||||
{
|
|
||||||
setIconSize(QSize(d.hugeIconSize, d.hugeIconSize));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void GuiView::giantSizedIcons()
|
|
||||||
{
|
|
||||||
setIconSize(QSize(d.giantIconSize, d.giantIconSize));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void GuiView::clearMessage()
|
void GuiView::clearMessage()
|
||||||
{
|
{
|
||||||
// FIXME: This code was introduced in r19643 to fix bug #4123. However,
|
// FIXME: This code was introduced in r19643 to fix bug #4123. However,
|
||||||
@ -1924,6 +1881,10 @@ bool GuiView::getStatus(FuncRequest const & cmd, FuncStatus & flag)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case LFUN_ICON_SIZE:
|
||||||
|
flag.setOnOff(d.iconSize(cmd.argument()) == iconSize());
|
||||||
|
break;
|
||||||
|
|
||||||
case LFUN_DROP_LAYOUTS_CHOICE:
|
case LFUN_DROP_LAYOUTS_CHOICE:
|
||||||
enable = buf != 0;
|
enable = buf != 0;
|
||||||
break;
|
break;
|
||||||
@ -3398,6 +3359,14 @@ bool GuiView::goToFileRow(string const & argument)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void GuiView::toolBarPopup(const QPoint & /*pos*/)
|
||||||
|
{
|
||||||
|
QMenu * menu = new QMenu;
|
||||||
|
menu = guiApp->menus().menu(toqstr("context-toolbars"), * this);
|
||||||
|
menu->exec(QCursor::pos());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
Buffer::ExportStatus GuiView::GuiViewPrivate::runAndDestroy(const T& func, Buffer const * orig, Buffer * clone, string const & format)
|
Buffer::ExportStatus GuiView::GuiViewPrivate::runAndDestroy(const T& func, Buffer const * orig, Buffer * clone, string const & format)
|
||||||
{
|
{
|
||||||
@ -3800,6 +3769,14 @@ void GuiView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case LFUN_ICON_SIZE: {
|
||||||
|
QSize size = d.iconSize(cmd.argument());
|
||||||
|
setIconSize(size);
|
||||||
|
dr.setMessage(bformat(_("Icon size set to %1$dx%2$d."),
|
||||||
|
size.width(), size.height()));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case LFUN_DIALOG_UPDATE: {
|
case LFUN_DIALOG_UPDATE: {
|
||||||
string const name = to_utf8(cmd.argument());
|
string const name = to_utf8(cmd.argument());
|
||||||
if (name == "prefs" || name == "document")
|
if (name == "prefs" || name == "document")
|
||||||
|
@ -146,7 +146,6 @@ public:
|
|||||||
/// updates the possible layouts selectable
|
/// updates the possible layouts selectable
|
||||||
void updateLayoutList();
|
void updateLayoutList();
|
||||||
void updateToolbars();
|
void updateToolbars();
|
||||||
QMenu * createPopupMenu();
|
|
||||||
|
|
||||||
///
|
///
|
||||||
LayoutBox * getLayoutDialog() const;
|
LayoutBox * getLayoutDialog() const;
|
||||||
@ -233,13 +232,6 @@ private Q_SLOTS:
|
|||||||
///
|
///
|
||||||
void on_lastWorkAreaRemoved();
|
void on_lastWorkAreaRemoved();
|
||||||
|
|
||||||
/// slots to change the icon size
|
|
||||||
void smallSizedIcons();
|
|
||||||
void normalSizedIcons();
|
|
||||||
void bigSizedIcons();
|
|
||||||
void hugeSizedIcons();
|
|
||||||
void giantSizedIcons();
|
|
||||||
|
|
||||||
/// For completion of autosave or export threads.
|
/// For completion of autosave or export threads.
|
||||||
void processingThreadStarted();
|
void processingThreadStarted();
|
||||||
void processingThreadFinished();
|
void processingThreadFinished();
|
||||||
@ -253,6 +245,9 @@ private Q_SLOTS:
|
|||||||
void updateStatusBarMessage(QString const & str);
|
void updateStatusBarMessage(QString const & str);
|
||||||
void clearMessageText();
|
void clearMessageText();
|
||||||
|
|
||||||
|
///
|
||||||
|
void toolBarPopup(const QPoint &pos);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/// Open given child document in current buffer directory.
|
/// Open given child document in current buffer directory.
|
||||||
void openChildDocument(std::string const & filename);
|
void openChildDocument(std::string const & filename);
|
||||||
|
@ -26,6 +26,10 @@ What's new
|
|||||||
- The title bar is now set according to platform UI. Read-only and
|
- The title bar is now set according to platform UI. Read-only and
|
||||||
version control are shown by indicators in the status bar.
|
version control are shown by indicators in the status bar.
|
||||||
|
|
||||||
|
- The toolbar context menu and the View>Toobars menus are now
|
||||||
|
identical. Both allow to change icon size and to enable individual
|
||||||
|
toolbars.
|
||||||
|
|
||||||
- The citation dialog has been redesigned, following user suggestions.
|
- The citation dialog has been redesigned, following user suggestions.
|
||||||
|
|
||||||
- Remember citation style settings both within and between sessions
|
- Remember citation style settings both within and between sessions
|
||||||
|
Loading…
Reference in New Issue
Block a user