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