Add shortcut manager in print layouts

This commit is contained in:
Yoann Quenach de Quivillic 2023-01-15 20:48:00 +01:00 committed by Nyall Dawson
parent 98b93c04a5
commit f8cd418e5f
3 changed files with 37 additions and 1 deletions

View File

@ -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>
@ -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
@ -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;

View File

@ -49,6 +49,7 @@ class QgsFeature;
class QgsMasterLayoutInterface;
class QgsLayoutGuideWidget;
class QgsScreenHelper;
class QgsConfigureShortcutsDialog;
class QgsAppLayoutDesignerInterface : public QgsLayoutDesignerInterface
{
@ -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:
/**
@ -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();

View File

@ -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">
@ -387,6 +387,7 @@
<string>Settings</string>
</property>
<addaction name="mActionOptions"/>
<addaction name="mActionKeyboardShortcuts"/>
</widget>
<addaction name="mLayoutMenu"/>
<addaction name="menuEdit"/>
@ -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"/>