Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multi-row icon bar #3230

Open
edreamleo opened this issue Mar 31, 2023 · 0 comments
Open

Multi-row icon bar #3230

edreamleo opened this issue Mar 31, 2023 · 0 comments
Milestone

Comments

@edreamleo
Copy link
Member

edreamleo commented Mar 31, 2023

I just ran across the following file from lukagolibrodo. I'm not sure how useful the above would be.

#@+leo-ver=5-thin
#@+node:lukagolibrodo.20210329145317.1: * @file /home/me/leo-environment/MakeIconbarMultirow.py
#@@language python

from leo.core.leoQt import QtWidgets, QtCore

# This script make iconbar always expanded. Mainly based on this solution:
#https://stackoverflow.com/questions/55930004/keep-qtoolbar-showing-always-all-items


class eventfilterinst(QtCore.QObject):
    def eventFilter(self, obj, event):
        if event.type() == QtCore.QEvent.Leave: # and obj is qt_widget:
            return True
        return super().eventFilter(obj, event)

#first, do it immediately
#@+<<hacks for iconbar>>
#@+node:lukagolibrodo.20210329151339.1: ** <<hacks for iconbar>>
iconbar=c.frame.iconBar.w
lay = iconbar.findChild(QtWidgets.QLayout)
if lay is not None:
    lay.setExpanded(True)

button = iconbar.findChild(QtWidgets.QToolButton, "qt_toolbar_ext_button")
if button is not None:
    button.setFixedSize(0, 0)

ieventfilterinst=eventfilterinst()
c.frame.iconBar.w.installEventFilter(ieventfilterinst)
#@-<<hacks for iconbar>>

#maybe there is some elegant solution, but if only to expand iconbar it overlaps with body and tree areas -> so just enlarge it
c.frame.iconBar.w.setFixedHeight(100)

#second, register hook (if not, behavoir of iconbar reset when save)
#this code may be dirty because every time new objects are created
def expandiconbar(tag, keywords):
    global ieventfilterinst #?
    #@+<<hacks for iconbar>>
    #@+node:lukagolibrodo.20210329151339.1: ** <<hacks for iconbar>>
    iconbar=c.frame.iconBar.w
    lay = iconbar.findChild(QtWidgets.QLayout)
    if lay is not None:
        lay.setExpanded(True)

    button = iconbar.findChild(QtWidgets.QToolButton, "qt_toolbar_ext_button")
    if button is not None:
        button.setFixedSize(0, 0)

    ieventfilterinst=eventfilterinst()
    c.frame.iconBar.w.installEventFilter(ieventfilterinst)
    #@-<<hacks for iconbar>>

g.registerHandler('save2',expandiconbar)

g.es('fin')

#@-leo

Notes

I have never gotten QMainWindow.addToolBarBreak() to work.

The following works, but does not put the two toolbars on separate rows:

toolbar = QToolBar()
c.frame.top.addToolBar(toolbar)  # c.frame.top is a `DynamicWindow`, a subclass of `QMainWindow`.

QToolBar shows a "extension" icon for large numbers of icons. Clicking this icon shows all icons on separate rows.

Summary

I have spent too much time on this issue. Somebody else will have to finish it.

@edreamleo edreamleo added this to the 6.7.3 milestone Mar 31, 2023
@edreamleo edreamleo self-assigned this Mar 31, 2023
@edreamleo edreamleo modified the milestones: 6.7.3, 6.7.4 Apr 9, 2023
@edreamleo edreamleo modified the milestones: 6.7.4, 6.7.3 Apr 18, 2023
@edreamleo edreamleo modified the milestones: 6.7.4, 6.7.5, Later Jun 13, 2023
@edreamleo edreamleo removed their assignment Jun 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant