Dark mode

Here is a nice script for those who love fancy "dark mode":


palette = RBA::QPalette::new palette.setColorGroup(RBA::QPalette::Active, RBA::QBrush::new(RBA::QColor::new("#f0f0f0")), # windowText RBA::QBrush::new(RBA::QColor::new("#303030")), # button RBA::QBrush::new(RBA::QColor::new("#505050")), # light RBA::QBrush::new(RBA::QColor::new("#707070")), # dark RBA::QBrush::new(RBA::QColor::new("#909090")), # mid RBA::QBrush::new(RBA::QColor::new("#e0e0e0")), # text RBA::QBrush::new(RBA::QColor::new("#909090")), # brightText RBA::QBrush::new(RBA::QColor::new("#202020")), # base RBA::QBrush::new(RBA::QColor::new("#101010")), # window ) palette.setColorGroup(RBA::QPalette::Inactive, RBA::QBrush::new(RBA::QColor::new("#f0f0f0")), # windowText RBA::QBrush::new(RBA::QColor::new("#303030")), # button RBA::QBrush::new(RBA::QColor::new("#505050")), # light RBA::QBrush::new(RBA::QColor::new("#707070")), # dark RBA::QBrush::new(RBA::QColor::new("#909090")), # mid RBA::QBrush::new(RBA::QColor::new("#e0e0e0")), # text RBA::QBrush::new(RBA::QColor::new("#909090")), # brightText RBA::QBrush::new(RBA::QColor::new("#202020")), # base RBA::QBrush::new(RBA::QColor::new("#101010")), # window ) palette.setColorGroup(RBA::QPalette::Disabled, RBA::QBrush::new(RBA::QColor::new("#808080")), # windowText RBA::QBrush::new(RBA::QColor::new("#303030")), # button RBA::QBrush::new(RBA::QColor::new("#505050")), # light RBA::QBrush::new(RBA::QColor::new("#606060")), # dark RBA::QBrush::new(RBA::QColor::new("#686868")), # mid RBA::QBrush::new(RBA::QColor::new("#707070")), # text RBA::QBrush::new(RBA::QColor::new("#686868")), # brightText RBA::QBrush::new(RBA::QColor::new("#202020")), # base RBA::QBrush::new(RBA::QColor::new("#101010")), # window ) RBA::QApplication::setPalette(palette)

Set the "run on startup" flag and enjoy night mode:

Matthias

Comments

  • Hi Matthias,

    Thanks a lot for the "dark mode" script! Personally, I prefer to use "dark mode" whenever it is available.

    I noticed two things:

    1) The top bar of the main window (with the menus) and the top bar of the layout panel(s) seem to stay "light" in my case and the menu names are hardly readable...

    2) The "Macro Development" window still has quite some "light" sub areas and the names of the folders and files in the "Local" map are hardly readable...

    Maybe it is related to the the KLayout version, 0.28 <> 0.27.9?

    Cheers,

    Tomas

  • Ok, I need to say that was a first shot :)

    I understand that Qt borrows parts of the styling from the underlying system. On Windows that's probably tab widgets and similar. I guess the way to do that properly is to use Qt style sheets rather simply changing the palette.

    On Linux however, the script works rather nicely. Some icons are hard to see, but as I said - that's a first shot only.

    Matthias

  • Your approach is excellent. I referenced your code and made modifications using GPT, and now it works very well on Windows systems too.

    app = RBA::QApplication::instance
    return if app.nil?
    
    RBA::QApplication::setStyle("Fusion")
    
    palette = RBA::QPalette::new
    
    [:Active, :Inactive].each do |state|
      palette.setColorGroup(
        RBA::QPalette.const_get(state),
    
        RBA::QBrush::new(RBA::QColor::new("#ffffff")), # windowText
        RBA::QBrush::new(RBA::QColor::new("#2d2d30")), # button
        RBA::QBrush::new(RBA::QColor::new("#3e3e42")), # light
        RBA::QBrush::new(RBA::QColor::new("#1e1e1e")), # dark
        RBA::QBrush::new(RBA::QColor::new("#2a2a2a")), # mid
        RBA::QBrush::new(RBA::QColor::new("#e6e6e6")), # text
        RBA::QBrush::new(RBA::QColor::new("#ffffff")), # brightText
        RBA::QBrush::new(RBA::QColor::new("#1e1e1e")), # base
        RBA::QBrush::new(RBA::QColor::new("#1e1e1e"))  # window
      )
    end
    
    palette.setColorGroup(
      RBA::QPalette::Disabled,
    
      RBA::QBrush::new(RBA::QColor::new("#7a7a7a")), # windowText
      RBA::QBrush::new(RBA::QColor::new("#2d2d30")), # button
      RBA::QBrush::new(RBA::QColor::new("#3a3a3a")), # light
      RBA::QBrush::new(RBA::QColor::new("#1a1a1a")), # dark
      RBA::QBrush::new(RBA::QColor::new("#2a2a2a")), # mid
      RBA::QBrush::new(RBA::QColor::new("#8a8a8a")), # text
      RBA::QBrush::new(RBA::QColor::new("#7a7a7a")), # brightText
      RBA::QBrush::new(RBA::QColor::new("#1e1e1e")), # base
      RBA::QBrush::new(RBA::QColor::new("#1e1e1e"))  # window
    )
    
    RBA::QApplication::setPalette(palette)
    

    Below is the result of using Klayout 0.30.4 on my Windows 11 system.

Sign In or Register to comment.