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
MainWindow.ui MainWindow.hpp MainWindow.cpp
FileDirDialog.hpp
FileDirDialog.hpp ErrorLabel.hpp
SysReqTableView.hpp SysReqTableView.cpp
VectorISATableView.hpp VectorISATableView.cpp
VectorISATableModel.hpp VectorISATableModelIntel.hpp

View File

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

View File

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

View File

@ -2,6 +2,10 @@
#include <QPropertyAnimation>
#include <QSequentialAnimationGroup>
#include <QHeaderView>
#include <QJsonDocument>
#include <QJsonObject>
#include <QJsonArray>
#include <QProcess>
#if _WIN32
#include <Windows.h>
@ -37,6 +41,26 @@ static QString GetWindowsVersionString()
SysReqTableModel::SysReqTableModel(QObject* 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] = {};
zeus::getCpuInfo(0, regs);
if (regs[0] >= 0x16)
@ -45,6 +69,7 @@ SysReqTableModel::SysReqTableModel(QObject* parent)
m_cpuSpeed = uint64_t(regs[0]);
}
m_cpuSpeedStr.sprintf("%g GHz", m_cpuSpeed / 1000.f);
#endif
#if _WIN32
ULONGLONG memSize;
GetPhysicallyInstalledSystemMemory(&memSize);
@ -62,6 +87,8 @@ SysReqTableModel::SysReqTableModel(QObject* parent)
#elif _WIN32
m_win7SP1OrGreater = IsWindows7SP1OrGreater();
m_osVersion = GetWindowsVersionString();
#elif __linux__
m_osVersion = QStringLiteral("Linux");
#endif
}
@ -124,6 +151,8 @@ QVariant SysReqTableModel::data(const QModelIndex& index, int role) const
return QStringLiteral("macOS 10.9");
#elif defined(_WIN32)
return QStringLiteral("Windows 7 SP1");
#elif defined(__linux__)
return QStringLiteral("Linux");
#else
return {};
#endif