Skip to content

Commit

Permalink
Add a view for Load Option edit
Browse files Browse the repository at this point in the history
  • Loading branch information
Inokinoki committed May 4, 2022
1 parent 6463d90 commit cd459df
Show file tree
Hide file tree
Showing 3 changed files with 95 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ set(PROJECT_SOURCES
helpers.h
qefidpeditorview.cpp
qefidpeditorview.h
qefiloadoptioneditorview.cpp
qefiloadoptioneditorview.h
qefivar/qefi.cpp
qefivar/qefidpacpi.cpp
qefivar/qefidphw.cpp
Expand Down
65 changes: 65 additions & 0 deletions qefiloadoptioneditorview.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#include "qefiloadoptioneditorview.h"
#include "qefidpeditorview.h"

#include <QDialog>

class EditorDialog : public QDialog
{
QEFIDPEditorView *m_view;
QBoxLayout *m_topLevelLayout;
public:
EditorDialog(QWidget *parent = nullptr)
: QDialog(parent)
{
m_view = new QEFIDPEditorView(nullptr, this);
setWindowTitle(QStringLiteral("Add Device Path"));
m_topLevelLayout = new QBoxLayout(QBoxLayout::LeftToRight, this);
m_topLevelLayout->addWidget(m_view);
}

~EditorDialog()
{
if (m_topLevelLayout) m_topLevelLayout->deleteLater();
if (m_view) m_view->deleteLater();
}
};

QEFILoadOptionEditorView::QEFILoadOptionEditorView(QEFILoadOption *option, QWidget *parent)
: QWidget(parent)
{
m_topLevelLayout = new QFormLayout(this);

QSpinBox *idSpinBox = new QSpinBox(this);
idSpinBox->setMinimum(0);
idSpinBox->setMaximum(0xFFFF);
idSpinBox->setDisplayIntegerBase(16);

m_topLevelLayout->addRow(QStringLiteral("ID:"), idSpinBox);
m_topLevelLayout->addRow(QStringLiteral("Name:"), new QLineEdit(option == nullptr ?
QStringLiteral("") : option->name(), this));
m_topLevelLayout->addRow(QStringLiteral("Optional Data:"),
new QLineEdit(option == nullptr ? QStringLiteral("") :
QString(option->optionalData().toHex()), this));
QPushButton *button = new QPushButton(QStringLiteral("Add Device Path"), this);
m_topLevelLayout->addRow(QStringLiteral(""), button);
connect(button, &QPushButton::clicked,
this, &QEFILoadOptionEditorView::createDPClicked);

setLayout(m_topLevelLayout);
}

QEFILoadOptionEditorView::~QEFILoadOptionEditorView()
{
if (m_topLevelLayout != nullptr) {
m_topLevelLayout->deleteLater();
m_topLevelLayout = nullptr;
}
}

void QEFILoadOptionEditorView::createDPClicked(bool checked)
{
Q_UNUSED(checked);
EditorDialog dialog(this);
dialog.exec();
// TODO: Get Device Path and add it
}
28 changes: 28 additions & 0 deletions qefiloadoptioneditorview.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#ifndef QEFILOADOPTIONEDITORVIEW_H
#define QEFILOADOPTIONEDITORVIEW_H

#include <QWidget>

#include <QFormLayout>
#include <QLabel>
#include <QLineEdit>
#include <QPushButton>

#include <qefi.h>

class QEFILoadOptionEditorView: public QWidget
{
Q_OBJECT

QFormLayout *m_topLevelLayout;

public:
QEFILoadOptionEditorView(QEFILoadOption *option = nullptr,
QWidget *parent = nullptr);
~QEFILoadOptionEditorView();

public slots:
void createDPClicked(bool checked);
};

#endif // QEFILOADOPTIONEDITORVIEW_H

0 comments on commit cd459df

Please sign in to comment.