Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rework of the frmmain.ui form design file for low resolution screens #469

Open
wants to merge 3 commits into
base: Experimental
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
175 changes: 81 additions & 94 deletions src/candle/frmmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,74 +22,79 @@
#include "ui_frmsettings.h"
#include "widgets/widgetmimedata.h"

frmMain::frmMain(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::frmMain)
frmMain::frmMain(QWidget* parent)
: QMainWindow(parent)
, ui(new Ui::frmMain)
, m_deviceStatuses {
{ DeviceUnknown, QStringLiteral("Unknown") },
{ DeviceIdle, QStringLiteral("Idle") },
{ DeviceAlarm, QStringLiteral("Alarm") },
{ DeviceRun, QStringLiteral("Run") },
{ DeviceHome, QStringLiteral("Home") },
{ DeviceHold0, QStringLiteral("Hold:0") },
{ DeviceHold1, QStringLiteral("Hold:1") },
{ DeviceQueue, QStringLiteral("Queue") },
{ DeviceCheck, QStringLiteral("Check") },
{ DeviceDoor0, QStringLiteral("Door:0") },
{ DeviceDoor1, QStringLiteral("Door:1") },
{ DeviceDoor2, QStringLiteral("Door:2") },
{ DeviceDoor3, QStringLiteral("Door:3") },
{ DeviceJog, QStringLiteral("Jog") },
{ DeviceSleep, QStringLiteral("Sleep") },
}
, m_statusCaptions {
{ DeviceUnknown, tr("Unknown") },
{ DeviceIdle, tr("Idle") },
{ DeviceAlarm, tr("Alarm") },
{ DeviceRun, tr("Run") },
{ DeviceHome, tr("Home") },
{ DeviceHold0, tr("Hold") + " (0)" },
{ DeviceHold1, tr("Hold") + " (1)" },
{ DeviceQueue, tr("Queue") },
{ DeviceCheck, tr("Check") },
{ DeviceDoor0, tr("Door") + " (0)" },
{ DeviceDoor1, tr("Door") + " (1)" },
{ DeviceDoor2, tr("Door") + " (2)" },
{ DeviceDoor3, tr("Door") + " (3)" },
{ DeviceJog, tr("Jog") },
{ DeviceSleep, tr("Sleep") },
}
, m_statusBackColors {
{ DeviceUnknown, QStringLiteral("red") },
{ DeviceIdle, QStringLiteral("palette(button)") },
{ DeviceAlarm, QStringLiteral("red") },
{ DeviceRun, QStringLiteral("lime") },
{ DeviceHome, QStringLiteral("lime") },
{ DeviceHold0, QStringLiteral("yellow") },
{ DeviceHold1, QStringLiteral("yellow") },
{ DeviceQueue, QStringLiteral("yellow") },
{ DeviceCheck, QStringLiteral("palette(button)") },
{ DeviceDoor0, QStringLiteral("red") },
{ DeviceDoor1, QStringLiteral("red") },
{ DeviceDoor2, QStringLiteral("red") },
{ DeviceDoor3, QStringLiteral("red") },
{ DeviceJog, QStringLiteral("lime") },
{ DeviceSleep, QStringLiteral("blue") },
}
, m_statusForeColors {
{ DeviceUnknown, QStringLiteral("white") },
{ DeviceIdle, QStringLiteral("palette(text)") },
{ DeviceAlarm, QStringLiteral("white") },
{ DeviceRun, QStringLiteral("black") },
{ DeviceHome, QStringLiteral("black") },
{ DeviceHold0, QStringLiteral("black") },
{ DeviceHold1, QStringLiteral("black") },
{ DeviceQueue, QStringLiteral("black") },
{ DeviceCheck, QStringLiteral("palette(text)") },
{ DeviceDoor0, QStringLiteral("white") },
{ DeviceDoor1, QStringLiteral("white") },
{ DeviceDoor2, QStringLiteral("white") },
{ DeviceDoor3, QStringLiteral("white") },
{ DeviceJog, QStringLiteral("black") },
{ DeviceSleep, QStringLiteral("white") },
}
{
// Initializing variables
m_deviceStatuses[DeviceUnknown] = "Unknown";
m_deviceStatuses[DeviceIdle] = "Idle";
m_deviceStatuses[DeviceAlarm] = "Alarm";
m_deviceStatuses[DeviceRun] = "Run";
m_deviceStatuses[DeviceHome] = "Home";
m_deviceStatuses[DeviceHold0] = "Hold:0";
m_deviceStatuses[DeviceHold1] = "Hold:1";
m_deviceStatuses[DeviceQueue] = "Queue";
m_deviceStatuses[DeviceCheck] = "Check";
m_deviceStatuses[DeviceDoor0] = "Door:0";
m_deviceStatuses[DeviceDoor1] = "Door:1";
m_deviceStatuses[DeviceDoor2] = "Door:2";
m_deviceStatuses[DeviceDoor3] = "Door:3";
m_deviceStatuses[DeviceJog] = "Jog";
m_deviceStatuses[DeviceSleep] = "Sleep";

m_statusCaptions[DeviceUnknown] = tr("Unknown");
m_statusCaptions[DeviceIdle] = tr("Idle");
m_statusCaptions[DeviceAlarm] = tr("Alarm");
m_statusCaptions[DeviceRun] = tr("Run");
m_statusCaptions[DeviceHome] = tr("Home");
m_statusCaptions[DeviceHold0] = tr("Hold") + " (0)";
m_statusCaptions[DeviceHold1] = tr("Hold") + " (1)";
m_statusCaptions[DeviceQueue] = tr("Queue");
m_statusCaptions[DeviceCheck] = tr("Check");
m_statusCaptions[DeviceDoor0] = tr("Door") + " (0)";
m_statusCaptions[DeviceDoor1] = tr("Door") + " (1)";
m_statusCaptions[DeviceDoor2] = tr("Door") + " (2)";
m_statusCaptions[DeviceDoor3] = tr("Door") + " (3)";
m_statusCaptions[DeviceJog] = tr("Jog");
m_statusCaptions[DeviceSleep] = tr("Sleep");

m_statusBackColors[DeviceUnknown] = "red";
m_statusBackColors[DeviceIdle] = "palette(button)";
m_statusBackColors[DeviceAlarm] = "red";
m_statusBackColors[DeviceRun] = "lime";
m_statusBackColors[DeviceHome] = "lime";
m_statusBackColors[DeviceHold0] = "yellow";
m_statusBackColors[DeviceHold1] = "yellow";
m_statusBackColors[DeviceQueue] = "yellow";
m_statusBackColors[DeviceCheck] = "palette(button)";
m_statusBackColors[DeviceDoor0] = "red";
m_statusBackColors[DeviceDoor1] = "red";
m_statusBackColors[DeviceDoor2] = "red";
m_statusBackColors[DeviceDoor3] = "red";
m_statusBackColors[DeviceJog] = "lime";
m_statusBackColors[DeviceSleep] = "blue";

m_statusForeColors[DeviceUnknown] = "white";
m_statusForeColors[DeviceIdle] = "palette(text)";
m_statusForeColors[DeviceAlarm] = "white";
m_statusForeColors[DeviceRun] = "black";
m_statusForeColors[DeviceHome] = "black";
m_statusForeColors[DeviceHold0] = "black";
m_statusForeColors[DeviceHold1] = "black";
m_statusForeColors[DeviceQueue] = "black";
m_statusForeColors[DeviceCheck] = "palette(text)";
m_statusForeColors[DeviceDoor0] = "white";
m_statusForeColors[DeviceDoor1] = "white";
m_statusForeColors[DeviceDoor2] = "white";
m_statusForeColors[DeviceDoor3] = "white";
m_statusForeColors[DeviceJog] = "black";
m_statusForeColors[DeviceSleep] = "white";

m_fileChanged = false;
m_heightMapChanged = false;
Expand Down Expand Up @@ -151,12 +156,6 @@ frmMain::frmMain(QWidget *parent) :
ui->cmdYMinus->setBackColor(ui->cmdXMinus->backColor());
ui->cmdYPlus->setBackColor(ui->cmdXMinus->backColor());

ui->cmdFit->setParent(ui->glwVisualizer);
ui->cmdIsometric->setParent(ui->glwVisualizer);
ui->cmdTop->setParent(ui->glwVisualizer);
ui->cmdFront->setParent(ui->glwVisualizer);
ui->cmdLeft->setParent(ui->glwVisualizer);

ui->cmdHeightMapBorderAuto->setMinimumHeight(ui->chkHeightMapBorderShow->sizeHint().height());
ui->cmdHeightMapCreate->setMinimumHeight(ui->cmdFileOpen->sizeHint().height());
ui->cmdHeightMapLoad->setMinimumHeight(ui->cmdFileOpen->sizeHint().height());
Expand Down Expand Up @@ -343,8 +342,6 @@ void frmMain::showEvent(QShowEvent *se)
{
Q_UNUSED(se)

placeVisualizerButtons();

#ifdef WINDOWS
if (QSysInfo::windowsVersion() >= QSysInfo::WV_WINDOWS7) {
if (m_taskBarButton == NULL) {
Expand All @@ -365,7 +362,6 @@ void frmMain::resizeEvent(QResizeEvent *re)
{
Q_UNUSED(re)

placeVisualizerButtons();
resizeTableHeightMapSections();
}

Expand Down Expand Up @@ -2557,15 +2553,6 @@ void frmMain::updateHeightMapInterpolationDrawer(bool reset)
m_programHeightmapModel.clear();
}

void frmMain::placeVisualizerButtons()
{
ui->cmdIsometric->move(ui->glwVisualizer->width() - ui->cmdIsometric->width() - 8, 8);
ui->cmdTop->move(ui->cmdIsometric->geometry().left() - ui->cmdTop->width() - 8, 8);
ui->cmdLeft->move(ui->glwVisualizer->width() - ui->cmdLeft->width() - 8, ui->cmdIsometric->geometry().bottom() + 8);
ui->cmdFront->move(ui->cmdLeft->geometry().left() - ui->cmdFront->width() - 8, ui->cmdIsometric->geometry().bottom() + 8);
ui->cmdFit->move(ui->glwVisualizer->width() - ui->cmdFit->width() - 8, ui->cmdLeft->geometry().bottom() + 8);
}

void frmMain::preloadSettings()
{
QSettings set(m_settingsFileName, QSettings::IniFormat);
Expand Down Expand Up @@ -2705,7 +2692,7 @@ void frmMain::loadSettings()
emit pluginsLoaded();

// Adjust docks width
int w = qMax(ui->dockDevice->widget()->sizeHint().width(),
int w = qMax(ui->dockDevice->widget()->sizeHint().width(),
ui->dockModification->widget()->sizeHint().width());
ui->dockDevice->setMinimumWidth(w);
ui->dockDevice->setMaximumWidth(w + ui->scrollArea->verticalScrollBar()->width());
Expand All @@ -2714,14 +2701,14 @@ void frmMain::loadSettings()
ui->dockUser->setMinimumWidth(w);
ui->dockUser->setMaximumWidth(w + ui->scrollArea->verticalScrollBar()->width());

// Buttons
int b = (w - ui->grpControl->layout()->margin() * 2 - ui->grpControl->layout()->spacing() * 3) / 4 * 0.8;
int c = b * 0.8;
setStyleSheet(styleSheet() + QString("\nStyledToolButton[adjustSize='true'] {\n\
min-width: %1px;\n\
min-height: %1px;\n\
qproperty-iconSize: %2px;\n\
}").arg(b).arg(c));
// Buttons
// int b = (w - ui->grpControl->layout()->margin() * 2 - ui->grpControl->layout()->spacing() * 3) / 4 * 0.8;
// int c = b * 0.8;
// setStyleSheet(styleSheet() + QString("\nStyledToolButton[adjustSize='true'] {\n\
// min-width: %1px;\n\
// min-height: %1px;\n\
// qproperty-iconSize: %2px;\n\
// }").arg(b).arg(c));
ensurePolished();

foreach (QDockWidget *w, findChildren<QDockWidget*>()) w->setStyleSheet("");
Expand Down Expand Up @@ -4500,4 +4487,4 @@ bool frmMain::actionTextLessThan(const QAction *a1, const QAction *a2)
QScriptValue frmMain::importExtension(QScriptContext *context, QScriptEngine *engine)
{
return engine->importExtension(context->argument(0).toString());
}
}
31 changes: 15 additions & 16 deletions src/candle/frmmain.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class CancelException : public std::exception {
}
};

class frmMain : public QMainWindow
class frmMain final: public QMainWindow
{
Q_OBJECT

Expand Down Expand Up @@ -214,22 +214,21 @@ private slots:
void onScriptException(const QScriptValue &exception);

void updateHeightMapInterpolationDrawer(bool reset = false);
void placeVisualizerButtons();

protected:
void showEvent(QShowEvent *se);
void hideEvent(QHideEvent *he);
void resizeEvent(QResizeEvent *re);
void timerEvent(QTimerEvent *);
void closeEvent(QCloseEvent *ce);
void dragEnterEvent(QDragEnterEvent *dee);
void dropEvent(QDropEvent *de);
QMenu *createPopupMenu() override;
void showEvent(QShowEvent* se) override;
void hideEvent(QHideEvent* he) override;
void resizeEvent(QResizeEvent* re) override;
void timerEvent(QTimerEvent*) override;
void closeEvent(QCloseEvent* ce) override;
void dragEnterEvent(QDragEnterEvent* dee) override;
void dropEvent(QDropEvent* de) override;
QMenu* createPopupMenu() override;

private:
static const int BUFFERLENGTH = 127;
static const int PROGRESSMINLINES = 10000;
static const int PROGRESSSTEP = 1000;
static const int PROGRESSSTEP = 1000;

enum SenderState {
SenderUnknown = -1,
Expand All @@ -256,16 +255,16 @@ private slots:
DeviceDoor2 = 11,
DeviceDoor3 = 12,
DeviceJog = 13,
DeviceSleep =14
DeviceSleep = 14
};

// Ui
Ui::frmMain *ui;

QMap<DeviceState, QString> m_deviceStatuses;
QMap<DeviceState, QString> m_statusCaptions;
QMap<DeviceState, QString> m_statusBackColors;
QMap<DeviceState, QString> m_statusForeColors;
const QMap<DeviceState, QString> m_deviceStatuses;
const QMap<DeviceState, QString> m_statusCaptions;
const QMap<DeviceState, QString> m_statusBackColors;
const QMap<DeviceState, QString> m_statusForeColors;

QMenu *m_tableMenu;
QMessageBox* m_senderErrorBox;
Expand Down
Loading