Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(notebook): align actions and hotkeys #5353

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## Unversioned

- Bugfix: Fixed links without a protocol not being clickable. (#5345)
- Bugfix: Fixed <kbd>Ctrl</kbd>+<kbd>U</kbd> and "Toggle visibility of tabs" not having the same effect. (#5353)

## 2.5.0

Expand Down
18 changes: 14 additions & 4 deletions src/widgets/Notebook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ Notebook::Notebook(QWidget *parent)
[this](bool value) {
this->setLockNotebookLayout(value);
});
this->showTabsAction_ = new QAction("Toggle visibility of tabs");
QObject::connect(this->showTabsAction_, &QAction::triggered, [this]() {
this->toggleTabsAction_ = new QAction("Toggle visibility of tabs");
QObject::connect(this->toggleTabsAction_, &QAction::triggered, [this]() {
this->setShowTabs(!this->getShowTabs());
});
this->updateTabVisibilityMenuAction();
Expand Down Expand Up @@ -597,6 +597,11 @@ void Notebook::refresh()
this->updateTabVisibility();
}

QAction *Notebook::toggleTabsAction()
{
return this->toggleTabsAction_;
}

void Notebook::updateTabVisibility()
{
for (auto &item : this->items_)
Expand Down Expand Up @@ -631,7 +636,7 @@ void Notebook::updateTabVisibilityMenuAction()
HotkeyCategory::Window, "setTabVisibility", {{"on"}});
}
}
this->showTabsAction_->setShortcut(toggleSeq);
this->toggleTabsAction_->setShortcut(toggleSeq);
}

bool Notebook::getShowAddButton() const
Expand Down Expand Up @@ -1204,7 +1209,7 @@ void Notebook::setLockNotebookLayout(bool value)

void Notebook::addNotebookActionsToMenu(QMenu *menu)
{
menu->addAction(this->showTabsAction_);
menu->addAction(this->toggleTabsAction_);

menu->addAction(this->lockNotebookLayoutAction_);

Expand Down Expand Up @@ -1397,6 +1402,11 @@ void SplitNotebook::toggleOfflineTabs()
}
}

QAction *SplitNotebook::toggleOfflineTabsAction()
{
return this->toggleOfflineTabsAction_;
}

void SplitNotebook::addNotebookActionsToMenu(QMenu *menu)
{
Notebook::addNotebookActionsToMenu(menu);
Expand Down
6 changes: 5 additions & 1 deletion src/widgets/Notebook.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ class Notebook : public BaseWidget
// Update layout and tab visibility
void refresh();

QAction *toggleTabsAction();

protected:
void scaleChangedEvent(float scale_) override;
void resizeEvent(QResizeEvent *) override;
Expand Down Expand Up @@ -195,7 +197,7 @@ class Notebook : public BaseWidget
bool lockNotebookLayout_ = false;
NotebookTabLocation tabLocation_ = NotebookTabLocation::Top;
QAction *lockNotebookLayoutAction_;
QAction *showTabsAction_;
QAction *toggleTabsAction_;
QAction *toggleTopMostAction_;

// This filter, if set, is used to figure out the visibility of
Expand All @@ -218,6 +220,8 @@ class SplitNotebook : public Notebook
void addNotebookActionsToMenu(QMenu *menu) override;
void toggleOfflineTabs();

QAction *toggleOfflineTabsAction();

protected:
void showEvent(QShowEvent *event) override;

Expand Down
12 changes: 2 additions & 10 deletions src/widgets/Window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -636,26 +636,18 @@ void Window::addShortcuts()
if (arg == "off")
{
this->notebook_->setShowTabs(false);
getSettings()->tabVisibility.setValue(
NotebookTabVisibility::AllTabs);
}
else if (arg == "on")
{
this->notebook_->setShowTabs(true);
getSettings()->tabVisibility.setValue(
NotebookTabVisibility::AllTabs);
}
else if (arg == "toggle")
{
this->notebook_->setShowTabs(!this->notebook_->getShowTabs());
getSettings()->tabVisibility.setValue(
NotebookTabVisibility::AllTabs);
this->notebook_->toggleTabsAction()->trigger();
}
else if (arg == "liveOnly")
{
this->notebook_->setShowTabs(true);
getSettings()->tabVisibility.setValue(
NotebookTabVisibility::LiveOnly);
this->notebook_->toggleOfflineTabsAction()->trigger();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change feels wrong - in the hotkey selector, the value for this is "Live only on".
Right below this there's a "toggleLiveOnly" which calls this->notebook_->toggleOfflineTabs()

}
else if (arg == "toggleLiveOnly")
{
Expand Down
Loading