void FolderViewDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const { QStyledItemDelegate::paint(painter,option,index); painter->save(); QFont font = QApplication::font(); QFont subFont = QApplication::font(); //font.setPixelSize(font.weight()+); font.setBold(true); subFont.setWeight(subFont.weight() - 4); QFontMetrics fm(font); 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 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 headerRect = option.rect; QRect iconRect = option.rect; iconRect.setRight(iconsize.width()+30); iconRect.setTop(iconRect.top()+5); headerRect.setLeft(iconRect.right()); headerRect.setTop(headerRect.top()+5); headerRect.setBottom(headerRect.top()+fm.height()); QRect subheaderRect = headerRect; subheaderRect.setTop(headerRect.bottom()); QFontMetrics fmSub( subFont ); subheaderRect.setBottom(subheaderRect.top()+fmSub.height()); QRect statusRect = subheaderRect; statusRect.setTop( subheaderRect.bottom() + 5); statusRect.setBottom( statusRect.top() + fmSub.height()); QRect lastSyncRect = statusRect; lastSyncRect.setTop( statusRect.bottom()); lastSyncRect.setBottom( lastSyncRect.top() + fmSub.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() + 8 ), statusIcon.pixmap( 48,48)); painter->setFont(font); painter->drawText(headerRect, aliasText); painter->setFont(subFont); painter->drawText(subheaderRect.left(),subheaderRect.top()+17, pathText); painter->drawText(lastSyncRect, tr("Last Sync: %1").arg( statusText )); painter->drawText(statusRect, tr("Sync Status: %1").arg( syncStatus )); painter->restore(); }
RazorDeskIconBase::RazorDeskIconBase( const QPoint & position, QWidget * parent) : QAbstractButton(parent), m_mouseOver(false), m_display(0), m_displayHighlight(0) { setAttribute(Qt::WA_AlwaysShowToolTips); qDebug() << "RazorDeskIconBase: initialising..." << parent; //setToolButtonStyle(Qt::ToolButtonTextUnderIcon); moveMe = false; movedMe = false; //QString name = QApplication::fontMetrics().elidedText(data->text(), Qt::ElideRight, 65); //TODO make this portable, read from config or anything else! QSize iconsize(32,32); setFixedSize(70,70); setIconSize(iconsize); if (! parent) { setAttribute(Qt::WA_X11NetWmWindowTypeDesktop); setWindowFlags(Qt::FramelessWindowHint | Qt::WindowStaysOnBottomHint | Qt::Dialog ); } else { setWindowFlags(Qt::FramelessWindowHint | Qt::Dialog ); } setAttribute(Qt::WA_TranslucentBackground); setCursor(Qt::PointingHandCursor); connect(this, SIGNAL(clicked(bool)), this, SLOT(launchApp())); show(); setPos(position); }
void FolderViewDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const { QStyledItemDelegate::paint(painter,option,index); painter->save(); QFont aliasFont = QApplication::font(); QFont subFont = QApplication::font(); QFont errorFont = subFont; //font.setPixelSize(font.weight()+); aliasFont.setBold(true); aliasFont.setPointSize( subFont.pointSize()+2 ); QFontMetrics subFm( subFont ); QFontMetrics aliasFm( aliasFont ); int margin = aliasFm.height()/2; QIcon folderIcon = 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 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" ); QSize iconsize(48, 48); // = icon.actualSize(option.decorationSize); QRect aliasRect = option.rect; QRect iconRect = option.rect; iconRect.setLeft( margin ); iconRect.setWidth( 48 ); iconRect.setTop( iconRect.top() + margin ); // (iconRect.height()-iconsize.height())/2); QRect statusRect = iconRect; statusRect.setLeft( option.rect.right() - margin - 48 ); statusRect.setRight( option.rect.right() - margin ); aliasRect.setLeft(iconRect.right()+margin); aliasRect.setTop(aliasRect.top() + aliasFm.height()/2 ); aliasRect.setBottom(aliasRect.top()+subFm.height()); // local directory box QRect localPathRect = aliasRect; localPathRect.setTop(aliasRect.bottom() + margin / 3); 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()); iconRect.setBottom(remotePathRect.bottom()); //painter->drawPixmap(QPoint(iconRect.right()/2,iconRect.top()/2),icon.pixmap(iconsize.width(),iconsize.height())); if( syncEnabled ) { painter->drawPixmap(QPoint(iconRect.left(),iconRect.top()), folderIcon.pixmap(iconsize.width(),iconsize.height())); } else { painter->drawPixmap(QPoint(iconRect.left(),iconRect.top()), folderIcon.pixmap(iconsize.width(),iconsize.height(), QIcon::Disabled )); } painter->drawPixmap(QPoint(statusRect.left(), statusRect.top()), 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)); // 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()+margin); errorRect.setRight( statusRect.right() ); painter->setBrush( QColor(0xbb, 0x4d, 0x4d) ); painter->setPen( QColor(0xaa, 0xaa, 0xaa)); painter->drawRoundedRect( errorRect, 4, 4 ); QIcon warnIcon(":/mirall/resources/warning-16"); painter->drawPixmap( QPoint(errorRect.left()+2, errorRect.top()+2), warnIcon.pixmap(QSize(16,16))); painter->setPen( Qt::white ); painter->setFont(errorFont); QRect errorTextRect = errorRect; errorTextRect.setLeft( errorTextRect.left()+margin/2 +16); errorTextRect.setTop( errorTextRect.top()+margin/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(); }
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(); }
QvisVCRControl::QvisVCRControl(QWidget *parent) : QWidget(parent) { // Make the stop button active. activeButton = 2; // Create pixmaps for the buttons. AugmentPixmap(frevpix_icon); QPixmap p1((const char **)augmentedData); AugmentPixmap(backpix_icon); QPixmap p2((const char **)augmentedData); AugmentPixmap(stoppix_icon); QPixmap p3((const char **)augmentedData); AugmentPixmap(playpix_icon); QPixmap p4((const char **)augmentedData); AugmentPixmap(fadvpix_icon); QPixmap p5((const char **)augmentedData); // Create the top layout. QHBoxLayout *topLayout = new QHBoxLayout(this); topLayout->setMargin(0); #if defined(Q_WS_MACX) || defined(Q_OS_MAC) topLayout->setSpacing(1); #else topLayout->setSpacing(10); #endif QSize iconsize(34,20); // Create the buttons and add the pixmaps to them. buttons[0] = new QPushButton(this); buttons[0]->setIcon(QIcon(p1)); buttons[0]->setIconSize(iconsize); buttons[1] = new QPushButton(this); buttons[1]->setIcon(QIcon(p2)); buttons[1]->setCheckable(true); buttons[1]->setDown(false); buttons[1]->setIconSize(iconsize); buttons[2] = new QPushButton(this); buttons[2]->setIcon(QIcon(p3)); buttons[2]->setCheckable(true); buttons[2]->setDown(true); buttons[2]->setIconSize(iconsize); buttons[3] = new QPushButton(this); buttons[3]->setIcon(QIcon(p4)); buttons[3]->setCheckable(true); buttons[3]->setDown(false); buttons[3]->setIconSize(iconsize); buttons[4] = new QPushButton(this); buttons[4]->setIcon(QIcon(p5)); buttons[4]->setIconSize(iconsize); // Connect the buttons' "pressed" signals to the appropriate VCR // clicked slot. connect(buttons[0], SIGNAL(pressed()), this, SLOT(b0_clicked())); connect(buttons[1], SIGNAL(pressed()), this, SLOT(b1_clicked())); connect(buttons[2], SIGNAL(pressed()), this, SLOT(b2_clicked())); connect(buttons[3], SIGNAL(pressed()), this, SLOT(b3_clicked())); connect(buttons[4], SIGNAL(pressed()), this, SLOT(b4_clicked())); // Add all the buttons to the top layout. for(int i = 0; i < 5; ++i) topLayout->addWidget(buttons[i]); }
/* init_matplot: initialises distmat plotting. The matrix size should * be Row x Col (which is the min. size in pixels). Title is put on the top * of the window by the window manager. Xorig and Yorig specify * the lower left corner position of the window: if either of them * is negative, then the window will be positioned interactively. * Return value: the 'gid' window ID number. */ long init_matplot(unsigned int Row, unsigned int Col, char *Title, long Xorig, long Yorig) { const unsigned int MINSIZE=500; long Gid, Xsize, Ysize, Xmax, Ymax; float Xmagnif, Ymagnif; unsigned int Rs, Cs; if (!Row) Row=MINSIZE; if (!Col) Col=MINSIZE; Xmagnif=(float)Col/MINSIZE; Ymagnif=(float)Row/MINSIZE; Rs=Row; Cs=Col; if (Col<=Row) { if (Xmagnif<1.0) { Cs=MINSIZE; Rs=round_id(Row/Xmagnif); } } else { if (Ymagnif<1.0) { Rs=MINSIZE; Cs=round_id(Col/Ymagnif); } } foreground(); /* enable signal catch etc. */ Xmax=getgdesc(GD_XPMAX); Ymax=getgdesc(GD_YPMAX); keepaspect(Col, Row); /* Xmax,Ymax: the maximal screen coordinates */ Xmax=getgdesc(GD_XPMAX); Ymax=getgdesc(GD_YPMAX); if (Xorig+Cs>Xmax) Xorig=Xmax-Cs; if (Yorig+Rs>Ymax) Yorig=Ymax-Rs; if (Xorig>=0 && Yorig>=0) prefposition(Xorig, Xorig+Cs, Yorig, Yorig+Rs); iconsize(84, 67); Gid=winopen(Title); /* create window */ RGBmode(); /* check if double buffering is available */ if (Dblbuffer=getgdesc(GD_BITS_NORM_DBL_BLUE)) { doublebuffer(); gconfig(); } else fputs("init_matplot: single-buffer mode\n", stderr); /* enable resize */ winconstraints(); keepaspect(Col, Row); winconstraints(); getsize(&Xsize, &Ysize); /* scale drawing into window */ Xmagnif=(float)Xsize/Col; Ymagnif=(float)Ysize/Row; pushmatrix(); scale(Xmagnif, Ymagnif, 1.0); cpack(RGB_BLACK); clear(); /* clears window to black */ if (Dblbuffer) { swapbuffers(); cpack(RGB_BLACK); clear(); } /* queue input events */ qdevice(ESCKEY); qdevice(WINFREEZE); qdevice(WINTHAW); qdevice(REDRAWICONIC); qdevice(WINQUIT); return(Gid); }