mirror of
https://github.com/edisionnano/QDiskInfo.git
synced 2026-03-20 11:40:54 +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->actionRescan_Refresh->setShortcut(QKeySequence::Refresh);
|
||||
|
||||
menuDevice = ui->menuDevice;
|
||||
menuDisk = ui->menuDisk;
|
||||
|
||||
toolMenu = new QMenu("Self Test", this);
|
||||
menuDisk->addMenu(toolMenu);
|
||||
menuDevice->addMenu(toolMenu);
|
||||
toolMenu->setToolTipsVisible(true);
|
||||
|
||||
disksGroup = new QActionGroup(this);
|
||||
disksGroup->setExclusive(true);
|
||||
|
||||
goodColor = QColor(Qt::green);
|
||||
cautionColor = QColor(Qt::yellow);
|
||||
badColor = QColor(Qt::red);
|
||||
@@ -189,6 +194,9 @@ void MainWindow::updateUI()
|
||||
QString health;
|
||||
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();
|
||||
bool isNvme = (protocol == "NVMe");
|
||||
|
||||
@@ -260,6 +268,11 @@ void MainWindow::updateUI()
|
||||
buttonGroup->addButton(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->setAutoExclusive(true);
|
||||
|
||||
@@ -270,12 +283,14 @@ void MainWindow::updateUI()
|
||||
populateWindow(localObj, health);
|
||||
}
|
||||
updateNavigationButtons(buttonGroup->buttons().indexOf(button));
|
||||
disksGroup->actions()[buttonGroup->buttons().indexOf(button)]->setChecked(true);
|
||||
});
|
||||
|
||||
if (firstTime) {
|
||||
globalObj = localObj;
|
||||
globalHealth = health;
|
||||
button->setChecked(true);
|
||||
diskAction->setChecked(true);
|
||||
firstTime = false;
|
||||
globalIsNvme = isNvme;
|
||||
if (isNvme) {
|
||||
@@ -880,6 +895,7 @@ void MainWindow::clearButtonGroup()
|
||||
}
|
||||
horizontalLayout->removeItem(buttonStretch);
|
||||
delete buttonStretch;
|
||||
menuDisk->clear();
|
||||
}
|
||||
|
||||
void MainWindow::on_actionQuit_triggered()
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include <QTimer>
|
||||
#include <QSettings>
|
||||
#include <QMouseEvent>
|
||||
#include <QActionGroup>
|
||||
#include <cmath>
|
||||
|
||||
#include "statusdot.h"
|
||||
@@ -69,8 +70,10 @@ private:
|
||||
QSpacerItem *buttonStretch;
|
||||
QSettings settings;
|
||||
|
||||
QMenu *menuDevice;
|
||||
QMenu *menuDisk;
|
||||
QMenu *toolMenu;
|
||||
QActionGroup *disksGroup;
|
||||
|
||||
QJsonArray devices;
|
||||
QStringList deviceOutputs;
|
||||
|
||||
@@ -353,16 +353,22 @@
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionAbout"/>
|
||||
</widget>
|
||||
<widget class="QMenu" name="menuDisk">
|
||||
<widget class="QMenu" name="menuDevice">
|
||||
<property name="title">
|
||||
<string>De&vice</string>
|
||||
</property>
|
||||
<addaction name="actionRescan_Refresh"/>
|
||||
<addaction name="separator"/>
|
||||
</widget>
|
||||
<widget class="QMenu" name="menuDisk">
|
||||
<property name="title">
|
||||
<string>Disk</string>
|
||||
</property>
|
||||
</widget>
|
||||
<addaction name="menuFile"/>
|
||||
<addaction name="menuDisk"/>
|
||||
<addaction name="menuDevice"/>
|
||||
<addaction name="menuSettings"/>
|
||||
<addaction name="menuDisk"/>
|
||||
<addaction name="menuHelp"/>
|
||||
</widget>
|
||||
<action name="actionSave_JSON">
|
||||
|
||||
Reference in New Issue
Block a user