mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-10-19 20:44:16 +02:00
Open the PLC master properties dialog at three times its width
Element::editProperty() gave PropertiesEditorDialog no size of its own, so the dialog fell back to its sizeHint, which is sized for the compact general-purpose editors it usually hosts. A PLC master instead shows a six-column IO table that grows horizontally, and the dialog came out too narrow to read those columns in. For a master whose type is PLC, resize the dialog to three times its natural width before exec(), keeping the natural height. The width is clamped to the available screen so it cannot run off the display, and every other element type opens exactly as before.
This commit is contained in:
@@ -39,7 +39,9 @@
|
||||
#include "elementtextitemgroup.h"
|
||||
#include "iostream"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QCollator>
|
||||
#include <QScreen>
|
||||
|
||||
static const QString plcTerminalKeys[] = {
|
||||
QETInformation::ELMT_PLC_T1,
|
||||
@@ -209,6 +211,21 @@ void Element::editProperty()
|
||||
//with the "text" tab of ElementPropertiesWidget,
|
||||
//the ui freeze, until user press escape key
|
||||
dialog.setWindowModality(Qt::WindowModal);
|
||||
|
||||
// A PLC master carries a 6-column IO table: without an explicit
|
||||
// size the dialog falls back to its (cramped) sizeHint, so open it
|
||||
// at three times its natural width instead. The height stays at
|
||||
// the natural one, and the width never exceeds the screen.
|
||||
const ElementData data = elementData();
|
||||
if (data.m_type == ElementData::Master
|
||||
&& data.m_master_type == ElementData::PLC) {
|
||||
const QSize natural = dialog.sizeHint();
|
||||
int width = natural.width() * 3;
|
||||
if (QScreen *screen = QApplication::primaryScreen())
|
||||
width = qMin(width, screen->availableGeometry().width());
|
||||
dialog.resize(width, natural.height());
|
||||
}
|
||||
|
||||
dialog.exec();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user