Skip to content

Commit

Permalink
[fix] Height setting was buggy when calling redo operations
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxFleur committed Dec 23, 2024
1 parent 77a0cf3 commit f71a2eb
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 8 deletions.
5 changes: 3 additions & 2 deletions src/ui/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -268,9 +268,10 @@ MainWindow::setTableWidget(bool isDataStored, bool newCombatStarted)
setCentralWidget(m_combatWidget);
connect(m_combatWidget, &CombatWidget::exit, this, &MainWindow::exitCombat);
connect(m_combatWidget, &CombatWidget::tableHeightSet, this, [this] (unsigned int height) {
if (height > START_HEIGHT) {
resize(width(), height);
if (height <= START_HEIGHT) {
return;
}
resize(width(), height);
});
connect(m_combatWidget, &CombatWidget::tableWidthSet, this, [this] (int tableWidth) {
// @note A single immediate call to resize() won't actually resize the window
Expand Down
2 changes: 1 addition & 1 deletion src/ui/table/CombatTableWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ CombatTableWidget::getHeight() const
for (int i = 0; i < rowCount(); i++) {
height += rowHeight(i);
}
return height + HEIGHT_BUFFER;
return height + TABLE_HEIGHT_BUFFER;
}


Expand Down
2 changes: 1 addition & 1 deletion src/ui/table/CombatTableWidget.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class CombatTableWidget : public QTableWidget {
static constexpr int FIRST_FIVE_COLUMNS = 5;
static constexpr int NMBR_COLUMNS = 6;

static constexpr int HEIGHT_BUFFER = 140;
static constexpr int TABLE_HEIGHT_BUFFER = 140;

static constexpr float WIDTH_NAME = 0.20f;
static constexpr float WIDTH_INI = 0.05f;
Expand Down
6 changes: 3 additions & 3 deletions src/ui/table/CombatWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ CombatWidget::openAddCharacterDialog()
auto *const dialog = new AddCharacterDialog(m_additionalSettings.modAddedToIni, this);
connect(dialog, &AddCharacterDialog::characterCreated, this, [this, &sizeBeforeDialog] (CharacterHandler::Character character, int instanceCount) {
addCharacter(character, instanceCount);
emit tableHeightSet(m_tableWidget->getHeight() + 40);
emit tableHeightSet(m_tableWidget->getHeight() + Utils::Table::HEIGHT_BUFFER);

m_logListWidget->logConditionalValue(COUNT, m_characterHandler->getCharacters().size() - sizeBeforeDialog, true);
sizeBeforeDialog = m_characterHandler->getCharacters().size();
Expand Down Expand Up @@ -416,7 +416,7 @@ CombatWidget::insertTable()
std::iota(m_affectedRowIndices.begin(), m_affectedRowIndices.end(), oldSize);

pushOnUndoStack();
emit tableHeightSet(m_tableWidget->getHeight() + 40);
emit tableHeightSet(m_tableWidget->getHeight() + Utils::Table::HEIGHT_BUFFER);

auto const reply = QMessageBox::question(this, tr("Sort Table?"), tr("Do you want to resort the Table?"),
QMessageBox::Yes | QMessageBox::No);
Expand Down Expand Up @@ -618,7 +618,7 @@ CombatWidget::removeRow()
m_tableWidget->itemSelectionChanged();

if (m_tableSettings.adjustHeightAfterRemove) {
emit tableHeightSet(m_tableWidget->getHeight() + 40);
emit tableHeightSet(m_tableWidget->getHeight() + Utils::Table::HEIGHT_BUFFER);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/ui/table/Undo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ Undo::setCombatWidget(bool undo)
tableWidget->setTableRowColor(!m_colorTableRows);
tableWidget->setIniColumnTooltips(!m_showIniToolTips);

emit m_combatWidget->tableHeightSet(tableWidget->getHeight());
emit m_combatWidget->tableHeightSet(tableWidget->getHeight() + Utils::Table::HEIGHT_BUFFER);
emit m_combatWidget->changeOccured();

tableWidget->blockSignals(false);
Expand Down
2 changes: 2 additions & 0 deletions src/utils/UtilsTable.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ setTableAdditionalInfoWidget(CombatWidget* combatWidget,
unsigned int row,
const QVariant& additionalInfo);

static constexpr int HEIGHT_BUFFER = 40;

static constexpr int COL_NAME = 0;
static constexpr int COL_INI = 1;
static constexpr int COL_MODIFIER = 2;
Expand Down

0 comments on commit f71a2eb

Please sign in to comment.