forked from AdrianTM/mx-tools
-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathmainwindow.h
More file actions
130 lines (118 loc) · 4.94 KB
/
mainwindow.h
File metadata and controls
130 lines (118 loc) · 4.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
/**********************************************************************
* Copyright (C) 2014 MX Authors
*
* Authors: Adrian
* MX Linux <http://mxlinux.org>
*
* This file is part of MX Tools.
*
* MX Tools is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* MX Tools is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with MX Tools. If not, see <http://www.gnu.org/licenses/>.
**********************************************************************/
#pragma once
#include <QDialog>
#include <QCloseEvent>
#include <QMessageBox>
#include <QMap>
#include <QResizeEvent>
#include <QSettings>
#include <QStringList>
#include <QVector>
#include "flatbutton.h"
namespace Ui
{
class MainWindow;
}
class MainWindow : public QDialog
{
Q_OBJECT
Q_DISABLE_COPY(MainWindow)
public:
explicit MainWindow(QWidget *parent = nullptr);
~MainWindow() override;
private slots:
void pushHelp_clicked();
void btn_clicked();
void checkHide_clicked(bool checked);
void pushAbout_clicked();
void textSearch_textChanged(const QString &arg1);
protected:
void closeEvent(QCloseEvent *event) override;
void resizeEvent(QResizeEvent *event) override;
private:
struct ToolInfo {
QString fileName;
QString name;
QString comment;
QString iconName;
QString exec;
QString category;
bool runInTerminal = false;
};
using CategoryToolsMap = QMap<QString, QVector<ToolInfo>>;
using CategoryFileMap = QMap<QString, QStringList>;
Ui::MainWindow *ui;
CategoryToolsMap info_map;
CategoryFileMap category_map;
QSettings settings;
QStringList live_list;
QStringList maintenance_list;
QStringList setup_list;
QStringList software_list;
QStringList utilities_list;
const QMap<QString, QStringList *> categories {{"MX-Live", &live_list},
{"MX-Maintenance", &maintenance_list},
{"MX-Setup", &setup_list},
{"MX-Software", &software_list},
{"MX-Utilities", &utilities_list}};
int colCount = 0;
int iconSize = 32;
int maxElements = 0;
int cachedMaxButtonWidth = 0;
// Path constants
static constexpr auto APPLICATIONS_PATH = "/usr/share/applications";
static constexpr auto USER_APPLICATIONS_PATH = "/.local/share/applications";
static constexpr auto HOME_SHARE_ICONS_PATH = "/.local/share/icons/";
static constexpr auto PIXMAPS_PATH = "/usr/share/pixmaps/";
static constexpr auto LOCAL_SHARE_ICONS_PATH = "/usr/local/share/icons/";
static constexpr auto SHARE_ICONS_PATH = "/usr/share/icons/";
static constexpr auto HICOLOR_SCALABLE_PATH = "/usr/share/icons/hicolor/scalable/apps/";
static constexpr auto HICOLOR_48_PATH = "/usr/share/icons/hicolor/48x48/apps/";
static constexpr auto ADWAITA_PATH = "/usr/share/icons/Adwaita/48x48/legacy/";
static constexpr auto MX_TOOLS_PATH = "/usr/bin/mx-tools";
static constexpr auto HELP_DOC_PATH = "/usr/share/mx-docs/mxum_en.pdf";
static constexpr auto LICENSE_PATH = "/usr/share/doc/mx-tools/license.html";
static constexpr auto DEFAULT_ICON_NAME = "utilities-terminal";
[[nodiscard]] FlatButton *createButton(const ToolInfo &toolInfo);
[[nodiscard]] QString getTranslation(const QString &text, const QString &key, const QString &langRegion,
const QString &lang);
[[nodiscard]] QString getValueFromText(const QString &text, const QString &key);
[[nodiscard]] QIcon findIcon(const QString &iconName);
[[nodiscard]] QStringList listDesktopFiles(const QString &searchString, const QString &location);
[[nodiscard]] int calculateMaxElements(const CategoryToolsMap &infoMap);
static void fixExecItem(QString *item);
static void hideShowIcon(const QString &fileName, bool hide);
static void removeEnvExclusive(QStringList *list, bool live, const QStringList &desktops);
void addButtons(const CategoryToolsMap &infoMap);
void addCategoryHeader(const QString &category, int &row, int max_columns);
void addCategorySeparator(int &row, int max_columns);
void checkHideToolsInMenu();
void clearGrid();
void filterDesktopEnvironmentItems();
void filterLiveEnvironmentItems();
void initializeCategoryLists();
void populateCategoryMap();
void readInfo(const CategoryFileMap &categoryMap);
void restoreWindowGeometry();
void setConnections();
};