Skip to content

Implementation of Material Design 2 for the Switch component.

License

Notifications You must be signed in to change notification settings

CM0use/SwitchButton

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

SwitchButton

Windows macOS Linux

Implementation of Material Design 2 for the Switch component.

FeaturesDescriptionUseContributingReferencesLicense

light dark

Features

  • The color palette is based on Chrome aesthetics.
  • You can customize the track and thumb colors.
  • Easy to use and understand.

Description

Based on Material Design 2 used by Google and other applications.

This repository was created to improve the functionality of Switch/Toggle that do not have the expected functionality or are too complex. These Switch/Toggle often do not allow to place a text next to it that is activated when clicking on it or in the surrounding area.

The color palette can be changed according to the theme you are using with the setThemeDark and setThemeLight methods.
You can also customize the color palette with the setTrackColor and setThumbColor methods to change the track and thumb colors.

Use

#include "switchbutton.h"

int main()
{
  // ...

  bool themeDarkIsOn{ true };

  // Add the text "myText" next to the SwitchButton and enable Chrome's dark theme
  SwitchButton *_switch{ new SwitchButton("myText", themeDarkIsOn) };

  // Add the text "myText" next to the SwitchButton and enable Chrome's light theme
  SwitchButton *_switch2{ new SwitchButton("myText", !themeDarkIsOn) };

  // Change the track and thumb color palette
  _switch.setTrackColor(QColor{ "#0f0" }, QColor{ "#00f" });
  _switch.setThumbColor(QColor{ "#f00" }, QColor{ "#ff0" });

  // Change the color palette of the SwitchButton
  _switch.setThemeLight();
  _switch.setThemeDark();

  // ...
}

Contributing

Any contribution you make will be greatly appreciated.
If you have any ideas/suggestions to improve this repository, make a fork and create a pull request.
You can also open the issue tracker to report any improvements or bugs.

References

Toggle Switch in Qt
PyToggle
Qt Material Design Desktop Widgets

License

Distributed under the GNU General Public License v3.0
See accompanying file LICENSE
or copy at GNU General Public License