From ef9360a7e9d9eb6932eca480c93869e0e6c511e3 Mon Sep 17 00:00:00 2001 From: Chris Rizzitello Date: Sun, 7 Nov 2021 11:37:49 -0500 Subject: [PATCH] Remove Scale Options --- demos/ff7tkWidgetGallery/mainwindow.cpp | 11 +- demos/ff7tkWidgetGallery/mainwindow.h | 27 ++-- demos/ff7tkWidgetGallery/mainwindow.ui | 7 - src/widgets/CharEditor.cpp | 184 +++++++++++++----------- src/widgets/CharEditor.h | 17 +-- src/widgets/DoubleCheckBox.h | 3 +- src/widgets/LocationViewer.cpp | 24 ++-- src/widgets/LocationViewer.h | 3 +- src/widgets/SlotPreview.cpp | 21 ++- src/widgets/SlotPreview.h | 9 +- src/widgets/SlotSelect.cpp | 9 +- src/widgets/SlotSelect.h | 4 +- 12 files changed, 159 insertions(+), 160 deletions(-) diff --git a/demos/ff7tkWidgetGallery/mainwindow.cpp b/demos/ff7tkWidgetGallery/mainwindow.cpp index 4f451bd5a..fe2a41372 100644 --- a/demos/ff7tkWidgetGallery/mainwindow.cpp +++ b/demos/ff7tkWidgetGallery/mainwindow.cpp @@ -31,11 +31,6 @@ MainWindow::MainWindow(QWidget *parent): QMainWindow(parent), ui(new Ui::MainWin ui->setupUi(this); setWindowTitle(QStringLiteral("ff7tkWidgetGallery-%1").arg(ff7tk_version())); hideAllBoxes(); - QScreen *screen = QGuiApplication::screens().at(0); - screen->logicalDotsPerInchX(); - ui->sb_scale->setValue(screen->logicalDotsPerInchX() / 96); - scale = screen->logicalDotsPerInchX() / 96; - ListPHS = new PhsListWidget(this); QHBoxLayout *listLayout = new QHBoxLayout; @@ -57,7 +52,7 @@ MainWindow::MainWindow(QWidget *parent): QMainWindow(parent), ui(new Ui::MainWin materia_editor_layout->addWidget(materia_editor); ui->editor_box->setLayout(materia_editor_layout); - char_editor = new CharEditor(scale); + char_editor = new CharEditor(this); QHBoxLayout *char_editor_layout = new QHBoxLayout(); char_editor_layout->addWidget(char_editor); ui->charEditor_box->setLayout(char_editor_layout); @@ -67,7 +62,7 @@ MainWindow::MainWindow(QWidget *parent): QMainWindow(parent), ui(new Ui::MainWin item_list_layout->addWidget(item_list); ui->itemList_box->setLayout(item_list_layout); - locViewer = new LocationViewer(scale, this); + locViewer = new LocationViewer(this); QHBoxLayout *locLayout = new QHBoxLayout(); locLayout->addWidget(locViewer); ui->innerLocBox->setLayout(locLayout); @@ -156,7 +151,7 @@ void MainWindow::on_btn_slotSelect_clicked() QString filename = QFileDialog::getOpenFileName(this, "Select A Save To Preview", QDir::homePath(), fileFilter); if (!filename.isEmpty()) { if (ff7save.get()->loadFile(filename)) { - SlotSelect *slotSelect = new SlotSelect(scale, ff7save.get(), ui->cbShowLoad->isChecked()); + SlotSelect *slotSelect = new SlotSelect(ff7save.get(), ui->cbShowLoad->isChecked()); if (slotSelect->exec() == -1) { on_btn_slotSelect_clicked(); } else { diff --git a/demos/ff7tkWidgetGallery/mainwindow.h b/demos/ff7tkWidgetGallery/mainwindow.h index 255653a31..a4343e7e0 100644 --- a/demos/ff7tkWidgetGallery/mainwindow.h +++ b/demos/ff7tkWidgetGallery/mainwindow.h @@ -1,5 +1,5 @@ /****************************************************************************/ -// copyright 2012 - 2020 Chris Rizzitello // +// copyright 2012 - 2021 Chris Rizzitello // // // // This file is part of FF7tk // // // @@ -68,17 +68,16 @@ private slots: private: - Ui::MainWindow *ui; - qreal scale; - MateriaEditor *materia_editor; - CharEditor *char_editor; - ItemList *item_list; - MetadataCreator *metadataCreator; - PhsListWidget *ListPHS; - MenuListWidget *ListMenu; - Lgp *lgpFile; - LocationViewer *locViewer; - OptionsWidget *optionsWidget; - ChocoboManager *chocoboManager; - AchievementEditor *achievementEditor; + Ui::MainWindow *ui = nullptr; + MateriaEditor *materia_editor = nullptr; + CharEditor *char_editor = nullptr; + ItemList *item_list = nullptr; + MetadataCreator *metadataCreator = nullptr; + PhsListWidget *ListPHS = nullptr; + MenuListWidget *ListMenu = nullptr; + Lgp *lgpFile = nullptr; + LocationViewer *locViewer = nullptr; + OptionsWidget *optionsWidget = nullptr; + ChocoboManager *chocoboManager = nullptr; + AchievementEditor *achievementEditor = nullptr; }; diff --git a/demos/ff7tkWidgetGallery/mainwindow.ui b/demos/ff7tkWidgetGallery/mainwindow.ui index f3ac3daf5..d114bf590 100644 --- a/demos/ff7tkWidgetGallery/mainwindow.ui +++ b/demos/ff7tkWidgetGallery/mainwindow.ui @@ -90,13 +90,6 @@ - - - - Widget Scale : - - - diff --git a/src/widgets/CharEditor.cpp b/src/widgets/CharEditor.cpp index 6926c66ea..18e4ee05d 100644 --- a/src/widgets/CharEditor.cpp +++ b/src/widgets/CharEditor.cpp @@ -36,11 +36,14 @@ #include #include -CharEditor::CharEditor(qreal Scale, QWidget *parent) : QWidget(parent) +CharEditor::CharEditor(QWidget *parent) + : QWidget(parent) , data(FF7CHAR()) - , scale(Scale) , elemental_effects(new QListWidget) , status_effects(new QListWidget) + , charWidth(fontMetrics().horizontalAdvance(QChar('W'))) + , lineHeight(fontMetrics().height()) + , sbSizePolicy(QSizePolicy::Maximum, QSizePolicy::Fixed) { updateText(); init_display(); @@ -60,18 +63,22 @@ void CharEditor::updateText() if (!lineName) { lineName = new QLineEdit(this); lineName->setMaxLength(11); - lineName->setMaximumWidth(fontMetrics().horizontalAdvance(QChar('W')) * lineName->maxLength()); + lineName->setMaximumWidth(charWidth * lineName->maxLength()); } lineName->setPlaceholderText(tr("Name")); - if (!lblCurrentHp) + if (!lblCurrentHp) { lblCurrentHp = new QLabel(this); + lblCurrentHp->setSizePolicy(sbSizePolicy); + } lblCurrentHp->setText(tr("Current HP")); if (!sbCurrentHp) { sbCurrentHp = new QSpinBox(this); sbCurrentHp->setMaximum(qint16Max); sbCurrentHp->setWrapping(true); + sbCurrentHp->setAlignment(Qt::AlignHCenter); + sbCurrentHp->setSizePolicy(sbSizePolicy); } sbCurrentHp->setToolTip(tr("Current HP")); @@ -79,8 +86,9 @@ void CharEditor::updateText() sbBaseHp = new QSpinBox(this); sbBaseHp->setToolTip(tr("Base HP")); - if (!lblBaseHp) + if (!lblBaseHp){ lblBaseHp = new QLabel(this); + } lblBaseHp->setText(tr("HP")); if (!lblBaseHpBonus) @@ -91,14 +99,18 @@ void CharEditor::updateText() lblMaxHp = new QLabel(this); lblMaxHp->setToolTip(tr("Maximum HP")); - if (!lblCurrentMp) + if (!lblCurrentMp) { lblCurrentMp = new QLabel(this); + lblCurrentMp->setSizePolicy(sbSizePolicy); + } lblCurrentMp->setText(tr("Current MP")); if (!sbCurrentMp) { sbCurrentMp = new QSpinBox(this); sbCurrentMp->setMaximum(qint16Max); sbCurrentMp->setWrapping(true); + sbCurrentMp->setAlignment(Qt::AlignHCenter); + sbCurrentMp->setSizePolicy(sbSizePolicy); } sbCurrentMp->setToolTip(tr("Current MP")); @@ -121,15 +133,26 @@ void CharEditor::updateText() if (!sbLevel) { sbLevel = new QSpinBox(this); sbLevel->setMaximum(99); + sbLevel->setSizePolicy(sbSizePolicy); + } + sbLevel->setPrefix(tr("Level").append(QStringLiteral(": "))); + + if (!sbLimitLevel){ + sbLimitLevel = new QSpinBox; + sbLimitLevel->setMaximum(4); + sbLimitLevel->setWrapping(true); + sbLimitLevel->setAlignment(Qt::AlignHCenter); + sbLimitLevel->setSizePolicy(sbSizePolicy); } - sbLevel->setPrefix(tr("Level").append(": ")); + sbLimitLevel->setPrefix(tr("Limit Level").append(QStringLiteral(": "))); if (!sbKills) { sbKills = new QSpinBox(this); sbKills->setMaximum(quint16Max); sbKills->setWrapping(true); + sbKills->setSizePolicy(sbSizePolicy); } - sbKills->setPrefix(tr("Kills").append(": ")); + sbKills->setPrefix(tr("Kills").append(QStringLiteral(": "))); if (!cbFury) cbFury = new QCheckBox(this); @@ -325,11 +348,11 @@ void CharEditor::updateText() lblArmorStats = new QLabel(this); lblArmorStats->setText(tr("AP:x%1").arg(FF7Item::materiaGrowthRate(data.armor + 256))); - QSize iconSize(fontMetrics().height(), fontMetrics().height()); + QSize iconSize(lineHeight, lineHeight); if(!comboId) { comboId = new QComboBox(this); - comboId->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Fixed); + comboId->setSizePolicy(sbSizePolicy); comboId->setIconSize(iconSize); comboId->setHidden(true); for (int i = 0; i <= FF7Char::totalCharacters(); i++) @@ -384,29 +407,25 @@ void CharEditor::updateText() if (!lbl_1_1) { lbl_1_1 = new QLabel(this); - lbl_1_1->setFixedWidth(fontMetrics().horizontalAdvance(QStringLiteral("WWW"))); + lbl_1_1->setFixedWidth(charWidth * 3); lbl_1_1->setAlignment(Qt::AlignHCenter); } lbl_1_1->setText(tr("1-1")); if (!lbl_2_1) { lbl_2_1 = new QLabel(this); - lbl_2_1->setFixedWidth(fontMetrics().horizontalAdvance(QStringLiteral("WWW"))); + lbl_2_1->setFixedWidth(charWidth * 3); lbl_2_1->setAlignment(Qt::AlignHCenter); } lbl_2_1->setText(tr("2-1")); if (!lbl_3_1) { lbl_3_1 = new QLabel(this); - lbl_3_1->setFixedWidth(fontMetrics().horizontalAdvance(QStringLiteral("WWW"))); + lbl_3_1->setFixedWidth(charWidth * 3); lbl_3_1->setAlignment(Qt::AlignHCenter); } lbl_3_1->setText(tr("3-1")); - if (!lbl_limit_level) - lbl_limit_level = new QLabel(); - lbl_limit_level->setText(tr("Limit Level")); - if (!list_limits) { list_limits = new QListWidget(); list_limits->addItems(FF7Char::limits(0)); @@ -437,7 +456,7 @@ void CharEditor::updateMateriaToolTips() void CharEditor::init_display() { lblAvatar = new QLabel(this); - lblAvatar->setFixedSize(int(86 * scale), int(98 * scale)); + lblAvatar->setFixedSize(lineHeight * 6, lineHeight * 7); lblAvatar->setScaledContents(true); cb_idChanger = new QCheckBox(this); @@ -446,13 +465,13 @@ void CharEditor::init_display() bar_tnl = new QProgressBar(this); bar_tnl->setMaximum(61);//strange indeed.. bar_tnl->setTextVisible(false); - bar_tnl->setFixedHeight(int(10 * scale)); - bar_tnl->setFixedWidth(int(61 * scale)); + bar_tnl->setFixedHeight(lineHeight / 2); + bar_tnl->setFixedWidth(charWidth * 5); auto name_level_layout = new QHBoxLayout; name_level_layout->addWidget(lineName); - name_level_layout->addSpacerItem(new QSpacerItem(20, 0, QSizePolicy::Fixed, QSizePolicy::Fixed)); name_level_layout->addWidget(sbLevel); + name_level_layout->addSpacerItem(new QSpacerItem(20, 0, QSizePolicy::Expanding, QSizePolicy::Fixed)); auto hp_layout = new QHBoxLayout; hp_layout->addWidget(lblCurrentHp); @@ -470,21 +489,17 @@ void CharEditor::init_display() barNextLayout->addWidget(lbl_level_next); barNextLayout->addSpacerItem(new QSpacerItem(0, 0, QSizePolicy::MinimumExpanding, QSizePolicy::Fixed)); - auto exp_layout = new QVBoxLayout; + auto exp_layout = new QHBoxLayout; exp_layout->setContentsMargins(0, 0, 0, 0); exp_layout->addWidget(sbTotalExp); exp_layout->addLayout(barNextLayout); - auto kills_layout = new QHBoxLayout; - kills_layout->setContentsMargins(0, 0, 0, 0); - kills_layout->addWidget(sbKills); - kills_layout->addLayout(exp_layout); - auto name_hp_mp_kills_layout = new QVBoxLayout; name_hp_mp_kills_layout->addLayout(name_level_layout); name_hp_mp_kills_layout->addLayout(hp_layout); name_hp_mp_kills_layout->addLayout(mp_layout); - name_hp_mp_kills_layout->addLayout(kills_layout); + name_hp_mp_kills_layout->addWidget(sbKills); + name_hp_mp_kills_layout->addLayout(exp_layout); auto fury_sadness_layout = new QVBoxLayout; fury_sadness_layout->setContentsMargins(0, 0, 0, 0); @@ -498,15 +513,11 @@ void CharEditor::init_display() sadness_row_id_layout->addWidget(cb_idChanger); sadness_row_id_layout->addSpacerItem(new QSpacerItem(0, 6, QSizePolicy::Preferred, QSizePolicy::Preferred)); sadness_row_id_layout->addWidget(comboId); + sadness_row_id_layout->addSpacerItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Preferred)); - auto avatar_name_layout = new QHBoxLayout; - avatar_name_layout->setContentsMargins(0, 0, 0, 0); - avatar_name_layout->addWidget(lblAvatar); - avatar_name_layout->addLayout(name_hp_mp_kills_layout); - avatar_name_layout->addLayout(sadness_row_id_layout); - + auto lcdSize = QSize(charWidth * 2, lineHeight); lcd_0x34 = new QLCDNumber(2); - lcd_0x34->setFixedSize(int(32 * scale), int(20 * scale)); + lcd_0x34->setFixedSize(lcdSize); lcd_0x34->setHexMode(); lcd_0x34->setSegmentStyle(QLCDNumber::Flat); auto _0x34_layout = new QVBoxLayout; @@ -516,7 +527,7 @@ void CharEditor::init_display() _0x34_layout->addWidget(lcd_0x34); lcd_0x35 = new QLCDNumber(2); - lcd_0x35->setFixedSize(int (32 * scale), int(20 * scale)); + lcd_0x35->setFixedSize(lcdSize); lcd_0x35->setHexMode(); lcd_0x35->setSegmentStyle(QLCDNumber::Flat); auto _0x35_layout = new QVBoxLayout; @@ -526,7 +537,7 @@ void CharEditor::init_display() _0x35_layout->addWidget(lcd_0x35); lcd_0x36 = new QLCDNumber(2); - lcd_0x36->setFixedSize(int(32 * scale), int(20 * scale)); + lcd_0x36->setFixedSize(lcdSize); lcd_0x36->setHexMode(); lcd_0x36->setSegmentStyle(QLCDNumber::Flat); auto _0x36_layout = new QVBoxLayout; @@ -536,7 +547,7 @@ void CharEditor::init_display() _0x36_layout->addWidget(lcd_0x36); lcd_0x37 = new QLCDNumber(2); - lcd_0x37->setFixedSize(int(32 * scale), int(20 * scale)); + lcd_0x37->setFixedSize(lcdSize); lcd_0x37->setHexMode(); lcd_0x37->setSegmentStyle(QLCDNumber::Flat); auto _0x37_layout = new QVBoxLayout; @@ -557,16 +568,19 @@ void CharEditor::init_display() unknown_box->setLayout(unknown_layout); unknown_box->setVisible(false); - auto stat_layout_2 = new QHBoxLayout; - stat_layout_2->setContentsMargins(0, 0, 0, 0); - stat_layout_2->addWidget(makeStatFrame()); - stat_layout_2->addWidget(unknown_box); + auto avatar_name_layout = new QHBoxLayout; + avatar_name_layout->setContentsMargins(0, 0, 0, 0); + avatar_name_layout->addWidget(lblAvatar); + avatar_name_layout->addLayout(name_hp_mp_kills_layout); + avatar_name_layout->addLayout(sadness_row_id_layout); + avatar_name_layout->addWidget(unknown_box); + avatar_name_layout->addSpacerItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Fixed)); auto lower_section = new QVBoxLayout; lower_section->setContentsMargins(0, 0, 0, 0); - lower_section->setSpacing(0); - lower_section->addLayout(stat_layout_2); - lower_section->addLayout(makeLimitLayout()); + lower_section->setSpacing(6); + lower_section->addWidget(makeStatFrame()); + lower_section->addWidget(makeLimitLayout()); auto left_Final = new QVBoxLayout; left_Final->setContentsMargins(0, 0, 0, 0); @@ -576,7 +590,7 @@ void CharEditor::init_display() materia_edit = new MateriaEditor(this); materia_edit->setVisible(false); - materia_edit->setStarsSize(int(32 * scale)); + materia_edit->setStarsSize(lineHeight * 1.75F); auto elemental = new QHBoxLayout(); elemental->setContentsMargins(3, 3, 3, 3); @@ -770,7 +784,7 @@ void CharEditor::init_connections() connect(sb_uses_limit_1_1, QOverload::of(&QSpinBox::valueChanged), this, &CharEditor::setTimesused1); connect(sb_uses_limit_2_1, QOverload::of(&QSpinBox::valueChanged), this, &CharEditor::setTimesused2); connect(sb_uses_limit_3_1, QOverload::of(&QSpinBox::valueChanged), this, &CharEditor::setTimesused3); - connect(sb_limit_level, QOverload::of(&QSpinBox::valueChanged), this, &CharEditor::setLimitLevel); + connect(sbLimitLevel, QOverload::of(&QSpinBox::valueChanged), this, &CharEditor::setLimitLevel); connect(comboId, QOverload::of(&QComboBox::currentIndexChanged), this, &CharEditor::setId); connect(weapon_selection, QOverload::of(&QComboBox::currentIndexChanged), this, &CharEditor::setWeapon); connect(armor_selection, QOverload::of(&QComboBox::currentIndexChanged), this, &CharEditor::setArmor); @@ -811,7 +825,7 @@ void CharEditor::disconnectAll() disconnect(sb_uses_limit_1_1, QOverload::of(&QSpinBox::valueChanged), this, &CharEditor::setTimesused1); disconnect(sb_uses_limit_2_1, QOverload::of(&QSpinBox::valueChanged), this, &CharEditor::setTimesused2); disconnect(sb_uses_limit_3_1, QOverload::of(&QSpinBox::valueChanged), this, &CharEditor::setTimesused3); - disconnect(sb_limit_level, QOverload::of(&QSpinBox::valueChanged), this, &CharEditor::setLimitLevel); + disconnect(sbLimitLevel, QOverload::of(&QSpinBox::valueChanged), this, &CharEditor::setLimitLevel); disconnect(comboId, QOverload::of(&QComboBox::currentIndexChanged), this, &CharEditor::setId); disconnect(weapon_selection, QOverload::of(&QComboBox::currentIndexChanged), this, &CharEditor::setWeapon); disconnect(armor_selection, QOverload::of(&QComboBox::currentIndexChanged), this, &CharEditor::setArmor); @@ -1020,7 +1034,6 @@ void CharEditor::setChar(const FF7CHAR &Chardata, const QString &Processed_Name) data = Chardata; _name = Processed_Name; //more here like setting the gui stuff. - lblAvatar->setPixmap(FF7Char::pixmap(data.id)); lineName->setText(_name); sbLevel->setValue(data.level); @@ -1076,7 +1089,7 @@ void CharEditor::setChar(const FF7CHAR &Chardata, const QString &Processed_Name) sb_uses_limit_1_1->setValue(data.timesused1); sb_uses_limit_2_1->setValue(data.timesused2); sb_uses_limit_3_1->setValue(data.timesused3); - sb_limit_level->setValue(data.limitlevel); + sbLimitLevel->setValue(data.limitlevel); weapon_selection->clear(); for (int i = FF7Char::weaponStartingId(data.id); i < FF7Char::numberOfWeapons(data.id) + FF7Char::weaponStartingId(data.id); i++) @@ -1876,7 +1889,8 @@ void CharEditor::elemental_info() } }//end of for Loop elemental_effects->setFixedHeight(y); - elemental_box->setFixedSize(int(205 * scale), y + elemental_box->contentsMargins().top() + elemental_box->contentsMargins().bottom()); + + elemental_box->setFixedSize( (charWidth * 16), y + elemental_box->contentsMargins().top() + elemental_box->contentsMargins().bottom()); }//end of else. }//end of other loop. elemental_box->setVisible(show); @@ -1942,7 +1956,7 @@ void CharEditor::status_info() } }//end of for Loop status_effects->setFixedHeight(y); - status_box->setFixedSize(int(205 * scale), y + status_box->contentsMargins().top() + status_box->contentsMargins().bottom()); + status_box->setFixedSize(charWidth * 16, y + status_box->contentsMargins().top() + status_box->contentsMargins().bottom()); }//end of else. }//end of loop status_box->setVisible(show); @@ -2094,13 +2108,13 @@ void CharEditor::MaxStats() sbCurrentMp->setValue(data.maxMP); if (data.id == FF7Char::CaitSith) { - sb_limit_level->setValue(2); + sbLimitLevel->setValue(2); setLimits(0x09); } else if (data.id == FF7Char::Vincent) { - sb_limit_level->setValue(4); + sbLimitLevel->setValue(4); setLimits(0x249); } else { - sb_limit_level->setValue(4); + sbLimitLevel->setValue(4); setLimits(0x2DB); } } @@ -2158,27 +2172,28 @@ void CharEditor::setEditableComboBoxes(bool editable) QWidget* CharEditor::makeStatWidget(QSpinBox* statBaseSpinBox, QSpinBox* statSourceSpinBox, QLabel* statLabel, QLabel* statMateriaBonusLabel, QLabel* statTotalLabel) { - QSizePolicy policy(QSizePolicy::Maximum, QSizePolicy::Fixed); - int width = fontMetrics().horizontalAdvance(QStringLiteral("WWW")); + int width = charWidth * 3; statBaseSpinBox->setMaximum(quint8Max); statBaseSpinBox->setWrapping(true); statBaseSpinBox->setAlignment(Qt::AlignCenter); + statBaseSpinBox->setSizePolicy(sbSizePolicy); if (statSourceSpinBox) { statSourceSpinBox->setMaximum(quint8Max); statSourceSpinBox->setWrapping(true); statSourceSpinBox->setAlignment(Qt::AlignCenter); + statSourceSpinBox->setSizePolicy(sbSizePolicy); } statLabel->setFixedWidth(width); - statLabel->setSizePolicy(policy); + statLabel->setSizePolicy(sbSizePolicy); statMateriaBonusLabel->setFixedWidth(width); - statMateriaBonusLabel->setSizePolicy(policy); + statMateriaBonusLabel->setSizePolicy(sbSizePolicy); statTotalLabel->setFixedWidth(width); - statTotalLabel->setSizePolicy(policy); + statTotalLabel->setSizePolicy(sbSizePolicy); auto lblEquals = new QLabel(QStringLiteral("= ")); lblEquals->setFixedWidth(fontMetrics().horizontalAdvance(QStringLiteral("= "))); @@ -2205,7 +2220,7 @@ QWidget* CharEditor::makeStatWidget(QSpinBox* statBaseSpinBox, QSpinBox* statSou layout->addWidget(statTotalLabel); auto widget = new QWidget(); - widget->setSizePolicy(policy); + widget->setSizePolicy(sbSizePolicy); widget->setLayout(layout); return widget; @@ -2213,15 +2228,18 @@ QWidget* CharEditor::makeStatWidget(QSpinBox* statBaseSpinBox, QSpinBox* statSou QFrame * CharEditor::makeStatFrame() { + auto statLeftLayout = new QVBoxLayout; statLeftLayout->addWidget(makeStatWidget(sbBaseHp, nullptr, lblBaseHp, lblBaseHpBonus, lblMaxHp), 0); statLeftLayout->addWidget(makeStatWidget(sbStr, sbStrSourceUse, lblStr, lblStrMateriaBonus, lblStrTotal), 0); statLeftLayout->addWidget(makeStatWidget(sbVit, sbVitSourceUse, lblVit, lblVitMateriaBonus, lblVitTotal), 0); statLeftLayout->addWidget(makeStatWidget(sbMag, sbMagSourceUse, lblMag, lblMagMateriaBonus, lblMagTotal), 0); + int lblWidth = charWidth * 4; + sbBaseHp->setMaximum(qint16Max); - sbBaseHp->setFixedWidth(fontMetrics().horizontalAdvance(QStringLiteral("WWWWW"))); - lblBaseHpBonus->setFixedWidth(fontMetrics().horizontalAdvance(QStringLiteral("WWWW"))); + sbBaseHp->setSizePolicy(sbSizePolicy); + lblBaseHpBonus->setFixedWidth(lblWidth); auto statRightLayout = new QVBoxLayout; statRightLayout->addWidget(makeStatWidget(sbBaseMp, nullptr, lblBaseMp, lblBaseMpBonus, lblMaxMp), 0); @@ -2230,8 +2248,8 @@ QFrame * CharEditor::makeStatFrame() statRightLayout->addWidget(makeStatWidget(sbLck, sbLckSourceUse, lblLck, lblLckMateriaBonus, lblLckTotal), 0); sbBaseMp->setMaximum(qint16Max); - sbBaseMp->setFixedWidth(fontMetrics().horizontalAdvance(QStringLiteral("WWWWW"))); - lblBaseMpBonus->setFixedWidth(fontMetrics().horizontalAdvance(QStringLiteral("WWWW"))); + sbBaseMp->setSizePolicy(sbSizePolicy); + lblBaseMpBonus->setFixedWidth(lblWidth); auto statBox = new QFrame(this); auto statLayout = new QHBoxLayout(statBox); @@ -2244,6 +2262,7 @@ QFrame * CharEditor::makeStatFrame() QHBoxLayout * CharEditor::makeMateriaSlotPair(QPushButton* button1, QPushButton* button2, QFrame *frame1, QFrame *frame2, QLabel* linkLabel) { + auto scale = std::clamp(lineHeight / 16, 1.0F, 3.0F); QSize slotSize = QSize(int(32 * scale), int(32 * scale)); QSize frameSize = QSize(int(34 * scale), int(34 * scale)); QSize materiaSize = QSize(int(24 * scale), int(24 * scale)); @@ -2288,15 +2307,14 @@ QHBoxLayout * CharEditor::makeMateriaSlotPair(QPushButton* button1, QPushButton* return finalLayout; } -QVBoxLayout * CharEditor::makeLimitLayout() +QWidget * CharEditor::makeLimitLayout() { - int charWidth = fontMetrics().horizontalAdvance((QChar('W'))); sb_uses_limit_1_1 = new QSpinBox; sb_uses_limit_1_1->setMaximum(qint16Max); sb_uses_limit_1_1->setWrapping(true); - sb_uses_limit_1_1->setFixedWidth(charWidth * 5); sb_uses_limit_1_1->setAlignment(Qt::AlignCenter); + sb_uses_limit_1_1->setSizePolicy(sbSizePolicy); auto layout_1_1 = new QHBoxLayout; layout_1_1->setContentsMargins(0, 0, 0, 0); @@ -2306,8 +2324,8 @@ QVBoxLayout * CharEditor::makeLimitLayout() sb_uses_limit_2_1 = new QSpinBox; sb_uses_limit_2_1->setWrapping(true); sb_uses_limit_2_1->setMaximum(qint16Max); - sb_uses_limit_2_1->setFixedWidth(charWidth * 5); sb_uses_limit_2_1->setAlignment(Qt::AlignCenter); + sb_uses_limit_2_1->setSizePolicy(sbSizePolicy); auto layout_2_1 = new QHBoxLayout; layout_2_1->setContentsMargins(0, 0, 0, 0); @@ -2317,8 +2335,8 @@ QVBoxLayout * CharEditor::makeLimitLayout() sb_uses_limit_3_1 = new QSpinBox; sb_uses_limit_3_1->setMaximum(qint16Max); sb_uses_limit_3_1->setWrapping(true); - sb_uses_limit_3_1->setFixedWidth(charWidth * 5); sb_uses_limit_3_1->setAlignment(Qt::AlignCenter); + sb_uses_limit_3_1->setSizePolicy(sbSizePolicy); auto layout_3_1 = new QHBoxLayout; layout_3_1->setContentsMargins(0, 0, 0, 0); @@ -2326,46 +2344,40 @@ QVBoxLayout * CharEditor::makeLimitLayout() layout_3_1->addWidget(sb_uses_limit_3_1); auto used_limits_layout = new QVBoxLayout; - used_limits_layout->setContentsMargins(0, 6, 0, 0); + used_limits_layout->setContentsMargins(0, 0, 0, 0); + used_limits_layout->addWidget(sbLimitLevel); used_limits_layout->addWidget(lbl_uses); used_limits_layout->addLayout(layout_1_1); used_limits_layout->addLayout(layout_2_1); used_limits_layout->addLayout(layout_3_1); used_limits_layout->addSpacerItem(new QSpacerItem(0, 0, QSizePolicy::Preferred, QSizePolicy::Expanding)); - sb_limit_level = new QSpinBox; - sb_limit_level->setMaximum(4); - sb_limit_level->setWrapping(true); - sb_limit_level->setFixedWidth(charWidth * 4); - - auto limit_level_layout = new QHBoxLayout; - limit_level_layout->setContentsMargins(0, 0, 0, 0); - limit_level_layout->addWidget(lbl_limit_level); - limit_level_layout->addWidget(sb_limit_level); - slider_limit = new QSlider(Qt::Horizontal); slider_limit->setMaximum(quint8Max); - slider_limit->setMaximumHeight(int(20 * scale)); + slider_limit->setMaximumHeight(lineHeight); lcdLimitValue = new QLCDNumber(3); lcdLimitValue->setSegmentStyle(QLCDNumber::Flat); auto limit_bar_layout = new QHBoxLayout; limit_bar_layout->setContentsMargins(0, 0, 0, 0); - limit_bar_layout->addLayout(limit_level_layout); - limit_bar_layout->addSpacerItem(new QSpacerItem(10, 0, QSizePolicy::Fixed, QSizePolicy::Fixed)); limit_bar_layout->addWidget(lbl_limit_bar); limit_bar_layout->addWidget(slider_limit); limit_bar_layout->addWidget(lcdLimitValue); auto limit_use_list = new QHBoxLayout; limit_use_list->addLayout(used_limits_layout); + limit_use_list->setSpacing(3); limit_use_list->addWidget(list_limits); auto finalLayout = new QVBoxLayout; - finalLayout->setContentsMargins(0, 0, 0, 0); + finalLayout->setContentsMargins(6, 6, 0, 0); finalLayout->addLayout(limit_bar_layout); + finalLayout->setSpacing(6); finalLayout->addLayout(limit_use_list); + finalLayout->addSpacerItem(new QSpacerItem(0, 0, QSizePolicy::Preferred, QSizePolicy::Expanding)); - return finalLayout; + auto widget = new QWidget(this); + widget->setLayout(finalLayout); + return widget; } diff --git a/src/widgets/CharEditor.h b/src/widgets/CharEditor.h index c2e923272..e4bb40487 100644 --- a/src/widgets/CharEditor.h +++ b/src/widgets/CharEditor.h @@ -50,8 +50,9 @@ class FF7TKWIDGETS_EXPORT CharEditor : public QWidget { Q_OBJECT public: - explicit CharEditor(qreal Scale = 1, QWidget *parent = nullptr); + explicit CharEditor(QWidget *parent = nullptr); void setChar(const FF7CHAR &Chardata, const QString &Processed_Name = ""); + bool AutoLevel(); bool AutoStatCalc(); bool Editable(); @@ -241,10 +242,10 @@ public slots: QHBoxLayout * makeMateriaSlotPair(QPushButton* button1 = nullptr, QPushButton* button2 = nullptr, QFrame *frame1 = nullptr, QFrame *frame2 = nullptr, QLabel* linkLabel = nullptr); /** - * @brief Creates the layout for the limit related controls. - * @return Layout containing the controls for the limit items. + * @brief Creates the widget for the limit related controls. + * @return Widget containing the controls for the limit items. */ - QVBoxLayout * makeLimitLayout(); + QWidget * makeLimitLayout(); //Data bool load{false}; bool autolevel{true}; @@ -255,7 +256,6 @@ public slots: qint32 ap{0}; FF7CHAR data; QString _name; - qreal scale; //GUI PARTS QLabel *lblAvatar = nullptr; QLineEdit *lineName = nullptr; @@ -324,8 +324,7 @@ public slots: QLabel *lblLckMateriaBonus = nullptr; QLabel *lblLckTotal = nullptr; - QLabel *lbl_limit_level = nullptr; - QSpinBox *sb_limit_level = nullptr; + QSpinBox *sbLimitLevel = nullptr; QSpinBox *sb_uses_limit_1_1 = nullptr; QSpinBox *sb_uses_limit_2_1 = nullptr; QSpinBox *sb_uses_limit_3_1 = nullptr; @@ -375,5 +374,7 @@ public slots: inline static const int qint16Max = 32767; inline static const int quint16Max = 65535; inline static const int expMax = 2147483647; - + const int charWidth; + const int lineHeight; + const QSizePolicy sbSizePolicy; }; diff --git a/src/widgets/DoubleCheckBox.h b/src/widgets/DoubleCheckBox.h index 331ff4a72..e945fdd44 100644 --- a/src/widgets/DoubleCheckBox.h +++ b/src/widgets/DoubleCheckBox.h @@ -1,5 +1,5 @@ /****************************************************************************/ -// copyright 2012 - 2020 Chris Rizzitello // +// copyright 2012 - 2022 Chris Rizzitello // // // // This file is part of FF7tk // // // @@ -84,5 +84,4 @@ class FF7TKWIDGETS_EXPORT DoubleCheckBox : public QWidget QCheckBox *cb_one = nullptr; QCheckBox *cb_two = nullptr; QLabel *label = nullptr; - qreal _scale = 1; }; diff --git a/src/widgets/LocationViewer.cpp b/src/widgets/LocationViewer.cpp index 863974a1a..c9a4666af 100644 --- a/src/widgets/LocationViewer.cpp +++ b/src/widgets/LocationViewer.cpp @@ -38,9 +38,8 @@ #include #include -LocationViewer::LocationViewer(qreal Scale, QWidget *parent) +LocationViewer::LocationViewer(QWidget *parent) : QWidget(parent) - , scale(Scale) , region(QString()) , regExpSearch(false) , caseSensitive(false) @@ -98,7 +97,7 @@ void LocationViewer::resizeEvent(QResizeEvent *ev) if (pix.isNull()) { return; } - lblLocationPreview->setPixmap(pix.scaled(lblLocationPreview->size(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation)); + lblLocationPreview->setPixmap(pix.scaled(lblLocationPreview->size(), Qt::KeepAspectRatio, Qt::SmoothTransformation)); } } @@ -121,8 +120,8 @@ void LocationViewer::updateText() newItem->setToolTip(_tooltip.arg( FF7Location::mapID(i), FF7Location::locationID(i), - QString::number(320 * scale), - QString::number(480 * scale))); + QString::number(fontMetrics().height() * 12), + QString::number(fontMetrics().height() * 15))); locationTable->setItem(i, 1, newItem); } actionNameSearch->setText(tr("Filter Mode: Name / Location String")); @@ -152,8 +151,9 @@ void LocationViewer::updateText() void LocationViewer::init_display(void) { - lblLocationPreview->setMinimumSize(int(320 * scale), int(240 * scale)); - lblLocationPreview->setBaseSize(int(640 * scale), int(480 * scale)); + int h = fontMetrics().height(); + lblLocationPreview->setMinimumSize(h * 12, h *15); + lblLocationPreview->setBaseSize(h * 24, h * 30); lblLocationPreview->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); locationTable->verticalHeader()->setHidden(true); @@ -169,8 +169,8 @@ void LocationViewer::init_display(void) newItem->setToolTip(_tooltip.arg( FF7Location::mapID(i), FF7Location::locationID(i), - QString::number(320 * scale), - QString::number(480 * scale))); + QString::number(fontMetrics().height() * 12), + QString::number(fontMetrics().height() * 15))); newItem->setTextAlignment(Qt::AlignLeft); locationTable->setItem(i, 0, newItem); @@ -263,10 +263,6 @@ void LocationViewer::init_display(void) CoordsLayout->addLayout(nameIDs); CoordsLayout->addLayout(XYTD); - QHBoxLayout *PreviewLayout = new QHBoxLayout; - PreviewLayout->setAlignment(Qt::AlignCenter); - PreviewLayout->addWidget(lblLocationPreview); - QHBoxLayout *FilterLayout = new QHBoxLayout; FilterLayout->setContentsMargins(0, 0, 0, 0); FilterLayout->addWidget(lineTableFilter, 8); @@ -280,7 +276,7 @@ void LocationViewer::init_display(void) QVBoxLayout *RightSideLayout = new QVBoxLayout; RightSideLayout->addLayout(CoordsLayout); RightSideLayout->addWidget(btnUpdateSaveLocation); - RightSideLayout->addLayout(PreviewLayout); + RightSideLayout->addWidget(lblLocationPreview); RightSideLayout->addWidget(groupFieldItems); setAdvancedMode(advancedMode()); diff --git a/src/widgets/LocationViewer.h b/src/widgets/LocationViewer.h index 2caff8e40..50522bace 100644 --- a/src/widgets/LocationViewer.h +++ b/src/widgets/LocationViewer.h @@ -45,7 +45,7 @@ class FF7TKWIDGETS_EXPORT LocationViewer : public QWidget Q_OBJECT public: enum filterMode {NAME, ITEM}; - explicit LocationViewer(qreal Scale = 1, QWidget *parent = nullptr); + explicit LocationViewer(QWidget *parent = nullptr); void setFilterString(QString filter = "", LocationViewer::filterMode mode = LocationViewer::NAME); signals: void locationChanged(QString); @@ -105,7 +105,6 @@ private slots: QString translate(QString text); void searchItem(QRegularExpression exp); void searchName(QRegularExpression exp); - qreal scale; QString region; QString langDir; int currentStartingLocation = -1; diff --git a/src/widgets/SlotPreview.cpp b/src/widgets/SlotPreview.cpp index 783dc35ac..05bf0ed32 100644 --- a/src/widgets/SlotPreview.cpp +++ b/src/widgets/SlotPreview.cpp @@ -14,6 +14,7 @@ // GNU General Public License for more details. // /****************************************************************************/ #include +#include #include #include @@ -22,15 +23,17 @@ #include -SlotPreview::SlotPreview(int index, qreal Scale, QWidget *parent) +SlotPreview::SlotPreview(int index, QWidget *parent) : QLabel(parent) - , scale(Scale) , m_index(index) { + QFontMetrics formFont(QFont(QStringLiteral("Verdana"), 18, 75, false)); + m_lineHeight = formFont.height(); + Final = new QVBoxLayout(); Final->setContentsMargins(2, 2, 2, 2); setLayout(Final); - setFixedSize(int(582 * scale), int(135 * scale)); + setFixedSize(QSize( int((m_lineHeight *5.2) * 4.311), int(m_lineHeight * 5.2))); setStyleSheet(_previewStyle); setCursor(Qt::PointingHandCursor); } @@ -56,8 +59,13 @@ void SlotPreview::init_display(void) connect(btn_paste, &QToolButton::clicked, this, [this] { Q_EMIT btn_paste_clicked(m_index); }); const QList buttons = findChildren(); + + int btnWH = int (m_lineHeight * 0.8); + QSize btnSize = QSize(btnWH, btnWH); + QSize iconSize = QSize (btnWH - 4, btnWH - 4); for (auto btn : buttons) { - btn->setMaximumSize(int(22 * scale), int(22 * scale)); + btn->setFixedSize(btnSize); + btn->setIconSize(iconSize); btn->setCursor(Qt::BitmapCursor); btn->setHidden(true); } @@ -104,7 +112,7 @@ void SlotPreview::set_psx_game(void) icon = new SaveIcon; party1 = new QLabel; party1->setScaledContents(true); - party1->setFixedSize(int(96 * scale), int(96 * scale)); + party1->setFixedSize( int(m_lineHeight * 3.5) , int(m_lineHeight * 3.5)); connect (icon, &SaveIcon::nextIcon, party1, &QLabel::setPixmap); location = new QLabel; location->setStyleSheet(_genericStyle); @@ -122,8 +130,7 @@ void SlotPreview::set_psx_game(void) void SlotPreview::set_ff7_save(void) { - QSize avatarSize(int(84 * scale), int(96 * scale)); - + QSize avatarSize (m_lineHeight * 3 , m_lineHeight * 3.75); party1 = new QLabel; party1->setFixedSize(avatarSize); party1->setScaledContents(true); diff --git a/src/widgets/SlotPreview.h b/src/widgets/SlotPreview.h index fa9070464..b93910217 100644 --- a/src/widgets/SlotPreview.h +++ b/src/widgets/SlotPreview.h @@ -36,8 +36,9 @@ class FF7TKWIDGETS_EXPORT SlotPreview : public QLabel Q_OBJECT public: /** \enum MODE */ - enum MODE {MODE_EMPTY,/**< \brief Empty Slot*/ MODE_PSXGAME, /**< \brief PSX Game or linked block */ MODE_FF7SAVE /**< \brief FF7 Save in slot*/ }; - SlotPreview(int index = 0, qreal Scale = 1, QWidget *parent = nullptr); + enum MODE + {MODE_EMPTY,/**< \brief Empty Slot*/ MODE_PSXGAME, /**< \brief PSX Game or linked block */ MODE_FF7SAVE /**< \brief FF7 Save in slot*/ }; + SlotPreview(int index = 0, QWidget *parent = nullptr); int index(void); void setParty(QPixmap p1, QPixmap p2, QPixmap p3); void setParty(QString p1_style, QString p2_style, QString p3_style); @@ -80,9 +81,9 @@ class FF7TKWIDGETS_EXPORT SlotPreview : public QLabel QHBoxLayout *btnLayout = nullptr; QVBoxLayout *Final = nullptr; QVBoxLayout *top_layout = nullptr; - qreal scale; int m_index; - static inline QString _previewStyle = QStringLiteral(R"(SlotPreview{border: .5ex solid;}\nQPushButton{border: 1px solid})"); + int m_lineHeight; + static inline QString _previewStyle = QStringLiteral(R"(SlotPreview{border: .5ex solid;}\nQToolButton{border: 1px solid})"); static inline QString _genericStyle = QStringLiteral(R"(font: 75 16pt "Verdana"; color: white)"); static inline QString _ff7SlotStyle = QStringLiteral(R"(background-color:rgba(0,0,0,0);font: 75 16pt "Verdana";color:white)"); static inline QString _emptyTextStyle = QStringLiteral(R"(font: 75 20pt "Verdana"; color:yellow;)"); diff --git a/src/widgets/SlotSelect.cpp b/src/widgets/SlotSelect.cpp index 79835a110..f290c79fa 100644 --- a/src/widgets/SlotSelect.cpp +++ b/src/widgets/SlotSelect.cpp @@ -27,11 +27,10 @@ #include -SlotSelect::SlotSelect(qreal scale, FF7Save *data, bool loadVisible, QWidget *parent) +SlotSelect::SlotSelect(FF7Save *data, bool loadVisible, QWidget *parent) : QDialog(parent) , btnNew(new QPushButton(QIcon::fromTheme(QString("document-open"), QPixmap()), tr("Load Another File"))) , ff7(data) - , _scale(scale) { connect(btnNew, &QPushButton::clicked, this, &SlotSelect::newFile); setWindowFlags(((windowFlags() | Qt::CustomizeWindowHint) & ~Qt::WindowCloseButtonHint)); //remove close button @@ -44,7 +43,7 @@ SlotSelect::SlotSelect(qreal scale, FF7Save *data, bool loadVisible, QWidget *pa preview_layout->setContentsMargins(0, 0, 0, 0); preview_layout->setSpacing(3); for (int i = 0; i < 15; i++) { - preview[i] = new SlotPreview(i, _scale); + preview[i] = new SlotPreview(i, this); preview_layout->addWidget(preview[i]); setSlotPreview(i); } @@ -58,7 +57,7 @@ SlotSelect::SlotSelect(qreal scale, FF7Save *data, bool loadVisible, QWidget *pa dialog_layout->addWidget(btnNew); showLoad(loadVisible); setLayout(dialog_layout); - setFixedWidth(int(preview[1]->width() + contentsMargins().left() + contentsMargins().right() + list_preview->verticalScrollBar()->sizeHint().width() + 4 * _scale)); + setFixedWidth(int(preview[1]->width() + contentsMargins().left() + contentsMargins().right() + list_preview->verticalScrollBar()->sizeHint().width() + fontMetrics().horizontalAdvance(QChar(':')))); setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred); if(parent) move(parent->x() + ((parent->width() - width()) / 2), parent->y() + ((parent->sizeHint().height() - sizeHint().height()) /2)); @@ -125,7 +124,7 @@ void SlotSelect::paste_slot(int s) void SlotSelect::ReIntSlot(int s) { preview[s]->~SlotPreview(); - preview[s] = new SlotPreview(s, _scale); + preview[s] = new SlotPreview(s, this); preview_layout->insertWidget(s, preview[s]); setSlotPreview(s); } diff --git a/src/widgets/SlotSelect.h b/src/widgets/SlotSelect.h index a4211c2c2..fea610022 100644 --- a/src/widgets/SlotSelect.h +++ b/src/widgets/SlotSelect.h @@ -40,12 +40,11 @@ class FF7TKWIDGETS_EXPORT SlotSelect : public QDialog public: /** \brief create a new SlotSelect Dialog. - * \param scale Scale Fixed contents by this number (hidpi screens) * \param data Pointer to a FF7Save object * \param loadVisiable show the load file button * \param parent Dialogs Parent */ - explicit SlotSelect(qreal scale = 1, FF7Save *data = nullptr, bool loadVisiable = false, QWidget *parent = nullptr); + explicit SlotSelect(FF7Save *data = nullptr, bool loadVisiable = false, QWidget *parent = nullptr); private slots: void button_clicked(int s); void remove_slot(int s); @@ -61,5 +60,4 @@ private slots: QPushButton *btnNew; //Private Data FF7Save *ff7; - qreal _scale; };