void CQMergingData::fillTree(QTreeWidget* pW, const CModel* pModel, std::map< QTreeWidgetItem *, const CCopasiObject * > & itemMap, bool flagGlobalQuantities, bool flagReactions, const std::set< const CCopasiObject * > & added, bool highlightInvolved) { itemMap.clear(); pW->clear(); CModelExpansion mex(const_cast<CModel*>(pModel)); //create an italic font for highlighting new model elements QFont tmpFont = pW->font(); tmpFont.setItalic(true); //add the compartments size_t i, imax = pModel->getCompartments().size(); for (i = 0; i < imax; ++i) { const CCopasiObject * pObj = &pModel->getCompartments()[i]; QTreeWidgetItem * pItem = new QTreeWidgetItem((QTreeWidget*)NULL, 1000); pItem->setText(0, FROM_UTF8(pObj->getObjectName())); //highlight new objects std::set<const CCopasiObject * >::const_iterator it = added.find(pObj); if (it != added.end()) { pItem->setFont(0, tmpFont); //pItem->setBackgroundColor(0, QColor(200,200,250)); } //highlight objects that are referred to by others if (highlightInvolved) { if (!mex.existDependentEntities(pObj)) pItem->setTextColor(0, QColor(130, 130, 130)); } itemMap[pItem] = pObj; pW->addTopLevelItem(pItem); pW->setFirstItemColumnSpanned(pItem, true); //add species //QTreeWidgetItem * pChild; size_t j, jmax = pModel->getCompartments()[i].getMetabolites().size(); for (j = 0; j < jmax; ++j) { pObj = &pModel->getCompartments()[i].getMetabolites()[j]; QTreeWidgetItem * pChild = new QTreeWidgetItem(pItem, 1001); pChild->setText(0, FROM_UTF8(pObj->getObjectName())); pW->setFirstItemColumnSpanned(pChild, true); //highlight new objects std::set< const CCopasiObject * >::const_iterator it = added.find(pObj); if (it != added.end()) { pChild->setFont(0, tmpFont); //pChild->setBackgroundColor(0, QColor(200,200,250)); } //highlight objects that are referred to by others if (highlightInvolved) { if (!mex.existDependentEntities(pObj)) pChild->setTextColor(0, QColor(130, 130, 130)); } itemMap[pChild] = pObj; } pItem->setExpanded(true); } if (flagGlobalQuantities && pModel->getModelValues().size()) { QTreeWidgetItem * pItem = new QTreeWidgetItem((QTreeWidget*)NULL, 1000); pItem->setText(0, "Global Quantities"); pW->addTopLevelItem(pItem); pW->setFirstItemColumnSpanned(pItem, true); //QTreeWidgetItem * pChild; size_t j, jmax = pModel->getModelValues().size(); for (j = 0; j < jmax; ++j) { const CCopasiObject * pObj = &pModel->getModelValues()[j]; QTreeWidgetItem * pChild = new QTreeWidgetItem(pItem, 1001); pChild->setText(0, FROM_UTF8(pObj->getObjectName())); pW->setFirstItemColumnSpanned(pChild, true); //highlight new objects std::set< const CCopasiObject * >::const_iterator it = added.find(pObj); if (it != added.end()) { pChild->setFont(0, tmpFont); //pChild->setBackgroundColor(0, QColor(200,200,250)); } //highlight objects that are referred to by others if (highlightInvolved) { if (!mex.existDependentEntities(pObj)) pChild->setTextColor(0, QColor(130, 130, 130)); } itemMap[pChild] = pObj; } } if (flagReactions && pModel->getReactions().size()) { pW->setColumnCount(2); QTreeWidgetItem * pItem = new QTreeWidgetItem((QTreeWidget*)NULL, 1000); pItem->setText(0, "Reactions"); pW->addTopLevelItem(pItem); pW->setFirstItemColumnSpanned(pItem, true); QFont tmpFontSmall = pItem->font(0); tmpFontSmall.setPointSize(tmpFontSmall.pointSize() - 2); //QTreeWidgetItem * pChild; size_t j, jmax = pModel->getReactions().size(); for (j = 0; j < jmax; ++j) { const CCopasiObject * pObj = &pModel->getReactions()[j]; QTreeWidgetItem * pChild = new QTreeWidgetItem(pItem, 1001); pChild->setText(0, FROM_UTF8(pObj->getObjectName())); pW->setFirstItemColumnSpanned(pChild, false); //add the chemical equation (with a smaller font) const CReaction * pReaction = dynamic_cast<const CReaction*>(pObj); if (pReaction) pChild->setText(1, FROM_UTF8(CChemEqInterface::getChemEqString(const_cast<CModel*>(pModel), *pReaction, false))); pChild->setFont(1, tmpFontSmall); //highlight new objects std::set< const CCopasiObject * >::const_iterator it = added.find(pObj); if (it != added.end()) { pChild->setFont(0, tmpFont); //pChild->setBackgroundColor(0, QColor(200,200,250)); } //highlight objects that are referred to by others if (highlightInvolved) { if (!mex.existDependentEntities(pObj)) pChild->setTextColor(0, QColor(130, 130, 130)); pChild->setTextColor(1, QColor(130, 130, 130)); } itemMap[pChild] = pObj; } //pW->setCo } }
soundKonverterView::soundKonverterView( Logger *_logger, Config *_config, CDManager *_cdManager, QWidget *parent ) : QWidget( parent ), config( _config ), logger( _logger ), cdManager( _cdManager ) { setAcceptDrops( true ); const int fontHeight = QFontMetrics(QApplication::font()).boundingRect("M").size().height(); // the grid for all widgets in the main window QGridLayout* gridLayout = new QGridLayout( this ); fileList = new FileList( logger, config, this ); gridLayout->addWidget( fileList, 1, 0 ); gridLayout->setRowStretch( 1, 1 ); connect( fileList, SIGNAL(fileCountChanged(int)), this, SLOT(fileCountChanged(int)) ); connect( fileList, SIGNAL(conversionStarted()), this, SLOT(conversionStarted()) ); connect( fileList, SIGNAL(conversionStopped(bool)), this, SLOT(conversionStopped(bool)) ); connect( fileList, SIGNAL(queueModeChanged(bool)), this, SLOT(queueModeChanged(bool)) ); connect( fileList, SIGNAL(showLog(int)), this, SIGNAL(showLog(int)) ); optionsLayer = new OptionsLayer( config, this ); fileList->setOptionsLayer( optionsLayer ); optionsLayer->hide(); gridLayout->addWidget( optionsLayer, 1, 0 ); connect( optionsLayer, SIGNAL(done(const KUrl::List&,ConversionOptions*,const QString&)), fileList, SLOT(addFiles(const KUrl::List&,ConversionOptions*,const QString&)) ); connect( optionsLayer, SIGNAL(saveFileList()), fileList, SLOT(save()) ); // add a horizontal box layout for the add combobutton to the grid QHBoxLayout *addBox = new QHBoxLayout(); addBox->setContentsMargins( 1, 0, 1, 0 ); // extra margin - determined by experiments gridLayout->addLayout( addBox, 3, 0 ); // create the combobutton for adding files to the file list cAdd = new ComboButton( this ); QFont font = cAdd->font(); //font.setWeight( QFont::DemiBold ); font.setPointSize( font.pointSize() + 3 ); cAdd->setFont( font ); cAdd->insertItem( KIcon("audio-x-generic"), i18n("Add files...") ); cAdd->insertItem( KIcon("folder"), i18n("Add folder...") ); cAdd->insertItem( KIcon("media-optical-audio"), i18n("Add CD tracks...") ); cAdd->insertItem( KIcon("network-workgroup"), i18n("Add url...") ); cAdd->insertItem( KIcon("view-media-playlist"), i18n("Add playlist...") ); cAdd->increaseHeight( 0.6*fontHeight ); addBox->addWidget( cAdd, 0, Qt::AlignVCenter ); connect( cAdd, SIGNAL(clicked(int)), this, SLOT(addClicked(int)) ); cAdd->setFocus(); addBox->addSpacing( fontHeight ); startAction = new KAction( KIcon("system-run"), i18n("Start"), this ); connect( startAction, SIGNAL(triggered()), fileList, SLOT(startConversion()) ); pStart = new KPushButton( KIcon("system-run"), i18n("Start"), this ); pStart->setFixedHeight( pStart->size().height() ); pStart->setEnabled( false ); startAction->setEnabled( false ); addBox->addWidget( pStart, 0, Qt::AlignVCenter ); connect( pStart, SIGNAL(clicked()), fileList, SLOT(startConversion()) ); stopActionMenu = new KActionMenu( KIcon("process-stop"), i18n("Stop"), this ); stopActionMenu->setDelayed( false ); killAction = new KAction( KIcon("flag-red"), i18n("Stop immediatelly"), this ); stopActionMenu->addAction( killAction ); connect( killAction, SIGNAL(triggered()), fileList, SLOT(killConversion()) ); stopAction = new KAction( KIcon("flag-yellow"), i18n("Stop after current conversions are completed"), this ); stopActionMenu->addAction( stopAction ); connect( stopAction, SIGNAL(triggered()), fileList, SLOT(stopConversion()) ); continueAction = new KAction( KIcon("flag-green"), i18n("Continue after current conversions are completed"), this ); stopActionMenu->addAction( continueAction ); connect( continueAction, SIGNAL(triggered()), fileList, SLOT(continueConversion()) ); queueModeChanged( true ); pStop = new KPushButton( KIcon("process-stop"), i18n("Stop"), this ); pStop->setFixedHeight( pStop->size().height() ); pStop->hide(); stopActionMenu->setEnabled( false ); pStop->setMenu( stopActionMenu->menu() ); addBox->addWidget( pStop, 0, Qt::AlignVCenter ); addBox->addSpacing( fontHeight ); progressIndicator = new ProgressIndicator( this, ProgressIndicator::Feature( ProgressIndicator::FeatureSpeed | ProgressIndicator::FeatureTime ) ); addBox->addWidget( progressIndicator, 0, Qt::AlignVCenter ); connect( progressIndicator, SIGNAL(progressChanged(const QString&)), this, SIGNAL(progressChanged(const QString&)) ); connect( fileList, SIGNAL(timeChanged(float)), progressIndicator, SLOT(timeChanged(float)) ); connect( fileList, SIGNAL(finished(bool)), progressIndicator, SLOT(finished(bool)) ); Convert *convert = new Convert( config, fileList, logger, this ); connect( fileList, SIGNAL(convertItem(FileListItem*)), convert, SLOT(add(FileListItem*)) ); connect( fileList, SIGNAL(killItem(FileListItem*)), convert, SLOT(kill(FileListItem*)) ); connect( fileList, SIGNAL(itemRemoved(FileListItem*)), convert, SLOT(itemRemoved(FileListItem*)) ); connect( convert, SIGNAL(finished(FileListItem*,FileListItem::ReturnCode,bool)), fileList, SLOT(itemFinished(FileListItem*,FileListItem::ReturnCode,bool)) ); connect( convert, SIGNAL(rippingFinished(const QString&)), fileList, SLOT(rippingFinished(const QString&)) ); connect( convert, SIGNAL(finishedProcess(int,bool,bool)), logger, SLOT(processCompleted(int,bool,bool)) ); connect( convert, SIGNAL(updateTime(float)), progressIndicator, SLOT(update(float)) ); connect( convert, SIGNAL(timeFinished(float)), progressIndicator, SLOT(timeFinished(float)) ); }
ArtistInfoWidget::ArtistInfoWidget( const Tomahawk::artist_ptr& artist, QWidget* parent ) : QWidget( parent ) , ui( new Ui::ArtistInfoWidget ) , m_artist( artist ) { QWidget* widget = new QWidget; ui->setupUi( widget ); QPalette pal = palette(); pal.setColor( QPalette::Window, QColor( "#393840" ) ); widget->setPalette( pal ); widget->setAutoFillBackground( true ); /* TomahawkUtils::unmarginLayout( ui->layoutWidget->layout() ); TomahawkUtils::unmarginLayout( ui->layoutWidget1->layout() ); TomahawkUtils::unmarginLayout( ui->layoutWidget2->layout() ); TomahawkUtils::unmarginLayout( ui->albumHeader->layout() );*/ m_albumsModel = new PlayableModel( ui->albums ); ui->albums->setPlayableModel( m_albumsModel ); ui->albums->setEmptyTip( tr( "Sorry, we could not find any albums for this artist!" ) ); m_relatedModel = new PlayableModel( ui->relatedArtists ); ui->relatedArtists->setPlayableModel( m_relatedModel ); ui->relatedArtists->proxyModel()->sort( -1 ); ui->relatedArtists->setEmptyTip( tr( "Sorry, we could not find any related artists!" ) ); m_topHitsModel = new PlaylistModel( ui->topHits ); ui->topHits->proxyModel()->setStyle( PlayableProxyModel::Short ); ui->topHits->setPlayableModel( m_topHitsModel ); ui->topHits->setSortingEnabled( false ); ui->topHits->setEmptyTip( tr( "Sorry, we could not find any top hits for this artist!" ) ); ui->relatedArtists->setAutoFitItems( false ); ui->relatedArtists->setWrapping( false ); ui->relatedArtists->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); ui->relatedArtists->setHorizontalScrollBarPolicy( Qt::ScrollBarAsNeeded ); ui->relatedArtists->delegate()->setItemSize( QSize( 170, 170 ) ); ui->albums->setAutoFitItems( false ); ui->albums->setWrapping( false ); ui->albums->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); ui->albums->setHorizontalScrollBarPolicy( Qt::ScrollBarAsNeeded ); ui->albums->delegate()->setItemSize( QSize( 170, 170 ) ); ui->albums->proxyModel()->setHideDupeItems( true ); ui->topHits->setFrameShape( QFrame::StyledPanel ); ui->topHits->setAttribute( Qt::WA_MacShowFocusRect, 0 ); m_pixmap = TomahawkUtils::defaultPixmap( TomahawkUtils::DefaultArtistImage, TomahawkUtils::Original, QSize( 48, 48 ) ); ui->cover->setPixmap( TomahawkUtils::defaultPixmap( TomahawkUtils::DefaultArtistImage, TomahawkUtils::Grid ) ); ui->cover->setShowText( true ); QFont f = font(); f.setPointSize( f.pointSize() + 1 ); ui->biography->setOpenLinks( false ); ui->biography->setOpenExternalLinks( true ); ui->biography->setFrameShape( QFrame::NoFrame ); ui->biography->setAttribute( Qt::WA_MacShowFocusRect, 0 ); ui->biography->setFont( f ); TomahawkUtils::styleScrollBar( ui->biography->verticalScrollBar() ); QPalette p = ui->biography->palette(); p.setColor( QPalette::Foreground, Qt::white ); p.setColor( QPalette::Text, Qt::gray ); ui->biography->setPalette( p ); ui->label->setPalette( p ); ui->label_2->setPalette( p ); ui->label_3->setPalette( p ); QScrollArea* area = new QScrollArea(); area->setWidgetResizable( true ); area->setWidget( widget ); area->setStyleSheet( "QScrollArea { background-color: #454e59; }" ); area->setFrameShape( QFrame::NoFrame ); area->setAttribute( Qt::WA_MacShowFocusRect, 0 ); QVBoxLayout* layout = new QVBoxLayout(); layout->addWidget( area ); setLayout( layout ); TomahawkUtils::unmarginLayout( layout ); TomahawkUtils::styleScrollBar( ui->albums->horizontalScrollBar() ); TomahawkUtils::styleScrollBar( ui->relatedArtists->horizontalScrollBar() ); ui->biography->setStyleSheet( "QTextBrowser#biography { background-color: transparent; }" ); ui->biography->document()->setDefaultStyleSheet( "a { text-decoration: none; font-weight: bold; color: #ffffff; }" ); ui->albums->setStyleSheet( "QListView { background-color: transparent; }" ); ui->albumFrame->setStyleSheet( "QFrame#albumFrame { background-color: transparent; }" "QFrame#albumFrame { " "border-image: url(" RESPATH "images/scrollbar-vertical-handle.png) 3 3 3 3 stretch stretch;" "border-top: 3px transparent; border-bottom: 3px transparent; border-right: 3px transparent; border-left: 3px transparent; }" ); ui->relatedArtists->setStyleSheet( "QListView { background-color: transparent; }" ); ui->artistFrame->setStyleSheet( "QFrame#artistFrame { background-color: transparent; }" "QFrame#artistFrame { " "border-image: url(" RESPATH "images/scrollbar-vertical-handle.png) 3 3 3 3 stretch stretch;" "border-top: 3px transparent; border-bottom: 3px transparent; border-right: 3px transparent; border-left: 3px transparent; }" ); // ui->topHits->setStyleSheet( "QTreeView#topHits { background-color: transparent; }" ); ui->trackFrame->setStyleSheet( "QFrame#trackFrame { background-color: transparent; }" "QFrame#trackFrame { " "border-image: url(" RESPATH "images/scrollbar-vertical-handle.png) 3 3 3 3 stretch stretch;" "border-top: 3px transparent; border-bottom: 3px transparent; border-right: 3px transparent; border-left: 3px transparent; }" ); connect( ui->biography, SIGNAL( anchorClicked( QUrl ) ), SLOT( onBiographyLinkClicked( QUrl ) ) ); MetaPlaylistInterface* mpl = new MetaPlaylistInterface(); mpl->addChildInterface( ui->relatedArtists->playlistInterface() ); mpl->addChildInterface( ui->topHits->playlistInterface() ); mpl->addChildInterface( ui->albums->playlistInterface() ); m_plInterface = playlistinterface_ptr( mpl ); load( artist ); }
AdvPrefsPanel::AdvPrefsPanel( intf_thread_t *_p_intf, QWidget *_parent, PrefsItemData * data ) : QWidget( _parent ), p_intf( _p_intf ) { /* Find our module */ module_t *p_module = NULL; if( data->i_type == TYPE_CATEGORY ) return; else if( data->i_type == TYPE_MODULE ) p_module = module_find( data->psz_name ); else { p_module = module_get_main(); assert( p_module ); } unsigned confsize; module_config_t *const p_config = module_config_get (p_module, &confsize), *p_item = p_config, *p_end = p_config + confsize; if( data->i_type == TYPE_SUBCATEGORY || data->i_type == TYPE_CATSUBCAT ) { while (p_item < p_end) { if( p_item->i_type == CONFIG_SUBCATEGORY && ( ( data->i_type == TYPE_SUBCATEGORY && p_item->value.i == data->i_object_id ) || ( data->i_type == TYPE_CATSUBCAT && p_item->value.i == data->i_subcat_id ) ) ) break; p_item++; } } /* Widgets now */ global_layout = new QVBoxLayout(); global_layout->setMargin( 2 ); QString head; QString help; help = QString( data->help ); if( data->i_type == TYPE_SUBCATEGORY || data->i_type == TYPE_CATSUBCAT ) { head = QString( data->name ); p_item++; // Why that ? } else { head = QString( qtr( module_GetLongName( p_module ) ) ); } QLabel *titleLabel = new QLabel( head ); QFont titleFont = QApplication::font(); titleFont.setPointSize( titleFont.pointSize() + 6 ); titleLabel->setFont( titleFont ); // Title <hr> QFrame *title_line = new QFrame; title_line->setFrameShape(QFrame::HLine); title_line->setFrameShadow(QFrame::Sunken); QLabel *helpLabel = new QLabel( help, this ); helpLabel->setWordWrap( true ); global_layout->addWidget( titleLabel ); global_layout->addWidget( title_line ); global_layout->addWidget( helpLabel ); QGroupBox *box = NULL; QGridLayout *boxlayout = NULL; QScrollArea *scroller= new QScrollArea; scroller->setFrameStyle( QFrame::NoFrame ); QWidget *scrolled_area = new QWidget; QGridLayout *layout = new QGridLayout(); int i_line = 0, i_boxline = 0; bool has_hotkey = false; if( p_item ) do { if( ( ( data->i_type == TYPE_SUBCATEGORY && p_item->value.i != data->i_object_id ) || ( data->i_type == TYPE_CATSUBCAT && p_item->value.i != data->i_subcat_id ) ) && ( p_item->i_type == CONFIG_CATEGORY || p_item->i_type == CONFIG_SUBCATEGORY ) ) break; if( p_item->b_internal ) continue; if( p_item->i_type == CONFIG_SECTION ) { if( box ) { box->setLayout( boxlayout ); box->show(); layout->addWidget( box, i_line, 0, 1, -1 ); i_line++; } box = new QGroupBox( qtr( p_item->psz_text ), this ); box->hide(); boxlayout = new QGridLayout(); } /* Only one hotkey control */ if( p_item->i_type == CONFIG_ITEM_KEY ) { if( has_hotkey ) continue; has_hotkey = true; } ConfigControl *control; if( ! box ) control = ConfigControl::createControl( VLC_OBJECT( p_intf ), p_item, this, layout, i_line ); else control = ConfigControl::createControl( VLC_OBJECT( p_intf ), p_item, this, boxlayout, i_boxline ); if( !control ) continue; if( box ) i_boxline++; else i_line++; controls.append( control ); } while( !( ( data->i_type == TYPE_SUBCATEGORY || data->i_type == TYPE_CATSUBCAT ) && ( p_item->i_type == CONFIG_CATEGORY || p_item->i_type == CONFIG_SUBCATEGORY ) ) && ( ++p_item < p_end ) ); if( box && i_boxline > 0 ) { box->setLayout( boxlayout ); box->show(); layout->addWidget( box, i_line, 0, 1, -1 ); } scrolled_area->setSizePolicy( QSizePolicy::Preferred,QSizePolicy::Fixed ); scrolled_area->setLayout( layout ); scroller->setWidget( scrolled_area ); scroller->setWidgetResizable( true ); global_layout->addWidget( scroller ); setLayout( global_layout ); }
inline QFont getDateFont(const QStyleOptionViewItem &option) { QFont noteFont = (option.font.pointSize()>0)?option.font:QFont(); noteFont.setPointSize(noteFont.pointSize()+2); return noteFont; }
void FolderViewDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const { QStyledItemDelegate::paint(painter,option,index); QSize s = sizeHint( option, index ); painter->save(); QFont aliasFont = QApplication::font(); QFont subFont = QApplication::font(); //font.setPixelSize(font.weight()+); aliasFont.setBold(true); aliasFont.setPointSize( subFont.pointSize()+2 ); QFontMetrics subFm( subFont ); QFontMetrics aliasFm( aliasFont ); QIcon icon = qvariant_cast<QIcon>(index.data(FolderIconRole)); QIcon statusIcon = qvariant_cast<QIcon>(index.data(FolderStatusIcon)); QString aliasText = qvariant_cast<QString>(index.data(FolderAliasRole)); QString pathText = qvariant_cast<QString>(index.data(FolderPathRole)); QString remotePath = qvariant_cast<QString>(index.data(FolderSecondPathRole)); QString statusText = qvariant_cast<QString>(index.data(FolderStatus)); bool syncEnabled = index.data(FolderSyncEnabled).toBool(); QString syncStatus = syncEnabled? tr( "Enabled" ) : tr( "Disabled" ); QSize iconsize(48,48); // = icon.actualSize(option.decorationSize); QRect aliasRect = option.rect; QRect iconRect = option.rect; iconRect.setRight( iconsize.width()+30 ); iconRect.setTop( iconRect.top() + (iconRect.height()-iconsize.height())/2); aliasRect.setLeft(iconRect.right()); aliasRect.setTop(aliasRect.top() + aliasFm.height()/2 ); aliasRect.setBottom(aliasRect.top()+subFm.height()); // local directory box QRect localPathRect = aliasRect; localPathRect.setTop(aliasRect.bottom() + subFm.height() / 2); localPathRect.setBottom(localPathRect.top()+subFm.height()); // remote directory box QRect remotePathRect = localPathRect; remotePathRect.setTop( localPathRect.bottom() + subFm.height()/2 ); remotePathRect.setBottom( remotePathRect.top() + subFm.height()); //painter->drawPixmap(QPoint(iconRect.right()/2,iconRect.top()/2),icon.pixmap(iconsize.width(),iconsize.height())); painter->drawPixmap(QPoint(iconRect.left()+15,iconRect.top()),icon.pixmap(iconsize.width(),iconsize.height())); painter->drawPixmap(QPoint(option.rect.right() - 4 - 48, option.rect.top() + (option.rect.height()-48)/2 ), statusIcon.pixmap(48,48)); painter->setFont(aliasFont); painter->drawText(aliasRect, aliasText); painter->setFont(subFont); painter->drawText(localPathRect.left(),localPathRect.top()+17, pathText); painter->drawText(remotePathRect, tr("Remote path: %1").arg(remotePath)); // painter->drawText(lastSyncRect, tr("Last Sync: %1").arg( statusText )); // painter->drawText(statusRect, tr("Sync Status: %1").arg( syncStatus )); painter->restore(); }
bool QtnPropertyDelegateQFont::propertyValueToStr(QString& strValue) const { QFont value = owner().value(); strValue = QString("[%1, %2]").arg(value.family()).arg(value.pointSize()); return true; }
void FolderViewDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const { QStyledItemDelegate::paint(painter,option,index); painter->save(); QFont aliasFont = option.font; QFont subFont = option.font; QFont errorFont = subFont; //font.setPixelSize(font.weight()+); aliasFont.setBold(true); aliasFont.setPointSize( subFont.pointSize()+2 ); QFontMetrics subFm( subFont ); QFontMetrics aliasFm( aliasFont ); int aliasMargin = aliasFm.height()/2; int margin = subFm.height()/4; QIcon statusIcon = qvariant_cast<QIcon>(index.data(FolderStatusIconRole)); QString aliasText = qvariant_cast<QString>(index.data(FolderAliasRole)); QString pathText = qvariant_cast<QString>(index.data(FolderPathRole)); QString remotePath = qvariant_cast<QString>(index.data(FolderSecondPathRole)); QString errorText = qvariant_cast<QString>(index.data(FolderErrorMsg)); // QString statusText = qvariant_cast<QString>(index.data(FolderStatus)); bool syncEnabled = index.data(FolderSyncEnabled).toBool(); // QString syncStatus = syncEnabled? tr( "Enabled" ) : tr( "Disabled" ); QRect iconRect = option.rect; QRect aliasRect = option.rect; iconRect.setLeft( aliasMargin ); iconRect.setTop( iconRect.top() + aliasMargin ); // (iconRect.height()-iconsize.height())/2); // local directory box aliasRect.setTop(aliasRect.top() + aliasMargin ); aliasRect.setBottom(aliasRect.top() + aliasFm.height()); aliasRect.setRight(aliasRect.right() - aliasMargin ); // local directory box QRect localPathRect = aliasRect; localPathRect.setTop(aliasRect.bottom() + margin ); localPathRect.setBottom(localPathRect.top() + subFm.height()); // remote directory box QRect remotePathRect = localPathRect; remotePathRect.setTop( localPathRect.bottom() + margin ); remotePathRect.setBottom( remotePathRect.top() + subFm.height()); iconRect.setBottom(remotePathRect.bottom()); iconRect.setWidth(iconRect.height()); int nextToIcon = iconRect.right()+aliasMargin; aliasRect.setLeft(nextToIcon); localPathRect.setLeft(nextToIcon); remotePathRect.setLeft(nextToIcon); int iconSize = iconRect.width(); QPixmap pm = statusIcon.pixmap(iconSize, iconSize, syncEnabled ? QIcon::Normal : QIcon::Disabled ); painter->drawPixmap(QPoint(iconRect.left(), iconRect.top()), pm); if ((option.state & QStyle::State_Selected) && (option.state & QStyle::State_Active) // Hack: Windows Vista's light blue is not contrasting enough for white && !Application::style()->inherits("QWindowsVistaStyle")) { painter->setPen(option.palette.color(QPalette::HighlightedText)); } else { painter->setPen(option.palette.color(QPalette::Text)); } QString elidedAlias = aliasFm.elidedText(aliasText, Qt::ElideRight, aliasRect.width()); painter->setFont(aliasFont); painter->drawText(aliasRect, elidedAlias); painter->setFont(subFont); QString elidedPathText = subFm.elidedText(pathText, Qt::ElideMiddle, localPathRect.width()); painter->drawText(localPathRect, elidedPathText); QString elidedRemotePathText = subFm.elidedText(tr("Remote path: %1").arg(remotePath), Qt::ElideMiddle, remotePathRect.width()); painter->drawText(remotePathRect, elidedRemotePathText); // paint an error overlay if there is an error string if( !errorText.isEmpty() ) { QRect errorRect = localPathRect; errorRect.setLeft( iconRect.left()); errorRect.setTop( iconRect.bottom()+subFm.height()/2 ); errorRect.setHeight(subFm.height()+aliasMargin); errorRect.setRight( option.rect.right()-aliasMargin ); painter->setBrush( QColor(0xbb, 0x4d, 0x4d) ); painter->setPen( QColor(0xaa, 0xaa, 0xaa)); painter->drawRoundedRect( errorRect, 4, 4 ); QIcon warnIcon(":/mirall/resources/warning-16"); QPoint warnPos(errorRect.left()+aliasMargin/2, errorRect.top()+aliasMargin/2); painter->drawPixmap( warnPos, warnIcon.pixmap(QSize(16,16))); painter->setPen( Qt::white ); painter->setFont(errorFont); QRect errorTextRect = errorRect; errorTextRect.setLeft( errorTextRect.left()+aliasMargin +16); errorTextRect.setTop( errorTextRect.top()+aliasMargin/2 ); int linebreak = errorText.indexOf(QLatin1String("<br")); QString eText = errorText; if(linebreak) { eText = errorText.left(linebreak); } painter->drawText(errorTextRect, eText); } // painter->drawText(lastSyncRect, tr("Last Sync: %1").arg( statusText )); // painter->drawText(statusRect, tr("Sync Status: %1").arg( syncStatus )); painter->restore(); }
ScoreItem* ScoreBrowser::genScoreItem(const QFileInfo& fi, ScoreListWidget* l) { ScoreInfo si(fi); QPixmap pm(l->iconSize() * qApp->devicePixelRatio()); if (!QPixmapCache::find(fi.filePath(), &pm)) { //load and scale pixmap QPixmap pixmap = mscore->extractThumbnail(fi.filePath()); if (pixmap.isNull()) pixmap = icons[int(Icons::file_ICON)]->pixmap(QSize(50,60)); pixmap = pixmap.scaled(pm.width() - 2, pm.height() - 2, Qt::KeepAspectRatio, Qt::SmoothTransformation); // draw pixmap and add border pm.fill(Qt::transparent); QPainter painter( &pm ); painter.setRenderHint(QPainter::Antialiasing); painter.setRenderHint(QPainter::TextAntialiasing); painter.drawPixmap(0, 0, pixmap); painter.setPen(QPen(QColor(0, 0, 0, 128), 1)); painter.setBrush(Qt::white); if (fi.baseName() == "00-Blank" || fi.baseName() == "Create_New_Score") { qreal round = 8.0 * qApp->devicePixelRatio(); painter.drawRoundedRect(QRectF(0, 0, pm.width() - 1 , pm.height() - 1), round, round); } else painter.drawRect(0, 0, pm.width() - 1, pm.height() - 1); if (fi.baseName() != "00-Blank") painter.drawPixmap(1, 1, pixmap); painter.end(); QPixmapCache::insert(fi.filePath(), pm); } si.setPixmap(pm); ScoreItem* item = new ScoreItem(si); item->setTextAlignment(Qt::AlignHCenter | Qt::AlignBottom); QFont f = item->font(); f.setPointSize(f.pointSize() - 2.0); f.setBold(_boldTitle); if (fi.baseName() == "00-Blank") { item->setText(tr("Choose Instruments")); f.setBold(true); } else if (fi.baseName() == "Create_New_Score") { item->setText(tr("Create New Score")); f.setBold(true); } else if (fi.baseName() == "Getting_Started") { item->setText(tr("Getting Started")); f.setBold(true); } else { QString s(si.completeBaseName()); if (!s.isEmpty() && s[0].isNumber() && _stripNumbers) s = s.mid(3); s = s.replace('_', ' '); item->setText(s); } item->setFont(f); item->setTextAlignment(Qt::AlignHCenter | Qt::AlignTop); item->setIcon(QIcon(pm)); item->setSizeHint(l->cellSize()); return item; }
//! @return font size expressed in points (pt) //! or if points are not available - in pixels (px) for @a font static QString fontSizeForCSS(const QFont& font) { return font.pointSize() > 0 ? QString::fromLatin1("%1pt").arg(font.pointSize()) : QString::fromLatin1("%1px").arg(font.pixelSize()); }
void tst_QFont::exactMatch() { QFont font; // Check if a non-existing font hasn't an exact match font = QFont( "BogusFont", 33 ); QVERIFY( !font.exactMatch() ); #ifdef Q_WS_WIN QSKIP("Exact matching on windows misses a lot because of the sample chars", SkipAll); return; #endif #ifdef Q_WS_X11 QVERIFY(QFont("sans").exactMatch()); QVERIFY(QFont("sans-serif").exactMatch()); QVERIFY(QFont("serif").exactMatch()); QVERIFY(QFont("monospace").exactMatch()); #endif QSKIP("This test is bogus on Unix with support for font aliases in fontconfig", SkipAll); return; QFontDatabase fdb; QList<QFontDatabase::WritingSystem> systems = fdb.writingSystems(); for (int system = 0; system < systems.count(); ++system) { QStringList families = fdb.families(systems[system]); if (families.isEmpty()) return; QStringList::ConstIterator f_it, f_end = families.end(); for (f_it = families.begin(); f_it != f_end; ++f_it) { const QString &family = *f_it; if (family.contains('[')) continue; QStringList styles = fdb.styles(family); QVERIFY(!styles.isEmpty()); QStringList::ConstIterator s_it, s_end = styles.end(); for (s_it = styles.begin(); s_it != s_end; ++s_it) { const QString &style = *s_it; if (fdb.isSmoothlyScalable(family, style)) { // smoothly scalable font... don't need to load every pointsize font = fdb.font(family, style, 12); QFontInfo fontinfo(font); if (! fontinfo.exactMatch()) { // Unfortunately, this can fail, since // QFontDatabase does not fill in all font // properties. Check to make sure that the // test didn't fail for obvious reasons if (fontinfo.family().isEmpty() && fontinfo.pointSize() == 0) { // this is a box rendering engine... this can happen from // time to time, especially on X11 with iso10646-1 or // unknown font encodings continue; } #ifdef Q_WS_WIN32 if (font.family().startsWith("MS ") || fontinfo.family().startsWith("MS ")) { /* qDebug("Family matching skipped for MS-Alias font: %s, fontinfo: %s", font.family().latin1(), fontinfo.family().latin1()); */ } else #endif { if (!(font.family() == fontinfo.family() || fontinfo.family().contains(font.family()) || fontinfo.family().isEmpty())) { qDebug("Test about to fail for font: %s, fontinfo: %s", font.family().toLatin1().constData(), fontinfo.family().toLatin1().constData()); } QVERIFY(font.family() == fontinfo.family() || fontinfo.family().contains(font.family()) || fontinfo.family().isEmpty()); } if (font.pointSize() != -1) { QVERIFY(font.pointSize() == fontinfo.pointSize()); } else { QVERIFY(font.pixelSize() == fontinfo.pixelSize()); } QVERIFY(font.italic() == fontinfo.italic()); if (font.weight() != fontinfo.weight()) { qDebug("font is %s", font.toString().toLatin1().constData()); } QVERIFY(font.weight() == fontinfo.weight()); } else { font.setFixedPitch(!fontinfo.fixedPitch()); QFontInfo fontinfo1(font); QVERIFY( !fontinfo1.exactMatch() ); font.setFixedPitch(fontinfo.fixedPitch()); QFontInfo fontinfo2(font); QVERIFY( fontinfo2.exactMatch() ); } } #if 0 // ############## can only work if we have float point sizes in QFD else { QList<int> sizes = fdb.pointSizes(family, style); QVERIFY(!sizes.isEmpty()); QList<int>::ConstIterator z_it, z_end = sizes.end(); for (z_it = sizes.begin(); z_it != z_end; ++z_it) { const int size = *z_it; // Initialize the font, and check if it is an exact match font = fdb.font(family, style, size); QFontInfo fontinfo(font, (QFont::Script) script); if (! fontinfo.exactMatch()) { // Unfortunately, this can fail, since // QFontDatabase does not fill in all font // properties. Check to make sure that the // test didn't fail for obvious reasons if (fontinfo.family().isEmpty() && fontinfo.pointSize() == 0) { // this is a box rendering engine... this can happen from // time to time, especially on X11 with iso10646-1 or // unknown font encodings continue; } // no need to skip MS-fonts here it seems if (!(font.family() == fontinfo.family() || fontinfo.family().contains(font.family()) || fontinfo.family().isEmpty())) { qDebug("Test about to fail for font: %s, fontinfo: %s", font.family().latin1(), fontinfo.family().latin1()); } QVERIFY(font.family() == fontinfo.family() || fontinfo.family().contains(font.family()) || fontinfo.family().isEmpty()); if (font.pointSize() != -1) { QVERIFY(font.pointSize() == fontinfo.pointSize()); } else { QVERIFY(font.pixelSize() == fontinfo.pixelSize()); } QVERIFY(font.italic() == fontinfo.italic()); QVERIFY(font.weight() == fontinfo.weight()); } else { font.setFixedPitch(!fontinfo.fixedPitch()); QFontInfo fontinfo1(font, (QFont::Script) script); QVERIFY( !fontinfo1.exactMatch() ); font.setFixedPitch(fontinfo.fixedPitch()); QFontInfo fontinfo2(font, (QFont::Script) script); QVERIFY( fontinfo2.exactMatch() ); } } } #endif } } } }
void CollapsibleControls::init() { m_timeline = new QTimeLine( 250, this ); m_timeline->setUpdateInterval( 5 ); m_animHeight = -1; m_collapseAnimation = false; connect( m_timeline, SIGNAL( frameChanged( int ) ), this, SLOT( onAnimationStep( int ) ) ); connect( m_timeline, SIGNAL( finished() ), this, SLOT( onAnimationFinished() ) ); m_layout = new QStackedLayout; setContentsMargins( 0, 0, 0, 0 ); m_layout->setContentsMargins( 0, 0, 0, 0 ); m_layout->setSpacing( 0 ); m_controls = new Tomahawk::DynamicControlList( this ); m_layout->addWidget( m_controls ); connect( m_controls, SIGNAL( toggleCollapse() ), this, SLOT( toggleCollapse() ) ); m_summaryWidget = new QWidget( this ); m_summaryWidget->setMinimumHeight( 24 ); m_summaryWidget->setMaximumHeight( 24 ); m_summaryWidget->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ); m_summaryLayout = new QHBoxLayout; m_summaryWidget->setLayout( m_summaryLayout ); m_summaryLayout->setMargin( 0 ); m_summaryWidget->setContentsMargins( 3, 0, 0, 0 ); m_summary = new ElidedLabel( m_summaryWidget ); QFont f = m_summary->font(); f.setPointSize( f.pointSize() + 1 ); f.setBold( true ); m_summary->setFont( f ); m_summaryLayout->addWidget( m_summary, 1 ); m_summaryExpand = DynamicControlWrapper::initButton( this ); m_summaryExpand->setIcon( QIcon( RESPATH "images/arrow-down-double.png" ) ); m_expandL = new QStackedLayout; m_expandL->setContentsMargins( 0, 0, 0, 0 ); m_expandL->setMargin( 0 ); m_expandL->addWidget( m_summaryExpand ); m_expandL->addWidget( DynamicControlWrapper::createDummy( m_summaryExpand, this ) ); m_summaryLayout->addLayout( m_expandL ); if( m_isLocal ) m_expandL->setCurrentIndex( 0 ); else m_expandL->setCurrentIndex( 1 ); m_layout->addWidget( m_summaryWidget ); connect( m_summaryExpand, SIGNAL( clicked( bool ) ), this, SLOT( toggleCollapse() ) ); if( m_isLocal ) m_layout->setCurrentWidget( m_controls ); else m_layout->setCurrentWidget( m_summary ); connect( m_controls, SIGNAL( controlChanged( Tomahawk::dyncontrol_ptr ) ), SIGNAL( controlChanged( Tomahawk::dyncontrol_ptr ) ) ); connect( m_controls, SIGNAL( controlsChanged( bool ) ), SIGNAL( controlsChanged( bool ) ) ); setLayout( m_layout ); setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ); }
SimpleRichTextEdit::SimpleRichTextEdit(QWidget *parent) : KTextEdit(parent) { enableFindReplace(false); setCheckSpellingEnabled(true); setAutoFormatting(KTextEdit::AutoNone); setWordWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere); QTextDocument *textDocument = document(); QTextOption textOption; textOption.setAlignment(Qt::AlignCenter); textOption.setWrapMode(QTextOption::NoWrap); textDocument->setDefaultTextOption(textOption); QFont defaultFont = font(); defaultFont.setPointSize(defaultFont.pointSize() + 2); textDocument->setDefaultFont(defaultFont); QString styleSheet("p {" " display: block;" " white-space: pre;" " margin-top: 0px;" " margin-bottom: 0px;" "}"); textDocument->setDefaultStyleSheet(styleSheet); setTextInteractionFlags(Qt::TextEditorInteraction); m_actions[Undo] = new QAction(this); m_actions[Undo]->setIcon(QIcon::fromTheme("edit-undo")); m_actions[Undo]->setText(i18n("Undo")); m_actions[Undo]->setShortcuts(KStandardShortcut::undo()); connect(m_actions[Undo], SIGNAL(triggered()), this, SLOT(undo())); m_actions[Redo] = new QAction(this); m_actions[Redo]->setIcon(QIcon::fromTheme("edit-redo")); m_actions[Redo]->setText(i18n("Redo")); m_actions[Redo]->setShortcuts(KStandardShortcut::redo()); connect(m_actions[Redo], SIGNAL(triggered()), this, SLOT(redo())); m_actions[Cut] = new QAction(this); m_actions[Cut]->setIcon(QIcon::fromTheme("edit-cut")); m_actions[Cut]->setText(i18n("Cut")); m_actions[Cut]->setShortcuts(KStandardShortcut::cut()); connect(m_actions[Cut], SIGNAL(triggered()), this, SLOT(cut())); m_actions[Copy] = new QAction(this); m_actions[Copy]->setIcon(QIcon::fromTheme("edit-copy")); m_actions[Copy]->setText(i18n("Copy")); m_actions[Copy]->setShortcuts(KStandardShortcut::copy()); connect(m_actions[Copy], SIGNAL(triggered()), this, SLOT(copy())); #if !defined(QT_NO_CLIPBOARD) m_actions[Paste] = new QAction(this); m_actions[Paste]->setIcon(QIcon::fromTheme("edit-paste")); m_actions[Paste]->setText(i18n("Paste")); m_actions[Paste]->setShortcuts(KStandardShortcut::paste()); connect(m_actions[Paste], SIGNAL(triggered()), this, SLOT(paste())); #endif m_actions[Delete] = new QAction(this); m_actions[Delete]->setIcon(QIcon::fromTheme("edit-delete")); m_actions[Delete]->setText(i18n("Delete")); m_actions[Delete]->setShortcut(QKeySequence::Delete); connect(m_actions[Delete], SIGNAL(triggered()), this, SLOT(deleteText())); m_actions[Clear] = new QAction(this); m_actions[Clear]->setIcon(QIcon::fromTheme("edit-clear")); m_actions[Clear]->setText(i18nc("@action:inmenu Clear all text", "Clear")); connect(m_actions[Clear], SIGNAL(triggered()), this, SLOT(undoableClear())); m_actions[SelectAll] = new QAction(this); m_actions[SelectAll]->setIcon(QIcon::fromTheme("edit-select-all")); m_actions[SelectAll]->setText(i18n("Select All")); m_actions[SelectAll]->setShortcut(QKeySequence::SelectAll); connect(m_actions[SelectAll], SIGNAL(triggered()), this, SLOT(selectAll())); m_actions[ToggleBold] = new QAction(this); m_actions[ToggleBold]->setIcon(QIcon::fromTheme("format-text-bold")); m_actions[ToggleBold]->setText(i18nc("@action:inmenu Toggle bold style", "Bold")); m_actions[ToggleBold]->setShortcut(QKeySequence("Ctrl+B")); connect(m_actions[ToggleBold], SIGNAL(triggered()), this, SLOT(toggleFontBold())); m_actions[ToggleItalic] = new QAction(this); m_actions[ToggleItalic]->setIcon(QIcon::fromTheme("format-text-italic")); m_actions[ToggleItalic]->setText(i18nc("@action:inmenu Toggle italic style", "Italic")); m_actions[ToggleItalic]->setShortcut(QKeySequence("Ctrl+I")); connect(m_actions[ToggleItalic], SIGNAL(triggered()), this, SLOT(toggleFontItalic())); m_actions[ToggleUnderline] = new QAction(this); m_actions[ToggleUnderline]->setIcon(QIcon::fromTheme("format-text-underline")); m_actions[ToggleUnderline]->setText(i18nc("@action:inmenu Toggle underline style", "Underline")); m_actions[ToggleUnderline]->setShortcut(QKeySequence("Ctrl+U")); connect(m_actions[ToggleUnderline], SIGNAL(triggered()), this, SLOT(toggleFontUnderline())); m_actions[ToggleStrikeOut] = new QAction(this); m_actions[ToggleStrikeOut]->setIcon(QIcon::fromTheme("format-text-strikethrough")); m_actions[ToggleStrikeOut]->setText(i18nc("@action:inmenu Toggle strike through style", "Strike Through")); m_actions[ToggleStrikeOut]->setShortcut(QKeySequence("Ctrl+T")); connect(m_actions[ToggleStrikeOut], SIGNAL(triggered()), this, SLOT(toggleFontStrikeOut())); m_actions[ChangeTextColor] = new QAction(this); m_actions[ChangeTextColor]->setIcon(QIcon::fromTheme("format-text-color")); m_actions[ChangeTextColor]->setText(i18nc("@action:inmenu Change Text Color", "Text Color")); m_actions[ChangeTextColor]->setShortcut(QKeySequence("Ctrl+Shift+C")); connect(m_actions[ChangeTextColor], SIGNAL(triggered()), this, SLOT(changeTextColor())); m_actions[CheckSpelling] = new QAction(this); m_actions[CheckSpelling]->setIcon(QIcon::fromTheme("tools-check-spelling")); m_actions[CheckSpelling]->setText(i18n("Check Spelling...")); connect(m_actions[CheckSpelling], SIGNAL(triggered()), this, SLOT(checkSpelling())); m_actions[ToggleAutoSpellChecking] = new QAction(this); m_actions[ToggleAutoSpellChecking]->setText(i18n("Auto Spell Check")); m_actions[ToggleAutoSpellChecking]->setCheckable(true); connect(m_actions[ToggleAutoSpellChecking], SIGNAL(triggered()), this, SLOT(toggleAutoSpellChecking())); m_actions[AllowTabulations] = new QAction(this); m_actions[AllowTabulations]->setText(i18n("Allow Tabulations")); connect(m_actions[AllowTabulations], SIGNAL(triggered()), this, SLOT(toggleTabChangesFocus())); QMenu *menu = createStandardContextMenu(); menu->setParent(this); QList<QAction *> actions = menu->actions(); m_insertUnicodeControlCharMenu = 0; for(QList<QAction *>::ConstIterator it = actions.constBegin(), end = actions.constEnd(); it != end; ++it) { if((*it)->menu()) { // this depends on Qt private implementation but at least is guaranteed // to behave reasonably if that implementation changes in the future. if(!strcmp((*it)->menu()->metaObject()->className(), "QUnicodeControlCharacterMenu")) { m_insertUnicodeControlCharMenu = (*it)->menu(); break; } } } }
void MainWindow::btnExportClicked() { QList<QChar> charset; if (chkLowerAZ->isChecked()) for (char c = 'a'; c <= 'z'; c++) charset.append(c); if (chkUpperAZ->isChecked()) for (char c = 'A'; c <= 'Z'; c++) charset.append(c); if (chkNumbers->isChecked()) for (char c = '0'; c <= '9'; c++) charset.append(c); QString str = ldtCharacters->text(); for (QString::const_iterator itr(str.begin()); itr != str.end(); itr++) if (!charset.contains(*itr)) charset.append(*itr); qSort(charset); // Render characters QFont font = fontSelector->currentFont(); font.setPixelSize(font.pointSize()); QFontMetrics metrics = QFontMetrics(font); QTextCodec *codec = QTextCodec::codecForName("utf-8"); QString glyphs; QString fontName = QString("font_%1%2") .arg(font.family().toLower()) .arg(font.pixelSize()) .replace(' ', '_'); QString fontstruct = QString( "const struct glib_font %1 = {\n" " .charcount = %2,\n" " .size = %3,\n" " .glyphs = {\n ") .arg(fontName) .arg(charset.size()) .arg(font.pixelSize()); QListIterator<QChar> itr(charset); while (itr.hasNext()) { QChar c = itr.next(); if (c == ' ') { // Add space character fontstruct += QString("{.utf8 = 0x20, .x = %1, .y = 0, .bitmap = NULL}") .arg(metrics.width(' ')); } else { QRect boundingRect = metrics.boundingRect(c); QImage image = QImage(boundingRect.width(), boundingRect.height(), QImage::Format_Mono); image.fill(Qt::color1); QPainter p; p.begin(&image); p.setFont(font); p.setWindow(metrics.boundingRect(c)); p.drawText(0, 0, c); p.end(); QString utf8 = codec->fromUnicode(c).toHex(); glyphs += renderGlyph(utf8, image); fontstruct += QString("{.utf8 = 0x%1, .x = %2, .y = %3, .bitmap = &glyph_%1}") .arg(utf8) .arg(boundingRect.x() + 1) .arg(boundingRect.y() - metrics.descent() + 1); // +1 for the base line } if (itr.hasNext()) fontstruct += ",\n "; } fontstruct += "\n }\n};\n"; glyphs = "#include <liblcd/glib.h>\n\n" + glyphs + "\n" + fontstruct; QString filename = QFileDialog::getSaveFileName(this, tr("Save Font"), fontName + ".c", tr("Source Files (*.c *.cpp)")); if (!filename.isEmpty()) { if (!(filename.endsWith(".c") || filename.endsWith(".cpp"))) filename += ".c"; QFile file(filename); if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) return; QTextStream out(&file); out << glyphs; file.close(); } }
void QtWebKitHelpViewer::setViewerFont(const QFont &font) { QWebSettings *webSettings = m_webView->settings(); webSettings->setFontFamily(QWebSettings::StandardFont, font.family()); webSettings->setFontSize(QWebSettings::DefaultFontSize, font.pointSize()); }
ArtistWidget::ArtistWidget( const SimilarArtistPtr &artist, QGraphicsWidget *parent, Qt::WindowFlags wFlags ) : QGraphicsWidget( parent, wFlags ) , m_artist( artist ) { setAttribute( Qt::WA_NoSystemBackground, true ); m_image = new QLabel; m_image->setAttribute( Qt::WA_NoSystemBackground, true ); m_image->setFixedSize( 128, 128 ); m_image->setCursor( Qt::PointingHandCursor ); QGraphicsProxyWidget *imageProxy = new QGraphicsProxyWidget( this ); imageProxy->setWidget( m_image ); m_image->installEventFilter( this ); m_nameLabel = new QLabel; m_match = new QLabel; m_tagsLabel = new QLabel; m_topTrackLabel = new QLabel; m_bio = new QGraphicsWidget( this ); QGraphicsProxyWidget *nameProxy = new QGraphicsProxyWidget( this ); QGraphicsProxyWidget *matchProxy = new QGraphicsProxyWidget( this ); QGraphicsProxyWidget *topTrackProxy = new QGraphicsProxyWidget( this ); QGraphicsProxyWidget *tagsProxy = new QGraphicsProxyWidget( this ); nameProxy->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Preferred ); matchProxy->setSizePolicy( QSizePolicy::Maximum, QSizePolicy::Preferred ); topTrackProxy->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Preferred ); tagsProxy->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Preferred ); imageProxy->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Preferred ); nameProxy->setWidget( m_nameLabel ); matchProxy->setWidget( m_match ); topTrackProxy->setWidget( m_topTrackLabel ); tagsProxy->setWidget( m_tagsLabel ); m_nameLabel->setAttribute( Qt::WA_NoSystemBackground ); m_match->setAttribute( Qt::WA_NoSystemBackground ); m_topTrackLabel->setAttribute( Qt::WA_NoSystemBackground ); m_tagsLabel->setAttribute( Qt::WA_NoSystemBackground ); m_image->setAlignment( Qt::AlignCenter ); m_match->setAlignment( Qt::AlignRight | Qt::AlignVCenter ); m_nameLabel->setAlignment( Qt::AlignLeft | Qt::AlignVCenter ); m_topTrackLabel->setAlignment( Qt::AlignLeft | Qt::AlignVCenter ); m_tagsLabel->setAlignment( Qt::AlignLeft | Qt::AlignVCenter ); m_nameLabel->setWordWrap( false ); m_match->setWordWrap( false ); m_topTrackLabel->setWordWrap( false ); m_tagsLabel->setWordWrap( false ); m_match->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Preferred ); m_topTrackLabel->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Preferred ); m_match->setMinimumWidth( 10 ); m_topTrackLabel->setMinimumWidth( 10 ); m_nameLabel->setMinimumWidth( 10 ); m_tagsLabel->setMinimumWidth( 10 ); QFontMetricsF fm( font() ); m_bio->setMinimumHeight( fm.lineSpacing() * 5 ); m_bio->setMaximumHeight( fm.lineSpacing() * 5 ); m_bio->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Preferred ); m_bioLayout.setCacheEnabled( true ); QFont artistFont; artistFont.setPointSize( artistFont.pointSize() + 2 ); artistFont.setBold( true ); m_nameLabel->setFont( artistFont ); m_topTrackLabel->setFont( KGlobalSettings::smallestReadableFont() ); m_tagsLabel->setFont( KGlobalSettings::smallestReadableFont() ); m_match->setFont( KGlobalSettings::smallestReadableFont() ); m_navigateButton = new Plasma::PushButton( this ); m_navigateButton->setMaximumSize( QSizeF( 22, 22 ) ); m_navigateButton->setIcon( KIcon( "edit-find" ) ); m_navigateButton->setToolTip( i18n( "Show in Media Sources" ) ); connect( m_navigateButton, SIGNAL(clicked()), this, SLOT(navigateToArtist()) ); m_lastfmStationButton = new Plasma::PushButton( this ); m_lastfmStationButton->setMaximumSize( QSizeF( 22, 22 ) ); m_lastfmStationButton->setIcon( KIcon("view-services-lastfm-amarok") ); m_lastfmStationButton->setToolTip( i18n( "Add Last.fm artist station to the Playlist" ) ); connect( m_lastfmStationButton, SIGNAL(clicked()), this, SLOT(addLastfmArtistStation()) ); m_topTrackButton = new Plasma::PushButton( this ); m_topTrackButton->setMaximumSize( QSizeF( 22, 22 ) ); m_topTrackButton->setIcon( KIcon( "media-track-add-amarok" ) ); m_topTrackButton->setToolTip( i18n( "Add top track to the Playlist" ) ); m_topTrackButton->hide(); connect( m_topTrackButton, SIGNAL(clicked()), this, SLOT(addTopTrackToPlaylist()) ); m_similarArtistButton = new Plasma::PushButton( this ); m_similarArtistButton->setMaximumSize( QSizeF( 22, 22 ) ); m_similarArtistButton->setIcon( KIcon( "similarartists-amarok" ) ); m_similarArtistButton->setToolTip( i18n( "Show Similar Artists of %1", m_artist->name() ) ); connect( m_similarArtistButton, SIGNAL(clicked()), this, SIGNAL(showSimilarArtists()) ); QGraphicsLinearLayout *buttonsLayout = new QGraphicsLinearLayout( Qt::Horizontal ); buttonsLayout->setSizePolicy( QSizePolicy::Maximum, QSizePolicy::Preferred ); buttonsLayout->addItem( m_topTrackButton ); buttonsLayout->addItem( m_navigateButton ); buttonsLayout->addItem( m_lastfmStationButton ); QString artistUrl = m_artist->url().url(); if( !artistUrl.isEmpty() ) { m_urlButton = new Plasma::PushButton( this ); m_urlButton->setMaximumSize( QSizeF( 22, 22 ) ); m_urlButton->setIcon( KIcon("applications-internet") ); m_urlButton->setToolTip( i18n( "Open Last.fm webpage for this artist" ) ); connect( m_urlButton, SIGNAL(clicked()), this, SLOT(openArtistUrl()) ); buttonsLayout->addItem( m_urlButton ); } buttonsLayout->addItem( m_similarArtistButton ); // the image display is extended on two row m_layout = new QGraphicsGridLayout( this ); m_layout->addItem( imageProxy, 0, 0, 4, 1 ); m_layout->addItem( nameProxy, 0, 1 ); m_layout->addItem( buttonsLayout, 0, 2, Qt::AlignRight ); m_layout->addItem( topTrackProxy, 1, 1 ); m_layout->addItem( matchProxy, 1, 2, Qt::AlignRight ); m_layout->addItem( tagsProxy, 2, 1, 1, 2 ); m_layout->addItem( m_bio, 3, 1, 1, 2 ); m_match->setText( i18n( "Match: %1%", QString::number( m_artist->match() ) ) ); m_nameLabel->setText( m_artist->name() ); QTimer::singleShot( 0, this, SLOT(updateInfo()) ); }
VolControl::VolControl(OBSSource source_) : source (source_), signalChanged (true), lastMeterTime (0), levelTotal (0.0f), levelCount (0.0f) { QVBoxLayout *mainLayout = new QVBoxLayout(); QHBoxLayout *textLayout = new QHBoxLayout(); int vol = int(obs_source_getvolume(source) * 100.0f); nameLabel = new QLabel(); volLabel = new QLabel(); volMeter = new QProgressBar(); slider = new QSlider(Qt::Horizontal); QFont font = nameLabel->font(); font.setPointSize(font.pointSize()-1); nameLabel->setText(obs_source_getname(source)); nameLabel->setFont(font); volLabel->setText(QString::number(vol)); volLabel->setFont(font); slider->setMinimum(0); slider->setMaximum(100); slider->setValue(vol); // slider->setMaximumHeight(13); volMeter->setMaximumHeight(1); volMeter->setMinimum(0); volMeter->setMaximum(10000); volMeter->setTextVisible(false); /* [Danni] Temporary color. */ QString testColor = "QProgressBar " "{border: 0px} " "QProgressBar::chunk " "{width: 1px; background-color: #AA0000;}"; volMeter->setStyleSheet(testColor); textLayout->setContentsMargins(0, 0, 0, 0); textLayout->addWidget(nameLabel); textLayout->addWidget(volLabel); textLayout->setAlignment(nameLabel, Qt::AlignLeft); textLayout->setAlignment(volLabel, Qt::AlignRight); mainLayout->setContentsMargins(4, 4, 4, 4); mainLayout->setSpacing(2); mainLayout->addItem(textLayout); mainLayout->addWidget(volMeter); mainLayout->addWidget(slider); setLayout(mainLayout); signal_handler_connect(obs_source_signalhandler(source), "volume", OBSVolumeChanged, this); signal_handler_connect(obs_source_signalhandler(source), "volume_level", OBSVolumeLevel, this); QWidget::connect(slider, SIGNAL(valueChanged(int)), this, SLOT(SliderChanged(int))); }
virtual QFont font(const QFont &f, Item, int) const { QFont f2 = f; f2.setPointSize((int)(f.pointSize() * 0.75)); return f2; }
/********************************************************************* * The Panels *********************************************************************/ SPrefsPanel::SPrefsPanel( intf_thread_t *_p_intf, QWidget *_parent, int _number, bool small ) : QWidget( _parent ), p_intf( _p_intf ) { module_config_t *p_config; ConfigControl *control; number = _number; #define CONFIG_GENERIC( option, type, label, qcontrol ) \ p_config = config_FindConfig( VLC_OBJECT(p_intf), option ); \ if( p_config ) \ { \ control = new type ## ConfigControl( VLC_OBJECT(p_intf), \ p_config, label, ui.qcontrol, false ); \ controls.append( control ); \ } \ else { \ ui.qcontrol->setEnabled( false ); \ if( label ) label->setEnabled( false ); \ } #define CONFIG_BOOL( option, qcontrol ) \ p_config = config_FindConfig( VLC_OBJECT(p_intf), option ); \ if( p_config ) \ { \ control = new BoolConfigControl( VLC_OBJECT(p_intf), \ p_config, NULL, ui.qcontrol, false ); \ controls.append( control ); \ } \ else { ui.qcontrol->setEnabled( false ); } #define CONFIG_GENERIC_NO_UI( option, type, label, qcontrol ) \ p_config = config_FindConfig( VLC_OBJECT(p_intf), option ); \ if( p_config ) \ { \ control = new type ## ConfigControl( VLC_OBJECT(p_intf), \ p_config, label, qcontrol, false ); \ controls.append( control ); \ } \ else { \ QWidget *widget = label; \ qcontrol->setVisible( false ); \ if( widget ) widget->setEnabled( false ); \ } #define CONFIG_GENERIC_NO_BOOL( option, type, label, qcontrol ) \ p_config = config_FindConfig( VLC_OBJECT(p_intf), option ); \ if( p_config ) \ { \ control = new type ## ConfigControl( VLC_OBJECT(p_intf), \ p_config, label, ui.qcontrol ); \ controls.append( control ); \ } #define CONFIG_GENERIC_FILE( option, type, label, qcontrol, qbutton ) \ p_config = config_FindConfig( VLC_OBJECT(p_intf), option ); \ if( p_config ) \ { \ control = new type ## ConfigControl( VLC_OBJECT(p_intf), \ p_config, label, qcontrol, qbutton ); \ controls.append( control ); \ } #define START_SPREFS_CAT( name , label ) \ case SPrefs ## name: \ { \ Ui::SPrefs ## name ui; \ ui.setupUi( panel ); \ panel_label->setText( label ); #define END_SPREFS_CAT \ break; \ } QVBoxLayout *panel_layout = new QVBoxLayout(); QWidget *panel = new QWidget(); panel_layout->setMargin( 3 ); // Title Label QLabel *panel_label = new QLabel; QFont labelFont = QApplication::font( static_cast<QWidget*>(0) ); labelFont.setPointSize( labelFont.pointSize() + 6 ); labelFont.setFamily( "Verdana" ); panel_label->setFont( labelFont ); // Title <hr> QFrame *title_line = new QFrame; title_line->setFrameShape(QFrame::HLine); title_line->setFrameShadow(QFrame::Sunken); QFont italicFont = QApplication::font( static_cast<QWidget*>(0) ); italicFont.setItalic( true ); switch( number ) { /****************************** * VIDEO Panel Implementation * ******************************/ START_SPREFS_CAT( Video , qtr("Video Settings") ); CONFIG_BOOL( "video", enableVideo ); CONFIG_BOOL( "fullscreen", fullscreen ); CONFIG_BOOL( "overlay", overlay ); CONFIG_BOOL( "video-on-top", alwaysOnTop ); CONFIG_BOOL( "video-deco", windowDecorations ); CONFIG_BOOL( "skip-frames", skipFrames ); CONFIG_GENERIC( "vout", Module, ui.voutLabel, outputModule ); CONFIG_BOOL( "video-wallpaper", wallpaperMode ); #ifdef WIN32 CONFIG_GENERIC( "directx-device", StringList, ui.dxDeviceLabel, dXdisplayDevice ); CONFIG_BOOL( "directx-hw-yuv", hwYUVBox ); #else ui.directXBox->setVisible( false ); ui.hwYUVBox->setVisible( false ); #endif CONFIG_GENERIC( "deinterlace", IntegerList, ui.deinterLabel, deinterlaceBox ); CONFIG_GENERIC( "deinterlace-mode", StringList, ui.deinterModeLabel, deinterlaceModeBox ); CONFIG_GENERIC( "aspect-ratio", String, ui.arLabel, arLine ); CONFIG_GENERIC_FILE( "snapshot-path", Directory, ui.dirLabel, ui.snapshotsDirectory, ui.snapshotsDirectoryBrowse ); CONFIG_GENERIC( "snapshot-prefix", String, ui.prefixLabel, snapshotsPrefix ); CONFIG_BOOL( "snapshot-sequential", snapshotsSequentialNumbering ); CONFIG_GENERIC( "snapshot-format", StringList, ui.arLabel, snapshotsFormat ); END_SPREFS_CAT; /****************************** * AUDIO Panel Implementation * ******************************/ START_SPREFS_CAT( Audio, qtr("Audio Settings") ); CONFIG_BOOL( "audio", enableAudio ); ui.SPrefsAudio_zone->setEnabled( ui.enableAudio->isChecked() ); CONNECT( ui.enableAudio, toggled( bool ), ui.SPrefsAudio_zone, setEnabled( bool ) ); #define audioCommon( name ) \ QWidget * name ## Control = new QWidget( ui.outputAudioBox ); \ QHBoxLayout * name ## Layout = new QHBoxLayout( name ## Control); \ name ## Layout->setMargin( 0 ); \ name ## Layout->setSpacing( 0 ); \ QLabel * name ## Label = new QLabel( qtr( "Device:" ), name ## Control ); \ name ## Label->setMinimumSize(QSize(250, 0)); \ name ## Layout->addWidget( name ## Label ); \ #define audioControl( name) \ audioCommon( name ) \ QComboBox * name ## Device = new QComboBox( name ## Control ); \ name ## Layout->addWidget( name ## Device ); \ name ## Label->setBuddy( name ## Device ); \ outputAudioLayout->addWidget( name ## Control, outputAudioLayout->rowCount(), 0, 1, -1 ); #define audioControl2( name) \ audioCommon( name ) \ QLineEdit * name ## Device = new QLineEdit( name ## Control ); \ name ## Layout->addWidget( name ## Device ); \ name ## Label->setBuddy( name ## Device ); \ QPushButton * name ## Browse = new QPushButton( qtr( "Browse..." ), name ## Control); \ name ## Layout->addWidget( name ## Browse ); \ outputAudioLayout->addWidget( name ## Control, outputAudioLayout->rowCount(), 0, 1, -1 ); /* Build if necessary */ QGridLayout * outputAudioLayout = qobject_cast<QGridLayout *>(ui.outputAudioBox->layout()); #ifdef WIN32 audioControl( DirectX ); optionWidgets.append( DirectXControl ); CONFIG_GENERIC_NO_UI( "directx-audio-device-name", StringList, DirectXLabel, DirectXDevice ); #else if( module_exists( "alsa" ) ) { audioControl( alsa ); optionWidgets.append( alsaControl ); CONFIG_GENERIC_NO_UI( "alsa-audio-device" , StringList, alsaLabel, alsaDevice ); } else optionWidgets.append( NULL ); if( module_exists( "oss" ) ) { audioControl2( OSS ); optionWidgets.append( OSSControl ); CONFIG_GENERIC_FILE( "oss-audio-device" , File, NULL, OSSDevice, OSSBrowse ); } else optionWidgets.append( NULL ); #endif #undef audioControl2 #undef audioControl #undef audioCommon /* Audio Options */ CONFIG_GENERIC_NO_BOOL( "volume" , IntegerRangeSlider, NULL, defaultVolume ); CONNECT( ui.defaultVolume, valueChanged( int ), this, updateAudioVolume( int ) ); CONFIG_BOOL( "qt-autosave-volume", keepVolumeRadio ); ui.defaultVolume_zone->setEnabled( ui.resetVolumeRadio->isChecked() ); CONNECT( ui.resetVolumeRadio, toggled( bool ), ui.defaultVolume_zone, setEnabled( bool ) ); CONFIG_GENERIC( "audio-language" , String , ui.langLabel, preferredAudioLanguage ); CONFIG_BOOL( "spdif", spdifBox ); CONFIG_GENERIC( "force-dolby-surround", IntegerList, ui.dolbyLabel, detectionDolby ); CONFIG_GENERIC_NO_BOOL( "norm-max-level" , Float, NULL, volNormSpin ); CONFIG_GENERIC( "audio-replay-gain-mode", StringList, ui.replayLabel, replayCombo ); CONFIG_GENERIC( "audio-visual" , Module , ui.visuLabel, visualisation); CONFIG_BOOL( "audio-time-stretch", autoscaleBox ); /* Audio Output Specifics */ CONFIG_GENERIC( "aout", Module, ui.outputLabel, outputModule ); CONNECT( ui.outputModule, currentIndexChanged( int ), this, updateAudioOptions( int ) ); /* File output exists on all platforms */ CONFIG_GENERIC_FILE( "audiofile-file", File, ui.fileLabel, ui.fileName, ui.fileBrowseButton ); optionWidgets.append( ui.fileControl ); optionWidgets.append( ui.outputModule ); optionWidgets.append( ui.volNormBox ); /*Little mofification of ui.volumeValue to compile with Qt < 4.3 */ ui.volumeValue->setButtonSymbols(QAbstractSpinBox::NoButtons); optionWidgets.append( ui.volumeValue ); optionWidgets.append( ui.headphoneEffect ); optionWidgets.append( ui.spdifBox ); updateAudioOptions( ui.outputModule->currentIndex() ); /* LastFM */ if( module_exists( "audioscrobbler" ) ) { CONFIG_GENERIC( "lastfm-username", String, ui.lastfm_user_label, lastfm_user_edit ); CONFIG_GENERIC( "lastfm-password", String, ui.lastfm_pass_label, lastfm_pass_edit ); if( config_ExistIntf( VLC_OBJECT( p_intf ), "audioscrobbler" ) ) ui.lastfm->setChecked( true ); else ui.lastfm->setChecked( false ); ui.lastfm_zone->setVisible( ui.lastfm->isChecked() ); CONNECT( ui.lastfm, toggled( bool ), ui.lastfm_zone, setVisible( bool ) ); CONNECT( ui.lastfm, stateChanged( int ), this, lastfm_Changed( int ) ); } else {
LTMWindow::LTMWindow(Context *context) : GcChartWindow(context), context(context), dirty(true), stackDirty(true), compareDirty(true) { useToToday = useCustom = false; plotted = DateRange(QDate(01,01,01), QDate(01,01,01)); // the plot QVBoxLayout *mainLayout = new QVBoxLayout; ltmPlot = new LTMPlot(this, context, true); // the stack of plots QPalette palette; palette.setBrush(QPalette::Background, QBrush(GColor(CPLOTBACKGROUND))); plotsWidget = new QWidget(this); plotsWidget->setPalette(palette); plotsLayout = new QVBoxLayout(plotsWidget); plotsLayout->setSpacing(0); plotsLayout->setContentsMargins(0,0,0,0); plotArea = new QScrollArea(this); #ifdef Q_OS_WIN QStyle *cde = QStyleFactory::create(OS_STYLE); plotArea->setStyle(cde); #endif plotArea->setAutoFillBackground(false); plotArea->setWidgetResizable(true); plotArea->setWidget(plotsWidget); plotArea->setFrameStyle(QFrame::NoFrame); plotArea->setContentsMargins(0,0,0,0); plotArea->setPalette(palette); // the data table dataSummary = new QWebView(this); dataSummary->setContentsMargins(0,0,0,0); dataSummary->page()->view()->setContentsMargins(0,0,0,0); dataSummary->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); dataSummary->setAcceptDrops(false); QFont defaultFont; // mainwindow sets up the defaults.. we need to apply dataSummary->settings()->setFontSize(QWebSettings::DefaultFontSize, defaultFont.pointSize()+1); dataSummary->settings()->setFontFamily(QWebSettings::StandardFont, defaultFont.family()); // compare plot page compareplotsWidget = new QWidget(this); compareplotsWidget->setPalette(palette); compareplotsLayout = new QVBoxLayout(compareplotsWidget); compareplotsLayout->setSpacing(0); compareplotsLayout->setContentsMargins(0,0,0,0); compareplotArea = new QScrollArea(this); #ifdef Q_OS_WIN cde = QStyleFactory::create(OS_STYLE); compareplotArea->setStyle(cde); #endif compareplotArea->setAutoFillBackground(false); compareplotArea->setWidgetResizable(true); compareplotArea->setWidget(compareplotsWidget); compareplotArea->setFrameStyle(QFrame::NoFrame); compareplotArea->setContentsMargins(0,0,0,0); compareplotArea->setPalette(palette); // the stack stackWidget = new QStackedWidget(this); stackWidget->addWidget(ltmPlot); stackWidget->addWidget(dataSummary); stackWidget->addWidget(plotArea); stackWidget->addWidget(compareplotArea); stackWidget->setCurrentIndex(0); mainLayout->addWidget(stackWidget); setChartLayout(mainLayout); // reveal controls QHBoxLayout *revealLayout = new QHBoxLayout; revealLayout->setContentsMargins(0,0,0,0); revealLayout->addStretch(); revealLayout->addWidget(new QLabel(tr("Group by"),this)); rGroupBy = new QxtStringSpinBox(this); QStringList strings; strings << tr("Days") << tr("Weeks") << tr("Months") << tr("Years") << tr("Time Of Day") << tr("All"); rGroupBy->setStrings(strings); rGroupBy->setValue(0); revealLayout->addWidget(rGroupBy); rData = new QCheckBox(tr("Data Table"), this); rStack = new QCheckBox(tr("Stacked"), this); QVBoxLayout *checks = new QVBoxLayout; checks->setSpacing(2); checks->setContentsMargins(0,0,0,0); checks->addWidget(rData); checks->addWidget(rStack); revealLayout->addLayout(checks); revealLayout->addStretch(); setRevealLayout(revealLayout); // the controls QWidget *c = new QWidget; c->setContentsMargins(0,0,0,0); QVBoxLayout *cl = new QVBoxLayout(c); cl->setContentsMargins(0,0,0,0); cl->setSpacing(0); setControls(c); // the popup popup = new GcPane(); ltmPopup = new LTMPopup(context); QVBoxLayout *popupLayout = new QVBoxLayout(); popupLayout->addWidget(ltmPopup); popup->setLayout(popupLayout); ltmTool = new LTMTool(context, &settings); // initialise settings.ltmTool = ltmTool; settings.data = NULL; settings.groupBy = LTM_DAY; settings.legend = ltmTool->showLegend->isChecked(); settings.events = ltmTool->showEvents->isChecked(); settings.shadeZones = ltmTool->shadeZones->isChecked(); settings.showData = ltmTool->showData->isChecked(); settings.stack = ltmTool->showStack->isChecked(); settings.stackWidth = ltmTool->stackSlider->value(); rData->setChecked(ltmTool->showData->isChecked()); rStack->setChecked(ltmTool->showStack->isChecked()); cl->addWidget(ltmTool); connect(this, SIGNAL(dateRangeChanged(DateRange)), this, SLOT(dateRangeChanged(DateRange))); connect(ltmTool, SIGNAL(filterChanged()), this, SLOT(filterChanged())); connect(context, SIGNAL(homeFilterChanged()), this, SLOT(filterChanged())); connect(ltmTool->groupBy, SIGNAL(currentIndexChanged(int)), this, SLOT(groupBySelected(int))); connect(rGroupBy, SIGNAL(valueChanged(int)), this, SLOT(rGroupBySelected(int))); connect(ltmTool->applyButton, SIGNAL(clicked(bool)), this, SLOT(applyClicked(void))); connect(ltmTool->shadeZones, SIGNAL(stateChanged(int)), this, SLOT(shadeZonesClicked(int))); connect(ltmTool->showData, SIGNAL(stateChanged(int)), this, SLOT(showDataClicked(int))); connect(rData, SIGNAL(stateChanged(int)), this, SLOT(showDataClicked(int))); connect(ltmTool->showStack, SIGNAL(stateChanged(int)), this, SLOT(showStackClicked(int))); connect(rStack, SIGNAL(stateChanged(int)), this, SLOT(showStackClicked(int))); connect(ltmTool->stackSlider, SIGNAL(valueChanged(int)), this, SLOT(zoomSliderChanged())); connect(ltmTool->showLegend, SIGNAL(stateChanged(int)), this, SLOT(showLegendClicked(int))); connect(ltmTool->showEvents, SIGNAL(stateChanged(int)), this, SLOT(showEventsClicked(int))); connect(ltmTool, SIGNAL(useCustomRange(DateRange)), this, SLOT(useCustomRange(DateRange))); connect(ltmTool, SIGNAL(useThruToday()), this, SLOT(useThruToday())); connect(ltmTool, SIGNAL(useStandardRange()), this, SLOT(useStandardRange())); connect(ltmTool, SIGNAL(curvesChanged()), this, SLOT(refresh())); connect(context, SIGNAL(filterChanged()), this, SLOT(refresh())); // comparing things connect(context, SIGNAL(compareDateRangesStateChanged(bool)), this, SLOT(compareChanged())); connect(context, SIGNAL(compareDateRangesChanged()), this, SLOT(compareChanged())); connect(context, SIGNAL(rideAdded(RideItem*)), this, SLOT(refresh(void))); connect(context, SIGNAL(rideDeleted(RideItem*)), this, SLOT(refresh(void))); connect(context, SIGNAL(configChanged()), this, SLOT(configChanged())); connect(context, SIGNAL(presetSelected(int)), this, SLOT(presetSelected(int))); configChanged(); }
void updateEditor() override { QFont font = property(); editor().lineEdit->setText(QString("[%1, %2]").arg(font.family()).arg(font.pointSize())); }
void SettingsDialog::chooseFont() { bool ok; QFont font = QFontDialog::getFont(&ok, m_standardFont, this); if (ok) { m_standardFont = font; standardLabel->setText(QString(QLatin1String("%1 %2")).arg(font.family()).arg(font.pointSize())); } }
QString QtPropertyBrowserUtils::fontValueText(const QFont &f) { return QApplication::translate("QtPropertyBrowserUtils", "[%1, %2]", 0, QApplication::UnicodeUTF8) .arg(f.family()) .arg(f.pointSize()); }
void LegendItem::setFont(const QFont &f, const QColor &c) { setLegendColor(c); setLegendFont(f); setFontScale(f.pointSize()); }
//! [0] Calculator::Calculator(QWidget *parent) : QWidget(parent) { sumInMemory = 0.0; sumSoFar = 0.0; factorSoFar = 0.0; waitingForOperand = true; //! [0] //! [1] display = new QLineEdit("0"); //! [1] //! [2] display->setReadOnly(true); display->setAlignment(Qt::AlignRight); display->setMaxLength(15); QFont font = display->font(); font.setPointSize(font.pointSize() + 8); display->setFont(font); //! [2] //! [4] for (int i = 0; i < NumDigitButtons; ++i) { digitButtons[i] = createButton(QString::number(i), SLOT(digitClicked())); } Button *pointButton = createButton(tr("."), SLOT(pointClicked())); Button *changeSignButton = createButton(tr("\302\261"), SLOT(changeSignClicked())); Button *backspaceButton = createButton(tr("Backspace"), SLOT(backspaceClicked())); Button *clearButton = createButton(tr("Clear"), SLOT(clear())); Button *clearAllButton = createButton(tr("Clear All"), SLOT(clearAll())); Button *clearMemoryButton = createButton(tr("MC"), SLOT(clearMemory())); Button *readMemoryButton = createButton(tr("MR"), SLOT(readMemory())); Button *setMemoryButton = createButton(tr("MS"), SLOT(setMemory())); Button *addToMemoryButton = createButton(tr("M+"), SLOT(addToMemory())); Button *divisionButton = createButton(tr("\303\267"), SLOT(multiplicativeOperatorClicked())); Button *timesButton = createButton(tr("\303\227"), SLOT(multiplicativeOperatorClicked())); Button *minusButton = createButton(tr("-"), SLOT(additiveOperatorClicked())); Button *plusButton = createButton(tr("+"), SLOT(additiveOperatorClicked())); Button *squareRootButton = createButton(tr("Sqrt"), SLOT(unaryOperatorClicked())); Button *powerButton = createButton(tr("x\302\262"), SLOT(unaryOperatorClicked())); Button *reciprocalButton = createButton(tr("1/x"), SLOT(unaryOperatorClicked())); Button *equalButton = createButton(tr("="), SLOT(equalClicked())); //! [4] //! [5] QGridLayout *mainLayout = new QGridLayout; //! [5] //! [6] mainLayout->setSizeConstraint(QLayout::SetFixedSize); mainLayout->addWidget(display, 0, 0, 1, 6); mainLayout->addWidget(backspaceButton, 1, 0, 1, 2); mainLayout->addWidget(clearButton, 1, 2, 1, 2); mainLayout->addWidget(clearAllButton, 1, 4, 1, 2); mainLayout->addWidget(clearMemoryButton, 2, 0); mainLayout->addWidget(readMemoryButton, 3, 0); mainLayout->addWidget(setMemoryButton, 4, 0); mainLayout->addWidget(addToMemoryButton, 5, 0); for (int i = 1; i < NumDigitButtons; ++i) { int row = ((9 - i) / 3) + 2; int column = ((i - 1) % 3) + 1; mainLayout->addWidget(digitButtons[i], row, column); } mainLayout->addWidget(digitButtons[0], 5, 1); mainLayout->addWidget(pointButton, 5, 2); mainLayout->addWidget(changeSignButton, 5, 3); mainLayout->addWidget(divisionButton, 2, 4); mainLayout->addWidget(timesButton, 3, 4); mainLayout->addWidget(minusButton, 4, 4); mainLayout->addWidget(plusButton, 5, 4); mainLayout->addWidget(squareRootButton, 2, 5); mainLayout->addWidget(powerButton, 3, 5); mainLayout->addWidget(reciprocalButton, 4, 5); mainLayout->addWidget(equalButton, 5, 5); setLayout(mainLayout); setWindowTitle(tr("Calculator")); }
void LegendItem::saveDialogDefaultsFont(const QFont &F, const QColor &C) { dialogDefaults().setValue(staticDefaultsGroupName()+"/font", QVariant(F).toString()); dialogDefaults().setValue(staticDefaultsGroupName()+"/fontScale",F.pointSize()); dialogDefaults().setValue(staticDefaultsGroupName()+"/color", C.name()); }
int Platform::DefaultFontSize() { QFont font = QApplication::font(); return font.pointSize(); }
void QGraph::SaveSettings(QSettings *pSettings) { QFont lgft; QColor clr; int k,s,w; bool ba, bs; double f; pSettings->beginGroup(m_GraphName); { //read variables clr = GetAxisColor(); pSettings->setValue("AxisColorRed", clr.red()); pSettings->setValue("AxisColorGreen",clr.green()); pSettings->setValue("AxisColorBlue", clr.blue()); k = GetAxisStyle(); pSettings->setValue("AxisStyle", k); k = GetAxisWidth(); pSettings->setValue("AxisWidth", k); clr = GetTitleColor(); pSettings->setValue("TitleColorRed", clr.red()); pSettings->setValue("TitleColorGreen",clr.green()); pSettings->setValue("TitleColorBlue", clr.blue()); clr = GetLabelColor(); pSettings->setValue("LabelColorRed", clr.red()); pSettings->setValue("LabelColorGreen",clr.green()); pSettings->setValue("LabelColorBlue", clr.blue()); GetTitleLogFont(&lgft); pSettings->setValue("TitleFontName", lgft.family()); pSettings->setValue("TitleFontSize", lgft.pointSize()); GetLabelLogFont(&lgft); pSettings->setValue("LabelFontName", lgft.family()); pSettings->setValue("LabelFontSize", lgft.pointSize()); GetXMajGrid(bs,clr,s,w); pSettings->setValue("XMajGridColorRed", clr.red()); pSettings->setValue("XMajGridColorGreen",clr.green()); pSettings->setValue("XMajGridColorBlue", clr.blue()); pSettings->setValue("XMajGridShow",bs); pSettings->setValue("XMajGridStyle",s); pSettings->setValue("XMajGridWidth",w); GetYMajGrid(bs,clr,s,w); pSettings->setValue("YMajGridColorRed", clr.red()); pSettings->setValue("YMajGridColorGreen",clr.green()); pSettings->setValue("YMajGridColorBlue", clr.blue()); pSettings->setValue("YMajGridShow",bs); pSettings->setValue("YMajGridStyle",s); pSettings->setValue("YMajGridWidth",w); GetXMinGrid(bs,ba,clr,s,w,f); pSettings->setValue("XMinGridColorRed", clr.red()); pSettings->setValue("XMinGridColorGreen",clr.green()); pSettings->setValue("XMinGridColorBlue", clr.blue()); pSettings->setValue("XMinGridAuto",ba); pSettings->setValue("XMinGridShow",bs); pSettings->setValue("XMinGridStyle",s); pSettings->setValue("XMinGridWidth",w); pSettings->setValue("XMinGridUnit",f); GetYMinGrid(bs,ba,clr,s,w,f); pSettings->setValue("YMinGridColorRed", clr.red()); pSettings->setValue("YMinGridColorGreen",clr.green()); pSettings->setValue("YMinGridColorBlue", clr.blue()); pSettings->setValue("YMinGridAuto",ba); pSettings->setValue("YMinGridShow",bs); pSettings->setValue("YMinGridStyle",s); pSettings->setValue("YMinGridWidth",w); pSettings->setValue("YMinGridUnit",f); clr = GetBorderColor(); s = GetBorderStyle(); w = GetBorderWidth(); pSettings->setValue("BorderColorRed", clr.red()); pSettings->setValue("BorderColorGreen", clr.green()); pSettings->setValue("BorderColorBlue", clr.blue()); pSettings->setValue("BorderStyle", s); pSettings->setValue("BorderWidth", w); pSettings->setValue("BorderShow", m_bBorder); clr = GetBackColor(); pSettings->setValue("BackColorRed", clr.red()); pSettings->setValue("BackColorGreen", clr.green()); pSettings->setValue("BackColorBlue", clr.blue()); pSettings->setValue("Inverted", m_bYInverted); pSettings->setValue("XVariable", m_X); pSettings->setValue("YVariable", m_Y); } pSettings->endGroup(); }
DateSettingsEdit::DateSettingsEdit(QWidget *parent) : parent(parent), active(false) { setContentsMargins(0,0,0,0); QFormLayout *mainLayout = new QFormLayout(this); mainLayout->setContentsMargins(0,0,0,0); mainLayout->setSpacing(5); QFont sameFont; #ifdef Q_OS_MAC sameFont.setPointSize(sameFont.pointSize() + 2); #endif radioSelected = new QRadioButton(tr("Current selection"), this); radioSelected->setChecked(true); radioSelected->setFont(sameFont); QHBoxLayout *selected = new QHBoxLayout; // use same layout mechanism as custom so they align selected->addWidget(radioSelected); selected->addStretch(); mainLayout->addRow(selected); radioToday = new QRadioButton(tr("Current selection thru today"), this); radioToday->setChecked(false); radioToday->setFont(sameFont); QHBoxLayout *today = new QHBoxLayout; // use same layout mechanism as custom so they align today->addWidget(radioToday); today->addStretch(); mainLayout->addRow(today); radioFrom = new QRadioButton(tr("From"), this); radioFrom->setChecked(false); radioFrom->setFont(sameFont); startDateEdit = new QDateEdit(this); startDateEdit->setDate(QDate::currentDate().addMonths(-3)); QHBoxLayout *from = new QHBoxLayout; from->addWidget(radioFrom); from->addWidget(startDateEdit); from->addWidget(new QLabel(tr("to today"))); from->addStretch(); mainLayout->addRow(from); radioCustom = new QRadioButton(tr("Between"), this); radioCustom->setFont(sameFont); radioCustom->setChecked(false); fromDateEdit = new QDateEdit(this); toDateEdit = new QDateEdit(this); QHBoxLayout *custom = new QHBoxLayout; custom->addWidget(radioCustom); custom->addWidget(fromDateEdit); custom->addWidget(new QLabel(tr("and"))); custom->addWidget(toDateEdit); custom->addStretch(); mainLayout->addRow(custom); radioLast = new QRadioButton(tr("Last"), this); radioLast->setFont(sameFont); radioLast->setChecked(false); lastn = new QDoubleSpinBox(this); lastn->setSingleStep(1.0); lastn->setDecimals(0); lastn->setMinimum(0); lastn->setMaximum(999); lastn->setValue(7); lastnx = new QComboBox(this); lastnx->addItem(tr("days")); lastnx->addItem(tr("weeks")); lastnx->addItem(tr("months")); lastnx->addItem(tr("years")); lastnx->setCurrentIndex(0); QHBoxLayout *last = new QHBoxLayout; last->addWidget(radioLast); last->addWidget(lastn); last->addWidget(lastnx); last->addStretch(); mainLayout->addRow(last); radioThis = new QRadioButton(tr("This"), this); radioThis->setFont(sameFont); radioThis->setChecked(false); thisperiod = new QComboBox(this); thisperiod->addItem(tr("week")); thisperiod->addItem(tr("month")); thisperiod->addItem(tr("year")); thisperiod->setCurrentIndex(0); prevperiod = new QDoubleSpinBox(this); prevperiod->setSingleStep(1.0); prevperiod->setDecimals(0); prevperiod->setMinimum(0); prevperiod->setMaximum(999); prevperiod->setValue(0); QHBoxLayout *thisl = new QHBoxLayout; thisl->addWidget(radioThis); thisl->addWidget(thisperiod); thisl->addWidget(new QLabel(tr("prior"))); thisl->addWidget(prevperiod); thisl->addStretch(); mainLayout->addRow(thisl); // switched between one or other connect(radioSelected, SIGNAL(toggled(bool)), this, SLOT(setDateSettings())); connect(radioToday, SIGNAL(toggled(bool)), this, SLOT(setDateSettings())); connect(radioCustom, SIGNAL(toggled(bool)), this, SLOT(setDateSettings())); connect(radioLast, SIGNAL(toggled(bool)), this, SLOT(setDateSettings())); connect(radioFrom, SIGNAL(toggled(bool)), this, SLOT(setDateSettings())); connect(radioThis, SIGNAL(toggled(bool)), this, SLOT(setDateSettings())); connect(fromDateEdit, SIGNAL(editingFinished()), this, SLOT(setDateSettings())); connect(toDateEdit, SIGNAL(editingFinished()), this, SLOT(setDateSettings())); connect(startDateEdit, SIGNAL(editingFinished()), this, SLOT(setDateSettings())); connect(lastn, SIGNAL(editingFinished()), this, SLOT(setDateSettings())); connect(lastnx, SIGNAL(currentIndexChanged(int)), this, SLOT(setDateSettings())); connect(thisperiod, SIGNAL(currentIndexChanged(int)), this, SLOT(setDateSettings())); connect(prevperiod, SIGNAL(editingFinished()), this, SLOT(setDateSettings())); }
/** Render the document */ void reportView::render(){ QFont generalFont = KGlobalSettings::generalFont(); QString fntFamily = generalFont.family(); int fntSize = generalFont.pointSize(); if (fntSize == -1) fntSize = QFontInfo(generalFont).pointSize(); QString textColor = KGlobalSettings::textColor().name(); QString baseColor = KGlobalSettings::baseColor().name(); QColorGroup cg = palette().active(); QString bgColor = cg.background().name(); QString hlColor = cg.highlight().name(); QString hlTextColor = cg.highlightedText().name(); QString locationName = m_weatherService->stationName(m_locationCode); QString countryName = m_weatherService->stationCountry(m_locationCode); QString temp = m_weatherService->temperature(m_locationCode); QString dewPoint = m_weatherService->dewPoint( m_locationCode); QString relHumidity = m_weatherService->relativeHumidity(m_locationCode ); QString heatIndex = m_weatherService->heatIndex(m_locationCode ); QString windChill = m_weatherService->windChill(m_locationCode ); QString pressure = m_weatherService->pressure(m_locationCode ); QString wind = m_weatherService->wind(m_locationCode ); QString sunRiseTime = m_weatherService->sunRiseTime(m_locationCode ); QString sunSetTime = m_weatherService->sunSetTime(m_locationCode ); QString date = m_weatherService->date(m_locationCode ); QString icon = m_weatherService->iconFileName(m_locationCode ); QStringList cover = m_weatherService->cover(m_locationCode ); QStringList weather = m_weatherService->weather(m_locationCode ); setCaption(i18n("Weather Report - %1").arg( locationName ) ); QString weatherText = "<ul>\n"; if ( m_weatherService->stationNeedsMaintenance( m_locationCode ) ) { weatherText += "<li>" + i18n( "Station reports that it needs maintenance" ) + " \n"; } for (QStringList::const_iterator it = cover.begin(); it != cover.end(); ++it) weatherText += "<li>" + *it + "\n"; for (QStringList::const_iterator it = weather.begin(); it != weather.end(); ++it) weatherText += "<li>" + *it + "\n"; weatherText += "</ul>\n"; QString contents = "<html><head><style type=\"text/css\">" + QString("body { font-family: \"%1\"; font-size: %2pt; color: %3; background-color: %4; }\n") .arg(fntFamily).arg(fntSize).arg(textColor).arg(baseColor) + QString("div.headerTitle { background-color: %1; color: %2; padding: 4px; font-size: 120%; border: solid %3 1px; }\n") .arg(hlColor).arg(hlTextColor).arg(textColor) + QString("div.headerMsg { background-color: %1; color: %2; border-bottom: solid %3 1px; " "border-left: solid %4 1px; border-right: solid %5 1px; margin-bottom: 1em; padding: 2px; }\n") .arg(bgColor).arg(textColor).arg(textColor).arg(textColor).arg(textColor) + QString("</style><title></title></head><body dir=\"%1\">").arg( QApplication::reverseLayout()?"rtl":"ltr") + "<div class=\"headerTitle\"><b>" + i18n( "Weather Report - %1 - %2" ).arg( locationName ).arg( countryName ) + "</b></div>\n"; if ( ! date.isEmpty() ) contents += "<div class=\"headerMsg\"><b>" + i18n( "Latest data from %1" ).arg(date) + "</b></div>\n"; contents += QString( "<table><tr><td width=\"60\" style=\"text-align: center; border: dotted %1 1px;\">" "<img width=\"64\" height=\"64\" src=\"%2\" /></td>" "<td style=\"vertical-align: top\">%3</td></tr>") .arg(bgColor).arg(KURL(icon).url()).arg(weatherText) + "</table><table>" + QString("<tr><th style=\"text-align: right\">" + i18n( "Temperature:" ) + "</th><td>%1</td>" "<td width=\"50\"> </td>" "<th style=\"text-align: right\">" + i18n( "Dew Point:" ) + "</th><td>%2</td></tr>" "<tr><th style=\"text-align: right\">" + i18n( "Air Pressure:" ) + "</th><td>%3</td>" "<td width=\"50\"> </td>" "<th style=\"text-align: right\">" + i18n( "Rel. Humidity:" ) + "</th><td>%4</td></tr>" "<tr><th style=\"text-align: right\">" + i18n( "Wind Speed:" ) + "</th><td>%5</td>") .arg(temp).arg(dewPoint).arg(pressure).arg(relHumidity) .arg(wind) + "<td width=\"50\"> </td>"; if (!heatIndex.isEmpty()) contents += QString("<th style=\"text-align: right\">" + i18n( "Heat Index:" ) + "</th><td>%1</td>").arg(heatIndex); else if (!windChill.isEmpty()) contents += QString("<th style=\"text-align: right\">" + i18n( "Wind Chill:" ) + "</th><td>%1</td>").arg(windChill); else contents += "<td> </td><td> </td>"; contents += "</tr>"; contents += QString("<tr><th style=\"text-align: right\">" + i18n( "Sunrise:" ) + "</th><td>%1</td>" + "<td width=\"50\"> </td><th style=\"text-align: right\">" + i18n( "Sunset:" ) + "</th><td>%2</td>") .arg(sunRiseTime).arg(sunSetTime); contents += "</tr></table></body></html>"; m_reportView->begin(); m_reportView->write( contents ); m_reportView->end(); QScrollView *view = m_reportView->view(); kdDebug() << "Size " << view->size().height() << "," << view->size().width() << endl; kdDebug() << "Size " << view->visibleHeight() << "," << view->visibleWidth() << endl; m_reportView->view()->resize(view->size().width(), view->size().height()); }