Item "Giant-sized Icons" "icon-size giant"
End
+#
+# Zoom context menu
+#
+ Menu "context-zoom"
+ ZoomOptions
+ Separator
+ Item "Show Zoom Slider|S" "ui-toggle zoomslider"
+ End
+
End
zoom_value_->setEnabled(currentBufferView());
zoom_value_->setContextMenuPolicy(Qt::CustomContextMenu);
- ZoomMenu * zoom_menu = new ZoomMenu(statusBar());
- act_zoom_default_ = new QAction(toqstr(bformat(_("&Reset to default (%1$d%)"),
- lyxrc.defaultZoom)), this);
- act_zoom_in_ = new QAction(qt_("Zoom &in"), this);
- act_zoom_out_ = new QAction(qt_("Zoom &out"), this);
- act_zoom_show_ = new QAction(qt_("Show zoom slider"), this);
- act_zoom_show_->setCheckable(true);
- zoom_menu->addAction(act_zoom_default_);
- zoom_menu->addAction(act_zoom_in_);
- zoom_menu->addAction(act_zoom_out_);
- zoom_menu->addAction(act_zoom_show_);
- enableZoomOptions();
- connect(act_zoom_default_, SIGNAL(triggered()),
- this, SLOT(resetDefaultZoom()));
- connect(act_zoom_in_, SIGNAL(triggered()),
- this, SLOT(zoomInPressed()));
- connect(act_zoom_out_, SIGNAL(triggered()),
- this, SLOT(zoomOutPressed()));
- connect(act_zoom_show_, SIGNAL(triggered()),
- this, SLOT(toogleZoomSlider()));
connect(zoom_value_, SIGNAL(customContextMenuRequested(QPoint)),
- zoom_menu, SLOT(showMenu(QPoint)));
+ this, SLOT(showZoomContextMenu()));
int const iconheight = max(int(d.normalIconSize), fm.height());
QSize const iconsize(iconheight, iconheight);
}
-void GuiView::enableZoomOptions()
-{
- act_zoom_default_->setEnabled(zoom_slider_->value() != lyxrc.defaultZoom);
- FuncStatus status;
- act_zoom_in_->setEnabled(getStatus(FuncRequest(LFUN_BUFFER_ZOOM_IN), status));
- act_zoom_out_->setEnabled(getStatus(FuncRequest(LFUN_BUFFER_ZOOM_OUT), status));
-}
-
-
void GuiView::zoomSliderMoved(int value)
{
DispatchResult dr;
{
if (value != lyxrc.currentZoom)
zoomSliderMoved(value);
- enableZoomOptions();
}
}
-void GuiView::toogleZoomSlider()
+void GuiView::showZoomContextMenu()
{
- DispatchResult dr;
- dispatch(FuncRequest(LFUN_UI_TOGGLE, "zoomslider"), dr);
-}
-
-
-void GuiView::resetDefaultZoom()
-{
- zoomValueChanged(lyxrc.defaultZoom);
- enableZoomOptions();
+ QMenu * menu = guiApp->menus().menu(toqstr("context-zoom"), * this);
+ if (!menu)
+ return;
+ menu->exec(QCursor::pos());
}
bool const show_zoom_slider = settings.value("zoom_slider_visible", true).toBool();
zoom_slider_->setVisible(show_zoom_slider);
- act_zoom_show_->setChecked(show_zoom_slider);
zoom_in_->setVisible(show_zoom_slider);
zoom_out_->setVisible(show_zoom_slider);
case LFUN_UI_TOGGLE:
if (cmd.argument() == "zoomslider") {
enable = doc_buffer;
- flag.setOnOff(zoom_slider_->isVisible());
+ // Test to avoid crash if called before zoom_slider_ is initialized
+ // FIXME: can probably be done better
+ if (enable)
+ flag.setOnOff(zoom_slider_->isVisible());
} else
flag.setOnOff(isFullScreen());
break;
bformat(_("Zoom level cannot be less than %1$d%."), zoom_min_);
flag.message(msg);
enable = false;
- }
+ } else if (cmd.argument().empty() && lyxrc.currentZoom == lyxrc.defaultZoom)
+ enable = false;
else
enable = doc_buffer;
break;
zoom_slider_->setVisible(!zoom_slider_->isVisible());
zoom_in_->setVisible(zoom_slider_->isVisible());
zoom_out_->setVisible(zoom_slider_->isVisible());
- act_zoom_show_->setChecked(zoom_slider_->isVisible());
} else if (ui_component == "frame") {
int const l = contentsMargins().left();
///
void zoomOutPressed();
///
- void resetDefaultZoom();
- ///
- void toogleZoomSlider();
+ void showZoomContextMenu();
///
void on_currentWorkAreaChanged(GuiWorkArea *);
///
void dispatchToBufferView(FuncRequest const & cmd, DispatchResult & dr);
///
void showMessage();
- ///
- void enableZoomOptions();
/// This view ID.
int id_;
QPushButton * zoom_in_;
/// Zoom out ("-") Button
QPushButton * zoom_out_;
- /// Set zoom to default
- QAction * act_zoom_default_;
- /// Zoom in menu action
- QAction * act_zoom_in_;
- /// Zoom out menu action
- QAction * act_zoom_out_;
- /// Show zoom slider
- QAction * act_zoom_show_;
/// The rate from which the actual zoom value is calculated
/// from the default zoom pref
void showMenu(QPoint const &) { exec(QCursor::pos()); }
};
-class ZoomMenu : public QMenu
-{
- Q_OBJECT
-public:
- explicit ZoomMenu(QWidget *) {};
-
-public Q_SLOTS:
- void showMenu(QPoint const &) { exec(QCursor::pos()); }
-};
-
} // namespace frontend
} // namespace lyx
/** Commands to separate environments (context menu version). */
EnvironmentSeparatorsContext,
/** This is the list of quotation marks available */
- SwitchQuotes
+ SwitchQuotes,
+ /** Options in the Zoom menu **/
+ ZoomOptions
};
explicit MenuItem(Kind kind) : kind_(kind), optional_(false) {}
void expandCaptions(Buffer const * buf, bool switchcap = false);
void expandEnvironmentSeparators(BufferView const *, bool contextmenu = false);
void expandQuotes(BufferView const *);
+ void expandZoomOptions(BufferView const *);
///
ItemList items_;
///
md_switchcaptions,
md_env_separators,
md_env_separatorscontext,
- md_switchquotes
+ md_switchquotes,
+ md_zoomoptions
};
LexerKeyword menutags[] = {
{ "toc", md_toc },
{ "toolbars", md_toolbars },
{ "updateformats", md_updateformats },
- { "viewformats", md_viewformats }
+ { "viewformats", md_viewformats },
+ { "zoomoptions", md_zoomoptions }
};
lex.pushTable(menutags);
add(MenuItem(MenuItem::SwitchQuotes));
break;
+ case md_zoomoptions:
+ add(MenuItem(MenuItem::ZoomOptions));
+ break;
+
case md_optsubmenu:
case md_submenu: {
lex.next(true);
}
+void MenuDefinition::expandZoomOptions(BufferView const * bv)
+{
+ if (!bv)
+ return;
+
+ add(MenuItem(MenuItem::Command,
+ toqstr(bformat(_("Reset to Default (%1$d%)|R"),
+ lyxrc.defaultZoom)),
+ FuncRequest(LFUN_BUFFER_ZOOM)));
+ add(MenuItem(MenuItem::Separator));
+ add(MenuItem(MenuItem::Command, qt_("Zoom In|I"),
+ FuncRequest(LFUN_BUFFER_ZOOM_IN)));
+ add(MenuItem(MenuItem::Command, qt_("Zoom Out|O"),
+ FuncRequest(LFUN_BUFFER_ZOOM_OUT)));
+ add(MenuItem(MenuItem::Separator));
+ // Offer some fractional values of the default
+ int z = lyxrc.defaultZoom * 1.75;
+ add(MenuItem(MenuItem::Command,
+ toqstr(bformat(_("[[ZOOM]]%1$d%"), z)),
+ FuncRequest(LFUN_BUFFER_ZOOM, convert<string>(z))));
+ z = lyxrc.defaultZoom * 1.5;
+ add(MenuItem(MenuItem::Command,
+ toqstr(bformat(_("[[ZOOM]]%1$d%"), z)),
+ FuncRequest(LFUN_BUFFER_ZOOM, convert<string>(z))));
+ z = lyxrc.defaultZoom * 1.25;
+ add(MenuItem(MenuItem::Command,
+ toqstr(bformat(_("[[ZOOM]]%1$d%"), z)),
+ FuncRequest(LFUN_BUFFER_ZOOM, convert<string>(z))));
+ z = lyxrc.defaultZoom * 0.75;
+ add(MenuItem(MenuItem::Command,
+ toqstr(bformat(_("[[ZOOM]]%1$d%"), z)),
+ FuncRequest(LFUN_BUFFER_ZOOM, convert<string>(z))));
+ z = lyxrc.defaultZoom * 0.5;
+ add(MenuItem(MenuItem::Command,
+ toqstr(bformat(_("[[ZOOM]]%1$d%"), z)),
+ FuncRequest(LFUN_BUFFER_ZOOM, convert<string>(z))));
+ z = lyxrc.defaultZoom * 0.25;
+ add(MenuItem(MenuItem::Command,
+ toqstr(bformat(_("[[ZOOM]]%1$d%"), z)),
+ FuncRequest(LFUN_BUFFER_ZOOM, convert<string>(z))));
+}
+
+
void MenuDefinition::expandQuotes(BufferView const * bv)
{
if (!bv)
tomenu.expandQuotes(bv);
break;
+ case MenuItem::ZoomOptions:
+ tomenu.expandZoomOptions(bv);
+ break;
+
case MenuItem::Submenu: {
MenuItem item(*cit);
item.setSubmenu(MenuDefinition(cit->submenuname()));