Here a patch which makes the toolbar icon size changeable. The size could be changed by the toolbar popup menu. It also saves the size when quiting and restores it the next time opening lyx.
This are the related Status.15x items: * Icons in the toolbars do not have the correct size, they are stretched a few pixels compared to 1.4. This makes the images look jagged and the initial window size has also become to small to show the whole toolbar (Joost 4/11/06). See also the math panel buttons entry above. * TODO toolbar popup menu, currently disabled (Peter 9/11/06) Peter
Index: src/frontends/Application.h =================================================================== --- src/frontends/Application.h (revision 16071) +++ src/frontends/Application.h (working copy) @@ -172,7 +172,7 @@ /// Create the main window with given geometry settings. LyXView & createView(unsigned int width, unsigned int height, - int posx, int posy, bool maximize); + int posx, int posy, bool maximize, unsigned int iconSizeXY); /// LyXView const & currentView() const; Index: src/frontends/LyXView.h =================================================================== --- src/frontends/LyXView.h (revision 16071) +++ src/frontends/LyXView.h (working copy) @@ -87,7 +87,8 @@ unsigned int width, unsigned int height, int posx, int posy, - bool maximize) = 0; + bool maximize, + unsigned int iconSizeXY) = 0; /// save the geometry state in the session manager. virtual void saveGeometry() = 0; Index: src/frontends/qt4/GuiView.h =================================================================== --- src/frontends/qt4/GuiView.h (revision 16071) +++ src/frontends/qt4/GuiView.h (working copy) @@ -59,7 +59,8 @@ unsigned int width, unsigned int height, int posx, int posy, - bool maximize); + bool maximize, + unsigned int iconSizeXY); virtual void saveGeometry(); virtual void busy(bool); Toolbars::ToolbarPtr makeToolbar(ToolbarBackend::Toolbar const & tbb); @@ -93,8 +94,10 @@ /// populate a toplevel menu and all its children on demand void updateMenu(QAction *); - void currentTabChanged (int index); + void currentTabChanged(int index); + void iconSizeChanged(int iconSize); + protected: /// make sure we quit cleanly virtual void closeEvent(QCloseEvent * e); @@ -130,6 +133,22 @@ GuiViewPrivate& d; }; +class IconSiceAction : public QAction +{ + Q_OBJECT +public: + IconSiceAction(QObject *parent, int iconSize); + +public Q_SLOTS: + void QAction_triggered(); + +Q_SIGNALS: + void triggered(int iconSize); + +private: + int iconSize_; +}; + } // namespace frontend } // namespace lyx Index: src/frontends/qt4/GuiView.C =================================================================== --- src/frontends/qt4/GuiView.C (revision 16071) +++ src/frontends/qt4/GuiView.C (working copy) @@ -6,6 +6,7 @@ * \author Lars Gullik Bjønnes * \author John Levon * \author Abdelrazak Younes + * \author Peter Kümmel * * Full author contact details are available in file CREDITS. */ @@ -52,6 +53,7 @@ #include <QDesktopWidget> #include <QVBoxLayout> + #include <boost/bind.hpp> using std::endl; @@ -89,6 +91,76 @@ } }; +IconSiceAction::IconSiceAction(QObject *parent, int iconSize) : QAction(parent), iconSize_(iconSize) +{ + QString text; + text.setNum(iconSize); + // TODO: translate + text.prepend("Size: "); + setText(text); + + setCheckable(true); + + QObject::connect(this, SIGNAL(triggered()), this, SLOT(QAction_triggered())); +} + +void IconSiceAction::QAction_triggered() +{ + // emit signal + triggered(iconSize_); +} + + +class ToolBarPopup : public QMenu +{ +public: + + ToolBarPopup(QMainWindow *parent) : QMenu(parent) + { + std::vector<int> sizes; + + // here are the available icon sizes hardcoded + sizes.push_back( 8); + sizes.push_back(12); + sizes.push_back(16); + sizes.push_back(18); + sizes.push_back(22); + sizes.push_back(26); + sizes.push_back(28); + + QActionGroup *iconSizeGroup = new QActionGroup(parent); + iconSizeGroup->setExclusive(true); + iconSizeGroup->setVisible(true); + iconSizeGroup->setEnabled(true); + + typedef std::pair<int, IconSiceAction*> ActionPair; + typedef std::map <int, IconSiceAction*>::iterator ActionIt; + std::map <int, IconSiceAction*> actions; + + for (size_t i = 0; i<sizes.size(); i++) + { + int size = sizes[i]; + IconSiceAction *icon = new IconSiceAction(iconSizeGroup, size); + connect(icon, SIGNAL(triggered(int)), parent, SLOT(iconSizeChanged(int))); + addAction(icon); + actions.insert(ActionPair(size, icon)); + } + + ActionIt it = actions.find(parent->iconSize().width()); + if (it != actions.end()) + it->second->setChecked(true); + else + { + // add actual size to the menu + int size = parent->iconSize().width(); + IconSiceAction *icon = new IconSiceAction(iconSizeGroup, size); + connect(icon, SIGNAL(triggered(int)), parent, SLOT(iconSizeChanged(int))); + addAction(icon); + icon->setChecked(true); + } + } +}; + struct GuiView::GuiViewPrivate { typedef std::map<int, FuncRequest> FuncMap; @@ -110,11 +182,8 @@ GuiView::GuiView(int id) : QMainWindow(), LyXView(id), commandbuffer_(0), d(*new GuiViewPrivate) { -// setToolButtonStyle(Qt::ToolButtonIconOnly); -// setIconSize(QSize(12,12)); + // bufferview_.reset(new BufferView(this, width, height)); -// bufferview_.reset(new BufferView(this, width, height)); - #ifndef Q_WS_MACX // assign an icon to main form. We do not do it under Qt/Mac, // since the icon is provided in the application bundle. @@ -140,9 +209,14 @@ { // disable toolbar popup menu // Qt docs: Ownership of the popup menu is transferred to the caller. - return new QMenu; + return new ToolBarPopup(this); } +void GuiView::iconSizeChanged(int iconSize) +{ + setIconSize(QSize(iconSize,iconSize)); +} + void GuiView::init() { menubar_.reset(new QLMenubar(this, menubackend)); @@ -187,6 +261,7 @@ session.sessionInfo().save("WindowWidth", convert<string>(geometry.width())); session.sessionInfo().save("WindowHeight", convert<string>(geometry.height())); session.sessionInfo().save("WindowIsMaximized", (isMaximized() ? "yes" : "no")); + session.sessionInfo().save("IconSizeXY", convert<string>(iconSize().width())); if (lyxrc.geometry_xysaved) { session.sessionInfo().save("WindowPosX", convert<string>(geometry.x() + d.posx_offset)); session.sessionInfo().save("WindowPosY", convert<string>(geometry.y() + d.posy_offset)); @@ -197,8 +272,14 @@ void GuiView::setGeometry(unsigned int width, unsigned int height, int posx, int posy, - bool maximize) + bool maximize, + unsigned int iconSizeXY) { + if (iconSizeXY > 8) + setIconSize(QSize(iconSizeXY, iconSizeXY)); + else + setIconSize(QSize(28, 28)); + // only true when the -geometry option was NOT used if (width != 0 && height != 0) { if (posx != -1 && posy != -1) { Index: src/frontends/Application.C =================================================================== --- src/frontends/Application.C (revision 16071) +++ src/frontends/Application.C (working copy) @@ -51,7 +51,8 @@ LyXView & Application::createView(unsigned int width, unsigned int height, int posx, int posy, - bool maximize) + bool maximize, + unsigned int iconSizeXY) { int view_id = gui().newView(); LyXView & view = gui().view(view_id); @@ -61,7 +62,7 @@ /*int workArea_id_ =*/ gui().newWorkArea(width, height, view_id); view.init(); - view.setGeometry(width, height, posx, posy, maximize); + view.setGeometry(width, height, posx, posy, maximize, iconSizeXY); setCurrentView(view); Index: src/lyx_main.C =================================================================== --- src/lyx_main.C (revision 16071) +++ src/lyx_main.C (working copy) @@ -560,6 +560,7 @@ // initial geometry unsigned int width = 690; unsigned int height = 510; + unsigned int iconSizeXY = 26; bool maximize = false; // first try lyxrc if (lyxrc.geometry_width != 0 && lyxrc.geometry_height != 0 ) { @@ -576,6 +577,9 @@ height = convert<unsigned int>(val); if (session().sessionInfo().load("WindowIsMaximized") == "yes") maximize = true; + val = session().sessionInfo().load("IconSizeXY"); + if (!val.empty()) + iconSizeXY = convert<unsigned int>(val); } // if user wants to restore window position @@ -595,7 +599,7 @@ height = 0; } // create the main window - LyXView * view = &pimpl_->application_->createView(width, height, posx, posy, maximize); + LyXView * view = &pimpl_->application_->createView(width, height, posx, posy, maximize, iconSizeXY); return view; }