mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-01 21:56:43 +08:00
Utility function to set button width for QWizard
This commit is contained in:
committed by
Mat Sutcliffe
parent
0732c32922
commit
072bb34a32
@@ -9,6 +9,7 @@
|
||||
#include "configurationwizard.h"
|
||||
#include "ui_configurationwizard.h"
|
||||
#include "blackgui/guiapplication.h"
|
||||
#include "blackgui/guiutility.h"
|
||||
#include "blackmisc/math/mathutils.h"
|
||||
#include "blackmisc/directoryutils.h"
|
||||
#include <QPointer>
|
||||
@@ -25,7 +26,6 @@ namespace BlackGui
|
||||
ui(new Ui::CConfigurationWizard)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
this->setWindowFlags(windowFlags() | Qt::CustomizeWindowHint | Qt::WindowMinimizeButtonHint | Qt::WindowMaximizeButtonHint | Qt::WindowCloseButtonHint);
|
||||
|
||||
ui->wp_CopyModels->setConfigComponent(ui->comp_CopyModels);
|
||||
@@ -64,6 +64,7 @@ namespace BlackGui
|
||||
});
|
||||
|
||||
this->setScreenGeometry();
|
||||
CGuiUtility::setWizardButtonWidths(this);
|
||||
}
|
||||
|
||||
CConfigurationWizard::~CConfigurationWizard()
|
||||
|
||||
@@ -61,11 +61,7 @@ namespace BlackGui
|
||||
connect(ui->selector_AirlineName, &CDbAirlineIcaoSelectorComponent::changedAirlineIcao, this, &CDbQuickMappingWizard::onAirlineSelected, Qt::QueuedConnection);
|
||||
|
||||
ui->comp_Log->showFilterDialog(); // filter for log normally not needed, so dialog (not bar)
|
||||
|
||||
if (this->button(BackButton)) { this->button(BackButton)->setMinimumWidth(75); }
|
||||
if (this->button(NextButton)) { this->button(NextButton)->setMinimumWidth(75); }
|
||||
if (this->button(CancelButton)) { this->button(CancelButton)->setMinimumWidth(75); }
|
||||
if (this->button(FinishButton)) { this->button(FinishButton)->setMinimumWidth(75); }
|
||||
CGuiUtility::setWizardButtonWidths(this);
|
||||
|
||||
// init if data already available
|
||||
this->onWebDataRead();
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
#include <QTabWidget>
|
||||
#include <QThreadStorage>
|
||||
#include <QWidget>
|
||||
#include <QWizard>
|
||||
#include <QLabel>
|
||||
#include <QTimer>
|
||||
#include <Qt>
|
||||
@@ -684,4 +685,18 @@ namespace BlackGui
|
||||
const QString clippedText = metrics.elidedText(shortText, mode, width);
|
||||
label->setText(clippedText);
|
||||
}
|
||||
|
||||
void CGuiUtility::setWizardButtonWidths(QWizard *wizard)
|
||||
{
|
||||
if (!wizard) { return; }
|
||||
|
||||
const int minW = qMax(qRound(CGuiUtility::fontMetricsLazyDog43Chars(true).width() * 6.0 / 43.0), 80);
|
||||
if (wizard->button(QWizard::BackButton)) { wizard->button(QWizard::BackButton)->setMinimumWidth(minW); }
|
||||
if (wizard->button(QWizard::NextButton)) { wizard->button(QWizard::NextButton)->setMinimumWidth(minW); }
|
||||
if (wizard->button(QWizard::CancelButton)) { wizard->button(QWizard::CancelButton)->setMinimumWidth(minW); }
|
||||
if (wizard->button(QWizard::FinishButton)) { wizard->button(QWizard::FinishButton)->setMinimumWidth(minW); }
|
||||
if (wizard->button(QWizard::CustomButton1)) { wizard->button(QWizard::CustomButton1)->setMinimumWidth(minW); }
|
||||
if (wizard->button(QWizard::CustomButton2)) { wizard->button(QWizard::CustomButton2)->setMinimumWidth(minW); }
|
||||
if (wizard->button(QWizard::CustomButton3)) { wizard->button(QWizard::CustomButton3)->setMinimumWidth(minW); }
|
||||
}
|
||||
} // ns
|
||||
|
||||
@@ -33,6 +33,7 @@ class QLineEdit;
|
||||
class QTabWidget;
|
||||
class QDialog;
|
||||
class QLabel;
|
||||
class QWizard;
|
||||
class QGraphicsOpacityEffect;
|
||||
class QAbstractItemModel;
|
||||
|
||||
@@ -244,6 +245,9 @@ namespace BlackGui
|
||||
//! Set elided text
|
||||
static void setElidedText(QLabel *label, const QString &shortText, const QString &longText, Qt::TextElideMode mode = Qt::ElideMiddle);
|
||||
|
||||
//! Set button widths for a wizard
|
||||
static void setWizardButtonWidths(QWizard *wizard);
|
||||
|
||||
private:
|
||||
//! No constructor, use static functions only
|
||||
CGuiUtility() {}
|
||||
|
||||
Reference in New Issue
Block a user