Grubuntu / PieMenu

Fork of PieMenu, with some improvements
8 stars 4 forks source link

Big new update #15

Closed pgilfernandez closed 7 months ago

pgilfernandez commented 7 months ago

Hi @Grubuntu,

I've been busy last 4-5 days with real life but yesterday and today I was able to work on a few things that I wanted to do with this branch. Most of the work is done, test it and let me know as I have done some "big" changes to the GUI and UX, here is more or less what I did:

The only issue I found is that as I moved the "fillet/chamfer" fast radius setting to be styleable, I don't know why but if you change stylesheet, it doesn't updates with the new stylesheet till you reboot FreeCAD... Let me know if you like it =)

Grubuntu commented 7 months ago

Hi Thanks !

I've been busy last 4-5 days with real life

Don't worry we all have our professional and family obligations :)

Great works. But the first attempts were not successful for me (on Windows 10) This fails to load the edit_OK and edit_Cancel icons (I checked many times that files are really in the good place)

If I print the content of 'styleCurrentTheme' :

styleCurrentTheme = styleCurrentTheme.replace("pieMenuQss:", stylepath)
print(styleCurrentTheme)

the URL to the image is :

QToolButton#styleComboCancel {
    image: url(D:\FreeCAD\FreeCAD_weekly-builds-35449-2023-12-22-conda-Windows-x86_64-py310\Mod\PieMenu/Resources/Stylesheets/images_dark-light/edit_Cancel.svg);
}

I think mix of backslashs and slashs doesn't make Windows happy. If I write directly the good URL in the QSS file like this, it is OK:

QToolButton#styleComboValid {
    image: url(D:/FreeCAD/FreeCAD_weekly-builds-35449-2023-12-22-conda-Windows-x86_64-py310/Mod/PieMenu/Resources/Stylesheets/images_dark-light/edit_OK.svg);
}

I will try to understand how to solve the problem...


The only issue I found is that as I moved the "fillet/chamfer" fast radius setting to be styleable, I don't know why but if you change stylesheet, it doesn't updates with the new stylesheet till you reboot FreeCAD... Let me know if you like it =)

We're going to redefine the style at line 804 and 809 (instead of lines 659 and 671), it will be update each time the are show : Add code at lines 805 and 810 (and comment line 659 and 671):

               if (Gui.ActiveDocument.getInEdit() != None):
                    """ or show Valid and Cancel buttons in Edit Feature Only """
                    buttonValid = self.validButton()

                    buttonValid.setStyleSheet(styleCurrentTheme)

                    buttonValid.setParent(self.menu)
                    buttonValid.clicked.connect(self.validation)
                    self.buttons.append(buttonValid)

                    buttonCancel = self.cancelButton()

                    buttonCancel.setStyleSheet(styleCurrentTheme)

                    buttonCancel.setParent(self.menu)
                    buttonCancel.clicked.connect(self.cancel)
                    self.buttons.append(buttonCancel)
Grubuntu commented 7 months ago
  • Removed on pie dropdown menu to make them simpler
  • Added cancel button "ring" to help closing pies faster and let user have a visual reference of pie center

Greats ideas, It's much better like this, it's more intuitive and beautiful. Well done.

pgilfernandez commented 7 months ago

I think mix of backslashs and slashs doesn't make Windows happy. If I write directly the good URL in the QSS file like this, it is OK:

QToolButton#styleComboValid {
    image: url(D:/FreeCAD/FreeCAD_weekly-builds-35449-2023-12-22-conda-Windows-x86_64-py310/Mod/PieMenu/Resources/Stylesheets/images_dark-light/edit_OK.svg);
}

I will try to understand how to solve the problem...

Ohh, yes, I understand, the problem are the backslashs and slashs... each OS handle it in a different way and we were forcing them here, doesn't it?:

    path = locator.path()
    respath = path + "/Resources/icons/"
    stylepath = path + "/Resources/Stylesheets/"

But then, why it worked before?

We're going to redefine the style at line 804 and 809 (instead of lines 659 and 671), it will be update each time the are show : Add code at lines 805 and 810 (and comment line 659 and 671):

Umm, doing this changes I lost the "OK" and "Cancel" icons... they are gone and before they were working right... any idea why?

Grubuntu commented 7 months ago

DIY solution to replace backslashs, while waiting to find better way...

    path = locator.path()
    respath = path + "/Resources/icons/"
    respath = respath.replace("\\" , "/")
    stylepath = path + "/Resources/Stylesheets/"
    stylepath = stylepath.replace("\\" , "/")

Moreover styleCurrentTheme is redefined elsewhere in the code (in setTheme and getTheme ) , we need to modify these occurences with your code : styleCurrentTheme = styleCurrentTheme.replace("pieMenuQss:", stylepath)

   def setTheme():
        comboBoxTheme.blockSignals(True)
        # Get the selected stylesheet from the combobox
        theme = comboBoxTheme.currentText()
        # Set Theme in parameters
        paramGet.SetString("Theme", theme)
        # Get qss file
        stylesheet_path = f"{stylepath}{theme}.qss"
        with open(stylesheet_path, "r") as f:
            styleCurrentTheme = f.read()

        styleCurrentTheme = styleCurrentTheme.replace("pieMenuQss:", stylepath)

        comboBoxTheme.blockSignals(False)
        return styleCurrentTheme

    def getTheme():
        ## TODO : warn user if there is no stylesheet
        # Listez tous les fichiers dans le répertoire
        all_files = os.listdir(stylepath)
        # Filtrez les fichiers avec l'extension ".qss"
        qss_files = [file for file in all_files if file.endswith(".qss")]
        # Supprimez l'extension ".qss" pour obtenir les noms des styles
        available_styles = [file[:-4] for file in qss_files]
        # Clear existing items in the combobox
        comboBoxTheme.blockSignals(True)
        comboBoxTheme.clear()
        # Add available stylesheets to the combobox
        comboBoxTheme.addItems(available_styles)
        # Set the current index based on the stored theme preference
        theme = paramGet.GetString("Theme")
        index = comboBoxTheme.findText(theme)
        if index != -1:
            comboBoxTheme.setCurrentIndex(index)

        stylesheet_path = f"{stylepath}{theme}.qss"
        with open(stylesheet_path, "r") as f:
            styleCurrentTheme = f.read()
            #print('gettheme : ', styleCurrentTheme)
        comboBoxTheme.blockSignals(False)

        styleCurrentTheme = styleCurrentTheme.replace("pieMenuQss:", stylepath)

        return styleCurrentTheme

I will try to do more tests tomorrow.

Grubuntu commented 7 months ago
  • Removed on pie dropdown menu to make them simpler

I just realized that by removing the quickmenu we lose :

Capture d’écran (6)

pgilfernandez commented 7 months ago

Could be move all of that to Preferences?

Grubuntu commented 7 months ago

Could be move all of that to Preferences?

I don't think it will be so easy through the Accessories > PieMenu to set rapidly a temporary Toolbar.

Moreover when you set a temporary ToolBar via ToolBar menu, after you need to re-set the previous PieMenu it would be unproductive to have to go back to the preferences to do it.

In this demonstration I used only one shortcutkey. ToolBar

Some menus do not have enough contrast, it is difficult to see when a shortcut is checked.

Capture d’écran (8)

Grubuntu commented 7 months ago

I will work on an option in preferences to set to show or not the QuickMenu.

pgilfernandez commented 7 months ago

I will work on an option in preferences to set to show or not the QuickMenu.

That's a nice solution. BTW, the toolbar "fast" pies loose interest once you are able to create a bunch of pies to fit your needs. I mean, it was added when you only could have just one pie, so switching to another one made sense. Now, with the power of creating any number of pies (and assign individual shortcuts to them), I think the toolbar "fast" pies are not needed anymore... unless when creating a new pie there is an option to "copy" commands from a toolbar.

It's just an opinion on how user experience will be but I may be wrong so, your idea to keep it optional makes sense... but, I would only add the options to switch pie to another "toolbar", not all the other options that are already moved to Preferences and should be access via Menu/Accesories/Piemenu

What do you think about it?