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:
Klaus Basan
2016-04-15 20:26:32 +02:00
parent ddc7347927
commit b78308b059
16 changed files with 261 additions and 90 deletions

View File

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