mirror of
https://github.com/edisionnano/QDiskInfo.git
synced 2026-04-20 04:03:20 +03:00
Lay the groundwork for Disk menu
This commit is contained in:
@@ -47,11 +47,16 @@ MainWindow::MainWindow(QWidget *parent)
|
|||||||
ui->actionQuit->setShortcut(QKeySequence::Quit);
|
ui->actionQuit->setShortcut(QKeySequence::Quit);
|
||||||
ui->actionRescan_Refresh->setShortcut(QKeySequence::Refresh);
|
ui->actionRescan_Refresh->setShortcut(QKeySequence::Refresh);
|
||||||
|
|
||||||
|
menuDevice = ui->menuDevice;
|
||||||
menuDisk = ui->menuDisk;
|
menuDisk = ui->menuDisk;
|
||||||
|
|
||||||
toolMenu = new QMenu("Self Test", this);
|
toolMenu = new QMenu("Self Test", this);
|
||||||
menuDisk->addMenu(toolMenu);
|
menuDevice->addMenu(toolMenu);
|
||||||
toolMenu->setToolTipsVisible(true);
|
toolMenu->setToolTipsVisible(true);
|
||||||
|
|
||||||
|
disksGroup = new QActionGroup(this);
|
||||||
|
disksGroup->setExclusive(true);
|
||||||
|
|
||||||
goodColor = QColor(Qt::green);
|
goodColor = QColor(Qt::green);
|
||||||
cautionColor = QColor(Qt::yellow);
|
cautionColor = QColor(Qt::yellow);
|
||||||
badColor = QColor(Qt::red);
|
badColor = QColor(Qt::red);
|
||||||
@@ -189,6 +194,9 @@ void MainWindow::updateUI()
|
|||||||
QString health;
|
QString health;
|
||||||
QColor healthColor;
|
QColor healthColor;
|
||||||
|
|
||||||
|
float userCapacityGB = localObj.value("user_capacity").toObject().value("bytes").toDouble() / 1e9;
|
||||||
|
QString userCapacityString = QString::number(static_cast<int>(userCapacityGB)) + "." + QString::number(static_cast<int>((userCapacityGB - static_cast<int>(userCapacityGB)) * 10)) + " GB";
|
||||||
|
|
||||||
QString protocol = localObj["device"].toObject()["protocol"].toString();
|
QString protocol = localObj["device"].toObject()["protocol"].toString();
|
||||||
bool isNvme = (protocol == "NVMe");
|
bool isNvme = (protocol == "NVMe");
|
||||||
|
|
||||||
@@ -260,6 +268,11 @@ void MainWindow::updateUI()
|
|||||||
buttonGroup->addButton(button);
|
buttonGroup->addButton(button);
|
||||||
horizontalLayout->addWidget(button);
|
horizontalLayout->addWidget(button);
|
||||||
|
|
||||||
|
QAction *diskAction = new QAction("(" + QString::number(i+1) + ") " + modelName + " " + userCapacityString + " GB", this);
|
||||||
|
diskAction->setCheckable(true);
|
||||||
|
menuDisk->addAction(diskAction);
|
||||||
|
disksGroup->addAction(diskAction);
|
||||||
|
|
||||||
button->setCheckable(true);
|
button->setCheckable(true);
|
||||||
button->setAutoExclusive(true);
|
button->setAutoExclusive(true);
|
||||||
|
|
||||||
@@ -270,12 +283,14 @@ void MainWindow::updateUI()
|
|||||||
populateWindow(localObj, health);
|
populateWindow(localObj, health);
|
||||||
}
|
}
|
||||||
updateNavigationButtons(buttonGroup->buttons().indexOf(button));
|
updateNavigationButtons(buttonGroup->buttons().indexOf(button));
|
||||||
|
disksGroup->actions()[buttonGroup->buttons().indexOf(button)]->setChecked(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (firstTime) {
|
if (firstTime) {
|
||||||
globalObj = localObj;
|
globalObj = localObj;
|
||||||
globalHealth = health;
|
globalHealth = health;
|
||||||
button->setChecked(true);
|
button->setChecked(true);
|
||||||
|
diskAction->setChecked(true);
|
||||||
firstTime = false;
|
firstTime = false;
|
||||||
globalIsNvme = isNvme;
|
globalIsNvme = isNvme;
|
||||||
if (isNvme) {
|
if (isNvme) {
|
||||||
@@ -880,6 +895,7 @@ void MainWindow::clearButtonGroup()
|
|||||||
}
|
}
|
||||||
horizontalLayout->removeItem(buttonStretch);
|
horizontalLayout->removeItem(buttonStretch);
|
||||||
delete buttonStretch;
|
delete buttonStretch;
|
||||||
|
menuDisk->clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_actionQuit_triggered()
|
void MainWindow::on_actionQuit_triggered()
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include <QMouseEvent>
|
#include <QMouseEvent>
|
||||||
|
#include <QActionGroup>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
||||||
#include "statusdot.h"
|
#include "statusdot.h"
|
||||||
@@ -69,8 +70,10 @@ private:
|
|||||||
QSpacerItem *buttonStretch;
|
QSpacerItem *buttonStretch;
|
||||||
QSettings settings;
|
QSettings settings;
|
||||||
|
|
||||||
|
QMenu *menuDevice;
|
||||||
QMenu *menuDisk;
|
QMenu *menuDisk;
|
||||||
QMenu *toolMenu;
|
QMenu *toolMenu;
|
||||||
|
QActionGroup *disksGroup;
|
||||||
|
|
||||||
QJsonArray devices;
|
QJsonArray devices;
|
||||||
QStringList deviceOutputs;
|
QStringList deviceOutputs;
|
||||||
|
|||||||
@@ -353,16 +353,22 @@
|
|||||||
<addaction name="separator"/>
|
<addaction name="separator"/>
|
||||||
<addaction name="actionAbout"/>
|
<addaction name="actionAbout"/>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QMenu" name="menuDisk">
|
<widget class="QMenu" name="menuDevice">
|
||||||
<property name="title">
|
<property name="title">
|
||||||
<string>De&vice</string>
|
<string>De&vice</string>
|
||||||
</property>
|
</property>
|
||||||
<addaction name="actionRescan_Refresh"/>
|
<addaction name="actionRescan_Refresh"/>
|
||||||
<addaction name="separator"/>
|
<addaction name="separator"/>
|
||||||
</widget>
|
</widget>
|
||||||
|
<widget class="QMenu" name="menuDisk">
|
||||||
|
<property name="title">
|
||||||
|
<string>Disk</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
<addaction name="menuFile"/>
|
<addaction name="menuFile"/>
|
||||||
<addaction name="menuDisk"/>
|
<addaction name="menuDevice"/>
|
||||||
<addaction name="menuSettings"/>
|
<addaction name="menuSettings"/>
|
||||||
|
<addaction name="menuDisk"/>
|
||||||
<addaction name="menuHelp"/>
|
<addaction name="menuHelp"/>
|
||||||
</widget>
|
</widget>
|
||||||
<action name="actionSave_JSON">
|
<action name="actionSave_JSON">
|
||||||
|
|||||||
Reference in New Issue
Block a user