Skip to content

Commit

Permalink
fixed layout, bug in file list
Browse files Browse the repository at this point in the history
  • Loading branch information
mjoppich committed Feb 23, 2017
1 parent 92087bc commit a23578c
Show file tree
Hide file tree
Showing 7 changed files with 166 additions and 18 deletions.
2 changes: 2 additions & 0 deletions src/app/AdvancedStreamBox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ void AdvancedCornerWidget::updateWidgetGeometry() {
}

m_pParentBox->setMinimumSize(oNewMin);
m_pParentBox->setMaximumSize(oNewMin);
m_pParentBox->setFixedSize(oNewMin);
//m_pParentBox->resize(oNewMin);

emit sizeChanged();
Expand Down
7 changes: 6 additions & 1 deletion src/bioGUIapp.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,14 @@ class bioGUIapp : public QApplication {
return m_pWindowParser;
}

QString getAppPath()
{
return m_oTemplatePath.path();
}

void reloadTemplates()
{
QDir oTemplatePath = m_oTemplatePath.path() + "/templates/";
QDir oTemplatePath = this->getAppPath() + "/templates/";

this->addTemplates( oTemplatePath );
}
Expand Down
3 changes: 2 additions & 1 deletion src/parsing/visual_nodes/WindowLayoutHorizontalNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,9 @@ class WindowLayoutHorizontalNode : public WindowLayoutNode {
{

QHBoxLayout *pLayout = new QOrderedHBoxLayout();
pLayout->setSizeConstraint(QLayout::SetFixedSize);

pLayout->setAlignment(Qt::AlignHorizontal_Mask);
//pLayout->setAlignment(Qt::AlignHorizontal_Mask);

CreatedElement oReturn;
oReturn.pElement = pLayout;
Expand Down
4 changes: 3 additions & 1 deletion src/parsing/visual_nodes/WindowLayoutVerticalNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ class WindowLayoutVerticalNode : public WindowLayoutNode {

QVBoxLayout *pLayout = new QOrderedVBoxLayout();

pLayout->setAlignment(Qt::AlignVertical_Mask);
//pLayout->setAlignment(Qt::AlignVertical_Mask);
pLayout->setSizeConstraint(QLayout::SetFixedSize);


CreatedElement oReturn;
oReturn.pElement = pLayout;
Expand Down
2 changes: 1 addition & 1 deletion src/parsing/visual_nodes/WindowWidgetFileListNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class WindowWidgetFileListNode : public WindowWidgetNode {

QComboBox *pComboBox = new QComboBox();

QString sCurrentPath = QDir::current().absolutePath();
QString sCurrentPath = this->m_pFactory->getApp()->getAppPath();
QString sSearchPath = this->getQAttribute(pDOMElement, "path", sCurrentPath + "/install_templates/");

bool bHasPathSet = this->hasAttribute(pDOMElement, "path");
Expand Down
137 changes: 136 additions & 1 deletion src/parsing/visual_nodes/WindowWidgetImageNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,142 @@ class WindowWidgetImageNode : public WindowWidgetNode {

}

virtual CreatedElement getWindowElement( QDomElement* pDOMElement )
QZoomableGraphicsView* createImage(QString sFileName)
{

QDir oDirectory(sFileName);
std::cerr << "Loading image " << oDirectory.absolutePath().toStdString() << std::endl;

QGraphicsScene* pScene = new QGraphicsScene();
QZoomableGraphicsView* pView = new QZoomableGraphicsView(pScene);
QGraphicsPixmapItem* pItem = new QGraphicsPixmapItem(QPixmap( sFileName ));

pScene->addItem( pItem );

return pView;
}

virtual CreatedElement getWindowElement( QDomElement* pDOMElement)
{

QString sTag = pDOMElement->tagName();
QString sValue = pDOMElement->text();

CreatedElement oReturn;
oReturn.bHasChildrenFinished = true;

QGroupBox* pGroupBox = new QGroupBox();


QString sFileName = this->getQAttribute(pDOMElement, "src", "");
QZoomableGraphicsView* pView = this->createImage(sFileName);

QString sWidth = this->getQAttribute(pDOMElement, "width" , "");
QString sHeight = this->getQAttribute(pDOMElement, "height", "");

if ((sWidth.length() > 0) && (sHeight.length() > 0))
{
int iWidth = sWidth.toInt();
int iHeight = sHeight.toInt();

pView->setFixedSize(iWidth, iHeight);
}

// this could also be a hboxlayout or a grid layout
QLayout* pLayout = new QVBoxLayout();
pLayout->addWidget( pView );

QPushButton* pClearButton = new QPushButton("Clear");

QObject::connect(pClearButton, &QAbstractButton::clicked, [pView] {

// do something here

});

pLayout->addWidget(pClearButton);

QPushButton* pSaveLogButton = new QPushButton("Full View");

QObject::connect(pSaveLogButton, &QAbstractButton::clicked, [pView] {

// do something here

});

pLayout->addWidget(pSaveLogButton);

pGroupBox->setLayout(pLayout);

oReturn.pElement = pGroupBox;

bioGUIapp* pApp = m_pFactory->getApp();
pLayout->setSizeConstraint(QLayout::SetFixedSize);

QObject::connect(pView, &QZoomableGraphicsView::sizeChanged, [pApp, pLayout] () {

pLayout->activate();
pLayout->update();

//pApp->getMainWindow()->update();
pApp->reloadAppWindow();

});

QObject::connect(pView, &QZoomableGraphicsView::sizeChanged, [pGroupBox] () {

pGroupBox->activateWindow();

pGroupBox->parentWidget()->activateWindow();
pGroupBox->parentWidget()->layout()->activate();
pGroupBox->parentWidget()->layout()->update();

});

// must be done here because otherwise the groupbox is the id widget ...
std::string sID = this->getAttribute(pDOMElement, "id", "");
if (sID.length() > 0)
{

WidgetFunctionNode* pWidgetFuncNode = new WidgetFunctionNode(pView, [pView] (const QWidget* pWidget, std::string key, std::string value) {

QString sKey(key.c_str());

if (sKey.compare("src", Qt::CaseInsensitive) == 0)
{

QFileInfo oFile(QString(value.c_str()));


if (!oFile.exists())
{
LOGLVL("Image Upd src: File does not exist: " + value, Logging::ERR)

return;
}

LOGLVL("Image Upd src: Loading Image: " + value, Logging::INFO)

QGraphicsPixmapItem* pItem = new QGraphicsPixmapItem(QPixmap( oFile.absoluteFilePath() ));
QGraphicsScene* pScene = pView->scene();

pScene->clear();
pScene->addItem( pItem );

}

return;
});
m_pFactory->getApp()->getWindowParser()->addID2WidgetFunction( sID, pWidgetFuncNode, true );

}

return oReturn;


}

virtual CreatedElement getWindowElementImg( QDomElement* pDOMElement )
{

QString sTag = pDOMElement->tagName();
Expand Down
29 changes: 16 additions & 13 deletions templates/test.gui
Original file line number Diff line number Diff line change
@@ -1,27 +1,30 @@
<template description="Test Program to Show Execution" title="Test Program">
<window title="Test Program">
<template description="poreSTAT" title="poreSTAT">
<window title="poreSTAT alpha">
<vgroup>
<checkbox id="WSLsel" value="true" selectonwindows="true">Run in WSL?</checkbox>

<group title="Files">
<filedialog id="folderin" folder="true">Input READS folder</filedialog>
<filedialog id="fileout" output="true">Output Statistics (PNG)</filedialog>
</group>

<group title="Operation">
<combobox id="operation">
<comboitem value="--reads">MinKNOWN reads folder</comboitem>
<comboitem value="--reads">MinKNOW reads folder</comboitem>
<comboitem value="--folders">index</comboitem>
</combobox>
</group>

<group title="Files">
<filedialog id="folderin" folder="true" location="/home/proj/projekte/sequencing/HPYLORI_MINION_ILLUMINA_JIMENEZ/reads/fail">Input READS folder</filedialog>
<filedialog id="fileout" output="true" location="/home/proj/projekte/sequencing/HPYLORI_MINION_ILLUMINA_JIMENEZ/tmp.png">Output Statistics (PNG)</filedialog>
</group>

<action program="test">Run</action>
<image id="statimg" src="/home/proj/projekte/sequencing/HPYLORI_MINION_ILLUMINA_JIMENEZ/tmp.png" width="100" height="100"/>

<streambox id="output1">
<stream id="outputstream1">std out</stream>
<stream id="outputstream2">err out</stream>
</streambox>
<hgroup>
<image id="statimg" src="/home/proj/projekte/sequencing/HPYLORI_MINION_ILLUMINA_JIMENEZ/tmp.png" width="100" height="100"/>

<streambox id="output1">
<stream id="outputstream1">std out</stream>
<stream id="outputstream2">err out</stream>
</streambox>
</hgroup>

</vgroup>
</window>
Expand Down

0 comments on commit a23578c

Please sign in to comment.