void TipDialog::setupGUI() { setWindowTitle(tags.at(0)); setWindowIcon(QPixmap(THEME_DIR + "icons/today_tip.png")); int h,s,v; QColor baseColor = palette().base().color(); baseColor.getHsv(&h,&s,&v); baseColor.setHsv(h, int(s*(71/76.0)), int(v*(67/93.0))); // baseColor.setHsv(h, int(s*(10/6.0)), int(v*(93/99.0))); QVBoxLayout *layout = new QVBoxLayout(this); textBrowser = new QTextBrowser; /* QTextFrameFormat format = textBrowser->document()->rootFrame()->frameFormat(); format.setMargin(15); format.setBorder(5); textBrowser->document()->rootFrame()->setFrameFormat(format); */ textBrowser->setWordWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere); textBrowser->setFrameStyle(QFrame::NoFrame | QFrame::Plain); textBrowser->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); textBrowser->setOpenExternalLinks(true); /* QPalette pal = textBrowser->palette(); pal.setBrush(QPalette::Base, baseColor); textBrowser->setPalette(pal); */ layout->addWidget(textBrowser); layout->addWidget(new TSeparator); QHBoxLayout *buttonLayout = new QHBoxLayout; m_showOnStart = new QCheckBox(tags.at(1)); buttonLayout->addWidget(m_showOnStart); connect(m_showOnStart, SIGNAL(clicked()), this, SLOT(setShowOnStart())); buttonLayout->addStretch(1); QPushButton *prevTip = new QPushButton(tags.at(2)); buttonLayout->addWidget(prevTip); connect(prevTip, SIGNAL(clicked()), this, SLOT(showPrevTip())); QPushButton *nextTip = new QPushButton(tags.at(3)); buttonLayout->addWidget(nextTip); connect(nextTip, SIGNAL(clicked()), this, SLOT(showNextTip())); QPushButton *close = new QPushButton(tags.at(4)); buttonLayout->addWidget(close); connect(close, SIGNAL(clicked()), this, SLOT(accept())); layout->addLayout(buttonLayout); setAttribute(Qt::WA_DeleteOnClose, true); TCONFIG->beginGroup("TipOfDay"); m_showOnStart->setChecked(qvariant_cast<bool>(TCONFIG->value("ShowOnStart", true))); showNextTip(); }
void TipDialog::setupGUI() { setWindowTitle(tags.at(0)); setWindowIcon(QPixmap(THEME_DIR + "icons" + QDir::separator() + "today_tip.png")); int h; int s; int v; QColor baseColor = palette().base().color(); baseColor.getHsv(&h,&s,&v); baseColor.setHsv(h, int(s*(71/76.0)), int(v*(67/93.0))); QVBoxLayout *layout = new QVBoxLayout(this); textBrowser = new QTextBrowser; textBrowser->setWordWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere); textBrowser->setFrameStyle(QFrame::NoFrame | QFrame::Plain); textBrowser->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); textBrowser->setOpenExternalLinks(true); QStringList path; #ifdef Q_OS_WIN32 QString resources = SHARE_DIR + "help" + QDir::separator(); #else QString resources = SHARE_DIR + "data" + QDir::separator() + "help" + QDir::separator(); #endif path << resources + "css"; path << resources + "images"; textBrowser->setSearchPaths(path); layout->addWidget(textBrowser); layout->addWidget(new TSeparator); QHBoxLayout *buttonLayout = new QHBoxLayout; m_showOnStart = new QCheckBox(tags.at(1)); buttonLayout->addWidget(m_showOnStart); connect(m_showOnStart, SIGNAL(clicked()), this, SLOT(setShowOnStart())); buttonLayout->addStretch(1); QPushButton *prevTip = new QPushButton(tags.at(2)); buttonLayout->addWidget(prevTip); connect(prevTip, SIGNAL(clicked()), this, SLOT(showPrevTip())); QPushButton *nextTip = new QPushButton(tags.at(3)); buttonLayout->addWidget(nextTip); connect(nextTip, SIGNAL(clicked()), this, SLOT(showNextTip())); QPushButton *close = new QPushButton(tags.at(4)); buttonLayout->addWidget(close); connect(close, SIGNAL(clicked()), this, SLOT(accept())); layout->addLayout(buttonLayout); setAttribute(Qt::WA_DeleteOnClose, true); TCONFIG->beginGroup("TipOfDay"); m_showOnStart->setChecked(qvariant_cast<bool>(TCONFIG->value("ShowOnStart", true))); showNextTip(); }