fall back to show title if there's no applet

This commit is contained in:
Hualet Wang 2015-07-14 10:40:34 +08:00
parent 146019a0aa
commit 8f9122e9b5
6 changed files with 26 additions and 10 deletions

View File

@ -13,7 +13,7 @@ AppItem::AppItem(QWidget *parent) :
initMenu();
}
QWidget *AppItem::getContents()
QWidget *AppItem::getApplet()
{
AppPreviews *preview = new AppPreviews();
connect(preview,&AppPreviews::mouseEntered,this,&AppItem::cancelHide);

View File

@ -46,7 +46,7 @@ public:
AppItem(QWidget *parent = 0);
~AppItem();
QWidget *getContents();
QWidget *getApplet();
void setEntryProxyer(DBusEntryProxyer *entryProxyer);
void destroyItem(const QString &id);
QString itemId() const;

View File

@ -15,7 +15,8 @@ public:
QFrame(parent) {}
virtual ~AbstractDockItem() {}
virtual QWidget * getContents() { return NULL; }
virtual QString getTitle() { return ""; }
virtual QWidget * getApplet() { return NULL; }
virtual bool moveable() { return m_moveable; }
virtual bool actived() { return m_isActived; }
@ -43,7 +44,15 @@ public:
m_previewAR->resizeWithContent();
return;
}
QWidget *tmpContent = getContents();
QWidget *tmpContent = getApplet();
if (tmpContent == NULL) {
QString title = getTitle();
// TODO: memory management
tmpContent = new QLabel(title);
tmpContent->setStyleSheet("QLabel { color: white }");
tmpContent->setFixedSize(100, 20);
}
m_previewAR->setArrorDirection(ArrowRectangle::ArrowBottom);
m_previewAR->setContent(tmpContent);
m_previewAR->showAtBottom(globalX() + width() / 2,globalY() - 5);

View File

@ -14,11 +14,11 @@ public:
virtual void init(DockPluginProxyInterface *proxy) = 0;
virtual QString name() = 0;
virtual QString title() = 0;
virtual QStringList uuids() = 0;
virtual QString getTitle(QString uuid) = 0;
virtual QWidget * getItem(QString uuid) = 0;
virtual QWidget * getApplets(QString uuid) = 0;
virtual QWidget * getApplet(QString uuid) = 0;
virtual void changeMode(Dock::DockMode newMode, Dock::DockMode oldMode) = 0;
};

View File

@ -12,7 +12,7 @@ PluginItemWrapper::PluginItemWrapper(DockPluginInterface *plugin,
if (m_plugin) {
QWidget * item = m_plugin->getItem(uuid);
m_pluginItemContents = m_plugin->getApplets(uuid);
m_pluginItemContents = m_plugin->getApplet(uuid);
if (item) {
setFixedSize(item->size());
@ -24,9 +24,14 @@ PluginItemWrapper::PluginItemWrapper(DockPluginInterface *plugin,
}
}
QWidget * PluginItemWrapper::getContents()
QString PluginItemWrapper::getTitle()
{
return m_plugin->getApplets(m_uuid);
return m_plugin->getTitle(m_uuid);
}
QWidget * PluginItemWrapper::getApplet()
{
return m_plugin->getApplet(m_uuid);
}
void PluginItemWrapper::enterEvent(QEvent *)

View File

@ -11,9 +11,11 @@ public:
PluginItemWrapper(DockPluginInterface *plugin, QString uuid, QWidget * parent = 0);
virtual ~PluginItemWrapper();
QWidget * getContents();
QString uuid() const;
QString getTitle();
QWidget * getApplet();
protected:
void enterEvent(QEvent * event);
void leaveEvent(QEvent * event);