Sun, 20 Mar 2022 20:59:05 +0100
Profile Mashs now on the mainscreen.
CMakeLists.txt | file | annotate | diff | comparison | revisions | |
src/MainWindow.cpp | file | annotate | diff | comparison | revisions | |
src/ProfileMashs.cpp | file | annotate | diff | comparison | revisions | |
src/ProfileMashs.h | file | annotate | diff | comparison | revisions | |
ui/ProfileMashs.ui | file | annotate | diff | comparison | revisions |
--- a/CMakeLists.txt Sun Mar 20 20:45:58 2022 +0100 +++ b/CMakeLists.txt Sun Mar 20 20:59:05 2022 +0100 @@ -174,7 +174,6 @@ ${UIDIR}/EditWater.ui ${UIDIR}/EditEquipment.ui ${UIDIR}/EditProfileWater.ui - ${UIDIR}/ProfileMashs.ui ${UIDIR}/EditProfileMash.ui ${UIDIR}/ProfileStyles.ui ${UIDIR}/EditProfileStyle.ui
--- a/src/MainWindow.cpp Sun Mar 20 20:45:58 2022 +0100 +++ b/src/MainWindow.cpp Sun Mar 20 20:59:05 2022 +0100 @@ -260,16 +260,19 @@ int index = ui->mainStack->count(); ui->mainStack->addWidget(ProfileWatersWindow); ui->mainStack->setCurrentIndex(index); - setWindowTitle(QString("BMSapp - %1 - Profile Waters").arg(VERSIONSTRING)); -// ui->menuBar->setVisible(false); + setWindowTitle(QString("BMSapp - %1 - Water Profiles").arg(VERSIONSTRING)); + ui->menuBar->setVisible(false); } void MainWindow::fromProfileMashs() { qDebug() << Q_FUNC_INFO; + ui->mainStack->setCurrentIndex(-1); + ui->mainStack->removeWidget(ProfileMashsWindow); delete ProfileMashsWindow; - this->show(); + setWindowTitle( QString("BMSapp - %1").arg(VERSIONSTRING) ); + ui->menuBar->setVisible(true); } @@ -277,9 +280,11 @@ { qDebug() << Q_FUNC_INFO; ProfileMashsWindow = new ProfileMashs(this); - QObject::connect(ProfileMashsWindow, SIGNAL(firstWindow()), this, SLOT(fromProfileMashs())); - this->hide(); // Close the main window - ProfileMashsWindow->show(); // Show a second window + int index = ui->mainStack->count(); + ui->mainStack->addWidget(ProfileMashsWindow); + ui->mainStack->setCurrentIndex(index); + setWindowTitle(QString("BMSapp - %1 - Mash Profiles").arg(VERSIONSTRING)); + ui->menuBar->setVisible(false); }
--- a/src/ProfileMashs.cpp Sun Mar 20 20:45:58 2022 +0100 +++ b/src/ProfileMashs.cpp Sun Mar 20 20:59:05 2022 +0100 @@ -16,19 +16,58 @@ */ #include "ProfileMashs.h" #include "EditProfileMash.h" -#include "../ui/ui_ProfileMashs.h" +#include "MainWindow.h" #include "config.h" #include "bmsapp.h" -ProfileMashs::ProfileMashs(QWidget *parent) : QDialog(parent), ui(new Ui::ProfileMashs) +ProfileMashs::ProfileMashs(QWidget *parent) : QDialog(parent) { qDebug() << "ProfileMashs start"; - ui->setupUi(this); + gridLayout = new QGridLayout(this); + gridLayout->setObjectName(QString::fromUtf8("gridLayout")); + tableMashs = new QTableWidget(this); + tableMashs->setObjectName(QString::fromUtf8("tableMashs")); + tableMashs->setEnabled(true); + QSizePolicy sizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding); + sizePolicy.setHorizontalStretch(0); + sizePolicy.setVerticalStretch(0); + tableMashs->setSizePolicy(sizePolicy); + tableMashs->setMinimumSize(QSize(1104, 0)); + gridLayout->addWidget(tableMashs, 0, 0, 1, 1); + + groupBox = new QGroupBox(this); + groupBox->setObjectName(QString::fromUtf8("groupBox")); + groupBox->setEnabled(true); + groupBox->setFlat(false); + horizontalLayout = new QHBoxLayout(groupBox); + horizontalLayout->setSpacing(6); + horizontalLayout->setObjectName(QString::fromUtf8("horizontalLayout")); + horizontalLayout->setContentsMargins(0, 0, 0, 0); + + quitButton = new QPushButton(groupBox); + quitButton->setObjectName(QString::fromUtf8("quitButton")); + quitButton->setMinimumSize(QSize(80, 24)); + quitButton->setText(tr("Quit")); + QIcon icon; + icon.addFile(QString::fromUtf8(":icons/silk/door_out.png"), QSize(), QIcon::Normal, QIcon::Off); + quitButton->setIcon(icon); + horizontalLayout->addWidget(quitButton, 0, Qt::AlignLeft); + + insertButton = new QPushButton(groupBox); + insertButton->setObjectName(QString::fromUtf8("insertButton")); + insertButton->setMinimumSize(QSize(80, 24)); + insertButton->setText(tr("New")); + QIcon icon3; + icon3.addFile(QString::fromUtf8(":icons/silk/table_row_insert.png"), QSize(), QIcon::Normal, QIcon::Off); + insertButton->setIcon(icon3); + horizontalLayout->addWidget(insertButton, 0, Qt::AlignRight); + gridLayout->addWidget(groupBox, 1, 0, 1, 1); + + connect(quitButton, SIGNAL(clicked()), parent, SLOT(fromProfileMashs())); + connect(insertButton, SIGNAL(clicked()), this, SLOT(on_insertButton_clicked())); emit refreshTable(); - - setWindowTitle( QString("BMSapp - %1 - Profile Mashs").arg(VERSIONSTRING) ); } @@ -44,23 +83,22 @@ QSqlQuery query("SELECT * FROM profile_mash ORDER BY name"); const QStringList labels({tr("Name"), tr("Notes"), tr("Steps"), tr("Edit")}); - ui->tableMashs->setColumnCount(4); - ui->tableMashs->setColumnWidth(0, 250); /* Name */ - ui->tableMashs->setColumnWidth(1, 675); /* Notes */ - ui->tableMashs->setColumnWidth(2, 75); /* Steps */ - ui->tableMashs->setColumnWidth(3, 80); /* Edit button */ - ui->tableMashs->setRowCount(query.size()); - ui->tableMashs->setHorizontalHeaderLabels(labels); - ui->tableMashs->verticalHeader()->hide(); - ui->tableMashs->setFixedSize(1080 + 24, 640); /* Even if this is too large, it works */ + this->tableMashs->setColumnCount(4); + this->tableMashs->setColumnWidth(0, 250); /* Name */ + this->tableMashs->setColumnWidth(1, 675); /* Notes */ + this->tableMashs->setColumnWidth(2, 75); /* Steps */ + this->tableMashs->setColumnWidth(3, 80); /* Edit button */ + this->tableMashs->setRowCount(query.size()); + this->tableMashs->setHorizontalHeaderLabels(labels); + this->tableMashs->verticalHeader()->hide(); QTableWidgetItem *rightitem = new QTableWidgetItem(); rightitem->setTextAlignment(Qt::AlignRight); query.first(); for (int ridx = 0 ; ridx < query.size() ; ridx++ ) { - ui->tableMashs->setItem(ridx, 0, new QTableWidgetItem(query.value(1).toString())); /* Name */ - ui->tableMashs->setItem(ridx, 1, new QTableWidgetItem(query.value(2).toString())); /* Notes */ + this->tableMashs->setItem(ridx, 0, new QTableWidgetItem(query.value(1).toString())); /* Name */ + this->tableMashs->setItem(ridx, 1, new QTableWidgetItem(query.value(2).toString())); /* Notes */ QJsonParseError parseError; const auto& json = query.value(3).toString(); @@ -72,12 +110,10 @@ if (parseError.error != QJsonParseError::NoError) qDebug() << "Parse error: " << parseError.errorString() << "at" << parseError.offset ; -// qDebug() << " ** " << doc << doc.isArray() << doc.array().size() ; - w = QString("%1").arg(doc.array().size()); QTableWidgetItem *item = new QTableWidgetItem(w); item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter); - ui->tableMashs->setItem(ridx, 2, item); + this->tableMashs->setItem(ridx, 2, item); } /* Add the Edit button */ @@ -90,25 +126,17 @@ pLayout->addWidget(btn_edit); pLayout->setContentsMargins(5, 0, 5, 0); pWidget->setLayout(pLayout); - ui->tableMashs->setCellWidget(ridx, 3, pWidget); + this->tableMashs->setCellWidget(ridx, 3, pWidget); query.next(); } - - setWindowTitle( QString("BMSapp - %1 - Profile Mashs").arg(VERSIONSTRING) ); } -ProfileMashs::~ProfileMashs() -{ - qDebug() << "ProfileMashs done"; - delete ui; -} +ProfileMashs::~ProfileMashs() {} void ProfileMashs::edit(int recno) { - qDebug() << "ProfileMashs edit:" << recno; - EditProfileMash dialog(recno, this); /* Signal from editor if a refresh is needed */ connect(&dialog, SIGNAL(entry_changed()), this, SLOT(refreshTable())); @@ -121,20 +149,13 @@ { QPushButton *pb = qobject_cast<QPushButton *>(QObject::sender()); int recno = pb->objectName().toInt(); - qDebug() << Q_FUNC_INFO << recno; edit(recno); } void ProfileMashs::on_insertButton_clicked() { - qDebug() << Q_FUNC_INFO; edit(-1); } -void ProfileMashs::on_quitButton_clicked() -{ - emit firstWindow(); -} -
--- a/src/ProfileMashs.h Sun Mar 20 20:45:58 2022 +0100 +++ b/src/ProfileMashs.h Sun Mar 20 20:59:05 2022 +0100 @@ -2,6 +2,12 @@ #define _PROFILEMASHS_H #include <QDialog> +#include <QtWidgets/QGridLayout> +#include <QtWidgets/QGroupBox> +#include <QtWidgets/QHBoxLayout> +#include <QtWidgets/QHeaderView> +#include <QtWidgets/QPushButton> +#include <QtWidgets/QTableWidget> namespace Ui { class ProfileMashs; @@ -15,17 +21,19 @@ explicit ProfileMashs(QWidget *parent = nullptr); ~ProfileMashs(); -signals: - void firstWindow(); - private slots: - void on_quitButton_clicked(); void on_insertButton_clicked(); void on_editButton_clicked(); void refreshTable(void); private: - Ui::ProfileMashs *ui; + QGridLayout *gridLayout; + QTableWidget *tableMashs; + QGroupBox *groupBox; + QHBoxLayout *horizontalLayout; + QPushButton *quitButton; + QPushButton *insertButton; + void edit(int recno); };
--- a/ui/ProfileMashs.ui Sun Mar 20 20:45:58 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,103 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>ProfileMashs</class> - <widget class="QDialog" name="ProfileMashs"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>1280</width> - <height>640</height> - </rect> - </property> - <property name="windowTitle"> - <string>Dialog</string> - </property> - <layout class="QGridLayout" name="gridLayout"> - <item row="0" column="0"> - <widget class="QTableWidget" name="tableMashs"> - <property name="enabled"> - <bool>true</bool> - </property> - </widget> - </item> - <item row="1" column="0"> - <widget class="QGroupBox" name="groupBox"> - <property name="enabled"> - <bool>true</bool> - </property> - <property name="flat"> - <bool>false</bool> - </property> - <layout class="QHBoxLayout" name="horizontalLayout"> - <property name="spacing"> - <number>6</number> - </property> - <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 alignment="Qt::AlignLeft"> - <widget class="QPushButton" name="quitButton"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="minimumSize"> - <size> - <width>80</width> - <height>24</height> - </size> - </property> - <property name="text"> - <string>Quit</string> - </property> - <property name="icon"> - <iconset> - <normaloff>:icons/silk/door_out.png</normaloff>:icons/silk/door_out.png</iconset> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="insertButton"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="minimumSize"> - <size> - <width>80</width> - <height>24</height> - </size> - </property> - <property name="text"> - <string>New</string> - </property> - <property name="icon"> - <iconset> - <normaloff>:icons/silk/table_row_insert.png</normaloff>:icons/silk/table_row_insert.png</iconset> - </property> - </widget> - </item> - </layout> - </widget> - </item> - </layout> - </widget> - <resources> - <include location="../../../../../../home/mbroek/MyProjects/bmsapp/resources/icons.qrc"/> - </resources> - <connections/> -</ui>