void WelcomePageButtonPrivate::doUpdate(bool cursorInside) { const bool active = isActive(); q->setPalette(buttonPalette(active, cursorInside, false)); const QPalette lpal = buttonPalette(active, cursorInside, true); m_label->setPalette(lpal); if (m_icon) m_icon->setPalette(lpal); q->update(); }
WelcomePageButton::WelcomePageButton(QWidget *parent) : WelcomePageFrame(parent), d(new WelcomePageButtonPrivate(this)) { setAutoFillBackground(true); setPalette(buttonPalette(false, false, false)); QFont f = font(); f.setPixelSize(15); d->m_label = new QLabel(this); d->m_label->setFont(f); d->m_label->setPalette(buttonPalette(false, false, true)); d->m_layout = new QHBoxLayout; d->m_layout->setContentsMargins(13, 5, 20, 5); d->m_layout->setSpacing(0); d->m_layout->addWidget(d->m_label); setLayout(d->m_layout); }
void ScheduleScreen::createScheduleScene() { QPen pen(Qt::blue); QBrush brush(Qt::black); QFont font = this->font(); font.setBold(true); QFontMetrics fm(font); weekHeight = (scene->height()/7.0)-(scene->height()*.025); pointArea.setRect(fm.boundingRect("Wed").width()+20, 15, scene->width(), weekHeight*7); timeWidth = ((pointArea.width() - pointArea.left())/4.0)-((pointArea.width() - pointArea.left())/4.0)/16; timeBlockWidth = timeWidth/24.0; //15 min increments pointArea.adjust(0,0,-timeBlockWidth, 0); QDate date = QDate::fromString("Sun", "ddd"); for(int a = 0;a<7;a++) { pen.setColor(QColor(110+40*(a%2),110+40*(a%2),110+40*(a%2))); brush.setColor(QColor(120+40*(a%2),120+40*(a%2),120+40*(a%2))); scene->addRect(0,pointArea.top()+a*weekHeight,pointArea.width(),weekHeight, pen, brush); pen.setColor(QColor(150,150,150)); brush.setColor(QColor(180,180,180)); scene->addRect(0,pointArea.top()+a*weekHeight,pointArea.left(),weekHeight-1, pen, brush); date = date.addDays(1); QString dateString = date.toString("ddd"); pen.setColor(QColor(50,50,50)); QPushButton* b = new QPushButton; connect(b, SIGNAL(clicked(bool)), this, SLOT(disableRow(bool))); b->setFlat(true); b->setFont(font); b->setFocusPolicy(Qt::NoFocus); b->setMaximumWidth(pointArea.left()-4); b->setMaximumHeight(weekHeight-4); QPalette buttonPalette(QColor(180,180,180)); //buttonPalette.setColor(QPalette::Active, QPalette::Button, QColor(180,180,180)); b->setPalette(buttonPalette); b->setCheckable(true); b->setChecked(true); b->setText(dateString); b->setProperty("dayNumber", date.dayOfWeek()-1); QGraphicsProxyWidget* textItem = new QGraphicsProxyWidget; textItem->setWidget(b); scene->addItem(textItem); textItem->setPos(pointArea.left()/2 - textItem->boundingRect().width()/2, pointArea.top()+ a*weekHeight + weekHeight/2 - textItem->boundingRect().height()/2); } scene->addLine(pointArea.left(), pointArea.top()+1, pointArea.left(), scene->height()-1); for(int a = 0;a<5;a++) { pen.setColor(QColor(110+40*(a%2),110+40*(a%2),110+40*(a%2))); brush.setColor(QColor(120+40*(a%2),120+40*(a%2),120+40*(a%2))); QString timeString = formatHourString(QTime(((a)*6)%24,0), m_globalSettings->timeFormat()); pen.setColor(QColor(200,200,200)); brush.setColor(QColor(200,200,200)); QGraphicsSimpleTextItem* textItem = scene->addSimpleText(timeString, font); textItem->setBrush(brush); textItem->setPos(timeBlockWidth*3+pointArea.left()+timeWidth*a - textItem->boundingRect().width()/2, pointArea.bottom() +6); pen.setColor(QColor(188,188,188)); pen.setStyle(Qt::DashLine); scene->addLine(timeBlockWidth*3+pointArea.left()+timeWidth*a, pointArea.top()+1, timeBlockWidth*3+pointArea.left()+timeWidth*a, pointArea.bottom()+3, pen); } }