├── .directory ├── .gitignore ├── LICENSE ├── README.md ├── Rocket ├── Rocket.pro ├── Rocket.pro.user ├── Rocket.user ├── icongrid │ ├── icongrid.cpp │ ├── icongrid.h │ ├── icongriditem.cpp │ ├── icongriditem.h │ ├── icongriditemcanvas.cpp │ └── icongriditemcanvas.h ├── main.cpp ├── mainwindow.cpp ├── mainwindow.h ├── mainwindow.ui ├── pager │ ├── horizontalpager.cpp │ ├── horizontalpager.h │ ├── pager.cpp │ ├── pager.h │ ├── pagercircularactiveindicator.cpp │ ├── pagercircularactiveindicator.h │ ├── pagercircularindicator.cpp │ ├── pagercircularindicator.h │ ├── pagerfolderview.cpp │ ├── pagerfolderview.h │ ├── pageritem.cpp │ ├── pageritem.h │ ├── verticalpager.cpp │ └── verticalpager.h ├── searchfield │ ├── searchfield.cpp │ └── searchfield.h └── tools │ ├── searchingapps.cpp │ └── searchingapps.h ├── RocketDesigner ├── RocketDesigner.pro ├── RocketDesigner.pro.user ├── main.cpp ├── mainwindow.cpp ├── mainwindow.h └── mainwindow.ui ├── RocketLibrary ├── RocketLibrary.pro ├── RocketLibrary.pro.user ├── rocketlibrary.cpp ├── rocketlibrary.h └── tools │ ├── kdeapplication.cpp │ ├── kdeapplication.h │ ├── kmenuitems.cpp │ ├── kmenuitems.h │ ├── rocketconfigmanager.cpp │ └── rocketconfigmanager.h └── screenshots ├── rocket_designer.png ├── screenshot.jpeg ├── screenshot_dark.jpeg ├── screenshot_large_grid_noboxes.jpeg ├── screenshot_search.jpeg └── vertical_scrolling.jpg /.directory: -------------------------------------------------------------------------------- 1 | [Dolphin] 2 | Timestamp=2021,4,6,14,10,49 3 | Version=4 4 | 5 | [Settings] 6 | HiddenFilesShown=true 7 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | build-Rocket-Desktop-Debug/* 2 | RocketDesigner/build-RocketDesigner-Desktop-Debug/* 3 | installer/* 4 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Rocket 2 | 3 | **Rocket** is an application launcher for KDE Plasma. It sorts all of your applications in a horizontal or vertical grid alphabetically, so you will always find what you are looking for at first glance. No more menu navigation, only scrolling. 4 | 5 | Features: 6 | - Customizable row and column sizes 7 | - Theming 8 | - Search for keywords (such as "file manager") 9 | - Scroll support for touchpad, mouse and the mouse wheel 10 | - Keyboard navigation 11 | - Launch by pressing the Meta button 12 | 13 | For more information check out the **wiki** and the **release notes**. 14 | 15 | # Installation 16 | 17 | Rocket has been tested on Kubuntu and on Debian, but it should also work on any platform with KDE installed. 18 | 19 | ## Release Version 20 | 21 | For the most recent release version download the zipped file containing all the binaries and icons from the [KDE Store](https://store.kde.org/p/1507169/) and install Rocket by making the bash script ```installer.sh``` executable via ```chmod +x installer.sh``` and by running it with ```./installer.sh```. 22 | 23 | ## Git Version 24 | 25 | Rocket uses Qt and KDE Plasma libraries to commununicate with the environment. If you would like to download Rocket and to test the most recent dev version, clone this repository and compile the code using 26 | 27 | ```qmake && make``` 28 | 29 | # Screenshot Gallery 30 | 31 | ## Default view 32 | ![Alt text](/screenshots/screenshot.jpeg?raw=true "") 33 | 34 | ## Dark Theme 35 | ![Alt text](/screenshots/screenshot_dark.jpeg?raw=true "") 36 | 37 | ## Searching 38 | ![Alt text](/screenshots/screenshot_search.jpeg?raw=true "") 39 | 40 | ## Custom Grid (Boxes Disabled, Blurred Background, Vertical Grid and more Icons) 41 | ![Alt text](/screenshots/screenshot_large_grid_noboxes.jpeg?raw=true "") 42 | 43 | ## Rocket Designer, the Customization Tool 44 | ![Alt text](/screenshots/rocket_designer.png?raw=true "") 45 | 46 | ------------------------------------------- 47 | \* Disclaimer: I'm not a professional developer, but it works on my configuration perfectly, and I love it. However, on your custom environment, you might experience unwanted bugs -- feel free to fork and to contribute. 48 | This software does not contain any code which messes with your base system, so if it does not work for you, it's easy to uninstall -- just follow the instructions in the release notes. 49 | 50 | Rocket's icon was taken from the [OpenMoji](https://openmoji.org/) library. 51 | -------------------------------------------------------------------------------- /Rocket/Rocket.pro: -------------------------------------------------------------------------------- 1 | #------------------------------------------------- 2 | # 3 | # Project created by QtCreator 2021-04-04T22:20:17 4 | # 5 | #------------------------------------------------- 6 | 7 | QT += core gui KIOCore KIOFileWidgets KIOWidgets KNTLM KI18n KConfigCore KConfigGui KWindowSystem KCoreAddons KJobWidgets KGuiAddons 8 | 9 | greaterThan(QT_MAJOR_VERSION, 4): QT += widgets 10 | 11 | TARGET = Rocket 12 | TEMPLATE = app 13 | 14 | # The following define makes your compiler emit warnings if you use 15 | # any feature of Qt which has been marked as deprecated (the exact warnings 16 | # depend on your compiler). Please consult the documentation of the 17 | # deprecated API in order to know how to port your code away from it. 18 | DEFINES += QT_DEPRECATED_WARNINGS 19 | 20 | # You can also make your code fail to compile if you use deprecated APIs. 21 | # In order to do so, uncomment the following line. 22 | # You can also select to disable deprecated APIs only up to a certain version of Qt. 23 | #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 24 | 25 | CONFIG += c++11 26 | 27 | SOURCES += \ 28 | main.cpp \ 29 | mainwindow.cpp \ 30 | pager/horizontalpager.cpp \ 31 | pager/pager.cpp \ 32 | pager/pageritem.cpp \ 33 | pager/pagercircularindicator.cpp \ 34 | pager/pagercircularactiveindicator.cpp \ 35 | icongrid/icongrid.cpp \ 36 | icongrid/icongriditem.cpp \ 37 | icongrid/icongriditemcanvas.cpp \ 38 | searchfield/searchfield.cpp \ 39 | tools/searchingapps.cpp \ 40 | pager/verticalpager.cpp \ 41 | ../RocketLibrary/rocketlibrary.cpp \ 42 | ../RocketLibrary/tools/rocketconfigmanager.cpp \ 43 | ../RocketLibrary/tools/kmenuitems.cpp \ 44 | ../RocketLibrary/tools/kdeapplication.cpp \ 45 | pager/pagerfolderview.cpp 46 | 47 | HEADERS += \ 48 | mainwindow.h \ 49 | pager/horizontalpager.h \ 50 | pager/pager.h \ 51 | pager/pageritem.h \ 52 | pager/pagercircularindicator.h \ 53 | pager/pagercircularactiveindicator.h \ 54 | icongrid/icongrid.h \ 55 | icongrid/icongriditem.h \ 56 | icongrid/icongriditemcanvas.h \ 57 | searchfield/searchfield.h \ 58 | tools/searchingapps.h \ 59 | pager/verticalpager.h \ 60 | ../RocketLibrary/rocketlibrary.h \ 61 | ../RocketLibrary/tools/rocketconfigmanager.h \ 62 | ../RocketLibrary/tools/kmenuitems.h \ 63 | ../RocketLibrary/tools/kdeapplication.h \ 64 | pager/pagerfolderview.h 65 | 66 | FORMS += \ 67 | mainwindow.ui 68 | 69 | # Default rules for deployment. 70 | qnx: target.path = /tmp/$${TARGET}/bin 71 | else: unix:!android: target.path = /opt/$${TARGET}/bin 72 | !isEmpty(target.path): INSTALLS += target 73 | 74 | SUBDIRS += \ 75 | ../RocketLibrary/RocketLibrary.pro 76 | -------------------------------------------------------------------------------- /Rocket/Rocket.pro.user: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | EnvironmentId 7 | {d0801bd6-9ed6-4b96-abb9-eb8da168ac52} 8 | 9 | 10 | ProjectExplorer.Project.ActiveTarget 11 | 0 12 | 13 | 14 | ProjectExplorer.Project.EditorSettings 15 | 16 | true 17 | false 18 | true 19 | 20 | Cpp 21 | 22 | CppGlobal 23 | 24 | 25 | 26 | QmlJS 27 | 28 | QmlJSGlobal 29 | 30 | 31 | 2 32 | UTF-8 33 | false 34 | 4 35 | false 36 | 80 37 | true 38 | true 39 | 1 40 | true 41 | false 42 | 0 43 | true 44 | true 45 | 0 46 | 8 47 | true 48 | 1 49 | true 50 | true 51 | true 52 | *.md, *.MD, Makefile 53 | false 54 | true 55 | 56 | 57 | 58 | ProjectExplorer.Project.PluginSettings 59 | 60 | 61 | true 62 | true 63 | true 64 | true 65 | true 66 | 67 | 68 | 0 69 | true 70 | 71 | true 72 | Builtin.Questionable 73 | 74 | true 75 | true 76 | Builtin.DefaultTidyAndClazy 77 | 2 78 | 79 | 80 | 81 | true 82 | 83 | 84 | 85 | 86 | ProjectExplorer.Project.Target.0 87 | 88 | Desktop 89 | Desktop 90 | Desktop 91 | {4af44187-b292-4eeb-a6a4-639659626ffe} 92 | 0 93 | 0 94 | 0 95 | 96 | 0 97 | /home/mate/Documents/experiments/qt/Rocket/build-Rocket-Desktop-Debug 98 | /home/mate/Documents/experiments/qt/Rocket/build-Rocket-Desktop-Debug 99 | 100 | 101 | true 102 | QtProjectManager.QMakeBuildStep 103 | 104 | false 105 | 106 | 107 | 108 | true 109 | Qt4ProjectManager.MakeStep 110 | 111 | 2 112 | Build 113 | Build 114 | ProjectExplorer.BuildSteps.Build 115 | 116 | 117 | 118 | true 119 | Qt4ProjectManager.MakeStep 120 | clean 121 | 122 | 1 123 | Clean 124 | Clean 125 | ProjectExplorer.BuildSteps.Clean 126 | 127 | 2 128 | false 129 | 130 | 131 | Debug 132 | Qt4ProjectManager.Qt4BuildConfiguration 133 | 2 134 | 0 135 | 136 | 137 | /home/mate/Documents/experiments/qt/Rocket/build-Rocket-Desktop-Release 138 | /home/mate/Documents/experiments/qt/Rocket/build-Rocket-Desktop-Release 139 | 140 | 141 | true 142 | QtProjectManager.QMakeBuildStep 143 | 144 | false 145 | 146 | 147 | 148 | true 149 | Qt4ProjectManager.MakeStep 150 | 151 | 2 152 | Build 153 | Build 154 | ProjectExplorer.BuildSteps.Build 155 | 156 | 157 | 158 | true 159 | Qt4ProjectManager.MakeStep 160 | clean 161 | 162 | 1 163 | Clean 164 | Clean 165 | ProjectExplorer.BuildSteps.Clean 166 | 167 | 2 168 | false 169 | 170 | 171 | Release 172 | Qt4ProjectManager.Qt4BuildConfiguration 173 | 0 174 | 0 175 | 176 | 177 | 0 178 | /home/mate/Documents/experiments/qt/Rocket/build-Rocket-Desktop-Profile 179 | /home/mate/Documents/experiments/qt/Rocket/build-Rocket-Desktop-Profile 180 | 181 | 182 | true 183 | QtProjectManager.QMakeBuildStep 184 | 185 | false 186 | 187 | 188 | 189 | true 190 | Qt4ProjectManager.MakeStep 191 | 192 | 2 193 | Build 194 | Build 195 | ProjectExplorer.BuildSteps.Build 196 | 197 | 198 | 199 | true 200 | Qt4ProjectManager.MakeStep 201 | clean 202 | 203 | 1 204 | Clean 205 | Clean 206 | ProjectExplorer.BuildSteps.Clean 207 | 208 | 2 209 | false 210 | 211 | 212 | Profile 213 | Qt4ProjectManager.Qt4BuildConfiguration 214 | 0 215 | 0 216 | 0 217 | 218 | 3 219 | 220 | 221 | 0 222 | Deploy 223 | Deploy 224 | ProjectExplorer.BuildSteps.Deploy 225 | 226 | 1 227 | 228 | false 229 | ProjectExplorer.DefaultDeployConfiguration 230 | 231 | 1 232 | 233 | dwarf 234 | 235 | cpu-cycles 236 | 237 | 238 | 250 239 | 240 | -e 241 | cpu-cycles 242 | --call-graph 243 | dwarf,4096 244 | -F 245 | 250 246 | 247 | -F 248 | true 249 | 4096 250 | false 251 | false 252 | 1000 253 | 254 | true 255 | 256 | false 257 | false 258 | false 259 | false 260 | true 261 | 0.01 262 | 10 263 | true 264 | kcachegrind 265 | 1 266 | 25 267 | 268 | 1 269 | true 270 | false 271 | true 272 | valgrind 273 | 274 | 0 275 | 1 276 | 2 277 | 3 278 | 4 279 | 5 280 | 6 281 | 7 282 | 8 283 | 9 284 | 10 285 | 11 286 | 12 287 | 13 288 | 14 289 | 290 | 291 | 2 292 | 293 | Qt4ProjectManager.Qt4RunConfiguration:/home/mate/Documents/experiments/qt/Rocket/Rocket/Rocket.pro 294 | /home/mate/Documents/experiments/qt/Rocket/Rocket/Rocket.pro 295 | false 296 | true 297 | true 298 | false 299 | true 300 | /home/mate/Documents/experiments/qt/Rocket/build-Rocket-Desktop-Debug 301 | 302 | 1 303 | 304 | 305 | 306 | ProjectExplorer.Project.TargetCount 307 | 1 308 | 309 | 310 | ProjectExplorer.Project.Updater.FileVersion 311 | 22 312 | 313 | 314 | Version 315 | 22 316 | 317 | 318 | -------------------------------------------------------------------------------- /Rocket/icongrid/icongrid.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #include "icongrid.h" 7 | 8 | #include "../RocketLibrary/tools/rocketconfigmanager.h" 9 | 10 | IconGrid::IconGrid(QWidget * parent) : QWidget (parent) 11 | { 12 | m_layout = new QGridLayout(); 13 | m_layout->setAlignment(Qt::AlignCenter); 14 | m_layout->setMargin(10); 15 | m_layout->setSpacing(0); 16 | setLayout(m_layout); 17 | setMouseTracking(true); 18 | } 19 | 20 | void IconGrid::addItem(IconGridItem * item) 21 | { 22 | int column_position = getNumberOfItems()%getMaxNumberOfColumns(); 23 | int row_position = (int)getNumberOfItems()/getMaxNumberOfColumns(); 24 | m_layout->addWidget(item,row_position,column_position,Qt::AlignCenter); 25 | m_items.push_back(item); 26 | } 27 | 28 | 29 | void IconGrid::setActiveElement(int element) 30 | { 31 | int delta = element-m_active_element; 32 | // Vertical Mode Behaviour 33 | if (ConfigManager.getVerticalModeSetting()) 34 | { 35 | if (delta == m_cols) //Key_Down 36 | { 37 | if ((int)(m_active_element/m_cols) == m_rows-1) //Last Row, Vertical Mode 38 | { 39 | goToPage(1); 40 | return; 41 | } 42 | } 43 | if (delta == -m_cols) //Key_Up 44 | { 45 | if ((int)(m_active_element/m_cols) == 0) //First Column, Vertical Mode 46 | { 47 | goToPage(-1); 48 | return; 49 | } 50 | } 51 | } 52 | // Horizontal Mode Behaviour 53 | if (!ConfigManager.getVerticalModeSetting()) 54 | { 55 | if (delta == 1) //Key_Right 56 | { 57 | if (m_active_element % m_cols == m_cols-1) //Last Column, Horizontal Mode 58 | { 59 | goToPage(1); 60 | return; 61 | } 62 | } 63 | if (delta == -1) //Key_Left 64 | { 65 | if (m_active_element % m_cols == 0) //First Column, Horizontal Mode 66 | { 67 | goToPage(-1); 68 | return; 69 | } 70 | } 71 | } 72 | 73 | if (element>=0 && element<=(int)getItems().size()-1) 74 | { 75 | m_active_element = element; 76 | } 77 | } 78 | 79 | 80 | void IconGrid::unhighlightAll() 81 | { 82 | for (IconGridItem * i : getItems()) 83 | { 84 | i->setHighlighted(false); 85 | i->update(); 86 | } 87 | } 88 | 89 | void IconGrid::highlight(int element) 90 | { 91 | m_active_element = element; 92 | getItems()[element]->setHighlighted(true); 93 | getItems()[element]->update(); 94 | } 95 | 96 | void IconGrid::resetHighlightAndActiveElement() 97 | { 98 | unhighlightAll(); 99 | m_active_element = -1; 100 | } 101 | 102 | void IconGrid::paintEvent(QPaintEvent *event) 103 | { 104 | if (getItems().size()==0) return; // search yielded no results -> no drawing 105 | QPainter painter(this); 106 | if (ConfigManager.getBoxSetting()) // no boxes -> global blur 107 | { 108 | QColor color = ConfigManager.getBaseColour(); 109 | painter.setBrush(QBrush(color,Qt::BrushStyle::SolidPattern)); 110 | painter.setPen(Qt::transparent); 111 | painter.drawRoundedRect(0,0,width(),height(),30,30); 112 | } 113 | } 114 | 115 | void IconGrid::mouseMoveEvent(QMouseEvent *event) 116 | { 117 | event->ignore(); 118 | } 119 | 120 | IconGrid::~IconGrid() 121 | { 122 | 123 | } 124 | -------------------------------------------------------------------------------- /Rocket/icongrid/icongrid.h: -------------------------------------------------------------------------------- 1 | #ifndef ICONGRID_H 2 | #define ICONGRID_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | #include "icongriditem.h" 9 | 10 | #include "../RocketLibrary/tools/rocketconfigmanager.h" 11 | 12 | class IconGrid : public QWidget 13 | { 14 | Q_OBJECT 15 | public: 16 | explicit IconGrid(QWidget * parent); 17 | //explicit IconGrid(QWidget * parent, int rows, int columns); 18 | ~IconGrid(); 19 | void paintEvent(QPaintEvent *event); 20 | void mouseMoveEvent(QMouseEvent *event); 21 | 22 | int getMaxNumberOfRows() {return m_rows;} 23 | int getMaxNumberOfColumns() {return m_cols;} 24 | int getNumberOfItems() {return m_items.size();} 25 | int getCurrentNumberOfRows(){ 26 | return getNumberOfItems()/getMaxNumberOfColumns()+(getNumberOfItems()%getMaxNumberOfColumns()>0 ? 1 : 0);} 27 | int getCurrentNumberOfColumns() { 28 | return getNumberOfItems()>=getMaxNumberOfColumns() ? getMaxNumberOfColumns() : getNumberOfItems();} 29 | void setMaxNumberOfRows(int row) {m_rows = row;} 30 | void setMaxNumberOfColumns(int cols) {m_cols = cols;} 31 | void addItem(IconGridItem * item); 32 | 33 | QGridLayout * getLayout(){return m_layout;} 34 | int getActiveElement(){return m_active_element;} 35 | void setActiveElement(int element); 36 | void unhighlightAll(); 37 | void highlight(int element); 38 | void resetHighlightAndActiveElement(); 39 | 40 | std::vector getItems(){return m_items;} 41 | void setItems(std::vector items){m_items=items;} 42 | 43 | signals: 44 | void goToPage(int deltaPage); 45 | 46 | private: 47 | // Vector of all items 48 | std::vector m_items; 49 | 50 | // Maximum Number of Rows and Columns 51 | int m_rows = ConfigManager.getRowNumber(); 52 | int m_cols = ConfigManager.getColumnNumber(); 53 | int m_active_element = -1; 54 | 55 | QGridLayout * m_layout; 56 | }; 57 | 58 | #endif // ICONGRID_H 59 | -------------------------------------------------------------------------------- /Rocket/icongrid/icongriditem.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | #include "icongriditem.h" 11 | #include "icongriditemcanvas.h" 12 | 13 | #include "../RocketLibrary/tools/rocketconfigmanager.h" 14 | 15 | 16 | IconGridItem::IconGridItem(QWidget *parent, KDEApplication application, QSize itemsize) : QWidget(parent) 17 | { 18 | m_application = application; 19 | m_icon = application.icon(); 20 | m_label = application.name(); 21 | m_item_size = itemsize; 22 | setFixedSize(m_item_size); 23 | setMouseTracking(true); 24 | 25 | // QPalette p; 26 | // setAutoFillBackground(true); 27 | // p.setColor(QPalette::ColorRole::Background,Qt::green); 28 | // setPalette(p); 29 | 30 | setLayout(m_layout); 31 | 32 | m_canvas = new IconGridItemCanvas(this,application); 33 | 34 | m_name_label = new QLabel(m_label,this); 35 | QFont label_font = m_name_label->font(); 36 | label_font.setPointSize(ConfigManager.getFontSize1()); 37 | m_name_label->setMaximumWidth(m_item_size.width()); 38 | m_name_label->setFont(label_font); 39 | m_name_label->setWordWrap(true); 40 | m_name_label->setAlignment(Qt::AlignCenter); 41 | m_name_label->setGeometry(0,0,m_item_size.width(),10); 42 | m_name_label->setMouseTracking(true); 43 | m_layout->addWidget(m_name_label,1,0); 44 | 45 | m_layout->addWidget(m_canvas,0,0); 46 | m_layout->setRowStretch(1,m_ratio_rows[1]); 47 | m_layout->setRowStretch(0,m_ratio_rows[0]); 48 | 49 | // QPalette p2; 50 | // m_name_label->setAutoFillBackground(true); 51 | // p2.setColor(QPalette::ColorRole::Background,Qt::cyan); 52 | // m_name_label->setPalette(p2); 53 | } 54 | 55 | 56 | void IconGridItem::paintEvent(QPaintEvent *event) 57 | { 58 | QPainter painter(this); 59 | if(m_highlighted) 60 | { 61 | painter.setBrush(QBrush(ConfigManager.getSelectionColour(),Qt::BrushStyle::SolidPattern)); 62 | painter.setPen(Qt::transparent); 63 | painter.drawRoundedRect(0,0,width()*0.99,height()*0.99,15,15); 64 | } 65 | } 66 | 67 | void IconGridItem::mouseMoveEvent(QMouseEvent *event) 68 | { 69 | event->ignore(); 70 | } 71 | 72 | IconGridItem::~IconGridItem() 73 | { 74 | 75 | } 76 | 77 | 78 | 79 | -------------------------------------------------------------------------------- /Rocket/icongrid/icongriditem.h: -------------------------------------------------------------------------------- 1 | #ifndef ICONGRIDITEM_H 2 | #define ICONGRIDITEM_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | #include "icongriditemcanvas.h" 12 | 13 | #include "../RocketLibrary/rocketlibrary.h" 14 | #include "../RocketLibrary/tools/kdeapplication.h" 15 | 16 | class IconGridItem : public QWidget 17 | { 18 | Q_OBJECT 19 | public: 20 | explicit IconGridItem(QWidget *parent, KDEApplication application, QSize itemsize); 21 | void mouseMoveEvent(QMouseEvent * event); 22 | void paintEvent(QPaintEvent *event); 23 | void initIconSize(); 24 | ~IconGridItem(); 25 | 26 | void setHighlighted(bool highlighted){m_highlighted = highlighted;} 27 | void setItemSize(QSize size) {m_item_size = size;} 28 | QSize getItemSize(){return m_item_size;} 29 | KDEApplication getApplication(){return m_application;} 30 | IconGridItemCanvas * getCanvas(){return m_canvas;} 31 | void setCanvas(IconGridItemCanvas * canvas){m_canvas = canvas;} 32 | QLabel * getNameLabel() {return m_name_label;} 33 | 34 | private: 35 | KDEApplication m_application; 36 | IconGridItemCanvas * m_canvas; 37 | QIcon m_icon = QIcon::fromTheme("file"); 38 | QString m_label = "file"; 39 | QGridLayout * m_layout = new QGridLayout(this); 40 | QLabel * m_name_label; 41 | QPixmap map; 42 | 43 | QSize m_item_size; 44 | std::vector m_ratio_rows = RocketStyle::icongrid_ratio_rows; 45 | bool m_highlighted = false; 46 | }; 47 | 48 | #endif // ICONGRIDITEM_H 49 | -------------------------------------------------------------------------------- /Rocket/icongrid/icongriditemcanvas.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | 19 | #include "icongriditemcanvas.h" 20 | #include "tools/searchingapps.h" 21 | 22 | #include "../RocketLibrary/rocketlibrary.h" 23 | #include "../RocketLibrary/tools/kdeapplication.h" 24 | #include "../RocketLibrary/tools/rocketconfigmanager.h" 25 | 26 | IconGridItemCanvas::IconGridItemCanvas(QWidget *parent, KDEApplication application) 27 | { 28 | m_icon = application.icon(); 29 | m_application = application; 30 | setMouseTracking(true); 31 | setAcceptDrops(true); 32 | 33 | // QPalette p; 34 | // setAutoFillBackground(true); 35 | // p.setColor(QPalette::ColorRole::Background,Qt::cyan); 36 | // setPalette(p); 37 | } 38 | 39 | void IconGridItemCanvas::paintEvent(QPaintEvent*) 40 | { 41 | QPainter painter(this); 42 | int size = std::min({width(),height()}); 43 | int pos_x = (width()-size)/2; 44 | int pos_y = (height()-size)/2; 45 | m_icon = QIcon::fromTheme(m_application.iconname()); 46 | 47 | painter.setViewport(0,0,width(),height()); 48 | 49 | QPixmap qpixmap(size,size); 50 | qpixmap.fill(Qt::transparent); 51 | QPainter qpainter(&qpixmap); 52 | auto drawFolderBackgournd = [=](QPainter & painter) { 53 | m_icon = QIcon::fromTheme(""); 54 | 55 | // pen for folders 56 | QPen pen; 57 | pen.setWidth(2); 58 | pen.setColor(ConfigManager.getSelectionColour().rgb()); 59 | painter.setPen(pen); 60 | 61 | painter.setBrush(QBrush(ConfigManager.getSelectionColour())); 62 | painter.drawRoundedRect(size*0.01,size*0.01,size*0.99,size*0.99,7,7); 63 | }; 64 | 65 | if(m_draw_folder) 66 | { 67 | if (!m_application.isFolder()) 68 | { 69 | drawFolderBackgournd(qpainter); 70 | m_application.icon().paint(&qpainter,size*0.05,size*0.05,size*0.4,size*0.4); 71 | m_icon.addPixmap(qpixmap); 72 | } 73 | else 74 | { 75 | drawFolderBackgournd(qpainter); 76 | for (int i=0;i<(int)m_application.getChildren().size() && i<4;i++) 77 | m_application.getChildren()[i].icon().paint(&qpainter,size*0.05+i%2*size/2,size*0.05+i/2*size/2,size*0.4,size*0.4); 78 | m_icon.addPixmap(qpixmap); 79 | } 80 | } 81 | else { 82 | if (m_application.isFolder()) 83 | { 84 | drawFolderBackgournd(qpainter); 85 | for (int i=0;i<(int)m_application.getChildren().size() && i<4;i++) 86 | m_application.getChildren()[i].icon().paint(&qpainter,size*0.05+i%2*size/2,size*0.05+i/2*size/2,size*0.4,size*0.4); 87 | m_icon.addPixmap(qpixmap); 88 | } 89 | } 90 | 91 | m_icon.paint(&painter,pos_x,pos_y,size,size); 92 | 93 | } 94 | 95 | void IconGridItemCanvas::mousePressEvent(QMouseEvent *event) 96 | { 97 | if (event->button()==Qt::LeftButton) 98 | { 99 | m_clicked = true; 100 | m_pressPos = QCursor::pos(); 101 | m_longclicktimer = new QTimer(); 102 | connect(m_longclicktimer,&QTimer::timeout,this,&IconGridItemCanvas::initIconDragging); 103 | m_longclicktimer->setSingleShot(true); 104 | m_longclicktimer->start(500); 105 | } 106 | event->ignore(); 107 | } 108 | 109 | void IconGridItemCanvas::setDraggable(bool draggable) 110 | { 111 | m_draggable = draggable; 112 | } 113 | 114 | void IconGridItemCanvas::initIconDragging() 115 | { 116 | if (!m_draggable) 117 | { 118 | return; 119 | } 120 | if (m_clicked) //i.e. cursor has not moved a lot 121 | { 122 | enterIconDraggingMode(true, this); 123 | QDrag *drag = new QDrag(this); 124 | QMimeData *mime = new QMimeData; 125 | std::vector i = searchApplicationTree(ConfigManager.getApplicationTree(),m_application); 126 | mime->setText(QString::number(i[0])+";"+QString::number(i[1])); 127 | drag->setMimeData(mime); 128 | if (m_application.isFolder()) 129 | { 130 | int size = std::min({width(),height()}); 131 | drag->setPixmap(m_icon.pixmap(QSize(size,size))); 132 | } 133 | else 134 | { 135 | m_icon = m_application.icon(); 136 | drag->setPixmap(m_application.icon().pixmap(size())); 137 | } 138 | drag->setHotSpot(QPoint(drag->pixmap().width()/2,drag->pixmap().height()/2)); 139 | drag->exec(); 140 | } 141 | m_clicked = false; 142 | } 143 | 144 | void IconGridItemCanvas::mouseMoveEvent(QMouseEvent *event) 145 | { 146 | int dx = QCursor::pos().x()-m_pressPos.x(); 147 | int dy = QCursor::pos().y()-m_pressPos.y(); 148 | if (dx*dx+dy*dy>=RocketStyle::click_tolerance && m_clicked) 149 | { 150 | m_longclicktimer->stop(); 151 | m_clicked = false; 152 | } 153 | event->ignore(); 154 | } 155 | 156 | void IconGridItemCanvas::mouseReleaseEvent(QMouseEvent *event) 157 | { 158 | if (m_clicked) 159 | { 160 | m_clicked = false; 161 | if (!m_application.isFolder()) 162 | { 163 | KDesktopFile d(m_application.entrypath()); 164 | KService s(&d,m_application.entrypath()); 165 | KService::Ptr p(&s); 166 | KIO::ApplicationLauncherJob * job = new KIO::ApplicationLauncherJob(p); 167 | job->setUiDelegate(new KIO::JobUiDelegate(KJobUiDelegate::AutoHandlingEnabled, this)); 168 | job->setAutoDelete(true); 169 | job->start(); 170 | qDebug() << "IconGridItemCanvas: Executing " + s.entryPath() + " " + s.exec(); 171 | connect(job,&KIO::ApplicationLauncherJob::finished,qApp,[=]{ 172 | qApp->exit(); 173 | }); 174 | event->ignore(); 175 | return; 176 | } 177 | else 178 | { 179 | folderClickEvent(m_application); 180 | } 181 | event->accept(); 182 | } 183 | else 184 | { 185 | event->ignore(); 186 | } 187 | } 188 | 189 | 190 | void IconGridItemCanvas::dragEnterEvent(QDragEnterEvent *event) 191 | { 192 | //qDebug() << "dragging into" << m_application.name(); 193 | std::vector apptree = ConfigManager.getApplicationTree(); 194 | QStringList indices = event->mimeData()->text().split(";"); 195 | int index1 = indices[0].toInt(); 196 | int index2 = indices[1].toInt(); 197 | KDEApplication dragged_item = (index2 == -1 ? apptree[index1] : apptree[index1].getChildren()[index2]); 198 | if (!(dragged_item==m_application) && !dragged_item.isFolder() && index2==-1) 199 | { 200 | m_draw_folder = true; 201 | update(); 202 | } 203 | event->acceptProposedAction(); 204 | } 205 | 206 | void IconGridItemCanvas::dropEvent(QDropEvent *event) 207 | { 208 | std::vector apptree = ConfigManager.getApplicationTree(); 209 | QStringList indices = event->mimeData()->text().split(";"); 210 | int index1 = indices[0].toInt(); 211 | int index2 = indices[1].toInt(); 212 | KDEApplication dragged_item = (index2 == -1 ? apptree[index1] : apptree[index1].getChildren()[index2]); 213 | if (!dragged_item.isFolder() && !(dragged_item==m_application) && index2==-1) 214 | { 215 | makeFolder(m_application,dragged_item); 216 | event->accept(); 217 | return; 218 | } 219 | // An item has been moved outside of a folder and has been dropped 220 | // on itself (and not on the pager) 221 | if (dragged_item==m_application && index2!=-1) 222 | { 223 | enterIconDraggingMode(false,((IconGridItemCanvas*)(event->source()))); 224 | event->accept(); 225 | return; 226 | } 227 | // In a folder, an a item has been dropped on another one 228 | if (index2!=-1) 229 | { 230 | enterIconDraggingMode(false,this); 231 | return; 232 | } 233 | enterIconDraggingMode(false); 234 | } 235 | 236 | void IconGridItemCanvas::dragMoveEvent(QDragMoveEvent *event) 237 | { 238 | //qDebug() << "dragMoveIconGriditem"; 239 | event->acceptProposedAction(); 240 | } 241 | 242 | void IconGridItemCanvas::dragLeaveEvent(QDragLeaveEvent *event) 243 | { 244 | //qDebug() << "dragging left" << m_application.name(); 245 | m_draw_folder = false; 246 | update(); 247 | event->accept(); 248 | } 249 | 250 | 251 | void IconGridItemCanvas::resizeEvent(QResizeEvent *event) 252 | { 253 | update(); 254 | } 255 | 256 | 257 | IconGridItemCanvas::~IconGridItemCanvas() 258 | { 259 | 260 | } 261 | -------------------------------------------------------------------------------- /Rocket/icongrid/icongriditemcanvas.h: -------------------------------------------------------------------------------- 1 | #ifndef ICONGRIDITEMCANVAS_H 2 | #define ICONGRIDITEMCANVAS_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | #include "../RocketLibrary/tools/kdeapplication.h" 11 | 12 | class IconGridItemCanvas : public QWidget 13 | { 14 | Q_OBJECT 15 | public: 16 | explicit IconGridItemCanvas(QWidget *parent, KDEApplication application); 17 | KDEApplication getApplication(){return m_application;} 18 | void mousePressEvent(QMouseEvent *event); 19 | void mouseMoveEvent(QMouseEvent *event); 20 | void mouseReleaseEvent(QMouseEvent *event); 21 | void dragEnterEvent(QDragEnterEvent *event); 22 | void dragMoveEvent(QDragMoveEvent *event); 23 | void dropEvent(QDropEvent *event); 24 | void dragLeaveEvent(QDragLeaveEvent *event); 25 | void resizeEvent(QResizeEvent *event); 26 | ~IconGridItemCanvas(); 27 | 28 | public slots: 29 | void setDraggable(bool draggable); 30 | 31 | signals: 32 | void enterIconDraggingMode(bool on, IconGridItemCanvas * canvas = nullptr); 33 | void folderClickEvent(KDEApplication folder); 34 | void makeFolder(KDEApplication app_dropped_on, KDEApplication app_dragged); 35 | 36 | private: 37 | void initIconDragging(); 38 | 39 | 40 | QIcon m_icon; 41 | QPixmap pixmap; 42 | KDEApplication m_application; 43 | 44 | bool m_clicked = false; 45 | bool m_draggable = true; 46 | QPoint m_pressPos; 47 | QTimer * m_longclicktimer = new QTimer(); 48 | bool m_draw_folder = false; // draws folder 49 | 50 | protected: 51 | void paintEvent(QPaintEvent *); 52 | }; 53 | 54 | #endif // ICONGRIDITEMCANVAS_H 55 | -------------------------------------------------------------------------------- /Rocket/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include 9 | 10 | #include "mainwindow.h" 11 | 12 | #include "../RocketLibrary/tools/rocketconfigmanager.h" 13 | 14 | extern RocketConfigManager ConfigManager = RocketConfigManager(); 15 | 16 | int main(int argc, char *argv[]) 17 | { 18 | QApplication a(argc, argv); 19 | 20 | QString name = a.applicationName().toLower(); 21 | 22 | // Create .config folder 23 | if (!QDir(QDir::homePath()+"/.config/"+name).exists()) 24 | QDir().mkdir(QDir::homePath()+"/.config/"+name); 25 | 26 | // Check if another instance of Rocket is running 27 | QLockFile mainlockFile(QDir::homePath()+"/.config/"+name+"/."+name+"main.lock"); 28 | if (!mainlockFile.tryLock(100)) 29 | { 30 | // Kill Rocket if already running and exit 31 | QProcess p; 32 | p.start("pkill rocket"); 33 | p.waitForFinished(1000); 34 | return 1; 35 | } 36 | 37 | // Loading settings and show main window 38 | KConfig styleconfig(QDir::homePath()+"/.config/"+name+"/"+name+"style",KConfig::OpenFlag::SimpleConfig); 39 | KConfig appgridconfig(QDir::homePath()+"/.config/"+name+"/"+name+"appgrid",KConfig::OpenFlag::SimpleConfig); 40 | 41 | ConfigManager.setStyleConfig(&styleconfig); 42 | ConfigManager.checkStyleConfigFile(); 43 | 44 | ConfigManager.setAppGridConfig(&appgridconfig); 45 | ConfigManager.checkAppGridConfigFile(); 46 | 47 | MainWindow w; 48 | w.showFullScreen(); 49 | 50 | return a.exec(); 51 | } 52 | -------------------------------------------------------------------------------- /Rocket/mainwindow.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | #include "mainwindow.h" 16 | #include "ui_mainwindow.h" 17 | #include "pager/horizontalpager.h" 18 | #include "pager/verticalpager.h" 19 | #include "pager/pageritem.h" 20 | #include "pager/pagercircularindicator.h" 21 | #include "pager/pagercircularactiveindicator.h" 22 | 23 | MainWindow::MainWindow(QWidget *parent) : 24 | QMainWindow(parent), 25 | ui(new Ui::MainWindow) 26 | { 27 | setStarupArgs(new QStringList(qApp->arguments())); 28 | 29 | QDBusConnection connection = QDBusConnection::sessionBus(); 30 | connection.interface()->registerService("com.friciwolf.rocket"); 31 | connection.registerObject("/",this,QDBusConnection::ExportAllSlots); 32 | connection.connect("com.friciwolf.rocket","/","com.friciwolf.rocket","dBusToggleWindowState",this,SLOT(MainWindow::dBusToggleWindowState())); 33 | 34 | ui->setupUi(this); 35 | setMouseTracking(true); 36 | setWindowOpacity(1); 37 | 38 | setAttribute(Qt::WA_TranslucentBackground); 39 | setAttribute(Qt::WA_NoSystemBackground); 40 | KWindowEffects::enableBlurBehind(winId()); 41 | 42 | if (ConfigManager.getVerticalModeSetting()) 43 | { 44 | verticalpager = new VerticalPager(this, ConfigManager.getApplicationTree(), false); 45 | 46 | indicator = new PagerCircularIndicator(this,verticalpager); 47 | connect(verticalpager,&VerticalPager::hideCircularIndicator,indicator,&PagerCircularIndicator::setHidden); 48 | 49 | active_indicator = new PagerCircularActiveIndicator(this,indicator); 50 | connect(verticalpager,&VerticalPager::hideCircularIndicator,active_indicator,&PagerCircularActiveIndicator::setHidden); 51 | 52 | searchfield = new SearchField(this); 53 | connect(verticalpager,&VerticalPager::setSearchbarVisibility,searchfield,&QLineEdit::setVisible); 54 | connect(searchfield,&QLineEdit::textEdited,verticalpager,&VerticalPager::activateSearch); 55 | connect(searchfield,&SearchField::navigate,this,&MainWindow::navigation); 56 | connect(searchfield,&QLineEdit::returnPressed,this,&MainWindow::executeSelected); 57 | } 58 | else 59 | { 60 | pager = new HorizontalPager(this, ConfigManager.getApplicationTree(), false); 61 | 62 | indicator = new PagerCircularIndicator(this,pager); 63 | connect(pager,&HorizontalPager::hideCircularIndicator,indicator,&PagerCircularIndicator::setHidden); 64 | 65 | active_indicator = new PagerCircularActiveIndicator(this,indicator); 66 | connect(pager,&HorizontalPager::hideCircularIndicator,active_indicator,&PagerCircularActiveIndicator::setHidden); 67 | 68 | searchfield = new SearchField(this); 69 | connect(pager,&HorizontalPager::setSearchbarVisibility,searchfield,&QLineEdit::setVisible); 70 | connect(searchfield,&QLineEdit::textEdited,pager,&HorizontalPager::activateSearch); 71 | connect(searchfield,&SearchField::navigate,this,&MainWindow::navigation); 72 | connect(searchfield,&QLineEdit::returnPressed,this,&MainWindow::executeSelected); 73 | } 74 | 75 | // comparing app lists might take a while, so start it in a new thread... 76 | ComparingApps * comparerthread = new ComparingApps(); 77 | connect(comparerthread, &ComparingApps::pagerUpdateNeeded,this,&MainWindow::pagerUpdaterMethod); 78 | connect(comparerthread, &ComparingApps::finished,comparerthread,&QObject::deleteLater); 79 | comparerthread->start(); 80 | } 81 | 82 | void MainWindow::dBusToggleWindowState(QString event) 83 | { 84 | if (event==QString("_toggle") && !getStarupArgs()->contains("--dbus")) 85 | { 86 | qApp->exit(); 87 | } 88 | if (getStarupArgs()->contains("--dbus")) 89 | { 90 | getStarupArgs()->removeAt(getStarupArgs()->indexOf("--dbus")); 91 | } 92 | } 93 | 94 | void MainWindow::pagerUpdaterMethod() 95 | { 96 | if (ConfigManager.getVerticalModeSetting()) 97 | { 98 | verticalpager->setApplicationList(ConfigManager.getApplications()); 99 | verticalpager->setApplicationTree(ConfigManager.getApplicationTree()); 100 | verticalpager->updatePager(ConfigManager.getApplicationTree()); 101 | } 102 | else 103 | { 104 | pager->setApplicationList(ConfigManager.getApplications()); 105 | pager->setApplicationTree(ConfigManager.getApplicationTree()); 106 | pager->updatePager(ConfigManager.getApplicationTree()); 107 | } 108 | qDebug() << "application list updated"; 109 | } 110 | 111 | void MainWindow::resizeEvent(QResizeEvent *event) 112 | { 113 | // if not in fullscreen, don't bother constructing the pager... 114 | if (size().width()<17) 115 | { 116 | event->accept(); 117 | return; 118 | } 119 | if (ConfigManager.getVerticalModeSetting()) 120 | { 121 | verticalpager->setFixedSize(width(),height()); 122 | indicator->positioning(); 123 | active_indicator->positioning(); 124 | searchfield->positioning(); 125 | } 126 | else 127 | { 128 | pager->setFixedSize(width(),height()); 129 | indicator->positioning(); 130 | active_indicator->positioning(); 131 | searchfield->positioning(); 132 | } 133 | } 134 | 135 | void MainWindow::navigation(int key) 136 | { 137 | if (key==Qt::Key::Key_Escape) 138 | { 139 | if (ConfigManager.getVerticalModeSetting()) 140 | { 141 | if (verticalpager->in_subfolder == false) 142 | qApp->exit(); 143 | else 144 | { 145 | verticalpager->updatePager(verticalpager->getApplicationTree()); 146 | verticalpager->hideCircularIndicator(false); 147 | verticalpager->enableIconDragging(true); 148 | verticalpager->setSearchbarVisibility(true); 149 | int index = 0; 150 | int i = 0; 151 | for (KDEApplication app : verticalpager->getApplicationTree()) 152 | if (app==verticalpager->in_subfolder_app) 153 | { 154 | index=i; 155 | break; 156 | } 157 | else i++; 158 | verticalpager->pages[verticalpager->current_element]->getIconGrid()->highlight((index%verticalpager->pages[0]->getIconGrid()->getItems().size())); 159 | verticalpager->in_subfolder = false; 160 | return; 161 | } 162 | } 163 | else 164 | { 165 | if (pager->in_subfolder==false) 166 | qApp->exit(); 167 | else 168 | { 169 | pager->updatePager(pager->getApplicationTree()); 170 | pager->hideCircularIndicator(false); 171 | pager->enableIconDragging(true); 172 | pager->setSearchbarVisibility(true); 173 | int index = 0; 174 | int i = 0; 175 | for (KDEApplication app : pager->getApplicationTree()) 176 | if (app==pager->in_subfolder_app) 177 | { 178 | index=i; 179 | break; 180 | } 181 | else i++; 182 | pager->pages[pager->current_element]->getIconGrid()->highlight((index%pager->pages[0]->getIconGrid()->getItems().size())); 183 | pager->in_subfolder = false; 184 | return; 185 | } 186 | } 187 | } 188 | IconGrid * grid; 189 | if (ConfigManager.getVerticalModeSetting()) 190 | { 191 | grid = verticalpager->pages[verticalpager->current_element]->getIconGrid(); 192 | if (grid->getNumberOfItems()==0) return; // "No Results found" - screen 193 | verticalpager->page_turned = false; 194 | } 195 | else 196 | { 197 | grid = pager->pages[pager->current_element]->getIconGrid(); 198 | if (grid->getNumberOfItems()==0) return; // "No Results found" - screen 199 | pager->page_turned = false; 200 | } 201 | grid->unhighlightAll(); 202 | int active = grid->getActiveElement(); 203 | switch (key) 204 | { 205 | case Qt::Key::Key_Right: 206 | { 207 | grid->setActiveElement(active+1); 208 | break; 209 | } 210 | case Qt::Key::Key_Left: 211 | { 212 | grid->setActiveElement(active-1); 213 | break; 214 | } 215 | case Qt::Key::Key_Up: 216 | { 217 | grid->setActiveElement(active-grid->getMaxNumberOfColumns()); 218 | break; 219 | } 220 | case Qt::Key::Key_Down: 221 | { 222 | if (active==-1) grid->setActiveElement(0); 223 | else grid->setActiveElement(active+grid->getMaxNumberOfColumns()); 224 | break; 225 | } 226 | case Qt::Key::Key_Tab: 227 | { 228 | if (active==(int)grid->getItems().size()-1 && (ConfigManager.getVerticalModeSetting() ? verticalpager->searching : pager->searching)) 229 | { 230 | grid->setActiveElement(0); 231 | } 232 | else { 233 | grid->setActiveElement(active+1); 234 | } 235 | break; 236 | } 237 | } 238 | active = grid->getActiveElement(); 239 | if (ConfigManager.getVerticalModeSetting()) 240 | { 241 | if (active!=-1 && !verticalpager->page_turned) grid->highlight(active); 242 | } 243 | else 244 | { 245 | if (active!=-1 && !pager->page_turned) grid->highlight(active); 246 | } 247 | } 248 | 249 | void MainWindow::executeSelected() 250 | { 251 | IconGrid * grid; 252 | if (ConfigManager.getVerticalModeSetting()) 253 | { 254 | grid = verticalpager->pages[verticalpager->current_element]->getIconGrid(); 255 | } 256 | else { 257 | grid = pager->pages[pager->current_element]->getIconGrid(); 258 | } 259 | int active = grid->getActiveElement(); 260 | if (active==-1) return; 261 | KDEApplication application = grid->getItems()[active]->getApplication(); 262 | if (!application.isFolder()) 263 | { 264 | KDesktopFile d(application.entrypath()); 265 | KService s(&d,application.entrypath()); 266 | KService::Ptr p(&s); 267 | KIO::ApplicationLauncherJob * job = new KIO::ApplicationLauncherJob(p); 268 | job->setUiDelegate(new KIO::JobUiDelegate(KJobUiDelegate::AutoHandlingEnabled, this)); 269 | job->setAutoDelete(true); 270 | job->start(); 271 | qDebug() << "MainWindow: Executing " + s.entryPath() + " " + s.exec(); 272 | connect(job,&KIO::ApplicationLauncherJob::finished,qApp,[=]{ 273 | qApp->exit(); 274 | }); 275 | } 276 | else 277 | { 278 | if (ConfigManager.getVerticalModeSetting()) 279 | { 280 | verticalpager->folderClickEvent(application); 281 | verticalpager->pages[verticalpager->current_element]->getIconGrid()->highlight(0); 282 | } 283 | else { 284 | pager->folderClickEvent(application); 285 | pager->pages[pager->current_element]->getIconGrid()->highlight(0); 286 | } 287 | } 288 | } 289 | 290 | MainWindow::~MainWindow() 291 | { 292 | delete ui; 293 | } 294 | -------------------------------------------------------------------------------- /Rocket/mainwindow.h: -------------------------------------------------------------------------------- 1 | #ifndef MAINWINDOW_H 2 | #define MAINWINDOW_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include "pager/horizontalpager.h" 9 | #include "pager/verticalpager.h" 10 | #include "pager/pagercircularindicator.h" 11 | #include "pager/pagercircularactiveindicator.h" 12 | #include "searchfield/searchfield.h" 13 | 14 | namespace Ui { 15 | class MainWindow; 16 | } 17 | 18 | class MainWindow : public QMainWindow 19 | { 20 | Q_OBJECT 21 | 22 | public: 23 | HorizontalPager * pager; 24 | VerticalPager * verticalpager; 25 | 26 | PagerCircularIndicator * indicator; 27 | PagerCircularActiveIndicator * active_indicator; 28 | SearchField * searchfield; 29 | 30 | int search_width; 31 | int search_height; 32 | 33 | explicit MainWindow(QWidget *parent = nullptr); 34 | 35 | void resizeEvent(QResizeEvent *event); 36 | void setStarupArgs(QStringList * args){m_startupargs = args;} 37 | QStringList * getStarupArgs(){return m_startupargs;} 38 | 39 | ~MainWindow(); 40 | 41 | public slots: 42 | void navigation(int key); 43 | void executeSelected(); 44 | void dBusToggleWindowState(QString event); 45 | void pagerUpdaterMethod(); 46 | 47 | private: 48 | Ui::MainWindow *ui; 49 | QStringList * m_startupargs; 50 | }; 51 | 52 | class ComparingApps : public QThread 53 | { 54 | Q_OBJECT 55 | void run() override { 56 | if(ConfigManager.updateApplicationList()) 57 | { 58 | emit pagerUpdateNeeded(); 59 | } 60 | } 61 | signals: 62 | void pagerUpdateNeeded(); 63 | }; 64 | 65 | #endif // MAINWINDOW_H 66 | -------------------------------------------------------------------------------- /Rocket/mainwindow.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | MainWindow 4 | 5 | 6 | 7 | 0 8 | 0 9 | 16 10 | 16 11 | 12 | 13 | 14 | MainWindow 15 | 16 | 17 | 0.000000000000000 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /Rocket/pager/horizontalpager.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | #include 14 | #include 15 | #include 16 | 17 | #include "icongrid/icongrid.h" 18 | #include "tools/searchingapps.h" 19 | #include "pager/horizontalpager.h" 20 | #include "pager/pagerfolderview.h" 21 | 22 | #include "../RocketLibrary/tools/kmenuitems.h" 23 | #include "../RocketLibrary/tools/rocketconfigmanager.h" 24 | 25 | HorizontalPager::HorizontalPager(QWidget *parent, std::vector appTree, bool withBackgound) : Pager(parent, appTree, withBackgound) 26 | { 27 | connect(m_timer_drag_switch,&QTimer::timeout,this,[=]{ 28 | m_timer_drag_mouse_pos = QCursor::pos(); 29 | 30 | current_element = current_element + m_timer_drag_delta; 31 | element_before_entering_submenu = (!in_subfolder ? current_element : element_before_entering_submenu); 32 | new_element = current_element; 33 | scrolled = false; 34 | touchpad = false; 35 | QParallelAnimationGroup * animationgroup = new QParallelAnimationGroup; 36 | for (int i=0;i<(int)pages.size(); i++) 37 | { 38 | QPropertyAnimation * animation = new QPropertyAnimation(pages[i],"pos"); 39 | animation->setTargetObject(pages[i]); 40 | animation->setStartValue(pages[i]->pos()); 41 | animation->setEndValue(QPoint((i-new_element)*width(),pages[i]->pos().y())); 42 | animation->setDuration(100); 43 | animationgroup->addAnimation(animation); 44 | } 45 | connect(animationgroup,&QParallelAnimationGroup::finished,this,[=]{ 46 | int dx0 = (QCursor::pos()-m_timer_drag_mouse_pos).x(); 47 | int dy0 = (QCursor::pos()-m_timer_drag_mouse_pos).y(); 48 | if (dx0*dx0+dy0*dy0=0 && current_element+m_timer_drag_deltagetNumberOfElements()) 49 | { 50 | m_timer_drag_switch->start(750); 51 | } 52 | else { 53 | m_timer_drag_delta = 0; 54 | } 55 | }); 56 | animationgroup->start(); 57 | }); 58 | } 59 | 60 | void HorizontalPager::constructPager(std::vector kapplications) 61 | { 62 | Pager::constructPager(kapplications); 63 | for (PagerItem * page : pages) 64 | { 65 | connect(page->getIconGrid(),&IconGrid::goToPage,this,&HorizontalPager::goToPage); 66 | } 67 | 68 | for (IconGridItem * i : getAllIconGridItems()) 69 | { 70 | connect(i->getCanvas(),&IconGridItemCanvas::makeFolder,this,&HorizontalPager::makeFolder); 71 | connect(i->getCanvas(),&IconGridItemCanvas::folderClickEvent,this,&HorizontalPager::folderClickEvent); 72 | connect(i->getCanvas(),&IconGridItemCanvas::enterIconDraggingMode,this,&HorizontalPager::enterIconDraggingMode); 73 | connect(this,&HorizontalPager::enableIconDragging,i->getCanvas(),&IconGridItemCanvas::setDraggable); 74 | } 75 | } 76 | 77 | void HorizontalPager::updatePager(std::vector kapplications) 78 | { 79 | Pager::updatePager(kapplications); 80 | HorizontalPager::constructPager(kapplications); 81 | for (int i=0;i<(int)pages.size();i++) 82 | { 83 | pages[i]->setGeometry(QRect((i-current_element)*width(),0,width(),height())); 84 | pages[i]->setEnabled(true); 85 | pages[i]->setVisible(true); 86 | } 87 | } 88 | 89 | // *********************************************** 90 | // EVENTS 91 | // *********************************************** 92 | 93 | void HorizontalPager::mouseMoveEvent(QMouseEvent * event) 94 | { 95 | if (scrolled) // pages have been scrolled 96 | { 97 | if (mouse_pos_scroll_0!=QCursor::pos()) 98 | { 99 | finishScrolling(); // update the state 100 | } 101 | } 102 | else // pages have been dragged manually 103 | { 104 | int dx0 = (QCursor::pos()-drag_0).x(); 105 | if (dragging && !searching) 106 | { 107 | if ((current_element==0 && dx0>RocketStyle::pager_deadzone_threshold) || (current_element==(int)pages.size()-1 && dx0<-RocketStyle::pager_deadzone_threshold)) 108 | { 109 | event->accept(); 110 | } 111 | else 112 | { 113 | QPoint delta = QCursor::pos()-drag_start_position; 114 | for (PagerItem *page_i : pages) 115 | { 116 | page_i->move((page_i->pos()+delta).x(),page_i->pos().y()); 117 | } 118 | drag_start_position = QCursor::pos(); 119 | } 120 | } 121 | } 122 | event->accept(); 123 | //qDebug() << "pager: mouse move!"; 124 | } 125 | 126 | void HorizontalPager::mouseReleaseEvent(QMouseEvent * event) 127 | { 128 | Pager::mouseReleaseEvent(event); 129 | 130 | // Scroll if neccessary and update 131 | new_element = current_element; 132 | if ((QCursor::pos()-drag_0).x()>swipe_decision_threshold && current_element!=0) { 133 | new_element = current_element-1; 134 | } 135 | if ((QCursor::pos()-drag_0).x()<-swipe_decision_threshold && current_element!=(int)pages.size()-1){ 136 | new_element = current_element+1; 137 | } 138 | 139 | QParallelAnimationGroup * animationgroup = new QParallelAnimationGroup; 140 | for (int i=0;i<(int)pages.size(); i++) 141 | { 142 | QPropertyAnimation * animation = new QPropertyAnimation(pages[i],"pos"); 143 | animation->setTargetObject(pages[i]); 144 | animation->setStartValue(pages[i]->pos()); 145 | animation->setEndValue(QPoint((i-new_element)*width(),pages[i]->pos().y())); 146 | animation->setDuration(100); 147 | animationgroup->addAnimation(animation); 148 | } 149 | animationgroup->start(); 150 | 151 | pages[new_element]->getIconGrid()->resetHighlightAndActiveElement(); 152 | current_element = new_element; 153 | element_before_entering_submenu = (!in_subfolder ? current_element : element_before_entering_submenu); 154 | dragging = false; 155 | event->accept(); 156 | //qDebug() << "pager: mouse up!"; 157 | } 158 | 159 | void HorizontalPager::wheelEvent(QWheelEvent *event) 160 | { 161 | pages[current_element]->getIconGrid()->resetHighlightAndActiveElement(); 162 | if (!searching) 163 | { 164 | if (event->angleDelta().y() % 120 == 0 && event->angleDelta().y()!=0 && !touchpad) //scrolling with a mouse 165 | { 166 | if (event->angleDelta().y()<0) goToPage(1); 167 | else goToPage(-1); 168 | pages[current_element]->getIconGrid()->resetHighlightAndActiveElement(); 169 | } 170 | else // scrolling with a touchpad 171 | { 172 | touchpad = true; // touchpads need to build up some momentum, thus this switch 173 | bool horizontal_now = (std::abs(event->angleDelta().x())>std::abs(event->angleDelta().y())); 174 | if (m_horizontal_scrolling==0) 175 | m_horizontal_scrolling = (horizontal_now ? 1 : -1); 176 | int delta = (horizontal_now ? -(event->angleDelta().x())*ConfigManager.getInvertedScrollFactorXfromSettings() : event->angleDelta().y()*ConfigManager.getInvertedScrollFactorYfromSettings() ); 177 | bool orig_horizontal = (m_horizontal_scrolling==1 ? true : false); 178 | if (orig_horizontal!=horizontal_now) return; 179 | if (pages[0]->pos().x()-delta<=0 && pages[0]->pos().x()-delta>=-width()*(getNumberOfElements()-1)) 180 | { 181 | m_scrolltimeouttimer->stop(); 182 | scrolled = true; 183 | mouse_pos_scroll_0 = QCursor::pos(); 184 | for (PagerItem *page_i : pages) 185 | { 186 | page_i->move(page_i->pos().x()-delta,page_i->pos().y()); 187 | } 188 | m_scrolltimeouttimer = new QTimer(); 189 | connect(m_scrolltimeouttimer,&QTimer::timeout,this,&HorizontalPager::finishScrolling); 190 | m_scrolltimeouttimer->setSingleShot(true); 191 | m_scrolltimeouttimer->start(250); 192 | } 193 | else { 194 | // we've reached the last/first page, don't do anything anymore 195 | current_element = (-pages[0]->pos().x()+width()/2)/width(); 196 | element_before_entering_submenu = (!in_subfolder ? current_element : element_before_entering_submenu); 197 | new_element = current_element; 198 | for (int i=0;i<(int)pages.size(); i++) 199 | { 200 | pages[i]->move(QPoint((i-new_element)*width(),pages[i]->pos().y())); 201 | } 202 | } 203 | } 204 | } 205 | event->accept(); 206 | } 207 | 208 | // *********************************************** 209 | // SLOTS 210 | // *********************************************** 211 | 212 | void HorizontalPager::activateSearch(const QString &query) 213 | { 214 | if (scrolled) // pages have been scrolled 215 | { 216 | m_scrolltimeouttimer->stop(); 217 | if (mouse_pos_scroll_0!=QCursor::pos()) 218 | { 219 | current_element = (-pages[0]->pos().x()+width()/2)/width(); 220 | element_before_entering_submenu = (!in_subfolder ? current_element : element_before_entering_submenu); 221 | new_element = current_element; 222 | scrolled = false; 223 | } 224 | } 225 | Pager::activateSearch(query); 226 | } 227 | 228 | void HorizontalPager::goToPage(int deltaPage) 229 | { 230 | if (current_element+deltaPage==getNumberOfElements() || current_element+deltaPage==-1) return; 231 | if (searching) return; 232 | int newpage = current_element+deltaPage; 233 | for (int i=0;i<(int)pages.size(); i++) 234 | { 235 | pages[i]->move(QPoint((i-newpage)*width(),pages[i]->pos().y())); 236 | } 237 | if (deltaPage==1) 238 | { 239 | IconGrid * oldGrid = pages[current_element]->getIconGrid(); 240 | int oldElement = oldGrid->getActiveElement(); // 0 ... N_elements 241 | int oldElementRow = (int) ((oldElement)/(oldGrid->getCurrentNumberOfColumns()))+1; // 1...N_rows 242 | IconGrid * newGrid = pages[current_element+1]->getIconGrid(); 243 | if (oldElementRow > newGrid->getCurrentNumberOfRows()) 244 | { 245 | if (newGrid->getCurrentNumberOfRows()==1) 246 | { 247 | newGrid->highlight(0); 248 | } 249 | else 250 | { 251 | newGrid->highlight(newGrid->getCurrentNumberOfColumns()*(newGrid->getCurrentNumberOfRows()-1)); 252 | } 253 | } 254 | else 255 | { 256 | newGrid->highlight((oldElementRow-1)*newGrid->getCurrentNumberOfColumns()); 257 | } 258 | } 259 | if (deltaPage==-1) 260 | { 261 | IconGrid * oldGrid = pages[current_element]->getIconGrid(); 262 | int oldElement = oldGrid->getActiveElement(); // 0 ... N_elements 263 | int oldElementRow = (int) ((oldElement)/(oldGrid->getCurrentNumberOfColumns())); // 0...N_rows 264 | IconGrid * newGrid = pages[current_element-1]->getIconGrid(); 265 | newGrid->highlight((oldElementRow+1)*newGrid->getCurrentNumberOfColumns()-1); 266 | } 267 | 268 | 269 | current_element = newpage; 270 | new_element = current_element; 271 | element_before_entering_submenu = (!in_subfolder ? current_element : element_before_entering_submenu); 272 | page_turned = true; 273 | } 274 | 275 | void HorizontalPager::finishScrolling() 276 | { 277 | current_element = (-pages[0]->pos().x()+width()/2)/width(); 278 | element_before_entering_submenu = (!in_subfolder ? current_element : element_before_entering_submenu); 279 | new_element = current_element; 280 | scrolled = false; 281 | touchpad = false; 282 | if (pages[0]->pos().x()!=0 || pages[0]->pos().x()!=-width()*(getNumberOfElements()-1)) 283 | { 284 | QParallelAnimationGroup * animationgroup = new QParallelAnimationGroup; 285 | for (int i=0;i<(int)pages.size(); i++) 286 | { 287 | QPropertyAnimation * animation = new QPropertyAnimation(pages[i],"pos"); 288 | animation->setTargetObject(pages[i]); 289 | animation->setStartValue(pages[i]->pos()); 290 | animation->setEndValue(QPoint((i-new_element)*width(),pages[i]->pos().y())); 291 | animation->setDuration(100); 292 | animationgroup->addAnimation(animation); 293 | } 294 | animationgroup->start(); 295 | } 296 | m_horizontal_scrolling = 0; 297 | } 298 | 299 | void HorizontalPager::updatePagerAndPlayAnimationIfOnePageLess() 300 | { 301 | int numberofelementsbefore = this->getNumberOfElements(); 302 | updatePager(m_kapplication_tree); 303 | // move pager to the right position if there is one page less, and we are on the last page 304 | if (getNumberOfElements() != numberofelementsbefore && element_before_entering_submenu==numberofelementsbefore-1) 305 | { 306 | current_element = getNumberOfElements()-1; 307 | element_before_entering_submenu = current_element; 308 | new_element = current_element; 309 | QParallelAnimationGroup * animationgroup = new QParallelAnimationGroup; 310 | for (int i=0;i<(int)pages.size(); i++) 311 | { 312 | QPropertyAnimation * animation = new QPropertyAnimation(pages[i],"pos"); 313 | animation->setTargetObject(pages[i]); 314 | animation->setStartValue(pages[i]->pos()); 315 | animation->setEndValue(QPoint((i-new_element)*width(),pages[i]->pos().y())); 316 | animation->setDuration(100); 317 | animationgroup->addAnimation(animation); 318 | } 319 | animationgroup->start(); 320 | } 321 | } 322 | 323 | void HorizontalPager::setTimerDragDelta(QDragMoveEvent *event) 324 | { 325 | if (!m_timer_drag_switch->isActive()) 326 | { 327 | if (event->pos().x()>pages[current_element]->getIconGrid()->geometry().right() 328 | && current_element+1pos().x()getIconGrid()->geometry().left() 333 | && current_element-1>=0) 334 | { 335 | m_timer_drag_delta = -1; 336 | } 337 | if (m_timer_drag_delta!=0) 338 | { 339 | m_timer_drag_mouse_pos = QCursor::pos(); 340 | m_timer_drag_switch->start(750); 341 | } 342 | } 343 | } 344 | -------------------------------------------------------------------------------- /Rocket/pager/horizontalpager.h: -------------------------------------------------------------------------------- 1 | #ifndef HORIZONTALPAGER_H 2 | #define HORIZONTALPAGER_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | #include "pager/pager.h" 14 | #include "pager/pageritem.h" 15 | #include "../RocketLibrary/tools/kmenuitems.h" 16 | 17 | class HorizontalPager : public Pager 18 | { 19 | Q_OBJECT 20 | public: 21 | ~HorizontalPager() {} 22 | 23 | explicit HorizontalPager(QWidget * parent, std::vector appTree, bool withBackgound); 24 | void constructPager(std::vector kapplications) override; 25 | void updatePager(std::vector kapplications) override; 26 | 27 | void mouseMoveEvent(QMouseEvent * event) override; 28 | void mouseReleaseEvent(QMouseEvent * event) override; 29 | void wheelEvent(QWheelEvent *event) override; 30 | 31 | public slots: 32 | void activateSearch(const QString & query) override; 33 | void goToPage(int deltaPage) override; 34 | void finishScrolling() override; 35 | void updatePagerAndPlayAnimationIfOnePageLess() override; 36 | virtual void enterIconDraggingMode(bool on, IconGridItemCanvas * canvas = nullptr) override 37 | { 38 | Pager::enterIconDraggingMode(on,canvas); 39 | } 40 | 41 | private: 42 | void setTimerDragDelta(QDragMoveEvent *event) override; 43 | }; 44 | 45 | #endif // HORIZONTALPAGER_H 46 | -------------------------------------------------------------------------------- /Rocket/pager/pager.h: -------------------------------------------------------------------------------- 1 | #ifndef PAGER_H 2 | #define PAGER_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | #include "pager/pageritem.h" 14 | #include "../RocketLibrary/tools/kmenuitems.h" 15 | 16 | class Pager : public QWidget 17 | { 18 | Q_OBJECT 19 | public: 20 | ~Pager() {} 21 | // Number of pages on which applications are displayed 22 | std::vector pages; 23 | 24 | // indicates the currently selected element, and the new one, if the user swipes 25 | int current_element = 0; 26 | int new_element = 0; 27 | int element_before_entering_submenu = 0; // submenu = searching or subfolder 28 | 29 | // below this threshold, the user cannot swipe to the next page 30 | int swipe_decision_threshold = RocketStyle::pager_swpipe_threshold; 31 | 32 | // indicates whether the user is currently dragging 33 | bool dragging = false; 34 | // Mouse position previously to compare new mouse movements to and to adjust the layout during dragging 35 | QPoint drag_start_position; 36 | // Mouse position at the time of the start of dragging procedure with the mouse 37 | QPoint drag_0; 38 | // Mouse position for touchpad scrolling 39 | QPoint mouse_pos_scroll_0; 40 | bool touchpad = false; 41 | int m_horizontal_scrolling = 0; 42 | bool searching = false; 43 | bool in_subfolder = false; //true if we are in a subfolder 44 | KDEApplication in_subfolder_app; //stores in which subfolder we are currently 45 | bool page_turned = false; 46 | bool scrolled = false; 47 | bool isIconDraggingOn(){return m_icon_dragging_on;} 48 | 49 | explicit Pager(QWidget * parent, std::vector appTree, bool withBackgound); 50 | virtual void constructPager(std::vector kapplications); 51 | virtual void updatePager(std::vector kapplications); 52 | IconGridItem * findGridItemOfMinimumDistance(QPoint referencePoint); 53 | 54 | int getNumberOfElements() {return pages.size();} 55 | void setApplicationList(std::vector newlist){m_kapplications = newlist;} 56 | std::vector getApplicationTree() {return m_kapplication_tree;} 57 | void setApplicationTree(std::vector tree){m_kapplication_tree = tree;} 58 | std::vector getAllIconGridItems(); 59 | 60 | void resizeEvent(QResizeEvent *event); 61 | void leaveEvent(QEvent * event); 62 | void mousePressEvent(QMouseEvent * e); 63 | virtual void mouseReleaseEvent(QMouseEvent * event); 64 | virtual void mouseMoveEvent(QMouseEvent * event) = 0; 65 | virtual void wheelEvent(QWheelEvent *event) = 0; 66 | void dragEnterEvent(QDragEnterEvent *event); 67 | void dragMoveEvent(QDragMoveEvent *event); 68 | void dropEvent(QDropEvent *event); 69 | void dragLeaveEvent(QDragLeaveEvent *event); 70 | 71 | public slots: 72 | void folderClickEvent(KDEApplication folder); 73 | void makeFolder(KDEApplication app_dropped_on, KDEApplication app_dragged); 74 | virtual void enterIconDraggingMode(bool on, IconGridItemCanvas * canvas = nullptr); 75 | virtual void activateSearch(const QString & query); 76 | virtual void goToPage(int deltaPage) = 0; 77 | virtual void finishScrolling() = 0; 78 | virtual void updatePagerAndPlayAnimationIfOnePageLess() = 0; 79 | 80 | signals: 81 | void hideCircularIndicator(bool indicatorVisibility); 82 | void enableIconDragging(bool enable); 83 | void setSearchbarVisibility(bool visibility); 84 | 85 | private: 86 | virtual void setTimerDragDelta(QDragMoveEvent *event) = 0; 87 | 88 | protected: 89 | bool m_icon_dragging_on = false; //true: icons are dragged 90 | QTimer * m_timer_drag_switch = new QTimer(); //if running, the user is moving elements bw. pages 91 | QTimer * m_timer_hovering_above_elements = new QTimer(); // delays rearangement animation 92 | int m_timer_drag_delta = 0; // +1 or -1 if paging is needed 93 | QPoint m_timer_drag_mouse_pos; 94 | IconGridItemCanvas * m_item_dragged; 95 | QParallelAnimationGroup * m_drag_animation = new QParallelAnimationGroup; 96 | QMainWindow * m_folder_view_window; 97 | 98 | std::vector m_kapplications; 99 | std::vector m_kapplication_tree; 100 | QTimer * m_scrolltimeouttimer = new QTimer(); 101 | QGraphicsView * m_backgroundView; 102 | bool m_withbackground; // true: draw the background; false for folders 103 | }; 104 | 105 | #endif // PAGER_H 106 | -------------------------------------------------------------------------------- /Rocket/pager/pagercircularactiveindicator.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "pager/pagercircularactiveindicator.h" 6 | 7 | #include "../RocketLibrary/tools/rocketconfigmanager.h" 8 | 9 | PagerCircularActiveIndicator::PagerCircularActiveIndicator(QWidget *parent, PagerCircularIndicator * indicator) : QWidget(parent) 10 | { 11 | if (ConfigManager.getVerticalModeSetting()) verticalpager = indicator->getVerticalPager(); 12 | else pager = indicator->getPager(); 13 | this->indicator = indicator; 14 | positioning(); 15 | } 16 | 17 | void PagerCircularActiveIndicator::positioning() 18 | { 19 | radius = indicator->getRadius(); 20 | spacing = indicator->getSpacing(); 21 | setGeometry(indicator->geometry()); 22 | } 23 | 24 | void PagerCircularActiveIndicator::paintEvent(QPaintEvent *event) 25 | { 26 | QPainter painter(this); 27 | painter.setBrush(QBrush(ConfigManager.getSecondaryColour(),Qt::BrushStyle::SolidPattern)); 28 | painter.setPen(Qt::transparent); 29 | //painter.drawEllipse(spacing*0.5+current_item*(radius*2+spacing)+correction,height/2-radius,radius*2,radius*2); 30 | if (pager==nullptr) 31 | { 32 | int position = -(float)verticalpager->pages[0]->pos().y()/verticalpager->height() * (2*radius+spacing); 33 | painter.drawEllipse(width()/2-radius,spacing*0.5+position,radius*2,radius*2); 34 | } 35 | else 36 | { 37 | int position = -(float)pager->pages[0]->pos().x()/pager->width() * (2*radius+spacing); 38 | painter.drawEllipse(spacing*0.5+position,height()/2-radius,radius*2,radius*2); 39 | } 40 | } 41 | 42 | void PagerCircularActiveIndicator::resizeEvent(QResizeEvent *event) 43 | { 44 | positioning(); 45 | } 46 | -------------------------------------------------------------------------------- /Rocket/pager/pagercircularactiveindicator.h: -------------------------------------------------------------------------------- 1 | #ifndef PAGERCIRCULARACTIVEINDICATOR_H 2 | #define PAGERCIRCULARACTIVEINDICATOR_H 3 | 4 | #include 5 | #include 6 | #include "pagercircularindicator.h" 7 | #include "horizontalpager.h" 8 | 9 | class PagerCircularActiveIndicator : public QWidget 10 | { 11 | Q_OBJECT 12 | public: 13 | explicit PagerCircularActiveIndicator(QWidget *parent, PagerCircularIndicator * indicator); 14 | void positioning(); 15 | void paintEvent(QPaintEvent *event); 16 | void resizeEvent(QResizeEvent *event); 17 | void setPager(HorizontalPager* newPager) {pager=newPager;} 18 | void setVerticalPager(VerticalPager* newPager) {verticalpager=newPager;} 19 | 20 | private: 21 | QPixmap pixmap; 22 | int radius; 23 | int spacing; 24 | HorizontalPager * pager = nullptr; 25 | VerticalPager * verticalpager = nullptr; 26 | PagerCircularIndicator * indicator; 27 | }; 28 | 29 | #endif // PAGERCIRCULARACTIVEINDICATOR_H 30 | -------------------------------------------------------------------------------- /Rocket/pager/pagercircularindicator.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "horizontalpager.h" 5 | #include "mainwindow.h" 6 | #include "pager/pagercircularindicator.h" 7 | 8 | #include "../RocketLibrary/tools/rocketconfigmanager.h" 9 | 10 | PagerCircularIndicator::PagerCircularIndicator(QWidget *parent, HorizontalPager *pager) : QWidget(parent) 11 | { 12 | m_pager = pager; 13 | m_elements = pager->getNumberOfElements(); 14 | setPalette(ConfigManager.getBaseColourBackgroundPalette()); 15 | positioning(); 16 | } 17 | 18 | PagerCircularIndicator::PagerCircularIndicator(QWidget *parent, VerticalPager *pager) : QWidget(parent) 19 | { 20 | m_verticalpager = pager; 21 | m_elements = pager->getNumberOfElements(); 22 | setPalette(ConfigManager.getBaseColourBackgroundPalette()); 23 | positioning(); 24 | } 25 | 26 | void PagerCircularIndicator::positioning() 27 | { 28 | m_parent_geometry = parentWidget()->geometry(); 29 | m_radius = m_parent_geometry.size().height()*0.01; 30 | m_spacing = m_radius; 31 | if (m_pager==nullptr) 32 | { 33 | m_elements = m_verticalpager->getNumberOfElements(); 34 | setFixedSize(m_parent_geometry.size().width()*0.05,m_elements*(2*m_radius+m_spacing)); 35 | setGeometry((m_parent_geometry.width()-width()),(m_parent_geometry.height()-height())*0.5,width(),height()); 36 | } 37 | else 38 | { 39 | m_elements = m_pager->getNumberOfElements(); 40 | setFixedSize(m_elements*(2*m_radius+m_spacing),m_parent_geometry.size().height()*0.1); 41 | setGeometry((m_parent_geometry.width()-width())*0.5,(m_parent_geometry.height()-height()),width(),height()); 42 | } 43 | } 44 | 45 | void PagerCircularIndicator::paintEvent(QPaintEvent *event) 46 | { 47 | QPainter painter(this); 48 | if (ConfigManager.getBoxSetting()) 49 | painter.setBrush(QBrush(ConfigManager.getBaseColour(),Qt::BrushStyle::SolidPattern)); 50 | else 51 | painter.setBrush(QBrush(ConfigManager.getSelectionColour(),Qt::BrushStyle::SolidPattern)); 52 | painter.setPen(Qt::transparent); 53 | //painter.drawRoundedRect(0,0,width,height,5,5); 54 | if (m_pager==nullptr) 55 | { 56 | for (int i=0;igetNumberOfElements();i++) 57 | { 58 | painter.drawEllipse(width()/2-m_radius,m_spacing*0.5+i*(m_radius*2+m_spacing),m_radius*2,m_radius*2); 59 | } 60 | } 61 | else 62 | { 63 | for (int i=0;igetNumberOfElements();i++) 64 | { 65 | painter.drawEllipse(m_spacing*0.5+i*(m_radius*2+m_spacing),height()/2-m_radius,m_radius*2,m_radius*2); 66 | } 67 | } 68 | } 69 | 70 | void PagerCircularIndicator::resizeEvent(QResizeEvent *event) 71 | { 72 | positioning(); 73 | } 74 | -------------------------------------------------------------------------------- /Rocket/pager/pagercircularindicator.h: -------------------------------------------------------------------------------- 1 | #ifndef PAGERCIRCULARINDICATOR_H 2 | #define PAGERCIRCULARINDICATOR_H 3 | 4 | #include "horizontalpager.h" 5 | #include "verticalpager.h" 6 | 7 | #include 8 | #include 9 | 10 | class PagerCircularIndicator : public QWidget 11 | { 12 | Q_OBJECT 13 | public: 14 | explicit PagerCircularIndicator(QWidget *parent, HorizontalPager * pager); 15 | explicit PagerCircularIndicator(QWidget *parent, VerticalPager * pager); 16 | void positioning(); 17 | void paintEvent(QPaintEvent *event); 18 | void resizeEvent(QResizeEvent *event); 19 | 20 | int getSpacing() {return m_spacing;} 21 | int getRadius() {return m_radius;} 22 | HorizontalPager * getPager() {return m_pager;} 23 | VerticalPager * getVerticalPager() {return m_verticalpager;} 24 | void setPager(HorizontalPager* newPager) {m_pager=newPager;} 25 | void setVerticalPager(VerticalPager* newPager) {m_verticalpager=newPager;} 26 | 27 | private: 28 | QPixmap pixmap; 29 | HorizontalPager * m_pager = nullptr; 30 | VerticalPager * m_verticalpager = nullptr; 31 | QRect m_parent_geometry; 32 | 33 | int m_elements; 34 | 35 | /* 36 | * Space between the circles and their radius. 37 | */ 38 | int m_spacing; 39 | int m_radius; 40 | }; 41 | 42 | #endif // PAGERCIRCULARINDICATOR_H 43 | -------------------------------------------------------------------------------- /Rocket/pager/pagerfolderview.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | #include "pagerfolderview.h" 8 | #include "tools/searchingapps.h" 9 | #include "pagercircularindicator.h" 10 | #include "pagercircularactiveindicator.h" 11 | 12 | PagerFolderView::PagerFolderView(QWidget *parent, std::vector appTree, bool withBackgound) : HorizontalPager(parent, appTree, withBackgound) 13 | { 14 | /* 15 | * Pager Settings 16 | */ 17 | m_appTree = appTree; 18 | in_subfolder = true; 19 | updatePager(appTree); 20 | if (ConfigManager.getVerticalModeSetting()) 21 | { 22 | VerticalPager * verticalpager = ((VerticalPager*)parent->parent()); 23 | in_subfolder_app = verticalpager->in_subfolder_app; 24 | } 25 | else 26 | { 27 | HorizontalPager * pager = ((HorizontalPager*)parent->parent()); 28 | in_subfolder_app = pager->in_subfolder_app; 29 | } 30 | 31 | /* 32 | * PagerFolderView Specific Initializers 33 | */ 34 | m_closeFolder = new QTimer(this); 35 | m_closeFolder->setSingleShot(true); 36 | m_closeFolder->setInterval(500); 37 | connect(m_closeFolder,&QTimer::timeout,this,[this]{ 38 | leavingPagerFolderView(); 39 | parentWidget()->hide(); 40 | }); 41 | 42 | /* 43 | * Folder Name Textfield 44 | */ 45 | m_folderNameField = new QLineEdit(parent); 46 | m_folderNameField->setAcceptDrops(false); 47 | QFont fieldfont = m_folderNameField->font(); 48 | fieldfont.setPointSize(ConfigManager.getFontSize2()); 49 | m_folderNameField->setFont(fieldfont); 50 | m_folderNameField->setGeometry(pages[0]->getIconGrid()->geometry().left()+30,pages[0]->getIconGrid()->pos().y()-m_folderNameField->height()*2,pages[0]->getIconGrid()->width()-60,50); 51 | QString rgba = QString::number(ConfigManager.getBaseColour().red())+","+QString::number(ConfigManager.getBaseColour().green())+","+QString::number(ConfigManager.getBaseColour().blue())+","+QString::number(ConfigManager.getBaseColour().alpha()); 52 | m_folderNameField->setStyleSheet( 53 | "QLineEdit {margin-top:10; padding-left: 30; background: rgba("+rgba+"); border: 0; border-radius: 10;}" 54 | ); 55 | m_folderNameField->setAlignment(Qt::AlignCenter); 56 | m_folderNameField->setText(in_subfolder_app.name()); 57 | 58 | std::vector res = searchApplicationTree(ConfigManager.getApplicationTree(),in_subfolder_app); 59 | connect(m_folderNameField,&QLineEdit::textEdited,this,[=]{ 60 | std::vector newtree = ConfigManager.getApplicationTree(); 61 | newtree[res[0]].setName(m_folderNameField->text()); 62 | ConfigManager.generateAppGridConfigFile(ConfigManager.getAppGridConfig(),newtree); 63 | }); 64 | connect(m_folderNameField,&QLineEdit::returnPressed,this,[=]{ 65 | pages[current_element]->getIconGrid()->highlight(0); 66 | m_folderNameField->clearFocus(); 67 | }); 68 | m_folderNameField->show(); 69 | 70 | /* 71 | * The Circular Indicators 72 | */ 73 | PagerCircularIndicator * indicator = new PagerCircularIndicator(this,this); 74 | indicator->setVerticalPager(nullptr); 75 | indicator->setPager(this); 76 | 77 | PagerCircularActiveIndicator * activeIndicator = new PagerCircularActiveIndicator(this,indicator); 78 | activeIndicator->setVerticalPager(nullptr); 79 | activeIndicator->setPager(this); 80 | 81 | if (pages.size()==1) 82 | { 83 | indicator->setVisible(false); 84 | activeIndicator->setVisible(false); 85 | } 86 | } 87 | 88 | 89 | void PagerFolderView::mouseReleaseEvent(QMouseEvent *event) 90 | { 91 | // Checking whether outside area is clicked; if it's the case, close the folder 92 | int dx0 = (QCursor::pos()-drag_0).x(); 93 | int dy0 = (QCursor::pos()-drag_0).y(); 94 | if (dx0*dx0+dy0*dy0button()==Qt::LeftButton) 95 | { 96 | bool clickedAboveIconGridItem = false; 97 | for (IconGridItem * i : pages[current_element]->getIconGrid()->getItems()) 98 | { 99 | if ((i->geometry().translated(pages[current_element]->getIconGrid()->geometry().topLeft())).contains(event->pos())) 100 | { 101 | clickedAboveIconGridItem = true; 102 | break; 103 | } 104 | } 105 | // If the user has not clicked inside of the grid AND not not on the folderNameField 106 | // OR if the user has clicked on an empty area within the icongrid 107 | // close the folder 108 | if ((!pages[current_element]->getIconGrid()->geometry().contains(event->pos()) && !m_folderNameField->geometry().contains(event->pos())) || !clickedAboveIconGridItem) 109 | { 110 | event->accept(); 111 | 112 | QRect end; 113 | for (IconGridItem * i : ((HorizontalPager*)parentWidget()->parentWidget())->getAllIconGridItems()) 114 | if (i->getApplication().getChildren()==m_appTree) 115 | { 116 | QPoint point = mapFromGlobal(i->mapToGlobal(i->getCanvas()->geometry().topLeft())); 117 | end=QRect(point.x(),point.y(),i->getCanvas()->width(),i->getCanvas()->height()); 118 | break; 119 | } 120 | 121 | m_windowAnimation = new QParallelAnimationGroup(this); 122 | QPropertyAnimation * panim = new QPropertyAnimation(this); 123 | panim->setTargetObject(pages[current_element]); 124 | panim->setPropertyName("geometry"); 125 | panim->setEndValue(end); 126 | panim->setStartValue(pages[current_element]->geometry()); 127 | panim->setDuration(300); 128 | panim->setEasingCurve(QEasingCurve::InQuart); 129 | m_windowAnimation->addAnimation(panim); 130 | 131 | QPropertyAnimation * panim2 = new QPropertyAnimation(this); 132 | panim2->setTargetObject(m_folderNameField); 133 | panim2->setPropertyName("geometry"); 134 | panim2->setEndValue(QRect(end.x(),end.y(),0,0)); 135 | panim2->setStartValue(m_folderNameField->geometry()); 136 | panim2->setDuration(300); 137 | panim2->setEasingCurve(QEasingCurve::InQuart); 138 | m_windowAnimation->addAnimation(panim2); 139 | 140 | QPropertyAnimation * panim3 = new QPropertyAnimation(window()); 141 | panim3->setTargetObject(window()); 142 | panim3->setPropertyName("windowOpacity"); 143 | panim3->setStartValue(1); 144 | panim3->setEndValue(0); 145 | panim3->setDuration(300); 146 | panim3->setEasingCurve(QEasingCurve::InQuart); 147 | m_windowAnimation->addAnimation(panim3); 148 | 149 | m_windowAnimation->start(); 150 | connect(m_windowAnimation,&QParallelAnimationGroup::finished,this,[=] { 151 | if (QCursor::pos().x()parentWidget()->mapToGlobal(parentWidget()->parentWidget()->geometry().topLeft()).x() || QCursor::pos().x()>parentWidget()->parentWidget()->mapToGlobal(parentWidget()->parentWidget()->geometry().topRight()).x() || 152 | QCursor::pos().y()>parentWidget()->parentWidget()->mapToGlobal(parentWidget()->parentWidget()->geometry().bottomLeft()).y() || QCursor::pos().y()parentWidget()->mapToGlobal(parentWidget()->parentWidget()->geometry().topRight()).y()) 153 | { 154 | qDebug() << "PagerFolderViewParallelAnimationFinished: exiting..."; 155 | qApp->exit(); 156 | } 157 | else 158 | { 159 | leavingPagerFolderView(); 160 | delete parent(); 161 | } 162 | }); 163 | return; 164 | } 165 | } 166 | HorizontalPager::mouseReleaseEvent(event); 167 | } 168 | 169 | /* 170 | * This function disables the dragging animation for folders if there is a single page only. 171 | */ 172 | void PagerFolderView::mouseMoveEvent(QMouseEvent * event) 173 | { 174 | if (pages.size()==1) 175 | return; 176 | else 177 | HorizontalPager::mouseMoveEvent(event); 178 | } 179 | 180 | void PagerFolderView::dragMoveEvent(QDragMoveEvent *event) 181 | { 182 | if (!pages[current_element]->getIconGrid()->geometry().contains(event->pos()) && !m_closeFolder->isActive()) 183 | m_closeFolder->start(); 184 | if (pages[current_element]->getIconGrid()->geometry().contains(event->pos()) && m_closeFolder->isActive()) 185 | m_closeFolder->stop(); 186 | HorizontalPager::dragMoveEvent(event); 187 | } 188 | 189 | void PagerFolderView::enterIconDraggingMode(bool on, IconGridItemCanvas * canvas) 190 | { 191 | if (on==false && canvas!=nullptr) 192 | { 193 | // an item has been dropped on another canvas in a folder 194 | std::vector newtree = ConfigManager.getApplicationTree(); 195 | std::vector i = searchApplicationTree(ConfigManager.getApplicationTree(),canvas->getApplication()); 196 | newtree[i[0]].setChildren(getApplicationTree()); 197 | updatePager(newtree[i[0]].getChildren()); 198 | ConfigManager.generateAppGridConfigFile(ConfigManager.getAppGridConfig(),newtree); 199 | return; 200 | } 201 | // Propagating the signal back to the parent widget 202 | if (ConfigManager.getVerticalModeSetting()) 203 | ((VerticalPager*)parentWidget()->parent())->enterIconDraggingMode(on,canvas); 204 | else 205 | ((HorizontalPager*)parentWidget()->parent())->enterIconDraggingMode(on,canvas); 206 | HorizontalPager::enterIconDraggingMode(on,canvas); 207 | } 208 | 209 | void PagerFolderView::leaveEvent(QEvent *event) 210 | { 211 | if (QCursor::pos().x()parentWidget()->mapToGlobal(parentWidget()->parentWidget()->geometry().topLeft()).x() || QCursor::pos().x()>parentWidget()->parentWidget()->mapToGlobal(parentWidget()->parentWidget()->geometry().topRight()).x() || 212 | QCursor::pos().y()>parentWidget()->parentWidget()->mapToGlobal(parentWidget()->parentWidget()->geometry().bottomLeft()).y() || QCursor::pos().y()parentWidget()->mapToGlobal(parentWidget()->parentWidget()->geometry().topRight()).y()) 213 | { 214 | qDebug() << parentWidget()->parentWidget()->geometry() << parentWidget()->parentWidget()->mapToGlobal(parentWidget()->parentWidget()->geometry().topLeft()) << pages[0]->getIconGrid()->getItems()[0]->getApplication().name(); 215 | qDebug() << "PagerFolderViewLeaveEvent: exiting..."; 216 | qApp->exit(); 217 | } 218 | event->accept(); 219 | } 220 | -------------------------------------------------------------------------------- /Rocket/pager/pagerfolderview.h: -------------------------------------------------------------------------------- 1 | #ifndef PAGERFOLDERVIEW_H 2 | #define PAGERFOLDERVIEW_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #include "pager/horizontalpager.h" 10 | #include "pager/verticalpager.h" 11 | 12 | class PagerFolderView : public HorizontalPager 13 | { 14 | Q_OBJECT 15 | public: 16 | ~PagerFolderView() {} 17 | explicit PagerFolderView(QWidget *parent, std::vector appTree, bool withBackgound = false); 18 | void mouseReleaseEvent(QMouseEvent *event) override; 19 | void mouseMoveEvent(QMouseEvent * event) override; 20 | void dragMoveEvent(QDragMoveEvent * event) override; 21 | void leaveEvent(QEvent * event) override; 22 | QLineEdit * getNameField() {return m_folderNameField;} 23 | QTimer * getCloseFolderTimer() {return m_closeFolder;} 24 | void setWindowAnimation(QParallelAnimationGroup * windowAnimation) {m_windowAnimation = windowAnimation;} 25 | QParallelAnimationGroup * getWindowAnimation() {return m_windowAnimation;} 26 | 27 | signals: 28 | void leavingPagerFolderView(); 29 | 30 | public slots: 31 | void enterIconDraggingMode(bool on, IconGridItemCanvas * canvas = nullptr) override; 32 | 33 | private: 34 | QLineEdit * m_folderNameField; 35 | std::vector m_appTree; 36 | QTimer * m_closeFolder; 37 | QParallelAnimationGroup * m_windowAnimation = nullptr; 38 | }; 39 | 40 | #endif // PAGERFOLDERVIEW_H 41 | -------------------------------------------------------------------------------- /Rocket/pager/pageritem.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #include "pager/pageritem.h" 10 | #include "icongrid/icongrid.h" 11 | #include "icongrid/icongriditem.h" 12 | 13 | #include "../RocketLibrary/tools/rocketconfigmanager.h" 14 | 15 | PagerItem::PagerItem(QWidget *parent, vector applications) : QWidget(parent) 16 | { 17 | m_applications = applications; 18 | m_itemlayout = new QGridLayout(); 19 | setLayout(m_itemlayout); 20 | m_grid = new IconGrid(this); 21 | setGridProperties(); 22 | for (KDEApplication app : applications) 23 | { 24 | IconGridItem * griditem = new IconGridItem(m_grid,app,m_grid_itemsize); 25 | m_grid->addItem(griditem); 26 | } 27 | gridLayoutManagement(); 28 | setMouseTracking(true); 29 | } 30 | 31 | void PagerItem::setGridProperties() 32 | { 33 | /* 34 | * Updates the properties of the grid for initialization and resizing. 35 | * 36 | * The grid occupies maximum 90 % and 80 % of the screen horizontally and vertically, respectively. 37 | * 38 | * */ 39 | m_grid_maxsize = QSize(parentWidget()->size().width()*0.9,parentWidget()->size().height()*0.8); 40 | m_grid->setMaximumSize(m_grid_maxsize); 41 | 42 | // Estimate for a griditemsize 43 | int size1 = m_grid_maxsize.width()/ConfigManager.getColumnNumber(); 44 | int size2 = m_grid_maxsize.height()/ConfigManager.getRowNumber(); 45 | m_grid_itemsize = QSize(size1,size2); 46 | } 47 | 48 | void PagerItem::gridLayoutManagement() 49 | { 50 | if (m_applications.size()==0) 51 | { 52 | QLabel * label = new QLabel(ki18n("No results found").toString(),m_grid); 53 | label->setAutoFillBackground(true); 54 | if (ConfigManager.getBoxSetting()) 55 | label->setPalette(ConfigManager.getBaseColourBackgroundPalette()); 56 | else 57 | label->setPalette(ConfigManager.getSelectionColourBackgroundPalette()); 58 | label->setAlignment(Qt::AlignCenter); 59 | label->setFixedHeight(m_grid_itemsize.height()); 60 | QFont label_font = label->font(); 61 | label_font.setPointSize(ConfigManager.getFontSize2()); 62 | label->setFont(label_font); 63 | m_itemlayout->addWidget(label,1,1); 64 | setLayout(m_itemlayout); 65 | } 66 | else { 67 | m_itemlayout->addWidget(m_grid,1,1); 68 | } 69 | 70 | m_itemlayout->setColumnStretch(0,1); 71 | m_itemlayout->setColumnStretch(1,m_grid->getMaxNumberOfColumns()); 72 | m_itemlayout->setColumnStretch(2,1); 73 | m_itemlayout->setRowStretch(0,1); 74 | m_itemlayout->setRowStretch(1,m_grid->getCurrentNumberOfRows()); 75 | m_itemlayout->setRowStretch(2,1); 76 | } 77 | 78 | void PagerItem::mouseMoveEvent(QMouseEvent *event) 79 | { 80 | event->ignore(); 81 | } 82 | 83 | void PagerItem::resizeEvent(QResizeEvent *event) 84 | { 85 | setGridProperties(); 86 | } 87 | -------------------------------------------------------------------------------- /Rocket/pager/pageritem.h: -------------------------------------------------------------------------------- 1 | #ifndef PAGERITEM_H 2 | #define PAGERITEM_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | #include "icongrid/icongrid.h" 9 | 10 | #include "../RocketLibrary/tools/kdeapplication.h" 11 | 12 | 13 | using namespace std; 14 | 15 | class PagerItem : public QWidget 16 | { 17 | Q_OBJECT 18 | public: 19 | explicit PagerItem(QWidget *parent, vector applications); 20 | void setGridProperties(); 21 | void gridLayoutManagement(); 22 | IconGrid * getIconGrid(){return m_grid;} 23 | QSize getIconGridItemSize(){return m_grid_itemsize;} 24 | QSize getIconGridMaxSize() {return m_grid_maxsize;} 25 | QGridLayout * getItemLayout() {return m_itemlayout;} 26 | 27 | void mouseMoveEvent(QMouseEvent *event); 28 | void resizeEvent(QResizeEvent *event); 29 | 30 | private: 31 | IconGrid * m_grid; 32 | QGridLayout * m_itemlayout; 33 | QSize m_grid_maxsize; 34 | QSize m_grid_itemsize; 35 | vector m_applications; 36 | 37 | }; 38 | 39 | #endif // PAGERITEM_H 40 | -------------------------------------------------------------------------------- /Rocket/pager/verticalpager.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | #include 14 | #include 15 | #include 16 | 17 | #include "icongrid/icongrid.h" 18 | #include "tools/searchingapps.h" 19 | #include "pager/verticalpager.h" 20 | #include "pager/pagerfolderview.h" 21 | 22 | #include "../RocketLibrary/tools/kmenuitems.h" 23 | #include "../RocketLibrary/tools/rocketconfigmanager.h" 24 | 25 | VerticalPager::VerticalPager(QWidget *parent, std::vector appTree, bool withBackgound) : Pager(parent, appTree, withBackgound) 26 | { 27 | connect(m_timer_drag_switch,&QTimer::timeout,this,[=]{ 28 | m_timer_drag_mouse_pos = QCursor::pos(); 29 | 30 | current_element = current_element + m_timer_drag_delta; 31 | element_before_entering_submenu = (!in_subfolder ? current_element : element_before_entering_submenu); 32 | new_element = current_element; 33 | scrolled = false; 34 | touchpad = false; 35 | QParallelAnimationGroup * animationgroup = new QParallelAnimationGroup; 36 | for (int i=0;i<(int)pages.size(); i++) 37 | { 38 | QPropertyAnimation * animation = new QPropertyAnimation(pages[i],"pos"); 39 | animation->setTargetObject(pages[i]); 40 | animation->setStartValue(pages[i]->pos()); 41 | animation->setEndValue(QPoint(pages[i]->pos().x(),(i-new_element)*height())); 42 | animation->setDuration(100); 43 | animationgroup->addAnimation(animation); 44 | } 45 | connect(animationgroup,&QParallelAnimationGroup::finished,this,[=]{ 46 | int dx0 = (QCursor::pos()-m_timer_drag_mouse_pos).x(); 47 | int dy0 = (QCursor::pos()-m_timer_drag_mouse_pos).y(); 48 | if (dx0*dx0+dy0*dy0=0 && current_element+m_timer_drag_deltagetNumberOfElements()) 49 | { 50 | m_timer_drag_switch->start(750); 51 | } 52 | else { 53 | m_timer_drag_delta = 0; 54 | } 55 | }); 56 | animationgroup->start(); 57 | }); 58 | } 59 | 60 | void VerticalPager::constructPager(std::vector kapplications) 61 | { 62 | Pager::constructPager(kapplications); 63 | for (PagerItem * page : pages) 64 | { 65 | connect(page->getIconGrid(),&IconGrid::goToPage,this,&VerticalPager::goToPage); 66 | } 67 | 68 | for (IconGridItem * i : getAllIconGridItems()) 69 | { 70 | connect(i->getCanvas(),&IconGridItemCanvas::makeFolder,this,&VerticalPager::makeFolder); 71 | connect(i->getCanvas(),&IconGridItemCanvas::folderClickEvent,this,&VerticalPager::folderClickEvent); 72 | connect(i->getCanvas(),&IconGridItemCanvas::enterIconDraggingMode,this,&VerticalPager::enterIconDraggingMode); 73 | connect(this,&VerticalPager::enableIconDragging,i->getCanvas(),&IconGridItemCanvas::setDraggable); 74 | } 75 | } 76 | 77 | void VerticalPager::updatePager(std::vector kapplications) 78 | { 79 | Pager::updatePager(kapplications); 80 | VerticalPager::constructPager(kapplications); 81 | for (int i=0;i<(int)pages.size();i++) 82 | { 83 | pages[i]->setGeometry(QRect(0,(i-current_element)*height(),width(),height())); 84 | pages[i]->setEnabled(true); 85 | pages[i]->setVisible(true); 86 | } 87 | } 88 | 89 | // *********************************************** 90 | // EVENTS 91 | // *********************************************** 92 | 93 | void VerticalPager::mouseMoveEvent(QMouseEvent * event) 94 | { 95 | if (scrolled) // pages have been scrolled 96 | { 97 | if (mouse_pos_scroll_0!=QCursor::pos()) 98 | { 99 | finishScrolling(); // update the state 100 | } 101 | } 102 | else // pages have been dragged manually 103 | { 104 | int dy0 = (QCursor::pos()-drag_0).y(); 105 | if (dragging && !searching) 106 | { 107 | if ((current_element==0 && dy0>RocketStyle::pager_deadzone_threshold) || (current_element==(int)pages.size()-1 && dy0<-RocketStyle::pager_deadzone_threshold)) 108 | { 109 | event->accept(); 110 | } 111 | else 112 | { 113 | QPoint delta = QCursor::pos()-drag_start_position; 114 | for (PagerItem *page_i : pages) 115 | { 116 | page_i->move(page_i->pos().x(),(page_i->pos()+delta).y()); 117 | } 118 | drag_start_position = QCursor::pos(); 119 | } 120 | } 121 | } 122 | event->accept(); 123 | //qDebug() << "pager: mouse move!"; 124 | } 125 | 126 | void VerticalPager::mouseReleaseEvent(QMouseEvent * event) 127 | { 128 | Pager::mouseReleaseEvent(event); 129 | 130 | // Scroll if neccessary and update 131 | new_element = current_element; 132 | if ((QCursor::pos()-drag_0).y()>swipe_decision_threshold && current_element!=0) { 133 | new_element = current_element-1; 134 | } 135 | if ((QCursor::pos()-drag_0).y()<-swipe_decision_threshold && current_element!=(int)pages.size()-1){ 136 | new_element = current_element+1; 137 | } 138 | 139 | QParallelAnimationGroup * animationgroup = new QParallelAnimationGroup; 140 | for (int i=0;i<(int)pages.size(); i++) 141 | { 142 | QPropertyAnimation * animation = new QPropertyAnimation(pages[i],"pos"); 143 | animation->setTargetObject(pages[i]); 144 | animation->setStartValue(pages[i]->pos()); 145 | animation->setEndValue(QPoint(pages[i]->pos().x(),(i-new_element)*height())); 146 | animation->setDuration(100); 147 | animationgroup->addAnimation(animation); 148 | } 149 | animationgroup->start(); 150 | 151 | pages[new_element]->getIconGrid()->resetHighlightAndActiveElement(); 152 | current_element = new_element; 153 | element_before_entering_submenu = (!in_subfolder ? current_element : element_before_entering_submenu); 154 | dragging = false; 155 | event->accept(); 156 | //qDebug() << "pager: mouse up!"; 157 | } 158 | 159 | void VerticalPager::wheelEvent(QWheelEvent *event) 160 | { 161 | pages[current_element]->getIconGrid()->resetHighlightAndActiveElement(); 162 | if (!searching) 163 | { 164 | if (event->angleDelta().y() % 120 == 0 && event->angleDelta().y()!=0 && !touchpad) //scrolling with a mouse 165 | { 166 | if (event->angleDelta().y()<0) goToPage(1); 167 | else goToPage(-1); 168 | pages[current_element]->getIconGrid()->resetHighlightAndActiveElement(); 169 | } 170 | else // scrolling with a touchpad 171 | { 172 | touchpad = true; // touchpads need to build up some momentum, thus this switch 173 | bool horizontal_now = (std::abs(event->angleDelta().x())>std::abs(event->angleDelta().y())); 174 | if (m_horizontal_scrolling==0) 175 | m_horizontal_scrolling = (horizontal_now ? 1 : -1); 176 | int delta = (event->angleDelta().y()==0 ? -(event->angleDelta().x())*ConfigManager.getInvertedScrollFactorXfromSettings() : event->angleDelta().y()*ConfigManager.getInvertedScrollFactorYfromSettings() ); 177 | bool orig_horizontal = (m_horizontal_scrolling==1 ? true : false); 178 | if (orig_horizontal!=horizontal_now) return; 179 | if (pages[0]->pos().y()-delta<=0 && pages[0]->pos().y()-delta>=-height()*(getNumberOfElements()-1)) 180 | { 181 | m_scrolltimeouttimer->stop(); 182 | scrolled = true; 183 | mouse_pos_scroll_0 = QCursor::pos(); 184 | for (PagerItem *page_i : pages) 185 | { 186 | page_i->move(page_i->pos().x(),page_i->pos().y()-delta); 187 | } 188 | m_scrolltimeouttimer = new QTimer(); 189 | connect(m_scrolltimeouttimer,&QTimer::timeout,this,&VerticalPager::finishScrolling); 190 | m_scrolltimeouttimer->setSingleShot(true); 191 | m_scrolltimeouttimer->start(250); 192 | } 193 | else { 194 | // we've reached the last/first page, don't do anything anymore 195 | current_element = (-pages[0]->pos().y()+height()/2)/height(); 196 | element_before_entering_submenu = (!in_subfolder ? current_element : element_before_entering_submenu); 197 | new_element = current_element; 198 | for (int i=0;i<(int)pages.size(); i++) 199 | { 200 | pages[i]->move(QPoint(pages[i]->pos().x(),(i-new_element)*height())); 201 | } 202 | } 203 | } 204 | } 205 | event->accept(); 206 | } 207 | 208 | // *********************************************** 209 | // SLOTS 210 | // *********************************************** 211 | 212 | void VerticalPager::activateSearch(const QString &query) 213 | { 214 | if (scrolled) // pages have been scrolled 215 | { 216 | m_scrolltimeouttimer->stop(); 217 | if (mouse_pos_scroll_0!=QCursor::pos()) 218 | { 219 | current_element = (-pages[0]->pos().y()+height()/2)/height(); 220 | element_before_entering_submenu = (!in_subfolder ? current_element : element_before_entering_submenu); 221 | new_element = current_element; 222 | scrolled = false; 223 | } 224 | } 225 | Pager::activateSearch(query); 226 | } 227 | 228 | void VerticalPager::goToPage(int deltaPage) 229 | { 230 | if (current_element+deltaPage==getNumberOfElements() || current_element+deltaPage==-1) return; 231 | if (searching) return; 232 | int newpage = current_element+deltaPage; 233 | for (int i=0;i<(int)pages.size(); i++) 234 | { 235 | pages[i]->move(QPoint(pages[i]->pos().x(),(i-newpage)*height())); 236 | } 237 | if (deltaPage==1) 238 | { 239 | IconGrid * oldGrid = pages[current_element]->getIconGrid(); 240 | int oldElement = oldGrid->getActiveElement(); // 0 ... N_elements 241 | int oldElementColumn = (oldElement) % oldGrid->getMaxNumberOfColumns()+1; // 1...N_cols 242 | IconGrid * newGrid = pages[current_element+1]->getIconGrid(); 243 | if (oldElementColumn > newGrid->getCurrentNumberOfColumns()) 244 | { 245 | newGrid->highlight(newGrid->getCurrentNumberOfColumns()-1); 246 | } 247 | else 248 | { 249 | newGrid->highlight((oldElementColumn-1==-1 ? 0 : oldElementColumn-1)); 250 | } 251 | } 252 | if (deltaPage==-1) 253 | { 254 | IconGrid * oldGrid = pages[current_element]->getIconGrid(); 255 | int oldElement = oldGrid->getActiveElement(); // 0 ... N_elements 256 | int oldElementColumn = (oldElement) % oldGrid->getMaxNumberOfColumns()+1; // 1...N_cols 257 | IconGrid * newGrid = pages[current_element-1]->getIconGrid(); 258 | newGrid->highlight(newGrid->getNumberOfItems()-(newGrid->getMaxNumberOfColumns()-oldElementColumn)-1); 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | } 267 | 268 | 269 | current_element = newpage; 270 | new_element = current_element; 271 | element_before_entering_submenu = (!in_subfolder ? current_element : element_before_entering_submenu); 272 | page_turned = true; 273 | } 274 | 275 | void VerticalPager::finishScrolling() 276 | { 277 | current_element = (-pages[0]->pos().y()+height()/2)/height(); 278 | element_before_entering_submenu = (!in_subfolder ? current_element : element_before_entering_submenu); 279 | new_element = current_element; 280 | scrolled = false; 281 | touchpad = false; 282 | if (pages[0]->pos().y()!=0 || pages[0]->pos().y()!=-height()*(getNumberOfElements()-1)) 283 | { 284 | QParallelAnimationGroup * animationgroup = new QParallelAnimationGroup; 285 | for (int i=0;i<(int)pages.size(); i++) 286 | { 287 | QPropertyAnimation * animation = new QPropertyAnimation(pages[i],"pos"); 288 | animation->setTargetObject(pages[i]); 289 | animation->setStartValue(pages[i]->pos()); 290 | animation->setEndValue(QPoint(pages[i]->pos().x(),(i-new_element)*height())); 291 | animation->setDuration(100); 292 | animationgroup->addAnimation(animation); 293 | } 294 | animationgroup->start(); 295 | } 296 | m_horizontal_scrolling = 0; 297 | } 298 | 299 | void VerticalPager::updatePagerAndPlayAnimationIfOnePageLess() 300 | { 301 | int numberofelementsbefore = getNumberOfElements(); 302 | updatePager(m_kapplication_tree); 303 | // move pager to the right position if there is one page less, and we are on the last page 304 | if (getNumberOfElements() != numberofelementsbefore && element_before_entering_submenu==numberofelementsbefore-1) 305 | { 306 | current_element = getNumberOfElements()-1; 307 | element_before_entering_submenu = current_element; 308 | new_element = current_element; 309 | QParallelAnimationGroup * animationgroup = new QParallelAnimationGroup; 310 | for (int i=0;i<(int)pages.size(); i++) 311 | { 312 | QPropertyAnimation * animation = new QPropertyAnimation(pages[i],"pos"); 313 | animation->setTargetObject(pages[i]); 314 | animation->setStartValue(pages[i]->pos()); 315 | animation->setEndValue(QPoint(pages[i]->pos().x(),(i-new_element)*height())); 316 | animation->setDuration(100); 317 | animationgroup->addAnimation(animation); 318 | } 319 | animationgroup->start(); 320 | } 321 | } 322 | 323 | void VerticalPager::setTimerDragDelta(QDragMoveEvent *event) 324 | { 325 | if (!m_timer_drag_switch->isActive()) 326 | { 327 | if (event->pos().y()>pages[current_element]->getIconGrid()->geometry().bottom() 328 | && current_element+1pos().y()getIconGrid()->geometry().top() 333 | && current_element-1>=0) 334 | { 335 | m_timer_drag_delta = -1; 336 | } 337 | if (m_timer_drag_delta!=0) 338 | { 339 | m_timer_drag_mouse_pos = QCursor::pos(); 340 | m_timer_drag_switch->start(750); 341 | } 342 | } 343 | } 344 | -------------------------------------------------------------------------------- /Rocket/pager/verticalpager.h: -------------------------------------------------------------------------------- 1 | #ifndef VERTICALPAGER_H 2 | #define VERTICALPAGER_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | #include "pager/pager.h" 14 | #include "pager/pageritem.h" 15 | #include "../RocketLibrary/tools/kmenuitems.h" 16 | 17 | class VerticalPager : public Pager 18 | { 19 | Q_OBJECT 20 | public: 21 | ~VerticalPager() {} 22 | 23 | explicit VerticalPager(QWidget * parent, std::vector appTree, bool withBackgound); 24 | void constructPager(std::vector kapplications) override; 25 | void updatePager(std::vector kapplications) override; 26 | 27 | void mouseReleaseEvent(QMouseEvent * event) override; 28 | void mouseMoveEvent(QMouseEvent * event) override; 29 | void wheelEvent(QWheelEvent *event) override; 30 | 31 | public slots: 32 | void activateSearch(const QString & query) override; 33 | void goToPage(int deltaPage) override; 34 | void finishScrolling() override; 35 | void updatePagerAndPlayAnimationIfOnePageLess() override; 36 | virtual void enterIconDraggingMode(bool on, IconGridItemCanvas * canvas = nullptr) override 37 | { 38 | Pager::enterIconDraggingMode(on,canvas); 39 | } 40 | 41 | private: 42 | void setTimerDragDelta(QDragMoveEvent *event) override; 43 | }; 44 | 45 | #endif // VERTICALPAGER_H 46 | -------------------------------------------------------------------------------- /Rocket/searchfield/searchfield.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "searchfield.h" 6 | 7 | #include "../RocketLibrary/tools/rocketconfigmanager.h" 8 | 9 | SearchField::SearchField(QWidget *parent) : QLineEdit(parent) 10 | { 11 | keyEnterReceiver* key = new keyEnterReceiver(); 12 | installEventFilter(key); 13 | } 14 | 15 | void SearchField::positioning() 16 | { 17 | QRect g = parentWidget()->geometry(); 18 | setGeometry((g.width()-width())*0.5,(g.height()*0.1-height())*0.5,g.width()*0.2,g.height()*0.05); 19 | } 20 | 21 | void SearchField::resizeEvent(QResizeEvent *event) 22 | { 23 | if (parentWidget()->size().width()<17) 24 | { 25 | event->accept(); 26 | return; 27 | } 28 | 29 | //it costs less time to set these properties here 30 | setAutoFillBackground(true); 31 | setPlaceholderText("search"); 32 | addAction(QIcon::fromTheme("search"),QLineEdit::LeadingPosition); 33 | 34 | QFont fieldfont = font(); 35 | fieldfont.setPointSize(ConfigManager.getFontSize1()); 36 | setFont(fieldfont); 37 | positioning(); 38 | } 39 | 40 | void SearchField::keyPressEvent(QKeyEvent *event) 41 | { 42 | std::vector navigationKeys = {Qt::Key::Key_Right,Qt::Key::Key_Left,Qt::Key::Key_Up,Qt::Key::Key_Down, Qt::Key::Key_Escape, Qt::Key::Key_Tab}; 43 | if (std::find(navigationKeys.begin(),navigationKeys.end(),event->key())!=navigationKeys.end()) 44 | { 45 | navigate(event->key()); 46 | event->accept(); 47 | } 48 | else { 49 | if (isVisible()) 50 | QLineEdit::keyPressEvent(event); 51 | event->accept(); 52 | } 53 | } 54 | 55 | bool keyEnterReceiver::eventFilter(QObject* obj, QEvent* event) 56 | { 57 | if (event->type()==QEvent::KeyPress) { 58 | QKeyEvent* key = static_cast(event); 59 | if ( (key->key()==Qt::Key_Enter) || (key->key()==Qt::Key_Return) ) { 60 | //Enter or return was pressed 61 | ((SearchField*)obj)->returnPressed(); 62 | } else { 63 | return QObject::eventFilter(obj, event); 64 | } 65 | return true; 66 | } else { 67 | return QObject::eventFilter(obj, event); 68 | } 69 | return false; 70 | } 71 | -------------------------------------------------------------------------------- /Rocket/searchfield/searchfield.h: -------------------------------------------------------------------------------- 1 | #ifndef SEARCHFIELD_H 2 | #define SEARCHFIELD_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | class SearchField : public QLineEdit 10 | { 11 | Q_OBJECT 12 | public: 13 | explicit SearchField(QWidget *parent); 14 | void positioning(); 15 | void keyPressEvent(QKeyEvent *event); 16 | void resizeEvent(QResizeEvent *event); 17 | 18 | signals: 19 | void navigate(int key); 20 | }; 21 | 22 | class keyEnterReceiver : public QObject 23 | { 24 | Q_OBJECT 25 | protected: 26 | bool eventFilter(QObject* obj, QEvent* event); 27 | }; 28 | 29 | #endif // SEARCHFIELD_H 30 | -------------------------------------------------------------------------------- /Rocket/tools/searchingapps.cpp: -------------------------------------------------------------------------------- 1 | #include "../RocketLibrary/tools/kdeapplication.h" 2 | 3 | std::vector searchApplication(std::vector list, QString query) 4 | { 5 | if (query=="") return list; 6 | std::vector res; 7 | for (KDEApplication i : list) 8 | { 9 | if (i.name().contains(query,Qt::CaseSensitivity::CaseInsensitive)) 10 | { 11 | res.push_back(i); 12 | continue; 13 | } 14 | if (i.genericname().contains(query,Qt::CaseSensitivity::CaseInsensitive)) 15 | { 16 | res.push_back(i); 17 | continue; 18 | } 19 | if (i.untranslatedGenericName().contains(query,Qt::CaseSensitivity::CaseInsensitive)) 20 | { 21 | res.push_back(i); 22 | continue; 23 | } 24 | if (i.exec().contains(query,Qt::CaseSensitivity::CaseInsensitive)) 25 | { 26 | res.push_back(i); 27 | continue; 28 | } 29 | if (i.comment().contains(query,Qt::CaseSensitivity::CaseInsensitive)) 30 | { 31 | res.push_back(i); 32 | continue; 33 | } 34 | bool found = false; 35 | for (QString i2 : i.keywords()) 36 | { 37 | if (i2.contains(query,Qt::CaseSensitivity::CaseInsensitive)) 38 | { 39 | res.push_back(i); 40 | found = true; 41 | break; 42 | } 43 | } 44 | if (found) continue; 45 | found = false; 46 | for (QString i2 : i.categories()) 47 | { 48 | if(i2.contains(query,Qt::CaseSensitivity::CaseInsensitive)) 49 | { 50 | res.push_back(i); 51 | found = true; 52 | break; 53 | } 54 | } 55 | if (found) continue; 56 | } 57 | return res; 58 | } 59 | 60 | std::vector searchApplicationTree(std::vector apptree, KDEApplication item) 61 | { 62 | int index1 = 0; 63 | int index2 = -1; 64 | bool found = false; 65 | for (int i=0;i<(int)apptree.size();i++) 66 | { 67 | if (apptree[i].isFolder()) 68 | if (!(item==apptree[i])) 69 | for (int j=0;j<(int)apptree[i].getChildren().size();j++) 70 | { 71 | if (item==apptree[i].getChildren()[j]) 72 | { 73 | index1 = i; 74 | index2 = j; 75 | found = true; 76 | break; 77 | } 78 | } 79 | else { 80 | index1 = i; 81 | found = true; 82 | } 83 | else { 84 | if (item==apptree[i]) 85 | { 86 | index1 = i; 87 | found = true; 88 | } 89 | } 90 | if (found) break; 91 | } 92 | return std::vector({index1,index2}); 93 | } 94 | -------------------------------------------------------------------------------- /Rocket/tools/searchingapps.h: -------------------------------------------------------------------------------- 1 | #ifndef SEARCHINGAPPS_H 2 | #define SEARCHINGAPPS_H 3 | 4 | #include 5 | #include "../RocketLibrary/tools/kdeapplication.h" 6 | 7 | std::vector searchApplication(std::vector list, QString query); 8 | std::vector searchApplicationTree(std::vector apptree, KDEApplication item); 9 | 10 | #endif // SEARCHINGAPPS_H 11 | -------------------------------------------------------------------------------- /RocketDesigner/RocketDesigner.pro: -------------------------------------------------------------------------------- 1 | #------------------------------------------------- 2 | # 3 | # Project created by QtCreator 2021-04-19T21:43:39 4 | # 5 | #------------------------------------------------- 6 | 7 | QT += core gui KIOCore KIOFileWidgets KIOWidgets KNTLM KI18n KConfigCore KConfigGui 8 | 9 | greaterThan(QT_MAJOR_VERSION, 4): QT += widgets 10 | 11 | TARGET = RocketDesigner 12 | TEMPLATE = app 13 | INCLUDEPATH += ../Rocket 14 | DEPENDPATH += ../Rocket 15 | 16 | # The following define makes your compiler emit warnings if you use 17 | # any feature of Qt which has been marked as deprecated (the exact warnings 18 | # depend on your compiler). Please consult the documentation of the 19 | # deprecated API in order to know how to port your code away from it. 20 | DEFINES += QT_DEPRECATED_WARNINGS 21 | 22 | # You can also make your code fail to compile if you use deprecated APIs. 23 | # In order to do so, uncomment the following line. 24 | # You can also select to disable deprecated APIs only up to a certain version of Qt. 25 | #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 26 | 27 | CONFIG += c++11 28 | 29 | SOURCES += \ 30 | main.cpp \ 31 | mainwindow.cpp \ 32 | ../RocketLibrary/rocketlibrary.cpp \ 33 | ../RocketLibrary/tools/rocketconfigmanager.cpp \ 34 | ../RocketLibrary/tools/kmenuitems.cpp \ 35 | ../RocketLibrary/tools/kdeapplication.cpp 36 | 37 | 38 | HEADERS += \ 39 | mainwindow.h \ 40 | ../RocketLibrary/rocketlibrary.h \ 41 | ../RocketLibrary/tools/rocketconfigmanager.h \ 42 | ../RocketLibrary/tools/kmenuitems.h \ 43 | ../RocketLibrary/tools/kdeapplication.h 44 | 45 | FORMS += \ 46 | mainwindow.ui 47 | 48 | # Default rules for deployment. 49 | qnx: target.path = /tmp/$${TARGET}/bin 50 | else: unix:!android: target.path = /opt/$${TARGET}/bin 51 | !isEmpty(target.path): INSTALLS += target 52 | 53 | SUBDIRS += \ 54 | ../RocketLibrary/RocketLibrary.pro \ 55 | ../Rocket.pro 56 | -------------------------------------------------------------------------------- /RocketDesigner/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "mainwindow.h" 6 | 7 | #include "../RocketLibrary/rocketlibrary.h" 8 | #include "../RocketLibrary/tools/rocketconfigmanager.h" 9 | 10 | extern RocketConfigManager ConfigManager = RocketConfigManager(); 11 | 12 | int main(int argc, char *argv[]) 13 | { 14 | QApplication a(argc, argv); 15 | 16 | QString name = QString("rocket"); 17 | 18 | KConfig styleconfig(QDir::homePath()+"/.config/"+name+"/"+name+"style",KConfig::OpenFlag::SimpleConfig); 19 | KConfig appgridconfig(QDir::homePath()+"/.config/"+name+"/"+name+"appgrid",KConfig::OpenFlag::SimpleConfig); 20 | 21 | ConfigManager.setStyleConfig(&styleconfig); 22 | ConfigManager.checkStyleConfigFile(); 23 | ConfigManager.setAppGridConfig(&appgridconfig); 24 | ConfigManager.checkAppGridConfigFile(); 25 | 26 | MainWindow w; 27 | w.show(); 28 | 29 | return a.exec(); 30 | } 31 | -------------------------------------------------------------------------------- /RocketDesigner/mainwindow.cpp: -------------------------------------------------------------------------------- 1 | #include "mainwindow.h" 2 | #include "ui_mainwindow.h" 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | #include 11 | 12 | MainWindow::MainWindow(QWidget *parent) : 13 | QMainWindow(parent), 14 | ui(new Ui::MainWindow) 15 | { 16 | ui->setupUi(this); 17 | setFixedSize(size()); 18 | 19 | /* 20 | * Rocket Meta Setting 21 | * */ 22 | m_rocketMetaCheckBox = findChild("rocketMetaCheckBox"); 23 | m_rocketMetaCheckBox->setChecked(ConfigManager.getStyleValue(RocketConfig::Settings::group,RocketConfig::Settings::metastart,RocketStyle::kwin_start_meta)); 24 | 25 | /* 26 | * Grid Properties Box 27 | * */ 28 | 29 | m_rowSpin = findChild("rowSpin"); 30 | m_rowSpin->setValue(ConfigManager.getRowNumber()); 31 | 32 | m_columnSpin = findChild("columnSpin"); 33 | m_columnSpin->setValue(ConfigManager.getColumnNumber()); 34 | 35 | m_horizontalInversionCheckBox = findChild("horizontalInversionCheckBox"); 36 | m_horizontalInversionCheckBox->setChecked(ConfigManager.getStyleValue(RocketConfig::Settings::group,RocketConfig::Settings::invertedscrollingx,RocketStyle::inverted_scrolling_x)); 37 | 38 | m_verticalInversionCheckBox = findChild("verticalInversionCheckBox"); 39 | m_verticalInversionCheckBox->setChecked(ConfigManager.getStyleValue(RocketConfig::Settings::group,RocketConfig::Settings::invertedscrollingy,RocketStyle::inverted_scrolling_y)); 40 | 41 | m_gridOrientationCombo = findChild("gridOrientationCombo"); 42 | m_gridOrientationCombo->setCurrentIndex(ConfigManager.getVerticalModeSetting()); 43 | 44 | m_enableBoxesCheckBox = findChild("enableBoxesCheckBox"); 45 | m_enableBoxesCheckBox->setChecked(ConfigManager.getBoxSetting()); 46 | 47 | m_tightLayoutCheckBox = findChild("tightLayoutCheckBox"); 48 | m_tightLayoutCheckBox->setChecked(ConfigManager.getTightLayoutSetting()); 49 | 50 | m_systemWallpaperCheckBox = findChild("systemWallpaperCheckBox"); 51 | m_systemWallpaperCheckBox->setChecked(ConfigManager.getUsingSystemWallpaper()); 52 | 53 | m_systemWallpaperScreenSpin = findChild("systemWallpaperScreenSpin"); 54 | KConfig config(QDir::homePath()+"/.config/plasma-org.kde.plasma.desktop-appletsrc"); 55 | QStringList wallpaper_candidates; 56 | QStringList list = config.group("Containments").groupList(); 57 | for (QString l : list) 58 | { 59 | if (config.group("Containments").group(l).groupList().contains("Wallpaper")) 60 | { 61 | QString variable = config.group("Containments").group(l).group("Wallpaper").group("org.kde.image").group("General").readEntry("Image"); 62 | if (variable.split("file://").size()>1) 63 | { 64 | wallpaper_candidates.push_back(config.group("Containments").group(l).readEntry("lastScreen")+variable.split("file://")[1]); 65 | } 66 | else 67 | { 68 | if (variable.at(variable.size()-1)!="/") wallpaper_candidates.push_back(config.group("Containments").group(l).readEntry("lastScreen")+variable); 69 | } 70 | } 71 | } 72 | wallpaper_candidates.sort(); 73 | int candidate = (ConfigManager.getWallpaperScreen()>=wallpaper_candidates.size() ? 0 : ConfigManager.getWallpaperScreen()); 74 | m_systemWallpaperScreenSpin->setMaximum(wallpaper_candidates.size()-1); 75 | m_systemWallpaperScreenSpin->setValue(candidate); 76 | 77 | m_systemWallpaperBlurSpin = findChild("systemWallpaperBlurSpin"); 78 | m_systemWallpaperBlurSpin->setValue(ConfigManager.getBlurRadius()); 79 | 80 | QString wallpaper_path = wallpaper_candidates[candidate].right(wallpaper_candidates[candidate].size()-1); 81 | if (!ConfigManager.getUsingSystemWallpaper()) wallpaper_path= QDir::homePath()+"/.config/rocket/wallpaper.jpeg"; 82 | QLabel * wallpaperLabel = findChild("wallpaperLabel"); 83 | wallpaperLabel->setText(wallpaper_path.split("/").last()); 84 | wallpaperLabel->setToolTip(wallpaper_path); 85 | QLabel * currentWallpaperLabel = findChild("currentWallpaperLabel"); 86 | currentWallpaperLabel->setToolTip(wallpaper_path); 87 | 88 | connect(m_systemWallpaperCheckBox,&QCheckBox::toggled,wallpaperLabel,[=](){ 89 | QString wallpaper_path = wallpaper_candidates[candidate].right(wallpaper_candidates[candidate].size()-1); 90 | if (!m_systemWallpaperCheckBox->isChecked()) wallpaper_path = QDir::homePath()+"/.config/rocket/wallpaper.jpeg"; 91 | wallpaperLabel->setText(wallpaper_path.split("/").last()); 92 | wallpaperLabel->setToolTip(wallpaper_path); 93 | currentWallpaperLabel->setToolTip(wallpaper_path); 94 | }); 95 | 96 | connect(m_systemWallpaperScreenSpin,QOverload::of(&QSpinBox::valueChanged),wallpaperLabel,[=](int i){ 97 | int candidate = i; 98 | QString wallpaper_path = wallpaper_candidates[candidate].right(wallpaper_candidates[candidate].size()-1); 99 | wallpaperLabel->setText(wallpaper_path.split("/").last()); 100 | wallpaperLabel->setToolTip(wallpaper_path); 101 | currentWallpaperLabel->setToolTip(wallpaper_path); 102 | }); 103 | 104 | QPushButton * wallpaperSelectorButton = findChild("wallpaperSelectorButton"); 105 | QFileDialog * wallpaperDialog = new QFileDialog(this,"Rocket Wallpaper Selection",QDir::homePath(),"Images (*.jpg *.jpeg *.png)"); 106 | connect(wallpaperSelectorButton,&QPushButton::pressed,wallpaperDialog,[=](){ 107 | wallpaperDialog->setFileMode(QFileDialog::FileMode::ExistingFile); 108 | if(wallpaperDialog->exec()) 109 | { 110 | QString file = wallpaperDialog->selectedFiles()[0]; 111 | qDebug() << file; 112 | if (QFile::exists(QDir::homePath()+"/.config/rocket/wallpaper.jpeg")) 113 | QFile::remove(QDir::homePath()+"/.config/rocket/wallpaper.jpeg"); 114 | QFile::copy(file,QDir::homePath()+"/.config/rocket/wallpaper.jpeg"); 115 | } 116 | }); 117 | 118 | /* 119 | * Font Size Box 120 | * */ 121 | 122 | m_font1Spin = findChild("font1Spin"); 123 | m_font1Spin->setValue(ConfigManager.getFontSize1()); 124 | 125 | m_font2Spin = findChild("font2Spin"); 126 | m_font2Spin->setValue(ConfigManager.getFontSize2()); 127 | 128 | /* 129 | * Base Colour Box 130 | * */ 131 | m_basecolour = ConfigManager.getBaseColour(); 132 | 133 | m_baseLabel_r = findChild("baseColourLabel_r"); 134 | m_baseLabel_r->setText(QString::number(m_basecolour.red())); 135 | m_baseLabel_g = findChild("baseColourLabel_g"); 136 | m_baseLabel_g->setText(QString::number(m_basecolour.green())); 137 | m_baseLabel_b = findChild("baseColourLabel_b"); 138 | m_baseLabel_b->setText(QString::number(m_basecolour.blue())); 139 | m_baseLabel_a = findChild("baseColourLabel_a"); 140 | m_baseLabel_a->setText(QString::number(m_basecolour.alpha())); 141 | 142 | m_baseColourPanel = findChild("baseColourPanel"); 143 | m_baseColourPanel->setAutoFillBackground(true); 144 | m_baseColourPanel->setPalette(QPalette(QColor(m_basecolour))); 145 | 146 | QPushButton * baseColourPickerButton = findChild("baseColourPickerButton"); 147 | QColorDialog * baseColourDialog = new QColorDialog(nullptr); 148 | connect(baseColourPickerButton,&QPushButton::clicked,baseColourDialog,[=](){ 149 | QColor newcolor = baseColourDialog->getColor(QColor(m_baseLabel_r->text().toInt(),m_baseLabel_g->text().toInt(),m_baseLabel_b->text().toInt(),m_baseLabel_a->text().toInt()),nullptr,"Base Color",QColorDialog::ColorDialogOption::ShowAlphaChannel); 150 | if (newcolor.isValid()) 151 | { 152 | m_baseColourPanel->setPalette(QPalette(newcolor)); 153 | m_baseLabel_r->setText(QString::number(newcolor.red())); 154 | m_baseLabel_g->setText(QString::number(newcolor.green())); 155 | m_baseLabel_b->setText(QString::number(newcolor.blue())); 156 | m_baseLabel_a->setText(QString::number(newcolor.alpha())); 157 | m_basecolour = newcolor; 158 | } 159 | }); 160 | 161 | /* 162 | * Secondary Colour Box 163 | * */ 164 | m_secondarycolour = ConfigManager.getSecondaryColour(); 165 | 166 | m_secondaryLabel_r = findChild("secondaryColourLabel_r"); 167 | m_secondaryLabel_r->setText(QString::number(m_secondarycolour.red())); 168 | m_secondaryLabel_g = findChild("secondaryColourLabel_g"); 169 | m_secondaryLabel_g->setText(QString::number(m_secondarycolour.green())); 170 | m_secondaryLabel_b = findChild("secondaryColourLabel_b"); 171 | m_secondaryLabel_b->setText(QString::number(m_secondarycolour.blue())); 172 | m_secondaryLabel_a = findChild("secondaryColourLabel_a"); 173 | m_secondaryLabel_a->setText(QString::number(m_secondarycolour.alpha())); 174 | 175 | m_secondaryColourPanel = findChild("secondaryColourPanel"); 176 | m_secondaryColourPanel->setAutoFillBackground(true); 177 | m_secondaryColourPanel->setPalette(QPalette(QColor(m_secondarycolour))); 178 | 179 | QPushButton * secondaryColourPickerButton = findChild("secondaryColourPickerButton"); 180 | QColorDialog * secondaryColourDialog = new QColorDialog(nullptr); 181 | connect(secondaryColourPickerButton,&QPushButton::clicked,secondaryColourDialog,[=](){ 182 | QColor newcolor = secondaryColourDialog->getColor(QColor(m_secondaryLabel_r->text().toInt(),m_secondaryLabel_g->text().toInt(),m_secondaryLabel_b->text().toInt(),m_secondaryLabel_a->text().toInt()),nullptr,"Secondary Color",QColorDialog::ColorDialogOption::ShowAlphaChannel); 183 | if (newcolor.isValid()) 184 | { 185 | m_secondaryColourPanel->setPalette(QPalette(newcolor)); 186 | m_secondaryLabel_r->setText(QString::number(newcolor.red())); 187 | m_secondaryLabel_g->setText(QString::number(newcolor.green())); 188 | m_secondaryLabel_b->setText(QString::number(newcolor.blue())); 189 | m_secondaryLabel_a->setText(QString::number(newcolor.alpha())); 190 | m_secondarycolour = newcolor; 191 | } 192 | }); 193 | 194 | /* 195 | * Selection Colour Box 196 | * */ 197 | m_selectioncolour = ConfigManager.getSelectionColour(); 198 | 199 | m_selectionLabel_r = findChild("selectionColourLabel_r"); 200 | m_selectionLabel_r->setText(QString::number(m_selectioncolour.red())); 201 | m_selectionLabel_g = findChild("selectionColourLabel_g"); 202 | m_selectionLabel_g->setText(QString::number(m_selectioncolour.green())); 203 | m_selectionLabel_b = findChild("selectionColourLabel_b"); 204 | m_selectionLabel_b->setText(QString::number(m_selectioncolour.blue())); 205 | m_selectionLabel_a = findChild("selectionColourLabel_a"); 206 | m_selectionLabel_a->setText(QString::number(m_selectioncolour.alpha())); 207 | 208 | m_selectionColourPanel = findChild("selectionColourPanel"); 209 | m_selectionColourPanel->setAutoFillBackground(true); 210 | m_selectionColourPanel->setPalette(QPalette(QColor(m_selectioncolour))); 211 | 212 | QPushButton * selectionColourPickerButton = findChild("selectionColourPickerButton"); 213 | QColorDialog * selectionColourDialog = new QColorDialog(nullptr); 214 | connect(selectionColourPickerButton,&QPushButton::clicked,selectionColourDialog,[=](){ 215 | QColor newcolor = selectionColourDialog->getColor(QColor(m_selectionLabel_r->text().toInt(),m_selectionLabel_g->text().toInt(),m_selectionLabel_b->text().toInt(),m_selectionLabel_a->text().toInt()),nullptr,"Selection Color",QColorDialog::ColorDialogOption::ShowAlphaChannel); 216 | if (newcolor.isValid()) 217 | { 218 | m_selectionColourPanel->setPalette(QPalette(newcolor)); 219 | m_selectionLabel_r->setText(QString::number(newcolor.red())); 220 | m_selectionLabel_g->setText(QString::number(newcolor.green())); 221 | m_selectionLabel_b->setText(QString::number(newcolor.blue())); 222 | m_selectionLabel_a->setText(QString::number(newcolor.alpha())); 223 | m_selectioncolour = newcolor; 224 | } 225 | }); 226 | 227 | /* 228 | * Buttons 229 | * */ 230 | 231 | QDialogButtonBox * buttonBox = findChild("buttonBox"); 232 | connect(buttonBox->button(QDialogButtonBox::Ok),&QPushButton::clicked,this,&MainWindow::OkClicked); 233 | connect(buttonBox->button(QDialogButtonBox::Reset),&QPushButton::clicked,this,&MainWindow::ResetClicked); 234 | connect(buttonBox->button(QDialogButtonBox::Apply),&QPushButton::clicked,this,&MainWindow::ApplyClicked); 235 | connect(buttonBox->button(QDialogButtonBox::Cancel),&QPushButton::clicked,this,&MainWindow::CancelClicked); 236 | } 237 | 238 | void MainWindow::OkClicked() 239 | { 240 | ApplyClicked(); 241 | CancelClicked(); 242 | } 243 | 244 | void MainWindow::ResetClicked() 245 | { 246 | m_rocketMetaCheckBox->setChecked(RocketStyle::kwin_start_meta); 247 | 248 | m_rowSpin->setValue(RocketStyle::m_rows); 249 | m_columnSpin->setValue(RocketStyle::m_cols); 250 | m_horizontalInversionCheckBox->setChecked(RocketStyle::inverted_scrolling_x); 251 | m_verticalInversionCheckBox->setChecked(RocketStyle::inverted_scrolling_y); 252 | m_gridOrientationCombo->setCurrentIndex((int)(RocketStyle::pager_vertical_orientation)); 253 | m_enableBoxesCheckBox->setChecked(RocketStyle::enable_boxes); 254 | m_tightLayoutCheckBox->setChecked(RocketStyle::tightlayout); 255 | m_systemWallpaperCheckBox->setChecked(RocketStyle::use_system_wallpaper); 256 | m_systemWallpaperScreenSpin->setValue(RocketStyle::use_system_wallpaper_screen); 257 | m_systemWallpaperBlurSpin->setValue(RocketStyle::blurradius); 258 | 259 | m_font1Spin->setValue(RocketStyle::fontsize1); 260 | m_font2Spin->setValue(RocketStyle::fontsize2); 261 | 262 | m_basecolour = RocketStyle::BaseColour; 263 | m_baseColourPanel->setPalette(QPalette(m_basecolour)); 264 | m_baseLabel_r->setText(QString::number(m_basecolour.red())); 265 | m_baseLabel_g->setText(QString::number(m_basecolour.green())); 266 | m_baseLabel_b->setText(QString::number(m_basecolour.blue())); 267 | m_baseLabel_a->setText(QString::number(m_basecolour.alpha())); 268 | 269 | m_secondarycolour = RocketStyle::SecondaryColour; 270 | m_secondaryColourPanel->setPalette(QPalette(m_secondarycolour)); 271 | m_secondaryLabel_r->setText(QString::number(m_secondarycolour.red())); 272 | m_secondaryLabel_g->setText(QString::number(m_secondarycolour.green())); 273 | m_secondaryLabel_b->setText(QString::number(m_secondarycolour.blue())); 274 | m_secondaryLabel_a->setText(QString::number(m_secondarycolour.alpha())); 275 | 276 | m_selectioncolour = RocketStyle::SelectionColour; 277 | m_selectionColourPanel->setPalette(QPalette(m_selectioncolour)); 278 | m_selectionLabel_r->setText(QString::number(m_selectioncolour.red())); 279 | m_selectionLabel_g->setText(QString::number(m_selectioncolour.green())); 280 | m_selectionLabel_b->setText(QString::number(m_selectioncolour.blue())); 281 | m_selectionLabel_a->setText(QString::number(m_selectioncolour.alpha())); 282 | } 283 | 284 | void MainWindow::ApplyClicked() 285 | { 286 | KConfig * config = ConfigManager.getStyleConfig(); 287 | 288 | // Rocket Meta Setting 289 | KConfig kwin_config(QDir::homePath()+"/.config/kwinrc"); 290 | QString kwin_value = kwin_config.group("ModifierOnlyShortcuts").readEntry("Meta"); 291 | QString config_value = QString(ConfigManager.getStyleValue(RocketConfig::Settings::group,RocketConfig::Settings::kwinrcoldmeta)); 292 | if (kwin_value!=config_value && kwin_value!=RocketStyle::kwindbus) 293 | { 294 | // backup 295 | config->group(RocketConfig::Settings::group).writeEntry(RocketConfig::Settings::kwinrcoldmeta,kwin_value); 296 | } 297 | if (m_rocketMetaCheckBox->isChecked()) 298 | { 299 | kwin_config.group("ModifierOnlyShortcuts").writeEntry("Meta",RocketStyle::kwindbus); 300 | } 301 | else 302 | { 303 | if (kwin_value==RocketStyle::kwindbus) 304 | { 305 | if (config_value=="") 306 | { 307 | kwin_config.group("ModifierOnlyShortcuts").deleteEntry("Meta"); 308 | } 309 | else { 310 | kwin_config.group("ModifierOnlyShortcuts").writeEntry("Meta",config_value); 311 | } 312 | } 313 | } 314 | if ((m_rocketMetaCheckBox->isChecked()) != (ConfigManager.getStyleValue(RocketConfig::Settings::group,RocketConfig::Settings::metastart,RocketStyle::kwin_start_meta))) 315 | { 316 | QProcess p; 317 | p.start("qdbus org.kde.KWin /KWin reconfigure"); 318 | p.waitForFinished(1000); 319 | } 320 | config->group(RocketConfig::Settings::group).writeEntry(RocketConfig::Settings::metastart,m_rocketMetaCheckBox->isChecked()); 321 | 322 | // Grid Properties Box 323 | config->group(RocketConfig::Dimensions::group).writeEntry(RocketConfig::Dimensions::rows,m_rowSpin->value()); 324 | config->group(RocketConfig::Dimensions::group).writeEntry(RocketConfig::Dimensions::columns,m_columnSpin->value()); 325 | config->group(RocketConfig::Settings::group).writeEntry(RocketConfig::Settings::invertedscrollingx,m_horizontalInversionCheckBox->isChecked()); 326 | config->group(RocketConfig::Settings::group).writeEntry(RocketConfig::Settings::invertedscrollingy,m_verticalInversionCheckBox->isChecked()); 327 | config->group(RocketConfig::Dimensions::group).writeEntry(RocketConfig::Dimensions::verticalorientation,(bool)(m_gridOrientationCombo->currentIndex())); 328 | config->group(RocketConfig::Settings::group).writeEntry(RocketConfig::Settings::enable_boxes,m_enableBoxesCheckBox->isChecked()); 329 | config->group(RocketConfig::Settings::group).writeEntry(RocketConfig::Settings::tightlayout,m_tightLayoutCheckBox->isChecked()); 330 | config->group(RocketConfig::Background::group).writeEntry(RocketConfig::Background::usesystemwallpaper,m_systemWallpaperCheckBox->isChecked()); 331 | config->group(RocketConfig::Background::group).writeEntry(RocketConfig::Background::wallpaperofscreen,m_systemWallpaperScreenSpin->value()); 332 | config->group(RocketConfig::Background::group).writeEntry(RocketConfig::Background::blurradius,m_systemWallpaperBlurSpin->value()); 333 | 334 | // Font 335 | config->group(RocketConfig::Font::group).writeEntry(RocketConfig::Font::size1,m_font1Spin->value()); 336 | config->group(RocketConfig::Font::group).writeEntry(RocketConfig::Font::size2,m_font2Spin->value()); 337 | 338 | // Colours 339 | config->group(RocketConfig::Color::group).writeEntry(RocketConfig::Color::base,m_basecolour); 340 | config->group(RocketConfig::Color::group).writeEntry(RocketConfig::Color::secondary,m_secondarycolour); 341 | config->group(RocketConfig::Color::group).writeEntry(RocketConfig::Color::selection,m_selectioncolour); 342 | 343 | config->sync(); 344 | } 345 | 346 | void MainWindow::CancelClicked() 347 | { 348 | qApp->exit(); 349 | } 350 | 351 | 352 | MainWindow::~MainWindow() 353 | { 354 | delete ui; 355 | } 356 | -------------------------------------------------------------------------------- /RocketDesigner/mainwindow.h: -------------------------------------------------------------------------------- 1 | #ifndef MAINWINDOW_H 2 | #define MAINWINDOW_H 3 | 4 | #include "pager/pager.h" 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | 12 | namespace Ui { 13 | class MainWindow; 14 | } 15 | 16 | class MainWindow : public QMainWindow 17 | { 18 | Q_OBJECT 19 | 20 | public: 21 | explicit MainWindow(QWidget *parent = nullptr); 22 | ~MainWindow(); 23 | 24 | public slots: 25 | void OkClicked(); 26 | void ResetClicked(); 27 | void ApplyClicked(); 28 | void CancelClicked(); 29 | 30 | private: 31 | Ui::MainWindow *ui; 32 | 33 | // Rocket Meta Setting 34 | QCheckBox * m_rocketMetaCheckBox; 35 | 36 | // Grid Properties Box 37 | QSpinBox * m_rowSpin; 38 | QSpinBox * m_columnSpin; 39 | QCheckBox * m_horizontalInversionCheckBox; 40 | QCheckBox * m_verticalInversionCheckBox; 41 | QComboBox * m_gridOrientationCombo; 42 | QCheckBox * m_enableBoxesCheckBox; 43 | QCheckBox * m_tightLayoutCheckBox; 44 | QCheckBox * m_systemWallpaperCheckBox; 45 | QSpinBox * m_systemWallpaperScreenSpin; 46 | QSpinBox * m_systemWallpaperBlurSpin; 47 | 48 | // Font 49 | QSpinBox * m_font1Spin; 50 | QSpinBox * m_font2Spin; 51 | 52 | // Colours 53 | QColor m_basecolour; 54 | QLabel * m_baseLabel_r; 55 | QLabel * m_baseLabel_g; 56 | QLabel * m_baseLabel_b; 57 | QLabel * m_baseLabel_a; 58 | QWidget * m_baseColourPanel; 59 | 60 | QColor m_secondarycolour; 61 | QLabel * m_secondaryLabel_r; 62 | QLabel * m_secondaryLabel_g; 63 | QLabel * m_secondaryLabel_b; 64 | QLabel * m_secondaryLabel_a; 65 | QWidget * m_secondaryColourPanel; 66 | 67 | QColor m_selectioncolour; 68 | QLabel * m_selectionLabel_r; 69 | QLabel * m_selectionLabel_g; 70 | QLabel * m_selectionLabel_b; 71 | QLabel * m_selectionLabel_a; 72 | QWidget * m_selectionColourPanel; 73 | }; 74 | 75 | #endif // MAINWINDOW_H 76 | -------------------------------------------------------------------------------- /RocketLibrary/RocketLibrary.pro: -------------------------------------------------------------------------------- 1 | #------------------------------------------------- 2 | # 3 | # Project created by QtCreator 2021-04-19T21:33:46 4 | # 5 | #------------------------------------------------- 6 | 7 | QT += gui KIOCore KIOFileWidgets KIOWidgets KNTLM KI18n KConfigCore KConfigGui 8 | 9 | TARGET = RocketLibrary 10 | TEMPLATE = lib 11 | CONFIG += staticlib 12 | 13 | # The following define makes your compiler emit warnings if you use 14 | # any feature of Qt which has been marked as deprecated (the exact warnings 15 | # depend on your compiler). Please consult the documentation of the 16 | # deprecated API in order to know how to port your code away from it. 17 | DEFINES += QT_DEPRECATED_WARNINGS 18 | 19 | # You can also make your code fail to compile if you use deprecated APIs. 20 | # In order to do so, uncomment the following line. 21 | # You can also select to disable deprecated APIs only up to a certain version of Qt. 22 | #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 23 | 24 | SOURCES += \ 25 | rocketlibrary.cpp \ 26 | tools/kdeapplication.cpp \ 27 | tools/kmenuitems.cpp \ 28 | tools/rocketconfigmanager.cpp 29 | 30 | HEADERS += \ 31 | rocketlibrary.h \ 32 | tools/kdeapplication.h \ 33 | tools/kmenuitems.h \ 34 | tools/rocketconfigmanager.h 35 | unix { 36 | target.path = /usr/lib 37 | INSTALLS += target 38 | } 39 | -------------------------------------------------------------------------------- /RocketLibrary/RocketLibrary.pro.user: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | EnvironmentId 7 | {070d6804-87d3-4137-bd70-79c322d9c5c3} 8 | 9 | 10 | ProjectExplorer.Project.ActiveTarget 11 | 0 12 | 13 | 14 | ProjectExplorer.Project.EditorSettings 15 | 16 | true 17 | false 18 | true 19 | 20 | Cpp 21 | 22 | CppGlobal 23 | 24 | 25 | 26 | QmlJS 27 | 28 | QmlJSGlobal 29 | 30 | 31 | 2 32 | UTF-8 33 | false 34 | 4 35 | false 36 | 80 37 | true 38 | true 39 | 1 40 | true 41 | false 42 | 0 43 | true 44 | true 45 | 0 46 | 8 47 | true 48 | 1 49 | true 50 | true 51 | true 52 | false 53 | 54 | 55 | 56 | ProjectExplorer.Project.PluginSettings 57 | 58 | 59 | true 60 | 61 | 62 | 63 | ProjectExplorer.Project.Target.0 64 | 65 | Desktop 66 | Desktop 67 | {59f74a71-253a-4ab3-9a42-c56c535c928c} 68 | 0 69 | 0 70 | 0 71 | 72 | /home/m/Documents/Rocket/RocketLibrary/build-RocketLibrary-Desktop-Debug 73 | 74 | 75 | true 76 | qmake 77 | 78 | QtProjectManager.QMakeBuildStep 79 | true 80 | 81 | false 82 | false 83 | false 84 | 85 | 86 | true 87 | Make 88 | 89 | Qt4ProjectManager.MakeStep 90 | 91 | false 92 | 93 | 94 | false 95 | 96 | 2 97 | Build 98 | 99 | ProjectExplorer.BuildSteps.Build 100 | 101 | 102 | 103 | true 104 | Make 105 | 106 | Qt4ProjectManager.MakeStep 107 | 108 | true 109 | clean 110 | 111 | false 112 | 113 | 1 114 | Clean 115 | 116 | ProjectExplorer.BuildSteps.Clean 117 | 118 | 2 119 | false 120 | 121 | Debug 122 | Debug 123 | Qt4ProjectManager.Qt4BuildConfiguration 124 | 2 125 | true 126 | 127 | 128 | /home/m/Documents/Rocket/RocketLibrary/build-RocketLibrary-Desktop-Release 129 | 130 | 131 | true 132 | qmake 133 | 134 | QtProjectManager.QMakeBuildStep 135 | false 136 | 137 | false 138 | false 139 | true 140 | 141 | 142 | true 143 | Make 144 | 145 | Qt4ProjectManager.MakeStep 146 | 147 | false 148 | 149 | 150 | false 151 | 152 | 2 153 | Build 154 | 155 | ProjectExplorer.BuildSteps.Build 156 | 157 | 158 | 159 | true 160 | Make 161 | 162 | Qt4ProjectManager.MakeStep 163 | 164 | true 165 | clean 166 | 167 | false 168 | 169 | 1 170 | Clean 171 | 172 | ProjectExplorer.BuildSteps.Clean 173 | 174 | 2 175 | false 176 | 177 | Release 178 | Release 179 | Qt4ProjectManager.Qt4BuildConfiguration 180 | 0 181 | true 182 | 183 | 184 | /home/m/Documents/Rocket/RocketLibrary/build-RocketLibrary-Desktop-Profile 185 | 186 | 187 | true 188 | qmake 189 | 190 | QtProjectManager.QMakeBuildStep 191 | true 192 | 193 | false 194 | true 195 | true 196 | 197 | 198 | true 199 | Make 200 | 201 | Qt4ProjectManager.MakeStep 202 | 203 | false 204 | 205 | 206 | false 207 | 208 | 2 209 | Build 210 | 211 | ProjectExplorer.BuildSteps.Build 212 | 213 | 214 | 215 | true 216 | Make 217 | 218 | Qt4ProjectManager.MakeStep 219 | 220 | true 221 | clean 222 | 223 | false 224 | 225 | 1 226 | Clean 227 | 228 | ProjectExplorer.BuildSteps.Clean 229 | 230 | 2 231 | false 232 | 233 | Profile 234 | Profile 235 | Qt4ProjectManager.Qt4BuildConfiguration 236 | 0 237 | true 238 | 239 | 3 240 | 241 | 242 | 0 243 | Déploiement 244 | 245 | ProjectExplorer.BuildSteps.Deploy 246 | 247 | 1 248 | Deploy Configuration 249 | 250 | ProjectExplorer.DefaultDeployConfiguration 251 | 252 | 1 253 | 254 | 255 | false 256 | false 257 | 1000 258 | 259 | true 260 | 261 | false 262 | false 263 | false 264 | false 265 | true 266 | 0.01 267 | 10 268 | true 269 | 1 270 | 25 271 | 272 | 1 273 | true 274 | false 275 | true 276 | valgrind 277 | 278 | 0 279 | 1 280 | 2 281 | 3 282 | 4 283 | 5 284 | 6 285 | 7 286 | 8 287 | 9 288 | 10 289 | 11 290 | 12 291 | 13 292 | 14 293 | 294 | 2 295 | 296 | 297 | Custom Executable 298 | 299 | ProjectExplorer.CustomExecutableRunConfiguration 300 | 301 | 3768 302 | false 303 | true 304 | false 305 | false 306 | true 307 | 308 | 309 | 310 | 1 311 | 312 | 313 | 314 | ProjectExplorer.Project.TargetCount 315 | 1 316 | 317 | 318 | ProjectExplorer.Project.Updater.FileVersion 319 | 20 320 | 321 | 322 | Version 323 | 20 324 | 325 | 326 | -------------------------------------------------------------------------------- /RocketLibrary/rocketlibrary.cpp: -------------------------------------------------------------------------------- 1 | #include "rocketlibrary.h" 2 | 3 | -------------------------------------------------------------------------------- /RocketLibrary/rocketlibrary.h: -------------------------------------------------------------------------------- 1 | #ifndef ROCKETLIBRARY_H 2 | #define ROCKETLIBRARY_H 3 | 4 | #include 5 | #include 6 | 7 | namespace RocketStyle { 8 | /* 9 | * Reasonable Defaults. 10 | * White theme 11 | */ 12 | const QColor BaseColour = QColor(255,255,255,200); 13 | const QColor SecondaryColour = QColor(0,0,0,100); 14 | const QColor SelectionColour = QColor(255,255,255,200); 15 | const int fontsize1 = 10; 16 | const int fontsize2 = 20; 17 | const int blurradius = 0; 18 | const bool enable_boxes = true; 19 | const bool tightlayout = true; 20 | const bool enable_folders = true; 21 | 22 | // A click is recongnized only if the mouse moves 10 pixels 23 | const int click_tolerance = 100; 24 | 25 | // IconGrid -- minimum 2 columns, otherwise navigation gets crazy (=it crashes) 26 | const int m_rows = 4; 27 | const int m_cols = 9; 28 | 29 | // IconGridItem 30 | const std::vector icongrid_ratio_rows({3,1}); 31 | 32 | // Pager 33 | const int pager_swpipe_threshold = 200; 34 | const int pager_deadzone_threshold = 50; 35 | 36 | const bool pager_vertical_orientation = false; 37 | 38 | const bool use_system_wallpaper = true; 39 | const int use_system_wallpaper_screen = 0; 40 | const bool inverted_scrolling_x = false; 41 | const bool inverted_scrolling_y = false; 42 | 43 | // Active Indicator 44 | const QBrush active_indicator_brush = QBrush(SecondaryColour,Qt::BrushStyle::SolidPattern); 45 | 46 | // dbus and kwin starter 47 | const QString kwindbus = QString("com.friciwolf.rocket,/,local.rocket.MainWindow,dBusToggleWindowState,_toggle"); 48 | const bool kwin_start_meta = false; 49 | } 50 | 51 | namespace RocketConfig { 52 | namespace Color { 53 | const QString group = QString("color"); 54 | const QString base = QString("base"); 55 | const QString secondary = QString("secondary"); 56 | const QString selection = QString("selection"); 57 | } 58 | 59 | namespace Font { 60 | const QString group = QString("font"); 61 | const QString size1 = QString("size1"); 62 | const QString size2 = QString("size2"); 63 | } 64 | 65 | namespace Dimensions { 66 | const QString group = QString("dimensions"); 67 | const QString rows = QString("rows"); 68 | const QString columns = QString("columns"); 69 | const QString verticalorientation = QString("vertical_orientation"); 70 | } 71 | 72 | namespace Background { 73 | const QString group = QString("background"); 74 | const QString usesystemwallpaper = QString("use_system_wallpaper"); 75 | const QString wallpaperofscreen = QString("wallpaper_of_screen"); 76 | const QString blurradius = QString("background_blur_radius"); 77 | } 78 | 79 | namespace Settings { 80 | const QString group = QString("settings"); 81 | const QString invertedscrollingx = QString("inverted_scrolling_x"); 82 | const QString invertedscrollingy = QString("inverted_scrolling_y"); 83 | const QString kwinrcoldmeta = QString("kwinrc_old_meta_value"); 84 | const QString metastart = QString("meta_start"); 85 | const QString enable_boxes = QString("enable_boxes"); 86 | const QString tightlayout = QString("tight_layout"); 87 | const QString enable_folders = QString("enable_folders"); 88 | } 89 | } 90 | 91 | #endif // ROCKETLIBRARY_H 92 | -------------------------------------------------------------------------------- /RocketLibrary/tools/kdeapplication.cpp: -------------------------------------------------------------------------------- 1 | #include "kdeapplication.h" 2 | 3 | KDEApplication::KDEApplication(QString name, QString iconname, QIcon icon, QString exec, QString comment, bool terminal, QStringList keywords, QString genericname, QString untranslatedGenericName, QStringList categories, QString entrypath) 4 | { 5 | m_name = name; 6 | m_iconname = iconname; 7 | m_icon = icon; 8 | m_exec = exec; 9 | m_comment = comment; 10 | m_terminal = terminal; 11 | m_keywords = (keywords.size()==1 ? (keywords[0].contains(",") ? keywords[0].split(",") : keywords) : keywords); 12 | m_genericname = genericname; 13 | m_untranslatedGenericName = untranslatedGenericName; 14 | m_categories = (categories.size()==1 ? (categories[0].contains(",") ? categories[0].split(",") : categories) : categories); 15 | m_entrypath = entrypath; 16 | m_isfolder = false; 17 | } 18 | 19 | KDEApplication::KDEApplication(QString name, QString iconname, QIcon icon, QString comment) 20 | { 21 | m_name = name; 22 | m_iconname = iconname; 23 | m_icon = icon; 24 | m_comment = comment; 25 | m_isfolder = true; 26 | } 27 | 28 | KDEApplication::KDEApplication() 29 | { 30 | 31 | } 32 | 33 | bool operator==(const KDEApplication& a, const KDEApplication& b) 34 | { 35 | if (a.m_name!=b.m_name) return false; 36 | if (a.m_iconname!=b.m_iconname) return false; 37 | if (a.m_exec!=b.m_exec) return false; 38 | if (a.m_comment!=b.m_comment) return false; 39 | if (a.m_terminal!=b.m_terminal) return false; 40 | bool studyKeywords = true; 41 | if (a.m_keywords.size()==1) 42 | if (a.m_keywords[0]=="") studyKeywords = false; 43 | if (b.m_keywords.size()==1) 44 | if (b.m_keywords[0]=="") studyKeywords = false; 45 | if (a.m_keywords.size()!=b.m_keywords.size() && studyKeywords) return false; 46 | else { 47 | for (int i=0;i 5 | #include 6 | 7 | class KDEApplication 8 | { 9 | public: 10 | ~KDEApplication() {} 11 | KDEApplication(QString name, QString iconname, QIcon icon, QString exec, QString comment, bool terminal, QStringList keywords, QString genericname, QString untranslatedGenericName, QStringList categories, QString entrypath); 12 | KDEApplication(QString name, QString iconname, QIcon icon, QString comment); 13 | KDEApplication(); 14 | QString name(){return m_name;} 15 | QString iconname(){return m_iconname;} 16 | QString exec(){return m_exec;} 17 | QIcon icon(){return m_icon;} 18 | QString comment() {return m_comment;} 19 | bool terminal() {return m_terminal;} 20 | QStringList keywords() {return m_keywords;} 21 | QString genericname() {return m_genericname;} 22 | QString untranslatedGenericName() {return m_untranslatedGenericName;} 23 | QStringList categories() {return m_categories;} 24 | QString entrypath() {return m_entrypath;} 25 | bool isFolder() {return m_isfolder;} 26 | friend bool operator==(const KDEApplication& a, const KDEApplication& b); 27 | 28 | void setChild(int index,KDEApplication child) {m_children[index] = child;} 29 | std::vector getChildren() {return m_children;} 30 | void setChildren(std::vector children){m_children=children;} 31 | void setToFolder(bool isFolder){m_isfolder = isFolder; m_iconname="folder"; m_icon=QIcon::fromTheme(m_iconname);} 32 | void setName(QString newname){m_name=newname;} 33 | 34 | private: 35 | QString m_name; 36 | QString m_iconname; 37 | QString m_exec; 38 | QIcon m_icon; 39 | QString m_comment; 40 | bool m_terminal; 41 | QStringList m_keywords; 42 | QString m_genericname; 43 | QString m_untranslatedGenericName; 44 | QStringList m_categories; 45 | QString m_entrypath; 46 | bool m_isfolder; 47 | std::vector m_children; 48 | }; 49 | 50 | #endif // KDEAPPLICATION_H 51 | -------------------------------------------------------------------------------- /RocketLibrary/tools/kmenuitems.cpp: -------------------------------------------------------------------------------- 1 | #include "kmenuitems.h" 2 | #include "kdeapplication.h" 3 | #include 4 | #include 5 | 6 | /* 7 | * This algorithm parses every element in the start menu by category and outputs the menu as such. 8 | * Duplicate programs, which belong to two categories thus are present. 9 | * 10 | */ 11 | void KMenuItems::scanElements(QString path,int n) 12 | { 13 | KServiceGroup::Ptr root = KServiceGroup::group(path); 14 | const KServiceGroup::List list = root->entries(); 15 | 16 | for (const KSycocaEntry::Ptr &p : list) { 17 | QString name; 18 | QString iconname; 19 | QString exec; 20 | QString comment; 21 | QIcon icon; 22 | QStringList keywords; 23 | QString genericname; 24 | QString untranslatedGenericName; 25 | QString entrypath; 26 | QStringList categories; 27 | bool terminal; 28 | if (p->isType(KST_KService)) { 29 | const KService::Ptr service(static_cast(p.data())); 30 | if (service->noDisplay()) continue; 31 | name = service->name(); 32 | iconname = service->icon(); 33 | icon = QIcon::fromTheme(service->icon()); 34 | exec = service->exec(); 35 | comment = service->comment(); 36 | terminal = service->terminal(); 37 | keywords = service->keywords(); 38 | genericname = service->genericName(); 39 | untranslatedGenericName = service->untranslatedGenericName(); 40 | categories = service->categories(); 41 | entrypath = service->entryPath(); 42 | bool doubled = false; 43 | for (KDEApplication a : applications) 44 | { 45 | if (a.name()==name) 46 | { 47 | doubled=true; 48 | break; 49 | } 50 | } 51 | if (doubled) continue; 52 | applications.push_back(KDEApplication(name,iconname,icon,exec,comment,terminal,keywords,genericname,untranslatedGenericName,categories,entrypath)); 53 | } 54 | else if (p->isType(KST_KServiceGroup)) { 55 | const KServiceGroup::Ptr serviceGroup(static_cast(p.data())); 56 | if (serviceGroup->noDisplay() || serviceGroup->childCount() == 0) continue; 57 | //name = serviceGroup->caption(); 58 | //w->itemnames.push_back(text); 59 | //w->icons.push_back(QIcon::fromTheme(serviceGroup->icon())); 60 | scanElements(serviceGroup->entryPath(),n+1); 61 | } 62 | else { 63 | // ?? (Even KDE devs don't know what this case means...) 64 | continue; 65 | } 66 | } 67 | 68 | // Sorting alphabetically... 69 | sortElementsAlphabetically(); 70 | } 71 | 72 | void KMenuItems::sortElementsAlphabetically() 73 | { 74 | bool swap = true; 75 | int j=0; 76 | while (swap) 77 | { 78 | swap = false; 79 | j++; 80 | for (int i=0;i<(int)applications.size()-j;i++) 81 | { 82 | QString a = applications[i].name().normalized(QString::NormalizationForm_KD); 83 | a.remove(QRegExp("[^a-zA-Z\\s]")); 84 | QString b = applications[i+1].name().normalized(QString::NormalizationForm_KD); 85 | b.remove(QRegExp("[^a-zA-Z\\s]")); 86 | if (a.toLower().toStdString()>b.toLower().toStdString()) 87 | { 88 | KDEApplication temp = applications[i]; 89 | applications[i] = applications[i+1]; 90 | applications[i+1] = temp; 91 | 92 | swap = true; 93 | } 94 | } 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /RocketLibrary/tools/kmenuitems.h: -------------------------------------------------------------------------------- 1 | #ifndef KMENUITEMS_H 2 | #define KMENUITEMS_H 3 | 4 | 5 | #include 6 | #include 7 | #include "kdeapplication.h" 8 | 9 | class KMenuItems { 10 | 11 | private: 12 | std::vector applications; 13 | 14 | public: 15 | void scanElements(QString path=QString("/"),int n=0); 16 | void sortElementsAlphabetically(); 17 | std::vector getApplications() {return applications;} 18 | }; 19 | #endif // KMENUITEMS_H 20 | -------------------------------------------------------------------------------- /RocketLibrary/tools/rocketconfigmanager.cpp: -------------------------------------------------------------------------------- 1 | #include "../rocketlibrary.h" 2 | #include "rocketconfigmanager.h" 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | using namespace RocketConfig; 9 | 10 | class DefaultGroupsAndKeys { 11 | public: 12 | map> items; 13 | DefaultGroupsAndKeys() 14 | { 15 | map colors; 16 | colors[Color::base] = RocketStyle::BaseColour; 17 | colors[Color::secondary] = RocketStyle::SecondaryColour; 18 | colors[Color::selection] = RocketStyle::SelectionColour; 19 | items[Color::group] = colors; 20 | 21 | map font; 22 | font[Font::size1] = RocketStyle::fontsize1; 23 | font[Font::size2] = RocketStyle::fontsize2; 24 | items[Font::group] = font; 25 | 26 | map dimensions; 27 | dimensions[Dimensions::rows] = RocketStyle::m_rows; 28 | dimensions[Dimensions::columns] = RocketStyle::m_cols; 29 | dimensions[Dimensions::verticalorientation] = RocketStyle::pager_vertical_orientation; 30 | items[Dimensions::group] = dimensions; 31 | 32 | map background; 33 | background[Background::usesystemwallpaper] = RocketStyle::use_system_wallpaper; 34 | background[Background::wallpaperofscreen] = RocketStyle::use_system_wallpaper_screen; 35 | background[Background::blurradius] = RocketStyle::blurradius; 36 | items[Background::group] = background; 37 | 38 | map settings; 39 | settings[Settings::invertedscrollingx] = RocketStyle::inverted_scrolling_x; 40 | settings[Settings::invertedscrollingy] = RocketStyle::inverted_scrolling_y; 41 | settings[Settings::enable_boxes] = RocketStyle::enable_boxes; 42 | settings[Settings::tightlayout] = RocketStyle::tightlayout; 43 | settings[Settings::enable_folders] = RocketStyle::enable_folders; 44 | items[Settings::group] = settings; 45 | } 46 | }; 47 | 48 | 49 | RocketConfigManager::RocketConfigManager() 50 | { 51 | 52 | } 53 | 54 | void RocketConfigManager::checkStyleConfigFile() 55 | { 56 | /* 57 | * This function checks whether the config file exists and if it contains the neccessary key-value pairs. 58 | * It does not check however, whether they are valid. 59 | * */ 60 | KConfig * config = m_styleconfig; 61 | for (auto groups : DefaultGroupsAndKeys().items) 62 | { 63 | QString group = groups.first; 64 | if (!config->hasGroup(group)) 65 | { 66 | for (auto child : groups.second) 67 | { 68 | config->group(group).writeEntry(child.first,child.second); 69 | } 70 | } 71 | else { 72 | for (auto child : groups.second) 73 | { 74 | if (!config->group(group).hasKey(child.first)) 75 | { 76 | config->group(group).writeEntry(child.first,child.second); 77 | } 78 | } 79 | } 80 | } 81 | } 82 | 83 | QString RocketConfigManager::getStyleValue(QString group, QString key) 84 | { 85 | return getStyleConfig()->group(group).readEntry(key); 86 | } 87 | 88 | QColor RocketConfigManager::getStyleValue(QString group, QString key, QColor defaultvalue) 89 | { 90 | return getStyleConfig()->group(group).readEntry(key,defaultvalue); 91 | } 92 | 93 | int RocketConfigManager::getStyleValue(QString group, QString key, int defaultvalue) 94 | { 95 | return getStyleConfig()->group(group).readEntry(key,defaultvalue); 96 | } 97 | 98 | bool RocketConfigManager::getStyleValue(QString group, QString key, bool defaultvalue) 99 | { 100 | bool value = getStyleConfig()->group(group).readEntry(key,defaultvalue); 101 | QString str = getStyleValue(group,key); 102 | if (str==QString("true") || str==QString("false")) return value; 103 | else { 104 | qDebug() << "Invalid argument for" << key << "(" << str << "). Falling back to defaults..."; 105 | return defaultvalue; 106 | } 107 | } 108 | 109 | QColor RocketConfigManager::getBaseColour() 110 | { 111 | return getStyleValue(Color::group,Color::base,RocketStyle::BaseColour); 112 | } 113 | 114 | QColor RocketConfigManager::getSecondaryColour() 115 | { 116 | return getStyleValue(Color::group,Color::secondary,RocketStyle::SecondaryColour); 117 | } 118 | 119 | QColor RocketConfigManager::getSelectionColour() 120 | { 121 | return getStyleValue(Color::group,Color::selection,RocketStyle::SelectionColour); 122 | } 123 | 124 | QPalette RocketConfigManager::getBaseColourBackgroundPalette() 125 | { 126 | QPalette p; 127 | p.setColor(QPalette::ColorRole::Background,getBaseColour()); 128 | return p; 129 | } 130 | 131 | QPalette RocketConfigManager::getSelectionColourBackgroundPalette() 132 | { 133 | QPalette p; 134 | p.setColor(QPalette::ColorRole::Background,getSelectionColour()); 135 | return p; 136 | } 137 | 138 | int RocketConfigManager::getFontSize1() 139 | { 140 | int size = getStyleValue(Font::group,Font::size1,RocketStyle::fontsize1); 141 | if (size>0) return size; 142 | else { 143 | qDebug() << "Invalid argument for" << Font::size1 << "(" << size << "). Falling back to defaults..."; 144 | return RocketStyle::fontsize1; 145 | } 146 | } 147 | 148 | int RocketConfigManager::getFontSize2() 149 | { 150 | int size = getStyleValue(Font::group,Font::size2,RocketStyle::fontsize2); 151 | if (size>0) return size; 152 | else { 153 | qDebug() << "Invalid argument for" << Font::size2 << "(" << size << "). Falling back to defaults..."; 154 | return RocketStyle::fontsize2; 155 | } 156 | } 157 | 158 | int RocketConfigManager::getBlurRadius() 159 | { 160 | int radius= getStyleValue(Background::group,Background::blurradius,RocketStyle::blurradius); 161 | if (radius>=0) return radius; 162 | else { 163 | qDebug() << "Invalid argument for" << Background::blurradius << "(" << radius << "). Falling back to defaults..."; 164 | return RocketStyle::blurradius; 165 | } 166 | } 167 | 168 | bool RocketConfigManager::getBoxSetting() 169 | { 170 | return getStyleValue(Settings::group,Settings::enable_boxes,RocketStyle::enable_boxes); 171 | } 172 | 173 | bool RocketConfigManager::getTightLayoutSetting() 174 | { 175 | return getStyleValue(Settings::group,Settings::tightlayout,RocketStyle::tightlayout); 176 | } 177 | 178 | bool RocketConfigManager::getFolderSetting() 179 | { 180 | return getStyleValue(Settings::group,Settings::enable_folders,RocketStyle::enable_folders); 181 | } 182 | 183 | int RocketConfigManager::getRowNumber() 184 | { 185 | int rows = getStyleValue(Dimensions::group,Dimensions::rows,RocketStyle::m_rows); 186 | if (rows>0) return rows; 187 | else 188 | { 189 | qDebug() << "Invalid argument for" << Dimensions::rows << "(" << rows << "). Falling back to defaults..."; 190 | return RocketStyle::m_rows; 191 | } 192 | } 193 | 194 | int RocketConfigManager::getColumnNumber() 195 | { 196 | int cols = getStyleValue(Dimensions::group,Dimensions::columns,RocketStyle::m_cols); 197 | if (cols>1) return cols; 198 | else 199 | { 200 | qDebug() << "Invalid argument for" << Dimensions::columns << "(" << cols << "). Falling back to defaults..."; 201 | if (cols==1) qDebug() << "only columns more than one are supported..."; 202 | return RocketStyle::m_cols; 203 | } 204 | } 205 | 206 | bool RocketConfigManager::getVerticalModeSetting() 207 | { 208 | return getStyleValue(Dimensions::group,Dimensions::verticalorientation,RocketStyle::pager_vertical_orientation); 209 | } 210 | 211 | bool RocketConfigManager::getUsingSystemWallpaper() 212 | { 213 | return getStyleValue(Background::group,Background::usesystemwallpaper,RocketStyle::use_system_wallpaper); 214 | } 215 | 216 | int RocketConfigManager::getWallpaperScreen() 217 | { 218 | return getStyleValue(Background::group,Background::wallpaperofscreen,RocketStyle::use_system_wallpaper_screen); 219 | } 220 | 221 | int RocketConfigManager::getInvertedScrollFactorXfromSettings() 222 | { 223 | bool val = getStyleValue(Settings::group,Settings::invertedscrollingx,RocketStyle::inverted_scrolling_x); 224 | return (val ? -1 : 1); 225 | } 226 | 227 | int RocketConfigManager::getInvertedScrollFactorYfromSettings() 228 | { 229 | bool inverted = getStyleValue(Settings::group,Settings::invertedscrollingy,RocketStyle::inverted_scrolling_y); 230 | return (inverted ? -1 : 1); 231 | } 232 | 233 | map RocketConfigManager::getApplicationTree(KConfigGroup group, KDEApplication * folder) 234 | { 235 | map apptree; 236 | if (group.groupList().size()>1) //Folder 237 | { 238 | QString name = group.readEntry("name"); 239 | QString iconname = group.readEntry("iconname"); 240 | QIcon icon = QIcon::fromTheme(iconname); 241 | QString comment = group.readEntry("comment"); 242 | int pos = group.readEntry("pos").toInt(); 243 | KDEApplication fol = KDEApplication(name,iconname,icon,comment); 244 | std::vector children(group.groupList().size()); 245 | fol.setChildren(children); 246 | 247 | for (int j=0;j foldercontent = getApplicationTree(group.group(group.groupList()[j]),&fol); 250 | } 251 | apptree[pos] = fol; 252 | } 253 | else //App 254 | { 255 | QString name = group.readEntry("name"); 256 | QString iconname = group.readEntry("iconname"); 257 | QIcon icon = QIcon::fromTheme(iconname); 258 | QString exec = group.readEntry("exec"); 259 | QString comment = group.readEntry("comment"); 260 | QStringList keywords = group.readEntry("keywords").split(","); 261 | QString genericname = group.readEntry("genericname"); 262 | QString untranslatedGenericName = group.readEntry("untranslatedgenericname"); 263 | QStringList categories = group.readEntry("categories").split(","); 264 | bool terminal = (group.readEntry("terminal") == "false" ? false : true); 265 | QString entrypath = group.readEntry("entrypath"); 266 | int pos = group.readEntry("pos").toInt(); 267 | if (folder==nullptr) 268 | apptree[pos] = KDEApplication(name,iconname,icon,exec,comment,terminal,keywords,genericname,untranslatedGenericName,categories,entrypath); 269 | else 270 | folder->setChild(pos,KDEApplication(name,iconname,icon,exec,comment,terminal,keywords,genericname,untranslatedGenericName,categories,entrypath)); 271 | } 272 | return apptree; 273 | } 274 | 275 | void RocketConfigManager::checkAppGridConfigFile() 276 | { 277 | KConfig * config = m_appgridconfig; 278 | if (config->groupList().size()==0) 279 | { 280 | qDebug() << "Appgrid configuration not found. Generating one..."; 281 | KMenuItems menuitems; 282 | menuitems.scanElements(); 283 | generateAppGridConfigFile(config,menuitems.getApplications()); 284 | m_apps = m_app_tree; 285 | } 286 | else 287 | { 288 | std::vector appTree(config->groupList().size()); 289 | 290 | std::vector appvector; 291 | for (QString item : config->groupList()) 292 | { 293 | map app_tree = getApplicationTree(config->group(item)); 294 | for (auto const& i: app_tree) 295 | { 296 | appTree[i.first] = i.second; 297 | if (!(((KDEApplication)i.second).isFolder())) 298 | appvector.push_back(i.second); 299 | else { 300 | std::vector c = ((KDEApplication)i.second).getChildren(); 301 | appvector.insert(appvector.end(),c.begin(),c.end()); 302 | } 303 | } 304 | } 305 | m_apps = appvector; 306 | m_app_tree = appTree; 307 | } 308 | } 309 | 310 | void RocketConfigManager::generateAppGridConfigFile(KConfig * config, std::vector app_tree) 311 | { 312 | for (QString group : config->groupList()) 313 | { 314 | for (QString subgroup : config->group(group).groupList()) 315 | config->group(group).deleteGroup(subgroup); 316 | config->deleteGroup(group); 317 | } 318 | 319 | int i = 0; 320 | for (KDEApplication app : app_tree) 321 | { 322 | if (app.isFolder()) 323 | { 324 | config->group("Entry"+QString::number(i)).writeEntry("name",app.name()); 325 | config->group("Entry"+QString::number(i)).writeEntry("iconname","folder"); 326 | config->group("Entry"+QString::number(i)).writeEntry("comment",app.comment()); 327 | config->group("Entry"+QString::number(i)).writeEntry("pos",QString::number(i)); 328 | int j=0; 329 | for (KDEApplication a : app.getChildren()) 330 | { 331 | config->group("Entry"+QString::number(i)).group("Entry"+QString::number(j)).writeEntry("name",a.name()); 332 | config->group("Entry"+QString::number(i)).group("Entry"+QString::number(j)).writeEntry("iconname",a.iconname()); 333 | config->group("Entry"+QString::number(i)).group("Entry"+QString::number(j)).writeEntry("exec",a.exec()); 334 | config->group("Entry"+QString::number(i)).group("Entry"+QString::number(j)).writeEntry("comment",a.comment()); 335 | config->group("Entry"+QString::number(i)).group("Entry"+QString::number(j)).writeEntry("terminal",a.terminal()); 336 | if (a.keywords()==QStringList("")) 337 | config->group("Entry"+QString::number(i)).group("Entry"+QString::number(j)).writeEntry("keywords",QStringList()); 338 | else 339 | config->group("Entry"+QString::number(i)).group("Entry"+QString::number(j)).writeEntry("keywords",a.keywords()); 340 | config->group("Entry"+QString::number(i)).group("Entry"+QString::number(j)).writeEntry("genericname",a.genericname()); 341 | config->group("Entry"+QString::number(i)).group("Entry"+QString::number(j)).writeEntry("untranslatedgenericname",a.untranslatedGenericName()); 342 | if (a.categories()==QStringList("")) 343 | config->group("Entry"+QString::number(i)).group("Entry"+QString::number(j)).writeEntry("categories",QStringList()); 344 | else 345 | config->group("Entry"+QString::number(i)).group("Entry"+QString::number(j)).writeEntry("categories",a.categories()); 346 | config->group("Entry"+QString::number(i)).group("Entry"+QString::number(j)).writeEntry("entrypath",a.entrypath()); 347 | config->group("Entry"+QString::number(i)).group("Entry"+QString::number(j)).writeEntry("pos",QString::number(j)); 348 | j++; 349 | } 350 | } 351 | else 352 | { 353 | config->group("Entry"+QString::number(i)).writeEntry("name",app.name()); 354 | config->group("Entry"+QString::number(i)).writeEntry("iconname",app.iconname()); 355 | config->group("Entry"+QString::number(i)).writeEntry("exec",app.exec()); 356 | config->group("Entry"+QString::number(i)).writeEntry("comment",app.comment()); 357 | config->group("Entry"+QString::number(i)).writeEntry("terminal",app.terminal()); 358 | if (app.keywords()==QStringList("")) 359 | config->group("Entry"+QString::number(i)).writeEntry("keywords",QStringList()); 360 | else 361 | config->group("Entry"+QString::number(i)).writeEntry("keywords",app.keywords()); 362 | config->group("Entry"+QString::number(i)).writeEntry("genericname",app.genericname()); 363 | config->group("Entry"+QString::number(i)).writeEntry("untranslatedgenericname",app.untranslatedGenericName()); 364 | if (app.categories()==QStringList("")) 365 | config->group("Entry"+QString::number(i)).writeEntry("categories",QStringList()); 366 | else 367 | config->group("Entry"+QString::number(i)).writeEntry("categories",app.categories()); 368 | config->group("Entry"+QString::number(i)).writeEntry("entrypath",app.entrypath()); 369 | config->group("Entry"+QString::number(i)).writeEntry("pos",QString::number(i)); 370 | } 371 | i++; 372 | } 373 | m_app_tree = app_tree; 374 | } 375 | 376 | bool RocketConfigManager::updateApplicationList() 377 | { 378 | KMenuItems menuitems; 379 | menuitems.scanElements(); 380 | 381 | bool changes = false; 382 | for (int i=0;i<(int)menuitems.getApplications().size(); i++) 383 | { 384 | for (int j=0;j<(int)m_apps.size();j++) 385 | { 386 | if (menuitems.getApplications()[i]==m_apps[j]) 387 | { 388 | break; 389 | } 390 | if (j+1==(int)m_apps.size()) 391 | { 392 | m_apps.push_back(menuitems.getApplications()[i]); 393 | m_app_tree.push_back(menuitems.getApplications()[i]); 394 | changes = true; 395 | } 396 | } 397 | } 398 | 399 | for (int i=0;i<(int)m_apps.size(); i++) 400 | { 401 | for (int j=0;j<(int)menuitems.getApplications().size();j++) 402 | { 403 | if (menuitems.getApplications()[j]==m_apps[i]) 404 | { 405 | break; 406 | } 407 | if (j+1==(int)menuitems.getApplications().size()) 408 | { 409 | bool done=false; 410 | for (int k=0;k<(int)m_app_tree.size();k++) 411 | { 412 | if (m_app_tree[k].isFolder()) 413 | { 414 | for (int k2=0;k2<(int)m_app_tree[k].getChildren().size();k2++) 415 | { 416 | if (m_app_tree[k].getChildren()[k2]==m_apps[i]) 417 | { 418 | m_app_tree[k].getChildren().erase(m_app_tree[k].getChildren().begin()+k2); 419 | done = true; 420 | break; 421 | } 422 | } 423 | if (m_app_tree[k].getChildren().size()==1) 424 | { 425 | m_app_tree[k] = m_app_tree[k].getChildren()[0]; 426 | m_app_tree[k].setToFolder(false); 427 | } 428 | } 429 | else 430 | { 431 | if (m_app_tree[k]==m_apps[i]) 432 | { 433 | m_app_tree.erase(m_app_tree.begin()+k); 434 | done = true; 435 | break; 436 | } 437 | } 438 | if (done) break; 439 | } 440 | m_apps.erase(m_apps.begin()+i); 441 | changes = true; 442 | } 443 | } 444 | } 445 | 446 | if (changes) 447 | { 448 | qDebug() << "Appgrid configuration changed. Generating new configuration file..."; 449 | generateAppGridConfigFile(m_appgridconfig,m_app_tree); 450 | m_appgridconfig->reparseConfiguration(); 451 | return true; 452 | } 453 | return false; 454 | } 455 | -------------------------------------------------------------------------------- /RocketLibrary/tools/rocketconfigmanager.h: -------------------------------------------------------------------------------- 1 | #ifndef ROCKETCONFIGMANAGER_H 2 | #define ROCKETCONFIGMANAGER_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include "kmenuitems.h" 9 | 10 | using namespace std; 11 | 12 | class RocketConfigManager { 13 | public: 14 | RocketConfigManager(); 15 | void setStyleConfig(KConfig * config){m_styleconfig = config;} 16 | KConfig * getStyleConfig(){return m_styleconfig;} 17 | void checkStyleConfigFile(); 18 | void setAppGridConfig(KConfig * config){m_appgridconfig = config;} 19 | KConfig * getAppGridConfig(){return m_appgridconfig;} 20 | void checkAppGridConfigFile(); 21 | map getApplicationTree(KConfigGroup group, KDEApplication * folder=nullptr); 22 | void generateAppGridConfigFile(KConfig * config,std::vector menuitems); 23 | 24 | QString getStyleValue(QString group, QString key); 25 | QColor getStyleValue(QString group, QString key, QColor defaultvalue); 26 | int getStyleValue(QString group, QString key, int defaultvalue); 27 | bool getStyleValue(QString group, QString key, bool defaultvalue); 28 | QColor getBaseColour(); 29 | QColor getSecondaryColour(); 30 | QColor getSelectionColour(); 31 | QPalette getBaseColourBackgroundPalette(); 32 | QPalette getSelectionColourBackgroundPalette(); 33 | int getFontSize1(); 34 | int getFontSize2(); 35 | int getBlurRadius(); 36 | bool getBoxSetting(); 37 | bool getTightLayoutSetting(); 38 | bool getFolderSetting(); 39 | int getRowNumber(); 40 | int getColumnNumber(); 41 | bool getVerticalModeSetting(); 42 | bool getUsingSystemWallpaper(); 43 | int getWallpaperScreen(); 44 | int getInvertedScrollFactorXfromSettings(); 45 | int getInvertedScrollFactorYfromSettings(); 46 | std::vector getApplications(){return m_apps;} 47 | std::vector getApplicationTree(){return m_app_tree;} 48 | bool updateApplicationList(); 49 | private: 50 | KConfig * m_styleconfig; 51 | KConfig * m_appgridconfig; 52 | std::vector m_apps; 53 | std::vector m_app_tree; 54 | }; 55 | 56 | extern RocketConfigManager ConfigManager; 57 | 58 | #endif // ROCKETCONFIGMANAGER_H 59 | -------------------------------------------------------------------------------- /screenshots/rocket_designer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/friciwolf/Rocket/b076f72496c3d0e9c1159f90ef21ed297888b1b6/screenshots/rocket_designer.png -------------------------------------------------------------------------------- /screenshots/screenshot.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/friciwolf/Rocket/b076f72496c3d0e9c1159f90ef21ed297888b1b6/screenshots/screenshot.jpeg -------------------------------------------------------------------------------- /screenshots/screenshot_dark.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/friciwolf/Rocket/b076f72496c3d0e9c1159f90ef21ed297888b1b6/screenshots/screenshot_dark.jpeg -------------------------------------------------------------------------------- /screenshots/screenshot_large_grid_noboxes.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/friciwolf/Rocket/b076f72496c3d0e9c1159f90ef21ed297888b1b6/screenshots/screenshot_large_grid_noboxes.jpeg -------------------------------------------------------------------------------- /screenshots/screenshot_search.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/friciwolf/Rocket/b076f72496c3d0e9c1159f90ef21ed297888b1b6/screenshots/screenshot_search.jpeg -------------------------------------------------------------------------------- /screenshots/vertical_scrolling.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/friciwolf/Rocket/b076f72496c3d0e9c1159f90ef21ed297888b1b6/screenshots/vertical_scrolling.jpg --------------------------------------------------------------------------------