├── main.cc ├── mainwindow.h ├── README.md ├── tool.h ├── tool.cc ├── .gitignore ├── new-toolbox.pro ├── mainwindow.ui ├── toolbox.h ├── icons ├── icons.qrc ├── light_krita_tool_polygon.svg ├── light_krita_tool_ellipse.svg ├── light_krita_tool_rectangle.svg ├── light_tool_pan.svg ├── light_krita_tool_line.svg ├── light_select.svg ├── light_krita_tool_smart_patch.svg ├── light_tool_perspectivegrid.svg ├── light_krita_tool_move.svg ├── light_draw-text.svg ├── light_tool_rect_selection.svg ├── light_tool_zoom.svg ├── light_krita_tool_freehand.svg ├── light_krita_tool_gradient.svg ├── light_krita_tool_color_fill.svg ├── light_krita_tool_assistant.svg ├── light_tool_similar_selection.svg ├── light_krita_tool_color_picker.svg ├── light_tool_contiguous_selection.svg ├── light_krita_tool_measure.svg ├── light_tool_elliptical_selection.svg ├── light_tool_crop.svg ├── light_krita_tool_grid.svg ├── light_krita_tool_dyna.svg ├── light_tool_path_selection.svg ├── light_krita_tool_reference_images.svg ├── light_krita_draw_path.svg ├── light_tool_magnetic_selection.svg ├── light_shape_handling.svg ├── light_tool_outline_selection.svg ├── light_krita_tool_multihand.svg ├── light_krita_tool_lazybrush.svg ├── light_krita_tool_freehandvector.svg ├── light_tool_polygonal_selection.svg ├── light_polyline.svg └── light_format-fill-color.svg ├── mainwindow.cc └── toolbox.cc /main.cc: -------------------------------------------------------------------------------- 1 | #include "mainwindow.h" 2 | 3 | #include 4 | 5 | int main(int argc, char *argv[]) 6 | { 7 | QApplication a(argc, argv); 8 | MainWindow w; 9 | w.show(); 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /mainwindow.h: -------------------------------------------------------------------------------- 1 | #ifndef MAINWINDOW_H 2 | #define MAINWINDOW_H 3 | 4 | #include 5 | 6 | QT_BEGIN_NAMESPACE 7 | namespace Ui { class MainWindow; } 8 | QT_END_NAMESPACE 9 | 10 | class MainWindow : public QMainWindow 11 | { 12 | Q_OBJECT 13 | 14 | public: 15 | MainWindow(QWidget *parent = nullptr); 16 | ~MainWindow(); 17 | 18 | private: 19 | Ui::MainWindow *ui; 20 | }; 21 | #endif // MAINWINDOW_H 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # blender-toolbox-qt 2 | I really liked the UI of the new Blender 2.8, so just a fun side project to recreate a blender like toolbox in Qt. 3 | This is just a protoype, not usable, but can be made usable. [Here](https://www.youtube.com/watch?v=BAghmqj057U) is a small video of it. 4 | 5 | ![screenshot](https://i.ibb.co/cNQdnJs/image.png) 6 | PS: The icons are from the krita repo [here](https://invent.kde.org/kde/krita/) and not mine, :) 7 | -------------------------------------------------------------------------------- /tool.h: -------------------------------------------------------------------------------- 1 | #ifndef TOOL_H 2 | #define TOOL_H 3 | 4 | #include 5 | #include 6 | 7 | class Tool 8 | { 9 | public: 10 | Tool(QString name, QIcon icon); 11 | Tool() {} 12 | 13 | QIcon icon(); 14 | QString name(); 15 | void addSubTool(Tool t); 16 | QVector subTools(); 17 | void swap(int index); 18 | 19 | private: 20 | QString m_name; 21 | QIcon m_icon; 22 | QVector m_subTools; 23 | }; 24 | 25 | #endif // TOOL_H 26 | -------------------------------------------------------------------------------- /tool.cc: -------------------------------------------------------------------------------- 1 | #include "tool.h" 2 | 3 | Tool::Tool(QString name, QIcon icon): 4 | m_name(name), m_icon(icon) 5 | { } 6 | 7 | QIcon Tool::icon() 8 | { 9 | return m_icon; 10 | } 11 | 12 | QString Tool::name() 13 | { 14 | return m_name; 15 | } 16 | 17 | void Tool::addSubTool(Tool t) 18 | { 19 | m_subTools.push_back(t); 20 | } 21 | 22 | QVector Tool::subTools() 23 | { 24 | return m_subTools; 25 | } 26 | 27 | void Tool::swap(int index) 28 | { 29 | Tool temp = m_subTools[index]; 30 | m_subTools.remove(index); 31 | Tool t(m_name, m_icon); 32 | m_subTools.push_front(t); 33 | m_icon = temp.icon(); 34 | m_name = temp.name(); 35 | } 36 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # This file is used to ignore files which are generated 2 | # ---------------------------------------------------------------------------- 3 | 4 | *~ 5 | *.autosave 6 | *.a 7 | *.core 8 | *.moc 9 | *.o 10 | *.obj 11 | *.orig 12 | *.rej 13 | *.so 14 | *.so.* 15 | *_pch.h.cpp 16 | *_resource.rc 17 | *.qm 18 | .#* 19 | *.*# 20 | core 21 | !core/ 22 | tags 23 | .DS_Store 24 | .directory 25 | *.debug 26 | Makefile* 27 | *.prl 28 | *.app 29 | moc_*.cpp 30 | ui_*.h 31 | qrc_*.cpp 32 | Thumbs.db 33 | *.res 34 | *.rc 35 | /.qmake.cache 36 | /.qmake.stash 37 | 38 | # qtcreator generated files 39 | *.pro.user* 40 | 41 | # xemacs temporary files 42 | *.flc 43 | 44 | # Vim temporary files 45 | .*.swp 46 | 47 | # Visual Studio generated files 48 | *.ib_pdb_index 49 | *.idb 50 | *.ilk 51 | *.pdb 52 | *.sln 53 | *.suo 54 | *.vcproj 55 | *vcproj.*.*.user 56 | *.ncb 57 | *.sdf 58 | *.opensdf 59 | *.vcxproj 60 | *vcxproj.* 61 | 62 | # MinGW generated files 63 | *.Debug 64 | *.Release 65 | 66 | # Python byte code 67 | *.pyc 68 | 69 | # Binaries 70 | # -------- 71 | *.dll 72 | *.exe 73 | 74 | -------------------------------------------------------------------------------- /new-toolbox.pro: -------------------------------------------------------------------------------- 1 | QT += core gui 2 | 3 | greaterThan(QT_MAJOR_VERSION, 4): QT += widgets 4 | 5 | CONFIG += c++11 6 | 7 | # The following define makes your compiler emit warnings if you use 8 | # any Qt feature that has been marked deprecated (the exact warnings 9 | # depend on your compiler). Please consult the documentation of the 10 | # deprecated API in order to know how to port your code away from it. 11 | DEFINES += QT_DEPRECATED_WARNINGS 12 | 13 | # You can also make your code fail to compile if it uses deprecated APIs. 14 | # In order to do so, uncomment the following line. 15 | # You can also select to disable deprecated APIs only up to a certain version of Qt. 16 | #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 17 | 18 | SOURCES += \ 19 | main.cc \ 20 | mainwindow.cc \ 21 | tool.cc \ 22 | toolbox.cc 23 | 24 | HEADERS += \ 25 | mainwindow.h \ 26 | tool.h \ 27 | toolbox.h 28 | 29 | FORMS += \ 30 | mainwindow.ui 31 | 32 | # Default rules for deployment. 33 | qnx: target.path = /tmp/$${TARGET}/bin 34 | else: unix:!android: target.path = /opt/$${TARGET}/bin 35 | !isEmpty(target.path): INSTALLS += target 36 | 37 | RESOURCES += \ 38 | icons/icons.qrc 39 | -------------------------------------------------------------------------------- /mainwindow.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | MainWindow 4 | 5 | 6 | 7 | 0 8 | 0 9 | 800 10 | 600 11 | 12 | 13 | 14 | MainWindow 15 | 16 | 17 | true 18 | 19 | 20 | MainWindow{ 21 | background: #3A3A3A; 22 | } 23 | 24 | 25 | 26 | 27 | 28 | 10 29 | 10 30 | 120 31 | 80 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 0 40 | 0 41 | 800 42 | 23 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | ToolBox 51 | QWidget 52 |
toolbox.h
53 | 1 54 |
55 |
56 | 57 | 58 |
59 | -------------------------------------------------------------------------------- /toolbox.h: -------------------------------------------------------------------------------- 1 | #ifndef TOOLBOX_H 2 | #define TOOLBOX_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #include "tool.h" 10 | 11 | class ToolBox : public QWidget 12 | { 13 | Q_OBJECT 14 | 15 | private: 16 | enum ToolBoxOrientation{ 17 | Vertical, Horizontal 18 | }; 19 | 20 | enum SubToolsOrientation{ 21 | Right, Left 22 | }; 23 | 24 | enum RowMode{ 25 | Single, Double 26 | }; 27 | 28 | enum ToolBoxState{ 29 | Locked, Unlocked 30 | }; 31 | 32 | public: 33 | explicit ToolBox(QWidget *parent = nullptr); 34 | void paintEvent(QPaintEvent *event) override; 35 | void mousePressEvent(QMouseEvent *event) override; 36 | void mouseReleaseEvent(QMouseEvent *event) override; 37 | void mouseMoveEvent(QMouseEvent *event) override; 38 | 39 | void addTool(Tool t); 40 | void addBreak(); 41 | 42 | public Q_SLOTS: 43 | void longPressEvent(); 44 | void showContextMenu(QPoint pos); 45 | void slotUnlockToolBox(); 46 | void slotRotateToolBox(); 47 | void slotChangeRowMode(); 48 | void slotFlipToolBox(); 49 | 50 | private: 51 | int m_activated, m_padding, m_subToolActivated; 52 | QSize m_buttonSize; 53 | QVector m_toolRects, m_secondaryTools; 54 | QVector m_tools; 55 | QVector m_breaks; 56 | QTimer m_timer; 57 | bool m_longPressed, m_toolBoxHandlePressed; 58 | QPoint m_lastMousePos; 59 | QMenu *m_contextMenu; 60 | QAction *m_rotateAction, *m_unlockAction, *m_rowModeAction, *m_flipAction; 61 | ToolBoxOrientation m_toolBoxOrientation; 62 | SubToolsOrientation m_subToolsOrientation; 63 | RowMode m_rowMode; 64 | ToolBoxState m_toolBoxState; 65 | }; 66 | 67 | #endif // TOOLBOX_H 68 | -------------------------------------------------------------------------------- /icons/icons.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | light_draw-text.svg 4 | light_krita_draw_path.svg 5 | light_krita_tool_ellipse.svg 6 | light_krita_tool_freehand.svg 7 | light_krita_tool_line.svg 8 | light_polyline.svg 9 | light_krita_tool_polygon.svg 10 | light_shape_handling.svg 11 | light_tool_outline_selection.svg 12 | light_tool_path_selection.svg 13 | light_krita_tool_rectangle.svg 14 | light_tool_crop.svg 15 | light_krita_tool_transform.svg 16 | light_tool_elliptical_selection.svg 17 | light_tool_polygonal_selection.svg 18 | light_tool_rect_selection.svg 19 | light_tool_magnetic_selection.svg 20 | light_format-fill-color.svg 21 | light_krita_tool_assistant.svg 22 | light_krita_tool_color_fill.svg 23 | light_krita_tool_lazybrush.svg 24 | light_krita_tool_multihand.svg 25 | light_krita_tool_color_picker.svg 26 | light_krita_tool_freehandvector.svg 27 | light_krita_tool_smart_patch.svg 28 | light_pattern.svg 29 | light_tool_contiguous_selection.svg 30 | light_tool_pan.svg 31 | light_krita_tool_dyna.svg 32 | light_krita_tool_gradient.svg 33 | light_krita_tool_measure.svg 34 | light_krita_tool_grid.svg 35 | light_krita_tool_move.svg 36 | light_krita_tool_reference_images.svg 37 | light_tool_similar_selection.svg 38 | light_select.svg 39 | light_tool_perspectivegrid.svg 40 | light_tool_zoom.svg 41 | 42 | 43 | -------------------------------------------------------------------------------- /icons/light_krita_tool_polygon.svg: -------------------------------------------------------------------------------- 1 | 2 | 13 | 15 | 17 | 18 | 20 | image/svg+xml 21 | 23 | 24 | 25 | 26 | Andrei Rudenko 27 | 28 | 29 | 31 | 32 | 34 | 36 | 38 | 40 | 42 | 44 | 46 | 47 | 48 | 49 | 52 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /icons/light_krita_tool_ellipse.svg: -------------------------------------------------------------------------------- 1 | 2 | 13 | 15 | 17 | 18 | 20 | image/svg+xml 21 | 23 | 24 | 25 | 26 | Andrei Rudenko 27 | 28 | 29 | 31 | 32 | 34 | 36 | 38 | 40 | 42 | 44 | 46 | 47 | 48 | 49 | 52 | 56 | 62 | 63 | 64 | -------------------------------------------------------------------------------- /icons/light_krita_tool_rectangle.svg: -------------------------------------------------------------------------------- 1 | 2 | 13 | 15 | 17 | 18 | 20 | image/svg+xml 21 | 23 | 24 | 25 | 26 | Andrei Rudenko 27 | 28 | 29 | 31 | 32 | 34 | 36 | 38 | 40 | 42 | 44 | 46 | 47 | 48 | 49 | 52 | 56 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /icons/light_tool_pan.svg: -------------------------------------------------------------------------------- 1 | 2 | 13 | 15 | 17 | 18 | 20 | image/svg+xml 21 | 23 | 24 | 25 | 26 | Timothée Giet 27 | 28 | 29 | 2016 30 | 32 | 33 | 35 | 37 | 39 | 41 | 43 | 45 | 47 | 48 | 49 | 50 | 53 | 57 | 61 | 62 | 63 | -------------------------------------------------------------------------------- /icons/light_krita_tool_line.svg: -------------------------------------------------------------------------------- 1 | 2 | 13 | 15 | 17 | 18 | 20 | image/svg+xml 21 | 23 | 24 | 25 | 26 | Andrei Rudenko 27 | 28 | 29 | 31 | 32 | 34 | 36 | 38 | 40 | 42 | 44 | 46 | 47 | 48 | 49 | 52 | 56 | 60 | 64 | 65 | 66 | 67 | -------------------------------------------------------------------------------- /icons/light_select.svg: -------------------------------------------------------------------------------- 1 | 2 | 13 | 15 | 17 | 18 | 20 | image/svg+xml 21 | 23 | 24 | 25 | 26 | Andrei Rudenko 27 | 28 | 29 | 31 | 32 | 34 | 36 | 38 | 40 | 42 | 44 | 46 | 47 | 48 | 49 | 52 | 56 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /icons/light_krita_tool_smart_patch.svg: -------------------------------------------------------------------------------- 1 | 2 | image/svg+xml2017Timothée Giet -------------------------------------------------------------------------------- /icons/light_tool_perspectivegrid.svg: -------------------------------------------------------------------------------- 1 | 2 | 13 | 15 | 17 | 18 | 20 | image/svg+xml 21 | 23 | 24 | 25 | 26 | Andrei Rudenko 27 | 28 | 29 | 31 | 32 | 34 | 36 | 38 | 40 | 42 | 44 | 46 | 47 | 48 | 49 | 52 | 55 | 59 | 60 | 63 | 64 | -------------------------------------------------------------------------------- /icons/light_krita_tool_move.svg: -------------------------------------------------------------------------------- 1 | 2 | 13 | 15 | 17 | 18 | 20 | image/svg+xml 21 | 23 | 24 | 25 | 26 | Andrei Rudenko 27 | 28 | 29 | 31 | 32 | 34 | 36 | 38 | 40 | 42 | 44 | 46 | 47 | 48 | 49 | 52 | 54 | 58 | 62 | 63 | 64 | -------------------------------------------------------------------------------- /icons/light_draw-text.svg: -------------------------------------------------------------------------------- 1 | 2 | 13 | 15 | 17 | 18 | 20 | image/svg+xml 21 | 23 | 24 | 25 | 26 | Andrei Rudenko 27 | 28 | 29 | 31 | 32 | 34 | 36 | 38 | 40 | 42 | 44 | 46 | 47 | 48 | 49 | 57 | 60 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /icons/light_tool_rect_selection.svg: -------------------------------------------------------------------------------- 1 | 2 | 13 | 15 | 17 | 18 | 20 | image/svg+xml 21 | 23 | 24 | 25 | 26 | Andrei Rudenko 27 | 28 | 29 | 31 | 32 | 34 | 36 | 38 | 40 | 42 | 44 | 46 | 47 | 48 | 49 | 57 | 60 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /icons/light_tool_zoom.svg: -------------------------------------------------------------------------------- 1 | 2 | 13 | 15 | 17 | 18 | 20 | image/svg+xml 21 | 23 | 24 | 25 | 26 | Timothée Giet 27 | 28 | 29 | 2016 30 | 32 | 33 | 35 | 37 | 39 | 41 | 43 | 45 | 47 | 48 | 49 | 50 | 53 | 57 | 61 | 65 | 69 | 70 | 71 | -------------------------------------------------------------------------------- /icons/light_krita_tool_freehand.svg: -------------------------------------------------------------------------------- 1 | 2 | 13 | 15 | 17 | 18 | 20 | image/svg+xml 21 | 23 | 24 | 25 | 26 | Timothée Giet 27 | 28 | 29 | 2017 30 | 32 | 33 | 35 | 37 | 39 | 41 | 43 | 45 | 47 | 48 | 49 | 50 | 53 | 57 | 61 | 65 | 69 | 70 | 71 | -------------------------------------------------------------------------------- /icons/light_krita_tool_gradient.svg: -------------------------------------------------------------------------------- 1 | 2 | 14 | 16 | 18 | 22 | 26 | 27 | 35 | 36 | 38 | 39 | 41 | image/svg+xml 42 | 44 | 45 | 46 | 47 | Andrei Rudenko 48 | 49 | 50 | 52 | 53 | 55 | 57 | 59 | 61 | 63 | 65 | 67 | 68 | 69 | 70 | 73 | 77 | 81 | 82 | 85 | 89 | 90 | 92 | 93 | -------------------------------------------------------------------------------- /icons/light_krita_tool_color_fill.svg: -------------------------------------------------------------------------------- 1 | 2 | 13 | 15 | 17 | 18 | 20 | image/svg+xml 21 | 23 | 24 | 25 | 26 | Andrei Rudenko 27 | 28 | 29 | 31 | 32 | 34 | 36 | 38 | 40 | 42 | 44 | 46 | 47 | 48 | 49 | 57 | 59 | 63 | 67 | 71 | 75 | 76 | 77 | -------------------------------------------------------------------------------- /icons/light_krita_tool_assistant.svg: -------------------------------------------------------------------------------- 1 | 2 | 13 | 15 | 17 | 18 | 20 | image/svg+xml 21 | 23 | 24 | 25 | 26 | Andrei Rudenko 27 | 28 | 29 | 31 | 32 | 34 | 36 | 38 | 40 | 42 | 44 | 46 | 47 | 48 | 49 | 52 | 56 | 60 | 67 | 74 | 81 | 88 | 89 | 90 | -------------------------------------------------------------------------------- /icons/light_tool_similar_selection.svg: -------------------------------------------------------------------------------- 1 | 2 | 13 | 15 | 17 | 18 | 20 | image/svg+xml 21 | 23 | 24 | 25 | 26 | Andrei Rudenko 27 | 28 | 29 | 31 | 32 | 34 | 36 | 38 | 40 | 42 | 44 | 46 | 47 | 48 | 49 | 52 | 56 | 57 | 59 | 67 | 76 | 80 | 84 | 85 | 86 | -------------------------------------------------------------------------------- /icons/light_krita_tool_color_picker.svg: -------------------------------------------------------------------------------- 1 | 2 | 13 | 15 | 17 | 18 | 20 | image/svg+xml 21 | 23 | 24 | 25 | 26 | Andrei Rudenko 27 | 28 | 29 | 31 | 32 | 34 | 36 | 38 | 40 | 42 | 44 | 46 | 47 | 48 | 49 | 57 | 59 | 67 | 76 | 80 | 84 | 85 | 86 | -------------------------------------------------------------------------------- /icons/light_tool_contiguous_selection.svg: -------------------------------------------------------------------------------- 1 | 2 | 13 | 15 | 17 | 18 | 20 | image/svg+xml 21 | 23 | 24 | 25 | 26 | Andrei Rudenko 27 | 28 | 29 | 31 | 32 | 34 | 36 | 38 | 40 | 42 | 44 | 46 | 47 | 48 | 49 | 52 | 60 | 67 | 74 | 82 | 90 | 98 | 99 | 100 | -------------------------------------------------------------------------------- /icons/light_krita_tool_measure.svg: -------------------------------------------------------------------------------- 1 | 2 | 13 | 15 | 17 | 18 | 20 | image/svg+xml 21 | 23 | 24 | 25 | 26 | Andrei Rudenko 27 | 28 | 29 | 31 | 32 | 34 | 36 | 38 | 40 | 42 | 44 | 46 | 47 | 48 | 49 | 68 | 70 | 74 | 78 | 79 | 80 | -------------------------------------------------------------------------------- /icons/light_tool_elliptical_selection.svg: -------------------------------------------------------------------------------- 1 | 2 | 13 | 15 | 17 | 18 | 20 | image/svg+xml 21 | 23 | 24 | 25 | 26 | Andrei Rudenko 27 | 28 | 29 | 31 | 32 | 34 | 36 | 38 | 40 | 42 | 44 | 46 | 47 | 48 | 49 | 51 | 55 | 59 | 63 | 67 | 71 | 75 | 79 | 83 | 84 | 85 | -------------------------------------------------------------------------------- /icons/light_tool_crop.svg: -------------------------------------------------------------------------------- 1 | 2 | 13 | 15 | 17 | 18 | 20 | image/svg+xml 21 | 23 | 24 | 25 | 26 | Andrei Rudenko 27 | 28 | 29 | 31 | 32 | 34 | 36 | 38 | 40 | 42 | 44 | 46 | 47 | 48 | 49 | 72 | 75 | 79 | 83 | 90 | 97 | 98 | 99 | -------------------------------------------------------------------------------- /icons/light_krita_tool_grid.svg: -------------------------------------------------------------------------------- 1 | 2 | 13 | 15 | 17 | 18 | 20 | image/svg+xml 21 | 23 | 24 | 25 | 26 | Andrei Rudenko 27 | 28 | 29 | 31 | 32 | 34 | 36 | 38 | 40 | 42 | 44 | 46 | 47 | 48 | 49 | 52 | 56 | 57 | 106 | 107 | -------------------------------------------------------------------------------- /mainwindow.cc: -------------------------------------------------------------------------------- 1 | #include "mainwindow.h" 2 | #include "ui_mainwindow.h" 3 | 4 | #include "toolbox.h" 5 | 6 | MainWindow::MainWindow(QWidget *parent) 7 | : QMainWindow(parent) 8 | , ui(new Ui::MainWindow) 9 | { 10 | ui->setupUi(this); 11 | 12 | Tool transformTool("Transform", QIcon (":/light_krita_tool_transform.svg")); 13 | Tool moveTool("Move", QIcon(":/light_krita_tool_move.svg")); 14 | transformTool.addSubTool(moveTool); 15 | 16 | Tool rectangularMarqueeTool("Rectangular Selection", QIcon (":/light_tool_rect_selection.svg")); 17 | Tool circularMarqueeTool("Elliptical Selection", QIcon (":/light_tool_elliptical_selection.svg")); 18 | rectangularMarqueeTool.addSubTool(circularMarqueeTool); 19 | 20 | Tool lassoTool("Freehand Selection", QIcon(":/light_tool_outline_selection.svg")); 21 | Tool polygonalLasso("Polygonal Selection", QIcon(":/light_tool_polygonal_selection.svg")); 22 | Tool magneticLasso("Magnetic Selection", QIcon(":/light_tool_magnetic_selection.svg")); 23 | Tool bezierCurveLasso("Path Selection", QIcon(":/light_tool_path_selection.svg")); 24 | lassoTool.addSubTool(polygonalLasso); 25 | lassoTool.addSubTool(magneticLasso); 26 | lassoTool.addSubTool(bezierCurveLasso); 27 | 28 | Tool similarSelectionTool("Similar Selection", QIcon(":/light_tool_similar_selection.svg")); 29 | Tool contagiousSelectionTool("Contagious Selection", QIcon(":/light_tool_contiguous_selection.svg")); 30 | similarSelectionTool.addSubTool(contagiousSelectionTool); 31 | 32 | Tool cropTool("Crop", QIcon (":/light_tool_crop.svg")); 33 | 34 | Tool fillTool("Fill", QIcon(":/light_krita_tool_color_fill.svg")); 35 | Tool colorPicker("Color Picker", QIcon(":/light_krita_tool_color_picker.svg")); 36 | Tool smartPatchTool("Smart Patch", QIcon(":/light_krita_tool_smart_patch.svg")); 37 | Tool gradientTool("Gradient", QIcon(":/light_krita_tool_gradient.svg")); 38 | Tool patternTool("Pattern", QIcon(":/light_pattern.svg")); 39 | fillTool.addSubTool(colorPicker); 40 | fillTool.addSubTool(smartPatchTool); 41 | fillTool.addSubTool(gradientTool); 42 | fillTool.addSubTool(patternTool); 43 | 44 | Tool brushTool("Brush", QIcon(":/light_krita_tool_freehand.svg")); 45 | Tool dynamicBrushTool("Dynamic Brush", QIcon(":/light_krita_tool_dyna.svg")); 46 | Tool lazyBrushTool("Lazy Brush", QIcon(":/light_krita_tool_lazybrush.svg")); 47 | Tool multiBrushTool("Multi Brush", QIcon(":/light_krita_tool_multihand.svg")); 48 | brushTool.addSubTool(dynamicBrushTool); 49 | brushTool.addSubTool(lazyBrushTool); 50 | brushTool.addSubTool(multiBrushTool); 51 | 52 | Tool rectangleTool("Rectangle", QIcon(":/light_krita_tool_rectangle.svg")); 53 | Tool lineTool("Line", QIcon(":/light_krita_tool_line.svg")); 54 | Tool freehandTool("Freehand", QIcon(":/light_krita_tool_freehandvector.svg")); 55 | Tool ellipseTool("Ellipse", QIcon(":/light_krita_tool_ellipse.svg")); 56 | Tool polylineTool("Polygon", QIcon(":/light_polyline.svg")); 57 | Tool pathTool("Path", QIcon(":/light_krita_draw_path.svg")); 58 | rectangleTool.addSubTool(lineTool); 59 | rectangleTool.addSubTool(ellipseTool); 60 | rectangleTool.addSubTool(polylineTool); 61 | rectangleTool.addSubTool(freehandTool); 62 | rectangleTool.addSubTool(pathTool); 63 | 64 | Tool textTool("Text", QIcon(":/light_draw-text.svg")); 65 | 66 | Tool shapeSelectTool("Shape Select", QIcon(":/light_select.svg")); 67 | Tool editShapesTool("Edit Shapes", QIcon(":/light_shape_handling.svg")); 68 | shapeSelectTool.addSubTool(editShapesTool); 69 | 70 | Tool assitantTool("Assistants", QIcon(":/light_krita_tool_assistant.svg")); 71 | Tool gridTool("Grid", QIcon(":/light_krita_tool_grid.svg")); 72 | Tool measureTool("Measure", QIcon(":/light_krita_tool_measure.svg")); 73 | Tool referenceImagesTool("Reference Images", QIcon(":/light_krita_tool_reference_images.svg")); 74 | Tool perspectiveGridTool("Perpective Grid", QIcon(":/light_tool_perspectivegrid.svg")); 75 | assitantTool.addSubTool(gridTool); 76 | assitantTool.addSubTool(measureTool); 77 | assitantTool.addSubTool(referenceImagesTool); 78 | assitantTool.addSubTool(perspectiveGridTool); 79 | 80 | Tool zoomTool("Zoom", QIcon(":/light_tool_zoom.svg")); 81 | Tool panTool("Pan", QIcon(":/light_tool_pan.svg")); 82 | zoomTool.addSubTool(panTool); 83 | 84 | ToolBox *tb = ui->widget; 85 | tb->addTool(transformTool); 86 | tb->addBreak(); 87 | 88 | tb->addTool(rectangularMarqueeTool); 89 | tb->addTool(lassoTool); 90 | tb->addTool(similarSelectionTool); 91 | tb->addBreak(); 92 | 93 | tb->addTool(cropTool); 94 | tb->addBreak(); 95 | 96 | tb->addTool(fillTool); 97 | tb->addBreak(); 98 | 99 | tb->addTool(brushTool); 100 | tb->addBreak(); 101 | 102 | tb->addTool(rectangleTool); 103 | tb->addTool(textTool); 104 | tb->addTool(shapeSelectTool); 105 | tb->addBreak(); 106 | 107 | tb->addTool(assitantTool); 108 | tb->addBreak(); 109 | 110 | tb->addTool(zoomTool); 111 | tb->addBreak(); 112 | 113 | } 114 | 115 | MainWindow::~MainWindow() 116 | { 117 | delete ui; 118 | } 119 | 120 | -------------------------------------------------------------------------------- /icons/light_krita_tool_dyna.svg: -------------------------------------------------------------------------------- 1 | 2 | 13 | 15 | 17 | 18 | 20 | image/svg+xml 21 | 23 | 24 | 25 | 26 | Andrei Rudenko 27 | 28 | 29 | 31 | 32 | 34 | 36 | 38 | 40 | 42 | 44 | 46 | 47 | 48 | 49 | 57 | 71 | 74 | 78 | 84 | 85 | 86 | -------------------------------------------------------------------------------- /icons/light_tool_path_selection.svg: -------------------------------------------------------------------------------- 1 | 2 | 13 | 15 | 17 | 18 | 20 | image/svg+xml 21 | 23 | 24 | 25 | 26 | Andrei Rudenko 27 | 28 | 29 | 31 | 32 | 34 | 36 | 38 | 40 | 42 | 44 | 46 | 47 | 48 | 49 | 52 | 61 | 71 | 81 | 82 | 85 | 89 | 93 | 97 | 101 | 105 | 109 | 113 | 114 | 115 | -------------------------------------------------------------------------------- /icons/light_krita_tool_reference_images.svg: -------------------------------------------------------------------------------- 1 | 2 | 13 | 15 | 17 | 18 | 20 | image/svg+xml 21 | 23 | 24 | 25 | 26 | Andrei Rudenko 27 | 28 | 29 | 31 | 32 | 34 | 36 | 38 | 40 | 42 | 44 | 46 | 47 | 48 | 49 | 69 | 89 | 92 | 96 | 97 | 98 | -------------------------------------------------------------------------------- /icons/light_krita_draw_path.svg: -------------------------------------------------------------------------------- 1 | 2 | 13 | 15 | 17 | 18 | 20 | image/svg+xml 21 | 23 | 24 | 25 | 26 | Andrei Rudenko 27 | 28 | 29 | 31 | 32 | 34 | 36 | 38 | 40 | 42 | 44 | 46 | 47 | 48 | 49 | 90 | 92 | 99 | 100 | 103 | 107 | 111 | 115 | 119 | 123 | 124 | 125 | -------------------------------------------------------------------------------- /icons/light_tool_magnetic_selection.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 22 | 24 | 28 | 33 | 39 | 44 | 49 | 55 | 56 | 60 | 65 | 71 | 76 | 81 | 87 | 88 | 89 | 113 | 127 | 128 | 130 | 131 | 133 | image/svg+xml 134 | 136 | 137 | 138 | 139 | Andrei Rudenko 140 | 141 | 142 | 143 | 144 | 145 | 150 | 156 | 157 | 161 | 168 | 169 | 170 | -------------------------------------------------------------------------------- /icons/light_shape_handling.svg: -------------------------------------------------------------------------------- 1 | 2 | 13 | 15 | 17 | 18 | 20 | image/svg+xml 21 | 23 | 24 | 25 | 26 | Andrei Rudenko 27 | 28 | 29 | 31 | 32 | 34 | 36 | 38 | 40 | 42 | 44 | 46 | 47 | 48 | 49 | 69 | 89 | 92 | 96 | 100 | 107 | 114 | 121 | 122 | 123 | -------------------------------------------------------------------------------- /icons/light_tool_outline_selection.svg: -------------------------------------------------------------------------------- 1 | 2 | 13 | 15 | 17 | 18 | 20 | image/svg+xml 21 | 23 | 24 | 25 | 26 | Andrei Rudenko 27 | 28 | 29 | 31 | 32 | 34 | 36 | 38 | 40 | 42 | 44 | 46 | 47 | 48 | 49 | 52 | 56 | 60 | 64 | 68 | 72 | 76 | 80 | 84 | 88 | 92 | 96 | 100 | 104 | 108 | 112 | 116 | 117 | 118 | -------------------------------------------------------------------------------- /icons/light_krita_tool_multihand.svg: -------------------------------------------------------------------------------- 1 | 2 | 13 | 15 | 17 | 18 | 20 | image/svg+xml 21 | 23 | 24 | 25 | 26 | Andrei Rudenko 27 | 28 | 29 | 31 | 32 | 34 | 36 | 38 | 40 | 42 | 44 | 46 | 47 | 48 | 49 | 69 | 72 | 76 | 79 | 83 | 87 | 91 | 92 | 96 | 100 | 104 | 108 | 109 | 113 | 117 | 121 | 125 | 126 | 127 | 128 | -------------------------------------------------------------------------------- /toolbox.cc: -------------------------------------------------------------------------------- 1 | #include "toolbox.h" 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | ToolBox::ToolBox(QWidget *parent) : 8 | QWidget(parent), m_activated(-1), m_padding(10), m_subToolActivated(-1), m_buttonSize(40, 40), 9 | m_longPressed(false), m_toolBoxHandlePressed(false), m_toolBoxOrientation(Vertical), 10 | m_subToolsOrientation(Right), m_rowMode(Single), m_toolBoxState(Locked) 11 | { 12 | setWindowFlags(Qt::Widget | Qt::FramelessWindowHint); 13 | setAttribute(Qt::WA_NoSystemBackground, true); 14 | setAttribute(Qt::WA_TranslucentBackground, true); 15 | m_timer.setInterval(1000); 16 | m_timer.setSingleShot(true); 17 | 18 | connect(&m_timer, &QTimer::timeout, this, &ToolBox::longPressEvent); 19 | setMouseTracking(true); 20 | setContextMenuPolicy(Qt::CustomContextMenu); 21 | connect(this, &QWidget::customContextMenuRequested, this, &ToolBox::showContextMenu); 22 | 23 | m_contextMenu = new QMenu(this); 24 | m_unlockAction = new QAction("Unlock ToolBox", this); 25 | m_contextMenu->addAction(m_unlockAction); 26 | connect(m_unlockAction, &QAction::triggered, this, &ToolBox::slotUnlockToolBox); 27 | 28 | m_rotateAction = new QAction("Rotate ToolBox", this); 29 | m_contextMenu->addAction(m_rotateAction); 30 | connect(m_rotateAction, &QAction::triggered, this, &ToolBox::slotRotateToolBox); 31 | 32 | m_rowModeAction = new QAction("Change Row Mode", this); 33 | m_contextMenu->addAction(m_rowModeAction); 34 | connect(m_rowModeAction, &QAction::triggered, this, &ToolBox::slotChangeRowMode); 35 | 36 | m_flipAction = new QAction("Flip Sub Tools", this); 37 | m_contextMenu->addAction(m_flipAction); 38 | connect(m_flipAction, &QAction::triggered, this, &ToolBox::slotFlipToolBox); 39 | } 40 | 41 | void ToolBox::paintEvent(QPaintEvent *event) 42 | { 43 | QPainter gc(this); 44 | gc.setRenderHint(QPainter::Antialiasing); 45 | 46 | QPoint tempTopLeft = event->rect().topLeft(); 47 | QColor highlightedBack(86, 128, 194); 48 | QColor back(49, 49, 49); 49 | 50 | if(m_toolBoxState == Unlocked){ 51 | QRect toolBoxHandle = QRect(tempTopLeft, QSize(m_buttonSize.width(), 7)); 52 | gc.fillRect(toolBoxHandle, back); 53 | tempTopLeft += QPoint(0, 9); 54 | } 55 | QPoint topLeft = tempTopLeft; 56 | m_toolRects.clear(); 57 | 58 | for(int i=0; i0){ 61 | count = count - m_breaks[i-1] - 1; 62 | } 63 | int h = m_buttonSize.height() * (count); 64 | QRect backRect(topLeft, QSize(m_buttonSize.width(), h)); 65 | QPainterPath p; 66 | p.addRoundedRect(backRect, 3, 3); 67 | gc.fillPath(p, back); 68 | topLeft += QPoint(0, 2+h); 69 | } 70 | 71 | int breakCount = 0; 72 | topLeft = tempTopLeft; 73 | 74 | for(int i=0;i tools = m_tools[m_activated].subTools(); 106 | m_secondaryTools.clear(); 107 | 108 | if(!tools.isEmpty()){ 109 | subTopLeft = QPoint(m_toolRects[m_activated].topRight()); 110 | for(int i=0; i topLeft.y()){ 133 | h = subTopLeft.y() + m_buttonSize.height() + 2; 134 | } 135 | } 136 | 137 | resize(w, h); 138 | } 139 | 140 | void ToolBox::addTool(Tool t) 141 | { 142 | m_tools.push_back(t); 143 | } 144 | 145 | void ToolBox::addBreak() 146 | { 147 | m_breaks.push_back(m_tools.count()-1); 148 | } 149 | 150 | void ToolBox::mousePressEvent(QMouseEvent *event) 151 | { 152 | QPoint pos = event->pos(); 153 | m_lastMousePos = pos; 154 | 155 | if(event->button() != Qt::LeftButton) 156 | return; 157 | 158 | if(m_toolBoxState == Unlocked){ 159 | m_toolBoxHandlePressed = true; 160 | return; 161 | } 162 | 163 | for(int i=0; ipos(); 176 | 177 | if(m_toolBoxState == Unlocked){ 178 | setCursor(Qt::OpenHandCursor); 179 | if(m_toolBoxHandlePressed){ 180 | move(mapToParent(event->pos() - m_lastMousePos)); 181 | setCursor(Qt::ClosedHandCursor); 182 | return; 183 | } 184 | }else{ 185 | setCursor(Qt::ArrowCursor); 186 | } 187 | 188 | if(m_longPressed) { 189 | for(int i=0; i= 0){ 207 | m_tools[m_activated].swap(m_subToolActivated); 208 | } 209 | m_timer.stop(); 210 | m_subToolActivated = -1; 211 | m_toolBoxHandlePressed = false; 212 | update(); 213 | setCursor(Qt::ArrowCursor); 214 | } 215 | 216 | void ToolBox::longPressEvent() 217 | { 218 | m_longPressed = true && !m_toolBoxHandlePressed; 219 | update(); 220 | } 221 | 222 | void ToolBox::showContextMenu(QPoint pos) 223 | { 224 | m_contextMenu->exec(mapToGlobal(pos)); 225 | } 226 | 227 | void ToolBox::slotChangeRowMode() 228 | { 229 | if(m_rowMode == Single){ 230 | m_rowMode = Double; 231 | m_flipAction->setEnabled(false); 232 | }else{ 233 | m_rowMode = Single; 234 | m_flipAction->setEnabled(true); 235 | } 236 | update(); 237 | } 238 | 239 | void ToolBox::slotRotateToolBox() 240 | { 241 | if(m_toolBoxOrientation == Horizontal){ 242 | m_toolBoxOrientation = Vertical; 243 | }else{ 244 | m_toolBoxOrientation = Horizontal; 245 | } 246 | update(); 247 | } 248 | 249 | void ToolBox::slotUnlockToolBox() 250 | { 251 | if(m_toolBoxState == Locked){ 252 | m_toolBoxState = Unlocked; 253 | }else{ 254 | m_toolBoxState = Locked; 255 | } 256 | m_subToolActivated = -1; 257 | update(); 258 | } 259 | 260 | void ToolBox::slotFlipToolBox() 261 | { 262 | if(m_subToolsOrientation == Left){ 263 | m_subToolsOrientation = Right; 264 | }else{ 265 | m_subToolsOrientation = Left; 266 | } 267 | update(); 268 | } 269 | -------------------------------------------------------------------------------- /icons/light_krita_tool_lazybrush.svg: -------------------------------------------------------------------------------- 1 | 2 | 13 | 15 | 17 | 18 | 20 | image/svg+xml 21 | 23 | 24 | 25 | 26 | Timothée Giet 27 | 28 | 29 | 2016 30 | 32 | 33 | 35 | 37 | 39 | 41 | 43 | 45 | 47 | 48 | 49 | 50 | 71 | 75 | 79 | 83 | 87 | 91 | 95 | 99 | 103 | 107 | 111 | 115 | 119 | 123 | 127 | 128 | 129 | -------------------------------------------------------------------------------- /icons/light_krita_tool_freehandvector.svg: -------------------------------------------------------------------------------- 1 | 2 | 13 | 15 | 17 | 18 | 20 | image/svg+xml 21 | 23 | 24 | 25 | 26 | Andrei Rudenko 27 | 28 | 29 | 31 | 32 | 34 | 36 | 38 | 40 | 42 | 44 | 46 | 47 | 48 | 49 | 73 | 76 | 80 | 84 | 88 | 92 | 93 | 113 | 133 | 134 | -------------------------------------------------------------------------------- /icons/light_tool_polygonal_selection.svg: -------------------------------------------------------------------------------- 1 | 2 | 13 | 15 | 17 | 18 | 20 | image/svg+xml 21 | 23 | 24 | 25 | 26 | Andrei Rudenko 27 | 28 | 29 | 31 | 32 | 34 | 36 | 38 | 40 | 42 | 44 | 46 | 47 | 48 | 49 | 125 | 128 | 132 | 136 | 140 | 144 | 148 | 152 | 156 | 160 | 164 | 168 | 172 | 176 | 180 | 184 | 188 | 192 | 193 | 194 | -------------------------------------------------------------------------------- /icons/light_polyline.svg: -------------------------------------------------------------------------------- 1 | 2 | 14 | 16 | 18 | 19 | 21 | image/svg+xml 22 | 24 | 25 | 26 | 27 | Andrei Rudenko 28 | 29 | 30 | 32 | 33 | 35 | 37 | 39 | 41 | 43 | 45 | 47 | 48 | 49 | 50 | 58 | 190 | 193 | 197 | 198 | 211 | 212 | -------------------------------------------------------------------------------- /icons/light_format-fill-color.svg: -------------------------------------------------------------------------------- 1 | 2 | 14 | 16 | 18 | 22 | 26 | 27 | 29 | 33 | 37 | 38 | 46 | 48 | 52 | 56 | 57 | 65 | 73 | 81 | 89 | 97 | 98 | 100 | 101 | 103 | image/svg+xml 104 | 106 | 107 | 108 | 109 | Andrei Rudenko 110 | 111 | 112 | 114 | 115 | 117 | 119 | 121 | 123 | 125 | 127 | 129 | 130 | 131 | 132 | 144 | 173 | 176 | 200 | 220 | 280 | 282 | 286 | 295 | 304 | 308 | 318 | 328 | 332 | 336 | 340 | 341 | 342 | --------------------------------------------------------------------------------