Skip to content

Commit

Permalink
Add shortcut manager in print layouts
Browse files Browse the repository at this point in the history
  • Loading branch information
YoannQDQ authored and nyalldawson committed Jan 16, 2023
1 parent 98b93c0 commit f8cd418
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 1 deletion.
15 changes: 15 additions & 0 deletions src/app/layout/qgslayoutdesignerdialog.cpp
Expand Up @@ -73,6 +73,8 @@
#include "qgslayoutlabelwidget.h"
#include "qgslabelingresults.h"
#include "qgsscreenhelper.h"
#include "qgsshortcutsmanager.h"
#include "qgsconfigureshortcutsdialog.h"
#include "ui_defaults.h"

#include <QShortcut>
Expand Down Expand Up @@ -993,6 +995,12 @@ QgsLayoutDesignerDialog::QgsLayoutDesignerDialog( QWidget *parent, Qt::WindowFla
std::sort( actions.begin(), actions.end(), cmpByText_ );
mToolbarMenu->insertActions( nullptr, actions );

// Create the shortcuts manager
mShortcutsManager = new QgsShortcutsManager( this, "LayoutDesigner/shortcuts/" );
mShortcutsManager->registerAllChildren( this );
mShortcutsDialog = new QgsConfigureShortcutsDialog( this, mShortcutsManager ) ;
connect( mActionKeyboardShortcuts, &QAction::triggered, mShortcutsDialog, &QDialog::show );

restoreWindowState();

//listen out to status bar updates from the view
Expand Down Expand Up @@ -1125,6 +1133,13 @@ std::unique_ptr<QgsLayoutDesignerInterface::ExportResults> QgsLayoutDesignerDial
return mLastExportResults ? std::make_unique< QgsLayoutDesignerInterface::ExportResults>( *mLastExportResults ) : nullptr;
}


QgsShortcutsManager *QgsLayoutDesignerDialog::shortcutsManager()
{
return mShortcutsManager;
}


QgsLayout *QgsLayoutDesignerDialog::currentLayout()
{
return mLayout;
Expand Down
11 changes: 11 additions & 0 deletions src/app/layout/qgslayoutdesignerdialog.h
Expand Up @@ -49,6 +49,7 @@ class QgsFeature;
class QgsMasterLayoutInterface;
class QgsLayoutGuideWidget;
class QgsScreenHelper;
class QgsConfigureShortcutsDialog;

class QgsAppLayoutDesignerInterface : public QgsLayoutDesignerInterface
{
Expand Down Expand Up @@ -209,6 +210,12 @@ class QgsLayoutDesignerDialog: public QMainWindow, public Ui::QgsLayoutDesignerB
*/
std::unique_ptr< QgsLayoutDesignerInterface::ExportResults > lastExportResults() const;

/**
* Returns the keyboard shortcuts manager
*
*/
QgsShortcutsManager *shortcutsManager();

public slots:

/**
Expand Down Expand Up @@ -517,6 +524,10 @@ class QgsLayoutDesignerDialog: public QMainWindow, public Ui::QgsLayoutDesignerB
std::unique_ptr< QgsLayoutDesignerInterface::ExportResults> mLastExportResults;
QMap< QString, QgsLabelingResults *> mLastExportLabelingResults;

//! Shortcuts manager and dialog
QgsShortcutsManager *mShortcutsManager = nullptr;
QgsConfigureShortcutsDialog *mShortcutsDialog = nullptr;

//! Save window state
void saveWindowState();

Expand Down
12 changes: 11 additions & 1 deletion src/ui/layout/qgslayoutdesignerbase.ui
Expand Up @@ -182,7 +182,7 @@
<x>0</x>
<y>0</y>
<width>2180</width>
<height>21</height>
<height>22</height>
</rect>
</property>
<widget class="QMenu" name="mLayoutMenu">
Expand Down Expand Up @@ -387,6 +387,7 @@
<string>Settings</string>
</property>
<addaction name="mActionOptions"/>
<addaction name="mActionKeyboardShortcuts"/>
</widget>
<addaction name="mLayoutMenu"/>
<addaction name="menuEdit"/>
Expand Down Expand Up @@ -1575,6 +1576,15 @@
<enum>QAction::PreferencesRole</enum>
</property>
</action>
<action name="mActionKeyboardShortcuts">
<property name="icon">
<iconset resource="../../../images/images.qrc">
<normaloff>:/images/themes/default/mActionKeyboardShortcuts.svg</normaloff>:/images/themes/default/mActionKeyboardShortcuts.svg</iconset>
</property>
<property name="text">
<string>&amp;Keyboard Shortcuts...</string>
</property>
</action>
</widget>
<resources>
<include location="../../../images/images.qrc"/>
Expand Down

0 comments on commit f8cd418

Please sign in to comment.