Flesh out some GUI infrastructure.

This commit is contained in:
David Given
2024-01-12 23:00:04 +01:00
parent 35633ae0ee
commit 5cda1901a6
6 changed files with 464 additions and 265 deletions

View File

@@ -35,6 +35,9 @@ cxxprogram(
name="gui2",
srcs=[
"./main.cc",
"./mainwindow.cc",
"./globals.h",
"./mainwindow.h",
],
cflags=["-fPIC"],
ldflags=["$(QT5_EXTRA_LIBS)"],

18
src/gui2/globals.h Normal file
View File

@@ -0,0 +1,18 @@
#pragma once
#include "userinterface.h"
class UserInterface : public Ui_MainWindow
{
};
class Application : public QApplication
{
public:
Application(int& argc, char** argv): QApplication(argc, argv) {}
virtual ~Application() {}
public:
};
extern std::unique_ptr<Application> app;

View File

@@ -1,19 +1,25 @@
#include <QApplication>
#include <QPushButton>
#include "userinterface.h"
#include "globals.h"
#include "mainwindow.h"
class UserInterface : public Ui_MainWindow {};
std::unique_ptr<Application> app;
int main(int argc, char **argv)
class ApplicationImpl : public Application
{
QApplication app (argc, argv);
Q_INIT_RESOURCE(resources);
QMainWindow mainWindow;
UserInterface ui;
ui.setupUi(&mainWindow);
mainWindow.setCorner(Qt::BottomLeftCorner, Qt::LeftDockWidgetArea);
mainWindow.setCorner(Qt::BottomRightCorner, Qt::RightDockWidgetArea);
mainWindow.show();
public:
ApplicationImpl(int& argc, char** argv):
Application(argc, argv),
_mainWindow(MainWindow::create())
{
_mainWindow->show();
}
return app.exec();
private:
std::unique_ptr<MainWindow> _mainWindow;
};
int main(int argc, char** argv)
{
Q_INIT_RESOURCE(resources);
app = std::make_unique<ApplicationImpl>(argc, argv);
return app->exec();
}

26
src/gui2/mainwindow.cc Normal file
View File

@@ -0,0 +1,26 @@
#include "mainwindow.h"
class MainWindowImpl : public MainWindow
{
public:
MainWindowImpl()
{
setupUi(this);
setCorner(Qt::BottomLeftCorner, Qt::LeftDockWidgetArea);
setCorner(Qt::BottomRightCorner, Qt::RightDockWidgetArea);
setDriveConfigurationPane(noDriveConfigurationWidget);
}
public:
void setDriveConfigurationPane(QWidget* active)
{
for (auto* w : driveConfigurationContainer->findChildren<QWidget*>())
w->setVisible(w == active);
}
};
std::unique_ptr<MainWindow> MainWindow::create()
{
return std::make_unique<MainWindowImpl>();
}

9
src/gui2/mainwindow.h Normal file
View File

@@ -0,0 +1,9 @@
#pragma once
#include "globals.h"
class MainWindow : public QMainWindow, public Ui_MainWindow
{
public:
static std::unique_ptr<MainWindow> create();
};

View File

@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>1449</width>
<height>705</height>
<width>1574</width>
<height>845</height>
</rect>
</property>
<property name="windowTitle">
@@ -19,14 +19,17 @@
</property>
<property name="styleSheet">
<string notr="true">QTabWidget::pane {
border: 1px black;
border-style: solid;
// border: 1px black;
// border-style: solid;
}
</string>
</property>
<widget class="QWidget" name="centralwidget">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@@ -35,34 +38,7 @@
<string notr="true"/>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="3" column="1">
<widget class="QLabel" name="label_9">
<property name="text">
<string>http://cowlark.com/fluxengine</string>
</property>
<property name="textFormat">
<enum>Qt::MarkdownText</enum>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="QPushButton" name="pushButton_3">
<property name="text">
<string>Work directly with disk</string>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QPushButton" name="pushButton_4">
<property name="text">
<string>Write memory to disk</string>
</property>
</widget>
</item>
<item row="1" column="1">
<item row="0" column="3">
<widget class="QWidget" name="widget_2" native="true">
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing">
@@ -80,38 +56,58 @@
<property name="bottomMargin">
<number>0</number>
</property>
</layout>
</widget>
</item>
<item row="6" column="1">
<widget class="QGroupBox" name="groupBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>Disk operations</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_6">
<item>
<widget class="QLabel" name="label">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>64</width>
<height>64</height>
</size>
</property>
<widget class="QPushButton" name="pushButton_2">
<property name="text">
<string/>
<string>Read disk into memory</string>
</property>
<property name="pixmap">
<pixmap resource="resources.qrc">:/ui/extras/icon.png</pixmap>
<property name="icon">
<iconset theme="media-playback-start">
<normaloff>.</normaloff>.</iconset>
</property>
<property name="scaledContents">
<bool>true</bool>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_4">
<property name="text">
<string>Write memory to disk</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
<property name="icon">
<iconset theme="media-record">
<normaloff>.</normaloff>.</iconset>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_3">
<property name="text">
<string>Work directly with disk</string>
</property>
<property name="icon">
<iconset theme="system-run">
<normaloff>.</normaloff>.</iconset>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="4" column="1">
<item row="4" column="1" colspan="3">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
@@ -124,49 +120,6 @@
</property>
</spacer>
</item>
<item row="8" column="1">
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="6" column="2">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="5" column="1">
<widget class="QPushButton" name="pushButton_2">
<property name="text">
<string>Read disk into memory</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLabel" name="label_2">
<property name="text">
<string>FluxEngine</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="6" column="0">
<spacer name="horizontalSpacer_2">
<property name="orientation">
@@ -180,6 +133,136 @@
</property>
</spacer>
</item>
<item row="1" column="1" colspan="3">
<widget class="QLabel" name="label">
<property name="minimumSize">
<size>
<width>64</width>
<height>64</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="resources.qrc">:/ui/extras/icon.png</pixmap>
</property>
<property name="scaledContents">
<bool>false</bool>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="7" column="1" colspan="3">
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
<item row="3" column="1" colspan="3">
<widget class="QLabel" name="label_9">
<property name="text">
<string>http://cowlark.com/fluxengine</string>
</property>
<property name="textFormat">
<enum>Qt::MarkdownText</enum>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="2" column="1" colspan="3">
<widget class="QLabel" name="label_2">
<property name="text">
<string>FluxEngine</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="6" column="3">
<widget class="QGroupBox" name="groupBox_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>Memory operations</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_9">
<item>
<widget class="QPushButton" name="pushButton">
<property name="text">
<string>Load image into memory</string>
</property>
<property name="icon">
<iconset theme="document-open">
<normaloff>.</normaloff>.</iconset>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_6">
<property name="text">
<string>Save image/flux from memory</string>
</property>
<property name="icon">
<iconset theme="document-save">
<normaloff>.</normaloff>.</iconset>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_9">
<property name="text">
<string>Create blank image</string>
</property>
<property name="icon">
<iconset theme="document-new">
<normaloff>.</normaloff>.</iconset>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="6" column="4">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="6" column="2">
<widget class="QLabel" name="label_8">
<property name="styleSheet">
<string notr="true">font-size: 20pt;
</string>
</property>
<property name="text">
<string>⬅➡</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QMenuBar" name="menubar">
@@ -187,12 +270,11 @@
<rect>
<x>0</x>
<y>0</y>
<width>1449</width>
<height>22</height>
<width>1574</width>
<height>29</height>
</rect>
</property>
</widget>
<widget class="QStatusBar" name="statusbar"/>
<widget class="QDockWidget" name="memoryWindow">
<property name="features">
<set>QDockWidget::DockWidgetFloatable|QDockWidget::DockWidgetMovable</set>
@@ -321,24 +403,6 @@ background: white;
</widget>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="_2">
<item>
<widget class="QPushButton" name="pushButton">
<property name="text">
<string>Load image into memory</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_6">
<property name="text">
<string>Save image/flux from memory</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
@@ -357,8 +421,26 @@ background: white;
</attribute>
<widget class="QWidget" name="dockWidgetContents_3">
<layout class="QVBoxLayout" name="verticalLayout_8">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QScrollArea" name="scrollArea_2">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
@@ -376,8 +458,8 @@ background: white;
<rect>
<x>0</x>
<y>0</y>
<width>283</width>
<height>635</height>
<width>310</width>
<height>524</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4">
@@ -416,11 +498,8 @@ background: white;
</widget>
</item>
<item>
<widget class="QWidget" name="formWidget_2" native="true">
<property name="autoFillBackground">
<bool>true</bool>
</property>
<layout class="QFormLayout" name="fluxfileDriveConfigurationWidget">
<widget class="QWidget" name="driveConfigurationContainer" native="true">
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="leftMargin">
<number>0</number>
</property>
@@ -433,140 +512,179 @@ background: white;
<property name="bottomMargin">
<number>0</number>
</property>
<item row="1" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Filename:</string>
<item>
<widget class="QWidget" name="hardwareDriveConfigurationWidget_2" native="true">
<property name="enabled">
<bool>true</bool>
</property>
<layout class="QFormLayout" name="hardwareDriveConfigurationWidget">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Drive:</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Drive type:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QComboBox" name="comboBox_3">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QCheckBox" name="checkBox">
<property name="text">
<string>High density disk inserted</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="comboBox_2">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="1" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLineEdit" name="lineEdit"/>
</item>
<item>
<widget class="QPushButton" name="pushButton_7">
<property name="text">
<string>Open</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_7">
<property name="text">
<string>Override RPM:</string>
<item>
<widget class="QWidget" name="fluxFileDriveConfigurationContainer" native="true">
<property name="autoFillBackground">
<bool>true</bool>
</property>
<layout class="QFormLayout" name="fluxfileDriveConfigurationWidget">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item row="1" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Filename:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLineEdit" name="lineEdit"/>
</item>
<item>
<widget class="QPushButton" name="pushButton_7">
<property name="text">
<string>Open</string>
</property>
<property name="icon">
<iconset theme="document-open">
<normaloff>.</normaloff>.</iconset>
</property>
</widget>
</item>
</layout>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_7">
<property name="text">
<string>Override RPM:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QRadioButton" name="radioButton">
<property name="text">
<string>Use value in file</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QRadioButton" name="radioButton_2">
<property name="text">
<string>300 rpm / 200 ms</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QRadioButton" name="radioButton_3">
<property name="text">
<string>360 rpm / 166 ms</string>
</property>
</widget>
</item>
<item row="5" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QRadioButton" name="radioButton_4">
<property name="text">
<string>Custom:</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="spinBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item row="2" column="1">
<widget class="QRadioButton" name="radioButton">
<item>
<widget class="QLabel" name="noDriveConfigurationWidget">
<property name="text">
<string>Use value in file</string>
<string>No drive selected! Select one from the list above, or work with images in the pane on the right.</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QRadioButton" name="radioButton_2">
<property name="text">
<string>300 rpm / 200 ms</string>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QRadioButton" name="radioButton_3">
<property name="text">
<string>360 rpm / 166 ms</string>
</property>
</widget>
</item>
<item row="5" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QRadioButton" name="radioButton_4">
<property name="text">
<string>Custom:</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="spinBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QWidget" name="formWidget" native="true">
<property name="enabled">
<bool>true</bool>
</property>
<layout class="QFormLayout" name="hardwareDriveConfigurationWidget">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Drive:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="comboBox_2"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Drive type:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="comboBox_3"/>
</item>
<item row="2" column="1">
<widget class="QCheckBox" name="checkBox">
<property name="text">
<string>High density disk inserted</string>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QLabel" name="label_8">
<property name="text">
<string>No drive selected! Select one from the list above, or work with images in the pane on the right.</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_4">
<property name="orientation">
@@ -575,7 +693,7 @@ background: white;
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>214</height>
<height>0</height>
</size>
</property>
</spacer>
@@ -633,8 +751,8 @@ background: white;
<rect>
<x>0</x>
<y>0</y>
<width>1431</width>
<height>179</height>
<width>1558</width>
<height>193</height>
</rect>
</property>
<property name="sizePolicy">
@@ -652,11 +770,15 @@ background: white;
</property>
<item>
<layout class="QGridLayout" name="gridLayout_2" columnstretch="0,0,100,0">
<item row="1" column="2">
<widget class="QComboBox" name="comboBox_4"/>
</item>
<item row="0" column="2" colspan="2">
<widget class="QComboBox" name="comboBox"/>
<widget class="QComboBox" name="comboBox">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QRadioButton" name="radioButton_5">
@@ -670,6 +792,10 @@ background: white;
<property name="text">
<string>Open</string>
</property>
<property name="icon">
<iconset theme="document-open">
<normaloff>.</normaloff>.</iconset>
</property>
</widget>
</item>
<item row="1" column="1">
@@ -689,6 +815,16 @@ background: white;
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QLineEdit" name="lineEdit_2">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
</layout>
</item>
<item>
@@ -735,6 +871,7 @@ background: white;
</layout>
</widget>
</widget>
<widget class="QStatusBar" name="statusbar"/>
</widget>
<resources>
<include location="resources.qrc"/>