Skip to content

Commit

Permalink
[UX] Add of the "Jump to..." navigation method and clean the "Window"…
Browse files Browse the repository at this point in the history
… menu of its duplicated elements (openscad#5630)

* Add of the "Jump to..." navigation method and clean the "Window" menu of its duplicated elements
* Add overlay hint to indicate to users the selected dock.
* Move the title management on topLevelChanged from MainWindow into Dock.
* Replace the dock title management in MainWindow & TabManager by the one in Dock.

The MainWindow class was having a lot of slots and method to handle topLevel changes.
eg:
   void consoleTopLevelChanged(bool);

There was several duplication in the code, with one slot per dock.
Most of the code was there to handle the two version of the dock's title.

Now that the title is implemented in Dock  class, all that code is not needed anymore
So the PR remove it.

The PR also move into dedicated method some code fragment used in several places.
This is why the following method appears:
- MainWindow::getCurrentFileName();

In TabManager there was also direct call to the MainWindow method, including
slot regarding topLevel changes. see TabManager::getTabContent() for an example.
I see no good reason justifying the cross dependency between TabManager and MainWindow, so
all the direct calling to MainWindows methods have been moved into the MainWindow::onTabManagerEditorChanged slot
The slot being connected to the new signal TabManager::currentEditorChanged

Finally all connection between tabmanager and maindows have been moved from TabManager to MainWindow.
Ideally the TabManager class should't include "MainWindow.h".

* Fix keyboard navigation with CTRL+K and CTRL+L problem.

The problem exists in master branch of openscad and is related to how we select the docks by using only
if the dock has focus or not. This seems to be not enough, and we also need to take the window
activation state.

---------

Signed-off-by: Damien Marchal <[email protected]>
Co-authored-by: Chris Mayo <[email protected]>
  • Loading branch information
damienmarchal and cjmayo authored Feb 23, 2025
1 parent c3d1738 commit 55a638f
Show file tree
Hide file tree
Showing 10 changed files with 327 additions and 244 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1091,6 +1091,7 @@ set(GUI_SOURCES
src/gui/PrintService.cc
src/gui/ExternalToolInterface.cc
src/gui/ProgressWidget.cc
src/gui/RubberBandManager.cc
src/gui/QGLView.cc
src/gui/QGLView2.cc
src/gui/QSettingsCached.cc
Expand Down Expand Up @@ -1158,6 +1159,7 @@ set(GUI_HEADERS
src/gui/PrintInitDialog.h
src/gui/PrintService.h
src/gui/ProgressWidget.h
src/gui/RubberBandManager.h
src/gui/QGLView.h
src/gui/QSettingsCached.h
src/gui/QWordSearchField.h
Expand Down
49 changes: 49 additions & 0 deletions src/gui/Dock.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@

Dock::Dock(QWidget *parent) : QDockWidget(parent)
{
connect(this, &QDockWidget::topLevelChanged, this, &Dock::onTopLevelStatusChanged);
dockTitleWidget = new QWidget();
}

Dock::~Dock()
{
delete dockTitleWidget;
}

void Dock::disableSettingsUpdate()
Expand All @@ -26,6 +33,11 @@ void Dock::setVisible(bool visible)
QDockWidget::setVisible(visible);
}

void Dock::setTitleBarVisibility(bool isVisible)
{
setTitleBarWidget(isVisible? dockTitleWidget : nullptr);
}

void Dock::setConfigKey(const QString& configKey)
{
this->configKey = configKey;
Expand All @@ -35,3 +47,40 @@ void Dock::setAction(QAction *action)
{
this->action = action;
}

void Dock::updateTitle(){
QString title(name);
if (isTopLevel() && !namesuffix.isEmpty()) {
title += " (" + namesuffix + ")";
}
setWindowTitle(title);
}

void Dock::setName(const QString& name_) {
name = name_;
updateTitle();
}

QString Dock::getName() const {
return name;
}

void Dock::setNameSuffix(const QString& namesuffix_) {
namesuffix = namesuffix_;
updateTitle();
}

void Dock::onTopLevelStatusChanged(bool isTopLevel)
{
// update the title of the window so it contains the title suffix (in general filename)
// also update the flags and visibility to provide interactive feedback on the user action
// while it is moving the dock in topLevel=true state. The purpose of such setting
// on Qt::Window flag is to allow the dock to be floating behind the main window,
// something which isn't supported for regular QDockWidgets.
Qt::WindowFlags flags = (windowFlags() & ~Qt::WindowType_Mask) | Qt::Window;
if (isTopLevel) {
setWindowFlags(flags);
show();
}
updateTitle();
}
14 changes: 14 additions & 0 deletions src/gui/Dock.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,29 @@ class Dock : public QDockWidget

public:
Dock(QWidget *parent = nullptr);
virtual ~Dock();

void setConfigKey(const QString& configKey);
void setAction(QAction *action);
void disableSettingsUpdate();

void setName(const QString& name_);
[[nodiscard]] QString getName() const;

void setNameSuffix(const QString& namesuffix_);
void setTitleBarVisibility(bool isVisible);
void updateTitle();


public slots:
void setVisible(bool visible) override;
void onTopLevelStatusChanged(bool);

private:
QString name;
QString namesuffix;
QString configKey;
QAction *action{nullptr};
bool updateSettings{true};
QWidget *dockTitleWidget;
};
Loading

0 comments on commit 55a638f

Please sign in to comment.