Skip to content

Commit

Permalink
Fixed new tab from preset and context menu's collapse action (#1176)
Browse files Browse the repository at this point in the history
This patch fixes two bugs when the terminal is started with a preset of N > 1 terminals:

 * Previously, the action "New tab from preset" didn't work correctly when the number of preset was less than N.
 * Also, if the terminal context menu was the first menu that was opened, the action "Collapse Subterminal" would be disabled.

I also silenced a compilation warning about `&QCheckBox::stateChanged`.

Fixes #1104
  • Loading branch information
tsujan authored Oct 30, 2024
1 parent bbd678f commit 49c4721
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -381,8 +381,10 @@ void MainWindow::setup_FileMenu_Actions()

if (presetsMenu == nullptr) {
presetsMenu = new QMenu(tr("New Tab From &Preset"), this);
presetsMenu->addAction(QIcon(), tr("1 &Terminal"),
this, SLOT(addNewTab()));
auto a = presetsMenu->addAction(QIcon(), tr("1 &Terminal"));
connect(a, &QAction::triggered, consoleTabulator, [this]() {
consoleTabulator->addNewTab(m_config);
});
presetsMenu->addAction(QIcon(), tr("2 &Horizontal Terminals"),
consoleTabulator, SLOT(preset2Horizontal()));
presetsMenu->addAction(QIcon(), tr("2 &Vertical Terminals"),
Expand Down
7 changes: 6 additions & 1 deletion src/propertiesdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,12 @@ PropertiesDialog::PropertiesDialog(QWidget *parent)
this, &PropertiesDialog::chooseBackgroundImageButton_clicked);

// fixed size
connect(saveSizeOnExitCheckBox, &QCheckBox::stateChanged, [this] (int state) {
#if (QT_VERSION >= QT_VERSION_CHECK(6,7,0))
connect(saveSizeOnExitCheckBox, &QCheckBox::checkStateChanged, [this] (int state)
#else
connect(saveSizeOnExitCheckBox, &QCheckBox::stateChanged, [this] (int state)
#endif
{
fixedSizeLabel->setEnabled(state == Qt::Unchecked);
xLabel->setEnabled(state == Qt::Unchecked);
fixedWithSpinBox->setEnabled(state == Qt::Unchecked);
Expand Down
5 changes: 5 additions & 0 deletions src/termwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,11 @@ void TermWidgetImpl::customContextMenuCall(const QPoint & pos)
menu.addAction(actions[QStringLiteral(TOGGLE_MENU)]);
menu.addAction(actions[QStringLiteral(HIDE_WINDOW_BORDERS)]);
menu.addAction(actions[QStringLiteral(PREFERENCES)]);

// The disabled actions should be updated before showing the menu because
// the "Actions" menu of the main window may have not been shown yet.
mainWindow->updateDisabledActions();

menu.exec(mapToGlobal(pos));
}

Expand Down

0 comments on commit 49c4721

Please sign in to comment.