QHBoxLayout* Settings::buildLayout() { // Create the left panel m_panel = new Panel( this ); m_panel->setMaximumWidth( 130 ); // Create the master layout QHBoxLayout* hLayout = new QHBoxLayout( this ); hLayout->addWidget( m_panel ); // Right Sub-layout QVBoxLayout* vLayout = new QVBoxLayout; m_title = new QLabel( this ); m_configPanel = new QScrollArea( this ); m_configPanel->setFrameShape( QFrame::NoFrame ); // Set the font and text of the panel title QFont labelFont = font(); labelFont.setPointSize( labelFont.pointSize() + 6 ); labelFont.setFamily( "Verdana" ); m_title->setFont( labelFont ); m_title->setText( "Empty" ); vLayout->addWidget( m_title ); vLayout->addWidget( m_configPanel ); vLayout->addWidget( m_buttons ); hLayout->insertLayout( -1, vLayout ); return hLayout; }
StreamPostWidget::StreamPostWidget(DATA::FbStreamPost *post, QWidget *parent) : QWidget(parent), m_post(post), m_triedBothIcons(false) { m_nam = new QNetworkAccessManager(this); connect(m_nam,SIGNAL(finished(QNetworkReply*)), this, SLOT(gotNetworkReply(QNetworkReply*))); //this->setStyleSheet("background : white;"); this->setAutoFillBackground(true); QPalette palette = this->palette(); palette.setColor(QPalette::Background, Qt::white); setPalette(palette); QHBoxLayout *mainLayout = new QHBoxLayout(); QFrame *f = new QFrame(); f->setMinimumWidth(10); f->setFrameShape(QFrame::VLine); mainLayout->insertWidget(1,f); mainLayout->setSizeConstraint(QLayout::SetMinimumSize); m_contentLayout = new QVBoxLayout(); m_contentLayout->setSizeConstraint(QLayout::SetMinimumSize); if (post->isFromUser()) this->setWindowTitle(post->getPoster().getName()); else this->setWindowTitle(post->getPage().getName()); if (post->getMessage() != "" || (post->getTargetId().compare("") != 0)) { QLabel *message = new QLabel(); QString text = post->getMessage(); if (post->getTargetId().compare("") != 0) text.prepend("-> " + post->getTarget().getName() + ": "); message->setText(UTIL::hyperLink(text)); message->setTextInteractionFlags(Qt::TextBrowserInteraction); message->setWordWrap(true); message->setMinimumWidth(450); message->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Minimum); connect(message, SIGNAL(linkActivated(QString)), this, SIGNAL(contentClicked(QString))); m_contentLayout->addWidget(message,0,Qt::AlignTop); } QString ageHtml = "<style type=\"text/css\">a { text-decoration: none; }</style>" "<font style=\"font-size : 8pt;\">" + UTIL::ageString(post->getCreatedTime()) + " "; if (post->getAttribution() != "" && !post->getAttribution().startsWith("via")) ageHtml.append("via "); ageHtml.append(post->getAttribution() + "</font>"); QLabel *age = new QLabel(ageHtml); m_ageLineLayout = new QHBoxLayout(); m_ageLineLayout->insertWidget(1,age,1); // Get the app icon, prefer the one in attachment if present if (post->getAttachment()->getIcon().toString() != "") { QNetworkRequest nr; nr.setUrl(post->getAttachment()->getIcon()); QNetworkReply *reply = m_nam->get(nr); m_outstandingNetworkRequests.insert(reply, AppIcon); } else if (m_post->getAppInfo().getIconUrl() != "") { m_triedBothIcons = true; QNetworkRequest nr; nr.setUrl(QUrl(m_post->getAppInfo().getIconUrl())); QNetworkReply *reply = m_nam->get(nr); m_outstandingNetworkRequests.insert(reply, AppIcon); } if (!post->getAttachment()->isEmpty()) { DATA::FbStreamAttachment *attachment = post->getAttachment(); FbAttachmentWidget *aw = new FbAttachmentWidget(attachment); aw->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Minimum); connect(aw, SIGNAL(userClickedUrl(QString)), this, SIGNAL(contentClicked(QString))); m_contentLayout->addWidget(aw); } m_contentLayout->addLayout(m_ageLineLayout,0); m_contentLayout->addStretch(); m_contentLayout->addSpacing(10); GUI::FbCommentManager *manager = new FbCommentManager(m_post->getPostId(), FbCommentManager::PostId, m_post->getCommentList()->canRemove()); manager->setMaximumHeight(400); QString fbObjectId = m_post->getPostId(); GUI::FbLikeManager *likeManager = new FbLikeManager(fbObjectId, m_post->userLikes()); connect(likeManager, SIGNAL(userChangedLike(bool)), this, SLOT(likeChanged(bool))); QHBoxLayout *hLayout = new QHBoxLayout(); m_showAddCommentButton = new QToolButton(); m_showAddCommentButton->setAutoFillBackground(true); palette = m_showAddCommentButton->palette(); palette.setColor(QPalette::Button,QColor(82,110,166)); m_showAddCommentButton->setPalette(palette); m_showAddCommentButton->setIcon(QIcon(":/uiImages/addComment_50_50.jpg")); m_showAddCommentButton->setIconSize(QSize(40,40)); m_showAddCommentButton->setToolTip("Comment"); connect(m_showAddCommentButton, SIGNAL(clicked()), manager, SLOT(showAddComment())); hLayout->addWidget(m_showAddCommentButton,0); m_likeButton = new QToolButton(); this->likeChanged(m_post->userLikes()); m_likeButton->setIconSize(QSize(40,40)); connect(m_likeButton, SIGNAL(clicked()), likeManager, SLOT(toggleUserLikes())); hLayout->addWidget(m_likeButton,0); hLayout->addStretch(1); m_contentLayout->addLayout(hLayout,0); m_contentLayout->addWidget(likeManager,0); m_contentLayout->addWidget(manager,2); //manager->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Minimum); mainLayout->insertLayout(2,m_contentLayout,1); setLayout(mainLayout); getPosterPixmap(); QDesktopWidget *dw = QApplication::desktop(); QRect r = dw->screenGeometry(); move(r.width() - 240, 40); }
QgsGrassModuleOption::QgsGrassModuleOption( QgsGrassModule *module, QString key, QDomElement &qdesc, QDomElement &gdesc, QDomNode &gnode, bool direct, QWidget * parent ) : QgsGrassModuleGroupBoxItem( module, key, qdesc, gdesc, gnode, direct, parent ) , mControlType( NoControl ) , mValueType( String ) , mOutputType( None ) , mHaveLimits( false ) , mMin( INT_MAX ) , mMax( INT_MIN ) , mComboBox( 0 ) , mIsOutput( false ) , mValidator( 0 ) , mLayout( 0 ) , mUsesRegion( false ) { QgsDebugMsg( "entered" ); setSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::Minimum ); if ( mHidden ) hide(); mLayout = new QVBoxLayout(); // Is it output? QDomNode promptNode = gnode.namedItem( "gisprompt" ); if ( !promptNode.isNull() ) { QDomElement promptElem = promptNode.toElement(); QString element = promptElem.attribute( "element" ); QString age = promptElem.attribute( "age" ); if ( age == "new" ) { mOutputElement = element; mIsOutput = true; if ( element == "vector" ) { mOutputType = Vector; } else if ( element == "cell" ) { mOutputType = Raster; } } } // String without options if ( !mHidden ) { QDomElement gelem = gnode.toElement(); // Output option may have missing gisprompt if output may be both vector and raster according to other options (e.g. v.kernel) // outputType qgm attribute allows forcing an output type // Predefined values ? QDomNode valuesNode = gnode.namedItem( "values" ); QDomElement valuesElem = valuesNode.toElement(); // null if valuesNode is null if ( !valuesNode.isNull() && valuesNode.childNodes().count() > 1 ) { setLayout( mLayout ); // predefined values -> ComboBox or CheckBox // one or many? if ( gelem.attribute( "multiple" ) == "yes" ) { mControlType = CheckBoxes; } else { mControlType = ComboBox; mComboBox = new QComboBox( this ); mLayout->addWidget( mComboBox ); } // List of values to be excluded QStringList exclude = qdesc.attribute( "exclude" ).split( ',', QString::SkipEmptyParts ); QDomNode valueNode = valuesElem.firstChild(); while ( !valueNode.isNull() ) { QDomElement valueElem = valueNode.toElement(); if ( !valueElem.isNull() && valueElem.tagName() == "value" ) { QDomNode n = valueNode.namedItem( "name" ); if ( !n.isNull() ) { QDomElement e = n.toElement(); QString val = e.text().trimmed(); if ( exclude.contains( val ) == 0 ) { n = valueNode.namedItem( "description" ); QString desc; if ( !n.isNull() ) { e = n.toElement(); desc = e.text().trimmed(); } else { desc = val; } desc.replace( 0, 1, desc.left( 1 ).toUpper() ); if ( mControlType == ComboBox ) { mComboBox->addItem( desc ); if ( mAnswer.length() > 0 && val == mAnswer ) { mComboBox->setCurrentIndex( mComboBox->count() - 1 ); } } else { QgsGrassModuleCheckBox *cb = new QgsGrassModuleCheckBox( desc, this ); mCheckBoxes.push_back( cb ); mLayout->addWidget( cb ); } mValues.push_back( val ); } } } valueNode = valueNode.nextSibling(); } } else // No values { // Line edit mControlType = LineEdit; // Output option may have missing gisprompt if output may be both vector and raster according to other options (e.g. v.kernel) // outputType qgm attribute allow forcing an output type QgsDebugMsg( "outputType = " + qdesc.attribute( "outputType" ) ); if ( qdesc.hasAttribute( "outputType" ) ) { QString outputType = qdesc.attribute( "outputType" ); mIsOutput = true; if ( outputType == "vector" ) { mOutputElement = "vector"; mOutputType = Vector; } else if ( outputType == "raster" ) { mOutputElement = "cell"; mOutputType = Raster; } else { mErrors << tr( "Unknown outputType" ) + " : " + outputType; } } if ( gelem.attribute( "type" ) == "integer" ) { mValueType = Integer; } else if ( gelem.attribute( "type" ) == "float" ) { mValueType = Double; } QStringList minMax; if ( valuesNode.childNodes().count() == 1 ) { QDomNode valueNode = valuesElem.firstChild(); QDomNode n = valueNode.namedItem( "name" ); if ( !n.isNull() ) { QDomElement e = n.toElement(); QString val = e.text().trimmed(); minMax = val.split( "-" ); if ( minMax.size() == 2 ) { mHaveLimits = true; mMin = minMax.at( 0 ).toDouble(); mMax = minMax.at( 1 ).toDouble(); } } } QDomNode keydescNode = gnode.namedItem( "keydesc" ); if ( !keydescNode.isNull() ) { // fixed number of line edits // Example: // <keydesc> // <item order="1">rows</item> // <item order="2">columns</item> // </keydesc> QDomNodeList keydescs = keydescNode.childNodes(); for ( int k = 0; k < keydescs.count(); k++ ) { QDomNode nodeItem = keydescs.at( k ); QString itemDesc = nodeItem.toElement().text().trimmed(); //QString itemDesc = nodeItem.firstChild().toText().data(); QgsDebugMsg( "keydesc item = " + itemDesc ); addLineEdit(); } setLayout( mLayout ); } else if ( gelem.attribute( "multiple" ) == "yes" ) { // variable number of line edits // add/delete buttons for multiple options QHBoxLayout *l = new QHBoxLayout( this ); QVBoxLayout *vl = new QVBoxLayout(); l->insertLayout( -1, mLayout ); l->insertLayout( -1, vl ); // TODO: how to keep both buttons on the top? QPushButton *b = new QPushButton( "+", this ); connect( b, SIGNAL( clicked() ), this, SLOT( addLineEdit() ) ); vl->addWidget( b, 0, Qt::AlignTop ); b = new QPushButton( "-", this ); connect( b, SIGNAL( clicked() ), this, SLOT( removeLineEdit() ) ); vl->addWidget( b, 0, Qt::AlignTop ); // Don't enable this, it makes the group box expanding // vl->addStretch(); } else { // only one line edit addLineEdit(); setLayout( mLayout ); } } } mUsesRegion = false; QString region = qdesc.attribute( "region" ); if ( region.length() > 0 ) { if ( region == "yes" ) mUsesRegion = true; } else { QgsDebugMsg( "\n\n\n\n**************************" ); QgsDebugMsg( QString( "isOutput = %1" ).arg( isOutput() ) ); QgsDebugMsg( QString( "mOutputType = %1" ).arg( mOutputType ) ); if ( isOutput() && mOutputType == Raster ) mUsesRegion = true; } QgsDebugMsg( QString( "mUsesRegion = %1" ).arg( mUsesRegion ) ); }
void widgetKeyBoard::createKeyboard(void) { QKeyPushButton *tmp = NULL; QVBoxLayout *tmpVLayout = new QVBoxLayout; QHBoxLayout *tmpLayout = new QHBoxLayout; QString tmpStyle = QString::null; if (widgetKeyBoard::m_created == true) // tastiera già creata: esce return; widgetKeyBoard::m_created = true; // segnala che è stata creata la tastiera // // stampa tasti numerici: tmpLayout->addWidget(createNewKey("\\")); for (short i = 49; i <= 57; i++) { tmpLayout->addWidget(createNewKey(QChar(i))); } tmpLayout->addWidget(createNewKey(tr("0"))); tmpLayout->addWidget(createNewKey(tr("/"))); tmpLayout->addWidget(createNewKey(tr("?"))); tmpLayout->addWidget(createNewKey(tr("'"))); if (this->isEmbeddedKeyboard() == true) tmpStyle = QString(KEY_BACKSPACE_EMBEDDED); else tmpStyle = QString(KEY_BACKSPACE); tmp = createNewKey(tmpStyle); tmp->setMaximumWidth(tmp->maximumWidth() * 2); tmp->setMinimumWidth(tmp->minimumWidth() * 2); tmpLayout->addWidget(tmp); tmpStyle = QString(KEY_CANC); if (this->isEmbeddedKeyboard() == true) tmpStyle = tmpStyle.toLower(); tmp = createNewKey(tmpStyle); tmp->setMaximumWidth(tmp->maximumWidth()); tmp->setMinimumWidth(tmp->minimumWidth()); tmpLayout->addWidget(tmp); #if !defined(QT_ARCH_MACOSX) tmpLayout->insertStretch(13, 1); #endif tmpVLayout->insertLayout(0, tmpLayout); // // Stampa linea della "Q": tmpLayout = new QHBoxLayout; QVBoxLayout *layoutReturn = new QVBoxLayout; tmp = createNewKey(KEY_TAB); tmp->setMaximumWidth(tmp->maximumWidth() * 2 - 5); tmp->setMinimumWidth(tmp->minimumWidth() * 2 - 5); tmpLayout->addWidget(tmp); tmpLayout->addWidget(createNewKey(tr("Q"))); tmpLayout->addWidget(createNewKey(tr("W"))); tmpLayout->addWidget(createNewKey(tr("E"))); tmpLayout->addWidget(createNewKey(tr("R"))); tmpLayout->addWidget(createNewKey(tr("T"))); tmpLayout->addWidget(createNewKey(tr("Y"))); tmpLayout->addWidget(createNewKey(tr("U"))); tmpLayout->addWidget(createNewKey(tr("I"))); tmpLayout->addWidget(createNewKey(tr("O"))); tmpLayout->addWidget(createNewKey(tr("P"))); tmpLayout->addWidget(createNewKey(tr("+"))); tmpLayout->addWidget(createNewKey(tr("*"))); tmpLayout->addWidget(createNewKey(tr("-"))); #if !defined(QT_ARCH_MACOSX) tmpLayout->insertStretch(-1, 1); #endif layoutReturn->insertLayout(0, tmpLayout, 1); // inserisce la riga della "Q" // // Stampa linea della "A": tmpLayout = new QHBoxLayout; tmp = createNewKey(KEY_CAPS); tmp->setMaximumWidth(tmp->maximumWidth() * 2 + 5); tmp->setMinimumWidth(tmp->minimumWidth() * 2 + 5); if (this->isEmbeddedKeyboard() == true) tmpStyle = QString(EMBEDDED_KEYBOARD); tmp->setStyleSheet(QString(DEFAULT_STYLE_BUTTON) + QString(CHANGED_BACKGROUND_BUTTON) + tmpStyle); // segnalato come attivo tmpLayout->addWidget(tmp); tmpLayout->addWidget(createNewKey(tr("A"))); tmpLayout->addWidget(createNewKey(tr("S"))); tmpLayout->addWidget(createNewKey(tr("D"))); tmpLayout->addWidget(createNewKey(tr("F"))); tmpLayout->addWidget(createNewKey(tr("G"))); tmpLayout->addWidget(createNewKey(tr("H"))); tmpLayout->addWidget(createNewKey(tr("J"))); tmpLayout->addWidget(createNewKey(tr("K"))); tmpLayout->addWidget(createNewKey(tr("L"))); tmpLayout->addWidget(createNewKey(tr("ò"))); tmpLayout->addWidget(createNewKey(tr("à"))); tmpLayout->addWidget(createNewKey(tr("ù"))); tmpLayout->addWidget(createNewKey(tr("@"))); tmpLayout->insertStretch(-1, 1); #if !defined(QT_ARCH_MACOSX) layoutReturn->setSpacing(5); #endif layoutReturn->insertLayout(1, tmpLayout, 1); // inserisce la riga della "A" // // inserisce il vertical layout all'interno di un horizontal: tmpLayout = new QHBoxLayout; tmpLayout->insertLayout(0, layoutReturn, 1); // // inserisce anche il tasto invio: tmp = createNewKey(KEY_RETURN); tmp->setMaximumWidth(tmp->maximumWidth() * 2); tmp->setMinimumWidth(tmp->minimumWidth() * 2); tmp->setMinimumHeight(tmp->minimumHeight() * 2); tmp->setMaximumHeight(tmp->maximumHeight() * 2); tmpLayout->addWidget(tmp); // // inserisce l'horizontal all'interno del layout verticale principale: tmpVLayout->insertLayout(1, tmpLayout); // // Stampa linea della "Z": tmpLayout = new QHBoxLayout; tmp = createNewKey(KEY_CUT_LEFT); tmp->setMaximumWidth(tmp->maximumWidth() * 2); tmp->setMinimumWidth(tmp->minimumWidth() * 2); tmpLayout->addWidget(tmp); tmpLayout->addWidget(createNewKey(tr("_"))); tmpLayout->addWidget(createNewKey(tr("Z"))); tmpLayout->addWidget(createNewKey(tr("X"))); tmpLayout->addWidget(createNewKey(tr("C"))); tmpLayout->addWidget(createNewKey(tr("V"))); tmpLayout->addWidget(createNewKey(tr("B"))); tmpLayout->addWidget(createNewKey(tr("N"))); tmpLayout->addWidget(createNewKey(tr("M"))); tmpLayout->addWidget(createNewKey(tr(","))); tmpLayout->addWidget(createNewKey(tr(";"))); tmpLayout->addWidget(createNewKey(tr(":"))); tmpLayout->addWidget(createNewKey(tr("."))); tmp = createNewKey(KEY_CTRL_LEFT); tmp->setMaximumWidth(tmp->maximumWidth() * 3 + 5); tmp->setMinimumWidth(tmp->minimumWidth() * 3 + 5); tmpLayout->addWidget(tmp); tmpVLayout->insertLayout(2, tmpLayout); // // Stampa linea dello SPACE: tmpLayout = new QHBoxLayout; tmp = createNewKey(KEY_COPY); tmp->setMaximumWidth(tmp->maximumWidth() * 2); tmp->setMinimumWidth(tmp->minimumWidth() * 2); tmpLayout->addWidget(tmp); tmp = createNewKey(KEY_ALT); tmp->setMaximumWidth(tmp->maximumWidth() * 2); tmp->setMinimumWidth(tmp->minimumWidth() * 2); tmpLayout->addWidget(tmp); tmp = createNewKey(KEY_SPACE); tmp->setMaximumWidth(tmp->maximumWidth() * 10); tmp->setMinimumWidth(tmp->minimumWidth() * 10); tmpLayout->addWidget(tmp); // password echo button: if (this->isEmbeddedKeyboard() == true) tmpStyle = QString(KEY_HIDECHAR_EMBEDDED); else tmpStyle = QString(KEY_HIDECHAR); tmp = createNewKey(tmpStyle); tmp->setMaximumWidth(tmp->maximumWidth() * 2); tmp->setMinimumWidth(tmp->minimumWidth() * 2); tmpLayout->addWidget(tmp); // tmp = createNewKey(KEY_PASTE); tmp->setMaximumWidth(tmp->maximumWidth() * 2); tmp->setMinimumWidth(tmp->minimumWidth() * 2); tmpLayout->addWidget(tmp); tmpVLayout->insertLayout(3, tmpLayout); #if defined (QT_ARCH_MACOSX) tmpVLayout->setMargin(5); #endif // // aggancia il layout a tutto il form: this->setLayout(tmpVLayout); this->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); }
void ItemsView::buildContents() { m_views.clear(); m_root->setBackgroundRole(QPalette::Base); QVBoxLayout* _layout = new QVBoxLayout(m_root); if (m_currentFeed != NULL) { Entry::List entries = m_currentFeed->entries(); //switch (m_sorting) //{ // case 0: // qSort(entries.begin(), entries.end(), NameSorter); // break; // case 1: // qSort(entries.begin(), entries.end(), RatingSorter); // break; // case 2: // qSort(entries.begin(), entries.end(), RecentSorter); // break; // case 3: // qSort(entries.begin(), entries.end(), DownloadsSorter); // break; //} Entry::List::iterator it = entries.begin(), iEnd = entries.end(); for (unsigned row = 0; it != iEnd; ++it) { Entry* entry = (*it); if (entry->name().representation().toLower().contains(m_searchText.toLower())) { QHBoxLayout * itemLayout = new QHBoxLayout; _layout->addLayout(itemLayout); EntryView *part = new EntryView(m_root); part->setBackgroundRole(row & 1 ? QPalette::AlternateBase : QPalette::Base); itemLayout->addWidget(part); QVBoxLayout * previewLayout = new QVBoxLayout; itemLayout->insertLayout(0, previewLayout); KDXSButton *dxsbutton = new KDXSButton(m_root); dxsbutton->setEntry(entry); dxsbutton->setProvider(m_currentProvider); dxsbutton->setEngine(m_engine); QString imageurl = entry->preview().representation(); if (!imageurl.isEmpty()) { QLabel *f = new QLabel(m_root); f->setFrameStyle(QFrame::Panel | QFrame::Sunken); QAsyncImage *pix = new QAsyncImage(imageurl, m_root); f->setFixedSize(64, 64); //connect(pix, SIGNAL(signalLoaded(QImage)), // f, SLOT(setImage(QImage))); previewLayout->addWidget(f); } //previewLayout->addWidget(dxsbutton); part->setEntry(entry); m_views.insert(entry, part); ++row; } } } //setWidget(m_root); }