Adds optional "title" attribute to SectionContent and show it in visible

areas e.g. context-menu.
Build as shared library by default.
This commit is contained in:
mfreiholz 2016-02-24 12:12:09 +01:00
parent 7e41d18a6d
commit 0e831ee55f
7 changed files with 50 additions and 20 deletions

View File

@ -1,6 +1,6 @@
TARGET = AdvancedDockingSystem TARGET = AdvancedDockingSystem
#VERSION = 0.1.0 #VERSION = 0.1.0
#CONFIG += adsBuildShared CONFIG += adsBuildShared
QT += core gui QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

View File

@ -43,19 +43,24 @@ public:
QWidget* titleWidget() const; QWidget* titleWidget() const;
QWidget* contentWidget() const; QWidget* contentWidget() const;
QString visibleTitle() const;
QString title() const;
void setTitle(const QString& title);
private: private:
const int _uid; const int _uid;
QString _uniqueName; QString _uniqueName;
ContainerWidget* _container;
QPointer<QWidget> _title; ContainerWidget* _containerWidget;
QPointer<QWidget> _content; QPointer<QWidget> _titleWidget;
QPointer<QWidget> _contentWidget;
// Optional attributes
QString _title;
static int GetNextUid(); static int GetNextUid();
static QHash<int, SectionContent::WeakPtr>& GetLookupMap(); static QHash<int, SectionContent::WeakPtr>& GetLookupMap();
static QHash<QString, SectionContent::WeakPtr>& GetLookupMapByName(); static QHash<QString, SectionContent::WeakPtr>& GetLookupMapByName();
//static QHash<int, SectionContent::WeakPtr> LookupMap;
//static QHash<QString, SectionContent::WeakPtr> LookupMapByName;
}; };
ADS_NAMESPACE_END ADS_NAMESPACE_END

View File

@ -213,7 +213,7 @@ QMenu* ContainerWidget::createContextMenu() const
const QList<SectionContent::RefPtr>& contents = sw->contents(); const QList<SectionContent::RefPtr>& contents = sw->contents();
foreach (const SectionContent::RefPtr& sc, contents) foreach (const SectionContent::RefPtr& sc, contents)
{ {
QAction* a = new QAction(QIcon(), sc->uniqueName(), NULL); QAction* a = new QAction(QIcon(), sc->visibleTitle(), NULL);
a->setObjectName(QString("ads-action-sc-%1").arg(QString::number(sc->uid()))); a->setObjectName(QString("ads-action-sc-%1").arg(QString::number(sc->uid())));
a->setProperty("uid", sc->uid()); a->setProperty("uid", sc->uid());
a->setProperty("type", "section"); a->setProperty("type", "section");
@ -235,7 +235,7 @@ QMenu* ContainerWidget::createContextMenu() const
hiddenIter.next(); hiddenIter.next();
const SectionContent::RefPtr sc = hiddenIter.value().data.content; const SectionContent::RefPtr sc = hiddenIter.value().data.content;
QAction* a = new QAction(QIcon(), sc->uniqueName(), NULL); QAction* a = new QAction(QIcon(), sc->visibleTitle(), NULL);
a->setObjectName(QString("ads-action-sc-%1").arg(QString::number(sc->uid()))); a->setObjectName(QString("ads-action-sc-%1").arg(QString::number(sc->uid())));
a->setProperty("uid", sc->uid()); a->setProperty("uid", sc->uid());
a->setProperty("type", "section"); a->setProperty("type", "section");
@ -255,7 +255,7 @@ QMenu* ContainerWidget::createContextMenu() const
const FloatingWidget* fw = _floatings.at(i); const FloatingWidget* fw = _floatings.at(i);
const SectionContent::RefPtr sc = fw->content(); const SectionContent::RefPtr sc = fw->content();
QAction* a = new QAction(QIcon(), sc->uniqueName(), NULL); QAction* a = new QAction(QIcon(), sc->visibleTitle(), NULL);
a->setObjectName(QString("ads-action-sc-%1").arg(QString::number(sc->uid()))); a->setObjectName(QString("ads-action-sc-%1").arg(QString::number(sc->uid())));
a->setProperty("uid", sc->uid()); a->setProperty("uid", sc->uid());
a->setProperty("type", "floating"); a->setProperty("type", "floating");

View File

@ -30,9 +30,9 @@ SectionContent::RefPtr SectionContent::newSectionContent(const QString& uniqueNa
QSharedPointer<SectionContent> sc(new SectionContent()); QSharedPointer<SectionContent> sc(new SectionContent());
sc->_uniqueName = uniqueName; sc->_uniqueName = uniqueName;
sc->_container = container; sc->_containerWidget = container;
sc->_title = title; sc->_titleWidget = title;
sc->_content = content; sc->_contentWidget = content;
GetLookupMap().insert(sc->uid(), sc); GetLookupMap().insert(sc->uid(), sc);
if (!sc->uniqueName().isEmpty()) if (!sc->uniqueName().isEmpty())
@ -45,8 +45,8 @@ SectionContent::~SectionContent()
{ {
GetLookupMap().remove(_uid); GetLookupMap().remove(_uid);
GetLookupMapByName().remove(_uniqueName); GetLookupMapByName().remove(_uniqueName);
delete _title; delete _titleWidget;
delete _content; delete _contentWidget;
} }
int SectionContent::uid() const int SectionContent::uid() const
@ -61,17 +61,34 @@ QString SectionContent::uniqueName() const
ContainerWidget* SectionContent::containerWidget() const ContainerWidget* SectionContent::containerWidget() const
{ {
return _container; return _containerWidget;
} }
QWidget* SectionContent::titleWidget() const QWidget* SectionContent::titleWidget() const
{ {
return _title; return _titleWidget;
} }
QWidget* SectionContent::contentWidget() const QWidget* SectionContent::contentWidget() const
{ {
return _content; return _contentWidget;
}
QString SectionContent::visibleTitle() const
{
if (_title.isEmpty())
return _uniqueName;
return _title;
}
QString SectionContent::title() const
{
return _title;
}
void SectionContent::setTitle(const QString& title)
{
_title = title;
} }
int SectionContent::GetNextUid() int SectionContent::GetNextUid()

View File

@ -9,7 +9,7 @@ int main(int argc, char *argv[])
QApplication a(argc, argv); QApplication a(argc, argv);
a.setQuitOnLastWindowClosed(true); a.setQuitOnLastWindowClosed(true);
Q_INIT_RESOURCE(ads); //Q_INIT_RESOURCE(ads);
// Load style sheet // Load style sheet
QFile f(":/stylesheets/default-windows.css"); QFile f(":/stylesheets/default-windows.css");

View File

@ -32,7 +32,9 @@ static ADS_NS::SectionContent::RefPtr createLongTextLabelSC(ADS_NS::ContainerWid
bl->addWidget(l); bl->addWidget(l);
const int index = ++CONTENT_COUNT; const int index = ++CONTENT_COUNT;
return ADS_NS::SectionContent::newSectionContent(QString("uname-%1").arg(index), container, new IconTitleWidget(QIcon(), QString("Label %1").arg(index)), w); ADS_NS::SectionContent::RefPtr sc = ADS_NS::SectionContent::newSectionContent(QString("uname-%1").arg(index), container, new IconTitleWidget(QIcon(), QString("Label %1").arg(index)), w);
sc->setTitle("Ein Label " + QString::number(index));
return sc;
} }
static ADS_NS::SectionContent::RefPtr createCalendarSC(ADS_NS::ContainerWidget* container) static ADS_NS::SectionContent::RefPtr createCalendarSC(ADS_NS::ContainerWidget* container)

View File

@ -43,6 +43,8 @@ Items sorted by priority
- [ ] `ContainerWidget::showSectionContent` needs to insert the SC at the correct preferred position of SW - [ ] `ContainerWidget::showSectionContent` needs to insert the SC at the correct preferred position of SW
- [ ] Empty splitters, if only 2 or 1 items are in container - [ ] Empty splitters, if only 2 or 1 items are in container
- [ ] Restore: Handle out-of-screen geometry for floating widgets - [ ] Restore: Handle out-of-screen geometry for floating widgets
- [ ] Find an alternative impl for current static QHash, e.g. `SectionContent::GetLookupMap`.
It does not work, if linking from DLL AND EXE
### Beta 0.1 ### Beta 0.1
- [x] Improve FloatingWidget (Remove maximize button, only support close-button which hides the widget) - [x] Improve FloatingWidget (Remove maximize button, only support close-button which hides the widget)
@ -54,6 +56,10 @@ Items sorted by priority
- [x] Clean up of unused e.g. count()<=1 QSplitters doesn't work well #BUG - [x] Clean up of unused e.g. count()<=1 QSplitters doesn't work well #BUG
- [x] Show close button on right corner of SectionWidget. How to safe last section position? - [x] Show close button on right corner of SectionWidget. How to safe last section position?
- [x] Serialize state of `_hiddenSectionContents` - [x] Serialize state of `_hiddenSectionContents`
- [x] Add "title" to SectionContent object, which will be used in visible areas to display contents name.
- [ ] It should be possible to catch the "activeTabChanged" signal for EXTERN_API users
- [x] Add API function to set an SC as active-tab
- [ ] Use scrolling for SectionWidget tabs?
### Some day... ### Some day...
- [ ] Drop indicator images should be fully visible over the DropOverlay rectangle - [ ] Drop indicator images should be fully visible over the DropOverlay rectangle