mirror of
https://github.com/edisionnano/QDiskInfo.git
synced 2026-04-15 22:41:29 +03:00
Addressed some issues with the code that produced warnings
This commit is contained in:
@@ -975,7 +975,7 @@ void MainWindow::on_actionAbout_triggered()
|
|||||||
|
|
||||||
void MainWindow::on_actionIgnore_C4_Reallocation_Event_Count_toggled(bool enabled)
|
void MainWindow::on_actionIgnore_C4_Reallocation_Event_Count_toggled(bool enabled)
|
||||||
{
|
{
|
||||||
settings.setValue("IgnoreC4", ui->actionIgnore_C4_Reallocation_Event_Count->isChecked());
|
settings.setValue("IgnoreC4", enabled);
|
||||||
if (!initializing) {
|
if (!initializing) {
|
||||||
Utils.clearButtonGroup(buttonGroup, horizontalLayout, buttonStretch, menuDisk);
|
Utils.clearButtonGroup(buttonGroup, horizontalLayout, buttonStretch, menuDisk);
|
||||||
updateUI();
|
updateUI();
|
||||||
@@ -984,7 +984,7 @@ void MainWindow::on_actionIgnore_C4_Reallocation_Event_Count_toggled(bool enable
|
|||||||
|
|
||||||
void MainWindow::on_actionHEX_toggled(bool enabled)
|
void MainWindow::on_actionHEX_toggled(bool enabled)
|
||||||
{
|
{
|
||||||
settings.setValue("HEX", ui->actionHEX->isChecked());
|
settings.setValue("HEX", enabled);
|
||||||
if (!initializing) {
|
if (!initializing) {
|
||||||
Utils.clearButtonGroup(buttonGroup, horizontalLayout, buttonStretch, menuDisk);
|
Utils.clearButtonGroup(buttonGroup, horizontalLayout, buttonStretch, menuDisk);
|
||||||
updateUI();
|
updateUI();
|
||||||
@@ -993,7 +993,7 @@ void MainWindow::on_actionHEX_toggled(bool enabled)
|
|||||||
|
|
||||||
void MainWindow::on_actionUse_Fahrenheit_toggled(bool enabled)
|
void MainWindow::on_actionUse_Fahrenheit_toggled(bool enabled)
|
||||||
{
|
{
|
||||||
settings.setValue("Fahrenheit", ui->actionUse_Fahrenheit->isChecked());
|
settings.setValue("Fahrenheit", enabled);
|
||||||
if (!initializing) {
|
if (!initializing) {
|
||||||
Utils.clearButtonGroup(buttonGroup, horizontalLayout, buttonStretch, menuDisk);
|
Utils.clearButtonGroup(buttonGroup, horizontalLayout, buttonStretch, menuDisk);
|
||||||
updateUI();
|
updateUI();
|
||||||
@@ -1002,14 +1002,14 @@ void MainWindow::on_actionUse_Fahrenheit_toggled(bool enabled)
|
|||||||
|
|
||||||
void MainWindow::on_actionCyclic_Navigation_toggled(bool cyclicNavigation)
|
void MainWindow::on_actionCyclic_Navigation_toggled(bool cyclicNavigation)
|
||||||
{
|
{
|
||||||
settings.setValue("CyclicNavigation", ui->actionCyclic_Navigation->isChecked());
|
settings.setValue("CyclicNavigation", cyclicNavigation);
|
||||||
int currentIndex = buttonGroup->buttons().indexOf(buttonGroup->checkedButton());
|
int currentIndex = buttonGroup->buttons().indexOf(buttonGroup->checkedButton());
|
||||||
updateNavigationButtons(currentIndex);
|
updateNavigationButtons(currentIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_actionUse_GB_instead_of_TB_toggled(bool gigabytes)
|
void MainWindow::on_actionUse_GB_instead_of_TB_toggled(bool gigabytes)
|
||||||
{
|
{
|
||||||
settings.setValue("UseGB", ui->actionUse_GB_instead_of_TB->isChecked());
|
settings.setValue("UseGB", gigabytes);
|
||||||
if (!initializing) {
|
if (!initializing) {
|
||||||
Utils.clearButtonGroup(buttonGroup, horizontalLayout, buttonStretch, menuDisk);
|
Utils.clearButtonGroup(buttonGroup, horizontalLayout, buttonStretch, menuDisk);
|
||||||
updateUI();
|
updateUI();
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ QT_END_NAMESPACE
|
|||||||
class MainWindow : public QMainWindow
|
class MainWindow : public QMainWindow
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
bool initializing;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MainWindow(QWidget *parent = nullptr);
|
MainWindow(QWidget *parent = nullptr);
|
||||||
@@ -27,27 +26,20 @@ public:
|
|||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void on_actionQuit_triggered();
|
void on_actionQuit_triggered();
|
||||||
|
|
||||||
void on_actionSave_JSON_triggered();
|
void on_actionSave_JSON_triggered();
|
||||||
|
|
||||||
void on_actionGitHub_triggered();
|
void on_actionGitHub_triggered();
|
||||||
|
|
||||||
void on_actionRescan_Refresh_triggered();
|
void on_actionRescan_Refresh_triggered();
|
||||||
|
|
||||||
void on_actionAbout_triggered();
|
void on_actionAbout_triggered();
|
||||||
|
|
||||||
void on_actionIgnore_C4_Reallocation_Event_Count_toggled(bool enabled);
|
void on_actionIgnore_C4_Reallocation_Event_Count_toggled(bool enabled);
|
||||||
|
|
||||||
void on_actionHEX_toggled(bool enabled);
|
void on_actionHEX_toggled(bool enabled);
|
||||||
|
|
||||||
void on_actionUse_Fahrenheit_toggled(bool enabled);
|
void on_actionUse_Fahrenheit_toggled(bool enabled);
|
||||||
|
|
||||||
void on_actionCyclic_Navigation_toggled(bool arg1);
|
void on_actionCyclic_Navigation_toggled(bool arg1);
|
||||||
|
|
||||||
void on_actionUse_GB_instead_of_TB_toggled(bool arg1);
|
void on_actionUse_GB_instead_of_TB_toggled(bool arg1);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::MainWindow *ui;
|
Ui::MainWindow *ui;
|
||||||
|
QSettings settings;
|
||||||
|
bool initializing;
|
||||||
QLocale locale;
|
QLocale locale;
|
||||||
utils Utils;
|
utils Utils;
|
||||||
QButtonGroup *buttonGroup;
|
QButtonGroup *buttonGroup;
|
||||||
@@ -60,15 +52,12 @@ private:
|
|||||||
QColor goodColor, cautionColor, badColor, naColor;
|
QColor goodColor, cautionColor, badColor, naColor;
|
||||||
QJsonObject deviceJson;
|
QJsonObject deviceJson;
|
||||||
QSpacerItem *buttonStretch;
|
QSpacerItem *buttonStretch;
|
||||||
QSettings settings;
|
|
||||||
QAction *actionCyclic_Navigation;
|
QAction *actionCyclic_Navigation;
|
||||||
|
|
||||||
QMenu *menuDevice;
|
QMenu *menuDevice;
|
||||||
QMenu *menuDisk;
|
QMenu *menuDisk;
|
||||||
QMenu *selfTestMenu;
|
QMenu *selfTestMenu;
|
||||||
QAction *selfTestLogAction;
|
QAction *selfTestLogAction;
|
||||||
QActionGroup *disksGroup;
|
QActionGroup *disksGroup;
|
||||||
|
|
||||||
QJsonArray devices;
|
QJsonArray devices;
|
||||||
QStringList deviceOutputs;
|
QStringList deviceOutputs;
|
||||||
QJsonObject globalObj;
|
QJsonObject globalObj;
|
||||||
@@ -85,4 +74,5 @@ private:
|
|||||||
void addSmartAttributesTable(const QJsonArray &attributes);
|
void addSmartAttributesTable(const QJsonArray &attributes);
|
||||||
void mousePressEvent(QMouseEvent*);
|
void mousePressEvent(QMouseEvent*);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ void utils::clearButtonGroup(QButtonGroup* buttonGroup, QHBoxLayout* horizontalL
|
|||||||
menuDisk->clear();
|
menuDisk->clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString utils::getSmartctlPath(bool initializing) {
|
QString utils::getSmartctlPath() {
|
||||||
QStringList paths = QString::fromLocal8Bit(qgetenv("PATH")).split(QDir::listSeparator(), Qt::SkipEmptyParts);
|
QStringList paths = QString::fromLocal8Bit(qgetenv("PATH")).split(QDir::listSeparator(), Qt::SkipEmptyParts);
|
||||||
|
|
||||||
paths << "/usr/sbin" << "/usr/local/sbin";
|
paths << "/usr/sbin" << "/usr/local/sbin";
|
||||||
@@ -37,10 +37,10 @@ QString utils::getSmartctlOutput(const QStringList &arguments, bool root, bool i
|
|||||||
if (root) {
|
if (root) {
|
||||||
command = "pkexec";
|
command = "pkexec";
|
||||||
} else {
|
} else {
|
||||||
command = getSmartctlPath(initializing);
|
command = getSmartctlPath();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!getSmartctlPath(initializing).isEmpty()) {
|
if (!getSmartctlPath().isEmpty()) {
|
||||||
process.start(command, arguments);
|
process.start(command, arguments);
|
||||||
process.waitForFinished(-1);
|
process.waitForFinished(-1);
|
||||||
}
|
}
|
||||||
@@ -67,7 +67,7 @@ QPair<QStringList, QJsonArray> utils::scanDevices(bool initializing)
|
|||||||
QJsonDocument doc = QJsonDocument::fromJson(output.toUtf8());
|
QJsonDocument doc = QJsonDocument::fromJson(output.toUtf8());
|
||||||
QJsonObject jsonObj = doc.object();
|
QJsonObject jsonObj = doc.object();
|
||||||
QJsonArray devices = jsonObj["devices"].toArray();
|
QJsonArray devices = jsonObj["devices"].toArray();
|
||||||
QString smartctlPath = getSmartctlPath(initializing);
|
QString smartctlPath = getSmartctlPath();
|
||||||
QStringList commandList;
|
QStringList commandList;
|
||||||
QStringList deviceOutputs;
|
QStringList deviceOutputs;
|
||||||
|
|
||||||
@@ -112,7 +112,7 @@ QPair<QStringList, QJsonArray> utils::scanDevices(bool initializing)
|
|||||||
QString utils::initiateSelfTest(const QString &testType, const QString &deviceNode)
|
QString utils::initiateSelfTest(const QString &testType, const QString &deviceNode)
|
||||||
{
|
{
|
||||||
QProcess process;
|
QProcess process;
|
||||||
QString command = getSmartctlPath(false);
|
QString command = getSmartctlPath();
|
||||||
QStringList arguments;
|
QStringList arguments;
|
||||||
arguments << command << "--json=o" << "-t" << testType << deviceNode;
|
arguments << command << "--json=o" << "-t" << testType << deviceNode;
|
||||||
|
|
||||||
@@ -129,7 +129,7 @@ QString utils::initiateSelfTest(const QString &testType, const QString &deviceNo
|
|||||||
void utils::cancelSelfTest(const QString &deviceNode)
|
void utils::cancelSelfTest(const QString &deviceNode)
|
||||||
{
|
{
|
||||||
QProcess process;
|
QProcess process;
|
||||||
QString command = getSmartctlPath(false);
|
QString command = getSmartctlPath();
|
||||||
QStringList arguments;
|
QStringList arguments;
|
||||||
arguments << command << "-X" << deviceNode;
|
arguments << command << "-X" << deviceNode;
|
||||||
|
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ public:
|
|||||||
utils();
|
utils();
|
||||||
|
|
||||||
void clearButtonGroup(QButtonGroup* buttonGroup, QHBoxLayout* horizontalLayout, QSpacerItem* buttonStretch, QMenu* menuDisk);
|
void clearButtonGroup(QButtonGroup* buttonGroup, QHBoxLayout* horizontalLayout, QSpacerItem* buttonStretch, QMenu* menuDisk);
|
||||||
QString getSmartctlPath(bool initializing);
|
QString getSmartctlPath();
|
||||||
QString getSmartctlOutput(const QStringList &arguments, bool root, bool initializing);
|
QString getSmartctlOutput(const QStringList &arguments, bool root, bool initializing);
|
||||||
QPair<QStringList, QJsonArray> scanDevices(bool initializing);
|
QPair<QStringList, QJsonArray> scanDevices(bool initializing);
|
||||||
QString initiateSelfTest(const QString &testType, const QString &deviceNode);
|
QString initiateSelfTest(const QString &testType, const QString &deviceNode);
|
||||||
@@ -39,4 +39,4 @@ public:
|
|||||||
QString toTitleCase(const QString& sentence);
|
QString toTitleCase(const QString& sentence);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // UTILS_H
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user