├── Doxyfile ├── app.pri ├── doc.src ├── ActionBox.png ├── ActionGroup.png ├── ActionLabel.png ├── ActionPanel1.png ├── ActionPanel2.png ├── ActionPanel3.png ├── ActionPanel4.png ├── ActionPanel5.png ├── ActionPanel6.png ├── Changes.txt ├── ColorButton.png ├── ColorButtons.png ├── ColorGrid.png ├── ColumnChart.png ├── Dial.png ├── DoubleSpinComboBox.png ├── Footer.html ├── Install.txt ├── LedWidget.png ├── MainPage.txt ├── OptionSlider.png ├── PathPicker.png ├── PieChart.png ├── QSint.0.2.png ├── QSint.png ├── RingChart.png ├── RoundBars.png ├── Slider2d.png ├── SpinComboBox.png ├── SpinSlider.png ├── StackedChart.png ├── TabListMenu.png └── TrendChart.png ├── examples ├── actionlabel │ ├── actionlabel.pro │ ├── main.cpp │ ├── mainwindow.cpp │ ├── mainwindow.h │ ├── mainwindow.ui │ ├── res.qrc │ └── res │ │ ├── editcopy.png │ │ ├── editcut.png │ │ ├── editpaste.png │ │ ├── editredo.png │ │ ├── editundo.png │ │ ├── exportpdf.png │ │ ├── filenew.png │ │ ├── fileopen.png │ │ ├── fileprint.png │ │ ├── filesave.png │ │ ├── textbold.png │ │ ├── textcenter.png │ │ ├── textitalic.png │ │ ├── textjustify.png │ │ ├── textleft.png │ │ ├── textright.png │ │ ├── textunder.png │ │ ├── zoomin.png │ │ └── zoomout.png ├── actionpanel │ ├── actionpanel.pro │ ├── main.cpp │ ├── mainwindow.cpp │ ├── mainwindow.h │ ├── mainwindow.ui │ ├── res.qrc │ └── res │ │ ├── editcopy.png │ │ ├── editcut.png │ │ ├── editpaste.png │ │ ├── editredo.png │ │ ├── editundo.png │ │ ├── exportpdf.png │ │ ├── filenew.png │ │ ├── fileopen.png │ │ ├── fileprint.png │ │ ├── filesave.png │ │ ├── textbold.png │ │ ├── textcenter.png │ │ ├── textitalic.png │ │ ├── textjustify.png │ │ ├── textleft.png │ │ ├── textright.png │ │ ├── textunder.png │ │ ├── zoomin.png │ │ └── zoomout.png ├── buttons │ ├── buttons.pro │ ├── main.cpp │ ├── mainwindow.cpp │ ├── mainwindow.h │ ├── mainwindow.ui │ ├── res.qrc │ └── res │ │ ├── editcopy.png │ │ ├── editcut.png │ │ ├── editpaste.png │ │ ├── editredo.png │ │ ├── editundo.png │ │ ├── exportpdf.png │ │ ├── filenew.png │ │ ├── fileopen.png │ │ ├── fileprint.png │ │ ├── filesave.png │ │ ├── textbold.png │ │ ├── textcenter.png │ │ ├── textitalic.png │ │ ├── textjustify.png │ │ ├── textleft.png │ │ ├── textright.png │ │ ├── textunder.png │ │ ├── zoomin.png │ │ └── zoomout.png ├── chartwidgets │ ├── chartwidgets.pro │ ├── main.cpp │ ├── mainwidget.cpp │ ├── mainwidget.h │ └── mainwidget.ui ├── colorgrid │ ├── colorgrid.pro │ ├── main.cpp │ ├── mainwindow.cpp │ ├── mainwindow.h │ └── mainwindow.ui ├── exampleapp.pri ├── examples.pro ├── ledwidget │ ├── ledwidget.pro │ ├── ledwidgetdemo.cpp │ ├── ledwidgetdemo.h │ ├── ledwidgetdemo.ui │ └── main.cpp ├── pathpicker │ ├── icons.qrc │ ├── icons │ │ ├── fileopen.png │ │ └── filesave.png │ ├── main.cpp │ ├── mainwindow.cpp │ ├── mainwindow.h │ ├── mainwindow.ui │ └── pathpicker.pro ├── roundprogressbar │ ├── main.cpp │ ├── roundprogressbar.pro │ ├── testwidget.cpp │ ├── testwidget.h │ └── testwidget.ui ├── simplecharts │ ├── main.cpp │ ├── mainwidget.cpp │ ├── mainwidget.h │ ├── mainwidget.ui │ └── simplecharts.pro ├── simplecharts2 │ ├── main.cpp │ ├── mainwidget.cpp │ ├── mainwidget.h │ ├── mainwidget.ui │ └── simplecharts2.pro ├── slider │ ├── main.cpp │ ├── mainwindow.cpp │ ├── mainwindow.h │ ├── mainwindow.ui │ └── slider.pro └── timepicker │ ├── main.cpp │ ├── mainwindow.cpp │ ├── mainwindow.h │ ├── mainwindow.ui │ └── timepicker.pro ├── include ├── QSintActions ├── QSintCharts └── QSintWidgets ├── qsint.pro └── src ├── actions ├── actionbox.cpp ├── actionbox.h ├── actiongroup.cpp ├── actiongroup.h ├── actionlabel.cpp ├── actionlabel.h ├── actionpanel.cpp ├── actionpanel.h ├── actionpanelscheme.cpp ├── actionpanelscheme.h ├── actions.pri ├── android │ ├── Fold.png │ ├── FoldOver.png │ ├── Unfold.png │ └── UnfoldOver.png ├── androidpanelscheme.cpp ├── androidpanelscheme.h ├── default │ ├── Fold.png │ ├── FoldOver.png │ ├── Unfold.png │ └── UnfoldOver.png ├── mac │ ├── FoldOver.png │ └── UnfoldOver.png ├── macpanelscheme.cpp ├── macpanelscheme.h ├── schemes.qrc ├── taskgroup_p.cpp ├── taskgroup_p.h ├── taskheader_p.cpp ├── taskheader_p.h ├── vista │ ├── Fold.png │ ├── FoldOver.png │ ├── Unfold.png │ └── UnfoldOver.png ├── winvistapanelscheme.cpp ├── winvistapanelscheme.h ├── winxppanelscheme.cpp ├── winxppanelscheme.h └── xp │ ├── FoldOver_Blue1.png │ ├── FoldOver_Blue2.png │ ├── Fold_Blue1.png │ ├── Fold_Blue2.png │ ├── UnfoldOver_Blue1.png │ ├── UnfoldOver_Blue2.png │ ├── Unfold_Blue1.png │ └── Unfold_Blue2.png ├── charts ├── axisbase.cpp ├── axisbase.h ├── barchartplotter.cpp ├── barchartplotter.h ├── barpainter.cpp ├── barpainter.h ├── charts.pri ├── columnbarpainter.cpp ├── columnbarpainter.h ├── paintscheme.cpp ├── paintscheme.h ├── piechart.cpp ├── piechart.h ├── piechartwidget.cpp ├── piechartwidget.h ├── plotterbase.cpp ├── plotterbase.h ├── ringchart.cpp ├── ringchart.h ├── ringplotbase.cpp ├── ringplotbase.h ├── stackedbarpainter.cpp ├── stackedbarpainter.h ├── trendpainter.cpp └── trendpainter.h ├── src.pro └── widgets ├── colorbutton.cpp ├── colorbutton.h ├── colorcombobox.cpp ├── colorcombobox.h ├── colordefs.cpp ├── colordefs.h ├── colorgrid.cpp ├── colorgrid.h ├── dial.cpp ├── dial.h ├── doublespincombobox.cpp ├── doublespincombobox.h ├── ledwidget.cpp ├── ledwidget.h ├── pathpicker.cpp ├── pathpicker.h ├── qfontbutton.cpp ├── qfontbutton.h ├── qmenubutton.cpp ├── qmenubutton.h ├── qpenbutton.cpp ├── qpenbutton.h ├── qpencombobox.cpp ├── qpencombobox.h ├── roundprogressbar.cpp ├── roundprogressbar.h ├── slider.cpp ├── slider.h ├── slider2d.cpp ├── slider2d.h ├── spincombobox.cpp ├── spincombobox.h ├── spinslider.cpp ├── spinslider.h ├── splitbutton.cpp ├── splitbutton.h ├── timepicker.cpp ├── timepicker.h └── widgets.pri /app.pri: -------------------------------------------------------------------------------- 1 | TEMPLATE = app 2 | 3 | QT += core gui widgets 4 | CONFIG += c++11 5 | 6 | INCLUDEPATH += $$PWD/include 7 | 8 | -------------------------------------------------------------------------------- /doc.src/ActionBox.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sintegrial/qsint/4b1d13c69e501a1dbf5f1bd381e152ad3b4f3a43/doc.src/ActionBox.png -------------------------------------------------------------------------------- /doc.src/ActionGroup.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sintegrial/qsint/4b1d13c69e501a1dbf5f1bd381e152ad3b4f3a43/doc.src/ActionGroup.png -------------------------------------------------------------------------------- /doc.src/ActionLabel.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sintegrial/qsint/4b1d13c69e501a1dbf5f1bd381e152ad3b4f3a43/doc.src/ActionLabel.png -------------------------------------------------------------------------------- /doc.src/ActionPanel1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sintegrial/qsint/4b1d13c69e501a1dbf5f1bd381e152ad3b4f3a43/doc.src/ActionPanel1.png -------------------------------------------------------------------------------- /doc.src/ActionPanel2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sintegrial/qsint/4b1d13c69e501a1dbf5f1bd381e152ad3b4f3a43/doc.src/ActionPanel2.png -------------------------------------------------------------------------------- /doc.src/ActionPanel3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sintegrial/qsint/4b1d13c69e501a1dbf5f1bd381e152ad3b4f3a43/doc.src/ActionPanel3.png -------------------------------------------------------------------------------- /doc.src/ActionPanel4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sintegrial/qsint/4b1d13c69e501a1dbf5f1bd381e152ad3b4f3a43/doc.src/ActionPanel4.png -------------------------------------------------------------------------------- /doc.src/ActionPanel5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sintegrial/qsint/4b1d13c69e501a1dbf5f1bd381e152ad3b4f3a43/doc.src/ActionPanel5.png -------------------------------------------------------------------------------- /doc.src/ActionPanel6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sintegrial/qsint/4b1d13c69e501a1dbf5f1bd381e152ad3b4f3a43/doc.src/ActionPanel6.png -------------------------------------------------------------------------------- /doc.src/Changes.txt: -------------------------------------------------------------------------------- 1 | /*! \page changes Changes and Features 2 | 3 | \b 0.4.0 4 | 5 | - New widgets: 6 | - QSint::SplitButton 7 | - QSint::QMenuButton 8 | - QSint::QFontButton 9 | - QSint::QPenButton 10 | - QSint::QPenComboBox 11 | - QSint::Dial 12 | - QSint::DoubleSpinComboBox 13 | 14 | - Reintegrated widgets: 15 | - QSint::Slider2d 16 | 17 | - Deprecated widgets: 18 | - QSint::OptionSlider 19 | - QSint::WidgetPopup 20 | 21 | - Charts: 22 | - QSint::PieChartWidget 23 | 24 | 25 | \b 0.3.0 26 | 27 | - \a Core module split into \a Widgets and \a Actions 28 | 29 | 30 | \b 0.2.2 31 | 32 | Changes of \a Core module: 33 | 34 | - New widgets: 35 | - QSint::SpinSlider 36 | - QSint::OptionSlider 37 | - QSint::LedWidget 38 | 39 | Changes of \a Charts module: 40 | 41 | - New widgets: 42 | - QSint::RingChart 43 | 44 | - Improvements: 45 | - Fixed some painting issue 46 | 47 | 48 | 49 | \b 0.2.1 50 | 51 | Since version 0.2.1, QSint library has modular structure. 52 | All the widgets are represented by \a Core module. 53 | 54 | New module \a Charts added, including: 55 | - QSint::BarChartPlotter 56 | - QSint::PieChart 57 | 58 | Changes of \a Core module: 59 | 60 | - New widgets: 61 | - QSint::PathPicker 62 | 63 | - Improvements: 64 | - Added \a AndroidScheme to QSint::ActionPanel 65 | 66 | 67 | 68 | \b 0.2.0 69 | 70 | - Designer Plugin added 71 | 72 | - New widgets: 73 | - QSint::ActionPanel and QSint::ActionGroup 74 | - QSint::ScrollPanner 75 | - QSint::TabListMenu 76 | - QSint::WidgetPopup 77 | 78 | - Improvements: 79 | - Support of \a QAction for QSint::ActionLabel and QSint::ActionBox 80 | 81 | */ 82 | -------------------------------------------------------------------------------- /doc.src/ColorButton.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sintegrial/qsint/4b1d13c69e501a1dbf5f1bd381e152ad3b4f3a43/doc.src/ColorButton.png -------------------------------------------------------------------------------- /doc.src/ColorButtons.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sintegrial/qsint/4b1d13c69e501a1dbf5f1bd381e152ad3b4f3a43/doc.src/ColorButtons.png -------------------------------------------------------------------------------- /doc.src/ColorGrid.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sintegrial/qsint/4b1d13c69e501a1dbf5f1bd381e152ad3b4f3a43/doc.src/ColorGrid.png -------------------------------------------------------------------------------- /doc.src/ColumnChart.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sintegrial/qsint/4b1d13c69e501a1dbf5f1bd381e152ad3b4f3a43/doc.src/ColumnChart.png -------------------------------------------------------------------------------- /doc.src/Dial.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sintegrial/qsint/4b1d13c69e501a1dbf5f1bd381e152ad3b4f3a43/doc.src/Dial.png -------------------------------------------------------------------------------- /doc.src/DoubleSpinComboBox.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sintegrial/qsint/4b1d13c69e501a1dbf5f1bd381e152ad3b4f3a43/doc.src/DoubleSpinComboBox.png -------------------------------------------------------------------------------- /doc.src/Footer.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 |
5 | 6 | © Sintegrial Technologies 2011-2020 7 |
8 | https://sourceforge.net/projects/qsint 9 | 10 |
11 | 12 | -------------------------------------------------------------------------------- /doc.src/Install.txt: -------------------------------------------------------------------------------- 1 | /*! \page install Installation and Usage 2 | 3 | \b Installation 4 | 5 | 1. Make sure that you have Qt installed on your system (if not, you can get it from http:/qt.nokia.com). 6 | Further we'll be calling this directory \a QSINT_ROOT. 7 | 8 | 2. Unpack QSint from archive into a directory, i.e. \a c:/qsint. 9 | 10 | 3. Go into this directory and either open \a qsint.pro with Qt Creator and build from IDE, or use \a qmake and \a make 11 | sequence (depending on which compiler you have installed on your system). 12 | 13 | Depending on your local project/compiler settings, library and binaries will be placed into the directory \a QSINT_BUILD_ROOT 14 | (it can be the same as \a QSINT_ROOT, or different, i.e. \a c:/qsint-build-desktop etc.) 15 | 16 | After successful build process, you will get the library in the \a QSINT_BUILD_ROOT/lib subdirectory and examples executables 17 | in the \a QSINT_BUILD_ROOT/examples subdirectories. 18 | 19 | \b Usage 20 | 21 | To use QSint in your project: 22 | 23 | 1. Add into your .pro file: 24 | 25 | \code 26 | INCLUDEPATH += QSINT_ROOT/include 27 | 28 | // for release version 29 | LIBS += -LQSINT_BUILD_ROOT/lib -lqsint 30 | 31 | // for debug version 32 | LIBS += -LQSINT_BUILD_ROOT/lib -lqsintd 33 | \endcode 34 | 35 | 2. In the .h/.cpp files where QSint widgets are used, put the necessary includes: 36 | 37 | \code 38 | // for Widgets module 39 | #include 40 | 41 | // for ActionPanel module 42 | #include 43 | 44 | // for Charts module 45 | #include 46 | \endcode 47 | 48 | As all the QSint classes are nested within \a QSint namespace, you would also like to use this namespace as well: 49 | 50 | \code 51 | using namespace QSint; 52 | \endcode 53 | 54 | */ 55 | -------------------------------------------------------------------------------- /doc.src/LedWidget.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sintegrial/qsint/4b1d13c69e501a1dbf5f1bd381e152ad3b4f3a43/doc.src/LedWidget.png -------------------------------------------------------------------------------- /doc.src/MainPage.txt: -------------------------------------------------------------------------------- 1 | /*! \mainpage QSint library manual 2 | 3 | \image html QSint.png 4 | 5 | \b QSint is an opensource collection of Qt widgets which can be used while developing own Qt-based applications. 6 | The library is designed to be used with Qt 5.x versions. 7 | 8 | \b QSint::Widgets module contains custom Qt widgets for everyday usage (color pickers, split buttons, sliders etc). 9 | 10 | \b QSint::Actions module contains additional Qt widgets which maintain look-and-feel of Windows XP Task Panels, Windows Vista Actions etc. 11 | 12 | \b QSint::Charts module contains 2D charting components which follow Qt Model-View ideology. 13 | 14 | 15 | 16 | \b QSint is licensed under LGPL so you can use it both in commercial and non-commercial projects. 17 | 18 | See also: 19 | - \ref install 20 | - \ref changes 21 | 22 | © Sintegrial Technologies 2011-2020 23 |
24 | https://sourceforge.net/projects/qsint 25 | */ 26 | 27 | -------------------------------------------------------------------------------- /doc.src/OptionSlider.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sintegrial/qsint/4b1d13c69e501a1dbf5f1bd381e152ad3b4f3a43/doc.src/OptionSlider.png -------------------------------------------------------------------------------- /doc.src/PathPicker.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sintegrial/qsint/4b1d13c69e501a1dbf5f1bd381e152ad3b4f3a43/doc.src/PathPicker.png -------------------------------------------------------------------------------- /doc.src/PieChart.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sintegrial/qsint/4b1d13c69e501a1dbf5f1bd381e152ad3b4f3a43/doc.src/PieChart.png -------------------------------------------------------------------------------- /doc.src/QSint.0.2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sintegrial/qsint/4b1d13c69e501a1dbf5f1bd381e152ad3b4f3a43/doc.src/QSint.0.2.png -------------------------------------------------------------------------------- /doc.src/QSint.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sintegrial/qsint/4b1d13c69e501a1dbf5f1bd381e152ad3b4f3a43/doc.src/QSint.png -------------------------------------------------------------------------------- /doc.src/RingChart.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sintegrial/qsint/4b1d13c69e501a1dbf5f1bd381e152ad3b4f3a43/doc.src/RingChart.png -------------------------------------------------------------------------------- /doc.src/RoundBars.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sintegrial/qsint/4b1d13c69e501a1dbf5f1bd381e152ad3b4f3a43/doc.src/RoundBars.png -------------------------------------------------------------------------------- /doc.src/Slider2d.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sintegrial/qsint/4b1d13c69e501a1dbf5f1bd381e152ad3b4f3a43/doc.src/Slider2d.png -------------------------------------------------------------------------------- /doc.src/SpinComboBox.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sintegrial/qsint/4b1d13c69e501a1dbf5f1bd381e152ad3b4f3a43/doc.src/SpinComboBox.png -------------------------------------------------------------------------------- /doc.src/SpinSlider.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sintegrial/qsint/4b1d13c69e501a1dbf5f1bd381e152ad3b4f3a43/doc.src/SpinSlider.png -------------------------------------------------------------------------------- /doc.src/StackedChart.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sintegrial/qsint/4b1d13c69e501a1dbf5f1bd381e152ad3b4f3a43/doc.src/StackedChart.png -------------------------------------------------------------------------------- /doc.src/TabListMenu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sintegrial/qsint/4b1d13c69e501a1dbf5f1bd381e152ad3b4f3a43/doc.src/TabListMenu.png -------------------------------------------------------------------------------- /doc.src/TrendChart.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sintegrial/qsint/4b1d13c69e501a1dbf5f1bd381e152ad3b4f3a43/doc.src/TrendChart.png -------------------------------------------------------------------------------- /examples/actionlabel/actionlabel.pro: -------------------------------------------------------------------------------- 1 | TARGET = actionlabel 2 | 3 | include(../exampleapp.pri) 4 | 5 | 6 | HEADERS += \ 7 | mainwindow.h 8 | 9 | SOURCES += \ 10 | mainwindow.cpp \ 11 | main.cpp 12 | 13 | FORMS += \ 14 | mainwindow.ui 15 | 16 | RESOURCES += \ 17 | res.qrc 18 | 19 | 20 | -------------------------------------------------------------------------------- /examples/actionlabel/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "mainwindow.h" 3 | 4 | int main(int argc, char *argv[]) 5 | { 6 | QApplication a(argc, argv); 7 | MainWindow w; 8 | w.show(); 9 | a.connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit())); 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /examples/actionlabel/mainwindow.h: -------------------------------------------------------------------------------- 1 | #ifndef MAINWINDOW_H 2 | #define MAINWINDOW_H 3 | 4 | #include 5 | 6 | namespace Ui { 7 | class MainWindow; 8 | } 9 | 10 | class MainWindow : public QWidget 11 | { 12 | Q_OBJECT 13 | 14 | public: 15 | explicit MainWindow(QWidget *parent = 0); 16 | ~MainWindow(); 17 | 18 | protected: 19 | void changeEvent(QEvent *e); 20 | 21 | protected slots: 22 | void executeAction(); 23 | 24 | private: 25 | Ui::MainWindow *ui; 26 | }; 27 | 28 | #endif // MAINWINDOW_H 29 | -------------------------------------------------------------------------------- /examples/actionlabel/res.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | res/fileopen.png 4 | res/fileprint.png 5 | res/filesave.png 6 | 7 | 8 | -------------------------------------------------------------------------------- /examples/actionlabel/res/editcopy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sintegrial/qsint/4b1d13c69e501a1dbf5f1bd381e152ad3b4f3a43/examples/actionlabel/res/editcopy.png -------------------------------------------------------------------------------- /examples/actionlabel/res/editcut.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sintegrial/qsint/4b1d13c69e501a1dbf5f1bd381e152ad3b4f3a43/examples/actionlabel/res/editcut.png -------------------------------------------------------------------------------- /examples/actionlabel/res/editpaste.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sintegrial/qsint/4b1d13c69e501a1dbf5f1bd381e152ad3b4f3a43/examples/actionlabel/res/editpaste.png -------------------------------------------------------------------------------- /examples/actionlabel/res/editredo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sintegrial/qsint/4b1d13c69e501a1dbf5f1bd381e152ad3b4f3a43/examples/actionlabel/res/editredo.png -------------------------------------------------------------------------------- /examples/actionlabel/res/editundo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sintegrial/qsint/4b1d13c69e501a1dbf5f1bd381e152ad3b4f3a43/examples/actionlabel/res/editundo.png -------------------------------------------------------------------------------- /examples/actionlabel/res/exportpdf.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sintegrial/qsint/4b1d13c69e501a1dbf5f1bd381e152ad3b4f3a43/examples/actionlabel/res/exportpdf.png -------------------------------------------------------------------------------- /examples/actionlabel/res/filenew.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sintegrial/qsint/4b1d13c69e501a1dbf5f1bd381e152ad3b4f3a43/examples/actionlabel/res/filenew.png -------------------------------------------------------------------------------- /examples/actionlabel/res/fileopen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sintegrial/qsint/4b1d13c69e501a1dbf5f1bd381e152ad3b4f3a43/examples/actionlabel/res/fileopen.png -------------------------------------------------------------------------------- /examples/actionlabel/res/fileprint.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sintegrial/qsint/4b1d13c69e501a1dbf5f1bd381e152ad3b4f3a43/examples/actionlabel/res/fileprint.png -------------------------------------------------------------------------------- /examples/actionlabel/res/filesave.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sintegrial/qsint/4b1d13c69e501a1dbf5f1bd381e152ad3b4f3a43/examples/actionlabel/res/filesave.png -------------------------------------------------------------------------------- /examples/actionlabel/res/textbold.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sintegrial/qsint/4b1d13c69e501a1dbf5f1bd381e152ad3b4f3a43/examples/actionlabel/res/textbold.png -------------------------------------------------------------------------------- /examples/actionlabel/res/textcenter.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sintegrial/qsint/4b1d13c69e501a1dbf5f1bd381e152ad3b4f3a43/examples/actionlabel/res/textcenter.png -------------------------------------------------------------------------------- /examples/actionlabel/res/textitalic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sintegrial/qsint/4b1d13c69e501a1dbf5f1bd381e152ad3b4f3a43/examples/actionlabel/res/textitalic.png -------------------------------------------------------------------------------- /examples/actionlabel/res/textjustify.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sintegrial/qsint/4b1d13c69e501a1dbf5f1bd381e152ad3b4f3a43/examples/actionlabel/res/textjustify.png -------------------------------------------------------------------------------- /examples/actionlabel/res/textleft.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sintegrial/qsint/4b1d13c69e501a1dbf5f1bd381e152ad3b4f3a43/examples/actionlabel/res/textleft.png -------------------------------------------------------------------------------- /examples/actionlabel/res/textright.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sintegrial/qsint/4b1d13c69e501a1dbf5f1bd381e152ad3b4f3a43/examples/actionlabel/res/textright.png -------------------------------------------------------------------------------- /examples/actionlabel/res/textunder.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sintegrial/qsint/4b1d13c69e501a1dbf5f1bd381e152ad3b4f3a43/examples/actionlabel/res/textunder.png -------------------------------------------------------------------------------- /examples/actionlabel/res/zoomin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sintegrial/qsint/4b1d13c69e501a1dbf5f1bd381e152ad3b4f3a43/examples/actionlabel/res/zoomin.png -------------------------------------------------------------------------------- /examples/actionlabel/res/zoomout.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sintegrial/qsint/4b1d13c69e501a1dbf5f1bd381e152ad3b4f3a43/examples/actionlabel/res/zoomout.png -------------------------------------------------------------------------------- /examples/actionpanel/actionpanel.pro: -------------------------------------------------------------------------------- 1 | TARGET = actionpanel 2 | 3 | include(../exampleapp.pri) 4 | 5 | 6 | HEADERS += \ 7 | mainwindow.h 8 | 9 | SOURCES += \ 10 | mainwindow.cpp \ 11 | main.cpp 12 | 13 | FORMS += \ 14 | mainwindow.ui 15 | 16 | RESOURCES += \ 17 | res.qrc 18 | -------------------------------------------------------------------------------- /examples/actionpanel/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "mainwindow.h" 3 | 4 | int main(int argc, char *argv[]) 5 | { 6 | QApplication a(argc, argv); 7 | MainWindow w; 8 | w.show(); 9 | a.connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit())); 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /examples/actionpanel/mainwindow.cpp: -------------------------------------------------------------------------------- 1 | #include "mainwindow.h" 2 | #include "ui_mainwindow.h" 3 | 4 | #include 5 | #include 6 | 7 | #include 8 | 9 | MainWindow::MainWindow(QWidget *parent) : 10 | QWidget(parent), 11 | ui(new Ui::MainWindow) 12 | { 13 | ui->setupUi(this); 14 | 15 | // create ActionGroups on ActionPanel 16 | 17 | QSint::ActionGroup *group1 = ui->ActionPanel->createGroup(QPixmap(":/res/filesave.png"), "Expandable Group"); 18 | group1->addAction(ui->actionNew); 19 | group1->addAction(ui->actionLoad); 20 | group1->addWidget(new QPushButton("Just a button", this)); 21 | group1->addAction(ui->actionSave); 22 | group1->addAction(ui->actionPrint); 23 | group1->addWidget(new QPushButton("Just another button", this)); 24 | 25 | QSint::ActionGroup *group2 = ui->ActionPanel->createGroup(QPixmap(":/res/editredo.png"), "Non-Expandable Group", false); 26 | group2->addAction(ui->actionNew); 27 | group2->addAction(ui->actionLoad); 28 | group2->addAction(ui->actionSave); 29 | group2->addAction(ui->actionPrint); 30 | 31 | ui->ActionPanel->addWidget(new QLabel("Action Group without header", this)); 32 | 33 | QSint::ActionGroup *group3 = ui->ActionPanel->createGroup(); 34 | group3->addAction(ui->actionNew); 35 | 36 | QHBoxLayout *hbl = new QHBoxLayout(); 37 | group3->groupLayout()->addLayout(hbl); 38 | hbl->addWidget(group3->addAction(ui->actionLoad, false)); 39 | hbl->addWidget(group3->addAction(ui->actionSave, false)); 40 | 41 | group3->addAction(ui->actionPrint); 42 | 43 | ui->ActionPanel->addStretch(); 44 | 45 | 46 | // setup standalone ActionGroup 47 | 48 | ui->ActionGroup1->setScheme(QSint::WinXPPanelScheme::defaultScheme()); 49 | 50 | ui->ActionGroup1->addWidget(ui->rbDefaultScheme); 51 | ui->ActionGroup1->addWidget(ui->rbXPBlueScheme); 52 | ui->ActionGroup1->addWidget(ui->rbXPBlue2Scheme); 53 | ui->ActionGroup1->addWidget(ui->rbVistaScheme); 54 | ui->ActionGroup1->addWidget(ui->rbMacScheme); 55 | ui->ActionGroup1->addWidget(ui->rbAndroidScheme); 56 | 57 | adjustSize(); 58 | } 59 | 60 | MainWindow::~MainWindow() 61 | { 62 | delete ui; 63 | } 64 | 65 | void MainWindow::changeEvent(QEvent *e) 66 | { 67 | QWidget::changeEvent(e); 68 | switch (e->type()) { 69 | case QEvent::LanguageChange: 70 | ui->retranslateUi(this); 71 | break; 72 | default: 73 | break; 74 | } 75 | } 76 | 77 | void MainWindow::executeAction() 78 | { 79 | QMessageBox::about(0, "Action clicked", "Do something here :)"); 80 | } 81 | 82 | void MainWindow::on_rbDefaultScheme_toggled(bool b) 83 | { 84 | if (b) 85 | ui->ActionPanel->setScheme(QSint::ActionPanelScheme::defaultScheme()); 86 | } 87 | 88 | void MainWindow::on_rbXPBlueScheme_toggled(bool b) 89 | { 90 | if (b) 91 | ui->ActionPanel->setScheme(QSint::WinXPPanelScheme::defaultScheme()); 92 | 93 | } 94 | 95 | void MainWindow::on_rbXPBlue2Scheme_toggled(bool b) 96 | { 97 | if (b) 98 | ui->ActionPanel->setScheme(QSint::WinXPPanelScheme2::defaultScheme()); 99 | } 100 | 101 | void MainWindow::on_rbVistaScheme_toggled(bool b) 102 | { 103 | if (b) 104 | ui->ActionPanel->setScheme(QSint::WinVistaPanelScheme::defaultScheme()); 105 | } 106 | 107 | void MainWindow::on_rbMacScheme_toggled(bool b) 108 | { 109 | if (b) 110 | ui->ActionPanel->setScheme(QSint::MacPanelScheme::defaultScheme()); 111 | } 112 | 113 | void MainWindow::on_rbAndroidScheme_toggled(bool b) 114 | { 115 | if (b) 116 | ui->ActionPanel->setScheme(QSint::AndroidPanelScheme::defaultScheme()); 117 | } 118 | 119 | -------------------------------------------------------------------------------- /examples/actionpanel/mainwindow.h: -------------------------------------------------------------------------------- 1 | #ifndef MAINWINDOW_H 2 | #define MAINWINDOW_H 3 | 4 | #include 5 | 6 | namespace Ui { 7 | class MainWindow; 8 | } 9 | 10 | class MainWindow : public QWidget 11 | { 12 | Q_OBJECT 13 | 14 | public: 15 | explicit MainWindow(QWidget *parent = 0); 16 | ~MainWindow(); 17 | 18 | protected: 19 | void changeEvent(QEvent *e); 20 | 21 | protected slots: 22 | void executeAction(); 23 | 24 | void on_rbDefaultScheme_toggled(bool); 25 | void on_rbXPBlueScheme_toggled(bool); 26 | void on_rbXPBlue2Scheme_toggled(bool); 27 | void on_rbVistaScheme_toggled(bool); 28 | void on_rbMacScheme_toggled(bool); 29 | void on_rbAndroidScheme_toggled(bool); 30 | 31 | private: 32 | Ui::MainWindow *ui; 33 | }; 34 | 35 | #endif // MAINWINDOW_H 36 | -------------------------------------------------------------------------------- /examples/actionpanel/res.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | res/editcopy.png 4 | res/editcut.png 5 | res/editpaste.png 6 | res/editredo.png 7 | res/editundo.png 8 | res/exportpdf.png 9 | res/filenew.png 10 | res/fileopen.png 11 | res/fileprint.png 12 | res/filesave.png 13 | res/textbold.png 14 | res/textcenter.png 15 | res/textitalic.png 16 | res/textjustify.png 17 | res/textleft.png 18 | res/textright.png 19 | res/textunder.png 20 | res/zoomin.png 21 | res/zoomout.png 22 | 23 | 24 | -------------------------------------------------------------------------------- /examples/actionpanel/res/editcopy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sintegrial/qsint/4b1d13c69e501a1dbf5f1bd381e152ad3b4f3a43/examples/actionpanel/res/editcopy.png -------------------------------------------------------------------------------- /examples/actionpanel/res/editcut.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sintegrial/qsint/4b1d13c69e501a1dbf5f1bd381e152ad3b4f3a43/examples/actionpanel/res/editcut.png -------------------------------------------------------------------------------- /examples/actionpanel/res/editpaste.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sintegrial/qsint/4b1d13c69e501a1dbf5f1bd381e152ad3b4f3a43/examples/actionpanel/res/editpaste.png -------------------------------------------------------------------------------- /examples/actionpanel/res/editredo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sintegrial/qsint/4b1d13c69e501a1dbf5f1bd381e152ad3b4f3a43/examples/actionpanel/res/editredo.png -------------------------------------------------------------------------------- /examples/actionpanel/res/editundo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sintegrial/qsint/4b1d13c69e501a1dbf5f1bd381e152ad3b4f3a43/examples/actionpanel/res/editundo.png -------------------------------------------------------------------------------- /examples/actionpanel/res/exportpdf.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sintegrial/qsint/4b1d13c69e501a1dbf5f1bd381e152ad3b4f3a43/examples/actionpanel/res/exportpdf.png -------------------------------------------------------------------------------- /examples/actionpanel/res/filenew.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sintegrial/qsint/4b1d13c69e501a1dbf5f1bd381e152ad3b4f3a43/examples/actionpanel/res/filenew.png -------------------------------------------------------------------------------- /examples/actionpanel/res/fileopen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sintegrial/qsint/4b1d13c69e501a1dbf5f1bd381e152ad3b4f3a43/examples/actionpanel/res/fileopen.png -------------------------------------------------------------------------------- /examples/actionpanel/res/fileprint.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sintegrial/qsint/4b1d13c69e501a1dbf5f1bd381e152ad3b4f3a43/examples/actionpanel/res/fileprint.png -------------------------------------------------------------------------------- /examples/actionpanel/res/filesave.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sintegrial/qsint/4b1d13c69e501a1dbf5f1bd381e152ad3b4f3a43/examples/actionpanel/res/filesave.png -------------------------------------------------------------------------------- /examples/actionpanel/res/textbold.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sintegrial/qsint/4b1d13c69e501a1dbf5f1bd381e152ad3b4f3a43/examples/actionpanel/res/textbold.png -------------------------------------------------------------------------------- /examples/actionpanel/res/textcenter.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sintegrial/qsint/4b1d13c69e501a1dbf5f1bd381e152ad3b4f3a43/examples/actionpanel/res/textcenter.png -------------------------------------------------------------------------------- /examples/actionpanel/res/textitalic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sintegrial/qsint/4b1d13c69e501a1dbf5f1bd381e152ad3b4f3a43/examples/actionpanel/res/textitalic.png -------------------------------------------------------------------------------- /examples/actionpanel/res/textjustify.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sintegrial/qsint/4b1d13c69e501a1dbf5f1bd381e152ad3b4f3a43/examples/actionpanel/res/textjustify.png -------------------------------------------------------------------------------- /examples/actionpanel/res/textleft.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sintegrial/qsint/4b1d13c69e501a1dbf5f1bd381e152ad3b4f3a43/examples/actionpanel/res/textleft.png -------------------------------------------------------------------------------- /examples/actionpanel/res/textright.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sintegrial/qsint/4b1d13c69e501a1dbf5f1bd381e152ad3b4f3a43/examples/actionpanel/res/textright.png -------------------------------------------------------------------------------- /examples/actionpanel/res/textunder.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sintegrial/qsint/4b1d13c69e501a1dbf5f1bd381e152ad3b4f3a43/examples/actionpanel/res/textunder.png -------------------------------------------------------------------------------- /examples/actionpanel/res/zoomin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sintegrial/qsint/4b1d13c69e501a1dbf5f1bd381e152ad3b4f3a43/examples/actionpanel/res/zoomin.png -------------------------------------------------------------------------------- /examples/actionpanel/res/zoomout.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sintegrial/qsint/4b1d13c69e501a1dbf5f1bd381e152ad3b4f3a43/examples/actionpanel/res/zoomout.png -------------------------------------------------------------------------------- /examples/buttons/buttons.pro: -------------------------------------------------------------------------------- 1 | TARGET = buttons 2 | 3 | include(../exampleapp.pri) 4 | 5 | 6 | HEADERS += \ 7 | mainwindow.h 8 | 9 | SOURCES += \ 10 | mainwindow.cpp \ 11 | main.cpp 12 | 13 | FORMS += \ 14 | mainwindow.ui 15 | 16 | RESOURCES += res.qrc 17 | -------------------------------------------------------------------------------- /examples/buttons/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "mainwindow.h" 3 | 4 | int main(int argc, char *argv[]) 5 | { 6 | QApplication a(argc, argv); 7 | MainWindow w; 8 | w.show(); 9 | a.connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit())); 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /examples/buttons/mainwindow.cpp: -------------------------------------------------------------------------------- 1 | #include "mainwindow.h" 2 | #include "ui_mainwindow.h" 3 | 4 | MainWindow::MainWindow(QWidget *parent) : 5 | QWidget(parent), 6 | ui(new Ui::MainWindow) 7 | { 8 | ui->setupUi(this); 9 | 10 | auto newAction = new QAction(QIcon(":res/fileopen.png"), "Open File..."); 11 | newAction->setToolTip("Open a document from the disk"); 12 | ui->SplitButton->addAction(newAction); 13 | 14 | auto printAction = new QAction(QIcon(":res/fileprint.png"), "Print Document"); 15 | printAction->setToolTip("Send current document to the printer"); 16 | ui->SplitButton->addAction(printAction); 17 | 18 | auto saveAction = new QAction(QIcon(":res/filesave.png"), "Save File"); 19 | saveAction->setToolTip("Store current document to the disk"); 20 | ui->SplitButton->addAction(saveAction); 21 | 22 | ui->SplitButton->setDefaultAction(newAction); 23 | 24 | ui->SplitButton->setLastActionDefault(true); 25 | 26 | 27 | 28 | ui->SplitButton_2->addAction(newAction); 29 | ui->SplitButton_2->addAction(saveAction); 30 | ui->SplitButton_2->addAction(printAction); 31 | ui->SplitButton_2->setDefaultAction(newAction); 32 | 33 | 34 | ui->SplitButton_3->addAction(newAction); 35 | ui->SplitButton_3->addAction(saveAction); 36 | ui->SplitButton_3->addAction(printAction); 37 | ui->SplitButton_3->setDefaultAction(newAction); 38 | ui->SplitButton_3->setActionsToggle(true); 39 | 40 | 41 | QList values = { 0, 0.12, 100, 234.567, -10 }; 42 | ui->doubleSpinBox->setValueList(values); 43 | 44 | 45 | QList integers = {0, 10, 20, 50, 100, 1000, 10000 }; 46 | ui->spinBox->setValueList(integers); 47 | } 48 | 49 | MainWindow::~MainWindow() 50 | { 51 | delete ui; 52 | } 53 | 54 | void MainWindow::changeEvent(QEvent *e) 55 | { 56 | QWidget::changeEvent(e); 57 | switch (e->type()) { 58 | case QEvent::LanguageChange: 59 | ui->retranslateUi(this); 60 | break; 61 | default: 62 | break; 63 | } 64 | } 65 | 66 | -------------------------------------------------------------------------------- /examples/buttons/mainwindow.h: -------------------------------------------------------------------------------- 1 | #ifndef MAINWINDOW_H 2 | #define MAINWINDOW_H 3 | 4 | #include 5 | 6 | namespace Ui { 7 | class MainWindow; 8 | } 9 | 10 | class MainWindow : public QWidget 11 | { 12 | Q_OBJECT 13 | 14 | public: 15 | explicit MainWindow(QWidget *parent = 0); 16 | ~MainWindow(); 17 | 18 | protected: 19 | void changeEvent(QEvent *e); 20 | 21 | private: 22 | Ui::MainWindow *ui; 23 | }; 24 | 25 | #endif // MAINWINDOW_H 26 | -------------------------------------------------------------------------------- /examples/buttons/mainwindow.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | MainWindow 4 | 5 | 6 | 7 | 0 8 | 0 9 | 525 10 | 302 11 | 12 | 13 | 14 | Buttons Example 15 | 16 | 17 | 18 | 19 | 30 20 | 30 21 | 61 22 | 31 23 | 24 | 25 | 26 | Aa+9 27 | 28 | 29 | 30 | 31 | 32 | 30 33 | 90 34 | 61 35 | 31 36 | 37 | 38 | 39 | Pen 40 | 41 | 42 | 43 | 44 | 45 | 110 46 | 30 47 | 101 48 | 71 49 | 50 | 51 | 52 | 53 | 54 | 55 | 230 56 | 30 57 | 101 58 | 71 59 | 60 | 61 | 62 | 63 | 64 | 65 | 350 66 | 30 67 | 101 68 | 71 69 | 70 | 71 | 72 | 73 | 74 | 75 | 100 76 | 160 77 | 111 78 | 111 79 | 80 | 81 | 82 | 83 | 12 84 | 75 85 | true 86 | true 87 | 88 | 89 | 90 | % 91 | 92 | 93 | 94 | 95 | 96 | 310 97 | 170 98 | 171 99 | 22 100 | 101 | 102 | 103 | 104 | 105 | 106 | 310 107 | 230 108 | 121 109 | 22 110 | 111 | 112 | 113 | 114 | 115 | 116 | QSint::QFontButton 117 | QToolButton 118 |
QSintWidgets
119 |
120 | 121 | QSint::QPenButton 122 | QToolButton 123 |
QSintWidgets
124 |
125 | 126 | QSint::SplitButton 127 | QToolButton 128 |
QSintWidgets
129 |
130 | 131 | QSint::Dial 132 | QDial 133 |
QSintWidgets
134 |
135 | 136 | QSint::DoubleSpinComboBox 137 | QDoubleSpinBox 138 |
QSintWidgets
139 |
140 | 141 | QSint::SpinComboBox 142 | QSpinBox 143 |
QSintWidgets
144 |
145 |
146 | 147 | 148 |
149 | -------------------------------------------------------------------------------- /examples/buttons/res.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | res/fileopen.png 4 | res/fileprint.png 5 | res/filesave.png 6 | 7 | 8 | -------------------------------------------------------------------------------- /examples/buttons/res/editcopy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sintegrial/qsint/4b1d13c69e501a1dbf5f1bd381e152ad3b4f3a43/examples/buttons/res/editcopy.png -------------------------------------------------------------------------------- /examples/buttons/res/editcut.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sintegrial/qsint/4b1d13c69e501a1dbf5f1bd381e152ad3b4f3a43/examples/buttons/res/editcut.png -------------------------------------------------------------------------------- /examples/buttons/res/editpaste.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sintegrial/qsint/4b1d13c69e501a1dbf5f1bd381e152ad3b4f3a43/examples/buttons/res/editpaste.png -------------------------------------------------------------------------------- /examples/buttons/res/editredo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sintegrial/qsint/4b1d13c69e501a1dbf5f1bd381e152ad3b4f3a43/examples/buttons/res/editredo.png -------------------------------------------------------------------------------- /examples/buttons/res/editundo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sintegrial/qsint/4b1d13c69e501a1dbf5f1bd381e152ad3b4f3a43/examples/buttons/res/editundo.png -------------------------------------------------------------------------------- /examples/buttons/res/exportpdf.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sintegrial/qsint/4b1d13c69e501a1dbf5f1bd381e152ad3b4f3a43/examples/buttons/res/exportpdf.png -------------------------------------------------------------------------------- /examples/buttons/res/filenew.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sintegrial/qsint/4b1d13c69e501a1dbf5f1bd381e152ad3b4f3a43/examples/buttons/res/filenew.png -------------------------------------------------------------------------------- /examples/buttons/res/fileopen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sintegrial/qsint/4b1d13c69e501a1dbf5f1bd381e152ad3b4f3a43/examples/buttons/res/fileopen.png -------------------------------------------------------------------------------- /examples/buttons/res/fileprint.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sintegrial/qsint/4b1d13c69e501a1dbf5f1bd381e152ad3b4f3a43/examples/buttons/res/fileprint.png -------------------------------------------------------------------------------- /examples/buttons/res/filesave.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sintegrial/qsint/4b1d13c69e501a1dbf5f1bd381e152ad3b4f3a43/examples/buttons/res/filesave.png -------------------------------------------------------------------------------- /examples/buttons/res/textbold.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sintegrial/qsint/4b1d13c69e501a1dbf5f1bd381e152ad3b4f3a43/examples/buttons/res/textbold.png -------------------------------------------------------------------------------- /examples/buttons/res/textcenter.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sintegrial/qsint/4b1d13c69e501a1dbf5f1bd381e152ad3b4f3a43/examples/buttons/res/textcenter.png -------------------------------------------------------------------------------- /examples/buttons/res/textitalic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sintegrial/qsint/4b1d13c69e501a1dbf5f1bd381e152ad3b4f3a43/examples/buttons/res/textitalic.png -------------------------------------------------------------------------------- /examples/buttons/res/textjustify.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sintegrial/qsint/4b1d13c69e501a1dbf5f1bd381e152ad3b4f3a43/examples/buttons/res/textjustify.png -------------------------------------------------------------------------------- /examples/buttons/res/textleft.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sintegrial/qsint/4b1d13c69e501a1dbf5f1bd381e152ad3b4f3a43/examples/buttons/res/textleft.png -------------------------------------------------------------------------------- /examples/buttons/res/textright.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sintegrial/qsint/4b1d13c69e501a1dbf5f1bd381e152ad3b4f3a43/examples/buttons/res/textright.png -------------------------------------------------------------------------------- /examples/buttons/res/textunder.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sintegrial/qsint/4b1d13c69e501a1dbf5f1bd381e152ad3b4f3a43/examples/buttons/res/textunder.png -------------------------------------------------------------------------------- /examples/buttons/res/zoomin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sintegrial/qsint/4b1d13c69e501a1dbf5f1bd381e152ad3b4f3a43/examples/buttons/res/zoomin.png -------------------------------------------------------------------------------- /examples/buttons/res/zoomout.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sintegrial/qsint/4b1d13c69e501a1dbf5f1bd381e152ad3b4f3a43/examples/buttons/res/zoomout.png -------------------------------------------------------------------------------- /examples/chartwidgets/chartwidgets.pro: -------------------------------------------------------------------------------- 1 | TARGET = chartwidgets 2 | 3 | include(../exampleapp.pri) 4 | 5 | 6 | SOURCES += main.cpp\ 7 | mainwidget.cpp 8 | 9 | HEADERS += mainwidget.h 10 | 11 | FORMS += mainwidget.ui 12 | -------------------------------------------------------------------------------- /examples/chartwidgets/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "mainwidget.h" 3 | 4 | int main(int argc, char *argv[]) 5 | { 6 | QApplication a(argc, argv); 7 | MainWidget w; 8 | w.show(); 9 | 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /examples/chartwidgets/mainwidget.cpp: -------------------------------------------------------------------------------- 1 | #include "mainwidget.h" 2 | #include "ui_mainwidget.h" 3 | 4 | #include 5 | 6 | 7 | MainWidget::MainWidget(QWidget *parent) : 8 | QWidget(parent), 9 | ui(new Ui::MainWidget) 10 | { 11 | ui->setupUi(this); 12 | 13 | QLinearGradient bg(0,0,0,1); 14 | bg.setCoordinateMode(QGradient::ObjectBoundingMode); 15 | bg.setColorAt(1, Qt::white); 16 | bg.setColorAt(0.5, QColor(0xccccff)); 17 | bg.setColorAt(0, Qt::white); 18 | 19 | ui->PieChart->setBackground(QBrush(bg)); 20 | 21 | ui->PieChart->setCutoutPercentage(0.1); 22 | } 23 | 24 | MainWidget::~MainWidget() 25 | { 26 | delete ui; 27 | } 28 | 29 | void MainWidget::changeEvent(QEvent *e) 30 | { 31 | QWidget::changeEvent(e); 32 | switch (e->type()) { 33 | case QEvent::LanguageChange: 34 | ui->retranslateUi(this); 35 | break; 36 | default: 37 | break; 38 | } 39 | } 40 | 41 | void MainWidget::on_AddButton_clicked() 42 | { 43 | QString name = ui->ChannelName->text(); 44 | QColor color = ui->ChannelColorButton->color(); 45 | double value = ui->Value->value(); 46 | 47 | ui->PieChart->addData(name, color, value); 48 | } 49 | 50 | 51 | void MainWidget::on_AddRandomButton_clicked() 52 | { 53 | ui->PieChart->addData("", QColor(qrand()%256, qrand() % 256, qrand() % 256), qrand()%200-100); 54 | } 55 | 56 | 57 | void MainWidget::on_ResetButton_clicked() 58 | { 59 | ui->PieChart->clear(); 60 | } 61 | -------------------------------------------------------------------------------- /examples/chartwidgets/mainwidget.h: -------------------------------------------------------------------------------- 1 | #ifndef MAINWIDGET_H 2 | #define MAINWIDGET_H 3 | 4 | #include 5 | #include 6 | 7 | namespace Ui { 8 | class MainWidget; 9 | } 10 | 11 | class MainWidget : public QWidget 12 | { 13 | Q_OBJECT 14 | 15 | public: 16 | explicit MainWidget(QWidget *parent = 0); 17 | ~MainWidget(); 18 | 19 | protected slots: 20 | void on_AddButton_clicked(); 21 | void on_AddRandomButton_clicked(); 22 | void on_ResetButton_clicked(); 23 | 24 | protected: 25 | void changeEvent(QEvent *e); 26 | 27 | private: 28 | Ui::MainWidget *ui; 29 | 30 | QStandardItemModel *itemModel; 31 | }; 32 | 33 | #endif // MAINWIDGET_H 34 | -------------------------------------------------------------------------------- /examples/colorgrid/colorgrid.pro: -------------------------------------------------------------------------------- 1 | TARGET = colorgrid 2 | 3 | include(../exampleapp.pri) 4 | 5 | 6 | HEADERS += \ 7 | mainwindow.h 8 | 9 | SOURCES += \ 10 | mainwindow.cpp \ 11 | main.cpp 12 | 13 | FORMS += \ 14 | mainwindow.ui 15 | -------------------------------------------------------------------------------- /examples/colorgrid/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "mainwindow.h" 3 | 4 | int main(int argc, char *argv[]) 5 | { 6 | QApplication a(argc, argv); 7 | MainWindow w; 8 | w.show(); 9 | a.connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit())); 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /examples/colorgrid/mainwindow.cpp: -------------------------------------------------------------------------------- 1 | #include "mainwindow.h" 2 | #include "ui_mainwindow.h" 3 | 4 | MainWindow::MainWindow(QWidget *parent) : 5 | QWidget(parent), 6 | ui(new Ui::MainWindow) 7 | { 8 | ui->setupUi(this); 9 | 10 | // ColorPopup1 uses standard color dialog 11 | ui->ColorPopup1->setPickMode(QSint::ColorButton::PM_COLORDIALOG); 12 | 13 | // ColorPopup2 uses ColorGrid color dialog (the default) 14 | ui->ColorPopup2->setColor(Qt::red); 15 | ui->ColorPopup2->setColorScheme(QSint::BaseColors()); 16 | // Cell size can be modified as well. 17 | ui->ColorPopup2->setCellSize(24); 18 | 19 | ui->ColorPopup3->setColor(Qt::green); 20 | ui->ColorPopup3->setColorScheme(QSint::SvgColors()); 21 | // Cell size can be modified as well. 22 | ui->ColorPopup3->setCellSize(16); 23 | 24 | ui->ColorPopup4->setColor(Qt::cyan); 25 | ui->ColorPopup4->setColorScheme(QSint::OpenOfficeColors()); 26 | 27 | ui->ColorPopup5->setColor(Qt::yellow); 28 | ui->ColorPopup5->setColorScheme(QSint::OpenOfficeColors()); 29 | ui->ColorPopup5->setPickMode(QSint::ColorButton::PM_COLORGRID); 30 | 31 | 32 | // connect grid signals to the buttons and combos 33 | connect(ui->ColorGrid1, SIGNAL(picked(QColor)), ui->ColorPopup1, SLOT(setColor(QColor))); 34 | connect(ui->ColorGrid1, SIGNAL(picked(QColor)), ui->ColorCombo1, SLOT(setColor(QColor))); 35 | } 36 | 37 | MainWindow::~MainWindow() 38 | { 39 | delete ui; 40 | } 41 | 42 | void MainWindow::changeEvent(QEvent *e) 43 | { 44 | QWidget::changeEvent(e); 45 | switch (e->type()) { 46 | case QEvent::LanguageChange: 47 | ui->retranslateUi(this); 48 | break; 49 | default: 50 | break; 51 | } 52 | } 53 | 54 | void MainWindow::on_ColorGrid1SchemeCombo_activated(int index) 55 | { 56 | switch (index) 57 | { 58 | case 0: 59 | ui->ColorGrid1->setScheme(QSint::defaultColors()); 60 | ui->ColorCombo1->setColors(*QSint::defaultColors()); 61 | ui->ColorCombo2->setColors(*QSint::defaultColors()); 62 | break; 63 | 64 | case 1: 65 | ui->ColorGrid1->setScheme(QSint::defaultColors2()); 66 | ui->ColorCombo1->setColors(*QSint::defaultColors2()); 67 | ui->ColorCombo2->setColors(*QSint::defaultColors2()); 68 | break; 69 | 70 | case 2: 71 | ui->ColorGrid1->setScheme(QSint::baseColors()); 72 | ui->ColorCombo1->setColors(*QSint::baseColors()); 73 | ui->ColorCombo2->setColors(*QSint::baseColors()); 74 | break; 75 | 76 | case 3: 77 | ui->ColorGrid1->setScheme(QSint::namedColors()); 78 | ui->ColorCombo1->setColors(*QSint::namedColors()); 79 | ui->ColorCombo2->setColors(*QSint::namedColors()); 80 | break; 81 | } 82 | } 83 | 84 | void MainWindow::on_ColorCombo1_currentColorChanged(QColor color) 85 | { 86 | ui->ColorLabel1->setText(color.name()); 87 | } 88 | 89 | void MainWindow::on_ColorCombo2_currentColorChanged(QColor color) 90 | { 91 | ui->ColorLabel2->setText(color.name()); 92 | } 93 | -------------------------------------------------------------------------------- /examples/colorgrid/mainwindow.h: -------------------------------------------------------------------------------- 1 | #ifndef MAINWINDOW_H 2 | #define MAINWINDOW_H 3 | 4 | #include 5 | 6 | namespace Ui { 7 | class MainWindow; 8 | } 9 | 10 | class MainWindow : public QWidget 11 | { 12 | Q_OBJECT 13 | 14 | public: 15 | explicit MainWindow(QWidget *parent = 0); 16 | ~MainWindow(); 17 | 18 | protected: 19 | void changeEvent(QEvent *e); 20 | 21 | private slots: 22 | void on_ColorGrid1SchemeCombo_activated(int); 23 | 24 | void on_ColorCombo1_currentColorChanged(QColor); 25 | void on_ColorCombo2_currentColorChanged(QColor); 26 | 27 | private: 28 | Ui::MainWindow *ui; 29 | }; 30 | 31 | #endif // MAINWINDOW_H 32 | -------------------------------------------------------------------------------- /examples/exampleapp.pri: -------------------------------------------------------------------------------- 1 | include(../app.pri) 2 | 3 | win32*{ 4 | DESTDIR = $$OUT_PWD/.. 5 | } 6 | else{ 7 | DESTDIR = $$OUT_PWD 8 | } 9 | 10 | LIBS += -L$$OUT_PWD/../../lib -lqsint 11 | 12 | win32-msvc*{ 13 | PRE_TARGETDEPS += $$OUT_PWD/../../lib/qsint.lib 14 | } 15 | 16 | -------------------------------------------------------------------------------- /examples/examples.pro: -------------------------------------------------------------------------------- 1 | TEMPLATE = subdirs 2 | 3 | CONFIG = ordered 4 | 5 | SUBDIRS = \ 6 | actionlabel actionpanel buttons \ 7 | colorgrid ledwidget pathpicker slider roundprogressbar timepicker \ 8 | simplecharts simplecharts2 chartwidgets 9 | 10 | -------------------------------------------------------------------------------- /examples/ledwidget/ledwidget.pro: -------------------------------------------------------------------------------- 1 | TARGET = ledwidget 2 | 3 | include(../exampleapp.pri) 4 | 5 | 6 | SOURCES += main.cpp\ 7 | ledwidgetdemo.cpp 8 | 9 | HEADERS += ledwidgetdemo.h 10 | 11 | FORMS += ledwidgetdemo.ui 12 | -------------------------------------------------------------------------------- /examples/ledwidget/ledwidgetdemo.cpp: -------------------------------------------------------------------------------- 1 | #include "ledwidgetdemo.h" 2 | #include "ui_ledwidgetdemo.h" 3 | 4 | 5 | LedWidgetDemo::LedWidgetDemo(QWidget *parent) : 6 | QWidget(parent), 7 | ui(new Ui::LedWidgetDemo) 8 | { 9 | ui->setupUi(this); 10 | 11 | ui->LED1->setColor(Qt::red); 12 | ui->LED3->setColor(Qt::green); 13 | ui->LED2->setColor(Qt::yellow); 14 | 15 | ui->LED4->setColors(Qt::black, Qt::darkGray); 16 | } 17 | 18 | 19 | LedWidgetDemo::~LedWidgetDemo() 20 | { 21 | delete ui; 22 | } 23 | -------------------------------------------------------------------------------- /examples/ledwidget/ledwidgetdemo.h: -------------------------------------------------------------------------------- 1 | #ifndef LEDWIDGETDEMO_H 2 | #define LEDWIDGETDEMO_H 3 | 4 | #include 5 | 6 | namespace Ui { 7 | class LedWidgetDemo; 8 | } 9 | 10 | class LedWidgetDemo : public QWidget 11 | { 12 | Q_OBJECT 13 | 14 | public: 15 | explicit LedWidgetDemo(QWidget *parent = 0); 16 | ~LedWidgetDemo(); 17 | 18 | private: 19 | Ui::LedWidgetDemo *ui; 20 | }; 21 | 22 | #endif // LEDWIDGETDEMO_H 23 | -------------------------------------------------------------------------------- /examples/ledwidget/ledwidgetdemo.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | LedWidgetDemo 4 | 5 | 6 | 7 | 0 8 | 0 9 | 400 10 | 300 11 | 12 | 13 | 14 | LedWidgetDemo 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | QSint::LedWidget 35 | QWidget 36 |
QSintWidgets
37 | 1 38 |
39 |
40 | 41 | 42 |
43 | -------------------------------------------------------------------------------- /examples/ledwidget/main.cpp: -------------------------------------------------------------------------------- 1 | #include "ledwidgetdemo.h" 2 | #include 3 | 4 | int main(int argc, char *argv[]) 5 | { 6 | QApplication a(argc, argv); 7 | LedWidgetDemo w; 8 | w.show(); 9 | 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /examples/pathpicker/icons.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | icons/fileopen.png 4 | icons/filesave.png 5 | 6 | 7 | -------------------------------------------------------------------------------- /examples/pathpicker/icons/fileopen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sintegrial/qsint/4b1d13c69e501a1dbf5f1bd381e152ad3b4f3a43/examples/pathpicker/icons/fileopen.png -------------------------------------------------------------------------------- /examples/pathpicker/icons/filesave.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sintegrial/qsint/4b1d13c69e501a1dbf5f1bd381e152ad3b4f3a43/examples/pathpicker/icons/filesave.png -------------------------------------------------------------------------------- /examples/pathpicker/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "mainwindow.h" 3 | 4 | int main(int argc, char *argv[]) 5 | { 6 | QApplication a(argc, argv); 7 | MainWindow w; 8 | w.show(); 9 | a.connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit())); 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /examples/pathpicker/mainwindow.cpp: -------------------------------------------------------------------------------- 1 | #include "mainwindow.h" 2 | #include "ui_mainwindow.h" 3 | 4 | MainWindow::MainWindow(QWidget *parent) : 5 | QWidget(parent), 6 | ui(new Ui::MainWindow) 7 | { 8 | ui->setupUi(this); 9 | 10 | //qApp->setStyle("fusion"); 11 | } 12 | 13 | MainWindow::~MainWindow() 14 | { 15 | delete ui; 16 | } 17 | 18 | void MainWindow::changeEvent(QEvent *e) 19 | { 20 | QWidget::changeEvent(e); 21 | switch (e->type()) { 22 | case QEvent::LanguageChange: 23 | ui->retranslateUi(this); 24 | break; 25 | default: 26 | break; 27 | } 28 | } 29 | 30 | void MainWindow::on_PathPicker_beforePicked() 31 | { 32 | int dialogFlags = QSint::PathPicker::DF_DEFAULT; 33 | 34 | if (ui->rbSystemDialog->isChecked()) 35 | dialogFlags = QSint::PathPicker::DF_SYSTEM; 36 | 37 | ui->PathPicker->setDialogType(dialogFlags); 38 | } 39 | 40 | void MainWindow::on_rbFile_toggled(bool on) 41 | { 42 | if (on) 43 | ui->PathPicker->setObjectsToPick(QSint::PathPicker::PF_EXISTING_FILE); 44 | } 45 | 46 | void MainWindow::on_rbFiles_toggled(bool on) 47 | { 48 | if (on) 49 | ui->PathPicker->setObjectsToPick(QSint::PathPicker::PF_EXISTING_FILES); 50 | } 51 | 52 | void MainWindow::on_rbDir_toggled(bool on) 53 | { 54 | if (on) 55 | ui->PathPicker->setObjectsToPick(QSint::PathPicker::PF_EXISTING_DIR); 56 | } 57 | 58 | void MainWindow::on_rbFileToSave_toggled(bool on) 59 | { 60 | if (on) 61 | ui->PathPicker->setObjectsToPick(QSint::PathPicker::PF_SAVE_FILE); 62 | } 63 | -------------------------------------------------------------------------------- /examples/pathpicker/mainwindow.h: -------------------------------------------------------------------------------- 1 | #ifndef MAINWINDOW_H 2 | #define MAINWINDOW_H 3 | 4 | #include 5 | 6 | namespace Ui { 7 | class MainWindow; 8 | } 9 | 10 | class MainWindow : public QWidget 11 | { 12 | Q_OBJECT 13 | 14 | public: 15 | explicit MainWindow(QWidget *parent = 0); 16 | ~MainWindow(); 17 | 18 | protected: 19 | void changeEvent(QEvent *e); 20 | 21 | private Q_SLOTS: 22 | void on_PathPicker_beforePicked(); 23 | void on_rbFile_toggled(bool); 24 | void on_rbFiles_toggled(bool); 25 | void on_rbDir_toggled(bool); 26 | void on_rbFileToSave_toggled(bool); 27 | 28 | private: 29 | Ui::MainWindow *ui; 30 | }; 31 | 32 | #endif // MAINWINDOW_H 33 | -------------------------------------------------------------------------------- /examples/pathpicker/mainwindow.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | MainWindow 4 | 5 | 6 | 7 | 0 8 | 0 9 | 551 10 | 313 11 | 12 | 13 | 14 | PathPicker Example 15 | 16 | 17 | 18 | 19 | 20 | Objects to pick 21 | 22 | 23 | 24 | 25 | 26 | File to open 27 | 28 | 29 | true 30 | 31 | 32 | 33 | 34 | 35 | 36 | Files to open 37 | 38 | 39 | 40 | 41 | 42 | 43 | Directory to open 44 | 45 | 46 | 47 | 48 | 49 | 50 | File to save 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | Dialog look 61 | 62 | 63 | 64 | 65 | 66 | System 67 | 68 | 69 | true 70 | 71 | 72 | 73 | 74 | 75 | 76 | Qt based 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | Qt::Horizontal 87 | 88 | 89 | 90 | 275 91 | 20 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | Qt::Vertical 100 | 101 | 102 | 103 | 20 104 | 94 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | Qt::Vertical 116 | 117 | 118 | 119 | 20 120 | 94 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | QSint::PathPicker 130 | QWidget 131 |
QSintWidgets
132 | 1 133 |
134 |
135 | 136 | 137 |
138 | -------------------------------------------------------------------------------- /examples/pathpicker/pathpicker.pro: -------------------------------------------------------------------------------- 1 | TARGET = pathpicker 2 | 3 | include(../exampleapp.pri) 4 | 5 | 6 | HEADERS += \ 7 | mainwindow.h 8 | 9 | SOURCES += \ 10 | mainwindow.cpp \ 11 | main.cpp 12 | 13 | FORMS += \ 14 | mainwindow.ui 15 | 16 | RESOURCES += \ 17 | icons.qrc 18 | -------------------------------------------------------------------------------- /examples/roundprogressbar/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "testwidget.h" 3 | 4 | int main(int argc, char *argv[]) 5 | { 6 | QApplication a(argc, argv); 7 | TestWidget w; 8 | w.show(); 9 | a.connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit())); 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /examples/roundprogressbar/roundprogressbar.pro: -------------------------------------------------------------------------------- 1 | TARGET = roundprogressbar 2 | 3 | include(../exampleapp.pri) 4 | 5 | 6 | HEADERS += \ 7 | testwidget.h 8 | 9 | SOURCES += \ 10 | testwidget.cpp \ 11 | main.cpp 12 | 13 | FORMS += \ 14 | testwidget.ui 15 | -------------------------------------------------------------------------------- /examples/roundprogressbar/testwidget.cpp: -------------------------------------------------------------------------------- 1 | #include "testwidget.h" 2 | #include "ui_testwidget.h" 3 | 4 | TestWidget::TestWidget(QWidget *parent) : 5 | QWidget(parent), 6 | ui(new Ui::TestWidget) 7 | { 8 | qApp->setStyle("fusion"); 9 | 10 | ui->setupUi(this); 11 | 12 | // QPalette palette1; 13 | // QPixmap bkgnd("e:/tmp/t.png"); 14 | // bkgnd = bkgnd.scaled(this->size(), Qt::IgnoreAspectRatio); 15 | 16 | // palette1.setBrush(QPalette::Background, bkgnd); 17 | // this->setPalette(palette1); 18 | 19 | // donut (default style) 20 | ui->RoundBar1->setFormat("%v"); 21 | ui->RoundBar1->setDecimals(0); 22 | connectToSlider(ui->RoundBar1); 23 | 24 | // pie 25 | ui->RoundBar2->setNullPosition(QSint::RoundProgressBar::PositionRight); 26 | ui->RoundBar2->setBarStyle(QSint::RoundProgressBar::StylePie); 27 | connectToSlider(ui->RoundBar2); 28 | 29 | // line 30 | ui->RoundBar3->setFormat("%m"); 31 | ui->RoundBar3->setBarStyle(QSint::RoundProgressBar::StyleLine); 32 | connectToSlider(ui->RoundBar3); 33 | 34 | // expand 35 | ui->ExpandBar1->setBarStyle(QSint::RoundProgressBar::StyleExpand); 36 | connectToSlider(ui->ExpandBar1); 37 | 38 | // donut (customized via QPalette + gradient) 39 | QPalette p1(palette()); 40 | p1.setBrush(QPalette::Background, Qt::NoBrush); 41 | p1.setBrush(QPalette::AlternateBase, Qt::black); 42 | p1.setColor(QPalette::Text, Qt::yellow); 43 | ui->RoundBar4->setPalette(p1); 44 | 45 | ui->RoundBar4->setNullPosition(QSint::RoundProgressBar::PositionLeft); 46 | ui->RoundBar4->setDecimals(0); 47 | 48 | // make a gradient from green over yellow to red 49 | QGradientStops gradientPoints; 50 | gradientPoints << QGradientStop(0, Qt::green) << QGradientStop(0.5, Qt::yellow) << QGradientStop(1, Qt::red); 51 | // and set it 52 | ui->RoundBar4->setDataColors(gradientPoints); 53 | 54 | connectToSlider(ui->RoundBar4); 55 | 56 | // pie (customized via QPalette + gradient) 57 | QPalette p2(p1); 58 | p2.setBrush(QPalette::Base, Qt::white); 59 | p2.setColor(QPalette::Text, Qt::darkMagenta); 60 | p2.setColor(QPalette::Shadow, Qt::green); 61 | ui->RoundBar5->setPalette(p2); 62 | ui->RoundBar5->setNullPosition(QSint::RoundProgressBar::PositionRight); 63 | ui->RoundBar5->setBarStyle(QSint::RoundProgressBar::StylePie); 64 | ui->RoundBar5->setDataColors(gradientPoints); // here gradient colors are set 65 | connectToSlider(ui->RoundBar5); 66 | 67 | // line style with custom outline 68 | ui->RoundBar6->setDecimals(2); 69 | ui->RoundBar6->setBarStyle(QSint::RoundProgressBar::StyleLine); 70 | ui->RoundBar6->setOutlinePenWidth(18); 71 | ui->RoundBar6->setDataPenWidth(10); 72 | connectToSlider(ui->RoundBar6); 73 | 74 | // expand with gradient 75 | ui->ExpandBar2->setBarStyle(QSint::RoundProgressBar::StyleExpand); 76 | ui->ExpandBar2->setDecimals(0); 77 | ui->ExpandBar2->setPalette(p2); 78 | ui->ExpandBar2->setDataColors(gradientPoints); // here gradient colors are set 79 | connectToSlider(ui->ExpandBar2); 80 | 81 | // big one 82 | connectToSlider(ui->RoundBar7); 83 | } 84 | 85 | TestWidget::~TestWidget() 86 | { 87 | delete ui; 88 | } 89 | 90 | void TestWidget::connectToSlider(QSint::RoundProgressBar *bar) 91 | { 92 | bar->setRange(ui->Slider->minimum(), ui->Slider->maximum()); 93 | bar->setValue(ui->Slider->value()); 94 | connect(ui->Slider, SIGNAL(valueChanged(int)), bar, SLOT(setValue(int))); 95 | } 96 | -------------------------------------------------------------------------------- /examples/roundprogressbar/testwidget.h: -------------------------------------------------------------------------------- 1 | #ifndef TESTWIDGET_H 2 | #define TESTWIDGET_H 3 | 4 | #include 5 | 6 | namespace Ui { 7 | class TestWidget; 8 | } 9 | 10 | class TestWidget : public QWidget 11 | { 12 | Q_OBJECT 13 | 14 | public: 15 | explicit TestWidget(QWidget *parent = 0); 16 | ~TestWidget(); 17 | 18 | private: 19 | void connectToSlider(class QSint::RoundProgressBar* bar); 20 | 21 | Ui::TestWidget *ui; 22 | }; 23 | 24 | #endif // TESTWIDGET_H 25 | -------------------------------------------------------------------------------- /examples/simplecharts/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "mainwidget.h" 3 | 4 | int main(int argc, char *argv[]) 5 | { 6 | QApplication a(argc, argv); 7 | MainWidget w; 8 | w.show(); 9 | 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /examples/simplecharts/mainwidget.h: -------------------------------------------------------------------------------- 1 | #ifndef MAINWIDGET_H 2 | #define MAINWIDGET_H 3 | 4 | #include 5 | #include 6 | 7 | namespace Ui { 8 | class MainWidget; 9 | } 10 | 11 | class MainWidget : public QWidget 12 | { 13 | Q_OBJECT 14 | 15 | public: 16 | explicit MainWidget(QWidget *parent = 0); 17 | ~MainWidget(); 18 | 19 | protected slots: 20 | void on_AddRowButton_clicked(); 21 | void on_AddColumnButton_clicked(); 22 | 23 | void on_StackedButton_clicked(); 24 | void on_NearButton_clicked(); 25 | void on_TrendButton_clicked(); 26 | 27 | void OnColumnChanged(QModelIndex,QModelIndex); 28 | 29 | protected: 30 | void changeEvent(QEvent *e); 31 | 32 | private: 33 | Ui::MainWidget *ui; 34 | 35 | QStandardItemModel *itemModel; 36 | }; 37 | 38 | #endif // MAINWIDGET_H 39 | -------------------------------------------------------------------------------- /examples/simplecharts/simplecharts.pro: -------------------------------------------------------------------------------- 1 | TARGET = simplecharts 2 | 3 | include(../exampleapp.pri) 4 | 5 | 6 | SOURCES += main.cpp\ 7 | mainwidget.cpp 8 | 9 | HEADERS += mainwidget.h 10 | 11 | FORMS += mainwidget.ui 12 | -------------------------------------------------------------------------------- /examples/simplecharts2/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "mainwidget.h" 3 | 4 | int main(int argc, char *argv[]) 5 | { 6 | QApplication a(argc, argv); 7 | MainWidget w; 8 | w.showMaximized(); 9 | 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /examples/simplecharts2/mainwidget.h: -------------------------------------------------------------------------------- 1 | #ifndef MAINWIDGET_H 2 | #define MAINWIDGET_H 3 | 4 | #include 5 | #include 6 | 7 | namespace Ui { 8 | class MainWidget; 9 | } 10 | 11 | class MainWidget : public QWidget 12 | { 13 | Q_OBJECT 14 | 15 | public: 16 | explicit MainWidget(QWidget *parent = 0); 17 | ~MainWidget(); 18 | 19 | protected: 20 | void changeEvent(QEvent *e); 21 | 22 | protected Q_SLOTS: 23 | void showTooltip1(const QModelIndex& index); 24 | 25 | private: 26 | Ui::MainWidget *ui; 27 | }; 28 | 29 | #endif // MAINWIDGET_H 30 | -------------------------------------------------------------------------------- /examples/simplecharts2/mainwidget.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | MainWidget 4 | 5 | 6 | 7 | 0 8 | 0 9 | 800 10 | 600 11 | 12 | 13 | 14 | 15 | 800 16 | 600 17 | 18 | 19 | 20 | QSint::Charts Demo 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | QSint::BarChartPlotter 44 | QWidget 45 |
QSintCharts
46 | 1 47 |
48 | 49 | QSint::PieChart 50 | QWidget 51 |
QSintCharts
52 | 1 53 |
54 | 55 | QSint::RingChart 56 | QWidget 57 |
QSintCharts
58 | 1 59 |
60 |
61 | 62 | 63 |
64 | -------------------------------------------------------------------------------- /examples/simplecharts2/simplecharts2.pro: -------------------------------------------------------------------------------- 1 | TARGET = simplecharts2 2 | 3 | include(../exampleapp.pri) 4 | 5 | 6 | SOURCES += main.cpp\ 7 | mainwidget.cpp 8 | 9 | HEADERS += mainwidget.h 10 | 11 | FORMS += mainwidget.ui 12 | -------------------------------------------------------------------------------- /examples/slider/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "mainwindow.h" 3 | 4 | int main(int argc, char *argv[]) 5 | { 6 | QApplication a(argc, argv); 7 | MainWindow w; 8 | w.show(); 9 | a.connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit())); 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /examples/slider/mainwindow.cpp: -------------------------------------------------------------------------------- 1 | #include "mainwindow.h" 2 | #include "ui_mainwindow.h" 3 | 4 | 5 | MainWindow::MainWindow(QWidget *parent) : 6 | QWidget(parent), 7 | ui(new Ui::MainWindow) 8 | { 9 | ui->setupUi(this); 10 | } 11 | 12 | MainWindow::~MainWindow() 13 | { 14 | delete ui; 15 | } 16 | 17 | void MainWindow::changeEvent(QEvent *e) 18 | { 19 | QWidget::changeEvent(e); 20 | switch (e->type()) { 21 | case QEvent::LanguageChange: 22 | ui->retranslateUi(this); 23 | break; 24 | default: 25 | break; 26 | } 27 | } 28 | 29 | -------------------------------------------------------------------------------- /examples/slider/mainwindow.h: -------------------------------------------------------------------------------- 1 | #ifndef MAINWINDOW_H 2 | #define MAINWINDOW_H 3 | 4 | #include 5 | 6 | namespace Ui { 7 | class MainWindow; 8 | } 9 | 10 | class MainWindow : public QWidget 11 | { 12 | Q_OBJECT 13 | 14 | public: 15 | explicit MainWindow(QWidget *parent = 0); 16 | ~MainWindow(); 17 | 18 | protected: 19 | void changeEvent(QEvent *e); 20 | 21 | private: 22 | Ui::MainWindow *ui; 23 | }; 24 | 25 | #endif // MAINWINDOW_H 26 | -------------------------------------------------------------------------------- /examples/slider/slider.pro: -------------------------------------------------------------------------------- 1 | TARGET = slider 2 | 3 | include(../exampleapp.pri) 4 | 5 | 6 | HEADERS += \ 7 | mainwindow.h 8 | 9 | SOURCES += \ 10 | mainwindow.cpp \ 11 | main.cpp 12 | 13 | FORMS += \ 14 | mainwindow.ui 15 | -------------------------------------------------------------------------------- /examples/timepicker/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "mainwindow.h" 3 | 4 | int main(int argc, char *argv[]) 5 | { 6 | QApplication a(argc, argv); 7 | MainWindow w; 8 | w.show(); 9 | a.connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit())); 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /examples/timepicker/mainwindow.cpp: -------------------------------------------------------------------------------- 1 | #include "mainwindow.h" 2 | #include "ui_mainwindow.h" 3 | 4 | MainWindow::MainWindow(QWidget *parent) : 5 | QWidget(parent), 6 | ui(new Ui::MainWindow) 7 | { 8 | ui->setupUi(this); 9 | 10 | ui->TimePicker->setTime(ui->TimeEdit->time()); 11 | 12 | connect(ui->TimePicker, SIGNAL(timePicked(QTime)), ui->TimeEdit, SLOT(setTime(QTime))); 13 | connect(ui->TimeEdit, SIGNAL(timeChanged(QTime)), ui->TimePicker, SLOT(setTime(QTime))); 14 | } 15 | 16 | MainWindow::~MainWindow() 17 | { 18 | delete ui; 19 | } 20 | 21 | void MainWindow::changeEvent(QEvent *e) 22 | { 23 | QWidget::changeEvent(e); 24 | switch (e->type()) { 25 | case QEvent::LanguageChange: 26 | ui->retranslateUi(this); 27 | break; 28 | default: 29 | break; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /examples/timepicker/mainwindow.h: -------------------------------------------------------------------------------- 1 | #ifndef MAINWINDOW_H 2 | #define MAINWINDOW_H 3 | 4 | #include 5 | 6 | namespace Ui { 7 | class MainWindow; 8 | } 9 | 10 | class MainWindow : public QWidget 11 | { 12 | Q_OBJECT 13 | 14 | public: 15 | explicit MainWindow(QWidget *parent = 0); 16 | ~MainWindow(); 17 | 18 | protected: 19 | void changeEvent(QEvent *e); 20 | 21 | private slots: 22 | 23 | private: 24 | Ui::MainWindow *ui; 25 | }; 26 | 27 | #endif // MAINWINDOW_H 28 | -------------------------------------------------------------------------------- /examples/timepicker/mainwindow.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | MainWindow 4 | 5 | 6 | 7 | 0 8 | 0 9 | 340 10 | 180 11 | 12 | 13 | 14 | TimePicker Example 15 | 16 | 17 | 18 | 19 | 20 | In-place time selection 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | QSint::TimePicker 37 | QWidget 38 |
QSintWidgets
39 | 1 40 |
41 |
42 | 43 | 44 |
45 | -------------------------------------------------------------------------------- /examples/timepicker/timepicker.pro: -------------------------------------------------------------------------------- 1 | TARGET = timepicker2 2 | 3 | include(../exampleapp.pri) 4 | 5 | 6 | HEADERS += \ 7 | mainwindow.h 8 | 9 | SOURCES += \ 10 | mainwindow.cpp \ 11 | main.cpp 12 | 13 | FORMS += \ 14 | mainwindow.ui 15 | -------------------------------------------------------------------------------- /include/QSintActions: -------------------------------------------------------------------------------- 1 | #include "../src/actions/actionbox.h" 2 | #include "../src/actions/actionlabel.h" 3 | #include "../src/actions/actiongroup.h" 4 | #include "../src/actions/actionpanel.h" 5 | #include "../src/actions/actionpanelscheme.h" 6 | #include "../src/actions/winxppanelscheme.h" 7 | #include "../src/actions/winvistapanelscheme.h" 8 | #include "../src/actions/macpanelscheme.h" 9 | #include "../src/actions/androidpanelscheme.h" 10 | -------------------------------------------------------------------------------- /include/QSintCharts: -------------------------------------------------------------------------------- 1 | #include "../src/charts/axisbase.h" 2 | #include "../src/charts/plotterbase.h" 3 | #include "../src/charts/barchartplotter.h" 4 | #include "../src/charts/piechart.h" 5 | #include "../src/charts/piechartwidget.h" 6 | #include "../src/charts/ringchart.h" 7 | -------------------------------------------------------------------------------- /include/QSintWidgets: -------------------------------------------------------------------------------- 1 | #include "../src/widgets/colorbutton.h" 2 | #include "../src/widgets/colorgrid.h" 3 | #include "../src/widgets/colorcombobox.h" 4 | #include "../src/widgets/ledwidget.h" 5 | #include "../src/widgets/pathpicker.h" 6 | #include "../src/widgets/slider.h" 7 | #include "../src/widgets/slider2d.h" 8 | #include "../src/widgets/roundprogressbar.h" 9 | #include "../src/widgets/timepicker.h" 10 | #include "../src/widgets/spinslider.h" 11 | #include "../src/widgets/dial.h" 12 | #include "../src/widgets/spincombobox.h" 13 | #include "../src/widgets/doublespincombobox.h" 14 | #include "../src/widgets/splitbutton.h" 15 | #include "../src/widgets/qmenubutton.h" 16 | #include "../src/widgets/qfontbutton.h" 17 | #include "../src/widgets/qpenbutton.h" 18 | #include "../src/widgets/qpencombobox.h" 19 | -------------------------------------------------------------------------------- /qsint.pro: -------------------------------------------------------------------------------- 1 | TEMPLATE = subdirs 2 | 3 | CONFIG += ordered 4 | 5 | SUBDIRS += src examples 6 | -------------------------------------------------------------------------------- /src/actions/actionlabel.cpp: -------------------------------------------------------------------------------- 1 | #include "actionlabel.h" 2 | 3 | #include 4 | #include 5 | 6 | 7 | namespace QSint 8 | { 9 | 10 | 11 | const char* ActionLabelStyle = 12 | "QSint--ActionLabel[class='action'] {" 13 | "background-color: transparent;" 14 | "border: 1px solid transparent;" 15 | "color: #0033ff;" 16 | "text-align: left;" 17 | "font: 11px;" 18 | "}" 19 | 20 | "QSint--ActionLabel[class='action']:!enabled {" 21 | "color: #999999;" 22 | "}" 23 | 24 | "QSint--ActionLabel[class='action']:hover {" 25 | "color: #0099ff;" 26 | "text-decoration: underline;" 27 | "}" 28 | 29 | "QSint--ActionLabel[class='action']:focus {" 30 | "border: 1px dotted black;" 31 | "}" 32 | 33 | "QSint--ActionLabel[class='action']:on {" 34 | "background-color: #ddeeff;" 35 | "color: #006600;" 36 | "}" 37 | ; 38 | 39 | 40 | ActionLabel::ActionLabel(QWidget *parent) : 41 | QToolButton(parent) 42 | { 43 | init(); 44 | } 45 | 46 | ActionLabel::ActionLabel(QAction *action, QWidget *parent) : 47 | QToolButton(parent) 48 | { 49 | init(); 50 | 51 | setDefaultAction(action); 52 | } 53 | 54 | void ActionLabel::init() 55 | { 56 | setProperty("class", "action"); 57 | 58 | setCursor(Qt::PointingHandCursor); 59 | 60 | setToolButtonStyle(Qt::ToolButtonTextBesideIcon); 61 | 62 | setStyleSheet(QString(ActionLabelStyle)); 63 | 64 | setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); 65 | 66 | setFocusPolicy(Qt::StrongFocus); 67 | } 68 | 69 | QSize ActionLabel::sizeHint() const 70 | { 71 | ensurePolished(); 72 | 73 | int w = 0, h = 0; 74 | 75 | QStyleOptionToolButton opt; 76 | initStyleOption(&opt); 77 | 78 | QString s(text()); 79 | bool empty = s.isEmpty(); 80 | if (empty) 81 | s = QString::fromLatin1("XXXX"); 82 | QFontMetrics fm = fontMetrics(); 83 | QSize sz = fm.size(Qt::TextShowMnemonic, s); 84 | if(!empty || !w) 85 | w += sz.width(); 86 | if(!empty || !h) 87 | h = qMax(h, sz.height()); 88 | opt.rect.setSize(QSize(w, h)); // PM_MenuButtonIndicator depends on the height 89 | 90 | if (!icon().isNull()) { 91 | int ih = opt.iconSize.height(); 92 | int iw = opt.iconSize.width() + 4; 93 | w += iw; 94 | h = qMax(h, ih); 95 | } 96 | 97 | if (menu()) 98 | w += style()->pixelMetric(QStyle::PM_MenuButtonIndicator, &opt, this); 99 | 100 | h += 4; 101 | w += 8; 102 | 103 | QSize sizeHint = (style()->sizeFromContents(QStyle::CT_PushButton, &opt, QSize(w, h), this). 104 | expandedTo(QApplication::globalStrut())); 105 | 106 | return sizeHint; 107 | } 108 | 109 | QSize ActionLabel::minimumSizeHint() const 110 | { 111 | return sizeHint(); 112 | } 113 | 114 | 115 | } // namespace 116 | 117 | -------------------------------------------------------------------------------- /src/actions/actionlabel.h: -------------------------------------------------------------------------------- 1 | #ifndef ACTIONLABEL_H 2 | #define ACTIONLABEL_H 3 | 4 | #include 5 | 6 | 7 | namespace QSint 8 | { 9 | 10 | 11 | /** 12 | \brief Class representing an action similar to Windows Vista/7 control panel item. 13 | 14 | \image html ActionLabel.png An example of ActionLabel 15 | 16 | ActionLabel normally consists of an icon and text. 17 | It also can have tooltip and status tip, 18 | be clickable and checkable etc. i.e. behave like a normal QToolButton. 19 | 20 | Customization of ActionLabel via CSS 21 | 22 | ActionLabel objects are easily customizable via CSS technology - you can get 23 | different look just by writing corresponding style sheet and applying it with setStyleSheet(). 24 | 25 | See the following example of the complete ActionLabel customization. Note that 26 | \a QSint--ActionLabel is used as a main class name. 27 | 28 | \code 29 | // define a string representing CSS style 30 | const char* ActionLabelNewStyle = 31 | 32 | "QSint--ActionLabel[class='action'] {" 33 | "background-color: transparent;" 34 | "border: 1px solid transparent;" 35 | "color: #0033ff;" 36 | "text-align: left;" 37 | "font: 11px;" 38 | "}" 39 | 40 | "QSint--ActionLabel[class='action']:hover {" 41 | "color: #0099ff;" 42 | "text-decoration: underline;" 43 | "}" 44 | 45 | "QSint--ActionLabel[class='action']:focus {" 46 | "border: 1px dotted black;" 47 | "}" 48 | 49 | "QSint--ActionLabel[class='action']:on {" 50 | "background-color: #ddeeff;" 51 | "color: #006600;" 52 | "}" 53 | ; 54 | 55 | // apply the style 56 | label1->setStyleSheet(ActionLabelNewStyle); 57 | 58 | \endcode 59 | */ 60 | class ActionLabel : public QToolButton 61 | { 62 | Q_OBJECT 63 | 64 | public: 65 | /** Constructor. 66 | */ 67 | explicit ActionLabel(QWidget *parent = 0); 68 | 69 | /** Constructor. Creates ActionLabel from the \a action. 70 | \since 0.2 71 | */ 72 | explicit ActionLabel(QAction *action, QWidget *parent = 0); 73 | 74 | virtual ~ActionLabel() {} 75 | 76 | virtual QSize sizeHint() const; 77 | virtual QSize minimumSizeHint() const; 78 | 79 | protected: 80 | void init(); 81 | }; 82 | 83 | 84 | } // namespace 85 | 86 | #endif // ACTIONLABEL_H 87 | -------------------------------------------------------------------------------- /src/actions/actionpanel.cpp: -------------------------------------------------------------------------------- 1 | #include "actionpanel.h" 2 | #include "actionpanelscheme.h" 3 | #include "actiongroup.h" 4 | 5 | #include 6 | 7 | 8 | namespace QSint 9 | { 10 | 11 | 12 | ActionPanel::ActionPanel(QWidget *parent) : 13 | BaseClass(parent) 14 | { 15 | setProperty("class", "panel"); 16 | 17 | setScheme(ActionPanelScheme::defaultScheme()); 18 | 19 | setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred); 20 | 21 | QVBoxLayout *vbl = new QVBoxLayout(); 22 | vbl->setMargin(8); 23 | vbl->setSpacing(8); 24 | setLayout(vbl); 25 | } 26 | 27 | void ActionPanel::setScheme(ActionPanelScheme *scheme) 28 | { 29 | if (scheme) { 30 | myScheme = scheme; 31 | setStyleSheet(myScheme->actionStyle); 32 | 33 | // set scheme for children 34 | QObjectList list(children()); 35 | foreach(QObject *obj, list) { 36 | if (dynamic_cast(obj)) { 37 | ((ActionGroup*)obj)->setScheme(scheme); 38 | continue; 39 | } 40 | } 41 | 42 | update(); 43 | } 44 | } 45 | 46 | //void ActionPanel::paintEvent ( QPaintEvent * event ) 47 | //{ 48 | // //QPainter p(this); 49 | 50 | // //p.setOpacity(0.5); 51 | // //p.fillRect(rect(), myScheme->panelBackground); 52 | //} 53 | 54 | void ActionPanel::addWidget(QWidget *w) 55 | { 56 | if (w) 57 | layout()->addWidget(w); 58 | } 59 | 60 | void ActionPanel::addStretch(int s) 61 | { 62 | ((QVBoxLayout*)layout())->addStretch(s); 63 | } 64 | 65 | ActionGroup * ActionPanel::createGroup() 66 | { 67 | ActionGroup * group = new ActionGroup(this); 68 | addWidget(group); 69 | return group; 70 | } 71 | 72 | ActionGroup * ActionPanel::createGroup(const QString &title, bool expandable) 73 | { 74 | ActionGroup * box = new ActionGroup(title, expandable, this); 75 | addWidget(box); 76 | return box; 77 | } 78 | 79 | ActionGroup * ActionPanel::createGroup(const QPixmap &icon, const QString &title, bool expandable) 80 | { 81 | ActionGroup * box = new ActionGroup(icon, title, expandable, this); 82 | addWidget(box); 83 | return box; 84 | } 85 | 86 | 87 | QSize ActionPanel::minimumSizeHint() const 88 | { 89 | return QSize(200,150); 90 | } 91 | 92 | 93 | } // namespace 94 | -------------------------------------------------------------------------------- /src/actions/actionpanel.h: -------------------------------------------------------------------------------- 1 | #ifndef ACTIONPANEL_H 2 | #define ACTIONPANEL_H 3 | 4 | #include 5 | 6 | 7 | namespace QSint 8 | { 9 | 10 | 11 | class ActionPanelScheme; 12 | class ActionGroup; 13 | 14 | 15 | /** 16 | \brief Class representing panels of actions similar to Windows XP task panels. 17 | \since 0.2 18 | 19 | \image html ActionPanel1.png An example of ActionPanel 20 | 21 | ActionPanel acts like a container for ActionGroup which in turn are containers for 22 | the actions represented by ActionLabel. 23 | 24 | The look and fill is complete styleable via setScheme(). 25 | Currently the following schemes available: ActionPanelScheme (the default), 26 | WinXPPanelScheme and WinXPPanelScheme2 (blue Windows XP schemes), 27 | WinVistaPanelScheme (Windows Vista variation), MacPanelScheme (MacOS variation), 28 | AndroidPanelScheme (Android variation). 29 | */ 30 | class ActionPanel : public QFrame 31 | { 32 | typedef QFrame BaseClass; 33 | 34 | Q_OBJECT 35 | 36 | public: 37 | /** Constructor. 38 | */ 39 | explicit ActionPanel(QWidget *parent = 0); 40 | 41 | /** Adds a widget \a w to the ActionPanel's vertical layout. 42 | */ 43 | void addWidget(QWidget *w); 44 | 45 | /** Adds a spacer with width \a s to the ActionPanel's vertical layout. 46 | Normally you should do this after all the ActionGroups were added, in order to 47 | maintain some space below. 48 | */ 49 | void addStretch(int s = 0); 50 | 51 | /** Creates and adds to the ActionPanel's vertical layout an empty ActionGroup without header. 52 | */ 53 | ActionGroup* createGroup(); 54 | 55 | /** Creates and adds to the ActionPanel's vertical layout an empty ActionGroup with header's 56 | text set to \a title, but with no icon. 57 | 58 | If \a expandable set to \a true (default), the group can be expanded/collapsed by the user. 59 | */ 60 | ActionGroup* createGroup(const QString &title, bool expandable = true); 61 | 62 | /** Creates and adds to the ActionPanel's vertical layout an empty ActionGroup with header's 63 | text set to \a title and icon set to \a icon. 64 | 65 | If \a expandable set to \a true (default), the group can be expanded/collapsed by the user. 66 | */ 67 | ActionGroup* createGroup(const QPixmap &icon, const QString &title, bool expandable = true); 68 | 69 | /** Sets the scheme of the panel and all the child groups to \a scheme. 70 | 71 | By default, ActionPanelScheme::defaultScheme() is used. 72 | */ 73 | void setScheme(ActionPanelScheme *scheme); 74 | 75 | virtual QSize minimumSizeHint() const; 76 | 77 | protected: 78 | //virtual void paintEvent ( QPaintEvent * event ); 79 | 80 | ActionPanelScheme *myScheme; 81 | }; 82 | 83 | 84 | } // namespace 85 | 86 | #endif // ACTIONPANEL_H 87 | -------------------------------------------------------------------------------- /src/actions/actionpanelscheme.cpp: -------------------------------------------------------------------------------- 1 | #include "actionpanelscheme.h" 2 | 3 | 4 | class StaticLibInitializer 5 | { 6 | public: 7 | StaticLibInitializer() 8 | { 9 | Q_INIT_RESOURCE(schemes); 10 | } 11 | }; 12 | 13 | StaticLibInitializer staticLibInitializer; 14 | 15 | 16 | namespace QSint 17 | { 18 | 19 | 20 | const char* ActionPanelDefaultStyle = 21 | 22 | "QFrame[class='panel'] {" 23 | "background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0, stop: 0 #99cccc, stop: 1 #EAF7FF);" 24 | "}" 25 | 26 | "QSint--ActionGroup QFrame[class='header'] {" 27 | "background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #F9FDFF, stop: 1 #EAF7FF);" 28 | "border: 1px solid #00aa99;" 29 | "border-bottom: 1px solid #99cccc;" 30 | "border-top-left-radius: 3px;" 31 | "border-top-right-radius: 3px;" 32 | "}" 33 | 34 | "QSint--ActionGroup QFrame[class='header']:hover {" 35 | "background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #EAF7FF, stop: 1 #F9FDFF);" 36 | "}" 37 | 38 | "QSint--ActionGroup QToolButton[class='header'] {" 39 | "text-align: left;" 40 | "font: 14px;" 41 | "color: #006600;" 42 | "background-color: transparent;" 43 | "border: 1px solid transparent;" 44 | "}" 45 | 46 | "QSint--ActionGroup QToolButton[class='header']:hover {" 47 | "color: #00cc00;" 48 | "text-decoration: underline;" 49 | "}" 50 | 51 | "QSint--ActionGroup QFrame[class='content'] {" 52 | "background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #F9FDFF, stop: 1 #EAF7FF);" 53 | "border: 1px solid #00aa99;" 54 | "}" 55 | 56 | "QSint--ActionGroup QFrame[class='content'][header='true'] {" 57 | "border-top: none;" 58 | "}" 59 | 60 | "QSint--ActionGroup QToolButton[class='action'] {" 61 | "background-color: transparent;" 62 | "border: 1px solid transparent;" 63 | "color: #0033ff;" 64 | "text-align: left;" 65 | "font: 11px;" 66 | "}" 67 | 68 | "QSint--ActionGroup QToolButton[class='action']:!enabled {" 69 | "color: #999999;" 70 | "}" 71 | 72 | "QSint--ActionGroup QToolButton[class='action']:hover {" 73 | "color: #0099ff;" 74 | "text-decoration: underline;" 75 | "}" 76 | 77 | "QSint--ActionGroup QToolButton[class='action']:focus {" 78 | "border: 1px dotted black;" 79 | "}" 80 | 81 | "QSint--ActionGroup QToolButton[class='action']:on {" 82 | "background-color: #ddeeff;" 83 | "color: #006600;" 84 | "}" 85 | ; 86 | 87 | 88 | ActionPanelScheme::ActionPanelScheme() 89 | { 90 | headerSize = 28; 91 | headerAnimation = true; 92 | 93 | headerButtonFold = QPixmap(":/default/Fold.png"); 94 | headerButtonFoldOver = QPixmap(":/default/FoldOver.png"); 95 | headerButtonUnfold = QPixmap(":/default/Unfold.png"); 96 | headerButtonUnfoldOver = QPixmap(":/default/UnfoldOver.png"); 97 | headerButtonSize = QSize(18,18); 98 | 99 | groupFoldSteps = 20; groupFoldDelay = 15; 100 | groupFoldEffect = NoFolding; 101 | groupFoldThaw = true; 102 | 103 | actionStyle = QString(ActionPanelDefaultStyle); 104 | } 105 | 106 | ActionPanelScheme* ActionPanelScheme::defaultScheme() 107 | { 108 | static ActionPanelScheme scheme; 109 | return &scheme; 110 | } 111 | 112 | 113 | } 114 | -------------------------------------------------------------------------------- /src/actions/actionpanelscheme.h: -------------------------------------------------------------------------------- 1 | #ifndef TASKPANELSCHEME_H 2 | #define TASKPANELSCHEME_H 3 | 4 | #include 5 | #include 6 | 7 | #include 8 | 9 | 10 | namespace QSint 11 | { 12 | 13 | 14 | /** 15 | \brief Class representing color scheme for ActionPanel and ActionGroup. 16 | \since 0.2 17 | 18 | \image html ActionPanel1.png Default ActionPanel scheme 19 | */ 20 | class ActionPanelScheme 21 | { 22 | public: 23 | /** \enum TaskPanelFoldEffect 24 | \brief Animation effect during expanding/collapsing of the ActionGroup's contents. 25 | */ 26 | enum TaskPanelFoldEffect 27 | { 28 | /// No folding effect 29 | NoFolding, 30 | /// Folding by scaling group's contents 31 | ShrunkFolding, 32 | /// Folding by sliding group's contents 33 | SlideFolding 34 | }; 35 | 36 | 37 | ActionPanelScheme(); 38 | 39 | /** Returns a pointer to the default scheme object. 40 | Must be reimplemented in the own schemes. 41 | */ 42 | static ActionPanelScheme* defaultScheme(); 43 | 44 | /// Height of the header in pixels. 45 | int headerSize; 46 | /// If set to \a true, moving mouse over the header results in changing its opacity slowly. 47 | bool headerAnimation; 48 | 49 | /// Image of folding button when the group is expanded. 50 | QPixmap headerButtonFold; 51 | /// Image of folding button when the group is expanded and mouse cursor is over the button. 52 | QPixmap headerButtonFoldOver; 53 | /// Image of folding button when the group is collapsed. 54 | QPixmap headerButtonUnfold; 55 | /// Image of folding button when the group is collapsed and mouse cursor is over the button. 56 | QPixmap headerButtonUnfoldOver; 57 | 58 | QSize headerButtonSize; 59 | 60 | /// Number of steps made for expanding/collapsing animation (default 20). 61 | int groupFoldSteps; 62 | /// Delay in ms between steps made for expanding/collapsing animation (default 15). 63 | int groupFoldDelay; 64 | /// Sets folding effect during expanding/collapsing. 65 | TaskPanelFoldEffect groupFoldEffect; 66 | /// If set to \a true, changes group's opacity slowly during expanding/collapsing. 67 | bool groupFoldThaw; 68 | 69 | /// The CSS for the ActionPanel/ActionGroup elements. 70 | QString actionStyle; 71 | }; 72 | 73 | 74 | } 75 | 76 | #endif // TASKPANELSCHEME_H 77 | -------------------------------------------------------------------------------- /src/actions/actions.pri: -------------------------------------------------------------------------------- 1 | HEADERS += \ 2 | $$PWD/actionpanel.h \ 3 | $$PWD/actiongroup.h \ 4 | $$PWD/actionbox.h \ 5 | $$PWD/actionlabel.h \ 6 | $$PWD/taskheader_p.h \ 7 | $$PWD/taskgroup_p.h \ 8 | $$PWD/actionpanelscheme.h \ 9 | $$PWD/winxppanelscheme.h \ 10 | $$PWD/winvistapanelscheme.h \ 11 | $$PWD/macpanelscheme.h \ 12 | $$PWD/androidpanelscheme.h 13 | 14 | SOURCES += \ 15 | $$PWD/actionpanel.cpp \ 16 | $$PWD/actiongroup.cpp \ 17 | $$PWD/actionbox.cpp \ 18 | $$PWD/actionlabel.cpp \ 19 | $$PWD/taskheader_p.cpp \ 20 | $$PWD/taskgroup_p.cpp \ 21 | $$PWD/actionpanelscheme.cpp \ 22 | $$PWD/winxppanelscheme.cpp \ 23 | $$PWD/winvistapanelscheme.cpp \ 24 | $$PWD/macpanelscheme.cpp \ 25 | $$PWD/androidpanelscheme.cpp 26 | 27 | RESOURCES += \ 28 | $$PWD/schemes.qrc 29 | -------------------------------------------------------------------------------- /src/actions/android/Fold.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sintegrial/qsint/4b1d13c69e501a1dbf5f1bd381e152ad3b4f3a43/src/actions/android/Fold.png -------------------------------------------------------------------------------- /src/actions/android/FoldOver.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sintegrial/qsint/4b1d13c69e501a1dbf5f1bd381e152ad3b4f3a43/src/actions/android/FoldOver.png -------------------------------------------------------------------------------- /src/actions/android/Unfold.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sintegrial/qsint/4b1d13c69e501a1dbf5f1bd381e152ad3b4f3a43/src/actions/android/Unfold.png -------------------------------------------------------------------------------- /src/actions/android/UnfoldOver.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sintegrial/qsint/4b1d13c69e501a1dbf5f1bd381e152ad3b4f3a43/src/actions/android/UnfoldOver.png -------------------------------------------------------------------------------- /src/actions/androidpanelscheme.cpp: -------------------------------------------------------------------------------- 1 | #include "androidpanelscheme.h" 2 | 3 | 4 | namespace QSint 5 | { 6 | 7 | 8 | const char* ActionPanelAndroidStyle = 9 | 10 | "QFrame[class='panel'] {" 11 | "background-color: #424242;" 12 | "color: #ffffff;" 13 | "font-size: 10px;" 14 | "}" 15 | 16 | "QSint--ActionGroup QFrame[class='header'] {" 17 | "background-color: #171717;" 18 | "border-top: 1px solid white;" 19 | "border-bottom: 1px solid white;" 20 | "color: #ffffff;" 21 | "}" 22 | 23 | "QSint--ActionGroup QToolButton[class='header'] {" 24 | "text-align: left;" 25 | "color: #ffffff;" 26 | "background-color: transparent;" 27 | "border: 1px solid transparent;" 28 | "font-size: 14px;" 29 | "}" 30 | 31 | "QSint--ActionGroup QFrame[class='content'] {" 32 | "background-color: #171717;" 33 | "}" 34 | 35 | "QSint--ActionGroup QToolButton[class='action'] {" 36 | "background-color: transparent;" 37 | "border: 1px solid transparent;" 38 | "color: #ffffff;" 39 | "text-align: left;" 40 | "font-size: 14px;" 41 | "min-height: 32px;" 42 | "}" 43 | 44 | "QSint--ActionGroup QToolButton[class='action']:!enabled {" 45 | "color: #666666;" 46 | "}" 47 | 48 | "QSint--ActionGroup QToolButton[class='action']:focus {" 49 | "border: 1px dotted black;" 50 | "}" 51 | 52 | "QSint--ActionGroup QToolButton[class='action']:on {" 53 | "background-color: #ddeeff;" 54 | "color: #006600;" 55 | "}" 56 | 57 | ; 58 | 59 | 60 | AndroidPanelScheme::AndroidPanelScheme() : ActionPanelScheme() 61 | { 62 | headerSize = 40; 63 | 64 | headerButtonFold = QPixmap(":/android/Fold.png"); 65 | headerButtonFoldOver = QPixmap(":/android/FoldOver.png"); 66 | headerButtonUnfold = QPixmap(":/android/Unfold.png"); 67 | headerButtonUnfoldOver = QPixmap(":/android/UnfoldOver.png"); 68 | headerButtonSize = QSize(33,33); 69 | 70 | actionStyle = QString(ActionPanelAndroidStyle); 71 | } 72 | 73 | 74 | } 75 | 76 | -------------------------------------------------------------------------------- /src/actions/androidpanelscheme.h: -------------------------------------------------------------------------------- 1 | #ifndef ANDROIDPANELSCHEME_H 2 | #define ANDROIDPANELSCHEME_H 3 | 4 | 5 | #include "actionpanelscheme.h" 6 | 7 | 8 | namespace QSint 9 | { 10 | 11 | 12 | /** 13 | \brief Android-like color scheme for ActionPanel and ActionGroup. 14 | \since 0.2.1 15 | 16 | \image html ActionPanel5.png Example of the scheme 17 | */ 18 | class AndroidPanelScheme : public ActionPanelScheme 19 | { 20 | public: 21 | AndroidPanelScheme(); 22 | 23 | static ActionPanelScheme* defaultScheme() 24 | { 25 | static AndroidPanelScheme scheme; 26 | return &scheme; 27 | } 28 | }; 29 | 30 | 31 | } 32 | 33 | 34 | #endif // ANDROIDPANELSCHEME_H 35 | -------------------------------------------------------------------------------- /src/actions/default/Fold.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sintegrial/qsint/4b1d13c69e501a1dbf5f1bd381e152ad3b4f3a43/src/actions/default/Fold.png -------------------------------------------------------------------------------- /src/actions/default/FoldOver.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sintegrial/qsint/4b1d13c69e501a1dbf5f1bd381e152ad3b4f3a43/src/actions/default/FoldOver.png -------------------------------------------------------------------------------- /src/actions/default/Unfold.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sintegrial/qsint/4b1d13c69e501a1dbf5f1bd381e152ad3b4f3a43/src/actions/default/Unfold.png -------------------------------------------------------------------------------- /src/actions/default/UnfoldOver.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sintegrial/qsint/4b1d13c69e501a1dbf5f1bd381e152ad3b4f3a43/src/actions/default/UnfoldOver.png -------------------------------------------------------------------------------- /src/actions/mac/FoldOver.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sintegrial/qsint/4b1d13c69e501a1dbf5f1bd381e152ad3b4f3a43/src/actions/mac/FoldOver.png -------------------------------------------------------------------------------- /src/actions/mac/UnfoldOver.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sintegrial/qsint/4b1d13c69e501a1dbf5f1bd381e152ad3b4f3a43/src/actions/mac/UnfoldOver.png -------------------------------------------------------------------------------- /src/actions/macpanelscheme.cpp: -------------------------------------------------------------------------------- 1 | #include "macpanelscheme.h" 2 | 3 | 4 | namespace QSint 5 | { 6 | 7 | 8 | const char* MacPanelStyle = 9 | 10 | "QFrame[class='panel'] {" 11 | "background-color: #D9DEE5;" 12 | "border: 1px solid #BBBBBB;" 13 | "}" 14 | 15 | "QSint--ActionGroup QFrame[class='header'] {" 16 | "border: none;" 17 | "}" 18 | 19 | "QSint--ActionGroup QToolButton[class='header'] {" 20 | "text-align: left;" 21 | "color: #828CA8;" 22 | "background-color: transparent;" 23 | "font-weight: bold;" 24 | "}" 25 | 26 | "QSint--ActionGroup QFrame[class='content'] {" 27 | "background-color: #D9DEE5;" 28 | "margin-left: 12px;" 29 | "}" 30 | 31 | "QSint--ActionGroup QToolButton[class='action'] {" 32 | "color: #000000;" 33 | "text-align: left;" 34 | "background-color: transparent;" 35 | "border: 1px solid transparent;" 36 | "}" 37 | 38 | "QSint--ActionGroup QToolButton[class='action']:!enabled {" 39 | "color: #ffffff;" 40 | "}" 41 | 42 | "QSint--ActionGroup QToolButton[class='action']:focus {" 43 | "border: 1px solid #1E6CBB;" 44 | "background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #6FA6DE, stop: 1 #1E6CBB);" 45 | "color: #ffffff;" 46 | "}" 47 | 48 | "QSint--ActionGroup QToolButton[class='action']:on {" 49 | "background-color: #ddeeff;" 50 | "color: #006600;" 51 | "}" 52 | ; 53 | 54 | MacPanelScheme::MacPanelScheme() : ActionPanelScheme() 55 | { 56 | actionStyle = QString(MacPanelStyle); 57 | 58 | headerButtonFold = QPixmap(); 59 | headerButtonFoldOver = QPixmap(":/mac/FoldOver.png"); 60 | headerButtonUnfold = QPixmap(); 61 | headerButtonUnfoldOver = QPixmap(":/mac/UnfoldOver.png"); 62 | headerButtonSize = QSize(30,16); 63 | } 64 | 65 | 66 | } 67 | -------------------------------------------------------------------------------- /src/actions/macpanelscheme.h: -------------------------------------------------------------------------------- 1 | #ifndef MACPANELSCHEME_H 2 | #define MACPANELSCHEME_H 3 | 4 | #include "actionpanelscheme.h" 5 | 6 | 7 | namespace QSint 8 | { 9 | 10 | 11 | /** 12 | \brief MacOS-like color scheme for ActionPanel and ActionGroup. 13 | \since 0.2 14 | 15 | \image html ActionPanel6.png Example of the scheme 16 | */ 17 | class MacPanelScheme : public ActionPanelScheme 18 | { 19 | public: 20 | explicit MacPanelScheme(); 21 | 22 | static ActionPanelScheme* defaultScheme() 23 | { 24 | static MacPanelScheme scheme; 25 | return &scheme; 26 | } 27 | }; 28 | 29 | 30 | } 31 | 32 | #endif // MACPANELSCHEME_H 33 | -------------------------------------------------------------------------------- /src/actions/schemes.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | default/Fold.png 4 | default/FoldOver.png 5 | default/Unfold.png 6 | default/UnfoldOver.png 7 | xp/Fold_Blue1.png 8 | xp/Fold_Blue2.png 9 | xp/FoldOver_Blue1.png 10 | xp/FoldOver_Blue2.png 11 | xp/Unfold_Blue1.png 12 | xp/Unfold_Blue2.png 13 | xp/UnfoldOver_Blue1.png 14 | xp/UnfoldOver_Blue2.png 15 | vista/Fold.png 16 | vista/FoldOver.png 17 | vista/Unfold.png 18 | vista/UnfoldOver.png 19 | mac/FoldOver.png 20 | mac/UnfoldOver.png 21 | android/Fold.png 22 | android/Unfold.png 23 | android/FoldOver.png 24 | android/UnfoldOver.png 25 | 26 | 27 | -------------------------------------------------------------------------------- /src/actions/taskgroup_p.cpp: -------------------------------------------------------------------------------- 1 | #include "taskgroup_p.h" 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | 8 | namespace QSint 9 | { 10 | 11 | 12 | TaskGroup::TaskGroup(QWidget *parent, bool hasHeader) 13 | : BaseClass(parent), 14 | myHasHeader(hasHeader) 15 | { 16 | setProperty("class", "content"); 17 | setProperty("header", hasHeader ? "true" : "false"); 18 | 19 | setScheme(ActionPanelScheme::defaultScheme()); 20 | 21 | QVBoxLayout *vbl = new QVBoxLayout(); 22 | vbl->setMargin(4); 23 | vbl->setSpacing(0); 24 | setLayout(vbl); 25 | 26 | setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Maximum); 27 | } 28 | 29 | void TaskGroup::setScheme(ActionPanelScheme *scheme) 30 | { 31 | if (scheme) { 32 | myScheme = scheme; 33 | 34 | setStyleSheet(myScheme->actionStyle); 35 | 36 | update(); 37 | } 38 | } 39 | 40 | bool TaskGroup::addActionLabel(ActionLabel *label, bool addToLayout, bool addStretch) 41 | { 42 | if (!label) 43 | return false; 44 | 45 | label->setStyleSheet(""); 46 | 47 | return addWidget(label, addToLayout, addStretch); 48 | } 49 | 50 | bool TaskGroup::addWidget(QWidget *widget, bool addToLayout, bool addStretch) 51 | { 52 | if (!widget) 53 | return false; 54 | 55 | if (!addToLayout) 56 | return true; 57 | 58 | if (addStretch) { 59 | QHBoxLayout *hbl = new QHBoxLayout(); 60 | hbl->setMargin(0); 61 | hbl->setSpacing(0); 62 | hbl->addWidget(widget); 63 | hbl->addStretch(); 64 | 65 | groupLayout()->addLayout(hbl); 66 | } 67 | else { 68 | groupLayout()->addWidget(widget); 69 | } 70 | 71 | return true; 72 | } 73 | 74 | QPixmap TaskGroup::transparentRender() 75 | { 76 | QPixmap pm(size()); 77 | pm.fill(Qt::transparent); 78 | 79 | render(&pm, QPoint(0,0), rect(), DrawChildren | IgnoreMask); 80 | 81 | return pm; 82 | } 83 | 84 | void TaskGroup::paintEvent ( QPaintEvent * event ) 85 | { 86 | // QPainter p(this); 87 | 88 | // p.setBrush(myScheme->groupBackground); 89 | 90 | // p.setPen(myScheme->groupBorder); 91 | // p.drawRect(rect().adjusted(0,-(int)myHasHeader,-1,-1)); 92 | 93 | BaseClass::paintEvent(event); 94 | } 95 | 96 | void TaskGroup::keyPressEvent ( QKeyEvent * event ) 97 | { 98 | switch (event->key()) 99 | { 100 | case Qt::Key_Down: 101 | { 102 | QKeyEvent ke(QEvent::KeyPress, Qt::Key_Tab, 0); 103 | QApplication::sendEvent(this, &ke); 104 | return; 105 | } 106 | 107 | case Qt::Key_Up: 108 | { 109 | QKeyEvent ke(QEvent::KeyPress, Qt::Key_Tab, Qt::ShiftModifier); 110 | QApplication::sendEvent(this, &ke); 111 | return; 112 | } 113 | 114 | default:; 115 | } 116 | 117 | BaseClass::keyPressEvent(event); 118 | } 119 | 120 | 121 | void TaskGroup::keyReleaseEvent ( QKeyEvent * event ) 122 | { 123 | switch (event->key()) 124 | { 125 | case Qt::Key_Down: 126 | { 127 | QKeyEvent ke(QEvent::KeyRelease, Qt::Key_Tab, 0); 128 | QApplication::sendEvent(this, &ke); 129 | return; 130 | } 131 | 132 | case Qt::Key_Up: 133 | { 134 | QKeyEvent ke(QEvent::KeyRelease, Qt::Key_Tab, Qt::ShiftModifier); 135 | QApplication::sendEvent(this, &ke); 136 | return; 137 | } 138 | 139 | default:; 140 | } 141 | 142 | BaseClass::keyReleaseEvent(event); 143 | } 144 | 145 | 146 | } 147 | -------------------------------------------------------------------------------- /src/actions/taskgroup_p.h: -------------------------------------------------------------------------------- 1 | #ifndef TASKGROUP_P_H 2 | #define TASKGROUP_P_H 3 | 4 | #include "actionpanelscheme.h" 5 | #include "actionlabel.h" 6 | 7 | #include 8 | #include 9 | 10 | 11 | namespace QSint 12 | { 13 | 14 | 15 | class TaskGroup : public QFrame 16 | { 17 | typedef QFrame BaseClass; 18 | 19 | public: 20 | TaskGroup(QWidget *parent, bool hasHeader = false); 21 | 22 | void setScheme(ActionPanelScheme *scheme); 23 | 24 | inline QBoxLayout* groupLayout() 25 | { 26 | return (QBoxLayout*)layout(); 27 | } 28 | 29 | bool addActionLabel(ActionLabel *label, bool addToLayout, bool addStretch); 30 | 31 | bool addWidget(QWidget *widget, bool addToLayout, bool addStretch); 32 | 33 | QPixmap transparentRender(); 34 | 35 | protected: 36 | virtual void paintEvent ( QPaintEvent * event ); 37 | virtual void keyPressEvent ( QKeyEvent * event ); 38 | virtual void keyReleaseEvent ( QKeyEvent * event ); 39 | 40 | ActionPanelScheme *myScheme; 41 | 42 | bool myHasHeader; 43 | }; 44 | 45 | 46 | } 47 | 48 | #endif // TASKGROUP_P_H 49 | -------------------------------------------------------------------------------- /src/actions/taskheader_p.h: -------------------------------------------------------------------------------- 1 | #ifndef TASKHEADER_P_H 2 | #define TASKHEADER_P_H 3 | 4 | #include "actionpanelscheme.h" 5 | #include "actionlabel.h" 6 | 7 | #include 8 | 9 | 10 | namespace QSint 11 | { 12 | 13 | 14 | class TaskHeader : public QFrame 15 | { 16 | Q_OBJECT 17 | 18 | typedef QFrame BaseClass; 19 | 20 | friend class ActionGroup; 21 | 22 | public: 23 | TaskHeader(const QIcon &icon, const QString &title, bool expandable, QWidget *parent = 0); 24 | 25 | inline bool expandable() const { return myExpandable; } 26 | void setExpandable(bool expandable); 27 | 28 | void setScheme(ActionPanelScheme *scheme); 29 | 30 | signals: 31 | void activated(); 32 | 33 | public slots: 34 | void fold(); 35 | 36 | protected slots: 37 | void animate(); 38 | 39 | protected: 40 | virtual void paintEvent ( QPaintEvent * event ); 41 | virtual void enterEvent ( QEvent * event ); 42 | virtual void leaveEvent ( QEvent * event ); 43 | virtual void mouseReleaseEvent ( QMouseEvent * event ); 44 | virtual void keyPressEvent ( QKeyEvent * event ); 45 | virtual void keyReleaseEvent ( QKeyEvent * event ); 46 | 47 | bool eventFilter(QObject *obj, QEvent *event); 48 | 49 | void changeIcons(); 50 | 51 | ActionPanelScheme *myScheme; 52 | 53 | bool myExpandable; 54 | bool m_over, m_buttonOver, m_fold; 55 | double m_opacity; 56 | 57 | ActionLabel *myTitle; 58 | QLabel *myButton; 59 | }; 60 | 61 | 62 | } 63 | 64 | #endif // TASKHEADER_P_H 65 | -------------------------------------------------------------------------------- /src/actions/vista/Fold.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sintegrial/qsint/4b1d13c69e501a1dbf5f1bd381e152ad3b4f3a43/src/actions/vista/Fold.png -------------------------------------------------------------------------------- /src/actions/vista/FoldOver.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sintegrial/qsint/4b1d13c69e501a1dbf5f1bd381e152ad3b4f3a43/src/actions/vista/FoldOver.png -------------------------------------------------------------------------------- /src/actions/vista/Unfold.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sintegrial/qsint/4b1d13c69e501a1dbf5f1bd381e152ad3b4f3a43/src/actions/vista/Unfold.png -------------------------------------------------------------------------------- /src/actions/vista/UnfoldOver.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sintegrial/qsint/4b1d13c69e501a1dbf5f1bd381e152ad3b4f3a43/src/actions/vista/UnfoldOver.png -------------------------------------------------------------------------------- /src/actions/winvistapanelscheme.cpp: -------------------------------------------------------------------------------- 1 | #include "winvistapanelscheme.h" 2 | 3 | 4 | namespace QSint 5 | { 6 | 7 | 8 | const char* ActionPanelWinVistaStyle = 9 | 10 | "QFrame[class='panel'] {" 11 | "background: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0, stop: 0 #416FA6, stop: 1 #6BB86E);" 12 | "}" 13 | 14 | "QSint--ActionGroup QFrame[class='header'] {" 15 | "background: transparent;" 16 | "border: 1px solid transparent;" 17 | "}" 18 | 19 | "QSint--ActionGroup QFrame[class='header']:hover {" 20 | "background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 rgba(249,253,255,100), stop: 0.5 rgba(234,247,255,20), stop: 1 rgba(249,253,255,100));" 21 | "border: 1px solid transparent;" 22 | "}" 23 | 24 | "QSint--ActionGroup QToolButton[class='header'] {" 25 | "text-align: left;" 26 | "color: #ffffff;" 27 | "background-color: transparent;" 28 | "border: 1px solid transparent;" 29 | "font-size: 12px;" 30 | "}" 31 | 32 | "QSint--ActionGroup QFrame[class='content'] {" 33 | "background-color: transparent;" 34 | "color: #ffffff;" 35 | "}" 36 | 37 | "QSint--ActionGroup QToolButton[class='action'] {" 38 | "background-color: transparent;" 39 | "border: 1px solid transparent;" 40 | "color: #ffffff;" 41 | "text-align: left;" 42 | "}" 43 | 44 | "QSint--ActionGroup QToolButton[class='action']:!enabled {" 45 | "color: #666666;" 46 | "}" 47 | 48 | "QSint--ActionGroup QToolButton[class='action']:hover {" 49 | "color: #DAF2FC;" 50 | "text-decoration: underline;" 51 | "}" 52 | 53 | "QSint--ActionGroup QToolButton[class='action']:focus {" 54 | "border: 1px dotted black;" 55 | "}" 56 | 57 | "QSint--ActionGroup QToolButton[class='action']:on {" 58 | "background-color: #ddeeff;" 59 | "color: #006600;" 60 | "}" 61 | ; 62 | 63 | 64 | WinVistaPanelScheme::WinVistaPanelScheme() : ActionPanelScheme() 65 | { 66 | headerSize = 25; 67 | headerAnimation = false; 68 | 69 | //headerLabelScheme.iconSize = 22; 70 | 71 | headerButtonFold = QPixmap(":/vista/Fold.png"); 72 | headerButtonFoldOver = QPixmap(":/vista/FoldOver.png"); 73 | headerButtonUnfold = QPixmap(":/vista/Unfold.png"); 74 | headerButtonUnfoldOver = QPixmap(":/vista/UnfoldOver.png"); 75 | headerButtonSize = QSize(17,17); 76 | 77 | groupFoldSteps = 20; groupFoldDelay = 15; 78 | groupFoldThaw = true; 79 | groupFoldEffect = SlideFolding; 80 | 81 | actionStyle = QString(ActionPanelWinVistaStyle); 82 | } 83 | 84 | 85 | } 86 | 87 | -------------------------------------------------------------------------------- /src/actions/winvistapanelscheme.h: -------------------------------------------------------------------------------- 1 | #ifndef WINVISTAPANELSCHEME_H 2 | #define WINVISTAPANELSCHEME_H 3 | 4 | 5 | #include "actionpanelscheme.h" 6 | 7 | 8 | namespace QSint 9 | { 10 | 11 | 12 | /** 13 | \brief Windows Vista-like color scheme for ActionPanel and ActionGroup. 14 | \since 0.2 15 | 16 | \image html ActionPanel4.png Example of the scheme 17 | */ 18 | class WinVistaPanelScheme : public ActionPanelScheme 19 | { 20 | public: 21 | WinVistaPanelScheme(); 22 | 23 | static ActionPanelScheme* defaultScheme() 24 | { 25 | static WinVistaPanelScheme scheme; 26 | return &scheme; 27 | } 28 | }; 29 | 30 | 31 | } 32 | 33 | 34 | #endif // WINVISTAPANELSCHEME_H 35 | -------------------------------------------------------------------------------- /src/actions/winxppanelscheme.h: -------------------------------------------------------------------------------- 1 | #ifndef WinXPPanelScheme_H 2 | #define WinXPPanelScheme_H 3 | 4 | #include "actionpanelscheme.h" 5 | 6 | 7 | namespace QSint 8 | { 9 | 10 | 11 | /** 12 | \brief WindowsXP-like blue color scheme for ActionPanel and ActionGroup. 13 | \since 0.2 14 | 15 | \image html ActionPanel2.png Example of the scheme 16 | */ 17 | class WinXPPanelScheme : public ActionPanelScheme 18 | { 19 | public: 20 | WinXPPanelScheme(); 21 | 22 | static ActionPanelScheme* defaultScheme() 23 | { 24 | static WinXPPanelScheme scheme; 25 | return &scheme; 26 | } 27 | }; 28 | 29 | 30 | /** 31 | \brief WindowsXP-like blue color scheme for ActionPanel and ActionGroup (variation 2). 32 | \since 0.2 33 | 34 | \image html ActionPanel3.png Example of the scheme 35 | */ 36 | class WinXPPanelScheme2 : public ActionPanelScheme 37 | { 38 | public: 39 | WinXPPanelScheme2(); 40 | 41 | static ActionPanelScheme* defaultScheme() 42 | { 43 | static WinXPPanelScheme2 scheme; 44 | return &scheme; 45 | } 46 | }; 47 | 48 | 49 | } 50 | 51 | #endif // WinXPPanelScheme_H 52 | -------------------------------------------------------------------------------- /src/actions/xp/FoldOver_Blue1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sintegrial/qsint/4b1d13c69e501a1dbf5f1bd381e152ad3b4f3a43/src/actions/xp/FoldOver_Blue1.png -------------------------------------------------------------------------------- /src/actions/xp/FoldOver_Blue2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sintegrial/qsint/4b1d13c69e501a1dbf5f1bd381e152ad3b4f3a43/src/actions/xp/FoldOver_Blue2.png -------------------------------------------------------------------------------- /src/actions/xp/Fold_Blue1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sintegrial/qsint/4b1d13c69e501a1dbf5f1bd381e152ad3b4f3a43/src/actions/xp/Fold_Blue1.png -------------------------------------------------------------------------------- /src/actions/xp/Fold_Blue2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sintegrial/qsint/4b1d13c69e501a1dbf5f1bd381e152ad3b4f3a43/src/actions/xp/Fold_Blue2.png -------------------------------------------------------------------------------- /src/actions/xp/UnfoldOver_Blue1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sintegrial/qsint/4b1d13c69e501a1dbf5f1bd381e152ad3b4f3a43/src/actions/xp/UnfoldOver_Blue1.png -------------------------------------------------------------------------------- /src/actions/xp/UnfoldOver_Blue2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sintegrial/qsint/4b1d13c69e501a1dbf5f1bd381e152ad3b4f3a43/src/actions/xp/UnfoldOver_Blue2.png -------------------------------------------------------------------------------- /src/actions/xp/Unfold_Blue1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sintegrial/qsint/4b1d13c69e501a1dbf5f1bd381e152ad3b4f3a43/src/actions/xp/Unfold_Blue1.png -------------------------------------------------------------------------------- /src/actions/xp/Unfold_Blue2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sintegrial/qsint/4b1d13c69e501a1dbf5f1bd381e152ad3b4f3a43/src/actions/xp/Unfold_Blue2.png -------------------------------------------------------------------------------- /src/charts/axisbase.h: -------------------------------------------------------------------------------- 1 | #ifndef AXISBASE_H 2 | #define AXISBASE_H 3 | 4 | 5 | #include "plotterbase.h" 6 | 7 | 8 | namespace QSint 9 | { 10 | 11 | 12 | class PlotterBase; 13 | 14 | 15 | /** 16 | \brief Class representing single vertical or horizontal plotter axis. 17 | \since 0.2.1 18 | 19 | Class provides basic axis painting and calculations. 20 | */ 21 | 22 | class AxisBase : public QObject 23 | { 24 | Q_OBJECT 25 | public: 26 | explicit AxisBase(Qt::Orientation orient, PlotterBase *parent); 27 | 28 | 29 | enum AxisType { AxisData, AxisTime, AxisModel }; 30 | 31 | void setType(AxisType type); 32 | inline AxisType type() const { return m_type; } 33 | 34 | 35 | void setRanges(double min, double max); 36 | inline double rangeMininum() const { return m_min; } 37 | inline double rangeMaximum() const { return m_max; } 38 | 39 | void setTicks(double minor, double major); 40 | inline double minorTicks() const { return m_minor; } 41 | inline double majorTicks() const { return m_major; } 42 | 43 | void setOffset(int offset); 44 | inline int offset() const { return m_offset; } 45 | 46 | 47 | void setFont(const QFont &font); 48 | inline const QFont& font() const { return m_font; } 49 | 50 | void setTextColor(const QColor &color); 51 | inline const QColor& textColor() const { return m_textColor; } 52 | 53 | void setPen(const QPen &pen); 54 | inline const QPen& pen() const { return m_pen; } 55 | 56 | void setMinorTicksPen(const QPen &pen); 57 | inline const QPen& minorTicksPen() const { return m_minorPen; } 58 | 59 | void setMajorTicksPen(const QPen &pen); 60 | inline const QPen& majorTicksPen() const { return m_majorPen; } 61 | 62 | void setMinorGridPen(const QPen &pen); 63 | inline const QPen& minorGridPen() const { return m_minorGridPen; } 64 | 65 | void setMajorGridPen(const QPen &pen); 66 | inline const QPen& majorGridPen() const { return m_majorGridPen; } 67 | 68 | 69 | void setModel(QAbstractItemModel *model); 70 | inline QAbstractItemModel* model() const { return m_model; } 71 | 72 | 73 | virtual void calculatePoints(int &p_start, int &p_end); 74 | 75 | virtual int toView(double value); 76 | 77 | // called from plot drawer 78 | virtual void drawGrid(QPainter &p); 79 | virtual void drawAxisLine(QPainter &p); 80 | 81 | protected: 82 | virtual void drawAxisData(QPainter &p); 83 | virtual void drawAxisModel(QPainter &p); 84 | 85 | Qt::Orientation m_orient; 86 | 87 | QAbstractItemModel *m_model; 88 | 89 | double m_min, m_max; 90 | double m_minor, m_major; 91 | int m_offset; 92 | 93 | QFont m_font; 94 | 95 | QPen m_pen, m_minorPen, m_majorPen, m_minorGridPen, m_majorGridPen; 96 | QColor m_textColor; 97 | 98 | AxisType m_type; 99 | }; 100 | 101 | 102 | } // namespace 103 | 104 | #endif // AXISBASE_H 105 | -------------------------------------------------------------------------------- /src/charts/barchartplotter.cpp: -------------------------------------------------------------------------------- 1 | #include "barchartplotter.h" 2 | #include "axisbase.h" 3 | 4 | // painters 5 | #include "stackedbarpainter.h" 6 | #include "columnbarpainter.h" 7 | #include "trendpainter.h" 8 | 9 | 10 | namespace QSint 11 | { 12 | 13 | // static predefined painters 14 | static StackedBarPainter s_stackedPainter; 15 | static ColumnBarPainter s_columnPainter; 16 | static TrendPainter s_trendPainter; 17 | 18 | 19 | BarChartPlotter::BarChartPlotter(QWidget *parent) : 20 | PlotterBase(parent), 21 | m_barPainter(NULL) 22 | { 23 | m_axisX = new AxisBase(Qt::Horizontal, this); 24 | m_axisY = new AxisBase(Qt::Vertical, this); 25 | 26 | setBarType(Stacked); 27 | 28 | m_axisX->setType(AxisBase::AxisModel); 29 | 30 | setBarSize(-INT_MAX, INT_MAX); 31 | setBarScale(0.5); 32 | setBarOpacity(1.0); 33 | 34 | setZeroLinePen(QPen(Qt::white)); 35 | } 36 | 37 | 38 | void BarChartPlotter::setBarType(BarChartType type) 39 | { 40 | switch (type) 41 | { 42 | case Stacked: 43 | setBarPainter(&s_stackedPainter); 44 | break; 45 | 46 | case Columns: 47 | setBarPainter(&s_columnPainter); 48 | break; 49 | 50 | case Trend: 51 | setBarPainter(&s_trendPainter); 52 | break; 53 | 54 | default: 55 | setBarPainter(NULL); 56 | 57 | Q_ASSERT(false); 58 | break; 59 | } 60 | } 61 | 62 | 63 | void BarChartPlotter::setBarPainter(BarPainter *painter) 64 | { 65 | if (painter != m_barPainter) 66 | { 67 | m_barPainter = painter; 68 | } 69 | } 70 | 71 | 72 | void BarChartPlotter::setBarSize(int min, int max) 73 | { 74 | m_barsize_min = qMax(min, 0); 75 | m_barsize_max = qMax(min, max); 76 | } 77 | 78 | 79 | void BarChartPlotter::setBarScale(double scale) 80 | { 81 | if (scale < 0.1) 82 | m_scale = 0.1; 83 | else 84 | m_scale = qMin(scale, 1.0); 85 | } 86 | 87 | 88 | void BarChartPlotter::setBarOpacity(double value) 89 | { 90 | if (value < 0.0) 91 | m_opacity = 0; 92 | else 93 | m_opacity = qMin(value, 1.0); 94 | } 95 | 96 | 97 | void BarChartPlotter::setZeroLinePen(const QPen &pen) 98 | { 99 | m_zeroLinePen = pen; 100 | } 101 | 102 | 103 | void BarChartPlotter::drawContent(QPainter &p) 104 | { 105 | if (!m_model || !m_axisX || !m_axisY) 106 | return; 107 | 108 | int p_start, p_end; 109 | m_axisX->calculatePoints(p_start, p_end); 110 | 111 | // draw zero line 112 | int p_y = m_axisY->toView(0); 113 | 114 | p.setPen(m_zeroLinePen); 115 | p.drawLine(p_start, p_y, p_end, p_y); 116 | 117 | int count = m_model->columnCount(); 118 | if (!count) 119 | return; 120 | 121 | int row_count = m_model->rowCount(); 122 | if (!row_count) 123 | return; 124 | 125 | int p_offs = double(p_end - p_start) / count; 126 | 127 | int bar_size = p_offs * m_scale; 128 | 129 | if (bar_size > m_barsize_max) 130 | bar_size = qMin(m_barsize_max, p_offs); 131 | else if (bar_size < m_barsize_min) 132 | bar_size = qMin(m_barsize_min, p_offs); 133 | 134 | if (m_barPainter) 135 | { 136 | QModelIndex indexUnderMouse = m_barPainter->draw(this, mousePos(), p, count, row_count, p_start, p_offs, bar_size); 137 | setIndexUnderMouse(indexUnderMouse); 138 | } 139 | } 140 | 141 | 142 | 143 | } // namespace 144 | -------------------------------------------------------------------------------- /src/charts/barchartplotter.h: -------------------------------------------------------------------------------- 1 | #ifndef BARCHARTPLOTTER_H 2 | #define BARCHARTPLOTTER_H 3 | 4 | 5 | #include "plotterbase.h" 6 | 7 | 8 | namespace QSint 9 | { 10 | 11 | 12 | // forwards (for GCC) 13 | class BarPainter; 14 | class StackedBarPainter; 15 | class ColumnBarPainter; 16 | class TrendPainter; 17 | 18 | 19 | /** 20 | \brief Class representing a barchart plotting widget. 21 | \since 0.2.1 22 | 23 | \image html StackedChart.png An example of BarChartPlotter with \a Stacked type 24 | \image html ColumnChart.png An example of BarChartPlotter with \a Columns type 25 | \image html TrendChart.png An example of BarChartPlotter with \a Trend type 26 | 27 | BarChartPlotter provides following types of the charts (see \a BarChartType enum): 28 | - Stacked bars 29 | - Column-based bars 30 | - Trends 31 | */ 32 | class BarChartPlotter : public PlotterBase 33 | { 34 | Q_OBJECT 35 | public: 36 | explicit BarChartPlotter(QWidget *parent = 0); 37 | 38 | // temp 39 | friend class BarPainter; 40 | friend class StackedBarPainter; 41 | friend class ColumnBarPainter; 42 | friend class TrendPainter; 43 | 44 | 45 | /// \brief Defines type of the chart. 46 | enum BarChartType 47 | { 48 | /// bar represents single model column 49 | Stacked, 50 | /// bar represents single model value 51 | Columns, 52 | /// trend-like plot 53 | Trend 54 | }; 55 | 56 | /// Sets the plotter type to \a type. 57 | void setBarType(BarChartType type); 58 | 59 | /// Sets custom plotter painter. The previous painter will not be deleted automatically. 60 | /// Plotter painters can be shared between several plotter instances. 61 | /// \since 0.3 62 | void setBarPainter(BarPainter *painter); 63 | 64 | /// Sets minimum and maximum sizes of a single bar. 65 | /// Valid for \b Stacked and \b Columns plotter types. 66 | void setBarSize(int min, int max = INT_MAX); 67 | /// Retrieves minimum bar size. \sa setBarSize() 68 | inline int barSizeMin() const { return m_barsize_min; } 69 | /// Retrieves maximum bar size. \sa setBarSize() 70 | inline int barSizeMax() const { return m_barsize_max; } 71 | 72 | /** Sets scale coefficient to \a scale. 73 | This value defines how many space a single model column representation could get. 74 | It should be in ranges between 0.1 and 1.0, 0.5 is the default. 75 | Valid for \b Stacked and \b Columns plotter types. 76 | */ 77 | void setBarScale(double scale); 78 | /// Retrieves bar scale coefficient. \sa setBarScale() 79 | inline double barScale() const { return m_scale; } 80 | 81 | /// Sets opacity of a single bar to \a value (should be in ranges between 0.1 and 1.0, 1.0 is the default). 82 | void setBarOpacity(double value); 83 | /// Retrieves bar opacity. \sa setBarOpacity() 84 | inline double barOpacity() const { return m_opacity; } 85 | 86 | 87 | /// Sets pen of zero line of the plotter to \a pen. 88 | void setZeroLinePen(const QPen &pen); 89 | /// Retrieves zero line pen. \sa setZeroLinePen() 90 | inline const QPen& zeroLinePen() const { return m_zeroLinePen; } 91 | 92 | protected: 93 | virtual void drawContent(QPainter &p); 94 | 95 | int m_barsize_min, m_barsize_max; 96 | double m_scale; 97 | double m_opacity; 98 | QPen m_zeroLinePen; 99 | 100 | BarPainter* m_barPainter; 101 | }; 102 | 103 | 104 | } // namespace 105 | 106 | #endif // BARCHARTPLOTTER_H 107 | -------------------------------------------------------------------------------- /src/charts/barpainter.cpp: -------------------------------------------------------------------------------- 1 | #include "barpainter.h" 2 | #include "barchartplotter.h" 3 | 4 | 5 | namespace QSint 6 | { 7 | 8 | 9 | void BarPainter::drawValueText( 10 | BarChartPlotter *plotter, 11 | QPainter &p, 12 | const QRect &rect, 13 | int flags, 14 | bool isHighlighted, 15 | const QModelIndex &index, 16 | const QString &text) const 17 | { 18 | if (isHighlighted) 19 | { 20 | p.setPen(QPen(plotter->highlightTextColor())); 21 | } 22 | else 23 | { 24 | QVariant v_pen(index.data(Qt::ForegroundRole)); 25 | if (v_pen.isValid()) 26 | p.setPen(qvariant_cast(v_pen)); 27 | else 28 | p.setPen(qvariant_cast(index.model()->headerData(index.row(), Qt::Vertical, Qt::ForegroundRole))); 29 | } 30 | 31 | p.drawText(rect, flags, text); 32 | } 33 | 34 | 35 | QRect BarPainter::drawHighlightedValueFrame( 36 | BarChartPlotter *plotter, 37 | QPainter &p, const QRect &rect, const QRect &textRect) const 38 | { 39 | QRect backRect(textRect.adjusted(-3,-3,3,3)); 40 | backRect.moveLeft(rect.center().x() - backRect.width()/2); 41 | backRect.moveTop(rect.center().y() - backRect.height()/2); 42 | 43 | p.setPen(plotter->highlightPen()); 44 | p.setBrush(plotter->highlightBrush()); 45 | p.drawRect(backRect); 46 | 47 | return backRect; 48 | } 49 | 50 | 51 | void BarPainter::drawSegment( 52 | BarChartPlotter *plotter, 53 | QPainter &p, 54 | QRect rect, 55 | const QModelIndex &index, 56 | double /*value*/, 57 | bool isHighlighted) const 58 | { 59 | if (isHighlighted) 60 | { 61 | p.setPen(plotter->highlightPen()); 62 | p.setBrush(plotter->highlightBrush()); 63 | } 64 | else 65 | { 66 | QVariant v_brush(index.data(Qt::BackgroundRole)); 67 | if (v_brush.isValid()) 68 | p.setBrush(qvariant_cast(v_brush)); 69 | else 70 | p.setBrush(qvariant_cast(index.model()->headerData(index.row(), Qt::Vertical, Qt::BackgroundRole))); 71 | 72 | p.setPen(plotter->itemPen()); 73 | } 74 | 75 | p.drawRect(rect); 76 | } 77 | 78 | 79 | } //ns 80 | -------------------------------------------------------------------------------- /src/charts/barpainter.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | 6 | namespace QSint 7 | { 8 | 9 | 10 | class BarChartPlotter; 11 | 12 | 13 | /** 14 | * @brief The BarPainter class is the base class for drawing contents of the BarChartPlotter data model. 15 | * \since 0.3 16 | */ 17 | class BarPainter 18 | { 19 | public: 20 | /// Draws all the plotter items and returns index of the item under mouse. 21 | virtual QModelIndex draw( 22 | BarChartPlotter *plotter, 23 | const QPoint& mousePosition, 24 | QPainter &p, 25 | int count, 26 | int row_count, 27 | int p_start, 28 | int p_offs, 29 | int bar_size) const = 0; 30 | 31 | virtual void drawValue( 32 | BarChartPlotter *plotter, 33 | QPainter &p, 34 | QRect rect, 35 | const QModelIndex &index, 36 | double value, 37 | bool isHighlighted) const = 0; 38 | 39 | protected: 40 | virtual void drawValueText( 41 | BarChartPlotter *plotter, 42 | QPainter &p, 43 | const QRect &rect, 44 | int flags, 45 | bool isHighlighted, 46 | const QModelIndex &index, 47 | const QString &text) const; 48 | 49 | virtual QRect drawHighlightedValueFrame( 50 | BarChartPlotter *plotter, 51 | QPainter &p, 52 | const QRect &rect, 53 | const QRect &textRect) const; 54 | 55 | virtual void drawSegment( 56 | BarChartPlotter *plotter, 57 | QPainter &p, 58 | QRect rect, 59 | const QModelIndex &index, 60 | double value, 61 | bool isHighlighted) const; 62 | }; 63 | 64 | 65 | } 66 | 67 | -------------------------------------------------------------------------------- /src/charts/charts.pri: -------------------------------------------------------------------------------- 1 | HEADERS += \ 2 | $$PWD/axisbase.h \ 3 | $$PWD/plotterbase.h \ 4 | $$PWD/paintscheme.h \ 5 | $$PWD/ringplotbase.h \ 6 | $$PWD/piechart.h \ 7 | $$PWD/piechartwidget.h \ 8 | $$PWD/ringchart.h \ 9 | $$PWD/barchartplotter.h \ 10 | $$PWD/barpainter.h \ 11 | $$PWD/stackedbarpainter.h \ 12 | $$PWD/columnbarpainter.h \ 13 | $$PWD/trendpainter.h 14 | 15 | SOURCES += \ 16 | $$PWD/axisbase.cpp \ 17 | $$PWD/barchartplotter.cpp \ 18 | $$PWD/paintscheme.cpp \ 19 | $$PWD/piechart.cpp \ 20 | $$PWD/piechartwidget.cpp \ 21 | $$PWD/plotterbase.cpp \ 22 | $$PWD/ringchart.cpp \ 23 | $$PWD/barpainter.cpp \ 24 | $$PWD/stackedbarpainter.cpp \ 25 | $$PWD/columnbarpainter.cpp \ 26 | $$PWD/trendpainter.cpp \ 27 | $$PWD/ringplotbase.cpp 28 | -------------------------------------------------------------------------------- /src/charts/columnbarpainter.cpp: -------------------------------------------------------------------------------- 1 | #include "columnbarpainter.h" 2 | #include "axisbase.h" 3 | #include "barchartplotter.h" 4 | 5 | 6 | namespace QSint 7 | { 8 | 9 | 10 | QModelIndex ColumnBarPainter::draw( 11 | BarChartPlotter *plotter, 12 | const QPoint& mousePosition, 13 | QPainter &p, 14 | int count, 15 | int row_count, 16 | int p_start, 17 | int p_offs, 18 | int bar_size) const 19 | { 20 | if (row_count <= 0) 21 | return QModelIndex(); 22 | 23 | int single_bar_size = bar_size / row_count; 24 | if (!single_bar_size) 25 | return QModelIndex(); 26 | 27 | bool isUnderMouse = false; 28 | double valueHl = 0.0; 29 | QModelIndex indexHl; 30 | QRect rectHl; 31 | 32 | for (int i = 0; i < count; i++) 33 | { 34 | int p_d = p_start + p_offs*i + (p_offs-bar_size)/2; 35 | 36 | int p_y = plotter->axisY()->toView(0); 37 | 38 | p.setOpacity(plotter->barOpacity()); 39 | 40 | for (int j = 0; j < row_count; j++) 41 | { 42 | const QModelIndex index(plotter->model()->index(j, i)); 43 | double value = index.data(Qt::EditRole).toDouble(); 44 | 45 | int p_h = plotter->axisY()->toView(value); 46 | 47 | QRect itemRect; 48 | 49 | if (value < 0) 50 | { 51 | itemRect = QRect(p_d, p_y, single_bar_size, p_h-p_y); 52 | } 53 | else 54 | { 55 | itemRect = QRect(p_d, p_h, single_bar_size, p_y-p_h); 56 | } 57 | 58 | p_d += single_bar_size; 59 | 60 | // check for highlight 61 | if (!isUnderMouse && !mousePosition.isNull() && itemRect.contains(mousePosition)) 62 | { 63 | isUnderMouse = true; 64 | valueHl = value; 65 | indexHl = index; 66 | rectHl = itemRect; 67 | } 68 | 69 | // do not draw if highlighted 70 | if (plotter->isHighlightEnabled() && index == indexHl) 71 | continue; 72 | 73 | drawSegment(plotter, p, itemRect, index, value, false); 74 | drawValue(plotter, p, itemRect, index, value, false); 75 | } 76 | } 77 | 78 | if (isUnderMouse) 79 | { 80 | if (plotter->isHighlightEnabled()) 81 | { 82 | drawSegment(plotter, p, rectHl, indexHl, valueHl, true); 83 | drawValue(plotter, p, rectHl, indexHl, valueHl, true); 84 | } 85 | 86 | // item under mouse found 87 | return indexHl; 88 | } 89 | 90 | // no item under mouse 91 | return QModelIndex(); 92 | } 93 | 94 | 95 | void ColumnBarPainter::drawValue( 96 | BarChartPlotter *plotter, 97 | QPainter &p, 98 | QRect rect, 99 | const QModelIndex &index, 100 | double value, 101 | bool isHighlighted) const 102 | { 103 | int flags = Qt::AlignCenter; 104 | 105 | QString text = plotter->formattedValue(value, index); 106 | 107 | QRect textRect(p.fontMetrics().boundingRect(text)); 108 | 109 | if (value < 0) 110 | { 111 | flags = Qt::AlignHCenter | Qt::AlignTop; 112 | rect.setTop(rect.bottom() + 4); 113 | rect.setHeight(textRect.height()); 114 | } 115 | else 116 | { 117 | flags = Qt::AlignHCenter | Qt::AlignBottom; 118 | rect.setTop(rect.top() - textRect.height() - 4); 119 | rect.setHeight(textRect.height()); 120 | } 121 | 122 | if (rect.width() < textRect.width() + 4) 123 | rect.setWidth(textRect.width() + 4); 124 | 125 | if (isHighlighted) 126 | { 127 | flags = Qt::AlignCenter; 128 | QRect frameRect = drawHighlightedValueFrame(plotter, p, rect, textRect); 129 | drawValueText(plotter, p, frameRect, flags, true, index, text); 130 | } 131 | else if (plotter->valuesAlwaysShown()) 132 | { 133 | drawValueText(plotter, p, rect, flags, false, index, text); 134 | } 135 | } 136 | 137 | 138 | } 139 | 140 | -------------------------------------------------------------------------------- /src/charts/columnbarpainter.h: -------------------------------------------------------------------------------- 1 | #ifndef COLUMNBARPAINTER_H 2 | #define COLUMNBARPAINTER_H 3 | 4 | #include "barpainter.h" 5 | 6 | 7 | namespace QSint 8 | { 9 | 10 | 11 | /** 12 | * @brief The ColumnBarPainter class implemenents default BarChartPlotter::Trend plot representation. 13 | * \since 0.3 14 | */ 15 | class ColumnBarPainter : public BarPainter 16 | { 17 | public: 18 | virtual QModelIndex draw( 19 | BarChartPlotter *plotter, 20 | const QPoint& mousePosition, 21 | QPainter &p, 22 | int count, 23 | int row_count, 24 | int p_start, 25 | int p_offs, 26 | int bar_size) const; 27 | 28 | virtual void drawValue( 29 | BarChartPlotter *plotter, 30 | QPainter &p, 31 | QRect rect, 32 | const QModelIndex &index, 33 | double value, 34 | bool isHighlighted) const; 35 | }; 36 | 37 | 38 | } 39 | 40 | #endif // COLUMNBARPAINTER_H 41 | -------------------------------------------------------------------------------- /src/charts/paintscheme.cpp: -------------------------------------------------------------------------------- 1 | #include "paintscheme.h" 2 | 3 | 4 | namespace QSint 5 | { 6 | 7 | 8 | PaintScheme::PaintScheme() 9 | { 10 | basePen = QPen(Qt::gray); 11 | baseBrush = QBrush(Qt::lightGray); 12 | } 13 | 14 | 15 | } 16 | 17 | -------------------------------------------------------------------------------- /src/charts/paintscheme.h: -------------------------------------------------------------------------------- 1 | #ifndef PAINTSCHEME_H 2 | #define PAINTSCHEME_H 3 | 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | 11 | namespace QSint 12 | { 13 | 14 | 15 | class PaintScheme 16 | { 17 | public: 18 | PaintScheme(); 19 | 20 | QPen basePen; 21 | QBrush baseBrush; 22 | 23 | QFont axisPen; 24 | QFont axisTextFont; 25 | QColor axisTextColor; 26 | 27 | QFont itemPen; 28 | QBrush itemBrush; 29 | QFont itemTextFont; 30 | QColor itemTextColor; 31 | 32 | QFont itemHighlightPen; 33 | QBrush itemHighlightBrush; 34 | QColor itemTextHighlightColor; 35 | }; 36 | 37 | 38 | } 39 | 40 | 41 | #endif // PAINTSCHEME_H 42 | -------------------------------------------------------------------------------- /src/charts/piechart.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "piechart.h" 4 | 5 | 6 | namespace QSint 7 | { 8 | 9 | 10 | PieChart::PieChart(QWidget *parent) : 11 | RingPlotBase(parent) 12 | { 13 | m_index = 0; 14 | } 15 | 16 | 17 | void PieChart::setActiveIndex(int index) 18 | { 19 | if (m_index == index) 20 | return; 21 | 22 | m_index = 0; 23 | 24 | scheduleUpdate(); 25 | 26 | if (!m_model) 27 | return; 28 | 29 | if (index >= 0 && index < m_model->columnCount()) 30 | m_index = index; 31 | } 32 | 33 | 34 | void PieChart::setActiveIndex(const QModelIndex &index) 35 | { 36 | if (index.isValid()) 37 | setActiveIndex(index.column()); 38 | } 39 | 40 | 41 | void PieChart::drawData(QPainter &p, int innerRadius, int outerRadius, const QRect& pieRect) 42 | { 43 | // check if need to draw highlight 44 | bool checkHighlight = false; 45 | double mouseAngle = 0; 46 | 47 | // check if we're inside piechart at all 48 | if (!m_mousePos.isNull() && pieRect.contains(m_mousePos)) 49 | { 50 | // Determine the distance from the center point of the pie chart. 51 | double cx = m_mousePos.x() - pieRect.center().x(); 52 | double cy = pieRect.center().y() - m_mousePos.y(); 53 | double mouseRadius = pow(pow(cx, 2) + pow(cy, 2), 0.5); 54 | if (!(mouseRadius <= innerRadius || mouseRadius >= outerRadius)) 55 | { 56 | // Determine the angle of the point. 57 | mouseAngle = (180 / M_PI) * acos(cx / mouseRadius); 58 | if (cy < 0) 59 | mouseAngle = 360 - mouseAngle; 60 | 61 | checkHighlight = true; 62 | } 63 | } 64 | 65 | drawRing(p, pieRect.center(), m_index, innerRadius, outerRadius, checkHighlight, mouseAngle); 66 | } 67 | 68 | 69 | void PieChart::drawSegment(QPainter &p, const QRect& pieRect, 70 | const QModelIndex &index, double /*value*/, 71 | double angle1, double angle2, 72 | bool isHighlighted) 73 | { 74 | int r = index.row(); 75 | 76 | if (isHighlighted) 77 | { 78 | p.setPen(m_hlPen); 79 | p.setBrush(m_hlBrush); 80 | 81 | p.drawPie(pieRect, int(angle1*16), int(angle2*16)); 82 | } 83 | else 84 | { 85 | p.setPen(m_itemPen); 86 | p.setBrush(brushFromIndex(index)); 87 | 88 | p.drawPie(pieRect, int(angle1*16), int(angle2*16)); 89 | } 90 | } 91 | 92 | 93 | } 94 | -------------------------------------------------------------------------------- /src/charts/piechart.h: -------------------------------------------------------------------------------- 1 | #ifndef PIECHART_H 2 | #define PIECHART_H 3 | 4 | 5 | #include "ringplotbase.h" 6 | 7 | 8 | namespace QSint 9 | { 10 | 11 | 12 | /** 13 | \brief Class representing a piechart model view widget. 14 | \since 0.2.1 15 | 16 | \image html PieChart.png An example of PieChart 17 | 18 | PieChart represents single column of the model as a pie chart diagram. 19 | Use setActiveIndex() method to choose the active column within the model. 20 | */ 21 | class PieChart : public RingPlotBase 22 | { 23 | Q_OBJECT 24 | 25 | public: 26 | PieChart(QWidget *parent = 0); 27 | 28 | public Q_SLOTS: 29 | /// Sets active column to the \a index. 30 | void setActiveIndex(int index); 31 | /// Sets active column to the \a index.column(). 32 | void setActiveIndex(const QModelIndex &index); 33 | 34 | protected: 35 | // override: RingPlotBase 36 | virtual void drawData(QPainter &p, int innerRadius, int outerRadius, const QRect& pieRect); 37 | 38 | /** Draws a signle pie chart segment using QPainter \a p. 39 | Chart is to be drawn in the rectangle \a pieRect. 40 | Current model index of the segment in \a index, current value is \a value. 41 | \a angle1 and \a angle2 are start and end angles of the segment (in gradus). 42 | \a isHighlighted is true when the segment is highlighted. 43 | */ 44 | virtual void drawSegment(QPainter &p, const QRect& pieRect, 45 | const QModelIndex &index, double value, 46 | double angle1, double angle2, 47 | bool isHighlighted); 48 | 49 | protected: 50 | int m_index = -1; 51 | }; 52 | 53 | 54 | } 55 | 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /src/charts/piechartwidget.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "piechartwidget.h" 4 | 5 | 6 | namespace QSint 7 | { 8 | 9 | 10 | PieChartWidget::PieChartWidget(QWidget *parent) : 11 | PieChart(parent) 12 | { 13 | m_model.setColumnCount(1); 14 | setModel(&m_model); 15 | } 16 | 17 | 18 | void PieChartWidget::clear() 19 | { 20 | m_model.clear(); 21 | m_model.setColumnCount(1); 22 | } 23 | 24 | 25 | int PieChartWidget::addData(const QString &text, const QBrush &brush, double value) 26 | { 27 | QStandardItem *item = new QStandardItem; 28 | item->setData(value, Qt::EditRole); 29 | item->setBackground(brush); 30 | 31 | int r = m_model.rowCount(); 32 | m_model.appendRow(item); 33 | 34 | if (!text.isEmpty()) 35 | m_model.setHeaderData(r, Qt::Vertical, text); 36 | 37 | return r; 38 | } 39 | 40 | 41 | bool PieChartWidget::removeData(int index) 42 | { 43 | if (index >= 0 && index < m_model.rowCount()) 44 | { 45 | m_model.removeRow(index); 46 | return true; 47 | } 48 | 49 | return false; 50 | } 51 | 52 | 53 | } 54 | -------------------------------------------------------------------------------- /src/charts/piechartwidget.h: -------------------------------------------------------------------------------- 1 | #ifndef PIECHARTWIDGET_H 2 | #define PIECHARTWIDGET_H 3 | 4 | 5 | #include "piechart.h" 6 | 7 | #include 8 | 9 | 10 | namespace QSint 11 | { 12 | 13 | 14 | /** 15 | \brief Class representing a piechart widget with own data model. 16 | \since 0.4 17 | 18 | \image html PieChart.png An example of PieChart 19 | 20 | Unlike PieChart, PieChartWidget allows to build pie chart diagrams using simpler API. 21 | */ 22 | class PieChartWidget : public PieChart 23 | { 24 | Q_OBJECT 25 | 26 | public: 27 | PieChartWidget(QWidget *parent = 0); 28 | 29 | /// Returns amount of data entries in the diagram. 30 | int dataCount() const { return m_model.rowCount(); } 31 | 32 | public Q_SLOTS: 33 | /// Appends new data entry to the diagram. Returns index of the data entry. 34 | int addData(const QString &text, const QBrush &brush, double value); 35 | 36 | /// Removes data entry at \a index. Returns \a true if \a index is valid and data has been removed. 37 | bool removeData(int index); 38 | 39 | /// Removes all the data entries. 40 | void clear(); 41 | 42 | protected: 43 | 44 | protected: 45 | QStandardItemModel m_model; 46 | }; 47 | 48 | 49 | } 50 | 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /src/charts/ringchart.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "ringchart.h" 4 | 5 | 6 | namespace QSint 7 | { 8 | 9 | 10 | RingChart::RingChart(QWidget *parent) : 11 | RingPlotBase(parent) 12 | { 13 | } 14 | 15 | 16 | void RingChart::drawData(QPainter &p, int innerRadius, int outerRadius, const QRect& pieRect) 17 | { 18 | int count = m_model->columnCount(); 19 | if (count <= 0) 20 | return; 21 | 22 | // check if need to draw highlight 23 | bool checkHighlight = false; 24 | double mouseAngle = 0, mouseRadius = 0; 25 | 26 | // check if we're inside piechart at all 27 | if (!m_mousePos.isNull() && pieRect.contains(m_mousePos)) 28 | { 29 | // Determine the distance from the center point of the pie chart. 30 | double cx = m_mousePos.x() - pieRect.center().x(); 31 | double cy = pieRect.center().y() - m_mousePos.y(); 32 | mouseRadius = pow(pow(cx, 2) + pow(cy, 2), 0.5); 33 | if (!(mouseRadius <= innerRadius || mouseRadius >= outerRadius)) 34 | { 35 | // Determine the angle of the point. 36 | mouseAngle = (180 / M_PI) * acos(cx / mouseRadius); 37 | if (cy < 0) 38 | mouseAngle = 360 - mouseAngle; 39 | 40 | checkHighlight = true; 41 | } 42 | } 43 | 44 | 45 | // draw rings 46 | int dr = outerRadius - innerRadius; 47 | int ringSize = dr / count; 48 | int r1 = innerRadius; 49 | int r2 = outerRadius; 50 | 51 | for (int ring = count - 1; ring >= 0; ring--) 52 | { 53 | // inner radius of the ring 54 | r1 = r2 - ringSize; 55 | 56 | // check if we are NOT between rings 57 | bool ringHighlight = checkHighlight; 58 | if (ringHighlight && (mouseRadius <= r1 || mouseRadius >= r2)) 59 | ringHighlight = false; 60 | 61 | drawRing(p, pieRect.center(), ring, r1, r2, ringHighlight, mouseAngle); 62 | 63 | // go next ring 64 | r2 = r1; 65 | } 66 | } 67 | 68 | 69 | void RingChart::drawSegment(QPainter &p, const QRect& pieRect, 70 | const QModelIndex &index, double /*value*/, 71 | double angle1, double angle2, 72 | bool isHighlighted) 73 | { 74 | p.setPen(m_itemPen); 75 | 76 | p.setBrush(brushFromIndex(index)); 77 | 78 | p.drawPie(pieRect, int(angle1*16), int(angle2*16)); 79 | 80 | // draw over if highlighted 81 | if (isHighlighted) 82 | { 83 | p.setPen(m_hlPen); 84 | p.setBrush(m_hlBrush); 85 | 86 | p.drawPie(pieRect, int(angle1*16), int(angle2*16)); 87 | } 88 | } 89 | 90 | 91 | } 92 | 93 | -------------------------------------------------------------------------------- /src/charts/ringchart.h: -------------------------------------------------------------------------------- 1 | #ifndef RINGCHART_H 2 | #define RINGCHART_H 3 | 4 | 5 | #include "ringplotbase.h" 6 | 7 | 8 | namespace QSint 9 | { 10 | 11 | 12 | /** 13 | \brief Class representing a ringchart widget. 14 | \since 0.2.2 15 | 16 | \image html RingChart.png An example of RingChart 17 | 18 | RingChart represents every column of the model as a ring which consists of the segments 19 | with their sizes proportional to the row values. 20 | */ 21 | class RingChart : public RingPlotBase 22 | { 23 | Q_OBJECT 24 | 25 | public: 26 | RingChart(QWidget *parent = 0); 27 | 28 | protected: 29 | // override: RingPlotBase 30 | virtual void drawData(QPainter &p, int innerRadius, int outerRadius, const QRect& pieRect); 31 | 32 | virtual void drawSegment(QPainter &p, const QRect& pieRect, 33 | const QModelIndex &index, double value, 34 | double angle1, double angle2, 35 | bool isHighlighted); 36 | }; 37 | 38 | 39 | } 40 | 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /src/charts/ringplotbase.h: -------------------------------------------------------------------------------- 1 | #ifndef RINGPLOTBASE_H 2 | #define RINGPLOTBASE_H 3 | 4 | 5 | #include "plotterbase.h" 6 | 7 | 8 | namespace QSint 9 | { 10 | 11 | 12 | class RingPlotBase : public PlotterBase 13 | { 14 | public: 15 | RingPlotBase(QWidget *parent = 0); 16 | 17 | /// Sets margins between the widget borders and piechart to \a margin (default is 3). 18 | void setMargin(int margin); 19 | /// Retrieves current value of the margins between the widget borders and piechart. 20 | inline int margin() const { return m_margin; } 21 | 22 | /// Enables/disables showing of negative values. 23 | /// \since 0.3 24 | void enableNegatives(bool on = true); 25 | /// Checks if negative values allowed (see enableNegatives()). 26 | /// \since 0.3 27 | inline bool negativesAllowed() const { return m_showNegatives; } 28 | 29 | /// Defines relative size of the inner cutout (0 - disabled, 1 - 100% of size). 30 | /// \since 0.4 31 | void setCutoutPercentage(float cutout); 32 | /// Returns relative size of the inner cutout (0 - disabled, 1 - 100% of size). 33 | /// \since 0.4 34 | inline float cutoutPercentage() const { return m_cutout; } 35 | 36 | /// Custom widget to be displayed in the middle (only if inner cutout > 0, see setCutoutPercentage()). 37 | /// If \a centralWidget is not NULL, the plot will be set to its parent automatically. 38 | /// \since 0.4 39 | void setCentralWidget(QWidget *centralWidget); 40 | /// Returns custom widget displayed in the middle (see setCentralWidget()). 41 | /// \since 0.4 42 | inline QWidget* centralWidget() { return m_centralWidget; } 43 | 44 | protected: 45 | // override: PlotterBase 46 | virtual void drawContent(QPainter &p); 47 | 48 | virtual void drawData(QPainter &p, int innerRadius, int outerRadius, const QRect& pieRect) = 0; 49 | 50 | virtual void drawRing(QPainter &p, const QPoint ¢er, int ring, int radius1, int radius2, bool checkHighlight, double mouseAngle); 51 | 52 | virtual void drawSegment(QPainter &p, const QRect& pieRect, 53 | const QModelIndex &index, double value, 54 | double angle1, double angle2, 55 | bool isHighlighted) = 0; 56 | 57 | /** Draws value of the segment using QPainter \a p. 58 | Value is to be drawn in the rectangle \a pieRect. 59 | Current model index of the segment in \a index, current value is \a value. 60 | \a angle1 and \a angle2 are start and end angles of the segment (in degrees). 61 | \a isHighlighted is true when the segment is highlighted. 62 | */ 63 | virtual void drawValue(QPainter &p, const QRect& pieRect, 64 | const QModelIndex &index, double value, 65 | double angle1, double angle2, 66 | bool isHighlighted); 67 | 68 | virtual void drawCutout(QPainter &p, const QRect &cutRect); 69 | 70 | protected: 71 | bool m_showNegatives = false; 72 | int m_margin = 3; 73 | 74 | float m_cutout = 0; 75 | QWidget *m_centralWidget = nullptr; 76 | 77 | struct HoverData { 78 | double angleHl1 = 0.0, angleHl2 = 0.0, valueHl = 0.0; 79 | QRect segmentRect; 80 | } hoverData; 81 | }; 82 | 83 | 84 | } 85 | 86 | #endif // RINGPLOTBASE_H 87 | -------------------------------------------------------------------------------- /src/charts/stackedbarpainter.cpp: -------------------------------------------------------------------------------- 1 | #include "stackedbarpainter.h" 2 | #include "axisbase.h" 3 | #include "barchartplotter.h" 4 | 5 | 6 | namespace QSint 7 | { 8 | 9 | 10 | QModelIndex StackedBarPainter::draw( 11 | BarChartPlotter *plotter, 12 | const QPoint& mousePosition, 13 | QPainter &p, 14 | int count, 15 | int row_count, 16 | int p_start, 17 | int p_offs, 18 | int bar_size) const 19 | { 20 | bool isUnderMouse = false; 21 | double valueHl = 0.0; 22 | QModelIndex indexHl; 23 | QRect rectHl; 24 | 25 | for (int i = 0; i < count; i++) 26 | { 27 | int p_d = p_start + p_offs*i + (p_offs-bar_size)/2; 28 | 29 | double acc_value = 0; 30 | int p_y = plotter->axisY()->toView(0); 31 | 32 | double neg_value = 0; 33 | int p_ny = p_y; 34 | 35 | p.setOpacity(plotter->barOpacity()); 36 | 37 | for (int j = 0; j < row_count; j++) 38 | { 39 | QRect itemRect; 40 | 41 | const QModelIndex index(plotter->model()->index(j, i)); 42 | double value = index.data(Qt::EditRole).toDouble(); 43 | if (value < 0) 44 | { 45 | neg_value += value; 46 | 47 | int p_h = plotter->axisY()->toView(neg_value); 48 | 49 | itemRect = QRect(p_d, p_ny, bar_size, p_h-p_ny); 50 | 51 | p_ny = p_h; 52 | } 53 | else 54 | { 55 | acc_value += value; 56 | 57 | int p_h = plotter->axisY()->toView(acc_value); 58 | 59 | itemRect = QRect(p_d, p_h, bar_size, p_y-p_h); 60 | 61 | p_y = p_h; 62 | } 63 | 64 | // check for highlight 65 | if (!isUnderMouse && !mousePosition.isNull() && itemRect.contains(mousePosition)) 66 | { 67 | isUnderMouse = true; 68 | valueHl = value; 69 | indexHl = index; 70 | rectHl = itemRect; 71 | } 72 | 73 | // do not draw if highlighted 74 | if (plotter->isHighlightEnabled() && index == indexHl) 75 | continue; 76 | 77 | drawSegment(plotter, p, itemRect, index, value, false); 78 | drawValue(plotter, p, itemRect, index, value, false); 79 | } 80 | } 81 | 82 | if (isUnderMouse) 83 | { 84 | if (plotter->isHighlightEnabled()) 85 | { 86 | drawSegment(plotter, p, rectHl, indexHl, valueHl, true); 87 | drawValue(plotter, p, rectHl, indexHl, valueHl, true); 88 | } 89 | 90 | // item under mouse found 91 | return indexHl; 92 | } 93 | 94 | // no item under mouse 95 | return QModelIndex(); 96 | } 97 | 98 | 99 | void StackedBarPainter::drawValue( 100 | BarChartPlotter *plotter, 101 | QPainter &p, 102 | QRect rect, 103 | const QModelIndex &index, 104 | double value, 105 | bool isHighlighted) const 106 | { 107 | int flags = Qt::AlignCenter; 108 | 109 | QString text = plotter->formattedValue(value, index); 110 | 111 | QRect textRect(p.fontMetrics().boundingRect(text)); 112 | 113 | if (textRect.height() > rect.height() || textRect.width() > rect.width()) 114 | { 115 | if (isHighlighted) 116 | { 117 | QRect frameRect = drawHighlightedValueFrame(plotter, p, rect, textRect); 118 | drawValueText(plotter, p, frameRect, flags, true, index, text); 119 | } 120 | } 121 | else if (plotter->valuesAlwaysShown() || isHighlighted) 122 | { 123 | drawValueText(plotter, p, rect, flags, isHighlighted, index, text); 124 | } 125 | } 126 | 127 | 128 | } 129 | 130 | -------------------------------------------------------------------------------- /src/charts/stackedbarpainter.h: -------------------------------------------------------------------------------- 1 | #ifndef STACKEDBARPAINTER_H 2 | #define STACKEDBARPAINTER_H 3 | 4 | #include "barpainter.h" 5 | 6 | 7 | namespace QSint 8 | { 9 | 10 | 11 | /** 12 | * @brief The StackedBarPainter class implemenents default BarChartPlotter::Stacked plot representation. 13 | * \since 0.3 14 | */ 15 | class StackedBarPainter : public BarPainter 16 | { 17 | public: 18 | virtual QModelIndex draw( 19 | BarChartPlotter *plotter, 20 | const QPoint& mousePosition, 21 | QPainter &p, 22 | int count, 23 | int row_count, 24 | int p_start, 25 | int p_offs, 26 | int bar_size) const; 27 | 28 | virtual void drawValue( 29 | BarChartPlotter *plotter, 30 | QPainter &p, 31 | QRect rect, 32 | const QModelIndex &index, 33 | double value, 34 | bool isHighlighted) const; 35 | }; 36 | 37 | 38 | } 39 | 40 | #endif // STACKEDBARPAINTER_H 41 | -------------------------------------------------------------------------------- /src/charts/trendpainter.h: -------------------------------------------------------------------------------- 1 | #ifndef TRENDPAINTER_H 2 | #define TRENDPAINTER_H 3 | 4 | #include "barpainter.h" 5 | 6 | 7 | namespace QSint 8 | { 9 | 10 | 11 | /** 12 | * @brief The TrendPainter class implemenents default BarChartPlotter::Trend plot representation. 13 | * \since 0.3 14 | */ 15 | class TrendPainter : public BarPainter 16 | { 17 | public: 18 | virtual QModelIndex draw( 19 | BarChartPlotter *plotter, 20 | const QPoint& mousePosition, 21 | QPainter &p, 22 | int count, 23 | int row_count, 24 | int p_start, 25 | int p_offs, 26 | int bar_size) const; 27 | 28 | virtual void drawValue( 29 | BarChartPlotter *plotter, 30 | QPainter &p, 31 | QRect rect, 32 | const QModelIndex &index, 33 | double value, 34 | bool isHighlighted) const; 35 | 36 | protected: 37 | virtual void drawSegment( 38 | BarChartPlotter *plotter, 39 | QPainter &p, 40 | QRect rect, 41 | const QModelIndex &index, 42 | double value, 43 | bool isHighlighted) const; 44 | }; 45 | 46 | 47 | } 48 | 49 | #endif // TRENDPAINTER_H 50 | -------------------------------------------------------------------------------- /src/src.pro: -------------------------------------------------------------------------------- 1 | TARGET = qsint 2 | 3 | TEMPLATE = lib 4 | CONFIG += staticlib c++11 5 | 6 | win32-msvc*{ 7 | QMAKE_CXXFLAGS += /MP 8 | QMAKE_CXXFLAGS += /Zi 9 | QMAKE_CXXFLAGS += /Gy 10 | QMAKE_CXXFLAGS += /FS 11 | } 12 | 13 | QT += core gui widgets 14 | 15 | DESTDIR = ../lib 16 | 17 | include(actions/actions.pri) 18 | include(widgets/widgets.pri) 19 | include(charts/charts.pri) 20 | -------------------------------------------------------------------------------- /src/widgets/colorbutton.h: -------------------------------------------------------------------------------- 1 | #ifndef COLORBUTTON_H 2 | #define COLORBUTTON_H 3 | 4 | #include "colordefs.h" 5 | 6 | #include 7 | #include 8 | 9 | 10 | namespace QSint 11 | { 12 | 13 | 14 | class ColorGrid; 15 | class ColorPopup; 16 | 17 | /** 18 | \brief A tool button to select a color from color dialog or grid. 19 | 20 | \image html ColorButton.png An example of ColorButton 21 | 22 | ColorButton is an extension of QToolButton designed to allow the user 23 | interactively choose a color from popping up dialog window. 24 | 25 | Depending on PickMode, different kinds of color dialogs will be shown when 26 | user clicks left or right mouse button over the ColorButton (see setPickModeLeft() 27 | and setPickModeRight() functions). 28 | 29 | You can modify the outlook of ColorButton by changing appropriate QToolButton 30 | properties. For instance, show text along with color box (ToolButtonStyle property), 31 | or show drop-down menu arrow (PopupMode property). 32 | 33 | \image html ColorButtons.png Different types of ColorButton 34 | */ 35 | class ColorButton : public QToolButton 36 | { 37 | Q_OBJECT 38 | 39 | Q_PROPERTY(int cellSize READ cellSize WRITE setCellSize) 40 | Q_PROPERTY(QColor color READ color WRITE setColor) 41 | Q_PROPERTY(PickMode pickMode READ pickMode WRITE setPickMode) 42 | 43 | public: 44 | /// \brief Defines color dialog type. 45 | enum PickMode 46 | { 47 | /// no dialog 48 | PM_NONE, 49 | /// standard system color dialog 50 | PM_COLORDIALOG, 51 | /// color grid based dialog 52 | PM_COLORGRID, 53 | /// color grid with standard color selector 54 | PM_COLORGRID_DIALOG 55 | }; 56 | 57 | enum TextMode 58 | { 59 | TM_NONE, 60 | TM_NAMED_COLOR, 61 | TM_HEX_COLOR, 62 | TM_NAMED_HEX_COLOR 63 | }; 64 | 65 | /** Constructor. 66 | */ 67 | ColorButton(QWidget *parent = 0); 68 | /** Destructor. 69 | */ 70 | virtual ~ColorButton(); 71 | 72 | /** Returns currently selected color. 73 | */ 74 | inline QColor color() const { return m_color; } 75 | 76 | /** Returns type of color dialog shown on left mouse click (PM_COLORGRID by default). 77 | \sa setPickMode() 78 | */ 79 | inline PickMode pickMode() const { return m_mode; } 80 | /** Sets type of color dialog shown on left mouse click to \a mode. 81 | */ 82 | void setPickMode(PickMode mode); 83 | 84 | /** Returns currently active color scheme (by default, defaultColors() is used). 85 | \sa setColorScheme() 86 | */ 87 | inline const NamedColorsScheme& colorScheme() const { return *m_colorScheme; } 88 | /** Sets color scheme to \a scheme. 89 | */ 90 | void setColorScheme(const NamedColorsScheme &scheme); 91 | 92 | /** Returns size of a color cell in pixels. 93 | */ 94 | int cellSize() const; 95 | /** Sets size of a color cell in pixels to \a size (must be > 0). 96 | */ 97 | void setCellSize(int size); 98 | 99 | void setTooltipMode(TextMode tm); 100 | 101 | void setLabelMode(TextMode tm); 102 | 103 | /** If \a on is true, it makes possible to select an empty (invalid) color from the drop-down menu. 104 | */ 105 | void enableNoColor(bool on); 106 | 107 | public Q_SLOTS: 108 | /** Sets current color to \a color. 109 | */ 110 | void setColor(const QColor& color); 111 | 112 | protected Q_SLOTS: 113 | void onNoColorButton(); 114 | void onDialogButton(); 115 | void onClicked(); 116 | 117 | Q_SIGNALS: 118 | /** Emitted when user selects a color from the dialog. 119 | 120 | \a color is the picked color value. 121 | */ 122 | void colorChanged(const QColor &color); 123 | 124 | void activated(const QColor &color); 125 | 126 | protected: 127 | virtual void drawColorItem(QPixmap &pm, const QColor& color); 128 | virtual QString getColorName(TextMode tm, const QColor& color) const; 129 | 130 | virtual void resizeEvent(QResizeEvent *event); 131 | 132 | QColor m_color; 133 | QString m_buttonText; 134 | PickMode m_mode; 135 | TextMode m_tooltipMode, m_labelMode; 136 | 137 | ColorGrid *m_grid; 138 | QWidgetAction *m_colorGridAction; 139 | QAction *m_colorDialogAction; 140 | QAction *m_noColorAction; 141 | 142 | const NamedColorsScheme *m_colorScheme; 143 | }; 144 | 145 | 146 | } // namespace 147 | 148 | #endif // COLORBUTTON_H 149 | -------------------------------------------------------------------------------- /src/widgets/colorcombobox.h: -------------------------------------------------------------------------------- 1 | #ifndef QCOLORCOMBOBOX_H 2 | #define QCOLORCOMBOBOX_H 3 | 4 | #include 5 | 6 | #include "colordefs.h" 7 | 8 | 9 | namespace QSint 10 | { 11 | 12 | 13 | class ColorComboBox : public QComboBox 14 | { 15 | Q_OBJECT 16 | public: 17 | explicit ColorComboBox(QWidget *parent = 0); 18 | 19 | /** Sets active color list to \a colorNames. 20 | * The names are shown in the way how they are stored in the \a colorNames. 21 | */ 22 | void setColors(const QStringList& colorNames); 23 | 24 | /** Sets active color list to \a colors. 25 | * The names are shown in the QColor::name() format, i.e. "#RRGGBB" 26 | */ 27 | void setColors(const ColorList& colors); 28 | 29 | /** Returns current color (selected or written). 30 | */ 31 | QColor currentColor() const; 32 | 33 | void allowListColorsOnly(bool on); 34 | 35 | bool isListColorsOnly() const 36 | { return m_listOnly; } 37 | 38 | virtual void setEditable(bool editable); 39 | 40 | QString colorName(const QColor& color) const; 41 | 42 | static QIcon colorIcon(const QColor& color, int size = 14); 43 | 44 | Q_SIGNALS: 45 | /** Emitted when current color has been changed to \a color. 46 | */ 47 | void currentColorChanged(const QColor& color); 48 | 49 | public Q_SLOTS: 50 | /** Sets current color to \a color (same as setCurrentColor()). 51 | */ 52 | void setColor(const QColor& color) 53 | { setCurrentColor(color); } 54 | 55 | /** Sets current color to \a color. 56 | */ 57 | void setCurrentColor(const QColor& color); 58 | 59 | protected Q_SLOTS: 60 | void onCurrentIndexChanged(int index); 61 | void onEdited(); 62 | void onSelectionTextChanged(); 63 | 64 | private: 65 | bool m_listOnly; 66 | }; 67 | 68 | 69 | } 70 | 71 | #endif // QCOLORCOMBOBOX_H 72 | -------------------------------------------------------------------------------- /src/widgets/colordefs.h: -------------------------------------------------------------------------------- 1 | #ifndef COLORDEFS_H 2 | #define COLORDEFS_H 3 | 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | 11 | namespace QSint 12 | { 13 | 14 | 15 | /** This type defines a list of QColor to be used in \a setScheme() functions. 16 | */ 17 | typedef QList ColorList; 18 | 19 | /** Returns default color scheme. 20 | \sa setScheme() 21 | */ 22 | ColorList* defaultColors(); 23 | /** Returns second default color scheme. 24 | \sa setScheme() 25 | */ 26 | ColorList* defaultColors2(); 27 | /** Returns default color scheme based on 16 base colors. 28 | \sa setScheme() 29 | */ 30 | ColorList* baseColors(); 31 | /** Returns default color scheme based on QColor::colorNames() list. 32 | \sa setScheme() 33 | */ 34 | ColorList* namedColors(); 35 | 36 | ColorList* openOfficeColors(); 37 | 38 | 39 | 40 | struct NamedColorsScheme 41 | { 42 | ColorList colors; 43 | QMap colorNames; 44 | int gridWidth; 45 | 46 | void addNamedColor(const QColor& color, const QString& name); 47 | QString colorName(const QColor& color) const; 48 | }; 49 | 50 | const NamedColorsScheme& BaseColors(); 51 | 52 | const NamedColorsScheme& SvgColors(); 53 | 54 | const NamedColorsScheme& OpenOfficeColors(); 55 | 56 | } 57 | 58 | 59 | #endif // COLORDEFS_H 60 | -------------------------------------------------------------------------------- /src/widgets/dial.cpp: -------------------------------------------------------------------------------- 1 | #include "dial.h" 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | 8 | namespace QSint 9 | { 10 | 11 | 12 | Dial::Dial(QWidget *parent) : QDial(parent) 13 | { 14 | connect(this, &QDial::valueChanged, this, &Dial::updateLabel); 15 | 16 | updateLabel(); 17 | 18 | update(); 19 | } 20 | 21 | 22 | void Dial::setValue(int v) 23 | { 24 | QDial::setValue(v); 25 | 26 | update(); 27 | } 28 | 29 | 30 | void Dial::setSuffixText(const QString &suffix) 31 | { 32 | m_suffix = suffix; 33 | 34 | update(); 35 | } 36 | 37 | 38 | void Dial::setLabelText(const QString &text) 39 | { 40 | m_text = text; 41 | 42 | update(); 43 | } 44 | 45 | 46 | void Dial::paintEvent(QPaintEvent *pe) 47 | { 48 | QDial::paintEvent(pe); 49 | 50 | updateLabel(); 51 | 52 | QPainter p(this); 53 | 54 | p.drawText(rect(), Qt::AlignCenter, m_valueText); 55 | } 56 | 57 | 58 | void Dial::mousePressEvent(QMouseEvent *e) 59 | { 60 | if (e->button() == Qt::RightButton) 61 | { 62 | Q_EMIT rightClicked(); 63 | } 64 | } 65 | 66 | 67 | void Dial::updateLabel() 68 | { 69 | if (m_text.size()) 70 | { 71 | m_valueText = m_text; 72 | update(); 73 | return; 74 | } 75 | 76 | m_valueText = QString::number(value()); 77 | 78 | if (m_suffix.size()) 79 | { 80 | m_valueText += m_suffix; 81 | } 82 | else 83 | { 84 | QString suffix = property("Suffix").toString(); 85 | if (suffix.size()) 86 | m_valueText += suffix; 87 | } 88 | } 89 | 90 | 91 | } -------------------------------------------------------------------------------- /src/widgets/dial.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | 7 | namespace QSint 8 | { 9 | 10 | 11 | /** 12 | \brief Extended QDial widget with additional value label in the middle. 13 | \since 0.4 14 | 15 | \image html Dial.png An example of Dial widget 16 | */ 17 | class Dial : public QDial 18 | { 19 | Q_OBJECT 20 | 21 | public: 22 | Dial(QWidget *parent = nullptr); 23 | 24 | void setLabelText(const QString &text); 25 | void setSuffixText(const QString &suffix); 26 | 27 | virtual void setValue(int v); 28 | 29 | Q_SIGNALS: 30 | void rightClicked(); 31 | 32 | protected: 33 | virtual void paintEvent(QPaintEvent *pe); 34 | virtual void mousePressEvent(QMouseEvent *e); 35 | 36 | private Q_SLOTS: 37 | void updateLabel(); 38 | 39 | private: 40 | QString m_text; 41 | QString m_valueText; 42 | QString m_suffix; 43 | }; 44 | 45 | 46 | } 47 | -------------------------------------------------------------------------------- /src/widgets/doublespincombobox.cpp: -------------------------------------------------------------------------------- 1 | #include "doublespincombobox.h" 2 | 3 | 4 | namespace QSint 5 | { 6 | 7 | 8 | DoubleSpinComboBox::DoubleSpinComboBox(QWidget *parent) : 9 | QDoubleSpinBox(parent) 10 | { 11 | m_button = new QToolButton(this); 12 | m_button->setFixedWidth(16); 13 | m_button->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred); 14 | m_button->setPopupMode(QToolButton::InstantPopup); 15 | m_button->setVisible(false); 16 | 17 | connect(m_button, SIGNAL(triggered(QAction*)), this, SLOT(onAction(QAction*))); 18 | 19 | QHBoxLayout *mainLayout = new QHBoxLayout(this); 20 | mainLayout->setContentsMargins(0, 0, 0, 0); 21 | mainLayout->setSpacing(0); 22 | setLayout(mainLayout); 23 | 24 | mainLayout->addStretch(); 25 | mainLayout->addWidget(m_button); 26 | } 27 | 28 | 29 | void DoubleSpinComboBox::setValueList(const QList &values) 30 | { 31 | m_button->setVisible(!values.isEmpty()); 32 | if (values.isEmpty()) 33 | return; 34 | 35 | QMenu *m = new QMenu(this); 36 | for (double i : values) 37 | { 38 | QAction *a = m->addAction(QString::number(i)); 39 | a->setData(i); 40 | } 41 | 42 | m_button->setMenu(m); 43 | } 44 | 45 | 46 | // protected members 47 | 48 | void DoubleSpinComboBox::resizeEvent(QResizeEvent *event) 49 | { 50 | QDoubleSpinBox::resizeEvent(event); 51 | 52 | int arrowSize = m_button->width(); 53 | 54 | layout()->setContentsMargins(1, 1, arrowSize - 1, 1); 55 | } 56 | 57 | 58 | void DoubleSpinComboBox::onAction(QAction* act) 59 | { 60 | double v = act->data().toDouble(); 61 | 62 | setValue(v); 63 | } 64 | 65 | 66 | } // namespace 67 | -------------------------------------------------------------------------------- /src/widgets/doublespincombobox.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | 12 | namespace QSint 13 | { 14 | 15 | 16 | /** 17 | \brief Double spin editor with additional drop down menu. 18 | \since 0.4 19 | 20 | \image html DoubleSpinComboBox.png An example of DoubleSpinComboBox 21 | */ 22 | class DoubleSpinComboBox : public QDoubleSpinBox 23 | { 24 | Q_OBJECT 25 | 26 | public: 27 | /** Constructor. 28 | */ 29 | explicit DoubleSpinComboBox(QWidget *parent = 0); 30 | 31 | void setValueList(const QList &values); 32 | 33 | Q_SIGNALS: 34 | 35 | protected Q_SLOTS: 36 | void onAction(QAction* action); 37 | 38 | protected: 39 | virtual void resizeEvent(QResizeEvent* event); 40 | 41 | QToolButton *m_button; 42 | }; 43 | 44 | 45 | } // namespace 46 | -------------------------------------------------------------------------------- /src/widgets/ledwidget.cpp: -------------------------------------------------------------------------------- 1 | #include "ledwidget.h" 2 | 3 | #include 4 | 5 | 6 | namespace QSint 7 | { 8 | 9 | 10 | LedWidget::LedWidget(QWidget *parent) : 11 | QWidget(parent) 12 | { 13 | setColor(Qt::gray); 14 | } 15 | 16 | 17 | void LedWidget::setColor(const QColor &ledColor) 18 | { 19 | m_gradient.setColorAt(0.0, Qt::white); 20 | m_gradient.setColorAt(1.0, ledColor); 21 | } 22 | 23 | 24 | void LedWidget::setColors(const QColor &ledColor, const QColor &highlightColor) 25 | { 26 | m_gradient.setColorAt(0.0, highlightColor); 27 | m_gradient.setColorAt(1.0, ledColor); 28 | } 29 | 30 | 31 | void LedWidget::paintEvent(QPaintEvent * /*event*/) 32 | { 33 | QPainter p(this); 34 | 35 | p.setPen(QPen(Qt::black)); 36 | p.setRenderHint(QPainter::Antialiasing); 37 | 38 | int radius = qMin(rect().width(), rect().height()) / 2 - 2; 39 | 40 | m_gradient.setCenter(rect().center()); 41 | m_gradient.setFocalPoint(rect().center() - QPoint(radius / 2, radius / 2)); 42 | m_gradient.setRadius(radius); 43 | 44 | p.setBrush(m_gradient); 45 | 46 | p.drawEllipse(rect().center(), radius, radius); 47 | } 48 | 49 | 50 | } 51 | 52 | -------------------------------------------------------------------------------- /src/widgets/ledwidget.h: -------------------------------------------------------------------------------- 1 | #ifndef LEDWIDGET_H 2 | #define LEDWIDGET_H 3 | 4 | #include 5 | 6 | 7 | namespace QSint 8 | { 9 | 10 | 11 | /** 12 | \brief Round LED-style widget with gradient fill. 13 | 14 | The gradient consists of two colors: led color (main color of the widget) 15 | and highlight color at the top-left corner (typically, white). 16 | 17 | \since 0.2.2 18 | 19 | \image html LedWidget.png An example of LedWidget 20 | */ 21 | class LedWidget : public QWidget 22 | { 23 | Q_OBJECT 24 | public: 25 | explicit LedWidget(QWidget *parent = 0); 26 | 27 | virtual QSize minimumSizeHint() const 28 | { return QSize(12,12); } 29 | 30 | virtual int heightForWidth(int w) const 31 | { return w; } 32 | 33 | public Q_SLOTS: 34 | /** 35 | * @brief setColor Funtion sets color of LED to \a ledColor. Highlight color is set to Qt::white. 36 | * @param ledColor Color to set (Qt::gray is the default value). 37 | */ 38 | void setColor(const QColor &ledColor); 39 | /** 40 | * @brief setColors Funtion sets color of LED to \a ledColor and its highlight color to \a blickColor. 41 | * @param ledColor (Qt::gray is the default value). 42 | * @param highlightColor (Qt::white is the default value). 43 | */ 44 | void setColors(const QColor &ledColor, const QColor &highlightColor); 45 | 46 | protected: 47 | virtual void paintEvent(QPaintEvent *event); 48 | 49 | QRadialGradient m_gradient; 50 | }; 51 | 52 | 53 | } 54 | 55 | 56 | #endif // LEDWIDGET_H 57 | -------------------------------------------------------------------------------- /src/widgets/qfontbutton.cpp: -------------------------------------------------------------------------------- 1 | #include "qfontbutton.h" 2 | 3 | 4 | namespace QSint 5 | { 6 | 7 | 8 | QString QFontButton::fontToText(const QFont& font) 9 | { 10 | QString result(font.family()); 11 | 12 | if (font.pointSizeF() > 0) 13 | result += QString(",%1pt").arg(font.pointSizeF()); 14 | else 15 | result += QString(",%1px").arg(font.pixelSize()); 16 | 17 | if (font.bold()) result += ",Bold"; 18 | if (font.italic()) result += ",Italic"; 19 | if (font.underline()) result += ",Underline"; 20 | 21 | return result; 22 | } 23 | 24 | 25 | QFontButton::QFontButton(QWidget *parent) : QToolButton(parent) 26 | { 27 | setToolButtonStyle(Qt::ToolButtonTextOnly); 28 | setPopupMode(QToolButton::MenuButtonPopup); 29 | 30 | setText("Aa"); 31 | setCurrentFont(QFont()); 32 | 33 | connect(this, SIGNAL(clicked()), this, SLOT(onClicked())); 34 | 35 | m_fontDialog = new QFontDialog(this); 36 | m_fontDialog->setOption(QFontDialog::DontUseNativeDialog, false); 37 | m_fontDialog->setSizeGripEnabled(false); 38 | 39 | QMenu *menu = new QMenu(this); 40 | setMenu(menu); 41 | 42 | QWidgetAction *dialogAction = new QWidgetAction(this); 43 | dialogAction->setDefaultWidget(m_fontDialog); 44 | menu->addAction(dialogAction); 45 | 46 | connect(menu, SIGNAL(aboutToShow()), this, SLOT(onDialogShown())); 47 | connect(m_fontDialog, SIGNAL(accepted()), menu, SLOT(hide())); 48 | connect(m_fontDialog, SIGNAL(rejected()), menu, SLOT(hide())); 49 | connect(m_fontDialog, SIGNAL(fontSelected(const QFont&)), this, SLOT(onDialogFontSelected(const QFont&))); 50 | } 51 | 52 | 53 | void QFontButton::setCurrentFont(const QFont &font) 54 | { 55 | m_font = font; 56 | 57 | setToolTip(fontToText(font)); 58 | 59 | if (m_font.pixelSize() > 20 || m_font.pointSize() > 20) 60 | { 61 | QFont f(font); 62 | f.setPointSize(20); 63 | setFont(f); 64 | } 65 | else 66 | setFont(m_font); 67 | } 68 | 69 | 70 | void QFontButton::onClicked() 71 | { 72 | Q_EMIT activated(m_font); 73 | } 74 | 75 | 76 | void QFontButton::onDialogShown() 77 | { 78 | m_fontDialog->setCurrentFont(m_font); 79 | 80 | m_fontDialog->setVisible(true); 81 | } 82 | 83 | 84 | void QFontButton::onDialogFontSelected(const QFont &font) 85 | { 86 | setCurrentFont(font); 87 | 88 | onClicked(); 89 | } 90 | 91 | 92 | } 93 | -------------------------------------------------------------------------------- /src/widgets/qfontbutton.h: -------------------------------------------------------------------------------- 1 | #ifndef QFONTBUTTON_H 2 | #define QFONTBUTTON_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | 10 | namespace QSint 11 | { 12 | 13 | 14 | class QFontButton : public QToolButton 15 | { 16 | Q_OBJECT 17 | 18 | public: 19 | QFontButton(QWidget *parent = Q_NULLPTR); 20 | 21 | const QFont& currentFont() const { return m_font; } 22 | 23 | static QString fontToText(const QFont& font); 24 | 25 | public Q_SLOTS: 26 | void setCurrentFont(const QFont &font); 27 | 28 | Q_SIGNALS: 29 | void activated(const QFont &font); 30 | 31 | private Q_SLOTS: 32 | void onClicked(); 33 | void onDialogShown(); 34 | void onDialogFontSelected(const QFont&); 35 | 36 | private: 37 | QFontDialog *m_fontDialog; 38 | QFont m_font; 39 | }; 40 | 41 | 42 | } 43 | 44 | #endif // QFONTBUTTON_H 45 | -------------------------------------------------------------------------------- /src/widgets/qmenubutton.cpp: -------------------------------------------------------------------------------- 1 | #include "qmenubutton.h" 2 | 3 | #include 4 | #include 5 | 6 | 7 | namespace QSint 8 | { 9 | 10 | 11 | QMenuButton::QMenuButton(QWidget *parent) : QToolButton(parent) 12 | { 13 | connect(this, SIGNAL(triggered(QAction*)), this, SLOT(onAction(QAction*))); 14 | 15 | setMenu(m_localMenu = new QMenu()); 16 | } 17 | 18 | 19 | QAction* QMenuButton::addAction(const QString &text, const QVariant &v) 20 | { 21 | QAction* act = new QAction(text, parent()); 22 | act->setData(v); 23 | 24 | m_localMenu->addAction(act); 25 | 26 | if (m_localMenu->actions().count() == 1) 27 | setDefaultAction(act); 28 | 29 | return act; 30 | } 31 | 32 | 33 | QAction* QMenuButton::addAction(const QIcon &icon, const QString &text, const QVariant &v) 34 | { 35 | QAction* act = addAction(text, v); 36 | act->setIcon(icon); 37 | return act; 38 | } 39 | 40 | 41 | QAction* QMenuButton::selectAction(const QVariant &data) 42 | { 43 | for (auto act: m_localMenu->actions()) 44 | { 45 | if (act->data() == data && act->isEnabled() && act->isVisible()) 46 | { 47 | setDefaultAction(act); 48 | return act; 49 | } 50 | } 51 | 52 | // not found 53 | return NULL; 54 | } 55 | 56 | 57 | QAction *QMenuButton::selectActionByIndex(int index) 58 | { 59 | if (index >= 0 && index < m_localMenu->actions().count()) 60 | { 61 | auto act = m_localMenu->actions()[index]; 62 | 63 | if (act->isEnabled() && act->isVisible()) 64 | { 65 | setDefaultAction(act); 66 | return act; 67 | } 68 | } 69 | 70 | // not found 71 | return NULL; 72 | } 73 | 74 | 75 | void QMenuButton::actionEvent(QActionEvent *event) 76 | { 77 | QToolButton::actionEvent(event); 78 | 79 | // set default action 80 | if (defaultAction() == NULL) 81 | { 82 | for (auto act: m_localMenu->actions()) 83 | { 84 | if (act->isEnabled() && act->isVisible()) 85 | { 86 | setDefaultAction(act); 87 | return; 88 | } 89 | } 90 | } 91 | } 92 | 93 | 94 | void QMenuButton::onAction(QAction* act) 95 | { 96 | setDefaultAction(act); 97 | 98 | if (act) 99 | Q_EMIT activated(act->data()); 100 | } 101 | 102 | 103 | void QMenuButton::setDefaultAction(QAction* act) 104 | { 105 | if (act != defaultAction()) 106 | { 107 | // prevent status tip 108 | QString oldStatusTip = statusTip(); 109 | 110 | QToolButton::setDefaultAction(act); 111 | m_localMenu->setDefaultAction(act); 112 | 113 | if (statusTip().isEmpty()) 114 | setStatusTip(oldStatusTip); 115 | } 116 | } 117 | 118 | 119 | } 120 | -------------------------------------------------------------------------------- /src/widgets/qmenubutton.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | 9 | namespace QSint 10 | { 11 | 12 | 13 | class QMenuButton : public QToolButton 14 | { 15 | Q_OBJECT 16 | 17 | public: 18 | QMenuButton(QWidget *parent = Q_NULLPTR); 19 | 20 | QAction* addAction(const QString &text, const QVariant &data = QVariant()); 21 | QAction* addAction(const QIcon &icon, const QString &text, const QVariant &data = QVariant()); 22 | 23 | void setDefaultAction(QAction* act); 24 | 25 | public Q_SLOTS: 26 | QAction* selectAction(const QVariant &data); 27 | QAction* selectActionByIndex(int index); 28 | 29 | Q_SIGNALS: 30 | void activated(QVariant data); 31 | 32 | protected Q_SLOTS: 33 | virtual void onAction(QAction* act); 34 | 35 | protected: 36 | virtual void actionEvent(QActionEvent *event); 37 | 38 | QMenu *m_localMenu; 39 | }; 40 | 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/widgets/qpenbutton.cpp: -------------------------------------------------------------------------------- 1 | #include "qpenbutton.h" 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | 8 | namespace QSint 9 | { 10 | 11 | 12 | QPenButton::QPenButton(QWidget *parent) : QMenuButton(parent) 13 | { 14 | init(); 15 | 16 | setUsedRange(Qt::NoPen, Qt::DashDotDotLine); 17 | setPenStyle(Qt::SolidLine); 18 | } 19 | 20 | 21 | QPixmap QPenButton::drawPixmap(Qt::PenStyle style, int width, QSize size) 22 | { 23 | QPen pen; 24 | pen.setWidth(width); 25 | pen.setStyle(style); 26 | 27 | QPixmap pixmap(size); 28 | pixmap.fill(QColor(Qt::transparent)); 29 | 30 | QPainter painter(&pixmap); 31 | painter.setPen(pen); 32 | painter.drawLine(0, int(pixmap.height() / 2.), pixmap.width(), int(pixmap.height() / 2.)); 33 | 34 | return pixmap; 35 | } 36 | 37 | 38 | void QPenButton::init() 39 | { 40 | for (int i = Qt::NoPen; i < Qt::CustomDashLine; i++) 41 | { 42 | QPixmap pixmap = drawPixmap(Qt::PenStyle(i), 2, iconSize() * 2); 43 | 44 | switch (i) 45 | { 46 | case Qt::NoPen: addAction(pixmap, tr("None"), i); break; 47 | case Qt::SolidLine: addAction(pixmap, tr("Solid"), i); break; 48 | case Qt::DashLine: addAction(pixmap, tr("Dashed"), i); break; 49 | case Qt::DotLine: addAction(pixmap, tr("Dotted"), i); break; 50 | case Qt::DashDotLine: addAction(pixmap, tr("Dash-Dot"), i); break; 51 | case Qt::DashDotDotLine: addAction(pixmap, tr("Dash-Dot-Dot"), i); break; 52 | default: break; 53 | } 54 | } 55 | } 56 | 57 | 58 | void QPenButton::setUsedRange(Qt::PenStyle start, Qt::PenStyle end) 59 | { 60 | auto list = actions(); 61 | 62 | for (int i = 0; i setVisible(i >= start && i <= end); 65 | } 66 | 67 | selectActionByIndex(start); 68 | } 69 | 70 | 71 | void QPenButton::setPenStyle(Qt::PenStyle style) 72 | { 73 | selectAction((int)style); 74 | } 75 | 76 | 77 | void QPenButton::onAction(QAction* act) 78 | { 79 | QMenuButton::onAction(act); 80 | 81 | int style = act->data().toInt(); 82 | if (style < Qt::NoPen || style >= Qt::CustomDashLine) 83 | style = Qt::NoPen; 84 | 85 | Q_EMIT activated((Qt::PenStyle)style); 86 | } 87 | 88 | 89 | } 90 | 91 | -------------------------------------------------------------------------------- /src/widgets/qpenbutton.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "qmenubutton.h" 4 | 5 | #include 6 | 7 | 8 | namespace QSint 9 | { 10 | 11 | 12 | class QPenButton : public QMenuButton 13 | { 14 | Q_OBJECT 15 | 16 | public: 17 | QPenButton(QWidget *parent = Q_NULLPTR); 18 | 19 | void setUsedRange(Qt::PenStyle start, Qt::PenStyle end); 20 | 21 | static QPixmap drawPixmap(Qt::PenStyle style, int width = 2, QSize size = QSize(24,24)); 22 | 23 | public Q_SLOTS: 24 | void setPenStyle(Qt::PenStyle style); 25 | 26 | Q_SIGNALS: 27 | void activated(Qt::PenStyle style); 28 | 29 | protected Q_SLOTS: 30 | virtual void onAction(QAction* act); 31 | 32 | private: 33 | virtual void init(); 34 | }; 35 | 36 | 37 | } 38 | 39 | -------------------------------------------------------------------------------- /src/widgets/qpencombobox.cpp: -------------------------------------------------------------------------------- 1 | #include "qpencombobox.h" 2 | 3 | #include 4 | #include 5 | 6 | 7 | namespace QSint 8 | { 9 | 10 | 11 | QPenComboBox::QPenComboBox(QWidget *parent) : QComboBox(parent) 12 | { 13 | setEditable(false); 14 | 15 | QPen pen; 16 | pen.setWidth(2); 17 | 18 | for (int i = Qt::SolidLine; i < Qt::CustomDashLine; i++) 19 | { 20 | QPixmap pixmap(24, 24); 21 | pixmap.fill(QColor(Qt::transparent)); 22 | 23 | pen.setStyle(Qt::PenStyle(i)); 24 | 25 | QPainter painter(&pixmap); 26 | painter.setPen(pen); 27 | painter.drawLine(0, int(pixmap.height() / 2.), pixmap.width(), int(pixmap.height() / 2.)); 28 | 29 | switch (i) 30 | { 31 | case Qt::NoPen: addItem(pixmap, tr("None")); break; 32 | case Qt::SolidLine: addItem(pixmap, tr("Solid")); break; 33 | case Qt::DashLine: addItem(pixmap, tr("Dash")); break; 34 | case Qt::DotLine: addItem(pixmap, tr("Dot")); break; 35 | case Qt::DashDotLine: addItem(pixmap, tr("Dash Dot")); break; 36 | case Qt::DashDotDotLine: addItem(pixmap, tr("Dash Dot Dot")); break; 37 | default: addItem(tr("Custom")); break; 38 | } 39 | } 40 | 41 | setCurrentIndex(1); 42 | 43 | setFixedSize(sizeHint()); 44 | } 45 | 46 | 47 | void QPenComboBox::setCurrentStyle(Qt::PenStyle newStyle) 48 | { 49 | setCurrentIndex((int)newStyle); 50 | } 51 | 52 | 53 | Qt::PenStyle QPenComboBox::currentStyle() const 54 | { 55 | return Qt::PenStyle(currentIndex()); 56 | } 57 | 58 | 59 | } 60 | -------------------------------------------------------------------------------- /src/widgets/qpencombobox.h: -------------------------------------------------------------------------------- 1 | #ifndef QPENCOMBOBOX_H 2 | #define QPENCOMBOBOX_H 3 | 4 | #include 5 | #include 6 | 7 | 8 | namespace QSint 9 | { 10 | 11 | 12 | class QPenComboBox: public QComboBox 13 | { 14 | public: 15 | QPenComboBox(QWidget *parent = 0); 16 | 17 | void setCurrentStyle(Qt::PenStyle); 18 | Qt::PenStyle currentStyle() const; 19 | }; 20 | 21 | 22 | } 23 | 24 | #endif // QPENCOMBOBOX_H 25 | -------------------------------------------------------------------------------- /src/widgets/slider.cpp: -------------------------------------------------------------------------------- 1 | #include "slider.h" 2 | 3 | #include 4 | #include 5 | 6 | 7 | namespace QSint 8 | { 9 | 10 | 11 | Slider::Slider(QWidget *parent): QSlider(parent), 12 | m_precise(false), 13 | m_clickJump(false) 14 | { 15 | setPreciseMovement(true); 16 | } 17 | 18 | 19 | void Slider::setPreciseMovement(bool on) 20 | { 21 | if (m_precise != on) 22 | { 23 | m_precise = on; 24 | 25 | if (m_precise) 26 | connect(this, SIGNAL(actionTriggered(int)), this, SLOT(onActionTriggered(int))); 27 | else 28 | disconnect(this); 29 | } 30 | } 31 | 32 | 33 | void Slider::setClickJump(bool on) 34 | { 35 | if (m_clickJump != on) 36 | { 37 | m_clickJump = on; 38 | } 39 | } 40 | 41 | 42 | void Slider::onActionTriggered(int action) 43 | { 44 | if (action == QAbstractSlider::SliderMove) 45 | { 46 | int v = (sliderPosition() / singleStep()) * singleStep(); 47 | setValue(v); 48 | } 49 | else 50 | if (action == QAbstractSlider::SliderPageStepAdd || action == QAbstractSlider::SliderPageStepSub) 51 | { 52 | int v = (sliderPosition() / pageStep()) * pageStep(); 53 | setValue(v); 54 | } 55 | } 56 | 57 | 58 | void Slider::mousePressEvent(QMouseEvent *event) 59 | { 60 | if (m_clickJump) 61 | { 62 | QStyleOptionSlider opt; 63 | initStyleOption(&opt); 64 | QRect sr = style()->subControlRect(QStyle::CC_Slider, &opt, QStyle::SC_SliderHandle, this); 65 | 66 | if (event->button() == Qt::LeftButton && !sr.contains(event->pos())) 67 | { 68 | int v = minimum(); 69 | 70 | if (orientation() == Qt::Vertical) 71 | v += ((maximum()-minimum()) * (height()-event->y())) / height(); 72 | else 73 | v += ((maximum()-minimum()) * event->x()) / width(); 74 | 75 | if (m_precise) 76 | v = (v / singleStep()) * singleStep(); 77 | 78 | if (invertedAppearance()) 79 | v = (maximum() - v + 1); 80 | 81 | setValue(v); 82 | } 83 | } 84 | 85 | QSlider::mousePressEvent(event); 86 | } 87 | 88 | 89 | } 90 | 91 | -------------------------------------------------------------------------------- /src/widgets/slider.h: -------------------------------------------------------------------------------- 1 | #ifndef SLIDER_H 2 | #define SLIDER_H 3 | 4 | #include 5 | 6 | 7 | namespace QSint 8 | { 9 | 10 | 11 | /** 12 | \brief A slider allowing more precise user control by a mouse. 13 | 14 | See: 15 | - setPreciseMovement() 16 | - setClickJump() 17 | 18 | \since 0.3 19 | */ 20 | 21 | class Slider : public QSlider 22 | { 23 | Q_OBJECT 24 | 25 | public: 26 | Slider(QWidget* parent = 0); 27 | 28 | /// \return true if presice movement has been activated. 29 | /// \sa setPreciseMovement() 30 | /// \since 0.3 31 | bool preciseMovementActive() const 32 | { return m_precise; } 33 | 34 | /// \return true if click jump has been activated. 35 | /// \sa setClickJump() 36 | /// \since 0.3 37 | bool clickJumpActive() const 38 | { return m_clickJump; } 39 | 40 | public Q_SLOTS: 41 | /// Activates precise movement of the slider. Its value will be always rounded up according to singleStep() 42 | /// when dragging & scrolling. 43 | /// Clicking on the slider will round up its value according to pageStep(). 44 | /// 45 | /// Enabled by default. 46 | /// \since 0.3 47 | void setPreciseMovement(bool on = true); 48 | 49 | /// When activated, clicking on the slider will move its handle to the click position immediately. 50 | /// 51 | /// Not enabled by default. 52 | /// \since 0.3 53 | void setClickJump(bool on = true); 54 | 55 | protected Q_SLOTS: 56 | void onActionTriggered(int id); 57 | 58 | protected: 59 | virtual void mousePressEvent(QMouseEvent *event); 60 | 61 | private: 62 | bool m_precise; 63 | bool m_clickJump; 64 | }; 65 | 66 | 67 | } 68 | 69 | #endif // SLIDER_H 70 | -------------------------------------------------------------------------------- /src/widgets/spincombobox.cpp: -------------------------------------------------------------------------------- 1 | #include "spincombobox.h" 2 | 3 | 4 | namespace QSint 5 | { 6 | 7 | 8 | SpinComboBox::SpinComboBox(QWidget *parent) : 9 | QSpinBox(parent) 10 | { 11 | m_button = new QToolButton(this); 12 | m_button->setFixedWidth(16); 13 | m_button->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred); 14 | m_button->setPopupMode(QToolButton::InstantPopup); 15 | m_button->setVisible(false); 16 | 17 | connect(m_button, SIGNAL(triggered(QAction*)), this, SLOT(onAction(QAction*))); 18 | 19 | QHBoxLayout *mainLayout = new QHBoxLayout(this); 20 | mainLayout->setContentsMargins(0, 0, 0, 0); 21 | mainLayout->setSpacing(0); 22 | setLayout(mainLayout); 23 | 24 | mainLayout->addStretch(); 25 | mainLayout->addWidget(m_button); 26 | } 27 | 28 | 29 | void SpinComboBox::setValueList(const QList &values) 30 | { 31 | m_button->setVisible(!values.isEmpty()); 32 | if (values.isEmpty()) 33 | return; 34 | 35 | QMenu *m = new QMenu(this); 36 | for (int i : values) 37 | { 38 | QAction *a = m->addAction(QString::number(i)); 39 | a->setData(i); 40 | } 41 | 42 | m_button->setMenu(m); 43 | } 44 | 45 | 46 | // protected members 47 | 48 | void SpinComboBox::resizeEvent(QResizeEvent *event) 49 | { 50 | QSpinBox::resizeEvent(event); 51 | 52 | int arrowSize = m_button->width(); 53 | 54 | layout()->setContentsMargins(1, 1, arrowSize - 1, 1); 55 | } 56 | 57 | 58 | void SpinComboBox::onAction(QAction* act) 59 | { 60 | int v = act->data().toInt(); 61 | 62 | setValue(v); 63 | } 64 | 65 | 66 | } // namespace 67 | -------------------------------------------------------------------------------- /src/widgets/spincombobox.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | 12 | namespace QSint 13 | { 14 | 15 | 16 | /** 17 | \brief Spin editor with additional drop down menu. 18 | \since 0.4 19 | 20 | \image html SpinComboBox.png An example of SpinComboBox 21 | */ 22 | class SpinComboBox : public QSpinBox 23 | { 24 | Q_OBJECT 25 | 26 | public: 27 | /** Constructor. 28 | */ 29 | explicit SpinComboBox(QWidget *parent = 0); 30 | 31 | void setValueList(const QList &values); 32 | 33 | Q_SIGNALS: 34 | 35 | protected Q_SLOTS: 36 | void onAction(QAction* action); 37 | 38 | protected: 39 | virtual void resizeEvent(QResizeEvent* event); 40 | 41 | QToolButton *m_button; 42 | }; 43 | 44 | 45 | } // namespace 46 | -------------------------------------------------------------------------------- /src/widgets/spinslider.cpp: -------------------------------------------------------------------------------- 1 | #include "spinslider.h" 2 | 3 | 4 | namespace QSint 5 | { 6 | 7 | 8 | SpinSlider::SpinSlider(QWidget *parent) : 9 | QWidget(parent) 10 | { 11 | QHBoxLayout *mainLayout = new QHBoxLayout(this); 12 | mainLayout->setContentsMargins(0,0,0,0); 13 | 14 | m_editor = new QSpinBox(this); 15 | mainLayout->addWidget(m_editor); 16 | 17 | m_unitLabel = new QLabel(this); 18 | m_unitLabel->hide(); 19 | mainLayout->addWidget(m_unitLabel); 20 | 21 | m_minButton = new QToolButton(this); 22 | mainLayout->addWidget(m_minButton); 23 | 24 | m_slider = new QSlider(this); 25 | m_slider->setOrientation(Qt::Horizontal); 26 | mainLayout->addWidget(m_slider); 27 | 28 | m_maxButton = new QToolButton(this); 29 | mainLayout->addWidget(m_maxButton); 30 | 31 | m_sliderMultiplier = 1; 32 | 33 | UpdateConstrains(); 34 | 35 | connect(m_editor, SIGNAL(valueChanged(int)), this, SLOT(OnEditorValueChanged(int))); 36 | connect(m_slider, SIGNAL(valueChanged(int)), this, SLOT(OnSliderMoved(int))); 37 | connect(m_minButton, SIGNAL(clicked()), this, SLOT(OnMinButtonClicked())); 38 | connect(m_maxButton, SIGNAL(clicked()), this, SLOT(OnMaxButtonClicked())); 39 | } 40 | 41 | 42 | void SpinSlider::setMinimum(int val) 43 | { 44 | m_editor->setMinimum(val); 45 | 46 | UpdateConstrains(); 47 | } 48 | 49 | 50 | void SpinSlider::setMaximum(int val) 51 | { 52 | m_editor->setMaximum(val); 53 | 54 | UpdateConstrains(); 55 | } 56 | 57 | 58 | void SpinSlider::setSliderMultiplier(int val) 59 | { 60 | if (val > 0){ 61 | m_sliderMultiplier = val; 62 | 63 | UpdateConstrains(); 64 | } 65 | } 66 | 67 | 68 | void SpinSlider::enableTicks(bool on) 69 | { 70 | m_slider->setTickPosition(on ? QSlider::TicksBelow : QSlider::NoTicks); 71 | } 72 | 73 | 74 | void SpinSlider::expandVertically(bool on) 75 | { 76 | if (on){ 77 | m_editor->setSizePolicy(m_editor->sizePolicy().horizontalPolicy(), QSizePolicy::Preferred); 78 | m_minButton->setSizePolicy(m_minButton->sizePolicy().horizontalPolicy(), QSizePolicy::Preferred); 79 | m_maxButton->setSizePolicy(m_maxButton->sizePolicy().horizontalPolicy(), QSizePolicy::Preferred); 80 | } 81 | else{ 82 | m_editor->setSizePolicy(m_editor->sizePolicy().horizontalPolicy(), QSizePolicy::Maximum); 83 | m_minButton->setSizePolicy(m_minButton->sizePolicy().horizontalPolicy(), QSizePolicy::Maximum); 84 | m_maxButton->setSizePolicy(m_maxButton->sizePolicy().horizontalPolicy(), QSizePolicy::Maximum); 85 | } 86 | } 87 | 88 | 89 | void SpinSlider::setEditorWidth(int width) 90 | { 91 | m_editor->setFixedWidth(width); 92 | } 93 | 94 | 95 | void SpinSlider::setUnitLabelWidth(int width) 96 | { 97 | m_unitLabel->setFixedWidth(width); 98 | m_unitLabel->setVisible(width > 0); 99 | } 100 | 101 | 102 | void SpinSlider::setUnitText(const QString &val) 103 | { 104 | m_unitLabel->setText(val); 105 | m_unitLabel->setVisible(!val.isEmpty()); 106 | } 107 | 108 | 109 | // protected members 110 | 111 | void SpinSlider::UpdateConstrains() 112 | { 113 | m_minButton->setText(QString::number(m_editor->minimum())); 114 | m_maxButton->setText(QString::number(m_editor->maximum())); 115 | 116 | m_slider->blockSignals(true); 117 | m_slider->setRange(m_editor->minimum() / m_sliderMultiplier, m_editor->maximum() / m_sliderMultiplier); 118 | m_slider->blockSignals(false); 119 | } 120 | 121 | 122 | // protected slots 123 | 124 | void SpinSlider::OnEditorValueChanged(int val) 125 | { 126 | m_slider->blockSignals(true); 127 | m_slider->setValue(val / m_sliderMultiplier); 128 | m_slider->blockSignals(false); 129 | 130 | m_minButton->setEnabled(val != minimum()); 131 | m_maxButton->setEnabled(val != maximum()); 132 | } 133 | 134 | 135 | void SpinSlider::OnSliderMoved(int val) 136 | { 137 | m_editor->setValue(val * m_sliderMultiplier); 138 | } 139 | 140 | 141 | void SpinSlider::OnMinButtonClicked() 142 | { 143 | m_editor->setValue(minimum()); 144 | } 145 | 146 | 147 | void SpinSlider::OnMaxButtonClicked() 148 | { 149 | m_editor->setValue(maximum()); 150 | } 151 | 152 | 153 | 154 | } // namespace 155 | -------------------------------------------------------------------------------- /src/widgets/spinslider.h: -------------------------------------------------------------------------------- 1 | #ifndef SPINSLIDER_H 2 | #define SPINSLIDER_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | 11 | namespace QSint 12 | { 13 | 14 | 15 | /** 16 | \brief Spin editor with additional buttons and slider for quick value edition. 17 | \since 0.2.2 18 | 19 | \image html SpinSlider.png An example of SpinSlider 20 | */ 21 | class SpinSlider : public QWidget 22 | { 23 | Q_OBJECT 24 | 25 | Q_PROPERTY(int minimum READ minimum WRITE setMinimum) 26 | Q_PROPERTY(int maximum READ maximum WRITE setMaximum) 27 | Q_PROPERTY(int value READ value WRITE setValue) 28 | Q_PROPERTY(int sliderMultiplier READ sliderMultiplier WRITE setSliderMultiplier) 29 | Q_PROPERTY(bool showTicks READ ticksEnabled WRITE enableTicks) 30 | Q_PROPERTY(QString unitText READ unitText WRITE setUnitText) 31 | 32 | public: 33 | /** Constructor. 34 | */ 35 | explicit SpinSlider(QWidget *parent = 0); 36 | 37 | int value() const { return m_editor->value(); } 38 | int minimum() const { return m_editor->minimum(); } 39 | int maximum() const { return m_editor->maximum(); } 40 | 41 | void setValue(int val) { m_editor->setValue(val); } 42 | void setMinimum(int val); 43 | void setMaximum(int val); 44 | 45 | int sliderMultiplier() const { return m_sliderMultiplier; } 46 | void setSliderMultiplier(int val); 47 | 48 | bool ticksEnabled() const { return m_slider->tickPosition() != QSlider::NoTicks; } 49 | void enableTicks(bool on = true); 50 | 51 | void expandVertically(bool on = true); 52 | 53 | void setEditorWidth(int width); 54 | void setUnitLabelWidth(int width); 55 | 56 | QString unitText() const { return m_unitLabel->text(); } 57 | void setUnitText(const QString& val); 58 | 59 | void setSingleStep(int step) { m_slider->setSingleStep(step); } 60 | void setPageStep(int step) { m_slider->setPageStep(step); } 61 | void setOrientation(int) {} 62 | 63 | Q_SIGNALS: 64 | /** Signal emitted when the current index is changed either by the user or programmatically. 65 | */ 66 | void valueChanged(int index); 67 | 68 | protected Q_SLOTS: 69 | void OnEditorValueChanged(int val); 70 | void OnSliderMoved(int val); 71 | void OnMinButtonClicked(); 72 | void OnMaxButtonClicked(); 73 | 74 | protected: 75 | void UpdateConstrains(); 76 | 77 | QSpinBox *m_editor; 78 | QSlider *m_slider; 79 | QToolButton *m_minButton, *m_maxButton; 80 | QLabel *m_unitLabel; 81 | 82 | int m_sliderMultiplier; 83 | }; 84 | 85 | 86 | } // namespace 87 | 88 | #endif // SPINSLIDER_H 89 | -------------------------------------------------------------------------------- /src/widgets/splitbutton.cpp: -------------------------------------------------------------------------------- 1 | #include "splitbutton.h" 2 | 3 | #include 4 | 5 | 6 | namespace QSint 7 | { 8 | 9 | 10 | SplitButton::SplitButton(QWidget *parent) : QWidget(parent) 11 | { 12 | m_button = new QToolButton(this); 13 | m_button->setObjectName("Button"); 14 | m_button->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::MinimumExpanding); 15 | m_button->setToolButtonStyle(Qt::ToolButtonIconOnly); 16 | 17 | m_split = new QToolButton(this); 18 | m_split->setObjectName("Split"); 19 | m_split->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Maximum); 20 | m_split->setToolButtonStyle(Qt::ToolButtonTextOnly); 21 | m_split->setPopupMode(QToolButton::InstantPopup); 22 | 23 | QVBoxLayout *vbl = new QVBoxLayout(); 24 | vbl->setContentsMargins(0,0,0,0); 25 | vbl->setSpacing(0); 26 | setLayout(vbl); 27 | vbl->addWidget(m_button); 28 | vbl->addWidget(m_split); 29 | 30 | m_menu = new QMenu(this); 31 | m_split->setMenu(m_menu); 32 | 33 | connect(m_menu, &QMenu::aboutToShow, this, &SplitButton::onMenuShow); 34 | connect(m_menu, &QMenu::triggered, this, &SplitButton::onMenuTriggered); 35 | connect(m_button, &QToolButton::clicked, this, &SplitButton::onButtonClicked); 36 | 37 | setIconSize(32); 38 | m_split->setMinimumHeight(24); 39 | 40 | // style 41 | setStyleSheet( 42 | "QToolButton#Button{" 43 | "border: 1px solid #ccc; border-top-left-radius: 5px; border-top-right-radius: 5px; " 44 | "background: #ddd;" 45 | "}" 46 | 47 | "QToolButton#Split{" 48 | "border: 1px solid #ccc; border-top-color: #ddd; border-bottom-right-radius: 5px; border-bottom-left-radius: 5px;" 49 | "background: #ddd;" 50 | "}" 51 | 52 | "QToolButton#Button:hover, QToolButton#Split:hover" 53 | "{" 54 | "background: #def; border-color: #09e;" 55 | "}" 56 | 57 | "QToolButton#Button:clicked, QToolButton#Split:clicked" 58 | "{" 59 | "background: #09e;" 60 | "}" 61 | ); 62 | } 63 | 64 | 65 | void SplitButton::onMenuShow() 66 | { 67 | m_menu->clear(); 68 | m_menu->addActions(actions()); 69 | m_menu->setDefaultAction(m_button->defaultAction()); 70 | } 71 | 72 | 73 | void SplitButton::onMenuTriggered(QAction *action) 74 | { 75 | if (m_setLast) 76 | { 77 | setDefaultAction(action); 78 | } 79 | } 80 | 81 | 82 | void SplitButton::onButtonClicked() 83 | { 84 | const auto& acts = actions(); 85 | 86 | if (m_toggle && acts.count()) 87 | { 88 | int index = acts.indexOf(m_button->defaultAction()); 89 | if (index < 0 || index == acts.count()-1) 90 | setDefaultAction(acts.first()); 91 | else 92 | setDefaultAction(acts.at(index+1)); 93 | } 94 | } 95 | 96 | 97 | void SplitButton::setDefaultAction(QAction *action) 98 | { 99 | // Qt bug workaround: setDefaultAction is adding action to actions 100 | while (m_button->actions().count()) 101 | m_button->removeAction(m_button->actions().first()); 102 | 103 | m_button->setDefaultAction(action); 104 | 105 | m_split->setDefaultAction(action); 106 | } 107 | 108 | 109 | void SplitButton::setIconSize(int size) 110 | { 111 | m_button->setIconSize(QSize(size, size)); 112 | } 113 | 114 | 115 | void SplitButton::setLastActionDefault(bool on) 116 | { 117 | m_setLast = on; 118 | } 119 | 120 | 121 | void SplitButton::setActionsToggle(bool on) 122 | { 123 | m_toggle = on; 124 | } 125 | 126 | 127 | } 128 | -------------------------------------------------------------------------------- /src/widgets/splitbutton.h: -------------------------------------------------------------------------------- 1 | #ifndef CSPLITBUTTON_H 2 | #define CSPLITBUTTON_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | 9 | namespace QSint 10 | { 11 | 12 | 13 | /** 14 | * @brief The SplitButton class represents Microsoft Office-like "Split Button" control which consists 15 | * of a clickable button itself and a drop-down list of some common actions connected with the button. 16 | * 17 | * Clicking on the button fires its default action (set via setDefaultAction() method). 18 | * Depending of the operation modes, default button action can be set automatically after choosing an option 19 | * from the drop-down list (see setLastActionDefault()) or can be toggled to the another one action 20 | * after the click on the button (see setActionsToggle()). 21 | * 22 | * \since 0.4 23 | */ 24 | class SplitButton : public QWidget 25 | { 26 | Q_OBJECT 27 | 28 | public: 29 | explicit SplitButton(QWidget *parent = nullptr); 30 | 31 | /// Set button's icon size to \a size. 32 | void setIconSize(int size); 33 | /// Set action \a action as default (it will be invoked after clicking on the button). 34 | void setDefaultAction(QAction *action); 35 | /// If \a on, the recently chosen action from the list will be set as default. 36 | void setLastActionDefault(bool on); 37 | /// If \a on, clicking on the button will automatically advance to the next action in the list. 38 | void setActionsToggle(bool on); 39 | 40 | signals: 41 | 42 | private slots: 43 | void onMenuShow(); 44 | void onMenuTriggered(QAction *action); 45 | void onButtonClicked(); 46 | 47 | private: 48 | QToolButton *m_button; 49 | QToolButton *m_split; 50 | QMenu *m_menu; 51 | bool m_setLast = false; 52 | bool m_toggle = false; 53 | }; 54 | 55 | 56 | } 57 | 58 | 59 | #endif // CSPLITBUTTON_H 60 | -------------------------------------------------------------------------------- /src/widgets/timepicker.cpp: -------------------------------------------------------------------------------- 1 | #include "timepicker.h" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | 11 | namespace QSint 12 | { 13 | 14 | 15 | TimePicker::TimePicker(QWidget *parent) : 16 | QWidget(parent) 17 | { 18 | QHBoxLayout *hbl = new QHBoxLayout(); 19 | setLayout(hbl); 20 | 21 | QGroupBox *hourBox = new QGroupBox(this); 22 | hourBox->setTitle(tr("Hours")); 23 | QGridLayout *hourGrid = new QGridLayout(); 24 | hourGrid->setSpacing(0); 25 | hourGrid->setMargin(1); 26 | hourBox->setLayout(hourGrid); 27 | hbl->addWidget(hourBox); 28 | 29 | int hour = 0; 30 | for (int r = 0; r < 6; r++) 31 | { 32 | for (int c = 0; c < 4; c++) 33 | { 34 | QToolButton *hourButton = new QToolButton(this); 35 | hourButton->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); 36 | hourButton->setText(QString::number(hour)); 37 | hourGrid->addWidget(hourButton, r, c); 38 | m_hourButtons.addButton(hourButton, hour); 39 | 40 | hour++; 41 | } 42 | } 43 | 44 | QGroupBox *minuteBox = new QGroupBox(this); 45 | minuteBox->setTitle(tr("Minutes")); 46 | QGridLayout *minuteGrid = new QGridLayout(); 47 | minuteGrid->setSpacing(0); 48 | minuteGrid->setMargin(1); 49 | minuteBox->setLayout(minuteGrid); 50 | hbl->addWidget(minuteBox); 51 | 52 | int minute = 0; 53 | for (int r = 0; r < 6; r++) 54 | { 55 | for (int c = 0; c < 10; c++) 56 | { 57 | QToolButton *minuteButton = new QToolButton(this); 58 | minuteButton->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); 59 | minuteButton->setText(QString::number(minute)); 60 | minuteGrid->addWidget(minuteButton, r, c); 61 | m_minuteButtons.addButton(minuteButton, minute); 62 | 63 | minute++; 64 | } 65 | } 66 | 67 | m_time = QTime::currentTime(); 68 | 69 | connect(&m_hourButtons, SIGNAL(buttonClicked(int)), this, SLOT(hourClicked(int))); 70 | connect(&m_minuteButtons, SIGNAL(buttonClicked(int)), this, SLOT(minuteClicked(int))); 71 | } 72 | 73 | 74 | void TimePicker::setTime(const QTime& time) 75 | { 76 | m_time = time; 77 | } 78 | 79 | 80 | void TimePicker::hourClicked(int hour) 81 | { 82 | m_time.setHMS(hour, m_time.minute(), 0, 0); 83 | 84 | Q_EMIT timePicked(m_time); 85 | } 86 | 87 | 88 | void TimePicker::minuteClicked(int minute) 89 | { 90 | m_time.setHMS(m_time.hour(), minute, 0, 0); 91 | 92 | Q_EMIT timePicked(m_time); 93 | } 94 | 95 | 96 | // picker button 97 | 98 | TimePickerButton::TimePickerButton(QWidget *parent) : QToolButton(parent), m_editor(NULL) 99 | { 100 | QFrame *frame = new QFrame(); 101 | frame->setLayout(new QVBoxLayout()); 102 | frame->layout()->addWidget(&m_timePicker); 103 | frame->layout()->setMargin(0); 104 | frame->setFrameShape(QFrame::Box); 105 | 106 | m_dialog = new QDialog(this, Qt::Popup); 107 | m_dialog->setLayout(new QVBoxLayout()); 108 | m_dialog->layout()->addWidget(frame); 109 | m_dialog->layout()->setMargin(0); 110 | 111 | connect(this, SIGNAL(clicked()), this, SLOT(OnButtonClicked())); 112 | } 113 | 114 | 115 | void TimePickerButton::OnButtonClicked() 116 | { 117 | if (m_editor) 118 | { 119 | m_timePicker.setTime(m_editor->time()); 120 | connect(&m_timePicker, SIGNAL(timePicked(QTime)), m_editor, SLOT(setTime(QTime))); 121 | } 122 | 123 | m_dialog->move(parentWidget()->mapToGlobal(pos() + QPoint(-m_dialog->width() / 2, height()))); 124 | m_dialog->exec(); 125 | 126 | if (m_editor) 127 | { 128 | m_timePicker.disconnect(m_editor); 129 | } 130 | } 131 | 132 | 133 | } 134 | 135 | -------------------------------------------------------------------------------- /src/widgets/timepicker.h: -------------------------------------------------------------------------------- 1 | #ifndef TIMEPICKER_H 2 | #define TIMEPICKER_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | 11 | namespace QSint 12 | { 13 | 14 | /** 15 | * @brief The TimePicker class allows to choose a time moment in a hour:minute form via simple UI. 16 | * \since 0.4 17 | */ 18 | class TimePicker : public QWidget 19 | { 20 | Q_OBJECT 21 | 22 | public: 23 | /** Constructor. 24 | */ 25 | explicit TimePicker(QWidget *parent = 0); 26 | 27 | /** Returns current time. 28 | */ 29 | QTime time() const 30 | { return m_time; } 31 | 32 | public Q_SLOTS: 33 | /** Sets current time. 34 | */ 35 | void setTime(const QTime& time); 36 | 37 | Q_SIGNALS: 38 | void timePicked(const QTime& time); 39 | 40 | private Q_SLOTS: 41 | void hourClicked(int hour); 42 | void minuteClicked(int minute); 43 | 44 | protected: 45 | QTime m_time; 46 | QButtonGroup m_hourButtons; 47 | QButtonGroup m_minuteButtons; 48 | }; 49 | 50 | 51 | // button with popup dialog 52 | 53 | class TimePickerButton : public QToolButton 54 | { 55 | Q_OBJECT 56 | 57 | public: 58 | TimePickerButton(QWidget *parent = 0); 59 | 60 | void setTimeEdit(QTimeEdit *timeEdit) { m_editor = timeEdit; } 61 | 62 | TimePicker* pickerWidget() { return &m_timePicker; } 63 | QDialog* dialogWidget() { return m_dialog; } 64 | 65 | private Q_SLOTS: 66 | void OnButtonClicked(); 67 | 68 | protected: 69 | QDialog* m_dialog; 70 | QTimeEdit* m_editor; 71 | TimePicker m_timePicker; 72 | }; 73 | 74 | 75 | } 76 | 77 | 78 | #endif // TIMEPICKER_H 79 | -------------------------------------------------------------------------------- /src/widgets/widgets.pri: -------------------------------------------------------------------------------- 1 | HEADERS += $$files($$PWD/*.h) 2 | SOURCES += $$files($$PWD/*.cpp) 3 | --------------------------------------------------------------------------------