ActionButtons: Showing +- labels with Qt 6.8.2 (cont.) (#4626)

Continuation of #4625
see https://groups.google.com/g/golden-cheetah-users/c/R-58f1LvwsM/m/XXFbjpOtAQAJ

* Updated more dialogs
* Changed vertical alignment of buttons in ActionButtonBox:
  https://groups.google.com/g/golden-cheetah-users/c/R-58f1LvwsM/m/tkNqRue3AQAJ
This commit is contained in:
Joachim Kohlhammer
2025-03-15 14:08:46 +01:00
committed by GitHub
parent f4dd479a01
commit 5c1eacee71
10 changed files with 56 additions and 105 deletions

View File

@@ -46,6 +46,7 @@ ExhaustionDialog::ExhaustionDialog(AllPlot *parent, Context *context, double sec
addButton = new QPushButton(tr(" + "));
#ifndef Q_OS_MAC
addButton->setFixedSize(20*dpiXFactor,20*dpiYFactor);
addButton->setStyleSheet("QPushButton { padding: 0px; }");
#endif
referenceValueLayout->addStretch();
referenceValueLayout->addWidget(addButton);
@@ -70,6 +71,7 @@ ExhaustionDialog::ExhaustionDialog(AllPlot *parent, Context *context, double sec
deleteRefButton = new QPushButton(" - ");
#ifndef Q_OS_MAC
deleteRefButton->setFixedSize(20*dpiXFactor,20*dpiYFactor);
deleteRefButton->setStyleSheet("QPushButton { padding: 0px; }");
#endif
connect(deleteRefButton, SIGNAL(clicked()), this, SLOT(deleteRef()));

View File

@@ -48,6 +48,7 @@ ReferenceLineDialog::ReferenceLineDialog(AllPlot *parent, Context *context, Ride
addButton = new QPushButton(tr(" + "));
#ifndef Q_OS_MAC
addButton->setFixedSize(20*dpiXFactor,20*dpiYFactor);
addButton->setStyleSheet("QPushButton { padding: 0px; }");
#endif
referenceValueLayout->addStretch();
referenceValueLayout->addWidget(addButton);
@@ -72,6 +73,7 @@ ReferenceLineDialog::ReferenceLineDialog(AllPlot *parent, Context *context, Ride
deleteRefButton = new QPushButton(" - ");
#ifndef Q_OS_MAC
deleteRefButton->setFixedSize(20*dpiXFactor,20*dpiYFactor);
deleteRefButton->setStyleSheet("QPushButton { padding: 0px; }");
#endif
connect(deleteRefButton, SIGNAL(clicked()), this, SLOT(deleteRef()));

View File

@@ -17,6 +17,7 @@
*/
#include "XDataDialog.h"
#include "ActionButtonBox.h"
#include "RideItem.h"
#include "RideFile.h"
#include "RideFileCommand.h"
@@ -69,45 +70,26 @@ XDataDialog::XDataDialog(QWidget *parent) : QDialog(parent), item(NULL)
xdataSeriesTable->setSelectionMode(QAbstractItemView::SingleSelection);
xdataSeriesTable->setSelectionBehavior(QAbstractItemView::SelectRows);
addXData = new QPushButton("+", this);
removeXData = new QPushButton("-", this);
addXDataSeries = new QPushButton("+", this);
removeXDataSeries = new QPushButton("-", this);
ActionButtonBox *xdataActionButtons = new ActionButtonBox(ActionButtonBox::AddDeleteGroup);
#ifdef Q_OS_MAC
addXData->setText(tr("Add"));
removeXData->setText(tr("Delete"));
addXDataSeries->setText(tr("Add"));
removeXDataSeries->setText(tr("Delete"));
#else
addXData->setFixedSize(20*dpiXFactor,20*dpiYFactor);
addXDataSeries->setFixedSize(20*dpiXFactor,20*dpiYFactor);
removeXData->setFixedSize(20*dpiXFactor,20*dpiYFactor);
removeXDataSeries->setFixedSize(20*dpiXFactor,20*dpiYFactor);
#endif
ActionButtonBox *xdataSeriesActionButtons = new ActionButtonBox(ActionButtonBox::AddDeleteGroup);
// lay it out
mainLayout->addWidget(xlabel);
mainLayout->addWidget(xdataTable);
QHBoxLayout *xb = new QHBoxLayout();
xb->addStretch();
xb->addWidget(addXData);
xb->addWidget(removeXData);
mainLayout->addLayout(xb);
mainLayout->addWidget(xdataActionButtons);
mainLayout->addWidget(xslabel);
mainLayout->addWidget(xdataSeriesTable);
QHBoxLayout *xs = new QHBoxLayout();
xs->addStretch();
xs->addWidget(addXDataSeries);
xs->addWidget(removeXDataSeries);
mainLayout->addLayout(xs);
mainLayout->addWidget(xdataSeriesActionButtons);
connect(xdataTable, SIGNAL(currentItemChanged(QTableWidgetItem*,QTableWidgetItem*)), this, SLOT(xdataSelected()));
connect(removeXData, SIGNAL(clicked(bool)), this, SLOT(removeXDataClicked()));
connect(addXData, SIGNAL(clicked(bool)), this, SLOT(addXDataClicked()));
connect(removeXDataSeries, SIGNAL(clicked(bool)), this, SLOT(removeXDataSeriesClicked()));
connect(addXDataSeries, SIGNAL(clicked(bool)), this, SLOT(addXDataSeriesClicked()));
xdataActionButtons->defaultConnect(xdataTable);
connect(xdataActionButtons, &ActionButtonBox::addRequested, this, &XDataDialog::addXDataClicked);
connect(xdataActionButtons, &ActionButtonBox::deleteRequested, this, &XDataDialog::removeXDataClicked);
xdataSeriesActionButtons->defaultConnect(xdataSeriesTable);
connect(xdataSeriesActionButtons, &ActionButtonBox::addRequested, this, &XDataDialog::addXDataSeriesClicked);
connect(xdataSeriesActionButtons, &ActionButtonBox::deleteRequested, this, &XDataDialog::removeXDataSeriesClicked);
}
void XDataDialog::close()

View File

@@ -58,9 +58,6 @@ class XDataDialog : public QDialog
QTableWidget *xdataTable;
QTableWidget *xdataSeriesTable;
QPushButton *addXData, *removeXData;
QPushButton *addXDataSeries, *removeXDataSeries;
QPushButton *closeButton;
};

View File

@@ -40,8 +40,8 @@ ActionButtonBox::ActionButtonBox
down->setArrowType(Qt::DownArrow);
down->setFixedSize(20 * dpiXFactor, 20 * dpiYFactor);
#endif
layout->addWidget(up, 0, Qt::AlignHCenter | Qt::AlignTop);
layout->addWidget(down, 0, Qt::AlignHCenter | Qt::AlignTop);
layout->addWidget(up, 0);
layout->addWidget(down, 0);
layout->addItem(new QSpacerItem(5 * dpiXFactor, 0));
leftOffset = 3;
@@ -79,8 +79,8 @@ ActionButtonBox::ActionButtonBox
del->setFixedSize(20 * dpiXFactor, 20 * dpiYFactor);
#endif
layout->addItem(new QSpacerItem(5 * dpiXFactor, 0));
layout->addWidget(add, 0, Qt::AlignHCenter | Qt::AlignTop);
layout->addWidget(del, 0, Qt::AlignHCenter | Qt::AlignTop);
layout->addWidget(add, 0);
layout->addWidget(del, 0);
rightOffset += 3;
connect(add, &QPushButton::clicked, this, &ActionButtonBox::addRequested);
@@ -203,6 +203,14 @@ ActionButtonBox::defaultConnect
}
void
ActionButtonBox::setMinViewItems
(int minItems)
{
minViewItems = minItems;
}
void
ActionButtonBox::setMaxViewItems
(int maxItems)
@@ -226,7 +234,7 @@ ActionButtonBox::updateButtonState
case AddDeleteGroup:
if (add != nullptr && del != nullptr) {
add->setEnabled(view->model()->rowCount() < maxViewItems);
del->setEnabled(index.isValid());
del->setEnabled(index.isValid() && view->model()->rowCount() > minViewItems);
}
break;
case EditGroup:

View File

@@ -66,6 +66,7 @@ class ActionButtonBox : public QWidget {
void defaultConnect(QAbstractItemView *view);
void defaultConnect(StandardButtonGroup group, QAbstractItemView *view);
void setMinViewItems(int minItems);
void setMaxViewItems(int maxItems);
signals:
@@ -88,6 +89,7 @@ class ActionButtonBox : public QWidget {
QPushButton *del = nullptr;
QPushButton *edit = nullptr;
int minViewItems = 0;
int maxViewItems = std::numeric_limits<int>::max();
int leftOffset = 0;

View File

@@ -18,6 +18,7 @@
#include "PerspectiveDialog.h"
#include "AbstractView.h"
#include "ActionButtonBox.h"
#include "Perspective.h"
#include <QFormLayout>
@@ -72,27 +73,10 @@ PerspectiveDialog::PerspectiveDialog(QWidget *parent, AbstractView *tabView) : Q
chartTable->setSelectionBehavior(QAbstractItemView::SelectRows);
chartTable->setDragEnabled(true);
upPerspective = new QToolButton(this);
upPerspective->setArrowType(Qt::UpArrow);
downPerspective = new QToolButton(this);
downPerspective->setArrowType(Qt::DownArrow);
upPerspective->setFixedSize(20*dpiXFactor,20*dpiYFactor);
downPerspective->setFixedSize(20*dpiXFactor,20*dpiYFactor);
editButton = new QPushButton(tr("Edit"), this);
importPerspective = new QPushButton(tr("Import"), this);
exportPerspective = new QPushButton(tr("Export"), this);
addPerspective = new QPushButton("+", this);
removePerspective = new QPushButton("-", this);
#ifdef Q_OS_MAC
addPerspective->setText(tr("Add"));
removePerspective->setText(tr("Delete"));
#else
addPerspective->setFixedSize(20*dpiXFactor,20*dpiYFactor);
removePerspective->setFixedSize(20*dpiXFactor,20*dpiYFactor);
#endif
ActionButtonBox *actionButtons = new ActionButtonBox(ActionButtonBox::UpDownGroup | ActionButtonBox::EditGroup | ActionButtonBox::AddDeleteGroup);
QPushButton *exportPerspective = actionButtons->addButton(tr("Export"), ActionButtonBox::Right);
QPushButton *importPerspective = actionButtons->addButton(tr("Import"), ActionButtonBox::Right);
actionButtons->setMinViewItems(1);
// not so obvious perhaps
instructions = new QLabel(tr("Drag charts to move to a perspective"));
@@ -100,19 +84,7 @@ PerspectiveDialog::PerspectiveDialog(QWidget *parent, AbstractView *tabView) : Q
// lay it out
mainLayout->addWidget(xlabel);
mainLayout->addWidget(perspectiveTable);
QHBoxLayout *xb = new QHBoxLayout();
xb->addWidget(upPerspective);
xb->addWidget(downPerspective);
xb->addStretch();
xb->addWidget(editButton);
xb->addStretch();
xb->addWidget(importPerspective);
xb->addWidget(exportPerspective);
xb->addStretch();
xb->addWidget(addPerspective);
xb->addWidget(removePerspective);
mainLayout->addLayout(xb);
mainLayout->addWidget(actionButtons);
mainLayout->addWidget(xslabel);
mainLayout->addWidget(chartTable);
QHBoxLayout *xs = new QHBoxLayout();
@@ -124,14 +96,14 @@ PerspectiveDialog::PerspectiveDialog(QWidget *parent, AbstractView *tabView) : Q
connect(perspectiveTable, SIGNAL(itemChanged(QTableWidgetItem*)), this, SLOT(perspectiveNameChanged(QTableWidgetItem*))); // user edit
connect(perspectiveTable, SIGNAL(itemDoubleClicked(QTableWidgetItem*)), this, SLOT(editPerspectiveClicked())); // Double click -> edit
connect(editButton, SIGNAL(clicked(bool)), this, SLOT(editPerspectiveClicked()));
connect(importPerspective, SIGNAL(clicked(bool)), this, SLOT(importPerspectiveClicked()));
connect(exportPerspective, SIGNAL(clicked(bool)), this, SLOT(exportPerspectiveClicked()));
connect(removePerspective, SIGNAL(clicked(bool)), this, SLOT(removePerspectiveClicked()));
connect(addPerspective, SIGNAL(clicked(bool)), this, SLOT(addPerspectiveClicked()));
connect(upPerspective, SIGNAL(clicked(bool)), this, SLOT(upPerspectiveClicked()));
connect(downPerspective, SIGNAL(clicked(bool)), this, SLOT(downPerspectiveClicked()));
actionButtons->defaultConnect(perspectiveTable);
connect(actionButtons, &ActionButtonBox::editRequested, this, &PerspectiveDialog::editPerspectiveClicked);
connect(actionButtons, &ActionButtonBox::addRequested, this, &PerspectiveDialog::addPerspectiveClicked);
connect(actionButtons, &ActionButtonBox::deleteRequested, this, &PerspectiveDialog::removePerspectiveClicked);
connect(actionButtons, &ActionButtonBox::upRequested, this, &PerspectiveDialog::upPerspectiveClicked);
connect(actionButtons, &ActionButtonBox::downRequested, this, &PerspectiveDialog::downPerspectiveClicked);
connect(importPerspective, &QPushButton::clicked, this, &PerspectiveDialog::importPerspectiveClicked);
connect(exportPerspective, &QPushButton::clicked, this, &PerspectiveDialog::exportPerspectiveClicked);
// set table
setTables();
@@ -165,9 +137,6 @@ void PerspectiveDialog::setTables()
}
// enable/disable remove button if we have > 1 perspectives
// it must not be possible to remove the last perspective
removePerspective->setEnabled(perspectiverow > 1);
active = false;
// set to first row
@@ -299,7 +268,7 @@ void
PerspectiveDialog::importPerspectiveClicked()
{
// import a new perspective from a file
QString fileName = QFileDialog::getOpenFileName(this, tr("Select Perspective file to export"), "", tr("GoldenCheetah Perspective Files (*.gchartset)"));
QString fileName = QFileDialog::getOpenFileName(this, tr("Select Perspective file to import"), "", tr("GoldenCheetah Perspective Files (*.gchartset)"));
if (fileName.isEmpty()) {
QMessageBox::critical(this, tr("Import Perspective"), tr("No perspective file selected!"));
} else {

View File

@@ -100,10 +100,6 @@ class PerspectiveDialog : public QDialog
PerspectiveTableWidget *perspectiveTable;
ChartTableWidget *chartTable;
QPushButton *editButton;
QPushButton *exportPerspective, *importPerspective;
QPushButton *addPerspective, *removePerspective;
QToolButton *upPerspective, *downPerspective;
QLabel *instructions;
QPushButton *closeButton;

View File

@@ -340,13 +340,11 @@ LibrarySearchDialog::LibrarySearchDialog(Context *context) : context(context)
findMedia->setChecked(true);
findVideoSyncs = new QCheckBox(tr("VideoSync files (.rlv, .tts etc)"), this);
findVideoSyncs->setChecked(true);
addPath = new QPushButton("+", this);
removePath = new QPushButton("-", this);
actionButtons = new ActionButtonBox(ActionButtonBox::AddDeleteGroup);
removeRef = new QPushButton("-", this);
#ifndef Q_OS_MAC
addPath->setFixedSize(20*dpiXFactor,20*dpiYFactor);
removePath->setFixedSize(20*dpiXFactor,20*dpiYFactor);
removeRef->setFixedSize(20*dpiXFactor,20*dpiYFactor);
removeRef->setStyleSheet("QPushButton { padding: 0px; }");
#endif
searchPathTable = new QTreeWidget(this);
@@ -418,15 +416,10 @@ LibrarySearchDialog::LibrarySearchDialog(Context *context) : context(context)
mainLayout->addWidget(findMedia, Qt::AlignCenter);
mainLayout->addWidget(findVideoSyncs, Qt::AlignCenter);
QHBoxLayout *editButtons = new QHBoxLayout;
QVBoxLayout *tableLayout = new QVBoxLayout;
editButtons->addWidget(addPath);
editButtons->addWidget(removePath);
editButtons->addStretch();
editButtons->setSpacing(2 *dpiXFactor);
tableLayout->setSpacing(2 *dpiXFactor);
tableLayout->addWidget(searchPathTable);
tableLayout->addLayout(editButtons);
tableLayout->addWidget(actionButtons);
QHBoxLayout *editButtons2 = new QHBoxLayout;
editButtons2->addWidget(removeRef);
editButtons2->addStretch();
@@ -459,8 +452,10 @@ LibrarySearchDialog::LibrarySearchDialog(Context *context) : context(context)
setSearching(false);
connect(addPath, SIGNAL(clicked()), this, SLOT(addDirectory()));
connect(removePath, SIGNAL(clicked()), this, SLOT(removeDirectory()));
actionButtons->defaultConnect(searchPathTable);
connect(actionButtons, &ActionButtonBox::addRequested, this, &LibrarySearchDialog::addDirectory);
connect(actionButtons, &ActionButtonBox::deleteRequested, this, &LibrarySearchDialog::removeDirectory);
connect(removeRef, SIGNAL(clicked()), this, SLOT(removeReference()));
connect(cancelButton, SIGNAL(clicked()), this, SLOT(cancel()));
connect(searchButton, SIGNAL(clicked()), this, SLOT(search()));
@@ -474,8 +469,7 @@ LibrarySearchDialog::setWidgets()
searchButton->hide();
cancelButton->setText(tr("Abort Search"));
searchPathTable->hide();
addPath->hide();
removePath->hide();
actionButtons->setVisible(false);
removeRef->hide();
refTable->hide();
@@ -493,8 +487,7 @@ LibrarySearchDialog::setWidgets()
searchButton->show();
cancelButton->setText(tr("Cancel"));
searchPathTable->show();
addPath->show();
removePath->show();
actionButtons->setVisible(true);
removeRef->show();
refTable->show();

View File

@@ -19,6 +19,7 @@
#ifndef _Library_h
#define _Library_h
#include "GoldenCheetah.h"
#include "ActionButtonBox.h"
#include <QDir>
#include <QLabel>
@@ -101,8 +102,7 @@ class LibrarySearchDialog : public QDialog
QCheckBox *findWorkouts,
*findVideoSyncs,
*findMedia;
QPushButton *addPath,
*removePath;
ActionButtonBox *actionButtons;
QPushButton *removeRef;
QTreeWidget *searchPathTable;
QTreeWidget *refTable;