mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-21 04:45:31 +08:00
follow up of refs #643, allow to display icon in overlay window
* some optimization to check if icon is available * menus for context menu * allow to display icon/image in overlay window
This commit is contained in:
@@ -10,9 +10,12 @@
|
||||
#ifndef BLACKGUI_MENUS_MENUDELEGATE_H
|
||||
#define BLACKGUI_MENUS_MENUDELEGATE_H
|
||||
|
||||
#include "blackmisc/logcategorylist.h"
|
||||
#include <QMenu>
|
||||
#include <QObject>
|
||||
|
||||
using namespace BlackMisc;
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Menus
|
||||
@@ -37,6 +40,13 @@ namespace BlackGui
|
||||
//! Destructor
|
||||
virtual ~IMenuDelegate() {}
|
||||
|
||||
//! Log categories
|
||||
const CLogCategoryList &getLogCategories()
|
||||
{
|
||||
static const CLogCategoryList cats({CLogCategory::guiComponent()});
|
||||
return cats;
|
||||
}
|
||||
|
||||
protected:
|
||||
//! Constructor
|
||||
IMenuDelegate(QWidget *parent = nullptr, bool separator = false) :
|
||||
@@ -50,12 +60,20 @@ namespace BlackGui
|
||||
}
|
||||
|
||||
//! Add separator
|
||||
void addSeparator(QMenu &menu) const
|
||||
virtual void addSeparator(QMenu &menu) const
|
||||
{
|
||||
if (!m_separator || menu.isEmpty()) { return; }
|
||||
menu.addSeparator();
|
||||
}
|
||||
|
||||
//! Does the previous (menu) item contain string?
|
||||
bool previousMenuItemContains(const QString &str, const QMenu &menu, Qt::CaseSensitivity cs = Qt::CaseSensitive) const
|
||||
{
|
||||
if (menu.isEmpty() || str.isEmpty()) { return false; }
|
||||
const QString t(menu.actions().last()->text());
|
||||
return t.contains(str, cs);
|
||||
}
|
||||
|
||||
IMenuDelegate *m_nestedDelegate = nullptr; //!< nested delegate if any
|
||||
bool m_separator = false; //!< at end, terminate with separator
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user