Esempio n. 1
0
void GxsChannelPostItem::loadPost(const RsGxsChannelPost &post)
{
	/* fill in */
#ifdef DEBUG_ITEM
	std::cerr << "GxsChannelPostItem::loadPost()";
	std::cerr << std::endl;
#endif

	m_inUpdateItemStatic = true;

	mPost = post;

	QString title;

	if (!mIsHome)
	{
		title = tr("Channel Feed") + ": ";
		RetroShareLink link;
		link.createChannel(post.mMeta.mGroupId, "");
		title += link.toHtml();
		titleLabel->setText(title);
		RetroShareLink msgLink;
		msgLink.createChannel(post.mMeta.mGroupId, post.mMeta.mMsgId);
		subjectLabel->setText(msgLink.toHtml());

		if (IS_GROUP_SUBSCRIBED(mSubscribeFlags) || IS_GROUP_ADMIN(mSubscribeFlags))
		{
			unsubscribeButton->setEnabled(true);
		}
		else 
		{
			unsubscribeButton->setEnabled(false);
		}
		readButton->hide();
		//newLabel->hide();
		copyLinkButton->hide();
	}
	else
	{
		/* subject */
		titleLabel->setText(QString::fromUtf8(post.mMeta.mMsgName.c_str()));
		subjectLabel->setText(RsHtml().formatText(NULL, QString::fromUtf8(post.mMsg.c_str()), RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS));

		/* disable buttons: deletion facility not enabled with cache services yet */
		clearButton->setEnabled(false);
		unsubscribeButton->setEnabled(false);
		clearButton->hide();
		readAndClearButton->hide();
		unsubscribeButton->hide();
		copyLinkButton->show();

		if (IS_GROUP_SUBSCRIBED(mGroupMeta.mSubscribeFlags) || IS_GROUP_ADMIN(mGroupMeta.mSubscribeFlags))
		{

			readButton->setVisible(true);
#if 0
			uint32_t status = 0;
			rsChannels->getMessageStatus(mChanId, mMsgId, status);
#endif

			if (IS_MSG_UNREAD(post.mMeta.mMsgStatus) || IS_MSG_NEW(post.mMeta.mMsgStatus))
			{
				readButton->setChecked(true);
				readButton->setIcon(QIcon(":/images/message-state-unread.png"));
			} 
			else 
			{
				readButton->setChecked(false);
				readButton->setIcon(QIcon(":/images/message-state-read.png"));
			}

			bool newState;
			QColor color;
			if (!IS_MSG_UNREAD(post.mMeta.mMsgStatus))
			{
				//newLabel->setVisible(false);
				newState = false;
				color = COLOR_NORMAL;
			} 
			else 
			{
				//newLabel->setVisible(true);
				newState = true;
				color = COLOR_NEW;
			}

			/* unpolish widget to clear the stylesheet's palette cache */
			frame->style()->unpolish(frame);

			QPalette palette = frame->palette();
			palette.setColor(frame->backgroundRole(), color);
			frame->setPalette(palette);

			frame->setProperty("new", newState);
			Rshare::refreshStyleSheet(frame, false);
		} 
		else 
		{
			readButton->setVisible(false);
			//newLabel->setVisible(false);
		}
	}

	msgLabel->setText(RsHtml().formatText(NULL, QString::fromUtf8(post.mMsg.c_str()), RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS));
	msgFrame->setVisible(!post.mMsg.empty());

	datetimelabel->setText(DateTime::formatLongDateTime(post.mMeta.mPublishTs));

	filelabel->setText(QString("(%1 %2) %3").arg(post.mCount).arg(tr("Files")).arg(misc::friendlyUnit(post.mSize)));

	if (mFileItems.empty() == false) {
		std::list<SubFileItem *>::iterator it;
		for(it = mFileItems.begin(); it != mFileItems.end(); it++)
		{
			delete(*it);
		}
		mFileItems.clear();
	}

	std::list<RsGxsFile>::const_iterator it;
	for(it = post.mFiles.begin(); it != post.mFiles.end(); it++)
	{
		/* add file */
		std::string path;
		SubFileItem *fi = new SubFileItem(it->mHash, it->mName, path, it->mSize,
				SFI_STATE_REMOTE | SFI_TYPE_CHANNEL, "");
		mFileItems.push_back(fi);
		
		/* check if the file is a media file */
		if (!misc::isPreviewable(QFileInfo(QString::fromUtf8(it->mName.c_str())).suffix())) 
		  fi->mediatype();


		QLayout *layout = expandFrame->layout();
		layout->addWidget(fi);
	}

	if(post.mThumbnail.mData != NULL)
	{
		QPixmap thumbnail;
		thumbnail.loadFromData(post.mThumbnail.mData, post.mThumbnail.mSize, "PNG");
		// Wiping data - as its been passed to thumbnail.
		logoLabel->setPixmap(thumbnail);
	}

	m_inUpdateItemStatic = false;
}
void QmitkToolSelectionBox::SetOrUnsetButtonForActiveTool()
{
  // we want to emit a signal in any case, whether we selected ourselves or somebody else changes "our" tool manager.
  // --> emit before check on m_SelfCall
  int id = m_ToolManager->GetActiveToolID();

  // don't emit signal for shape model tools
  bool emitSignal = true;
  mitk::Tool *tool = m_ToolManager->GetActiveTool();
  if (tool && std::string(tool->GetGroup()) == "organ_segmentation")
    emitSignal = false;

  if (emitSignal)
    emit ToolSelected(id);

  // delete old GUI (if any)
  if (m_LastToolGUI && m_ToolGUIWidget)
  {
    if (m_ToolGUIWidget->layout())
    {
      m_ToolGUIWidget->layout()->removeWidget(m_LastToolGUI);
    }

    // m_LastToolGUI->reparent(nullptr, QPoint(0,0));
    // TODO: reparent <-> setParent, Daniel fragen
    m_LastToolGUI->setParent(0);
    delete m_LastToolGUI; // will hopefully notify parent and layouts
    m_LastToolGUI = nullptr;

    QLayout *layout = m_ToolGUIWidget->layout();
    if (layout)
    {
      layout->activate();
    }
  }

  QToolButton *toolButton(nullptr);
  // mitk::Tool* tool = m_ToolManager->GetActiveTool();

  if (m_ButtonIDForToolID.find(id) != m_ButtonIDForToolID.end()) // if this tool is in our box
  {
    // toolButton = dynamic_cast<QToolButton*>( Q3ButtonGroup::find( m_ButtonIDForToolID[id] ) );
    toolButton = dynamic_cast<QToolButton *>(m_ToolButtonGroup->buttons().at(m_ButtonIDForToolID[id]));
  }

  if (toolButton)
  {
    // mmueller
    // uncheck all other buttons
    QAbstractButton *tmpBtn = 0;
    QList<QAbstractButton *>::iterator it;
    for (int i = 0; i < m_ToolButtonGroup->buttons().size(); ++i)
    {
      tmpBtn = m_ToolButtonGroup->buttons().at(i);
      if (tmpBtn != toolButton)
        dynamic_cast<QToolButton *>(tmpBtn)->setChecked(false);
    }

    toolButton->setChecked(true);

    if (m_ToolGUIWidget && tool)
    {
      // create and reparent new GUI (if any)
      itk::Object::Pointer possibleGUI = tool->GetGUI("Qmitk", "GUI").GetPointer(); // prefix and postfix
      QmitkToolGUI *gui = dynamic_cast<QmitkToolGUI *>(possibleGUI.GetPointer());

      //!
      m_LastToolGUI = gui;
      if (gui)
      {
        gui->SetTool(tool);

        // mmueller
        // gui->reparent(m_ToolGUIWidget, gui->geometry().topLeft(), true );
        gui->setParent(m_ToolGUIWidget);
        gui->move(gui->geometry().topLeft());
        gui->show();

        QLayout *layout = m_ToolGUIWidget->layout();
        if (!layout)
        {
          layout = new QVBoxLayout(m_ToolGUIWidget);
        }
        if (layout)
        {
          // mmueller
          layout->addWidget(gui);
          // layout->add( gui );
          layout->activate();
        }
      }
    }
  }
  else
  {
    // disable all buttons
    QToolButton *selectedToolButton = dynamic_cast<QToolButton *>(m_ToolButtonGroup->checkedButton());
    // QToolButton* selectedToolButton = dynamic_cast<QToolButton*>( Q3ButtonGroup::find( Q3ButtonGroup::selectedId() )
    // );
    if (selectedToolButton)
    {
      // mmueller
      selectedToolButton->setChecked(false);
      // selectedToolButton->setOn(false);
    }
  }
}
Esempio n. 3
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui_(CONNECT_TO_SERVER)
{
    //ui->setupUi(this);
    //connect UI build
    connectUI_ = new QWidget(this);
    QLayout * connectLayout = new QHBoxLayout(connectUI_);
    connectUI_->setLayout(connectLayout);

    connectLayout->addWidget(new QLabel("Server",connectUI_));

    QLineEdit *edit_ip = new QLineEdit(connectUI_);
    edit_ip->setObjectName(QStringLiteral("edit_ip"));

    edit_ip->setText( "218.56.11.182");
    QSizePolicy spIP(QSizePolicy::Preferred, QSizePolicy::Fixed);
    spIP.setHorizontalStretch(3);
    edit_ip->setSizePolicy(spIP);
    connectLayout->addWidget(edit_ip);

    connectLayout->addWidget(new QLabel(":",connectUI_));

    QLineEdit *edit_port = new QLineEdit(connectUI_);
    edit_port->setObjectName(QStringLiteral("edit_port"));
    edit_port->setText( "8888");
    QSizePolicy spPort(QSizePolicy::Preferred, QSizePolicy::Fixed);
    spPort.setHorizontalStretch(1);
    edit_port->setSizePolicy(spPort);
    connectLayout->addWidget(edit_port);

    QPushButton *btn_Connect = new QPushButton(connectUI_);
    btn_Connect->setObjectName(QStringLiteral("btn_Connect"));
    btn_Connect->setText(QApplication::translate("MainWindow", "Connect", 0));
    QObject::connect(btn_Connect,&QPushButton::clicked,this,&MainWindow::OnConnectServer);
    connectLayout->addWidget(btn_Connect);

    //peer list ui
    peerListUI_ = new QTreeWidget(this);
    peerListUI_->header()->setVisible(false);
    QObject::connect(peerListUI_,&QTreeWidget::itemDoubleClicked,this,&MainWindow::OnItemDoubleClicked);
    //peerListUI_->hide();

    //stream ui
    //streamUI_ = new StreamingUIWidget(this);
    //streamUI_->setMinimumSize(640,480);
    //streamUI_->hide();

    QWidget *newCenter = new QWidget(this);
    QVBoxLayout * centerLayout = new QVBoxLayout(newCenter);
    centerLayout->addWidget(connectUI_);
    centerLayout->addWidget(peerListUI_);
    //centerLayout->addWidget(streamUI_);

    this->setCentralWidget(newCenter);

    QObject::connect(this,&MainWindow::signalUIThreadCallback,
                     this,&MainWindow::OnUIThreadCallback,
                     Qt::QueuedConnection);



}
Esempio n. 4
0
GTrans::GTrans() {

    //lzt QTextcode modify for Utf8
    QTextCodec::setCodecForTr(QTextCodec::codecForLocale());
    QTextCodec::setCodecForCStrings( QTextCodec::codecForLocale());

    //Layout
//    QLayout *mainLayout = new QVBoxLayout;
    QLayout *mainLayout = new QStackedLayout;

    // The input section
//    QLayout *top = new QHBoxLayout;
//    QBoxLayout *tl = new QVBoxLayout;
//    QLabel *inLabel = new QLabel(tr("Input:"));
//    mainLayout->addWidget(inLabel);                  //lzt add
//   fromLang = new QComboBox;
//    tl->addWidget(inLabel);
//    tl->addSpacing(10);
//    tl->addWidget(fromLang);
//    tl->addStretch();
//    top->addItem(tl);
//    inputTxt = new QTextEdit;

//    top->addWidget(inputTxt);
//    mainLayout->addWidget(inputTxt);                //lzt add

    // The output section
//    QLayout *bottom = new QHBoxLayout;
//    QBoxLayout *bl = new QVBoxLayout;
//    QLabel *outLabel = new QLabel(tr("Output:"));
//    toLang = new QComboBox;
//    bl->addWidget(outLabel);
//    bl->addSpacing(10);
//    bl->addWidget(toLang);
//    bl->addStretch();
//    bottom->addItem(bl);
//    mainLayout->addWidget(outLabel);                //lzt add
      outputTxt = new QTextEdit;
//    outputTxt->setReadOnly(true);
//    bottom->addWidget(outputTxt);
      mainLayout->addWidget(outputTxt);               //lzt add

//    mainLayout->addItem(top);
//    mainLayout->addItem(bottom);

    // Translate button
//    trans_b = new QPushButton(tr("Translate"));
//    mainLayout->addWidget(trans_b);

    setLayout(mainLayout);
    setWindowTitle(tr("Translate"));


//    trans_b->setDefault(true);
//    connect(trans_b, SIGNAL(clicked()), this, SLOT(doTrans()));

//lzt clip
    QClipboard *clipboard = QApplication::clipboard();
    connect(clipboard, SIGNAL(selectionChanged()), this, SLOT(doTrans()));
//

    // Setup foxus and tab order.
//    inputTxt->setTabChangesFocus(true);
//    inputTxt->setFocus(Qt::ActiveWindowFocusReason);
//    outputTxt->setFocusProxy(trans_b);
}
Esempio n. 5
0
void MsgItem::updateItemStatic()
{
	/* fill in */
#ifdef DEBUG_ITEM
	std::cerr << "MsgItem::updateItemStatic()";
	std::cerr << std::endl;
#endif

	MessageInfo mi;

	if (!rsMsgs) 
		return;

	if (!rsMsgs->getMessage(mMsgId, mi))
		return;

	/* get peer Id */
	mPeerId = mi.srcId;

	avatar->setId(mPeerId, false);

	QString title;
	QString timestamp;
	QString srcName = QString::fromUtf8(rsPeers->getPeerName(mi.srcId).c_str());

	{
		QDateTime qtime;
		qtime.setTime_t(mi.ts);
		timestamp = qtime.toString("yyyy-MM-dd hh:mm:ss");
	}

	if (!mIsHome)
	{
		title = tr("Message From") + ": ";
	}
	else
	{
		/* subject */
		uint32_t box = mi.msgflags & RS_MSG_BOXMASK;
		switch(box)
		{
			case RS_MSG_SENTBOX:
				title = tr("Sent Msg") + ": ";
				replyButton->setEnabled(false);
				break;
			case RS_MSG_DRAFTBOX:
				title = tr("Draft Msg") + ": ";
				replyButton->setEnabled(false);
				break;
			case RS_MSG_OUTBOX:
				title = tr("Pending Msg") + ": ";
				//deleteButton->setEnabled(false);
				replyButton->setEnabled(false);
				break;
			default:
			case RS_MSG_INBOX:
				title = "";
				break;
		}
	}
	title += srcName + " @ " + timestamp;

	titleLabel->setText(title);
	subjectLabel->setText(QString::fromStdWString(mi.title));
		
	msgLabel->setText(RsHtml::formatText(QString::fromStdWString(mi.msg), RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS));

	std::list<FileInfo>::iterator it;
	for(it = mi.files.begin(); it != mi.files.end(); it++)
	{
		/* add file */
		SubFileItem *fi = new SubFileItem(it->hash, it->fname, it->path, it->size, SFI_STATE_REMOTE, mi.srcId);
		mFileItems.push_back(fi);

		QLayout *layout = expandFrame->layout();
		layout->addWidget(fi);
	}

	playButton->setEnabled(false);
	
	if (mIsHome)
	{
		/* disable buttons */
		clearButton->setEnabled(false);
		//gotoButton->setEnabled(false);

		/* hide buttons */
		clearButton->hide();
	}
	else
	{
		//deleteButton->setEnabled(false);
	}
}
Esempio n. 6
0
int main(int argc, char *argv[])
{
    QApplication app(argc, argv);
    auto *proxyStyle = new TabBarProxyStyle;
    app.setStyle(proxyStyle);

    QWidget widget;
    QStackedWidget stackedWidget;
    QTabBar tabBar;
    tabBar.setDocumentMode(true);
    tabBar.setTabsClosable(true);
    tabBar.setMovable(true);
    tabBar.setExpanding(false);

    // top
    tabBar.setShape(QTabBar::RoundedNorth);
    // bottom
//    tabBar.setShape(QTabBar::RoundedSouth);
    // left
//    tabBar.setShape(QTabBar::RoundedWest);
    // right
//    tabBar.setShape(QTabBar::RoundedEast);

    const auto shortLabel = QStringLiteral("Tab %1");
    const auto longLabel = QStringLiteral("An Extremely Long Tab Label %1");

    QMap<int, QWidget*> tabs;
    for (int i = 0; i < TabCount; i++) {
        QString tabNumberString = QString::number(i);
        QLabel *label = new QLabel(QStringLiteral("Tab %1 content").arg(tabNumberString));
        tabs[i] = label;
        label->setAlignment(Qt::AlignCenter);
        stackedWidget.addWidget(label);
        tabBar.addTab(shortLabel.arg(tabNumberString));
    }

    QObject::connect(&tabBar, &QTabBar::tabMoved, [&tabs](int from, int to) {
        QWidget *thisWidget = tabs[from];
        QWidget *thatWidget = tabs[to];
        tabs[from] = thatWidget;
        tabs[to] = thisWidget;
    });

    QObject::connect(&tabBar, &QTabBar::currentChanged, [&stackedWidget, &tabs](int index) {
        if (index >= 0)
            stackedWidget.setCurrentWidget(tabs[index]);
    });

    QObject::connect(&tabBar, &QTabBar::tabCloseRequested, [&stackedWidget, &tabBar, &tabs](int index) {
        QWidget *widget = tabs[index];
        tabBar.removeTab(index);
        for (int i = index + 1; i < TabCount; i++)
            tabs[i-1] = tabs[i];
        int currentIndex = tabBar.currentIndex();
        if (currentIndex >= 0)
            stackedWidget.setCurrentWidget(tabs[currentIndex]);
        delete widget;
    });

    QLayout *layout;
    switch (tabBar.shape()) {
    case QTabBar::RoundedEast:
    case QTabBar::TriangularEast:
        tabBar.setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Expanding);
        layout = new QHBoxLayout(&widget);
        layout->addWidget(&stackedWidget);
        layout->addWidget(&tabBar);
        break;
    case QTabBar::RoundedWest:
    case QTabBar::TriangularWest:
        tabBar.setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Expanding);
        layout = new QHBoxLayout(&widget);
        layout->addWidget(&tabBar);
        layout->addWidget(&stackedWidget);
        break;
    case QTabBar::RoundedNorth:
    case QTabBar::TriangularNorth:
        tabBar.setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum);
        layout = new QVBoxLayout(&widget);
        layout->addWidget(&tabBar);
        layout->addWidget(&stackedWidget);
        break;
    case QTabBar::RoundedSouth:
    case QTabBar::TriangularSouth:
        tabBar.setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum);
        layout = new QVBoxLayout(&widget);
        layout->addWidget(&stackedWidget);
        layout->addWidget(&tabBar);
        break;
    }

    TabBarForm form;
    layout->addWidget(&form);
    layout->setAlignment(&form, Qt::AlignHCenter);

    form.ui->documentModeButton->setChecked(tabBar.documentMode());
    QObject::connect(form.ui->documentModeButton, &QCheckBox::toggled, [&] {
        tabBar.setDocumentMode(form.ui->documentModeButton->isChecked());
        // QMacStyle (and maybe other styles) requires a re-polish to get the right font
        QApplication::sendEvent(&tabBar, new QEvent(QEvent::ThemeChange));
    });

    form.ui->movableTabsButton->setChecked(tabBar.isMovable());
    QObject::connect(form.ui->movableTabsButton, &QCheckBox::toggled, [&] {
        tabBar.setMovable(form.ui->movableTabsButton->isChecked());
        tabBar.update();
    });

    form.ui->closableTabsButton->setChecked(tabBar.tabsClosable());
    QObject::connect(form.ui->closableTabsButton, &QCheckBox::toggled, [&] {
        tabBar.setTabsClosable(form.ui->closableTabsButton->isChecked());
        tabBar.update();
    });

    form.ui->expandingTabsButton->setChecked(tabBar.expanding());
    QObject::connect(form.ui->expandingTabsButton, &QCheckBox::toggled, [&] {
        tabBar.setExpanding(form.ui->expandingTabsButton->isChecked());
        tabBar.update();
    });

    form.ui->displayIconButton->setChecked(!tabBar.tabIcon(0).isNull());
    QObject::connect(form.ui->displayIconButton, &QCheckBox::toggled, [&] {
        const auto icon = form.ui->displayIconButton->isChecked() ?
                          tabBar.style()->standardIcon(QStyle::SP_ComputerIcon) : QIcon();
        for (int i = 0; i < tabBar.count(); i++)
            tabBar.setTabIcon(i, icon);
    });

    form.ui->longLabelButton->setChecked(false);
    QObject::connect(form.ui->longLabelButton, &QCheckBox::toggled, [&] {
        const auto &label = form.ui->longLabelButton->isChecked() ? longLabel : shortLabel;
        for (int i = 0; i < tabBar.count(); i++)
            tabBar.setTabText(i, label.arg(i));
    });

    QObject::connect(form.ui->shapeComboBox, QOverload<int>::of(&QComboBox::currentIndexChanged), [&](int index) {
        Q_UNUSED(index);
        // TODO
    });

    if (proxyStyle->alignment == Qt::AlignLeft)
        form.ui->leftAlignedButton->setChecked(true);
    else if (proxyStyle->alignment == Qt::AlignRight)
        form.ui->rightAlignedButton->setChecked(true);
    else
        form.ui->centeredButton->setChecked(true);
    QObject::connect(form.ui->textAlignmentGroup, QOverload<QAbstractButton *>::of(&QButtonGroup::buttonClicked), [&](QAbstractButton *b) {
        proxyStyle->alignment = b == form.ui->leftAlignedButton ? Qt::AlignLeft :
                                b == form.ui->rightAlignedButton ? Qt::AlignRight : Qt::AlignCenter;
        QApplication::sendEvent(&tabBar, new QEvent(QEvent::StyleChange));
    });

    layout->setMargin(12);
    widget.show();

    return app.exec();
}
Esempio n. 7
0
void TemplateOptionsPage::load(const SourceFileTemplate& fileTemplate, TemplateRenderer* renderer)
{
    d->entries.clear();

    QLayout* layout = new QVBoxLayout();
    QHash<QString, QList<SourceFileTemplate::ConfigOption> > options = fileTemplate.customOptions(renderer);
    QHash<QString, QList<SourceFileTemplate::ConfigOption> >::const_iterator it;

    for (it = options.constBegin(); it != options.constEnd(); ++it)
    {
        QGroupBox* box = new QGroupBox(this);
        box->setTitle(it.key());

        QFormLayout* formLayout = new QFormLayout;

        d->entries << it.value();
        foreach (const SourceFileTemplate::ConfigOption& entry, it.value())
        {
            QLabel* label = new QLabel(entry.label, box);
            QWidget* control = nullptr;
            const QString type = entry.type;
            if (type == QLatin1String("String"))
            {
                control = new QLineEdit(entry.value.toString(), box);
            }
            else if (type == QLatin1String("Int"))
            {
                auto input = new QSpinBox(box);
                input->setValue(entry.value.toInt());
                if (!entry.minValue.isEmpty())
                {
                    input->setMinimum(entry.minValue.toInt());
                }
                if (!entry.maxValue.isEmpty())
                {
                    input->setMaximum(entry.maxValue.toInt());
                }
                control = input;
            }
            else if (type == QLatin1String("Bool"))
            {
                bool checked = (QString::compare(entry.value.toString(), QStringLiteral("true"), Qt::CaseInsensitive) == 0);
                QCheckBox* checkBox = new QCheckBox(entry.label, box);
                checkBox->setCheckState(checked ? Qt::Checked : Qt::Unchecked);
            }
            else
            {
                qCDebug(PLUGIN_FILETEMPLATES) << "Unrecognized option type" << entry.type;
            }
            if (control)
            {
                formLayout->addRow(label, control);
                d->controls.insert(entry.name, control);
            }
        }

        box->setLayout(formLayout);
        layout->addWidget(box);
    }
    setLayout(layout);
}
FlatButtonExamples::FlatButtonExamples(QWidget *parent)
    : ExampleList(parent)
{
    QLayout *layout = widget()->layout();

    {
        FlatButton *flatButton = new FlatButton;
        flatButton->setText("Press me!");
        flatButton->setMinimumSize(200, 42);

        flatButton->setRole(Material::Primary);
//        flatButton->setDisabled(true);

        ExampleView *view = new ExampleView;
        view->setWidget(flatButton);
        view->setBackgroundRole(QPalette::Base);

        Frame *frame = new Frame;
        frame->setCodeSnippet(
            "FlatButton *flatButton = new FlatButton;\n"
            "flatButton->setText(\"Press me!\");"
        );
        frame->setWidget(view);

        layout->addWidget(frame);
    }
    {
        FlatButton *flatButton = new FlatButton;
        flatButton->setText("Press me!");
        flatButton->setMinimumSize(200, 42);

        flatButton->setRole(Material::Secondary);
//        flatButton->setDisabled(true);

        ExampleView *view = new ExampleView;
        view->setWidget(flatButton);
        view->setBackgroundRole(QPalette::Base);

        Frame *frame = new Frame;
        frame->setCodeSnippet(
            "FlatButton *flatButton = new FlatButton;\n"
            "flatButton->setText(\"Press me!\");"
        );
        frame->setWidget(view);

        layout->addWidget(frame);
    }
    {
        FlatButton *flatButton = new FlatButton;
        flatButton->setText("Press me!");
        flatButton->setMinimumSize(200, 42);

        flatButton->setRole(Material::Secondary);
        flatButton->setBackgroundColor(QColor(0, 0, 0, 80));
        //flatButton->setTextColor(Style::instance().themeColor("primary1"));
//        flatButton->setDisabled(true);

        ExampleView *view = new ExampleView;
        view->setWidget(flatButton);
        view->setBackgroundRole(QPalette::Base);

        Frame *frame = new Frame;
        frame->setCodeSnippet(
            "FlatButton *flatButton = new FlatButton;\n"
            "flatButton->setText(\"Press me!\");"
        );
        frame->setWidget(view);

        layout->addWidget(frame);
    }
    {
        FlatButton *flatButton = new FlatButton;
        flatButton->setText("Press me!");
        flatButton->setMinimumSize(200, 42);

        flatButton->setRole(Material::Primary);
        flatButton->setBackgroundMode(Qt::OpaqueMode);
        //flatButton->setPrimaryTextColor(Qt::white);
        flatButton->setPeakOpacity(0.25);

        ExampleView *view = new ExampleView;
        view->setWidget(flatButton);
        view->setBackgroundRole(QPalette::Base);

        Frame *frame = new Frame;
        frame->setCodeSnippet(
            "FlatButton *flatButton = new FlatButton;\n"
            "flatButton->setText(\"Press me!\");"
        );
        frame->setWidget(view);

        layout->addWidget(frame);
    }
    {
        FlatButton *flatButton = new FlatButton;
        flatButton->setText("Press me!");
        flatButton->setMinimumSize(200, 42);

        flatButton->setRole(Material::Secondary);
        flatButton->setBackgroundMode(Qt::OpaqueMode);
        flatButton->setPeakOpacity(0.25);

        ExampleView *view = new ExampleView;
        view->setWidget(flatButton);
        view->setBackgroundRole(QPalette::Base);

        Frame *frame = new Frame;
        frame->setCodeSnippet(
            "FlatButton *flatButton = new FlatButton;\n"
            "flatButton->setText(\"Press me!\");"
        );
        frame->setWidget(view);

        layout->addWidget(frame);
    }
    {
        FlatButton *flatButton = new FlatButton;
        flatButton->setText("Press me!");
        flatButton->setMinimumSize(200, 42);

        //flatButton->setRole(Material::Secondary);
        flatButton->setBackgroundMode(Qt::OpaqueMode);
        flatButton->setBackgroundColor(Qt::green);
        flatButton->setPeakOpacity(0.25);

        ExampleView *view = new ExampleView;
        view->setWidget(flatButton);
        view->setBackgroundRole(QPalette::Base);

        Frame *frame = new Frame;
        frame->setCodeSnippet(
            "FlatButton *flatButton = new FlatButton;\n"
            "flatButton->setText(\"Press me!\");"
        );
        frame->setWidget(view);

        layout->addWidget(frame);
    }
    {
        FlatButton *flatButton = new FlatButton;
        flatButton->setText("Press me!");
        flatButton->setIcon(QIcon("../qt-material-widgets/face.svg"));
        flatButton->setMinimumSize(200, 50);

        ExampleView *view = new ExampleView;
        view->setWidget(flatButton);

        Frame *frame = new Frame;
        frame->setCodeSnippet(
            "FlatButton *flatButton = new FlatButton;\n"
            "flatButton->setText(\"Press me!\");\n"
            "flatButton->setIcon(QIcon(\"face.svg\"));"
        );
        frame->setWidget(view);

        layout->addWidget(frame);
    }
    {
        FlatButton *flatButton = new FlatButton;
        flatButton->setText("Press me!");
        flatButton->setDisabled(true);

        ExampleView *view = new ExampleView;
        view->setWidget(flatButton);

        Frame *frame = new Frame;
        frame->setCodeSnippet(
                    ""
        );
        frame->setWidget(view);

        layout->addWidget(frame);
    }
    {
        QPushButton *flatButton = new QPushButton;
        flatButton->setText("Press me!");
        flatButton->setIcon(QIcon("../qt-material-widgets/face.svg"));
        flatButton->setMinimumSize(200, 50);
        flatButton->setCheckable(true);

        ExampleView *view = new ExampleView;
        view->setWidget(flatButton);

        Frame *frame = new Frame;
        frame->setCodeSnippet(
                    ""
        );
        frame->setWidget(view);

        layout->addWidget(frame);
    }
        //QPushButton *flatButton = new QPushButton;
        //flatButton->setText("Press me!");
        //flatButton->setIcon(QIcon("../qt-material-widgets/face.svg"));
        //flatButton->setMinimumSize(200, 50);
        //flatButton->setCheckable(true);

        //FloatingActionButton *button = new FloatingActionButton(QIcon("../qt-material-widgets/ic_local_dining_white_24px.svg"));

        //qDebug() << QGuiApplication::allWindows();

        //ExampleView *view = new ExampleView;
        //view->setWidget(button);

        //Frame *frame = new Frame;
        //frame->setCodeSnippet(
        //            ""
        //);
        //frame->setWidget(view);

        //layout->addWidget(frame);
}
Esempio n. 9
0
DatabaseWidget::DatabaseWidget(Database* db, QWidget* parent)
    : QStackedWidget(parent)
    , m_db(db)
    , m_searchUi(new Ui::SearchWidget())
    , m_searchWidget(new QWidget())
    , m_newGroup(Q_NULLPTR)
    , m_newEntry(Q_NULLPTR)
    , m_newParent(Q_NULLPTR)
{
    m_searchUi->setupUi(m_searchWidget);

    m_searchTimer = new QTimer(this);
    m_searchTimer->setSingleShot(true);

    m_mainWidget = new QWidget(this);
    QLayout* layout = new QHBoxLayout(m_mainWidget);
    m_splitter = new QSplitter(m_mainWidget);
    m_splitter->setChildrenCollapsible(false);

    QWidget* rightHandSideWidget = new QWidget(m_splitter);
    m_searchWidget->setParent(rightHandSideWidget);

    m_groupView = new GroupView(db, m_splitter);
    m_groupView->setObjectName("groupView");
    m_groupView->setContextMenuPolicy(Qt::CustomContextMenu);
    connect(m_groupView, SIGNAL(customContextMenuRequested(QPoint)),
            SLOT(emitGroupContextMenuRequested(QPoint)));

    m_entryView = new EntryView(rightHandSideWidget);
    m_entryView->setObjectName("entryView");
    m_entryView->setContextMenuPolicy(Qt::CustomContextMenu);
    m_entryView->setGroup(db->rootGroup());
    connect(m_entryView, SIGNAL(customContextMenuRequested(QPoint)),
            SLOT(emitEntryContextMenuRequested(QPoint)));

    QAction* closeAction = new QAction(m_searchWidget);
    QIcon closeIcon = filePath()->icon("actions", "dialog-close");
    closeAction->setIcon(closeIcon);
    m_searchUi->closeSearchButton->setDefaultAction(closeAction);
    m_searchUi->closeSearchButton->setShortcut(Qt::Key_Escape);
    m_searchWidget->hide();
    m_searchUi->caseSensitiveCheckBox->setVisible(false);

    QVBoxLayout* vLayout = new QVBoxLayout(rightHandSideWidget);
    vLayout->setMargin(0);
    vLayout->addWidget(m_searchWidget);
    vLayout->addWidget(m_entryView);

    rightHandSideWidget->setLayout(vLayout);

    setTabOrder(m_searchUi->searchRootRadioButton, m_entryView);
    setTabOrder(m_entryView, m_groupView);
    setTabOrder(m_groupView, m_searchWidget);

    m_splitter->addWidget(m_groupView);
    m_splitter->addWidget(rightHandSideWidget);

    m_splitter->setStretchFactor(0, 30);
    m_splitter->setStretchFactor(1, 70);

    layout->addWidget(m_splitter);
    m_mainWidget->setLayout(layout);

    m_editEntryWidget = new EditEntryWidget();
    m_editEntryWidget->setObjectName("editEntryWidget");
    m_historyEditEntryWidget = new EditEntryWidget();
    m_editGroupWidget = new EditGroupWidget();
    m_editGroupWidget->setObjectName("editGroupWidget");
    m_changeMasterKeyWidget = new ChangeMasterKeyWidget();
    m_changeMasterKeyWidget->headlineLabel()->setText(tr("Change master key"));
    QFont headlineLabelFont = m_changeMasterKeyWidget->headlineLabel()->font();
    headlineLabelFont.setBold(true);
    headlineLabelFont.setPointSize(headlineLabelFont.pointSize() + 2);
    m_changeMasterKeyWidget->headlineLabel()->setFont(headlineLabelFont);
    m_databaseSettingsWidget = new DatabaseSettingsWidget();
    m_databaseSettingsWidget->setObjectName("databaseSettingsWidget");
    m_databaseOpenWidget = new DatabaseOpenWidget();
    m_databaseOpenWidget->setObjectName("databaseOpenWidget");
    m_keepass1OpenWidget = new KeePass1OpenWidget();
    m_keepass1OpenWidget->setObjectName("keepass1OpenWidget");
    m_unlockDatabaseWidget = new UnlockDatabaseWidget();
    m_unlockDatabaseWidget->setObjectName("unlockDatabaseWidget");
    addWidget(m_mainWidget);
    addWidget(m_editEntryWidget);
    addWidget(m_editGroupWidget);
    addWidget(m_changeMasterKeyWidget);
    addWidget(m_databaseSettingsWidget);
    addWidget(m_historyEditEntryWidget);
    addWidget(m_databaseOpenWidget);
    addWidget(m_keepass1OpenWidget);
    addWidget(m_unlockDatabaseWidget);

    connect(m_splitter, SIGNAL(splitterMoved(int,int)), SIGNAL(splitterSizesChanged()));
    connect(m_entryView->header(), SIGNAL(sectionResized(int,int,int)), SIGNAL(entryColumnSizesChanged()));
    connect(m_groupView, SIGNAL(groupChanged(Group*)), this, SLOT(clearLastGroup(Group*)));
    connect(m_groupView, SIGNAL(groupChanged(Group*)), SIGNAL(groupChanged()));
    connect(m_groupView, SIGNAL(groupChanged(Group*)), m_entryView, SLOT(setGroup(Group*)));
    connect(m_entryView, SIGNAL(entryActivated(Entry*, EntryModel::ModelColumn)),
            SLOT(entryActivationSignalReceived(Entry*, EntryModel::ModelColumn)));
    connect(m_entryView, SIGNAL(entrySelectionChanged()), SIGNAL(entrySelectionChanged()));
    connect(m_editEntryWidget, SIGNAL(editFinished(bool)), SLOT(switchToView(bool)));
    connect(m_editEntryWidget, SIGNAL(historyEntryActivated(Entry*)), SLOT(switchToHistoryView(Entry*)));
    connect(m_historyEditEntryWidget, SIGNAL(editFinished(bool)), SLOT(switchBackToEntryEdit()));
    connect(m_editGroupWidget, SIGNAL(editFinished(bool)), SLOT(switchToView(bool)));
    connect(m_changeMasterKeyWidget, SIGNAL(editFinished(bool)), SLOT(updateMasterKey(bool)));
    connect(m_databaseSettingsWidget, SIGNAL(editFinished(bool)), SLOT(switchToView(bool)));
    connect(m_databaseOpenWidget, SIGNAL(editFinished(bool)), SLOT(openDatabase(bool)));
    connect(m_keepass1OpenWidget, SIGNAL(editFinished(bool)), SLOT(openDatabase(bool)));
    connect(m_unlockDatabaseWidget, SIGNAL(editFinished(bool)), SLOT(unlockDatabase(bool)));
    connect(this, SIGNAL(currentChanged(int)), this, SLOT(emitCurrentModeChanged()));
    connect(m_searchUi->searchEdit, SIGNAL(textChanged(QString)), this, SLOT(startSearchTimer()));
    connect(m_searchUi->caseSensitiveCheckBox, SIGNAL(toggled(bool)), this, SLOT(startSearch()));
    connect(m_searchUi->searchCurrentRadioButton, SIGNAL(toggled(bool)), this, SLOT(startSearch()));
    connect(m_searchUi->searchRootRadioButton, SIGNAL(toggled(bool)), this, SLOT(startSearch()));
    connect(m_searchUi->searchEdit, SIGNAL(returnPressed()), m_entryView, SLOT(setFocus()));
    connect(m_searchTimer, SIGNAL(timeout()), this, SLOT(search()));
    connect(closeAction, SIGNAL(triggered()), this, SLOT(closeSearch()));
    connect( &m_file_watcher, SIGNAL( fileChanged() ), this, SLOT( databaseModifedExternally() ) );

    setCurrentWidget(m_mainWidget);
}
Esempio n. 10
0
ClientGUI::ClientGUI(QWidget *parent)
    : QWidget(parent)
{
	/**********
	 * Initialize NULL pointer
	 **********/

	client = NULL;

    /**********
     * Build base application window
     **********/

    setWindowTitle("GaoChat Client");


	// Construct tabs
	tabPt = new map<QString,Tab*>;
	tabs = new CloseableTabWidget(tabPt);
	tabs->setDocumentMode(true);
	tabs->setTabPosition(QTabWidget::North);
	tabs->setTabsClosable(true);

	Tab *groupChat = new GroupTab(this);
	groupChat->setDisabled(true);	// Disable until connected to server
	tabPt->insert(std::pair<QString,Tab*>(ROOTTAB,groupChat));
	tabs->addTab(groupChat,"Group Chat");

	QLayout *mainLayout = new QVBoxLayout;
	mainLayout->setMargin(0);
	mainLayout->setSpacing(0);
	mainLayout->addWidget(tabs);

	setLayout(mainLayout);

    /**********
     * Dialog box prompting for server,port and nickname
     **********/
    configPrompt = new QDialog;
    configPrompt->setWindowTitle("Settings");
    configPrompt->setFixedSize(configPrompt->sizeHint());
    configPrompt->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed);

    QLayout *serverSettings = new QVBoxLayout;

    serverAddr = new QLineEdit;
    serverAddr->setFixedWidth(125);
    serverAddr->setText("127.0.0.1");

    serverPort = new QSpinBox;
    serverPort->setMinimum(1024);
    serverPort->setMaximum(65535);
    serverPort->setValue(S_PORT);

    // Radio buttons for UDP/TCP

    serverSettings->addWidget(new QLabel("Server:"));
    serverSettings->addWidget(serverAddr);
    serverSettings->addWidget(new QLabel("Port:"));
    serverSettings->addWidget(serverPort);
    serverSettings->setSpacing(1);
    serverSettings->setMargin(0);

    QLayout *userSettings = new QVBoxLayout;

    nick = new QLineEdit;
	nick->setText("sudowork");
    userSettings->addWidget(new QLabel("Nickname:"));
    userSettings->addWidget(nick);

    QPushButton *conn = new QPushButton("Connect");
    connect(conn,SIGNAL(clicked()),this,SLOT(serverConnect()));
    QPushButton *quit = new QPushButton("Quit");
    connect(quit,SIGNAL(clicked()),this,SLOT(quit()));

    QVBoxLayout *configLayout = new QVBoxLayout;
    configLayout->addLayout(serverSettings);
    configLayout->addLayout(userSettings);
    configLayout->addWidget(conn);
    configLayout->addWidget(quit);

    configPrompt->setLayout(configLayout);

    configPrompt->exec();
}
Esempio n. 11
0
void ResourceWizard::PageChanged(int PageId)
{
    //qDebug()<<"start"<<"PageId"<<PageId<<"CurrentPageId"<<CurrentPageId;
    if(CurrentPageId == 0)
    {
        MultiLanguageString str;
        str.SetTranslation("en",ui->DescriptionEn->text());
        str.SetTranslation("ru",ui->DescripnionRu->text());

        ResourceWidget->SetVariableName(ui->Name->text());
        ResourceWidget->SetDescription(str);
    }else if(CurrentPageId == 1)
    {
        ResourceWidget->SetTypeId(Type);

    }else if(CurrentPageId == 2)
    {
        if(Type == "FixedString")
        {
            QCheckBox * e = ResourceWidget->GetTemplateWidgetByType(false,Type)->findChild<QCheckBox *>("NotEmptyCheckBox");
            if(e)
                e->setChecked(ui->StringNotEmpty->isChecked());

            QLineEdit * FixedStringValue = ResourceWidget->GetTemplateWidgetByType(true,Type)->findChild<QLineEdit *>("FixedStringValue");
            if(FixedStringValue)
                FixedStringValue->setText(ui->StringDefaultValue->text());
        }
    }else if(CurrentPageId == 10)
    {
        if(IsAdditionalTab)
        {
            IsAdditionalTab = false;
            MultiLanguageString str;
            str.SetTranslation("en",ui->TabEn->text());
            str.SetTranslation("ru",ui->TabRu->text());
            ResourceWidget->SetSectionName(str);
        }
    }else if(CurrentPageId == 9)
    {
        if(IsAdditionalIf)
        {
            IsAdditionalIf = false;
            ResourceWidget->SetVisibilityConditionValue(ui->VisibilityValue->text());
            ResourceWidget->SetVisibilityConditionVariable(ui->VisibilityName->text());

        }
    }else if(CurrentPageId == 8)
    {
        if(Type == "Select")
        {
            QComboBox * SelectTypeCombo = ResourceWidget->GetTemplateWidgetByType(false,Type)->findChild<QComboBox *>("SelectTypeCombo");
            if(SelectTypeCombo)
                SelectTypeCombo->setCurrentText(ui->SelectType->currentText());

            QPlainTextEdit * SelectValuesEdit = ResourceWidget->GetTemplateWidgetByType(false,Type)->findChild<QPlainTextEdit *>("SelectValuesEdit");
            if(SelectValuesEdit)
                SelectValuesEdit->setPlainText(ui->SelectLines->toPlainText());

            QWidget *child = ResourceWidget->GetTemplateWidgetByType(true,Type)->findChild<QWidget *>("SelectWidget");
            QLayout * layout = child->layout();

            /*MultiSelect * OldSelect = child->findChild<MultiSelect *>();
            if(OldSelect)
                OldSelect->deleteLater();

            MultiSelect * Select = new MultiSelect(child);*/

            MultiSelect * Select = child->findChild<MultiSelect *>();

            QStringList list = ui->SelectLines->toPlainText().split(QRegExp("[\r\n]"),QString::SkipEmptyParts);

            MultiSelect *multi = ui->SelectDefaultValueContainer->findChild<MultiSelect *>();

            Select->Update(ui->SelectType->currentText(), list, multi->GetSelectedIndex());
            layout->addWidget(Select);


        }
    }else if(CurrentPageId == 7)
    {
        if(Type == "RandomString")
        {
            QLineEdit * RandomStringValue = ResourceWidget->GetTemplateWidgetByType(true,Type)->findChild<QLineEdit *>("RandomStringValue");
            if(RandomStringValue)
                RandomStringValue->setText(ui->RandomStringValue->text());
        }
    }else if(CurrentPageId == 4)
    {
        if(Type == "FixedInteger")
        {
            QSpinBox * min = ResourceWidget->GetTemplateWidgetByType(false,Type)->findChild<QSpinBox *>("EditMinimum");
            QSpinBox * max = ResourceWidget->GetTemplateWidgetByType(false,Type)->findChild<QSpinBox *>("EditMaximum");
            if(min)
                min->setValue(ui->MinValueNumber->value());
            if(max)
                max->setValue(ui->MaxValueNumber->value());

            QSpinBox * FixedIntegerValue = ResourceWidget->GetTemplateWidgetByType(true,Type)->findChild<QSpinBox *>("FixedIntegerValue");
            if(FixedIntegerValue)
                FixedIntegerValue->setValue(ui->Number->value());


        }

    }else if(CurrentPageId == 3)
    {

        if(Type == "RandomInteger")
        {
            QSpinBox * min = ResourceWidget->GetTemplateWidgetByType(false,Type)->findChild<QSpinBox *>("EditMinimum_2");
            QSpinBox * max = ResourceWidget->GetTemplateWidgetByType(false,Type)->findChild<QSpinBox *>("EditMaximum_2");
            if(min)
                min->setValue(ui->MinValueRange->value());
            if(max)
                max->setValue(ui->MaxValueRange->value());

            QSpinBox * RIMinimumValue = ResourceWidget->GetTemplateWidgetByType(true,Type)->findChild<QSpinBox *>("RIMinimumValue");
            if(RIMinimumValue)
                RIMinimumValue->setValue(ui->NumberMin->value());

            QSpinBox * RIMaximumValue = ResourceWidget->GetTemplateWidgetByType(true,Type)->findChild<QSpinBox *>("RIMaximumValue");
            if(RIMaximumValue)
                RIMaximumValue->setValue(ui->NumberMax->value());
        }
    }else if(CurrentPageId == 5)
    {
        if(Type == "LinesFromFile")
        {

            QCheckBox * FileRead = ResourceWidget->GetTemplateWidgetByType(true,Type)->findChild<QCheckBox *>("FileRead");
            if(FileRead)
                FileRead->setChecked(!ui->OnlyWrite->isChecked());

            QCheckBox * FileWrite = ResourceWidget->GetTemplateWidgetByType(true,Type)->findChild<QCheckBox *>("FileWrite");
            if(FileWrite)
                FileWrite->setChecked(!ui->OnlyRead->isChecked());

            QCheckBox * FileMix = ResourceWidget->GetTemplateWidgetByType(true,Type)->findChild<QCheckBox *>("FileMix");
            if(FileMix)
                FileMix->setChecked(ui->MixLines->isChecked());


        }
        if(Type == "FilesFromDirectory")
        {
            QCheckBox * DirectoryClean = ResourceWidget->GetTemplateWidgetByType(true,Type)->findChild<QCheckBox *>("DirectoryClean");
            if(DirectoryClean)
                DirectoryClean->setChecked(!ui->OnlyRead->isChecked());

            QCheckBox * DirectoryMix = ResourceWidget->GetTemplateWidgetByType(true,Type)->findChild<QCheckBox *>("DirectoryMix");
            if(DirectoryMix)
                DirectoryMix->setChecked(ui->MixLines->isChecked());

        }

        if(Type == "Database")
        {
            QCheckBox * DatabaseClear = ResourceWidget->GetTemplateWidgetByType(true,Type)->findChild<QCheckBox *>("DatabaseClear");
            if(DatabaseClear)
                DatabaseClear->setChecked(!ui->OnlyRead->isChecked());

            QCheckBox * DatabaseMix = ResourceWidget->GetTemplateWidgetByType(true,Type)->findChild<QCheckBox *>("DatabaseMix");
            if(DatabaseMix)
                DatabaseMix->setChecked(ui->MixLines->isChecked());
        }
    }else if(CurrentPageId == 6)
    {
        int Success = 0;
        int Fails = 0;
        if(ui->EachLineOneTime->isChecked())
        {
            Success = 1;
            Fails = 1;
        }else if(ui->EachLineSeveralTimes->isChecked())
        {
            Success = 10;
            Fails = 10;
        }else if(ui->EachLineAnyNumberOfTimes->isChecked())
        {
            Success = 100000;
            Fails = 100000;
        }

        if(Type == "LinesFromFile")
        {
            QSpinBox * FileMaxSuccess = ResourceWidget->GetTemplateWidgetByType(true,Type)->findChild<QSpinBox *>("FileMaxSuccess");
            if(FileMaxSuccess)
                FileMaxSuccess->setValue(Success);

            QSpinBox * FileMaxFail = ResourceWidget->GetTemplateWidgetByType(true,Type)->findChild<QSpinBox *>("FileMaxFail");
            if(FileMaxFail)
                FileMaxFail->setValue(Fails);
        }

        if(Type == "FilesFromDirectory")
        {
            QSpinBox * DirectoryMaxSuccess = ResourceWidget->GetTemplateWidgetByType(true,Type)->findChild<QSpinBox *>("DirectoryMaxSuccess");
            if(DirectoryMaxSuccess)
                DirectoryMaxSuccess->setValue(Success);

            QSpinBox * DirectoryMaxFail = ResourceWidget->GetTemplateWidgetByType(true,Type)->findChild<QSpinBox *>("DirectoryMaxFail");
            if(DirectoryMaxFail)
                DirectoryMaxFail->setValue(Fails);

        }

        if(Type == "Database")
        {
            QSpinBox * DatabaseMaxSuccess = ResourceWidget->GetTemplateWidgetByType(true,Type)->findChild<QSpinBox *>("DatabaseMaxSuccess");
            if(DatabaseMaxSuccess)
                DatabaseMaxSuccess->setValue(Success);

            QSpinBox * DatabaseMaxFail = ResourceWidget->GetTemplateWidgetByType(true,Type)->findChild<QSpinBox *>("DatabaseMaxFail");
            if(DatabaseMaxFail)
                DatabaseMaxFail->setValue(Fails);
        }

        if(Type == "LinesFromUrl")
        {
            QSpinBox * UrlMaxSuccess = ResourceWidget->GetTemplateWidgetByType(true,Type)->findChild<QSpinBox *>("UrlMaxSuccess");
            if(UrlMaxSuccess)
                UrlMaxSuccess->setValue(Success);

            QSpinBox * UrlMaxFail = ResourceWidget->GetTemplateWidgetByType(true,Type)->findChild<QSpinBox *>("UrlMaxFail");
            if(UrlMaxFail)
                UrlMaxFail->setValue(Fails);
        }
    }

    if(PageId > CurrentPageId)
    {
        if(PageId == 2 && Type != "FixedString")
        {
            next();
            return;
        }
        if(PageId == 3 && Type != "RandomInteger")
        {
            next();
            return;
        }
        if(PageId == 4 && Type != "FixedInteger")
        {
            next();
            return;
        }
        if(PageId == 5 && Type != "LinesFromFile" && Type != "FilesFromDirectory" && Type != "Database")
        {
            next();
            return;
        }
        if(PageId == 6 && Type != "LinesFromFile" && Type != "FilesFromDirectory" && Type != "Database" && Type != "LinesFromUrl")
        {
            next();
            return;
        }
        if(PageId == 7 && Type != "RandomString")
        {
            next();
            return;
        }
        if(PageId == 8 && Type != "Select")
        {
            next();
            return;
        }
        if(PageId == 9 && !IsAdditionalIf)
        {
            next();
            return;
        }
        if(PageId == 10 && !IsAdditionalTab)
        {
            next();
            return;
        }
    }else
    {
        if(PageId == 2 && Type != "FixedString")
        {
            back();
            return;
        }
        if(PageId == 3 && Type != "RandomInteger")
        {
            back();
            return;
        }
        if(PageId == 4 && Type != "FixedInteger")
        {
            back();
            return;
        }
        if(PageId == 5 && Type != "LinesFromFile" && Type != "FilesFromDirectory" && Type != "Database")
        {
            back();
            return;
        }
        if(PageId == 6 && Type != "LinesFromFile" && Type != "FilesFromDirectory" && Type != "Database" && Type != "LinesFromUrl")
        {
            back();
            return;
        }
        if(PageId == 7 && Type != "RandomString")
        {
            back();
            return;
        }
        if(PageId == 8 && Type != "Select")
        {
            back();
            return;
        }
        if(PageId == 9 && !IsAdditionalIf)
        {
            back();
            return;
        }
        if(PageId == 10 && !IsAdditionalTab)
        {
            back();
            return;
        }
    }

    CurrentPageId = PageId;
}
Esempio n. 12
0
void BookmarkWidget::setup(bool showButtons)
{
    regExp.setPatternSyntax(QRegExp::FixedString);
    regExp.setCaseSensitivity(Qt::CaseInsensitive);

    QLayout *vlayout = new QVBoxLayout(this);
    vlayout->setMargin(4);

    QLabel *label = new QLabel(tr("Filter:"), this);
    vlayout->addWidget(label);

    searchField = new QLineEdit(this);
    vlayout->addWidget(searchField);
    connect(searchField, SIGNAL(textChanged(QString)), this,
        SLOT(filterChanged()));

    treeView = new TreeView(this);
    vlayout->addWidget(treeView);

#ifdef Q_OS_MAC
#   define SYSTEM "mac"
#else
#   define SYSTEM "win"
#endif

    if (showButtons) {
        QLayout *hlayout = new QHBoxLayout();
        vlayout->addItem(hlayout);

        hlayout->addItem(new QSpacerItem(40, 20, QSizePolicy::Expanding));

        addButton = new QToolButton(this);
        addButton->setText(tr("Add"));
        addButton->setIcon(QIcon(QLatin1String(":/assistant-icons/addtab.png")));
        addButton->setAutoRaise(true);
        addButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
        hlayout->addWidget(addButton);
        connect(addButton, SIGNAL(clicked()), this, SIGNAL(addBookmark()));

        removeButton = new QToolButton(this);
        removeButton->setText(tr("Remove"));
        removeButton->setIcon(QIcon(QLatin1String(":/assistant-icons/closetab.png")));
        removeButton->setAutoRaise(true);
        removeButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
        hlayout->addWidget(removeButton);
        connect(removeButton, SIGNAL(clicked()), this, SLOT(removeClicked()));
    }

    filterBookmarkModel = new QSortFilterProxyModel(this);
    treeView->setModel(filterBookmarkModel);

    treeView->setDragEnabled(true);
    treeView->setAcceptDrops(true);
    treeView->setAutoExpandDelay(1000);
    treeView->setDropIndicatorShown(true);
    treeView->header()->setVisible(false);
    treeView->viewport()->installEventFilter(this);
    treeView->setContextMenuPolicy(Qt::CustomContextMenu);

    connect(treeView, SIGNAL(expanded(QModelIndex)), this,
        SLOT(expand(QModelIndex)));
    connect(treeView, SIGNAL(collapsed(QModelIndex)), this,
        SLOT(expand(QModelIndex)));
    connect(treeView, SIGNAL(activated(QModelIndex)), this,
        SLOT(activated(QModelIndex)));
    connect(treeView, SIGNAL(customContextMenuRequested(QPoint)),
        this, SLOT(customContextMenuRequested(QPoint)));

    filterBookmarkModel->setFilterKeyColumn(0);
    filterBookmarkModel->setDynamicSortFilter(true);
    filterBookmarkModel->setSourceModel(bookmarkManager->treeBookmarkModel());

    expandItems();
}
Esempio n. 13
0
/*=========================================================================
  Constructor
=========================================================================*/
KFileBrowser::KFileBrowser(QWidget *parent)
    : KFileWidget (path, parent)
  {
  QLayout *layout = new QVBoxLayout;

  homeDir = getHomeDir(); 
  
  toolbar = new QToolBar ();
  toolbar->setToolButtonStyle (Qt::ToolButtonTextUnderIcon);

  QAction *exitAction = new QAction (*exitIcon, "Exit", toolbar);
  QObject::connect(exitAction, SIGNAL(triggered(bool)), 
      this, SLOT(handleExitAction()));

  QAction *openAction = new QAction (*openIcon, "Open", toolbar);
  QObject::connect(openAction, SIGNAL(triggered(bool)), 
      this, SLOT(handleOpenAction()));

  QAction *upAction = new QAction (*upIcon, "Up", toolbar);
  QObject::connect(upAction, SIGNAL(triggered(bool)), 
      this, SLOT(handleUpAction()));

  QAction *homeAction = new QAction (*homeIcon, "Home", toolbar);
  QObject::connect(homeAction, SIGNAL(triggered(bool)), 
      this, SLOT(handleHomeAction()));

  QAction *viewAction = new QAction (*viewIcon, "View", toolbar);
  QObject::connect(viewAction, SIGNAL(triggered(bool)), 
      this, SLOT(handleViewAction()));

  QAction *newBrowserAction = new QAction (*newBrowserIcon, "New browser", 
      toolbar);
  QObject::connect(newBrowserAction, SIGNAL(triggered(bool)), 
      this, SLOT(handleNewBrowserAction()));

  QAction *newFileAction = new QAction (*newFileIcon, "New file", 
      toolbar);
  QObject::connect(newFileAction, SIGNAL(triggered(bool)), 
      this, SLOT(handleNewFileAction()));

  QAction *newDirAction = new QAction (*newDirIcon, "New folder", 
      toolbar);
  QObject::connect(newDirAction, SIGNAL(triggered(bool)), 
      this, SLOT(handleNewDirAction()));

  QAction *deleteAction = new QAction (*deleteIcon, "Delete", 
      toolbar);
  QObject::connect(deleteAction, SIGNAL(triggered(bool)), 
      this, SLOT(handleDeleteAction()));

  QAction *cutAction = new QAction (*cutIcon, "Cut", 
      toolbar);
  QObject::connect(cutAction, SIGNAL(triggered(bool)), 
      this, SLOT(handleCutAction()));

  QAction *copyAction = new QAction (*copyIcon, "Copy", 
      toolbar);
  QObject::connect(copyAction, SIGNAL(triggered(bool)), 
      this, SLOT(handleCopyAction()));

  QAction *pasteAction = new QAction (*pasteIcon, "Paste", 
      toolbar);
  QObject::connect(pasteAction, SIGNAL(triggered(bool)), 
      this, SLOT(handlePasteAction()));

  QAction *refreshAction = new QAction (*refreshIcon, "Refresh", 
      toolbar);
  QObject::connect(refreshAction, SIGNAL(triggered(bool)), 
      this, SLOT(handleRefreshAction()));

  QAction *searchAction = new QAction (*searchIcon, "Search", 
      toolbar);
  QObject::connect(searchAction, SIGNAL(triggered(bool)), 
      this, SLOT(handleSearchAction()));

  QAction *settingsAction = new QAction (*settingsIcon, "Settings", 
      toolbar);
  QObject::connect(settingsAction, SIGNAL(triggered(bool)), 
      this, SLOT(handleSettingsAction()));

  QAction *manualAction = new QAction (*manualIcon, "Manual", 
      toolbar);
  QObject::connect(manualAction, SIGNAL(triggered(bool)), 
      this, SLOT(handleManualAction()));

  QAction *aboutAction = new QAction (*aboutIcon, "About", 
      toolbar);
  QObject::connect(aboutAction, SIGNAL(triggered(bool)), 
      this, SLOT(handleAboutAction()));

  QAction *renameAction = new QAction (*renameIcon, "Rename", 
      toolbar);
  QObject::connect(renameAction, SIGNAL(triggered(bool)), 
      this, SLOT(handleRenameAction()));

  QAction *selectAllAction = new QAction (*selectAllIcon, "Select all", 
      toolbar);
  QObject::connect(selectAllAction, SIGNAL(triggered(bool)), 
      this, SLOT(handleSelectAllAction()));

  QAction *selectNoneAction = new QAction (*selectNoneIcon, "Select none", 
      toolbar);
  QObject::connect(selectNoneAction, SIGNAL(triggered(bool)), 
      this, SLOT(handleSelectNoneAction()));

  newMenu = new QMenu ();
  QToolButton *newButton = new QToolButton();
  newMenu->addAction (newBrowserAction);
  newMenu->addAction (newDirAction);
  newMenu->addAction (newFileAction);
  newButton->setMenu (newMenu);
  newButton->setIcon (*newBrowserIcon);
  newButton->setPopupMode (QToolButton::InstantPopup);
  newButton->setText ("New");
  newButton->setToolButtonStyle (Qt::ToolButtonTextUnderIcon);

  editMenu = new QMenu ();
  QToolButton *editButton = new QToolButton();
  editMenu->addAction (deleteAction);
  editMenu->addAction (cutAction);
  editMenu->addAction (copyAction);
  editMenu->addAction (pasteAction);
  editMenu->addAction (renameAction);
  editMenu->addSeparator();
  editMenu->addAction (selectAllAction);
  editMenu->addAction (selectNoneAction);
  editButton->setMenu (editMenu);
  editButton->setIcon (*copyIcon);
  editButton->setPopupMode (QToolButton::InstantPopup);
  editButton->setText ("Edit");
  editButton->setToolButtonStyle (Qt::ToolButtonTextUnderIcon);

  helpMenu = new QMenu ();
  QToolButton *helpButton = new QToolButton();
  helpMenu->addAction (manualAction);
  helpMenu->addAction (aboutAction);
  helpButton->setMenu (helpMenu);
  helpButton->setIcon (*helpIcon);
  helpButton->setPopupMode (QToolButton::InstantPopup);
  helpButton->setText ("Help");
  helpButton->setToolButtonStyle (Qt::ToolButtonTextUnderIcon);

  toolbar->addAction (exitAction);
  toolbar->addAction (refreshAction);
  toolbar->addAction (openAction);
  toolbar->addAction (upAction);
  toolbar->addAction (homeAction);
  toolbar->addAction (viewAction);
  toolbar->addAction (searchAction);
  toolbar->addWidget(newButton);
  toolbar->addWidget(editButton);
  toolbar->addAction (settingsAction);
  toolbar->addWidget (helpButton);
  
  pathDisplay = new QLabel ();
  pathDisplay->setObjectName ("pathDisplay");
  pathDisplay->setTextFormat (Qt::PlainText);

  layout->addWidget (toolbar);
  layout->addWidget (pathDisplay);
  layout->addWidget (list);

  setLayout (layout);

  pasteByNameOnly = false;
  }
MeasurementWidget::MeasurementWidget(Form::FormItem *formItem, QWidget *parent) :
    Form::IFormWidget(formItem,parent),
    m_units(0),
    m_value(0),
    m_defaultUnitId(-1),
    m_isWeight(false),
    m_isLength(false)
{
    setObjectName("MeasurementWidget");
    bool uiBased = false;
    QLayout *hb = 0;
    const QString &layout = formItem->spec()->value(Form::FormItemSpec::Spec_UiInsertIntoLayout).toString();
    const QString &widgets = formItem->spec()->value(Form::FormItemSpec::Spec_UiWidget).toString();

    // Manage Qt UI files and pure FreeMedForms defined forms
    if (widgets.isEmpty() && !layout.isEmpty()) {
        // QtUi Loaded using layout
        // Here the user wants to build the measurement widget from a
        // Qt UI file inside a specific layout.
        // We need here to insert the measurement widgets inside the layout
        // This includes a label, one value (spin) and one unit (combo) editor
        QLayout *lay = formItem->parentFormMain()->formWidget()->findChild<QLayout*>(layout);
        if (lay) {
            hb = lay;
        } else {
            LOG_ERROR("Using the QtUiLinkage, layout not found in the ui: " + formItem->uuid() + "; layout name: "+ layout);
            // To avoid segfaulting create a fake combo
            hb = new QHBoxLayout(this);
        }
        // Find Label
        m_Label = findLabel(formItem);

        // Add spin + combo to the layout
        m_units = new QComboBox(this);
        m_value = new QDoubleSpinBox(this);
        hb->addWidget(m_value);
        hb->addWidget(m_units);
        uiBased= true;
    } else if (!widgets.isEmpty() && layout.isEmpty()) {
        // Qt Ui using widgets naming
        // Here the user wants to build a measurement widget from a
        // Qt UI file using specific & defined widgets.
        // We need here to get the measurement widgets from the UI
        // This includes a label, one value (spin) and one unit (combo) editor
        // The FormItem widget string content must include two objectname
        // coma separated. Eg: "widget1Value;widget2Units"
        if (widgets.count(";") != 1) {
            LOG_ERROR("Wrong widget naming. No ; found.");
        } else {
            QStringList w = widgets.split(";");
            QDoubleSpinBox *value = formItem->parentFormMain()->formWidget()->findChild<QDoubleSpinBox*>(w.at(0));
            if (value) {
                m_value = value;
            } else {
                LOG_ERROR("Using the QtUiLinkage, value spinbox not found in the ui: " + formItem->uuid() + "; widget name: "+ w.at(0));
            }
            QComboBox *units = formItem->parentFormMain()->formWidget()->findChild<QComboBox*>(w.at(1));
            if (units) {
                m_units = units;
            } else {
                LOG_ERROR("Using the QtUiLinkage, units combobox not found in the ui: " + formItem->uuid() + "; widget name: "+ w.at(1));
            }
            uiBased = true;
        }
        // Find Label
        m_Label = findLabel(formItem);
    } else if (!widgets.isEmpty() && !layout.isEmpty())  {
        // This is a form coding error
        // Users can choose two Qt UI method: use widgets, insert in a layout
        // Not both
        LOG_ERROR(QString("Item %1 can not be constructed. "
                          "Please choose between QtUI widgets method or Qt UI layout insertion method. You can not use both")
                  .arg(formItem->spec()->uuid())
                  );
    } else {
        // Pure FreeMedForms form. User does not use any Qt UI file.
        // We need here to create the measurement widgets and insert them inside the right layout
        // Widgets include: a label, one value (spin) and one unit (combo) editor
        hb = getBoxLayout(OnLeft, m_FormItem->spec()->label(), this);
        hb->addWidget(m_Label);
        hb->setMargin(0);
        hb->setSpacing(0);
    }

    // Ensure that the widgets are available
    // - layout
    if (!hb && (!m_units || !m_value) && !uiBased) {
        LOG_ERROR("No layout, creating a default one. Form item: " + formItem->uuid());
        hb = new QHBoxLayout(this);
    } else if (!hb && !uiBased) {
        hb = getBoxLayout(OnLeft, m_FormItem->spec()->label(), this);
        hb->addWidget(m_Label);
        hb->setMargin(0);
        hb->setSpacing(0);
    }
    // - value editor
    if (!m_value) {
        m_value = new QDoubleSpinBox(this);
        m_value->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
        hb->addWidget(m_value);
    }
    // - units editor
    if (!m_units) {
        // Add spin + combo to the layout
        m_units = new QComboBox(this);
        m_value->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
        hb->addWidget(m_units);
    }
    m_units->setFocusPolicy(Qt::ClickFocus);

    // Manage options:
    // The measurement units widget can be autopopulated with
    // Length or Weight units using the "length" and "weight" options
    const QStringList &options = formItem->getOptions();
    if (options.contains("Length", Qt::CaseInsensitive)) {
        populateWithLength();
    } else if (options.contains("Weight", Qt::CaseInsensitive)) {
        populateWithWeight();
    }

    setFocusedWidget(m_value);
    setLastTabWidget(m_units);
    setFocusProxy(m_value);

    // create item data
    MeasurementWidgetData *data = new MeasurementWidgetData(formItem);
    data->setMeasurementWidget(this);
    data->setDefaultUnitIndex(m_defaultUnitId);
    formItem->setItemData(data);

//    connect(m_Text->textEdit(), SIGNAL(textChanged()), data, SLOT(onValueChanged()));
    retranslate();
}
Esempio n. 15
0
/**
 * Constructs a new PropertyDialog.
 */
PropertyDialog::PropertyDialog(NeuralNetworkEditor *owner)
	: EditorToolWidget(owner), mInitialized(false), mCurrentProperties(0), 
	  mPropertyList(0), mListScrollArea(0),
	  mSetButton(0), mChangeButton(0), mRemoveButton(0), mPropertySelectionField(0),
	  mValueEditField(0)
{
	setObjectName("PropertyDialog");

	QVBoxLayout *layout = new QVBoxLayout(this);	
	layout->setObjectName("MainLayout");
	setLayout(layout);

	QLayout *nameLayout = new QHBoxLayout();
	layout->addLayout(nameLayout);

	QLayout *listLayout = new QHBoxLayout();
	listLayout->setObjectName("ListLayout");
	layout->addLayout(listLayout);

	QHBoxLayout *propertySelectLayout = new QHBoxLayout();	
	layout->addLayout(propertySelectLayout);

	QHBoxLayout *valueEditLayout = new QHBoxLayout();
	layout->addLayout(valueEditLayout);

	QHBoxLayout *buttonLayout = new QHBoxLayout();
	buttonLayout->setObjectName("ButtonLayout");
	layout->addLayout(buttonLayout);

	QHBoxLayout *autoSelectLayout = new QHBoxLayout();
	autoSelectLayout->setObjectName("AutoSelectLayout");
	layout->addLayout(autoSelectLayout);

	QHBoxLayout *typeSelectionLayout = new QHBoxLayout();
	layout->addLayout(typeSelectionLayout);
	QHBoxLayout *typeSelectionLayoutLower = new QHBoxLayout();
	layout->addLayout(typeSelectionLayoutLower);


	mNameLabel = new QLabel("");
	nameLayout->addWidget(mNameLabel);

	mPropertyList = new QListWidget(this);
	mListScrollArea = new QScrollArea(this);
	mListScrollArea->setWidget(mPropertyList);
	mListScrollArea->setWidgetResizable(true);
	listLayout->addWidget(mListScrollArea);

	mPropertySelectionField = new QComboBox(this);
	mPropertySelectionField->setEditable(true);
	addStandardPropertyTemplates();
	propertySelectLayout->addWidget(mPropertySelectionField);
	
	mValueEditField = new QLineEdit();
	valueEditLayout->addWidget(mValueEditField);

	mSetButton = new QPushButton("Set", this);
	mSetButton->setContentsMargins(2, 2, 2, 2);
	mSetButton->setMinimumWidth(15);
	mChangeButton = new QPushButton("Change", this);
	mChangeButton->setContentsMargins(2, 2, 2, 2);
	mChangeButton->setMinimumWidth(15);
	mRemoveButton = new QPushButton("Delete", this);
	mRemoveButton->setContentsMargins(2, 2, 2, 2);
	mRemoveButton->setMinimumWidth(15);
	mApplyToAllIndividuals = new QCheckBox("All", this);
	mApplyToAllIndividuals->setChecked(false);
	mApplyToAllIndividuals->setToolTip("Apply changes to all individuals (Evolution only)");
	mShowAllProperties = new QCheckBox("H", this);
	mShowAllProperties->setChecked(false),
	mShowAllProperties->setToolTip("Show also hidden properties");

	buttonLayout->addWidget(mSetButton);
	buttonLayout->addWidget(mChangeButton);
	buttonLayout->addWidget(mRemoveButton);
	buttonLayout->addWidget(mApplyToAllIndividuals);
	buttonLayout->addWidget(mShowAllProperties);

	mSelectMatchingElementsButton = new QPushButton("Select Matching");
	mForceExactMatchForSelectionCheckBox = new QCheckBox("Exact");
	mForceExactMatchForSelectionCheckBox->setChecked(false);
	mShowNonMatchingElementsCheckBox = new QCheckBox("Negate");
	mShowNonMatchingElementsCheckBox->setChecked(false);

	autoSelectLayout->addWidget(mSelectMatchingElementsButton);
	autoSelectLayout->addWidget(mForceExactMatchForSelectionCheckBox);
	autoSelectLayout->addWidget(mShowNonMatchingElementsCheckBox);

	mConsiderNeurons = new QCheckBox("N");
	mConsiderSynapses = new QCheckBox("S");
	mConsiderGroups = new QCheckBox("G");
	mConsiderModules = new QCheckBox("M");

	mHelpButton = new QPushButton("Help");
	mHelpButton->setContentsMargins(2, 2, 2, 2);
	mHelpButton->setMinimumWidth(15);

	mConsiderNeurons->setMinimumWidth(10);
	mConsiderSynapses->setMinimumWidth(10);
	mConsiderGroups->setMinimumWidth(10);
	mConsiderModules->setMinimumWidth(10);

	typeSelectionLayout->addWidget(mConsiderNeurons);
	typeSelectionLayout->addWidget(mConsiderSynapses);
	typeSelectionLayout->addWidget(mConsiderGroups);
	typeSelectionLayout->addWidget(mConsiderModules);
	typeSelectionLayout->addWidget(mHelpButton);
	


	if(mEditor != 0) {
		connect(mEditor, SIGNAL(tabSelectionChanged(int)),
				this, SLOT(currentEditorTabChanged(int)));
	}
Esempio n. 16
0
/**
 * Request the video to avoid the conflicts
 **/
WId VideoWidget::request( int *pi_x, int *pi_y,
                          unsigned int *pi_width, unsigned int *pi_height,
                          bool b_keep_size )
{
    msg_Dbg( p_intf, "Video was requested %i, %i", *pi_x, *pi_y );

    if( reparentable != NULL )
    {
        msg_Dbg( p_intf, "embedded video already in use" );
        return NULL;
    }
    if( b_keep_size )
    {
        *pi_width  = size().width();
        *pi_height = size().height();
    }

    /* The Qt4 UI needs a fixed a widget ("this"), so that the parent layout is
     * not messed up when we the video is reparented. Hence, we create an extra
     * reparentable widget, that will be within the VideoWidget in windowed
     * mode, and within the root window (NULL parent) in full-screen mode.
     */
    reparentable = new ReparentableWidget( this );
    QLayout *innerLayout = new QHBoxLayout( reparentable );
    innerLayout->setContentsMargins( 0, 0, 0, 0 );

    /* The owner of the video window needs a stable handle (WinId). Reparenting
     * in Qt4-X11 changes the WinId of the widget, so we need to create another
     * dummy widget that stays within the reparentable widget. */
    QWidget *stable = new QWidget();
    QPalette plt = palette();
    plt.setColor( QPalette::Window, Qt::black );
    stable->setPalette( plt );
    stable->setAutoFillBackground(true);
    /* Indicates that the widget wants to draw directly onto the screen.
       Widgets with this attribute set do not participate in composition
       management */
    stable->setAttribute( Qt::WA_PaintOnScreen, true );

    innerLayout->addWidget( stable );

    layout->addWidget( reparentable );

#ifdef Q_WS_X11
    /* HACK: Only one X11 client can subscribe to mouse button press events.
     * VLC currently handles those in the video display.
     * Force Qt4 to unsubscribe from mouse press and release events. */
    Display *dpy = QX11Info::display();
    Window w = stable->winId();
    XWindowAttributes attr;

    XGetWindowAttributes( dpy, w, &attr );
    attr.your_event_mask &= ~(ButtonPressMask|ButtonReleaseMask);
    XSelectInput( dpy, w, attr.your_event_mask );
#endif
    videoSync();
#ifndef NDEBUG
    msg_Dbg( p_intf, "embedded video ready (handle %p)",
             (void *)stable->winId() );
#endif
    return stable->winId();
}