Skip to content

Commit

Permalink
fix: UI bugs
Browse files Browse the repository at this point in the history
1. complete translations
2. fixed dialog box

log: bug fix
  • Loading branch information
HJC5305 committed Aug 16, 2023
1 parent e079dc4 commit 960bb9e
Show file tree
Hide file tree
Showing 16 changed files with 430 additions and 280 deletions.
303 changes: 186 additions & 117 deletions assets/translations/en_US.ts

Large diffs are not rendered by default.

326 changes: 198 additions & 128 deletions assets/translations/zh_CN.ts

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions src/common/dialog/contextdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ void ContextDialog::okCancel(QString text, QString title,
messageBox.setText(text);
messageBox.setIcon(icon);
messageBox.setStandardButtons(QMessageBox::Ok|QMessageBox::Cancel);
messageBox.button(QMessageBox::Ok)->setText(QObject::tr("OK"));
messageBox.button(QMessageBox::Cancel)->setText(QObject::tr("Cancel"));
if (okCallBack)
QObject::connect(messageBox.button(QMessageBox::Ok),
&QAbstractButton::clicked, okCallBack);
Expand All @@ -47,6 +49,7 @@ void ContextDialog::ok(QString text, QString title,
messageBox.setText(text);
messageBox.setIcon(icon);
messageBox.setStandardButtons(QMessageBox::Ok);
messageBox.button(QMessageBox::Ok)->setText(QObject::tr("OK"));
if (okCallBack)
QObject::connect(messageBox.button(QMessageBox::Ok),
&QAbstractButton::clicked, okCallBack);
Expand Down
1 change: 1 addition & 0 deletions src/common/dialog/contextdialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <QSet>

#include <functional>
#include <QObject>

class ContextDialog final
{
Expand Down
3 changes: 1 addition & 2 deletions src/framework/lifecycle/pluginview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,12 @@ PluginView::PluginView(QWidget *parent)
categoryWidegt->setIndentation(20);
categoryWidegt->setUniformRowHeights(true);
categoryWidegt->setSortingEnabled(true);
categoryWidegt->setColumnWidth(2, 40);
categoryWidegt->header()->setDefaultSectionSize(120);
categoryWidegt->header()->setMinimumSectionSize(40);
categoryWidegt->header()->setSortIndicator(0, Qt::AscendingOrder);
categoryWidegt->setSelectionMode(QAbstractItemView::SingleSelection);
categoryWidegt->setSelectionBehavior(QAbstractItemView::SelectRows);
categoryWidegt->setHeaderLabels({ tr("Name"), tr("Load"), tr("Version"), tr("Vendor") });
categoryWidegt->setHeaderLabels({QObject::tr("Name"), QObject::tr("Load"), QObject::tr("Version"), QObject::tr("Vendor")});

auto *gridLayout = new QGridLayout(this);
gridLayout->setContentsMargins(2, 2, 2, 2);
Expand Down
33 changes: 17 additions & 16 deletions src/plugins/binarytools/mainframe/binarytoolsdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "common/util/eventdefinitions.h"

#include <QPushButton>
#include <QDialogButtonBox>
#include <QProcess>
#include <QBoxLayout>
#include <QTextBlock>
Expand All @@ -15,6 +16,7 @@ class BinaryToolsDialogPrivate
{
friend class BinaryToolsDialog;
BinaryToolsConfigView *configView = nullptr;
QDialogButtonBox *buttons = nullptr;
};

BinaryToolsDialog::BinaryToolsDialog(QDialog *parent)
Expand All @@ -29,32 +31,31 @@ BinaryToolsDialog::BinaryToolsDialog(QDialog *parent)

d->configView = new BinaryToolsConfigView;
vLayout->addWidget(d->configView);

QHBoxLayout *buttonLayout = new QHBoxLayout(this);
QPushButton *pbtUse = new QPushButton(tr("Use Tool"), this);
QPushButton *pbtSave = new QPushButton(tr("Save"), this);
QPushButton *pbtCancel = new QPushButton(tr("Cancel"), this);
pbtUse->setDefault(true);
auto buttonSpacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);

buttonLayout->addItem(buttonSpacer);
buttonLayout->addWidget(pbtUse);
buttonLayout->addWidget(pbtSave);
buttonLayout->addWidget(pbtCancel);
vLayout->addStretch();

QHBoxLayout * buttonLayout = new QHBoxLayout();
d->buttons = new QDialogButtonBox(this);
d->buttons->setStandardButtons(QDialogButtonBox::Apply | QDialogButtonBox::Save | QDialogButtonBox::Cancel);
d->buttons->button(QDialogButtonBox::Apply)->setText(tr("Use Tool"));
d->buttons->button(QDialogButtonBox::Save)->setText(tr("Save"));
d->buttons->button(QDialogButtonBox::Cancel)->setText(tr("Cancel"));
d->buttons->button(QDialogButtonBox::Apply)->setDefault(true);
buttonLayout->addWidget(d->buttons);
vLayout->addLayout(buttonLayout);

connect(pbtUse, &QPushButton::clicked, [=](){
connect(d->configView, &BinaryToolsConfigView::useCombinationCommand, [=](){
QtConcurrent::run([=](){
useClicked();
});
});
connect(d->configView, &BinaryToolsConfigView::useCombinationCommand, [=](){
connect(d->buttons->button(QDialogButtonBox::Apply), &QPushButton::clicked, [=](){
QtConcurrent::run([=](){
useClicked();
});
});
connect(pbtSave, &QPushButton::clicked, this, &BinaryToolsDialog::saveClicked);
connect(pbtCancel, &QPushButton::clicked, this, &BinaryToolsDialog::reject);
connect(d->buttons->button(QDialogButtonBox::Save), &QPushButton::clicked, this, &BinaryToolsDialog::saveClicked);
connect(d->buttons, &QDialogButtonBox::rejected, this, &BinaryToolsDialog::reject);
connect(d->buttons, &QDialogButtonBox::accepted, this, &BinaryToolsDialog::accept);
}

BinaryToolsDialog::~BinaryToolsDialog()
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/binarytools/mainframe/environmentview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,9 @@ QVariant EnvironmentModel::headerData(int section, Qt::Orientation orientation,
if (orientation == Qt::Horizontal && role == Qt::DisplayRole) {
switch (section) {
case Key:
return tr("Key");
return QObject::tr("Variable");
case Value:
return tr("Value");
return QObject::tr("Value");
default:
break;
}
Expand Down
8 changes: 5 additions & 3 deletions src/plugins/core/mainframe/plugindialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ PluginDialog::PluginDialog(QWidget *parent)
auto vLayout = new QVBoxLayout(this);
vLayout->addWidget(view);

closeButton = new QDialogButtonBox(QDialogButtonBox::Close, Qt::Horizontal, this);
detailsButton = new QPushButton(tr("Details"), this);
closeButton = new QPushButton(tr("Close"), this);
closeButton->button(QDialogButtonBox::Close)->setText(tr("Close"));
detailsButton->setEnabled(false);
closeButton->setEnabled(true);
closeButton->setDefault(true);

restratRequired = new QLabel(tr(" Restart required."), this);
if (!isRestartRequired)
Expand All @@ -45,6 +45,7 @@ PluginDialog::PluginDialog(QWidget *parent)
hLayout->addWidget(restratRequired);
hLayout->addStretch(5);
hLayout->addWidget(closeButton);

vLayout->addLayout(hLayout);

QObject::connect(view, &dpf::PluginView::currentPluginChanged,
Expand All @@ -55,7 +56,7 @@ PluginDialog::PluginDialog(QWidget *parent)
this, &PluginDialog::updateRestartRequired);
QObject::connect(detailsButton, &QPushButton::clicked,
[this] { openDetails(); });
QObject::connect(closeButton, &QPushButton::clicked,
QObject::connect(closeButton->button(QDialogButtonBox::Close), &QPushButton::clicked,
[this] { closeDialog() ;});

updateButtons();
Expand Down Expand Up @@ -91,6 +92,7 @@ void PluginDialog::openDetails()
vLayout->addWidget(detailView);
detailView->update(plugin);
QDialogButtonBox *buttons = new QDialogButtonBox(QDialogButtonBox::Close, Qt::Horizontal, &dialog);
buttons->button(QDialogButtonBox::Close)->setText(tr("Close"));
vLayout->addWidget(buttons);

connect(buttons, &QDialogButtonBox::accepted, &dialog, &QDialog::accept);
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/core/mainframe/plugindialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#include <QSpacerItem>

class DetailsView;
class QPushButton;
class QDialogButtonBox;
class QLabel;

namespace dpf {
Expand All @@ -38,8 +38,8 @@ class PluginDialog : public QDialog
dpf::PluginView *view = nullptr;
DetailsView *detailView = nullptr;

QDialogButtonBox *closeButton = nullptr;
QPushButton *detailsButton = nullptr;
QPushButton *closeButton = nullptr;
QLabel *restratRequired = nullptr;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ DetailPropertyWidget::DetailPropertyWidget(QWidget *parent)
d->cleanStepsPane = new StepsPane(this);
d->envWidget = new EnvironmentWidget(this);

CollapseWidget *buildStep = new CollapseWidget("Build Steps", d->buildStepsPane, this);
CollapseWidget *cleanStep = new CollapseWidget("Clean Steps", d->cleanStepsPane, this);
CollapseWidget *envStep = new CollapseWidget("Runtime Env", d->envWidget, this);
CollapseWidget *buildStep = new CollapseWidget(QObject::tr("Build Steps"), d->buildStepsPane, this);
CollapseWidget *cleanStep = new CollapseWidget(QObject::tr("Clean Steps"), d->cleanStepsPane, this);
CollapseWidget *envStep = new CollapseWidget(QObject::tr("Runtime Env"), d->envWidget, this);

addCollapseWidget(buildStep);
addCollapseWidget(cleanStep);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ QVariant EnvironmentModel::headerData(int section, Qt::Orientation orientation,
if (orientation == Qt::Horizontal && role == Qt::DisplayRole) {
switch (section) {
case kVaribale:
return "Variable";
return QObject::tr("Variable");
case kValue:
return "Value";
return QObject::tr("Value");
default:
break;
}
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/java/gradle/option/gradlewidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ void GradleWidget::setupUi()
setLayout(vLayout);

QLabel *label = new QLabel(QLabel::tr("Gradle distribution:"));
d->useWrapper = new QRadioButton("use Gradle wrapper");
d->useWrapper = new QRadioButton(tr("use Gradle wrapper"));

QHBoxLayout *localLayout = new QHBoxLayout();
d->useLocal = new QRadioButton("use Local installation, directory:");
d->useLocal = new QRadioButton(tr("use Local installation, directory:"));
d->useLocal->setFixedWidth(300);
d->useLocal->setChecked(true);
d->localDetail = new QComboBox();
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/option/optioncore/mainframe/environmentwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ class EnvironmentModel : public QAbstractTableModel
if (orientation == Qt::Horizontal && role == Qt::DisplayRole) {
switch (section) {
case kVaribale:
return "Variable";
return QObject::tr("Variable");
case kValue:
return "Value";
return QObject::tr("Value");
default:
; // do nothing.
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@

class OptionGeneralGenerator : public dpfservice::OptionGenerator
{
Q_OBJECT
public:
OptionGeneralGenerator();
inline static QString kitName() {return tr("General");}
inline static QString kitName() {return QObject::tr("General");}
virtual QWidget *optionWidget() override;
};

Expand Down
2 changes: 2 additions & 0 deletions src/plugins/reversedebug/eventfilterdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,8 @@ void EventFilterDialog::setupUi()

d->buttonBox = new QDialogButtonBox(this);
d->buttonBox->setStandardButtons(QDialogButtonBox::Cancel | QDialogButtonBox::Ok);
d->buttonBox->button(QDialogButtonBox::Ok)->setText(tr("OK"));
d->buttonBox->button(QDialogButtonBox::Cancel)->setText(tr("Cancel"));
d->buttonBox->button(QDialogButtonBox::Ok)->setDefault(true);
d->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true);

Expand Down
2 changes: 2 additions & 0 deletions src/plugins/reversedebug/loadcoredialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ void LoadCoreDialog::setupUi()
// ok & cancel button.
d->buttonBox = new QDialogButtonBox(this);
d->buttonBox->setStandardButtons(QDialogButtonBox::Cancel | QDialogButtonBox::Ok);
d->buttonBox->button(QDialogButtonBox::Ok)->setText(tr("OK"));
d->buttonBox->button(QDialogButtonBox::Cancel)->setText(tr("Cancel"));
d->buttonBox->button(QDialogButtonBox::Ok)->setDefault(true);

auto hLayout = new QHBoxLayout();
Expand Down

0 comments on commit 960bb9e

Please sign in to comment.