Linux fixes

This commit is contained in:
Jack Andersen 2018-01-01 18:21:45 -10:00
parent 8c9ad43a60
commit f4638bd21b
4 changed files with 38 additions and 5 deletions

View File

@ -27,7 +27,7 @@ list(APPEND PLAT_SRCS mainicon_qt.cpp)
add_executable(hecl-gui WIN32 MACOSX_BUNDLE add_executable(hecl-gui WIN32 MACOSX_BUNDLE
MainWindow.ui MainWindow.hpp MainWindow.cpp MainWindow.ui MainWindow.hpp MainWindow.cpp
FileDirDialog.hpp FileDirDialog.hpp ErrorLabel.hpp
SysReqTableView.hpp SysReqTableView.cpp SysReqTableView.hpp SysReqTableView.cpp
VectorISATableView.hpp VectorISATableView.cpp VectorISATableView.hpp VectorISATableView.cpp
VectorISATableModel.hpp VectorISATableModelIntel.hpp VectorISATableModel.hpp VectorISATableModelIntel.hpp

View File

@ -36,8 +36,6 @@ MainWindow::MainWindow(QWidget *parent) :
m_updateURDEButton->setPalette(pal); m_updateURDEButton->setPalette(pal);
connect(m_updateURDEButton, SIGNAL(clicked()), this, SLOT(onUpdateURDEPressed())); connect(m_updateURDEButton, SIGNAL(clicked()), this, SLOT(onUpdateURDEPressed()));
setPath(m_settings.value(QStringLiteral("working_dir")).toString());
m_dlManager.connectWidgets(m_ui->downloadProgressBar, m_ui->downloadErrorLabel, m_dlManager.connectWidgets(m_ui->downloadProgressBar, m_ui->downloadErrorLabel,
std::bind(&MainWindow::onIndexDownloaded, this, std::placeholders::_1), std::bind(&MainWindow::onIndexDownloaded, this, std::placeholders::_1),
std::bind(&MainWindow::onBinaryDownloaded, this, std::placeholders::_1), std::bind(&MainWindow::onBinaryDownloaded, this, std::placeholders::_1),
@ -46,6 +44,8 @@ MainWindow::MainWindow(QWidget *parent) :
initSlots(); initSlots();
m_dlManager.fetchIndex(); m_dlManager.fetchIndex();
setPath(m_settings.value(QStringLiteral("working_dir")).toString());
} }
MainWindow::~MainWindow() MainWindow::~MainWindow()
@ -797,7 +797,11 @@ bool MainWindow::checkDownloadedBinary()
m_heclPath = QString(); m_heclPath = QString();
if (m_path.isEmpty()) if (m_path.isEmpty())
{
m_ui->heclTabs->setCurrentIndex(1);
m_ui->downloadErrorLabel->setText(QStringLiteral("Set working directory to continue."), true);
return false; return false;
}
#if __APPLE__ #if __APPLE__
QString urdePath = m_path + "/URDE.app/Contents/MacOS/urde"; QString urdePath = m_path + "/URDE.app/Contents/MacOS/urde";

View File

@ -88,7 +88,7 @@
</sizepolicy> </sizepolicy>
</property> </property>
<property name="text"> <property name="text">
<string>Working Directory:</string> <string>Wor&amp;king Directory:</string>
</property> </property>
<property name="buddy"> <property name="buddy">
<cstring>pathEdit</cstring> <cstring>pathEdit</cstring>
@ -135,7 +135,7 @@
<item row="1" column="0" colspan="5"> <item row="1" column="0" colspan="5">
<widget class="QTabWidget" name="heclTabs"> <widget class="QTabWidget" name="heclTabs">
<property name="currentIndex"> <property name="currentIndex">
<number>0</number> <number>1</number>
</property> </property>
<widget class="QWidget" name="dataTab"> <widget class="QWidget" name="dataTab">
<attribute name="title"> <attribute name="title">

View File

@ -2,6 +2,10 @@
#include <QPropertyAnimation> #include <QPropertyAnimation>
#include <QSequentialAnimationGroup> #include <QSequentialAnimationGroup>
#include <QHeaderView> #include <QHeaderView>
#include <QJsonDocument>
#include <QJsonObject>
#include <QJsonArray>
#include <QProcess>
#if _WIN32 #if _WIN32
#include <Windows.h> #include <Windows.h>
@ -37,6 +41,26 @@ static QString GetWindowsVersionString()
SysReqTableModel::SysReqTableModel(QObject* parent) SysReqTableModel::SysReqTableModel(QObject* parent)
: QAbstractTableModel(parent) : QAbstractTableModel(parent)
{ {
#ifdef __linux__
QProcess lscpuProc;
lscpuProc.start("lscpu", {"-J"}, QProcess::ReadOnly);
lscpuProc.waitForFinished();
QJsonDocument lscpu = QJsonDocument::fromJson(lscpuProc.readAll());
QJsonValue lscpuObj = lscpu.object().take("lscpu");
if (lscpuObj.type() == QJsonValue::Array)
{
for (const QJsonValue& v: lscpuObj.toArray())
{
QJsonObject vObj = v.toObject();
if (vObj.take("field").toString() == "CPU MHz:")
{
double speed = vObj.take("data").toString().toDouble();
m_cpuSpeed = speed;
m_cpuSpeedStr.sprintf("%g GHz", speed / 1000.0);
}
}
}
#else
int regs[4] = {}; int regs[4] = {};
zeus::getCpuInfo(0, regs); zeus::getCpuInfo(0, regs);
if (regs[0] >= 0x16) if (regs[0] >= 0x16)
@ -45,6 +69,7 @@ SysReqTableModel::SysReqTableModel(QObject* parent)
m_cpuSpeed = uint64_t(regs[0]); m_cpuSpeed = uint64_t(regs[0]);
} }
m_cpuSpeedStr.sprintf("%g GHz", m_cpuSpeed / 1000.f); m_cpuSpeedStr.sprintf("%g GHz", m_cpuSpeed / 1000.f);
#endif
#if _WIN32 #if _WIN32
ULONGLONG memSize; ULONGLONG memSize;
GetPhysicallyInstalledSystemMemory(&memSize); GetPhysicallyInstalledSystemMemory(&memSize);
@ -62,6 +87,8 @@ SysReqTableModel::SysReqTableModel(QObject* parent)
#elif _WIN32 #elif _WIN32
m_win7SP1OrGreater = IsWindows7SP1OrGreater(); m_win7SP1OrGreater = IsWindows7SP1OrGreater();
m_osVersion = GetWindowsVersionString(); m_osVersion = GetWindowsVersionString();
#elif __linux__
m_osVersion = QStringLiteral("Linux");
#endif #endif
} }
@ -124,6 +151,8 @@ QVariant SysReqTableModel::data(const QModelIndex& index, int role) const
return QStringLiteral("macOS 10.9"); return QStringLiteral("macOS 10.9");
#elif defined(_WIN32) #elif defined(_WIN32)
return QStringLiteral("Windows 7 SP1"); return QStringLiteral("Windows 7 SP1");
#elif defined(__linux__)
return QStringLiteral("Linux");
#else #else
return {}; return {};
#endif #endif