diff --git a/src/guiutils.h b/src/guiutils.h index 0facb15..72ecb5e 100644 --- a/src/guiutils.h +++ b/src/guiutils.h @@ -1,214 +1,214 @@ /* * KDiff3 - Text Diff And Merge Tool * * SPDX-FileCopyrightText: 2008 Valentin Rusu kde at rusu.info * SPDX-FileCopyrightText: 2018-2020 Michael Reeves reeves.87@gmail.com * SPDX-License-Identifier: GPL-2.0-or-later */ #ifndef GUIUTILS_H #define GUIUTILS_H #include #include namespace GuiUtils { - //Use std::enable_if since complires don't disabiguate overloads based on return type alone + //Use std::enable_if since compilers don't disabiguate overloads based on return type alone template inline typename std::enable_if::value, QAction>::type* createAction( const QString& text, const Receiver receiver, const Func slot, KActionCollection* ac, const QString& actionName) { Q_ASSERT(ac != nullptr); QAction* theAction; theAction = ac->addAction(actionName); theAction->setText(text); QObject::connect(theAction, &QAction::triggered, receiver, slot); return theAction; } template inline typename std::enable_if::value, KToggleAction>::type* createAction( const QString& text, const Receiver receiver, const Func slot, KActionCollection* ac, const QString &actionName) { Q_ASSERT( ac != nullptr ); KToggleAction* theAction = new KToggleAction(ac); ac->addAction( actionName, theAction ); theAction->setText( text ); QObject::connect( theAction, &KToggleAction::triggered, receiver, slot ); return theAction; } template T* createAction( const QString& text, const QKeySequence& shortcut, Receiver receiver, Func slot, KActionCollection* ac, const QString &actionName) { T* theAction = createAction( text, receiver, slot, ac, actionName ); ac->setDefaultShortcut(theAction, shortcut); return theAction; } template T* createAction( const QString& text, const QIcon& icon, Receiver receiver, Func slot, KActionCollection* ac, const QString &actionName) { T* theAction = createAction( text, receiver, slot, ac, actionName ); theAction->setIcon( icon ); return theAction; } template T* createAction( const QString& text, const QIcon& icon, const QString& iconText, Receiver receiver, Func slot, KActionCollection* ac, const QString &actionName) { T* theAction = createAction( text, receiver, slot, ac, actionName ); theAction->setIcon( icon ); theAction->setIconText( iconText ); return theAction; } template T* createAction( const QString& text, const QIcon& icon, const QKeySequence& shortcut, Receiver receiver, Func slot, KActionCollection* ac, const QString &actionName) { T* theAction = createAction( text, shortcut, receiver, slot, ac, actionName ); theAction->setIcon( icon ); return theAction; } template T* createAction( const QString& text, const QIcon& icon, const QString& iconText, const QKeySequence& shortcut, Receiver receiver, Func slot, KActionCollection* ac, const QString &actionName) { T* theAction = createAction( text, shortcut, receiver, slot, ac, actionName ); theAction->setIcon( icon ); theAction->setIconText( iconText ); return theAction; } //Allow actions to be created without connecting them immediately. template inline typename std::enable_if::value, QAction>::type* createAction( const QString& text, KActionCollection* ac, const QString& actionName) { Q_ASSERT(ac != nullptr); QAction* theAction; theAction = ac->addAction(actionName); theAction->setText(text); return theAction; } template inline typename std::enable_if::value, KToggleAction>::type* createAction( const QString& text, KActionCollection* ac, const QString &actionName) { Q_ASSERT( ac != nullptr ); KToggleAction* theAction = new KToggleAction(ac); ac->addAction( actionName, theAction ); theAction->setText( text ); return theAction; } template T* createAction( const QString& text, const QKeySequence& shortcut, KActionCollection* ac, const QString &actionName) { T* theAction = createAction( text, ac, actionName ); ac->setDefaultShortcut(theAction, shortcut); return theAction; } template T* createAction( const QString& text, const QIcon& icon, KActionCollection* ac, const QString &actionName) { T* theAction = createAction( text, ac, actionName ); theAction->setIcon( icon ); return theAction; } template T* createAction( const QString& text, const QIcon& icon, const QString& iconText, KActionCollection* ac, const QString &actionName) { T* theAction = createAction( text, ac, actionName ); theAction->setIcon( icon ); theAction->setIconText( iconText ); return theAction; } template T* createAction( const QString& text, const QIcon& icon, const QKeySequence& shortcut, KActionCollection* ac, const QString &actionName) { T* theAction = createAction( text, shortcut, ac, actionName ); theAction->setIcon( icon ); return theAction; } template T* createAction( const QString& text, const QIcon& icon, const QString& iconText, const QKeySequence& shortcut, KActionCollection* ac, const QString &actionName) { T* theAction = createAction( text, shortcut, ac, actionName ); theAction->setIcon( icon ); theAction->setIconText( iconText ); return theAction; } } #endif