mirror of
https://github.com/edisionnano/QDiskInfo.git
synced 2026-03-07 11:59:57 +03:00
Move headers to an include folder
This commit is contained in:
19
include/asciiview.h
Normal file
19
include/asciiview.h
Normal file
@@ -0,0 +1,19 @@
|
||||
#pragma once
|
||||
|
||||
#include <QString>
|
||||
#include <QVector>
|
||||
|
||||
#define SMART_READ_CMD_LEN 12
|
||||
#define INQUIRY_CMD_LEN 6
|
||||
#define SMART_READ_RESP_LEN 512
|
||||
#define INQUIRY_RESP_LEN 96
|
||||
#define SENSE_BUFFER_LEN 32
|
||||
|
||||
class AsciiView
|
||||
{
|
||||
public:
|
||||
AsciiView() = default;
|
||||
|
||||
QVector<unsigned char> readSMARTData(const QString& device_path);
|
||||
QString hexDump(const QVector<unsigned char> &data);
|
||||
};
|
||||
27
include/custombutton.h
Normal file
27
include/custombutton.h
Normal file
@@ -0,0 +1,27 @@
|
||||
#pragma once
|
||||
|
||||
#include <QColor>
|
||||
#include <QPushButton>
|
||||
#include <QString>
|
||||
#include <QWidget>
|
||||
|
||||
class CustomButton : public QPushButton {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
CustomButton(const QString &text1_, const QString &text2_, const QString &text3_, const QColor &lineColor_, QWidget *parent = nullptr);
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *event) override;
|
||||
void resizeEvent(QResizeEvent *event) override;
|
||||
void setText1(const QString &newText1);
|
||||
void setText2(const QString &newText2);
|
||||
void setText3(const QString &newText3);
|
||||
void adjustWidthToFitText();
|
||||
|
||||
private:
|
||||
QString text1;
|
||||
QString text2;
|
||||
QString text3;
|
||||
QColor lineColor;
|
||||
};
|
||||
16
include/jsonparser.h
Normal file
16
include/jsonparser.h
Normal file
@@ -0,0 +1,16 @@
|
||||
#pragma once
|
||||
|
||||
#include <QString>
|
||||
#include <QVector>
|
||||
#include <QPair>
|
||||
|
||||
class JsonParser
|
||||
{
|
||||
public:
|
||||
JsonParser() = default;
|
||||
|
||||
QVector<QPair<QString, int>> parse(const QString &json);
|
||||
|
||||
private:
|
||||
QString removeQuotes(const QString &s);
|
||||
};
|
||||
92
include/mainwindow.h
Normal file
92
include/mainwindow.h
Normal file
@@ -0,0 +1,92 @@
|
||||
#pragma once
|
||||
|
||||
#include <QAction>
|
||||
#include <QActionGroup>
|
||||
#include <QJsonObject>
|
||||
#include <QLabel>
|
||||
#include <QMainWindow>
|
||||
#include <QMouseEvent>
|
||||
#include <QPushButton>
|
||||
#include <QSettings>
|
||||
#include <QTableWidget>
|
||||
#include <QWidget>
|
||||
#include <QProcess>
|
||||
#include <cmath>
|
||||
|
||||
#include "utils.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
namespace Ui {
|
||||
class MainWindow;
|
||||
}
|
||||
QT_END_NAMESPACE
|
||||
|
||||
class MainWindow : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
MainWindow(QWidget *parent = nullptr);
|
||||
~MainWindow();
|
||||
|
||||
private slots:
|
||||
void on_actionQuit_triggered();
|
||||
void on_actionSave_JSON_triggered();
|
||||
void on_actionGitHub_triggered();
|
||||
void on_actionAbout_QDiskInfo_triggered();
|
||||
void on_actionAbout_Qt_triggered();
|
||||
void on_actionRescan_Refresh_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);
|
||||
|
||||
void on_actionClear_Settings_triggered();
|
||||
|
||||
void on_actionASCII_View_triggered();
|
||||
|
||||
private:
|
||||
Ui::MainWindow *ui;
|
||||
QSettings settings;
|
||||
bool initializing;
|
||||
QLocale locale;
|
||||
utils Utils;
|
||||
QButtonGroup *buttonGroup;
|
||||
QHBoxLayout *horizontalLayout;
|
||||
QVBoxLayout *verticalLayout;
|
||||
QGridLayout *gridLayout;
|
||||
QLabel *diskName, *temperatureValue, *healthStatusValue;
|
||||
QLabel *temperatureLabelHorizontal, *healthStatusLabelHorizontal, *temperatureValueHorizontal, *healthStatusValueHorizontal;
|
||||
QLineEdit *firmwareLineEdit, *serialNumberLineEdit, *typeLineEdit, *protocolLineEdit, *deviceNodeLineEdit;
|
||||
QLineEdit *totalReadsLineEdit, *totalWritesLineEdit, *rotationRateLineEdit, *powerOnCountLineEdit, *powerOnHoursLineEdit;
|
||||
QTableWidget *tableWidget;
|
||||
QPushButton *prevButton, *nextButton;
|
||||
QColor goodColor, cautionColor, badColor, naColor;
|
||||
QLabel *statusLabel;
|
||||
QJsonObject deviceJson;
|
||||
QSpacerItem *buttonStretch;
|
||||
QAction *actionCyclic_Navigation;
|
||||
QMenu *menuDevice;
|
||||
QMenu *menuDisk;
|
||||
QMenu *selfTestMenu;
|
||||
QAction *selfTestLogAction;
|
||||
QActionGroup *disksGroup;
|
||||
QJsonArray devices;
|
||||
QStringList deviceOutputs;
|
||||
QJsonObject globalObj;
|
||||
QString globalHealth;
|
||||
bool globalIsNvme;
|
||||
QVector<QPair<QString, int>> globalNvmeSmartOrdered;
|
||||
|
||||
void onNextButtonClicked();
|
||||
void onPrevButtonClicked();
|
||||
void updateNavigationButtons(qsizetype currentIndex);
|
||||
void updateUI();
|
||||
void populateWindow(const QJsonObject &tempObj, const QString &health, const QVector<QPair<QString, int>>& nvmeLogOrdered = QVector<QPair<QString, int>>());
|
||||
void addSCSIErrorCounterLogTable(const QJsonObject &scsiErrorCounterLog);
|
||||
void addNvmeLogTable(const QVector<QPair<QString, int>>& nvmeLogOrdered);
|
||||
void addSmartAttributesTable(const QJsonArray &attributes);
|
||||
void transformWindow();
|
||||
void mousePressEvent(QMouseEvent*);
|
||||
};
|
||||
17
include/statusdot.h
Normal file
17
include/statusdot.h
Normal file
@@ -0,0 +1,17 @@
|
||||
#pragma once
|
||||
|
||||
#include <QPainter>
|
||||
#include <QStyleOptionViewItem>
|
||||
#include <QStyledItemDelegate>
|
||||
|
||||
class StatusDot : public QStyledItemDelegate
|
||||
{
|
||||
public:
|
||||
StatusDot(QObject *parent = nullptr)
|
||||
: QStyledItemDelegate(parent)
|
||||
{}
|
||||
|
||||
void paint(QPainter *painter,
|
||||
const QStyleOptionViewItem &option,
|
||||
const QModelIndex &index) const override;
|
||||
};
|
||||
22
include/utils.h
Normal file
22
include/utils.h
Normal file
@@ -0,0 +1,22 @@
|
||||
#pragma once
|
||||
|
||||
#include <QButtonGroup>
|
||||
#include <QHBoxLayout>
|
||||
#include <QJsonArray>
|
||||
#include <QMenu>
|
||||
#include <QSpacerItem>
|
||||
|
||||
class utils
|
||||
{
|
||||
public:
|
||||
utils() = default;
|
||||
|
||||
void clearButtonGroup(QButtonGroup* buttonGroup, QHBoxLayout* horizontalLayout, QSpacerItem* buttonStretch, QMenu* menuDisk);
|
||||
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);
|
||||
void cancelSelfTest(const QString &deviceNode);
|
||||
void selfTestHandler(const QString &mode, const QString &name, const QString &minutes);
|
||||
QString toTitleCase(const QString& sentence);
|
||||
};
|
||||
Reference in New Issue
Block a user