Graphic UI objects names change, Ribbon init() now remember current tab

This commit is contained in:
2021-02-18 15:21:53 +03:00
parent 63aea62c89
commit 17911b8651
5 changed files with 93 additions and 83 deletions

View File

@@ -3,7 +3,7 @@ cmake_policy(SET CMP0017 NEW) # need include() with .cmake
project(qad) project(qad)
set(qad_MAJOR 1) set(qad_MAJOR 1)
set(qad_MINOR 15) set(qad_MINOR 15)
set(qad_REVISION 0) set(qad_REVISION 1)
set(qad_SUFFIX ) set(qad_SUFFIX )
set(qad_COMPANY SHS) set(qad_COMPANY SHS)
set(qad_DOMAIN org.SHS) set(qad_DOMAIN org.SHS)

View File

@@ -91,6 +91,12 @@ void Ribbon::init() {
if (parent == 0) return; if (parent == 0) return;
if (parent->menuBar() == 0) return; if (parent->menuBar() == 0) return;
QList<QAction * > lm = parent->menuBar()->actions(), la; QList<QAction * > lm = parent->menuBar()->actions(), la;
QString prev_tab;
if (tab) {
if (tab->currentIndex() >= 0)
prev_tab = tab->tabText(tab->currentIndex());
tab->deleteLater();
}
clear(); clear();
if (scroll_area) delete scroll_area; if (scroll_area) delete scroll_area;
buttons.clear(); buttons.clear();
@@ -192,6 +198,8 @@ void Ribbon::init() {
tl->addSpacerItem(new QSpacerItem(1, 1, QSizePolicy::Expanding, QSizePolicy::Fixed)); tl->addSpacerItem(new QSpacerItem(1, 1, QSizePolicy::Expanding, QSizePolicy::Fixed));
//sa->widget()->setLayout(tl); //sa->widget()->setLayout(tl);
tab->widget(tab->count() - 1)->setLayout(tl); tab->widget(tab->count() - 1)->setLayout(tl);
if (i->text() == prev_tab)
tab->setCurrentIndex(tab->count() - 1);
} }
setFloatable(false); setFloatable(false);
setMovable(false); setMovable(false);

View File

@@ -40,19 +40,19 @@ Graphic::Graphic(QWidget * parent): QFrame(parent), canvas(0), line_x_min(this),
ui = new Ui::Graphic(); ui = new Ui::Graphic();
ui->setupUi(this); ui->setupUi(this);
QActionGroup * agroup = new QActionGroup(this); QActionGroup * agroup = new QActionGroup(this);
agroup->addAction(ui->actionGuidesFree ); agroup->addAction(ui->graphic_actionGuidesFree );
agroup->addAction(ui->actionGuidesTraceX); agroup->addAction(ui->graphic_actionGuidesTraceX);
agroup->addAction(ui->actionGuidesTraceY); agroup->addAction(ui->graphic_actionGuidesTraceY);
ui->actionGuidesFree ->setProperty("_value", (int)Free ); ui->graphic_actionGuidesFree ->setProperty("_value", (int)Free );
ui->actionGuidesTraceX->setProperty("_value", (int)TraceX); ui->graphic_actionGuidesTraceX->setProperty("_value", (int)TraceX);
ui->actionGuidesTraceY->setProperty("_value", (int)TraceY); ui->graphic_actionGuidesTraceY->setProperty("_value", (int)TraceY);
ui->actionGuidesFree->setChecked(true); ui->graphic_actionGuidesFree->setChecked(true);
connect(agroup, SIGNAL(triggered(QAction*)), this, SLOT(actionGuidesTriggered(QAction*))); connect(agroup, SIGNAL(triggered(QAction*)), this, SLOT(actionGuidesTriggered(QAction*)));
ui->checkGuides->addAction(ui->actionGuidesFree ); ui->graphic_checkGuides ->addAction(ui->graphic_actionGuidesFree );
ui->checkGuides->addAction(ui->actionGuidesTraceX); ui->graphic_checkGuides ->addAction(ui->graphic_actionGuidesTraceX);
ui->checkGuides->addAction(ui->actionGuidesTraceY); ui->graphic_checkGuides ->addAction(ui->graphic_actionGuidesTraceY);
ui->buttonAutofit->addAction(ui->actionExpandX); ui->graphic_buttonAutofit->addAction(ui->graphic_actionExpandX);
ui->buttonAutofit->addAction(ui->actionExpandY); ui->graphic_buttonAutofit->addAction(ui->graphic_actionExpandY);
line_x_min.setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed); line_x_min.setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
line_x_max.setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed); line_x_max.setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
((QBoxLayout * )ui->widgetLY->layout())->insertWidget(0, &line_y_min); ((QBoxLayout * )ui->widgetLY->layout())->insertWidget(0, &line_y_min);
@@ -540,7 +540,7 @@ void Graphic::clear() {
graphics[i].max_x = 0.; graphics[i].max_x = 0.;
graphics[i].cvrect = QRectF(); graphics[i].cvrect = QRectF();
} }
if (isFit) on_buttonAutofit_clicked(); if (isFit) on_graphic_buttonAutofit_clicked();
} }
@@ -553,9 +553,9 @@ void Graphic::setAntialiasing(bool enabled) {
void Graphic::setPaused(bool yes) { void Graphic::setPaused(bool yes) {
pause_ = yes; pause_ = yes;
ui->checkPause->blockSignals(true); ui->graphic_checkPause->blockSignals(true);
ui->checkPause->setChecked(yes); ui->graphic_checkPause->setChecked(yes);
ui->checkPause->blockSignals(false); ui->graphic_checkPause->blockSignals(false);
for (int i = 0; i < graphics.size(); ++i) for (int i = 0; i < graphics.size(); ++i)
graphics[i].cvrect = QRectF(); graphics[i].cvrect = QRectF();
if (!pause_) { if (!pause_) {
@@ -592,17 +592,17 @@ void Graphic::setHistorySize(double val) {
void Graphic::setMaxVisibleTime(double val) { void Graphic::setMaxVisibleTime(double val) {
visible_time = val; visible_time = val;
if (isFit) on_buttonAutofit_clicked(); if (isFit) on_graphic_buttonAutofit_clicked();
} }
void Graphic::setOnlyExpandY(bool yes) { void Graphic::setOnlyExpandY(bool yes) {
ui->actionExpandY->setChecked(yes); ui->graphic_actionExpandY->setChecked(yes);
} }
void Graphic::setOnlyExpandX(bool yes) { void Graphic::setOnlyExpandX(bool yes) {
ui->actionExpandX->setChecked(yes); ui->graphic_actionExpandX->setChecked(yes);
} }
@@ -649,25 +649,25 @@ void Graphic::setGraphicsDataRaw(const QByteArray & ba) {
void Graphic::setFloatingAxisEnabled(bool on) { void Graphic::setFloatingAxisEnabled(bool on) {
ui->checkGuides->setChecked(on); ui->graphic_checkGuides->setChecked(on);
} }
void Graphic::setButtons(Graphic::Buttons b) { void Graphic::setButtons(Graphic::Buttons b) {
buttons_ = b; buttons_ = b;
ui->buttonAutofit->setVisible(b.testFlag(Autofit)); ui->graphic_buttonAutofit->setVisible(b.testFlag(Autofit));
ui->checkGrid->setVisible(b.testFlag(Grid)); ui->graphic_checkGrid->setVisible(b.testFlag(Grid));
ui->checkGuides->setVisible(b.testFlag(CursorAxis)); ui->graphic_checkGuides->setVisible(b.testFlag(CursorAxis));
ui->buttonFullscreen->setVisible(b.testFlag(Fullscreen)); ui->graphic_buttonFullscreen->setVisible(b.testFlag(Fullscreen));
ui->checkBorderInputs->setVisible(b.testFlag(BorderInputs)); ui->graphic_checkBorderInputs->setVisible(b.testFlag(BorderInputs));
ui->checkLegend->setVisible(b.testFlag(Legend)); ui->graphic_checkLegend->setVisible(b.testFlag(Legend));
ui->buttonClear->setVisible(b.testFlag(Clear)); ui->graphic_buttonClear->setVisible(b.testFlag(Clear));
ui->buttonConfigure->setVisible(b.testFlag(Configure)); ui->graphic_buttonConfigure->setVisible(b.testFlag(Configure));
ui->buttonSave->setVisible(b.testFlag(Save)); ui->graphic_buttonSave->setVisible(b.testFlag(Save));
ui->buttonClose->setVisible(b.testFlag(Close)); ui->graphic_buttonClose->setVisible(b.testFlag(Close));
ui->checkPause->setVisible(b.testFlag(Pause)); ui->graphic_checkPause->setVisible(b.testFlag(Pause));
if (ui->buttonAutofit->isVisible() || ui->checkGrid->isVisible() || ui->checkGuides->isVisible() || if (ui->graphic_buttonAutofit ->isVisible() || ui->graphic_checkGrid ->isVisible() || ui->graphic_checkGuides->isVisible() ||
ui->buttonConfigure->isVisible() || ui->buttonSave->isVisible() || ui->checkPause->isVisible()) ui->graphic_buttonConfigure->isVisible() || ui->graphic_buttonSave->isVisible() || ui->graphic_checkPause ->isVisible())
ui->verticalSpacer->changeSize(0, 30, QSizePolicy::Preferred, QSizePolicy::Preferred); ui->verticalSpacer->changeSize(0, 30, QSizePolicy::Preferred, QSizePolicy::Preferred);
else else
ui->verticalSpacer->changeSize(0, 0, QSizePolicy::Preferred, QSizePolicy::Preferred); ui->verticalSpacer->changeSize(0, 0, QSizePolicy::Preferred, QSizePolicy::Preferred);
@@ -1447,7 +1447,7 @@ void Graphic::tick(int index, bool slide, bool update_) {
} }
void Graphic::on_buttonAutofit_clicked() { void Graphic::on_graphic_buttonAutofit_clicked() {
isFit = true; isFit = true;
bool isEmpty = true; bool isEmpty = true;
foreach (const GraphicType & t, graphics) { foreach (const GraphicType & t, graphics) {
@@ -1464,7 +1464,7 @@ void Graphic::on_buttonAutofit_clicked() {
} }
void Graphic::on_buttonConfigure_clicked() { void Graphic::on_graphic_buttonConfigure_clicked() {
conf->graphicItems.clear(); conf->graphicItems.clear();
for (int i = 0; i < graphics.size(); i++) { for (int i = 0; i < graphics.size(); i++) {
GraphicConf::GraphicItem item; GraphicConf::GraphicItem item;
@@ -1510,7 +1510,7 @@ void Graphic::on_buttonConfigure_clicked() {
} }
void Graphic::on_checkGuides_toggled(bool checked) { void Graphic::on_graphic_checkGuides_toggled(bool checked) {
guides = checked; guides = checked;
setGuidesCursor(); setGuidesCursor();
update(); update();
@@ -1594,8 +1594,8 @@ void Graphic::graphicVisibleChange(bool checked) {
QCheckBox * cb = qobject_cast<QCheckBox*>(sender()); QCheckBox * cb = qobject_cast<QCheckBox*>(sender());
int i = cb->property("graphic_num").toInt(); int i = cb->property("graphic_num").toInt();
graphics[i].visible = checked; graphics[i].visible = checked;
if (isFit) on_buttonAutofit_clicked(); if (isFit) on_graphic_buttonAutofit_clicked();
else update(); else {update();}
emit graphicSettingsChanged(); emit graphicSettingsChanged();
} }
@@ -1607,8 +1607,8 @@ void Graphic::graphicAllVisibleChange(bool checked) {
graphics[i].pb->setChecked(checked); graphics[i].pb->setChecked(checked);
} }
visible_update = false; visible_update = false;
if (isFit) on_buttonAutofit_clicked(); if (isFit) on_graphic_buttonAutofit_clicked();
else update(); else {update();}
emit graphicSettingsChanged(); emit graphicSettingsChanged();
} }
@@ -1759,14 +1759,14 @@ void Graphic::setCaption(const QString & str) {
void Graphic::setGridEnabled(bool enabled) { void Graphic::setGridEnabled(bool enabled) {
ui->checkGrid->setChecked(enabled); ui->graphic_checkGrid->setChecked(enabled);
} }
void Graphic::setBorderInputsVisible(bool visible) { void Graphic::setBorderInputsVisible(bool visible) {
ui->widgetLX->setVisible(visible); ui->widgetLX->setVisible(visible);
ui->widgetLY->setVisible(visible); ui->widgetLY->setVisible(visible);
ui->checkBorderInputs->setChecked(visible); ui->graphic_checkBorderInputs->setChecked(visible);
if (visible) setRectToLines(); if (visible) setRectToLines();
} }
@@ -1778,24 +1778,24 @@ void Graphic::setStatusVisible(bool visible) {
void Graphic::setLegendVisible(bool visible) { void Graphic::setLegendVisible(bool visible) {
ui->widgetLegend->setVisible(visible); ui->widgetLegend->setVisible(visible);
ui->checkLegend->setChecked(visible); ui->graphic_checkLegend->setChecked(visible);
updateLegend(); updateLegend();
} }
void Graphic::on_actionExpandX_triggered(bool checked) { void Graphic::on_graphic_actionExpandX_triggered(bool checked) {
only_expand_x = checked; only_expand_x = checked;
ui->actionExpandX->setIcon(checked ? icon_exp_x : icon_exp_sx); ui->graphic_actionExpandX->setIcon(checked ? icon_exp_x : icon_exp_sx);
} }
void Graphic::on_actionExpandY_triggered(bool checked) { void Graphic::on_graphic_actionExpandY_triggered(bool checked) {
only_expand_y = checked; only_expand_y = checked;
ui->actionExpandY->setIcon(checked ? icon_exp_y : icon_exp_sy); ui->graphic_actionExpandY->setIcon(checked ? icon_exp_y : icon_exp_sy);
} }
void Graphic::actionGuidesTriggered(QAction * a) { void Graphic::actionGuidesTriggered(QAction * a) {
ui->checkGuides->setChecked(true); ui->graphic_checkGuides->setChecked(true);
setFloatingAxisType((FloatingAxisType)a->property("_value").toInt()); setFloatingAxisType((FloatingAxisType)a->property("_value").toInt());
} }

View File

@@ -313,7 +313,7 @@ public slots:
void addGraphic(const GraphicType & gd, bool update = true) {graphics << gd; if (update) updateLegend();} void addGraphic(const GraphicType & gd, bool update = true) {graphics << gd; if (update) updateLegend();}
void setVisualRect(const QRectF & rect); void setVisualRect(const QRectF & rect);
void setDefaultRect(const QRectF & rect); void setDefaultRect(const QRectF & rect);
void autofit() {on_buttonAutofit_clicked();} void autofit() {on_graphic_buttonAutofit_clicked();}
void saveImage(); void saveImage();
void clear(); void clear();
void update(bool force = false); void update(bool force = false);
@@ -416,19 +416,19 @@ protected slots:
void lineXMaxChanged(double value) {selrect.setRight(value); checkLines();} void lineXMaxChanged(double value) {selrect.setRight(value); checkLines();}
void lineYMinChanged(double value) {selrect.setBottom(value); checkLines();} void lineYMinChanged(double value) {selrect.setBottom(value); checkLines();}
void lineYMaxChanged(double value) {selrect.setTop(value); checkLines();} void lineYMaxChanged(double value) {selrect.setTop(value); checkLines();}
void on_buttonClose_clicked() {emit closeRequest(this);} void on_graphic_buttonClose_clicked() {emit closeRequest(this);}
void on_buttonClear_clicked() {clear(); emit cleared();} void on_graphic_buttonClear_clicked() {clear(); emit cleared();}
void on_buttonAutofit_clicked(); void on_graphic_buttonAutofit_clicked();
void on_buttonConfigure_clicked(); void on_graphic_buttonConfigure_clicked();
void on_buttonFullscreen_clicked() {fullscreen();} void on_graphic_buttonFullscreen_clicked() {fullscreen();}
void on_buttonSave_clicked() {saveImage();} void on_graphic_buttonSave_clicked() {saveImage();}
void on_checkGrid_toggled(bool checked) {grid = checked; update();} void on_graphic_checkGrid_toggled(bool checked) {grid = checked; update();}
void on_checkGuides_toggled(bool checked); void on_graphic_checkGuides_toggled(bool checked);
void on_actionExpandX_triggered(bool checked); void on_graphic_actionExpandX_triggered(bool checked);
void on_actionExpandY_triggered(bool checked); void on_graphic_actionExpandY_triggered(bool checked);
void on_checkBorderInputs_toggled(bool checked) {setBorderInputsVisible(checked);} void on_graphic_checkBorderInputs_toggled(bool checked) {setBorderInputsVisible(checked);}
void on_checkLegend_toggled(bool checked) {setLegendVisible(checked);} void on_graphic_checkLegend_toggled(bool checked) {setLegendVisible(checked);}
void on_checkPause_toggled(bool checked) {setPaused(checked);} void on_graphic_checkPause_toggled(bool checked) {setPaused(checked);}
void actionGuidesTriggered(QAction * a); void actionGuidesTriggered(QAction * a);
void enterFullscreen(); void enterFullscreen();
void leaveFullscreen(); void leaveFullscreen();

View File

@@ -48,7 +48,7 @@
<number>2</number> <number>2</number>
</property> </property>
<item> <item>
<widget class="QToolButton" name="buttonAutofit"> <widget class="QToolButton" name="graphic_buttonAutofit">
<property name="toolTip"> <property name="toolTip">
<string>Autofit</string> <string>Autofit</string>
</property> </property>
@@ -59,7 +59,7 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QToolButton" name="checkGrid"> <widget class="QToolButton" name="graphic_checkGrid">
<property name="toolTip"> <property name="toolTip">
<string>Grid</string> <string>Grid</string>
</property> </property>
@@ -76,7 +76,7 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QToolButton" name="checkGuides"> <widget class="QToolButton" name="graphic_checkGuides">
<property name="toolTip"> <property name="toolTip">
<string>Cursor axis</string> <string>Cursor axis</string>
</property> </property>
@@ -90,7 +90,7 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QToolButton" name="buttonFullscreen"> <widget class="QToolButton" name="graphic_buttonFullscreen">
<property name="toolTip"> <property name="toolTip">
<string>Fullscreen</string> <string>Fullscreen</string>
</property> </property>
@@ -101,7 +101,7 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QToolButton" name="checkBorderInputs"> <widget class="QToolButton" name="graphic_checkBorderInputs">
<property name="toolTip"> <property name="toolTip">
<string>Border inputs</string> <string>Border inputs</string>
</property> </property>
@@ -118,7 +118,7 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QToolButton" name="checkLegend"> <widget class="QToolButton" name="graphic_checkLegend">
<property name="toolTip"> <property name="toolTip">
<string>Legend</string> <string>Legend</string>
</property> </property>
@@ -135,7 +135,7 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QToolButton" name="checkPause"> <widget class="QToolButton" name="graphic_checkPause">
<property name="toolTip"> <property name="toolTip">
<string>Pause</string> <string>Pause</string>
</property> </property>
@@ -149,23 +149,23 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QToolButton" name="buttonConfigure"> <widget class="QToolButton" name="graphic_buttonConfigure">
<property name="toolTip"> <property name="toolTip">
<string>Configure ...</string> <string>Configure ...</string>
</property> </property>
<property name="icon"> <property name="icon">
<iconset resource="qad_graphic.qrc"> <iconset resource="../application/qad_application.qrc">
<normaloff>:/icons/configure.png</normaloff>:/icons/configure.png</iconset> <normaloff>:/icons/configure.png</normaloff>:/icons/configure.png</iconset>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QToolButton" name="buttonSave"> <widget class="QToolButton" name="graphic_buttonSave">
<property name="toolTip"> <property name="toolTip">
<string>Save image ...</string> <string>Save image ...</string>
</property> </property>
<property name="icon"> <property name="icon">
<iconset resource="qad_graphic.qrc"> <iconset resource="../blockview/qad_blockview.qrc">
<normaloff>:/icons/document-save.png</normaloff>:/icons/document-save.png</iconset> <normaloff>:/icons/document-save.png</normaloff>:/icons/document-save.png</iconset>
</property> </property>
</widget> </widget>
@@ -187,23 +187,23 @@
</spacer> </spacer>
</item> </item>
<item> <item>
<widget class="QToolButton" name="buttonClear"> <widget class="QToolButton" name="graphic_buttonClear">
<property name="toolTip"> <property name="toolTip">
<string>Clear</string> <string>Clear</string>
</property> </property>
<property name="icon"> <property name="icon">
<iconset resource="qad_graphic.qrc"> <iconset resource="../application/qad_application.qrc">
<normaloff>:/icons/edit-clear.png</normaloff>:/icons/edit-clear.png</iconset> <normaloff>:/icons/edit-clear.png</normaloff>:/icons/edit-clear.png</iconset>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QToolButton" name="buttonClose"> <widget class="QToolButton" name="graphic_buttonClose">
<property name="toolTip"> <property name="toolTip">
<string>Close</string> <string>Close</string>
</property> </property>
<property name="icon"> <property name="icon">
<iconset resource="qad_graphic.qrc"> <iconset resource="../blockview/qad_blockview.qrc">
<normaloff>:/icons/dialog-close.png</normaloff>:/icons/dialog-close.png</iconset> <normaloff>:/icons/dialog-close.png</normaloff>:/icons/dialog-close.png</iconset>
</property> </property>
</widget> </widget>
@@ -397,7 +397,7 @@
</widget> </widget>
</item> </item>
</layout> </layout>
<action name="actionGuidesFree"> <action name="graphic_actionGuidesFree">
<property name="checkable"> <property name="checkable">
<bool>true</bool> <bool>true</bool>
</property> </property>
@@ -405,7 +405,7 @@
<string>Free</string> <string>Free</string>
</property> </property>
</action> </action>
<action name="actionGuidesTraceX"> <action name="graphic_actionGuidesTraceX">
<property name="checkable"> <property name="checkable">
<bool>true</bool> <bool>true</bool>
</property> </property>
@@ -413,7 +413,7 @@
<string>Trace X</string> <string>Trace X</string>
</property> </property>
</action> </action>
<action name="actionGuidesTraceY"> <action name="graphic_actionGuidesTraceY">
<property name="checkable"> <property name="checkable">
<bool>true</bool> <bool>true</bool>
</property> </property>
@@ -421,7 +421,7 @@
<string>Trace Y</string> <string>Trace Y</string>
</property> </property>
</action> </action>
<action name="actionExpandX"> <action name="graphic_actionExpandX">
<property name="checkable"> <property name="checkable">
<bool>true</bool> <bool>true</bool>
</property> </property>
@@ -429,7 +429,7 @@
<string>Only expand X</string> <string>Only expand X</string>
</property> </property>
</action> </action>
<action name="actionExpandY"> <action name="graphic_actionExpandY">
<property name="checkable"> <property name="checkable">
<bool>true</bool> <bool>true</bool>
</property> </property>
@@ -449,6 +449,8 @@
</customwidget> </customwidget>
</customwidgets> </customwidgets>
<resources> <resources>
<include location="../application/qad_application.qrc"/>
<include location="../blockview/qad_blockview.qrc"/>
<include location="qad_graphic.qrc"/> <include location="qad_graphic.qrc"/>
</resources> </resources>
<connections/> <connections/>