ArtistInfoWidget::ArtistInfoWidget( const Tomahawk::artist_ptr& artist, QWidget* parent ) : QWidget( parent ) , TomahawkUtils::DpiScaler( this ) , ui( new Ui::ArtistInfoWidget ) , m_artist( artist ) { m_widget = new QWidget; m_headerWidget = new BasicHeader; ui->setupUi( m_widget ); { ui->relatedArtists->setAutoResize( true ); ui->relatedArtists->setAutoFitItems( true ); ui->relatedArtists->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); ui->relatedArtists->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); ui->relatedArtists->setItemWidth( scaledX( 170 ) ); 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!" ) ); TomahawkStyle::stylePageFrame( ui->relatedArtists ); TomahawkStyle::stylePageFrame( ui->artistFrame ); TomahawkStyle::styleScrollBar( ui->relatedArtists->verticalScrollBar() ); } { ui->albums->setAutoResize( true ); ui->albums->setAutoFitItems( false ); ui->albums->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); ui->albums->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); ui->albums->setWrapping( false ); ui->albums->setItemWidth( scaledX( 190 ) ); ui->albums->proxyModel()->setHideDupeItems( true ); ui->albums->delegate()->setWordWrapping( true ); ui->albums->setFixedHeight( ui->albums->itemSize().height() + ui->albums->spacing() * 2 ); m_albumsModel = new PlayableModel( ui->albums ); ui->albums->setPlayableModel( m_albumsModel ); ui->albums->proxyModel()->sort( -1 ); ui->albums->setEmptyTip( tr( "Sorry, we could not find any albums for this artist!" ) ); TomahawkStyle::stylePageFrame( ui->albumFrame ); TomahawkStyle::styleScrollBar( ui->albums->verticalScrollBar() ); TomahawkStyle::styleScrollBar( ui->albums->horizontalScrollBar() ); } { ui->topHits->setAutoResize( true ); ui->topHits->setAutoFitItems( false ); ui->topHits->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); ui->topHits->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); ui->topHits->setWrapping( false ); ui->topHits->setItemWidth( scaledX( 140 ) ); ui->topHits->proxyModel()->setHideDupeItems( true ); ui->topHits->delegate()->setWordWrapping( true ); ui->topHits->delegate()->setShowBuyButtons( true ); ui->topHits->setFixedHeight( ui->topHits->itemSize().height() + ui->topHits->spacing() * 2 ); m_topHitsModel = new PlayableModel( ui->topHits ); ui->topHits->setPlayableModel( m_topHitsModel ); ui->topHits->proxyModel()->sort( -1 ); ui->topHits->setEmptyTip( tr( "Sorry, we could not find any top hits for this artist!" ) ); TomahawkStyle::stylePageFrame( ui->trackFrame ); } { ui->biography->setObjectName( "biography" ); ui->biography->setContentsMargins( 0, 0, 0, 0 ); ui->biography->page()->mainFrame()->setScrollBarPolicy( Qt::Horizontal, Qt::ScrollBarAlwaysOff ); ui->biography->page()->mainFrame()->setScrollBarPolicy( Qt::Vertical, Qt::ScrollBarAsNeeded ); ui->biography->page()->setLinkDelegationPolicy( QWebPage::DelegateAllLinks ); ui->biography->installEventFilter( this ); TomahawkStyle::stylePageWidget( ui->biography ); TomahawkStyle::stylePageFrame( ui->bioFrame ); connect( ui->biography, SIGNAL( linkClicked( QUrl ) ), SLOT( onBiographyLinkClicked( QUrl ) ) ); QFont f = ui->topHitsMoreLabel->font(); f.setWeight( QFont::Light ); f.setPointSize( TomahawkUtils::defaultFontSize() + 1 ); ui->topHitsMoreLabel->setFont( f ); ui->albumsMoreLabel->setFont( f ); connect( ui->albumsMoreLabel, SIGNAL( clicked() ), SLOT( onAlbumsMoreClicked() ) ); connect( ui->topHitsMoreLabel, SIGNAL( clicked() ), SLOT( onTopHitsMoreClicked() ) ); ui->cover->setFixedSize( scaled( QSize( 384, 384 ) ) ); } { m_headerWidget->ui->anchor1Label->setText( tr( "Music" ) ); m_headerWidget->ui->anchor2Label->setText( tr( "Biography" ) ); m_headerWidget->ui->anchor3Label->setText( tr( "Related Artists" ) ); m_headerWidget->ui->anchor1Label->show(); m_headerWidget->ui->anchor2Label->show(); m_headerWidget->ui->anchor3Label->show(); QFontMetrics fm( m_headerWidget->ui->anchor1Label->font() ); m_headerWidget->ui->anchor1Label->setFixedWidth( fm.width( m_headerWidget->ui->anchor1Label->text() ) + 16 ); m_headerWidget->ui->anchor2Label->setFixedWidth( fm.width( m_headerWidget->ui->anchor2Label->text() ) + 16 ); m_headerWidget->ui->anchor3Label->setFixedWidth( fm.width( m_headerWidget->ui->anchor3Label->text() ) + 16 ); connect( m_headerWidget->ui->anchor1Label, SIGNAL( clicked() ), SLOT( onMusicAnchorClicked() ) ); connect( m_headerWidget->ui->anchor2Label, SIGNAL( clicked() ), SLOT( onBioAnchorClicked() ) ); connect( m_headerWidget->ui->anchor3Label, SIGNAL( clicked() ), SLOT( onRelatedArtistsAnchorClicked() ) ); } m_stackedWidget = new QStackedWidget(); { m_area = new QScrollArea(); m_area->setWidgetResizable( true ); m_area->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOn ); m_area->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); m_area->setWidget( m_widget ); QPalette pal = palette(); pal.setBrush( backgroundRole(), TomahawkStyle::PAGE_BACKGROUND ); m_area->setPalette( pal ); m_area->setAutoFillBackground( true ); m_area->setFrameShape( QFrame::NoFrame ); m_area->setAttribute( Qt::WA_MacShowFocusRect, 0 ); m_stackedWidget->addWidget( m_area ); connect( m_area->verticalScrollBar(), SIGNAL( valueChanged(int ) ), SLOT( onSliderValueChanged( int ) ) ); } { ContextView* topHitsFullView = new ContextView( m_stackedWidget ); topHitsFullView->setCaption( tr( "Songs" ) ); topHitsFullView->setShowCloseButton( true ); topHitsFullView->trackView()->setPlayableModel( m_topHitsModel ); m_stackedWidget->addWidget( topHitsFullView ); connect( topHitsFullView, SIGNAL( closeClicked() ), SLOT( onPageClosed() ) ); } { GridView* albumsFullView = new GridView( m_stackedWidget ); albumsFullView->delegate()->setWordWrapping( true ); // albumsFullView->setCaption( tr( "Albums" ) ); // albumsFullView->setShowCloseButton( true ); albumsFullView->setPlayableModel( m_albumsModel ); albumsFullView->proxyModel()->setHideDupeItems( true ); CaptionLabel* captionLabel = new CaptionLabel( this ); captionLabel->setText( tr( "Albums" ) ); captionLabel->setShowCloseButton( true ); QWidget* vbox = new QWidget; QPalette pal = vbox->palette(); pal.setBrush( vbox->backgroundRole(), TomahawkStyle::PAGE_BACKGROUND ); vbox->setPalette( pal ); vbox->setAutoFillBackground( true ); QVBoxLayout* vboxl = new QVBoxLayout; TomahawkUtils::unmarginLayout( vboxl ); vboxl->setContentsMargins( 32, 32, 32, 32 ); vboxl->setSpacing( scaledY( 8 ) ); vbox->setLayout( vboxl ); vboxl->addWidget( captionLabel ); vboxl->addWidget( albumsFullView ); vboxl->addStretch(); vboxl->setStretchFactor( albumsFullView, 1 ); m_stackedWidget->addWidget( vbox ); connect( captionLabel, SIGNAL( clicked() ), SLOT( onPageClosed() ) ); } { QVBoxLayout* layout = new QVBoxLayout(); layout->addWidget( m_headerWidget ); layout->addWidget( m_stackedWidget ); setLayout( layout ); TomahawkUtils::unmarginLayout( layout ); } MetaPlaylistInterface* mpl = new MetaPlaylistInterface(); mpl->addChildInterface( ui->relatedArtists->playlistInterface() ); mpl->addChildInterface( ui->topHits->playlistInterface() ); mpl->addChildInterface( ui->albums->playlistInterface() ); m_plInterface = playlistinterface_ptr( mpl ); onSliderValueChanged( 0 ); TomahawkUtils::fixMargins( this ); m_pixmap = TomahawkUtils::defaultPixmap( TomahawkUtils::DefaultArtistImage, TomahawkUtils::Original, scaled( QSize( 48, 48 ) ) ); load( artist ); }
void MainWindow::onTextCharFormatChanged( const QTextCharFormat & sFormat ) { QFont fnt = sFormat.font(); m_pCmbFont->setCurrentText( fnt.family() ); m_pCmbFontPointSize->setCurrentText( QString::number( fnt.pointSize() ) ); }
PrefsDialog::PrefsDialog(QWidget *parent): QDialog(parent),ui(new Ui::PrefsDialog){ // map dropdown values to indices listTagFormat << TAG_FORMAT_KEYS; listTagFormat << TAG_FORMAT_CUSTOM; listTagFormat << TAG_FORMAT_BOTH; listStartingFreq << 27.5; listStartingFreq << 55; listStartingFreq << 110; listStartingFreq << 220; listStartingFreq << 440; listStartingFreq << 880; listHopSize << 128; listHopSize << 256; listHopSize << 512; listHopSize << 1024; listHopSize << 2048; listHopSize << 4096; listHopSize << 8192; listHopSize << 16384; listHopSize << 32768; listHopSize << 65536; listTemporalWindow << KeyFinder::WINDOW_BLACKMAN; listTemporalWindow << KeyFinder::WINDOW_HAMMING; listTemporalWindow << KeyFinder::WINDOW_HANN; listFftFrameSize << 512; listFftFrameSize << 1024; listFftFrameSize << 2048; listFftFrameSize << 4096; listFftFrameSize << 8192; listFftFrameSize << 16384; listFftFrameSize << 32768; listFftFrameSize << 65536; listFftFrameSize << 131072; listFftFrameSize << 262144; listTuningMethod << KeyFinder::TUNING_HARTE; listTuningMethod << KeyFinder::TUNING_BIN_ADAPTIVE; listSegmentation << KeyFinder::SEGMENTATION_NONE; listSegmentation << KeyFinder::SEGMENTATION_HARTE; listSegmentation << KeyFinder::SEGMENTATION_COSINE; listSegmentation << KeyFinder::SEGMENTATION_ARBITRARY; listToneProfile << KeyFinder::TONE_PROFILE_KRUMHANSL; listToneProfile << KeyFinder::TONE_PROFILE_TEMPERLEY; listToneProfile << KeyFinder::TONE_PROFILE_GOMEZ; listToneProfile << KeyFinder::TONE_PROFILE_SHAATH; listToneProfile << KeyFinder::TONE_PROFILE_CUSTOM; listSimilarityMeasure << KeyFinder::SIMILARITY_COSINE; listSimilarityMeasure << KeyFinder::SIMILARITY_CORRELATION; // UI ui->setupUi(this); this->setWindowFlags(Qt::WindowTitleHint | Qt::CustomizeWindowHint); // get values from preferences Preferences p; ui->writeToFilesAutomatically->setChecked(p.getWriteToFilesAutomatically()); ui->parallelBatchJobs->setChecked(p.getParallelBatchJobs()); ui->writeToTagComment->setChecked(p.getWriteToTagComment()); ui->writeToTagGrouping->setChecked(p.getWriteToTagGrouping()); ui->writeToTagKey->setChecked(p.getWriteToTagKey()); ui->writeToFilePrefix->setChecked(p.getWriteToFilePrefix()); ui->writeToFileSuffix->setChecked(p.getWriteToFileSuffix()); ui->filenameDelimiter->setText(p.getFilenameDelimiter()); ui->skipFilesWithExistingTags->setChecked(p.getSkipFilesWithExistingTags()); ui->temporalWindow->setCurrentIndex(listTemporalWindow.indexOf(p.getTemporalWindow())); ui->segmentation->setCurrentIndex(listSegmentation.indexOf(p.getSegmentation())); ui->similarityMeasure->setCurrentIndex(listSimilarityMeasure.indexOf(p.getSimilarityMeasure())); ui->tagFormat->setCurrentIndex(listTagFormat.indexOf(p.getTagFormat())); ui->hopSize->setCurrentIndex(listHopSize.indexOf(p.getHopSize())); ui->fftFrameSize->setCurrentIndex(listFftFrameSize.indexOf(p.getFftFrameSize())); ui->octaves->setValue(p.getOctaves()); ui->bps->setValue(p.getBpo()/12); ui->octaveOffset->setChecked(p.getOffsetToC()); ui->dFactor->setValue(p.getDFactor()); ui->toneProfile->setCurrentIndex(listToneProfile.indexOf(p.getToneProfile())); ui->hcdfPeakPickingNeighbours->setValue(p.getHcdfPeakPickingNeighbours()); ui->arbitrarySegments->setValue(p.getArbitrarySegments()); ui->hcdfGaussianSize->setValue(p.getHcdfGaussianSize()); ui->tuningMethod->setCurrentIndex(listTuningMethod.indexOf(p.getTuningMethod())); ui->hcdfGaussianSigma->setValue(p.getHcdfGaussianSigma()); ui->stFreq->setCurrentIndex(listStartingFreq.indexOf(p.getStartingFreqA())); ui->directSkStretch->setValue(p.getDirectSkStretch()); ui->detunedBandWeight->setValue(p.getDetunedBandWeight()); ui->iTunesLibraryPath->setText(p.getITunesLibraryPath()); ui->traktorLibraryPath->setText(p.getTraktorLibraryPath()); ui->seratoLibraryPath->setText(p.getSeratoLibraryPath()); std::vector<float> ctp = p.getCustomToneProfile(); ui->maj0->setValue(ctp[0]); ui->maj1->setValue(ctp[1]); ui->maj2->setValue(ctp[2]); ui->maj3->setValue(ctp[3]); ui->maj4->setValue(ctp[4]); ui->maj5->setValue(ctp[5]); ui->maj6->setValue(ctp[6]); ui->maj7->setValue(ctp[7]); ui->maj8->setValue(ctp[8]); ui->maj9->setValue(ctp[9]); ui->maj10->setValue(ctp[10]); ui->maj11->setValue(ctp[11]); ui->min0->setValue(ctp[12]); ui->min1->setValue(ctp[13]); ui->min2->setValue(ctp[14]); ui->min3->setValue(ctp[15]); ui->min4->setValue(ctp[16]); ui->min5->setValue(ctp[17]); ui->min6->setValue(ctp[18]); ui->min7->setValue(ctp[19]); ui->min8->setValue(ctp[20]); ui->min9->setValue(ctp[21]); ui->min10->setValue(ctp[22]); ui->min11->setValue(ctp[23]); QStringList ckc = p.getCustomKeyCodes(); ui->majKey0->setText(ckc[0]); ui->minKey0->setText(ckc[1]); ui->majKey1->setText(ckc[2]); ui->minKey1->setText(ckc[3]); ui->majKey2->setText(ckc[4]); ui->minKey2->setText(ckc[5]); ui->majKey3->setText(ckc[6]); ui->minKey3->setText(ckc[7]); ui->majKey4->setText(ckc[8]); ui->minKey4->setText(ckc[9]); ui->majKey5->setText(ckc[10]); ui->minKey5->setText(ckc[11]); ui->majKey6->setText(ckc[12]); ui->minKey6->setText(ckc[13]); ui->majKey7->setText(ckc[14]); ui->minKey7->setText(ckc[15]); ui->majKey8->setText(ckc[16]); ui->minKey8->setText(ckc[17]); ui->majKey9->setText(ckc[18]); ui->minKey9->setText(ckc[19]); ui->majKey10->setText(ckc[20]); ui->minKey10->setText(ckc[21]); ui->majKey11->setText(ckc[22]); ui->minKey11->setText(ckc[23]); ui->silence->setText(ckc[24]); // enable/disable fields as necessary tuningEnabled(); binAdaptiveTuningEnabled(); segmentationEnabled(); customProfileEnabled(); filenameDelimiterEnabled(); //relative sizing on Mac only #ifdef Q_OS_MAC QFont smallerFont; smallerFont.setPointSize(smallerFont.pointSize() - 2); for(int i=0; i<ui->gridLayoutKeyCodes->count(); i++) if(!ui->gridLayoutKeyCodes->itemAt(i)->isEmpty()) if(ui->gridLayoutKeyCodes->itemAt(i)->widget()->inherits("QLabel")) ui->gridLayoutKeyCodes->itemAt(i)->widget()->setFont(smallerFont); for(int i=0; i<ui->customMajor->count(); i++) if(!ui->customMajor->itemAt(i)->isEmpty()) if(ui->customMajor->itemAt(i)->widget()->inherits("QLabel")) ui->customMajor->itemAt(i)->widget()->setFont(smallerFont); for(int i=0; i<ui->customMinor->count(); i++) if(!ui->customMinor->itemAt(i)->isEmpty()) if(ui->customMinor->itemAt(i)->widget()->inherits("QLabel")) ui->customMinor->itemAt(i)->widget()->setFont(smallerFont); #endif }
void GraphEditor::setBaseFont( QFont fnt) { _leBaseFont->setFont(fnt); _leBaseFont->setText(fnt.toString()); }
GcScopeBar::GcScopeBar(Context *context) : QWidget(context->mainWindow), context(context) { setFixedHeight(23); setContentsMargins(10,0,10,0); layout = new QHBoxLayout(this); layout->setSpacing(2); layout->setContentsMargins(0,0,0,0); searchLabel = new GcLabel(tr("Search/Filter:")); searchLabel->setYOff(1); searchLabel->setFixedHeight(20); searchLabel->setHighlighted(true); QFont font; font.setPointSize(10); font.setWeight(QFont::Black); searchLabel->setFont(font); layout->addWidget(searchLabel); searchLabel->hide(); connect(context, SIGNAL(filterChanged()), this, SLOT(setHighlighted())); connect(context, SIGNAL(compareIntervalsStateChanged(bool)), this, SLOT(setCompare())); connect(context, SIGNAL(compareDateRangesStateChanged(bool)), this, SLOT(setCompare())); // Mac uses QtMacButton - recessed etc #ifdef Q_OS_MAC home = new QtMacButton(this, QtMacButton::Recessed); #ifdef GC_HAVE_ICAL diary = new QtMacButton(this, QtMacButton::Recessed); #endif anal = new QtMacButton(this, QtMacButton::Recessed); train = new QtMacButton(this, QtMacButton::Recessed); #else // Windows / Linux uses GcScopeButton - pushbutton home = new GcScopeButton(this); #ifdef GC_HAVE_ICAL diary = new GcScopeButton(this); #endif anal = new GcScopeButton(this); train = new GcScopeButton(this); #endif // now set the text for each one home->setText(tr("Trends")); layout->addWidget(home); connect(home, SIGNAL(clicked(bool)), this, SLOT(clickedHome())); HelpWhatsThis *helpHome = new HelpWhatsThis(home); home->setWhatsThis(helpHome->getWhatsThisText(HelpWhatsThis::ScopeBar_Trends)); #ifdef GC_HAVE_ICAL diary->setText(tr("Diary")); layout->addWidget(diary); connect(diary, SIGNAL(clicked(bool)), this, SLOT(clickedDiary())); HelpWhatsThis *helpDiary = new HelpWhatsThis(diary); diary->setWhatsThis(helpDiary->getWhatsThisText(HelpWhatsThis::ScopeBar_Diary)); #endif anal->setText(tr("Activities")); anal->setWidth(70); anal->setChecked(true); layout->addWidget(anal); connect(anal, SIGNAL(clicked(bool)), this, SLOT(clickedAnal())); HelpWhatsThis *helpAnal = new HelpWhatsThis(anal); anal->setWhatsThis(helpAnal->getWhatsThisText(HelpWhatsThis::ScopeBar_Rides)); train->setText(tr("Train")); layout->addWidget(train); connect(train, SIGNAL(clicked(bool)), this, SLOT(clickedTrain())); HelpWhatsThis *helpTrain = new HelpWhatsThis(train); train->setWhatsThis(helpTrain->getWhatsThisText(HelpWhatsThis::ScopeBar_Train)); //layout->addWidget(traintool); //XXX!!! eek // we now need to adjust the buttons according to their text size // this is particularly bad for German's who, as a nation, must // suffer from RSI from typing and writing more than any other nation ;) QFontMetrics fontMetric(font); int width = fontMetric.width(tr("Trends")); home->setWidth(width+30); width = fontMetric.width(tr("Activities")); anal->setWidth(width+30); width = fontMetric.width(tr("Train")); train->setWidth(width+30); #ifdef GC_HAVE_ICAL width = fontMetric.width(tr("Diary")); diary->setWidth(width+30); #endif }
QBalloonTip::QBalloonTip(QSystemTrayIcon::MessageIcon icon, const QString& title, const QString& message, QSystemTrayIcon *ti) : QWidget(0, Qt::ToolTip), trayIcon(ti), timerId(-1) { setAttribute(Qt::WA_DeleteOnClose); QObject::connect(ti, SIGNAL(destroyed()), this, SLOT(close())); QLabel *titleLabel = new QLabel; titleLabel->installEventFilter(this); titleLabel->setText(title); QFont f = titleLabel->font(); f.setBold(true); #ifdef Q_OS_WINCE f.setPointSize(f.pointSize() - 2); #endif titleLabel->setFont(f); titleLabel->setTextFormat(Qt::PlainText); // to maintain compat with windows #ifdef Q_OS_WINCE const int iconSize = style()->pixelMetric(QStyle::PM_SmallIconSize); const int closeButtonSize = style()->pixelMetric(QStyle::PM_SmallIconSize) - 2; #else const int iconSize = 18; const int closeButtonSize = 15; #endif QPushButton *closeButton = new QPushButton; closeButton->setIcon(style()->standardIcon(QStyle::SP_TitleBarCloseButton)); closeButton->setIconSize(QSize(closeButtonSize, closeButtonSize)); closeButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); closeButton->setFixedSize(closeButtonSize, closeButtonSize); QObject::connect(closeButton, SIGNAL(clicked()), this, SLOT(close())); QLabel *msgLabel = new QLabel; #ifdef Q_OS_WINCE f.setBold(false); msgLabel->setFont(f); #endif msgLabel->installEventFilter(this); msgLabel->setText(message); msgLabel->setTextFormat(Qt::PlainText); msgLabel->setAlignment(Qt::AlignTop | Qt::AlignLeft); // smart size for the message label #ifdef Q_OS_WINCE int limit = QApplication::desktop()->availableGeometry(msgLabel).size().width() / 2; #else int limit = QApplication::desktop()->availableGeometry(msgLabel).size().width() / 3; #endif if (msgLabel->sizeHint().width() > limit) { msgLabel->setWordWrap(true); if (msgLabel->sizeHint().width() > limit) { msgLabel->d_func()->ensureTextControl(); if (QWidgetTextControl *control = msgLabel->d_func()->control) { QTextOption opt = control->document()->defaultTextOption(); opt.setWrapMode(QTextOption::WrapAnywhere); control->document()->setDefaultTextOption(opt); } } #ifdef Q_OS_WINCE // Make sure that the text isn't wrapped "somewhere" in the balloon widget // in the case that we have a long title label. setMaximumWidth(limit); #else // Here we allow the text being much smaller than the balloon widget // to emulate the weird standard windows behavior. msgLabel->setFixedSize(limit, msgLabel->heightForWidth(limit)); #endif } QIcon si; switch (icon) { case QSystemTrayIcon::Warning: si = style()->standardIcon(QStyle::SP_MessageBoxWarning); break; case QSystemTrayIcon::Critical: si = style()->standardIcon(QStyle::SP_MessageBoxCritical); break; case QSystemTrayIcon::Information: si = style()->standardIcon(QStyle::SP_MessageBoxInformation); break; case QSystemTrayIcon::NoIcon: default: break; } QGridLayout *layout = new QGridLayout; if (!si.isNull()) { QLabel *iconLabel = new QLabel; iconLabel->setPixmap(si.pixmap(iconSize, iconSize)); iconLabel->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); iconLabel->setMargin(2); layout->addWidget(iconLabel, 0, 0); layout->addWidget(titleLabel, 0, 1); } else { layout->addWidget(titleLabel, 0, 0, 1, 2); } layout->addWidget(closeButton, 0, 2); layout->addWidget(msgLabel, 1, 0, 1, 3); layout->setSizeConstraint(QLayout::SetFixedSize); layout->setMargin(3); setLayout(layout); QPalette pal = palette(); pal.setColor(QPalette::Window, QColor(0xff, 0xff, 0xe1)); pal.setColor(QPalette::WindowText, Qt::black); setPalette(pal); }
void GraphEditor::setDataFont( QFont fnt ) { _leDataFont->setFont(fnt); _leDataFont->setText(fnt.toString()); }
void CurveWidget::paintEvent(QPaintEvent * /* event */) { QPainter *painter = new QPainter(this); painter->setRenderHint(QPainter::Antialiasing, true); static const QColor BASE_COLOR(Qt::black); static const QColor AXE_COLOR(Qt::black); QColor EXTREMITY_COLOR(isEnabled()? Qt::red : Qt::gray); QColor CURVE_COLOR(isEnabled()? Qt::darkRed : Qt::gray); QColor BREAKPOINT_COLOR(isEnabled()? Qt::blue : Qt::gray); static const QColor MOVING_BREAKPOINT_COLOR(Qt::darkBlue); static const QColor UNACTIVE_COLOR(Qt::darkGray); // Abcisses line QPen penXAxis((_unactive) ? UNACTIVE_COLOR : AXE_COLOR); painter->setPen(penXAxis); painter->drawLine(0, _xAxisPos, width(), _xAxisPos); painter->setPen(BASE_COLOR); vector<float>::iterator it; map<float, pair<float, float> >::iterator it2; float pointSizeX = 6; float pointSizeY = 6; QPointF curPoint(0, 0); QPointF precPoint(-1, -1); unsigned int i = 0; for (it = _abstract->_curve.begin(); it != _abstract->_curve.end(); ++it) { curPoint = absoluteCoordinates(QPointF(1, *it)); curPoint.setX(i * _interspace * _scaleX); if (it == _abstract->_curve.begin()) { // First point is represented by a specific color painter->fillRect(QRectF(curPoint - QPointF(pointSizeX / 2., pointSizeY / 2.), QSizeF(pointSizeX, pointSizeY)), EXTREMITY_COLOR); } if (precPoint != QPointF(-1, -1)) { QPen pen(_unactive ? UNACTIVE_COLOR : CURVE_COLOR); pen.setWidth(_unactive ? 1 : 2); painter->setPen(pen); painter->drawLine(precPoint, curPoint); // Draw lines between values painter->setPen(BASE_COLOR); } precPoint = curPoint; i++; } // Last point is represented by a specific color if (!_unactive) { painter->fillRect(QRectF(curPoint - QPointF(pointSizeX / 2., pointSizeY / 2.), QSizeF(pointSizeX, pointSizeY)), EXTREMITY_COLOR); precPoint = QPointF(-1, -1); for (it2 = _abstract->_breakpoints.begin(); it2 != _abstract->_breakpoints.end(); ++it2) { curPoint = absoluteCoordinates(QPointF(it2->first, it2->second.first)); // Breakpoints are drawn with rectangles painter->fillRect(QRectF(curPoint - QPointF(pointSizeX / 2., pointSizeY / 2.), QSizeF(pointSizeX, pointSizeY)), _unactive ? UNACTIVE_COLOR : BREAKPOINT_COLOR); precPoint = curPoint; } if (_movingBreakpointX != -1 && _movingBreakpointY != -1) { QPointF cursor = absoluteCoordinates(QPointF(_movingBreakpointX, _movingBreakpointY)); // If a breakpoint is currently being moved, it is represented by a rectangle painter->fillRect(QRectF(cursor - QPointF(pointSizeX / 2., pointSizeY / 2.), QSizeF(pointSizeX, pointSizeY)), _abstract->_interpolate ? MOVING_BREAKPOINT_COLOR : UNACTIVE_COLOR); } } //text : minY, maxY if(_minYModified || _maxYModified) { painter->save(); QFont textFont; textFont.setPointSize(9.); painter->setFont(textFont); painter->setPen(QPen(Qt::black)); if(_minYModified) { painter->drawText(*_minYTextRect,QString("%1").arg(_minY)); _minYModified = false; } else if(_maxYModified) { painter->drawText(*_maxYTextRect,QString("%1").arg(_maxY)); _maxYModified = false; } painter->restore(); } delete painter; }
/** * First Panel - Meta Info * All the usual MetaData are displayed and can be changed. **/ MetaPanel::MetaPanel( QWidget *parent, intf_thread_t *_p_intf ) : QWidget( parent ), p_intf( _p_intf ) { QGridLayout *metaLayout = new QGridLayout( this ); metaLayout->setVerticalSpacing( 0 ); QFont smallFont = QApplication::font(); smallFont.setPointSize( smallFont.pointSize() - 1 ); smallFont.setBold( true ); int line = 0; /* Counter for GridLayout */ p_input = NULL; QLabel *label; #define ADD_META( string, widget, col, colspan ) { \ label = new QLabel( qtr( string ) ); label->setFont( smallFont ); \ label->setContentsMargins( 3, 2, 0, 0 ); \ metaLayout->addWidget( label, line++, col, 1, colspan ); \ widget = new QLineEdit; \ metaLayout->addWidget( widget, line, col, 1, colspan ); \ CONNECT( widget, textEdited( QString ), this, enterEditMode() ); \ } /* Title, artist and album*/ ADD_META( VLC_META_TITLE, title_text, 0, 10 ); line++; ADD_META( VLC_META_ARTIST, artist_text, 0, 10 ); line++; ADD_META( VLC_META_ALBUM, collection_text, 0, 7 ); /* Date */ label = new QLabel( qtr( VLC_META_DATE ) ); label->setFont( smallFont ); label->setContentsMargins( 3, 2, 0, 0 ); metaLayout->addWidget( label, line - 1, 7, 1, 2 ); /* Date (Should be in years) */ date_text = new QLineEdit; date_text->setAlignment( Qt::AlignRight ); date_text->setInputMask("0000"); date_text->setMaximumWidth( 140 ); metaLayout->addWidget( date_text, line, 7, 1, -1 ); line++; /* Genre Name */ /* TODO List id3genres.h is not includable yet ? */ ADD_META( VLC_META_GENRE, genre_text, 0, 7 ); /* Number - on the same line */ label = new QLabel( qtr( VLC_META_TRACK_NUMBER ) ); label->setFont( smallFont ); label->setContentsMargins( 3, 2, 0, 0 ); metaLayout->addWidget( label, line - 1, 7, 1, 3 ); seqnum_text = new QLineEdit; seqnum_text->setMaximumWidth( 64 ); seqnum_text->setAlignment( Qt::AlignRight ); metaLayout->addWidget( seqnum_text, line, 7, 1, 1 ); label = new QLabel( "/" ); label->setFont( smallFont ); metaLayout->addWidget( label, line, 8, 1, 1 ); seqtot_text = new QLineEdit; seqtot_text->setMaximumWidth( 64 ); seqtot_text->setAlignment( Qt::AlignRight ); metaLayout->addWidget( seqtot_text, line, 9, 1, 1 ); line++; /* Rating - on the same line */ /* metaLayout->addWidget( new QLabel( qtr( VLC_META_RATING ) ), line, 4, 1, 2 ); rating_text = new QSpinBox; setSpinBounds( rating_text ); metaLayout->addWidget( rating_text, line, 6, 1, 1 ); */ /* Now Playing - Useful for live feeds (HTTP, DVB, ETC...) */ ADD_META( VLC_META_NOW_PLAYING, nowplaying_text, 0, 7 ); nowplaying_text->setReadOnly( true ); line--; /* Language on the same line */ ADD_META( VLC_META_LANGUAGE, language_text, 7, -1 ); line++; ADD_META( VLC_META_PUBLISHER, publisher_text, 0, 7 ); fingerprintButton = new QPushButton( qtr("&Fingerprint") ); fingerprintButton->setToolTip( qtr( "Find meta data using audio fingerprinting" ) ); fingerprintButton->setVisible( false ); metaLayout->addWidget( fingerprintButton, line, 7 , 3, -1 ); CONNECT( fingerprintButton, clicked(), this, fingerprint() ); line++; lblURL = new QLabel; lblURL->setOpenExternalLinks( true ); lblURL->setTextFormat( Qt::RichText ); metaLayout->addWidget( lblURL, line -1, 7, 1, -1 ); ADD_META( VLC_META_COPYRIGHT, copyright_text, 0, 7 ); line++; /* ART_URL */ art_cover = new CoverArtLabel( this, p_intf ); metaLayout->addWidget( art_cover, line, 7, 6, 3, Qt::AlignLeft ); ADD_META( VLC_META_ENCODED_BY, encodedby_text, 0, 7 ); line++; label = new QLabel( qtr( N_("Comments") ) ); label->setFont( smallFont ); label->setContentsMargins( 3, 2, 0, 0 ); metaLayout->addWidget( label, line++, 0, 1, 7 ); description_text = new QTextEdit; description_text->setAcceptRichText( false ); metaLayout->addWidget( description_text, line, 0, 1, 7 ); // CONNECT( description_text, textChanged(), this, enterEditMode() ); //FIXME line++; /* VLC_META_SETTING: Useless */ /* ADD_META( TRACKID ) Useless ? */ /* ADD_URI - Do not show it, done outside */ metaLayout->setColumnStretch( 1, 20 ); metaLayout->setColumnMinimumWidth ( 1, 80 ); metaLayout->setRowStretch( line, 10 ); #undef ADD_META CONNECT( seqnum_text, textEdited( QString ), this, enterEditMode() ); CONNECT( seqtot_text, textEdited( QString ), this, enterEditMode() ); CONNECT( date_text, textEdited( QString ), this, enterEditMode() ); // CONNECT( THEMIM->getIM(), artChanged( QString ), this, enterEditMode() ); /* CONNECT( rating_text, valueChanged( QString ), this, enterEditMode( QString ) );*/ /* We are not yet in Edit Mode */ b_inEditMode = false; }
SongdisplayWidget::SongdisplayWidget( QWidget *parent ) : QWidget( parent ) { this->cover = new QLabel( this ); this->cover->setFixedSize( 64, 64 ); setDefaultIcon(); // Build the rows this->title = new QLabel( this ); QFont font = this->title->font(); font.setPointSize( font.pointSize() + 5 ); this->title->setFont( font ); this->title->setMinimumWidth( 300 ); this->title->setSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::Fixed ); this->artist = new QLabel( this ); this->album = new QLabel( this ); this->song_box = new QWidget(); QVBoxLayout *layout = new QVBoxLayout( this ); layout->addWidget( this->title ); layout->addWidget( this->artist ); layout->addWidget( this->album ); this->song_box->setLayout( layout ); QHBoxLayout *foo = new QHBoxLayout( this ); foo->addWidget( this->cover ); foo->addWidget( this->song_box ); this->setLayout( foo ); QPalette sample_palette; sample_palette.setColor( QPalette::Window, Qt::black ); sample_palette.setColor( QPalette::WindowText, Qt::gray ); this->setAutoFillBackground( true ); this->setPalette( sample_palette ); //this->setText("What ever text"); QPalette sample_palette2; sample_palette2.setColor( QPalette::Window, Qt::black ); sample_palette2.setColor( QPalette::WindowText, QColor( 200, 200, 200 ) ); this->title->setPalette( sample_palette2 ); this->title->setText( "1111" ); sample_palette2.setColor( QPalette::Window, Qt::black ); sample_palette2.setColor( QPalette::WindowText, QColor( 150, 150, 150 ) ); this->artist->setPalette( sample_palette2 ); this->artist->setText( "2222" ); sample_palette2.setColor( QPalette::Window, Qt::black ); sample_palette2.setColor( QPalette::WindowText, QColor( 100, 100, 100 ) ); this->album->setPalette( sample_palette2 ); this->album->setText( "3333" ); this->currentTrack = new Track(); manager = new QNetworkAccessManager(); setupSignals(); }
void PKPlayerListWidget::UpdatePKPlayerList(const QList<Player> &playerList) { PKPlayerListWidgetDebug("PKPlayerListWidget UpdatePKPlayerList"); ui->playerListWidget->setRowCount(playerList.size()); ui->playerListWidget->setColumnCount(4); QFont font; font.setPixelSize(12); font.setWeight(75); font.setBold(true); font.setFamily("宋体"); for(int row = 0; row < playerList.size(); row++) { ui->playerListWidget->setRowHeight(row,36); for(int column = 0;column < 4;column++) { QLabel *label =new QLabel(); label->setFont(font); int hostNameLen = 65; switch(column) { case 0: PKPlayerListWidgetDebug("PKPlayerListWidget UpdatePKPlayerList0"); ui->playerListWidget->setColumnWidth(column,41); label->setStyleSheet(QString("border-image: url(:/image/PKRoomUI/seq_%1.png);").arg(row+1)); ui->playerListWidget->setCellWidget(row, column, label); break; case 1: PKPlayerListWidgetDebug("PKPlayerListWidget UpdatePKPlayerList1"); ui->playerListWidget->setColumnWidth(column,114); label->setText(QString("<font color=\"#ffffff\"> %1</font>").arg(playerList[row].getShortCutName(label->font(), hostNameLen))); ui->playerListWidget->setCellWidget(row, column, label); break; case 2: PKPlayerListWidgetDebug("PKPlayerListWidget UpdatePKPlayerList2"); ui->playerListWidget->setColumnWidth(column,34); if(row==0) { label->setText(QString("<font color=\"#fad22f\">主æ’</font>")); } else { label->setText(QString("<font color=\"#ffffff\">出价</font>")); } ui->playerListWidget->setCellWidget(row, column, label); break; case 3: PKPlayerListWidgetDebug("PKPlayerListWidget UpdatePKPlayerList3"); ui->playerListWidget->setColumnWidth(column,105); if(row == 0) { delete label; label = NULL; }else { PKPlayerListWidgetDebug("PKPlayerListWidget UpdatePKPlayerList4 %d", playerList[row].getProp().getUseNumber()); label->setText(QString("<font color = \"#fad22f\">%1 </font> <font color = \"#ffffff\">æ–—æŒè±†</font>").arg(playerList[row].getProp().getUseNumber())); ui->playerListWidget->setCellWidget(row, column, label); } break; default: break; } } } }
axis->setTickStep(1.0); axis->setAutoTickLabels(false); axis->setSubTickPen(no_pen); axis->setTickPen(no_pen); axis->setBasePen(no_pen); } value_axis_->grid()->setVisible(false); key_axis_->setRangeReversed(true); key_axis_->grid()->setVisible(false); comment_axis_->setRangeReversed(true); comment_axis_->grid()->setVisible(false); QFont comment_font = comment_axis_->tickLabelFont(); comment_font.setPointSizeF(comment_font.pointSizeF() * 0.8); smooth_font_size(comment_font); comment_axis_->setTickLabelFont(comment_font); comment_axis_->setSelectedTickLabelFont(QFont(comment_font.family(), comment_font.pointSizeF(), QFont::Bold)); // frame_label // port_src -----------------> port_dst // setTickVectorLabels // valueAxis->setTickLabelRotation(30); } SequenceDiagram::~SequenceDiagram() { delete data_; }
void TomahawkApp::init() { if ( arguments().contains( "--help" ) || arguments().contains( "-h" ) ) { printHelp(); ::exit( 0 ); } qDebug() << "TomahawkApp thread:" << thread(); Logger::setupLogfile(); qsrand( QTime( 0, 0, 0 ).secsTo( QTime::currentTime() ) ); tLog() << "Starting Tomahawk..."; #ifdef ENABLE_HEADLESS m_headless = true; #else m_mainwindow = 0; m_headless = arguments().contains( "--headless" ); setWindowIcon( QIcon( RESPATH "icons/tomahawk-icon-128x128.png" ) ); setQuitOnLastWindowClosed( false ); QFont f = APP->font(); f.setPixelSize( HeaderLabel::defaultFontSize() ); QFontMetrics fm( f ); TomahawkUtils::setHeaderHeight( fm.height() + 8 ); #endif TomahawkSettings* s = TomahawkSettings::instance(); tDebug( LOGINFO ) << "Setting NAM."; // Cause the creation of the nam, but don't need to address it directly, so prevent warning Q_UNUSED( TomahawkUtils::nam() ); m_audioEngine = QWeakPointer<AudioEngine>( new AudioEngine ); m_scanManager = QWeakPointer<ScanManager>( new ScanManager( this ) ); // init pipeline and resolver factories new Pipeline(); #ifndef ENABLE_HEADLESS Pipeline::instance()->addExternalResolverFactory( boost::bind( &QtScriptResolver::factory, _1 ) ); Pipeline::instance()->addExternalResolverFactory( boost::bind( &ScriptResolver::factory, _1 ) ); new ActionCollection( this ); connect( ActionCollection::instance()->getAction( "quit" ), SIGNAL( triggered() ), SLOT( quit() ), Qt::UniqueConnection ); #endif m_servent = QWeakPointer<Servent>( new Servent( this ) ); connect( m_servent.data(), SIGNAL( ready() ), SLOT( initSIP() ) ); tDebug() << "Init Database."; initDatabase(); QByteArray magic = QByteArray::fromBase64( enApiSecret ); QByteArray wand = QByteArray::fromBase64( QCoreApplication::applicationName().toLatin1() ); int length = magic.length(), n2 = wand.length(); for ( int i=0; i<length; i++ ) magic[i] = magic[i] ^ wand[i%n2]; Echonest::Config::instance()->setAPIKey( magic ); #ifndef ENABLE_HEADLESS tDebug() << "Init Echonest Factory."; GeneratorFactory::registerFactory( "echonest", new EchonestFactory ); #endif tDebug() << "Init Database Factory."; GeneratorFactory::registerFactory( "database", new DatabaseFactory ); // Register shortcut handler for this platform #ifdef Q_WS_MAC m_shortcutHandler = QWeakPointer<Tomahawk::ShortcutHandler>( new MacShortcutHandler( this ) ); Tomahawk::setShortcutHandler( static_cast<MacShortcutHandler*>( m_shortcutHandler.data() ) ); Tomahawk::setApplicationHandler( this ); increaseMaxFileDescriptors(); #endif // Connect up shortcuts if ( !m_shortcutHandler.isNull() ) { connect( m_shortcutHandler.data(), SIGNAL( playPause() ), m_audioEngine.data(), SLOT( playPause() ) ); connect( m_shortcutHandler.data(), SIGNAL( pause() ), m_audioEngine.data(), SLOT( pause() ) ); connect( m_shortcutHandler.data(), SIGNAL( stop() ), m_audioEngine.data(), SLOT( stop() ) ); connect( m_shortcutHandler.data(), SIGNAL( previous() ), m_audioEngine.data(), SLOT( previous() ) ); connect( m_shortcutHandler.data(), SIGNAL( next() ), m_audioEngine.data(), SLOT( next() ) ); connect( m_shortcutHandler.data(), SIGNAL( volumeUp() ), m_audioEngine.data(), SLOT( raiseVolume() ) ); connect( m_shortcutHandler.data(), SIGNAL( volumeDown() ), m_audioEngine.data(), SLOT( lowerVolume() ) ); connect( m_shortcutHandler.data(), SIGNAL( mute() ), m_audioEngine.data(), SLOT( mute() ) ); } tDebug() << "Init InfoSystem."; m_infoSystem = QWeakPointer<Tomahawk::InfoSystem::InfoSystem>( Tomahawk::InfoSystem::InfoSystem::instance() ); tDebug() << "Init AccountManager."; m_accountManager = QWeakPointer< Tomahawk::Accounts::AccountManager >( new Tomahawk::Accounts::AccountManager( this ) ); connect( m_accountManager.data(), SIGNAL( ready() ), SLOT( accountManagerReady() ) ); Echonest::Config::instance()->setNetworkAccessManager( TomahawkUtils::nam() ); #ifndef ENABLE_HEADLESS EchonestGenerator::setupCatalogs(); if ( !m_headless ) { tDebug() << "Init MainWindow."; m_mainwindow = new TomahawkWindow(); m_mainwindow->setWindowTitle( "Tomahawk" ); m_mainwindow->setObjectName( "TH_Main_Window" ); if ( !arguments().contains( "--hide" ) ) { m_mainwindow->show(); } } #endif tDebug() << "Init Local Collection."; initLocalCollection(); tDebug() << "Init Pipeline."; initPipeline(); #ifndef ENABLE_HEADLESS // load remote list of resolvers able to be installed AtticaManager::instance(); #endif if ( arguments().contains( "--http" ) || TomahawkSettings::instance()->value( "network/http", true ).toBool() ) { initHTTP(); } connect( TomahawkSettings::instance(), SIGNAL( changed() ), SLOT( initHTTP() ) ); #ifndef ENABLE_HEADLESS if ( !s->hasScannerPaths() ) { m_mainwindow->showSettingsDialog(); } #endif #ifdef LIBLASTFM_FOUND tDebug() << "Init Scrobbler."; m_scrobbler = new Scrobbler( this ); #endif if ( arguments().contains( "--filescan" ) ) { m_scanManager.data()->runScan( true ); } // Set up echonest catalog synchronizer Tomahawk::EchonestCatalogSynchronizer::instance(); PlaylistUpdaterInterface::registerUpdaterFactory( new XspfUpdaterFactory ); PlaylistUpdaterInterface::registerUpdaterFactory( new SpotifyUpdaterFactory ); // Following work-around/fix taken from Clementine rev. 13e13ccd9a95 and courtesy of David Sansome // A bug in Qt means the wheel_scroll_lines setting gets ignored and replaced // with the default value of 3 in QApplicationPrivate::initialize. { QSettings qt_settings(QSettings::UserScope, "Trolltech"); qt_settings.beginGroup("Qt"); QApplication::setWheelScrollLines( qt_settings.value("wheelScrollLines", QApplication::wheelScrollLines()).toInt()); } #ifndef ENABLE_HEADLESS // Make sure to init GAM in the gui thread GlobalActionManager::instance(); // check if our spotify playlist api server is up and running, and enable spotify playlist drops if so QNetworkReply* r = TomahawkUtils::nam()->get( QNetworkRequest( QUrl( SPOTIFY_PLAYLIST_API_URL "/pong" ) ) ); connect( r, SIGNAL( finished() ), this, SLOT( spotifyApiCheckFinished() ) ); #endif #ifdef Q_WS_MAC // Make sure to do this after main window is inited Tomahawk::enableFullscreen(); #endif }
void PointPlotter::plotPoints(){ pixmap->resize(size()); pixmap->fill(QColor(0, 0, 0)); if(!values.size()){ repaint(); // force a thingy.. return; } QPainter p(pixmap); // paint on the pixmap.. // plot points on a vertical line.. going from min value to max value bottom to top.. int tm, bm, lm, rm; // the margins on either side of the plot.. int indent = 10; tm = bm = rm = 30; // what the hell.. lm = 50; // need space for the labels. int h = height() - tm - bm; int w = width() - lm - rm; int x = lm + indent; // just indent it a few pixels.. int mw=8; // marker width.. float range = max - min; p.setPen(QPen(QColor(255, 255, 255), 1)); p.setBrush(QColor(0, 0, 255)); // a blue brush.. for(int i=0; i < values.size(); i++){ int y = tm + h - mw/2 - (int)( ((float)h * (values[i]-min))/range ); p.drawEllipse(x, y, mw, mw); } // and let's draw some axis.. -- p.drawLine(lm, tm, lm, tm+h); int y = tm + h; if(min <= 0){ // then we like to indicate this.. y = tm + h - (int)( ((float)h * (0-min))/range ); } p.drawLine(lm, y, lm + w, y); // and let's put some labels on it.. -- let's have a label every 40 pixels or so.. int labelHeight = 40; int ln = h/labelHeight; QFont fnt = font(); // if(fnt.pointSize() == -1){ //cout << "setting pixel size to : " << fnt.pixelSize() << endl; fnt.setPixelSize(fnt.pixelSize() - 4); }else{ fnt.setPointSize(fnt.pointSize() - 2); //cout << "setting point size to : " << fnt.pointSize() - 2 << endl; } p.setFont(fnt); for(int i=0; i < ln; i++){ // and work out what label to put on it.. in the range of min to max.. float value = min + (float(i)*range / float(ln-1)); int y = tm + h - (int)( ((float)h * (value-min))/range ); // wich of course is a long way round of doing it.. p.drawLine(lm, y, lm + indent/2, y); // and let's draw some text.. QString number; number.sprintf("%1.1e", value); p.drawText(0, y - labelHeight/2, lm-3, labelHeight, Qt::AlignRight|Qt::AlignVCenter, number); } // if the threshold is changing we need to recalculate it from the change in position.. if(thresholdChanging){ //cout << "threshold changing from " << threshold << " to : "; threshold -= (range * float(thisY - lastY)/float(h)); //cout << threshold << endl; } if(drawThreshold){ // well we better draw it.. int y = tm + h - (int)( ((float)h * (threshold-min))/range ); // and if silly, don't draw it.. if(y <= h + tm){ QString number; number.sprintf("%1.3e", threshold); p.drawLine(lm, y, lm + w, y); p.drawText(lm, y - labelHeight, w - 3, labelHeight-2, Qt::AlignRight|Qt::AlignBottom, number); } } repaint(); }
/*! * \class TextCursorChangeFontFace * \author Anders Fernström * \date 2005-11-03 * \date 2006-01-13 (update) * * \brief Command for changing font face * * 2005-11-07 AF, Added function (case 4) in switch to change * strikckout settings * 2005-11-15 AF, added trick to get correct style on links * 2006-01-13 AF, remove trick to get correct style on links because * it made undo/redo work incorrectly */ void TextCursorChangeFontFace::execute() { QTextEdit *editor = document()->getCursor()->currentCell()->textEdit(); QFont font; if( editor ) { switch( face_ ) { case 0: // Plain editor->setFontWeight( QFont::Normal ); editor->setFontItalic( false ); editor->setFontUnderline( false ); font = editor->currentFont(); font.setStrikeOut( false ); editor->setCurrentFont( font ); break; case 1: // Bold if( editor->fontWeight() != QFont::Normal ) editor->setFontWeight( QFont::Normal ); else editor->setFontWeight( QFont::Bold ); break; case 2: // Italic if( editor->fontItalic() ) editor->setFontItalic( false ); else editor->setFontItalic( true ); break; case 3: // Underline if( editor->fontUnderline() ) editor->setFontUnderline( false ); else editor->setFontUnderline( true ); break; case 4: // Strickout font = editor->currentFont(); if( font.strikeOut() ) font.setStrikeOut( false ); else font.setStrikeOut( true ); editor->setCurrentFont( font ); break; } // ugly trick to make the sure that the links haven't change // color /* if( !editor->toPlainText().isEmpty() ) { int start = editor->textCursor().selectionStart(); int end = editor->textCursor().selectionEnd(); editor->setHtml( editor->toHtml() ); QTextCursor cursor( editor->textCursor() ); cursor.setPosition( start ); cursor.setPosition( end, QTextCursor::KeepAnchor ); editor->setTextCursor( cursor ); }*/ } }
QVariant LocationListModel::data(const QModelIndex& index, int role) const { if (!isValidIndex(index)) return QVariant(); const Location& loc = *locations[index.row()]; if (role == Qt::BackgroundRole && loc.hasDuplicate) { return QBrush(Qt::red, Qt::SolidPattern); } // Columns follow the formatting of the file. switch (index.column()) { case 0: // Name if (role == Qt::DisplayRole || role == Qt::EditRole) return loc.name; if (role == Qt::ToolTipRole) return loc.stelId; break; case 1: // Region if (role == Qt::DisplayRole || role == Qt::EditRole) return loc.region; break; case 2: // Country if (role == Qt::DisplayRole) return loc.countryName; else if (role == Qt::EditRole) return loc.country; else if (role == Qt::FontRole) { // Mark non-coded countries if (loc.country == loc.countryName) { QFont font; font.setBold(true); return font; } else return QVariant(); } break; case 3: // Type if (role == Qt::DisplayRole || role == Qt::EditRole) return loc.role; break; case 4: // Population if (role == Qt::DisplayRole || role == Qt::EditRole) return loc.population; break; case 5: // Latitude if (role == Qt::DisplayRole || role == Qt::EditRole) return loc.latitudeStr; if (role == Qt::ToolTipRole) return loc.latitude; if (role == (Qt::UserRole + 1)) return loc.latitude; break; case 6: // Longitude if (role == Qt::DisplayRole || role == Qt::EditRole) return loc.longitudeStr; if (role == Qt::ToolTipRole) return loc.longitude; if (role == (Qt::UserRole + 1)) return loc.longitude; break; case 7: // Altitude if (role == Qt::DisplayRole || role == Qt::EditRole) return loc.altitude; break; case 8: // Light pollution if (role == Qt::DisplayRole) { if (loc.bortleScaleIndex < 0.) return QVariant(); else return loc.bortleScaleIndex; } else if (role == Qt::EditRole) { return loc.bortleScaleIndex; } case 9: // Time zone if (role == Qt::DisplayRole || role == Qt::EditRole) return loc.timeZone; break; case 10: // Planet if (role == Qt::DisplayRole || role == Qt::EditRole) return loc.planetName; break; case 11: // Landscape if (role == Qt::DisplayRole || role == Qt::EditRole) return loc.landscapeKey; break; default: break; } return QVariant(); }
void SetUpStatus::addMessage() { QVBoxLayout *pvbox = new QVBoxLayout; QFont font = QLabel().font(); font.setPointSize(20); font.setBold(true); QGroupBox *groupbox1 = new QGroupBox; QVBoxLayout *python = new QVBoxLayout; QLabel *header1 = new QLabel("Python Executable"); header1->setFont(font); QLabel *message1 = new QLabel( messages[3]); python->addWidget(header1); python->addWidget(message1); groupbox1->setLayout(python); QGroupBox *groupbox2 = new QGroupBox; QVBoxLayout *metapathways = new QVBoxLayout; QLabel *header2 = new QLabel("MetaPathways Directory"); header2->setFont(font); QLabel *message2 = new QLabel( messages[0]); metapathways->addWidget(header2); metapathways->addWidget(message2); groupbox2->setLayout(metapathways); QGroupBox *groupbox3 = new QGroupBox; QVBoxLayout *executables = new QVBoxLayout; QLabel *header3 = new QLabel("Dir for OS specific executables : "); header3->setFont(font); QLabel *message3 = new QLabel( messages[2]); executables->addWidget(header3); executables->addWidget(message3); groupbox3->setLayout(executables); QGroupBox *groupbox4 = new QGroupBox; QVBoxLayout *databases = new QVBoxLayout; QLabel *header4 = new QLabel("Databases directory :"); header4->setFont(font); QLabel *message4 = new QLabel( messages[1]); databases->addWidget(header4); databases->addWidget(message4); groupbox4->setLayout(databases); QGroupBox *groupbox5 = new QGroupBox; QVBoxLayout *pgdbs = new QVBoxLayout; QLabel *header5 = new QLabel("PGDB Folder Path :"); header5->setFont(font); QLabel *message5 = new QLabel( messages[4]); pgdbs->addWidget(header5); pgdbs->addWidget(message5); groupbox5->setLayout(pgdbs); QGroupBox *groupbox6 = new QGroupBox; QVBoxLayout *pathwaytools = new QVBoxLayout; QLabel *header6 = new QLabel("Pathway-Tools executables :"); header6->setFont(font); QLabel *message6 = new QLabel( messages[5]); pathwaytools->addWidget(header6); pathwaytools->addWidget(message6); groupbox6->setLayout(pathwaytools); QGroupBox *groupbox = new QGroupBox; QHBoxLayout* vbox = new QHBoxLayout; QPushButton * cancelButton = new QPushButton("Cancel"); QPushButton *saveButton = new QPushButton("Save"); QSpacerItem * horizontalSpacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); vbox->addItem(horizontalSpacer); vbox->addWidget(cancelButton); vbox->addWidget(saveButton); groupbox->setLayout(vbox); connect(saveButton, SIGNAL(clicked()), this, SLOT(saveConfig() ) ); connect(cancelButton, SIGNAL(clicked()), this, SLOT(destroy())); pvbox->addWidget(groupbox2); pvbox->addWidget(groupbox4); pvbox->addWidget(groupbox3); pvbox->addWidget(groupbox1); pvbox->addWidget(groupbox5); pvbox->addWidget(groupbox6); pvbox->addWidget(groupbox); this->setLayout(pvbox); }
void IdentityItemDelegate::paint(QPainter *p, const QStyleOptionViewItem &opt, const QModelIndex &index) const { p->save(); /* Exclude shadow area */ QRect r = opt.rect.adjusted(0, (index.row() ? topShadow : 0), 0, -bottomShadow); /* Selection */ if (opt.state & (QStyle::State_Selected | QStyle::State_MouseOver)) { SelectionState sst = (opt.state & QStyle::State_Selected) ? Selected : MouseOver; p->drawPixmap(r.topLeft(), customSelectionRect(r.size(), sst)); } else { QLinearGradient gradient(0, 0, 0, 1); gradient.setCoordinateMode(QGradient::ObjectBoundingMode); gradient.setColorAt(0, QColor(253, 253, 253)); gradient.setColorAt(1, QColor(231, 231, 231)); p->fillRect(opt.rect, QBrush(gradient)); /* Shadowing */ const int left = opt.rect.left(); const int right = opt.rect.right(); const int bottom = opt.rect.bottom(); const int top = opt.rect.top(); int shd[4] = { 216, 232, 243, 251 }; for (int i = 0; i < 4; ++i) { p->setPen(QColor(shd[i], shd[i], shd[i])); p->drawLine(QPoint(left, bottom - (3-i)), QPoint(right, bottom - (3-i))); } if (index.row() != 0) { for (int i = 0; i < 3; ++i) shd[i] = qMin(shd[i]+10, 255); p->setPen(QColor(shd[0], shd[0], shd[0])); p->drawLine(QPoint(left, top + 2), QPoint(right, top + 2)); p->setPen(QColor(shd[1], shd[1], shd[1])); p->drawLine(QPoint(left, top + 1), QPoint(right, top + 1)); p->setPen(QColor(shd[2], shd[2], shd[2])); p->drawLine(QPoint(left, top), QPoint(right, top)); } } /* Exclude margins from r */ r.adjust(xMargin, yMargin, -xMargin, -yMargin); /* Name */ QFont nameFont = opt.font; nameFont.setPixelSize(16); p->setFont(nameFont); p->setPen(QColor(0x00, 0x66, 0xaa)); p->drawText(r, Qt::AlignCenter, index.data().toString()); /* Status */ QPixmap status = index.data(ContactsModel::StatusIndicator).value<QPixmap>(); p->drawPixmap((qreal)r.x(), (qreal)r.y() + 1 + ((r.height() - status.height())/(qreal)2), status); p->restore(); }
QFont QgsDetailedItemDelegate::categoryFont( const QStyleOptionViewItem &theOption ) const { QFont myFont = theOption.font; myFont.setBold( true ); return myFont; }
void Strings::paint(QPainter *painter, bool printMode) { painter->save(); painter->setRenderHint(QPainter::Antialiasing); if(!printMode){ if(selected_){ painter->setBrush(Qt::darkBlue); painter->setPen(Qt::darkBlue); }else{ painter->setBrush(Qt::black); painter->setPen(Qt::black); } }else{ painter->setPen(Qt::lightGray); painter->setBrush(Qt::NoBrush); } painter->drawRect(0,0,size_.width(),size_.height()); //Base point QPoint base(20,25); //Rect where strings will be drawn QRect strings(base,QSize(size_.width()-base.x()-10,size_.height()-base.y()-10)); //Main Fret if(printMode){ painter->setPen(Qt::darkGray); painter->setBrush(Qt::darkGray); }else{ painter->setPen(Qt::white); painter->setBrush(Qt::white); } painter->drawRect(base.x(),base.y()-5,strings.width(),5); painter->setBrush(Qt::NoBrush); painter->drawRect(strings); QList<int> poses; int min = -1; int max = -1; //Find min and max, save poses QList<QString> fingers = fingers_.split(" ", QString::SkipEmptyParts); int nbString = fingers.size(); if(nbString<2|| nbString>12){ painter->restore(); return; } bool containEmpty = false; foreach(QString finger, fingers){ if(finger=="X"||finger=="x"){ poses.push_back(-1); continue; } bool ok; int pose = finger.toInt(&ok); if(!ok){ poses.push_back(-1); continue; }else{ poses.push_back(pose); } if(pose==0){ containEmpty = true; continue; } if(pose>max) max = pose; if(pose<min || min==-1) min = pose; } int shift = 0; if(max>5) shift = min-1; //Strings double incr_v = (double)(strings.width()) / (double)(nbString-1); for(int i=0;i<nbString;i++){ painter->drawLine(base.x()+incr_v*i,base.y(), base.x()+incr_v*i,base.y()+strings.height()); } //Frets double incr_h = (double)(strings.height()) / 5; for(int i=0;i<6;i++){ painter->drawLine(base.x(),base.y()+incr_h*i, base.x()+strings.width(),base.y()+incr_h*i); } int s = 5.0 * size_.width() / 150.0; for(int i=0;i<nbString;i++){ //Draw a cross in case of no playing string if(poses[i]<0){ if(printMode) painter->setPen(Qt::black); else painter->setPen(QPen(Qt::red,2)); painter->drawLine(base.x()+incr_v*i-s,10-s, base.x()+incr_v*i+s,10+s); painter->drawLine(base.x()+incr_v*i+s,10-s, base.x()+incr_v*i-s,10+s); continue; } int pose = poses[i]; //Draw a circle in case of empty string if(pose==0){ if(printMode) painter->setPen(Qt::black); else painter->setPen(QPen(Qt::red,2)); painter->setBrush(Qt::NoBrush); painter->drawEllipse(QPointF(base.x()+i*incr_v,10),s,s); continue; } pose -= shift; //If pose is out of the drawing if(pose>5) continue; if(printMode){ painter->setPen(Qt::black); painter->setBrush(Qt::black); }else{ painter->setPen(Qt::red); painter->setBrush(Qt::red); } painter->drawEllipse(QPointF(base.x()+i*incr_v,base.y()+pose*incr_h - (double)incr_h/2.0),s+2,s+2); } //Draw a bar if needed if(min>0 && !containEmpty){ QList<int> list; for(int i=0;i<nbString;i++){ if(poses[i]==min) list.push_back(i); } //If there are several minima, draw a bar if(list.size()>1){ if(printMode){ painter->setPen(Qt::black); painter->setBrush(Qt::black); }else{ painter->setPen(Qt::red); painter->setBrush(Qt::red); } painter->drawRect(base.x()+list.first()*incr_v, base.y()+(double)(min-shift)*incr_h-(s+2) - (double)incr_h/2.0, (double)(list.last()-list.first())*incr_v,2*s+5); } } //Print first fret QFont font = painter->font(); if(printMode){ painter->setPen(Qt::black); font.setPointSize(8); }else{ painter->setPen(Qt::white); font.setPointSize(12); } painter->setFont(font); painter->setBrush(Qt::NoBrush); painter->drawText(0,16,20,16,Qt::AlignCenter,QString::number(1+shift)); painter->restore(); }
void GraphEditor::setValueTitleFont( QFont fnt ) { _leValueTitleFont->setFont(fnt); _leValueTitleFont->setText(fnt.toString()); }
Stats::Stats(QQuickItem* parent) : QQuickItem(parent) { INSTANCE = this; const QFont font = QFontDatabase::systemFont(QFontDatabase::FixedFont); _monospaceFont = font.family(); _audioStats = &DependencyManager::get<AudioClient>()->getStats(); }
void MsgEdit::editFontChanged(const QFont &f) { btnBold->setOn(f.bold()); btnItalic->setOn(f.italic()); btnUnder->setOn(f.underline()); }
bool ChartShape::Private::loadOdfLabel(KoShape *label, KoXmlElement &labelElement, KoShapeLoadingContext &context) { TextLabelData *labelData = qobject_cast<TextLabelData*>(label->userData()); if (!labelData) return false; // Following will always return false cause KoTextShapeData::loadOdf will try to load // a frame while our text:p is not within a frame. So, let's just not call loadOdf then... //label->loadOdf(labelElement, context); // 1. set the text KoXmlElement pElement = KoXml::namedItemNS(labelElement, KoXmlNS::text, "p"); QTextDocument* doc = labelData->document(); doc->setPlainText(pElement.text()); // 2. set the position QPointF pos = label->position(); bool posChanged = false; if (labelElement.hasAttributeNS(KoXmlNS::svg, "x")) { pos.setX(KoUnit::parseValue(labelElement.attributeNS(KoXmlNS::svg, "x", QString()))); posChanged = true; } if (labelElement.hasAttributeNS(KoXmlNS::svg, "y")) { pos.setY(KoUnit::parseValue(labelElement.attributeNS(KoXmlNS::svg, "y", QString()))); posChanged = true; } if (posChanged) { label->setPosition(pos); } // 3. set the styles if (labelElement.hasAttributeNS(KoXmlNS::chart, "style-name")) { KoStyleStack &styleStack = context.odfLoadingContext().styleStack(); styleStack.clear(); context.odfLoadingContext().fillStyleStack(labelElement, KoXmlNS::chart, "style-name", "chart"); styleStack.setTypeProperties("chart"); if (styleStack.hasProperty(KoXmlNS::style, "rotation-angle")) { qreal rotationAngle = 360 - KoUnit::parseValue(styleStack.property(KoXmlNS::style, "rotation-angle")); label->rotate(rotationAngle); } styleStack.setTypeProperties("text"); if (styleStack.hasProperty(KoXmlNS::fo, "font-size")) { const qreal fontSize = KoUnit::parseValue(styleStack.property(KoXmlNS::fo, "font-size")); QFont font = doc->defaultFont(); font.setPointSizeF(fontSize); doc->setDefaultFont(font); } if (styleStack.hasProperty(KoXmlNS::fo, "font-family")) { const QString fontFamily = styleStack.property(KoXmlNS::fo, "font-family"); QFont font = doc->defaultFont(); font.setFamily(fontFamily); doc->setDefaultFont(font); } } // 4. set the size if (labelElement.hasAttributeNS(KoXmlNS::svg, "width") && labelElement.hasAttributeNS(KoXmlNS::svg, "height")) { const qreal width = KoUnit::parseValue(labelElement.attributeNS(KoXmlNS::svg, "width")); const qreal height = KoUnit::parseValue(labelElement.attributeNS(KoXmlNS::svg, "height")); label->setSize(QSizeF(width, height)); } else { QSizeF size = shape->size(); QRect r = QFontMetrics(doc->defaultFont()).boundingRect( labelData->shapeMargins().left, labelData->shapeMargins().top, qMax(CM_TO_POINT(5), qreal(size.width() - pos.x() * 2.0 - labelData->shapeMargins().right)), qMax(CM_TO_POINT(0.6), qreal(size.height() - labelData->shapeMargins().bottom)), Qt::AlignLeft | Qt::AlignTop | Qt::TextWordWrap, doc->toPlainText()); label->setSize(r.size()); } return true; }
void MainWindow::onFontPointSizeChanged() { QFont fnt = currentFont(); fnt.setPointSize( m_pCmbFontPointSize->currentText().toInt() ); setCurrentFont( fnt ); }
ChartShape::ChartShape(KoDocumentResourceManager *resourceManager) : KoFrameShape(KoXmlNS::draw, "object") , KoShapeContainer(new ChartLayout) , d (new Private(this)) { d->resourceManager = resourceManager; setShapeId(ChartShapeId); // Instantiated all children first d->proxyModel = new ChartProxyModel(this, &d->tableSource); d->plotArea = new PlotArea(this); d->document = new ChartDocument(this); d->legend = new Legend(this); // Configure the plotarea. // We need this as the very first step, because some methods // here rely on the d->plotArea pointer. addShape(d->plotArea); d->plotArea->plotAreaInit(); d->plotArea->setZIndex(0); setClipped(d->plotArea, true); setInheritsTransform(d->plotArea, true); // Configure the legend. d->legend->setVisible(true); d->legend->setZIndex(1); setClipped(d->legend, true); setInheritsTransform(d->legend, true); // A few simple defaults (chart type and subtype in this case) setChartType(BarChartType); setChartSubType(NormalChartSubtype); // Create the Title, which is a standard TextShape. KoShapeFactoryBase *textShapeFactory = KoShapeRegistry::instance()->value(TextShapeId); if (textShapeFactory) d->title = textShapeFactory->createDefaultShape(resourceManager); // Potential problem 1) No TextShape installed if (!d->title) { d->title = new TextLabelDummy; if (ENABLE_USER_INTERACTION) KMessageBox::error(0, i18n("The plugin needed for displaying text labels in a chart is not available."), i18n("Plugin Missing")); // Potential problem 2) TextShape incompatible } else if (dynamic_cast<TextLabelData*>(d->title->userData()) == 0 && ENABLE_USER_INTERACTION) KMessageBox::error(0, i18n("The plugin needed for displaying text labels is not compatible with the current version of the chart Flake shape."), i18n("Plugin Incompatible")); // In both cases we need a KoTextShapeData instance to function. This is // enough for unit tests, so there has to be no TextShape plugin doing the // actual text rendering, we just need KoTextShapeData which is in the libs. if (dynamic_cast<TextLabelData*>(d->title->userData()) == 0) { TextLabelData *dataDummy = new TextLabelData; KoTextDocumentLayout *documentLayout = new KoTextDocumentLayout(dataDummy->document()); dataDummy->document()->setDocumentLayout(documentLayout); d->title->setUserData(dataDummy); } // Start with a reasonable default size that we can base all following relative // positions of chart elements on. setSize(QSizeF(CM_TO_POINT(8), CM_TO_POINT(5))); // Add the title to the shape addShape(d->title); QFont font = titleData()->document()->defaultFont(); font.setPointSizeF(12.0); titleData()->document()->setDefaultFont(font); titleData()->document()->setHtml("<div align=\"center\">" + i18n("Title") + "</font></div>"); // Position the title center at the very top. d->title->setSize(QSizeF(CM_TO_POINT(5), CM_TO_POINT(0.7))); d->title->setPosition(QPointF(size().width() / 2.0 - d->title->size().width() / 2.0, 0.0)); d->title->setVisible(false); d->title->setZIndex(2); setClipped(d->title, true); setInheritsTransform(d->title, true); // Create the Subtitle and add it to the shape. if (textShapeFactory) d->subTitle = textShapeFactory->createDefaultShape(resourceManager); if (!d->subTitle) { d->subTitle = new TextLabelDummy; } if (dynamic_cast<TextLabelData*>(d->subTitle->userData()) == 0) { TextLabelData *dataDummy = new TextLabelData; KoTextDocumentLayout *documentLayout = new KoTextDocumentLayout(dataDummy->document()); dataDummy->document()->setDocumentLayout(documentLayout); d->subTitle->setUserData(dataDummy); } addShape(d->subTitle); font = subTitleData()->document()->defaultFont(); font.setPointSizeF(10.0); subTitleData()->document()->setDefaultFont(font); subTitleData()->document()->setHtml("<div align=\"center\">" + i18n("Subtitle") + "</div>"); // Position it in the center, just below the title. d->subTitle->setSize(QSizeF(CM_TO_POINT(5), CM_TO_POINT(0.6))); d->subTitle->setPosition(QPointF(size().width() / 2.0 - d->title->size().width() / 2.0, d->title->size().height())); d->subTitle->setVisible(false); d->subTitle->setZIndex(3); setClipped(d->subTitle, true); setInheritsTransform(d->subTitle, true); // Create the Footer and add it to the shape. if (textShapeFactory) d->footer = textShapeFactory->createDefaultShape(resourceManager); if (!d->footer) { d->footer = new TextLabelDummy; } if (dynamic_cast<TextLabelData*>(d->footer->userData()) == 0) { TextLabelData *dataDummy = new TextLabelData; KoTextDocumentLayout *documentLayout = new KoTextDocumentLayout(dataDummy->document()); dataDummy->document()->setDocumentLayout(documentLayout); d->footer->setUserData(dataDummy); } addShape(d->footer); font = footerData()->document()->defaultFont(); font.setPointSizeF(10.0); footerData()->document()->setDefaultFont(font); footerData()->document()->setHtml("<div align=\"center\">" + i18n("Footer") + "</div>"); // Position the footer in the center, at the bottom. d->footer->setSize(QSizeF(CM_TO_POINT(5), CM_TO_POINT(0.6))); d->footer->setPosition(QPointF(size().width() / 2.0 - d->footer->size().width() / 2.0, size().height() - d->footer->size().height())); d->footer->setVisible(false); d->footer->setZIndex(4); setClipped(d->footer, true); setInheritsTransform(d->footer, true); // Set default contour (for how text run around is done around this shape) // to prevent a crash in LO setTextRunAroundContour(KoShape::ContourBox); // Enable auto-resizing of chart labels foreach(KoShape *label, labels()) { TextLabelData *labelData = qobject_cast<TextLabelData*>(label->userData()); KoTextDocument doc(labelData->document()); //FIXME doc.setResizeMethod(KoTextDocument::AutoResize); }
QVariant TaskItemModel::data(const QModelIndex &index, int role) const { if (!index.isValid()) { return QVariant(); } const qint64 totalTime = m_taskManager->calcTaskTime(static_cast<TaskItem *>(index.internalPointer())); const TaskItem *taskItem = static_cast<TaskItem *>(index.internalPointer()); if (role == Qt::DisplayRole || role == Qt::ToolTipRole) { switch (index.column()) { case 0: return taskItem->data().title(); case 1: if (taskItem->data().timeLimit() == 0) return secsToTimeStr(totalTime, true); return secsToTimeStr(taskItem->data().timeLimit() - totalTime, true) + "/" + secsToTimeStr(taskItem->data().timeLimit(), true); default: ; } } if (role == Qt::DecorationRole) { if (index.column() == 0) { switch (taskItem->activeState()) { case TaskItem::Active: if (m_taskManager->state() == TaskManager::Working) return theme::icon(theme::IconTaskWorking); else return theme::icon(theme::IconTaskActive); case TaskItem::SubActive: return theme::icon(theme::IconSubTaskActive); case TaskItem::Inactive: if (taskItem->data().isCompleted()) return theme::icon(theme::IconTaskDone); else return theme::icon(theme::IconTaskInactive); } } } if (role == Qt::FontRole) { if (taskItem->activeState() != TaskItem::Inactive) { QFont font; font.setBold(true); return font; } } if (role == Qt::TextColorRole) { if (taskItem->data().timeLimit() != 0 && taskItem->data().timeLimit() < totalTime) { return QColor(Qt::darkRed); } } if (role == Qt::UserRole) { return taskItem->id(); } return QVariant(); }
void ModeTabBar::paintEvent(QPaintEvent *event) { QPainter p(this); IconManager *iconManager = IconManager::instance(); QLinearGradient bgGrad(rect().topLeft(), rect().topRight()); bgGrad.setColorAt(0.5, palette().color(QPalette::Window)); bgGrad.setColorAt(1.0, palette().color(QPalette::Midlight)); p.fillRect(rect(), bgGrad); p.setPen(palette().color(QPalette::Shadow)); p.drawLine(width() - 1, 0, width() - 1, height()); for(int i = 0; i < count(); ++i) { p.save(); QFont labelFont = font(); labelFont.setBold(true); p.setFont(labelFont); QRect rect = tabRect(i); int textHeight = p.fontMetrics().boundingRect(QRect(0, 0, width(), height()), 0, tabLabel(i)).height(); QRect labelRect(QPoint(rect.left() + tabPadding, rect.bottom() - textHeight - tabPadding), QSize(rect.width() - (tabPadding * 2), textHeight)); int iconSize = rect.height() - textHeight - (3 * tabPadding); QRect iconRect(QPoint((rect.width() - iconSize) / 2, rect.top() + tabPadding), QSize(iconSize, iconSize)); bool isSelected = (i == m_currentIndex); bool isEnabled = isTabEnabled(i); bool isHovered = (i == m_hoverIndex); if(isHovered && isEnabled) { p.fillRect(rect.adjusted(0, 0, -1, 0), QColor(0, 0, 0, 24)); } if(isSelected) { p.save(); p.setPen(palette().color(QPalette::Shadow)); p.drawLine(rect.topLeft(), rect.topRight()); p.drawLine(rect.bottomLeft(), rect.bottomRight()); p.fillRect(rect.adjusted(0, 0, -1, 0), QColor(0, 0, 0, 32)); p.translate(rect.width() - 6, rect.top() + (rect.height() / 2) - 12); QPolygon arrowPoly; arrowPoly.append(QPoint(7, 0)); arrowPoly.append(QPoint(7, 24)); arrowPoly.append(QPoint(0, 12)); p.translate(0, 1); p.setBrush(palette().color(QPalette::Shadow)); p.setPen(palette().color(QPalette::Shadow)); p.setRenderHint(QPainter::Antialiasing); p.drawPolygon(arrowPoly); p.translate(0, -1); p.setBrush(palette().color(QPalette::Light)); p.drawPolygon(arrowPoly); p.restore(); } if(!isEnabled) p.setOpacity(0.6); QIcon icon(iconManager->icon(tabIcon(i))); QPixmap pixmap = icon.pixmap(iconSize, iconSize, isEnabled ? QIcon::Normal : QIcon::Disabled); p.drawPixmap(iconRect, pixmap); p.setPen(palette().color(QPalette::Text)); p.drawText(labelRect, Qt::AlignCenter, tabLabel(i)); p.restore(); } }
void PowerManagementRecordGui::onMessageReceived(const QString &response) { QStringList breakdown = response.split(","); QString command = breakdown[0].right(1); // Error Code switch (command[0].toAscii()) { // Show Free Space case 'F': { int freeSpace = breakdown[2].toInt()*breakdown[1].toInt()/2048; PowerManagementRecordUi.diskSpaceAvailable->setText(QString("%1 M")\ .arg(freeSpace, 0, 10)); break; } /* Directory listing. Fill a predefined model with strings from the response breakdown. The response will be a comma separated list of items preceded by a type. */ case 'D': { model->clear(); if (breakdown.size() <= 1) break; for (int i=1; i<breakdown.size(); i++) { QChar type = breakdown[i][0]; bool ok; QString fileSize = QString("%1") .arg((float)breakdown[i].mid(1,8).toInt(&ok,16)/1000000,8,'f',3); if (type == 'd') fileSize = ""; if ((type == 'f') || (type == 'd')) { QString fileName = breakdown[i].mid(9,breakdown[i].length()-1); QFont font; if (type == 'd') font.setBold(true); QStandardItem *nameItem = new QStandardItem(fileName); QStandardItem *sizeItem = new QStandardItem(fileSize); QList<QStandardItem *> row; nameItem->setFont(font); nameItem->setData(Qt::AlignLeft, Qt::TextAlignmentRole); sizeItem->setData(Qt::AlignRight, Qt::TextAlignmentRole); row.append(nameItem); row.append(sizeItem); nameItem->setData(QVariant(type)); // item->setIcon(...); model->appendRow(row); } } break; } /* Directory listing incremental. Fill a predefined model with a string from the response breakdown. A series of responses will give each entry in the listing, terminated by an empty filename. This will ease the communications load by requesting each entry only after the previous entry has been fully received. */ case 'd': { if (breakdown.size() < 1) break; // Empty parameters received indicates the directory listing has ended. directoryEnded = (breakdown.size() == 1); if (directoryEnded) break; nextDirectoryEntry = true; for (int i=1; i<breakdown.size(); i++) { QChar type = breakdown[i][0]; bool ok; QString fileSize = QString("%1") .arg((float)breakdown[i].mid(1,8).toInt(&ok,16)/1000000,8,'f',3); if (type == 'd') fileSize = ""; if ((type == 'f') || (type == 'd')) { QString fileName = breakdown[i].mid(9,breakdown[i].length()-1); QFont font; if (type == 'd') font.setBold(true); QStandardItem *nameItem = new QStandardItem(fileName); QStandardItem *sizeItem = new QStandardItem(fileSize); QList<QStandardItem *> row; nameItem->setFont(font); nameItem->setData(Qt::AlignLeft, Qt::TextAlignmentRole); sizeItem->setData(Qt::AlignRight, Qt::TextAlignmentRole); row.append(nameItem); row.append(sizeItem); nameItem->setData(QVariant(type)); // item->setIcon(...); model->appendRow(row); } /* Request the next entry by sending another incremental directory command with no directory name. */ socket->write("fd\r\n"); } break; } // Status of recording and open files. // The write and read file handles are retrieved from this case 's': { if (breakdown.size() <= 1) break; recordingOn = (breakdown[1].toInt() & 0x02) > 0; if (recordingOn) // recording on PowerManagementRecordUi.startButton-> setStyleSheet("background-color:lightgreen;"); else PowerManagementRecordUi.startButton-> setStyleSheet("background-color:lightpink;"); if (breakdown.size() <= 2) break; writeFileHandle = breakdown[2].toInt(); writeFileOpen = (writeFileHandle < 255); if (writeFileOpen) { PowerManagementRecordUi.recordFileButton-> setStyleSheet("background-color:lightgreen;"); PowerManagementRecordUi.recordFileName->setText(breakdown[3]); } else PowerManagementRecordUi.recordFileButton-> setStyleSheet("background-color:lightpink;"); if (breakdown.size() <= 3) break; readFileHandle = breakdown[3].toInt(); readFileOpen = (readFileHandle < 255); if (readFileOpen) PowerManagementRecordUi.readFileName->setText(breakdown[3]); break; } // Open a file for recording. case 'W': { writeFileHandle = extractValue(response); break; } case 'E': { QString errorText[19] = {"Hard Disk Error", "Internal Error", "Medium Not Ready", "File not Found", "Path not Found", "Invalid Path Format", "Access denied or directory full", "File Exists", "File/directory object invalid", "Drive write protected", "Logical drive number invalid", "Volume has no work area", "No valid FAT volume", "Format aborted: parameter error", "Timeout waiting for access", "File sharing policy violation", "LFN working buffer could not be allocated", "Too many open files", "Invalid Parameter"}; int status = breakdown[1].toInt(); if ((status > 0) && (status < 20)) PowerManagementRecordUi.errorLabel->setText(errorText[status-1]); break; } } }
KraftView::KraftView(QWidget *parent) : KraftViewBase( parent ), mHelpLabel( 0 ), mRememberAmount( -1 ), mModified( false ) { setCaption( i18n("Document" ) ); setModal( false ); setButtons( KDialog::Ok | KDialog::Cancel ); m_type = ReadWrite; QWidget *w = new QWidget( this ); QVBoxLayout *vLayoutGlobal = new QVBoxLayout; w->setLayout( vLayoutGlobal ); setMainWidget( w ); mDetailHeader = new QLabel; mDetailHeader->setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Fixed ) ); mDetailHeader->setFrameStyle( QFrame::Box + QFrame::Plain ); mDetailHeader->setLineWidth( 1 ); mDetailHeader->setAutoFillBackground(true); mAddressProvider = new AddressProvider( this ); connect( mAddressProvider, SIGNAL(addresseeFound( const QString&, const KABC::Addressee& )), this, SLOT( slotAddresseeFound( const QString&, const KABC::Addressee& ))); QPalette palette; palette.setColor(mDetailHeader->backgroundRole(), QColor( "darkBlue" )); palette.setColor(mDetailHeader->foregroundRole(), QColor( "white ")); mDetailHeader->setPalette( palette ); mDetailHeader->setTextFormat( Qt::PlainText ); mDetailHeader->setFixedHeight( 40 ); // FIXME QFont f = mDetailHeader->font(); f.setPointSize( qRound( 1.4 * f.pointSize() ) ); f.setBold( true ); mDetailHeader->setFont( f ); vLayoutGlobal->addWidget( mDetailHeader ); mCSplit = new QSplitter( w ); vLayoutGlobal->addWidget( mCSplit ); mViewStack = new QStackedWidget; mCSplit->addWidget( mViewStack ); kDebug() << "mViewSTack height is " << mViewStack->height() << endl; mAssistant = new DocAssistant( mCSplit ); mCSplit->addWidget( mAssistant ); /* catalog template selection signal */ connect( mAssistant, SIGNAL( templatesToDocument(Katalog*,CatalogTemplateList) ), this, SLOT( slotAddItems( Katalog*, CatalogTemplateList ) ) ); /* signal to toggle the visibility of the template section in the assistant */ connect( mAssistant, SIGNAL( toggleShowTemplates( bool ) ), this, SLOT( slotShowTemplates( bool ) ) ); /* signal that brings a new address to the document */ connect( mAssistant, SIGNAL( addressTemplate( const Addressee& ) ), this, SLOT( slotNewAddress( const Addressee& ) ) ); connect( mAssistant, SIGNAL( headerTextTemplate( const QString& ) ), this, SLOT( slotNewHeaderText( const QString& ) ) ); connect( mAssistant, SIGNAL( footerTextTemplate( const QString& ) ), this, SLOT( slotNewFooterText( const QString& ) ) ); if ( KraftSettings::self()->docViewSplitter().count() == 2 ) { mCSplit->setSizes( KraftSettings::self()->docViewSplitter() ); } connect( mAssistant, SIGNAL( selectPage( int ) ), this, SLOT( slotSwitchToPage( int ) ) ); QSize size = KraftSettings::self()->docViewSize(); if ( !size.isEmpty() ) resize( size ); QPoint pos = KraftSettings::self()->docViewPosition(); if ( !pos.isNull() ) move( pos ); mAssistant->slotSelectDocPart( KraftDoc::Header ); setupMappers(); }