Example #1
0
About::About(QWidget * parent, Qt::WindowFlags f)
   : QDialog(parent, f)
{
   // stuff
   setWindowTitle("About LibreLibreCell");

   QLabel *versionLabel = new QLabel(QString("Git revision: %1").arg(LIBRELIBRECELL_VERSION));
   QPlainTextEdit *aboutBox = new QPlainTextEdit;
   QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok);

   QVBoxLayout *vLayout = new QVBoxLayout;
   vLayout->addWidget(versionLabel);
   vLayout->addWidget(aboutBox, 1);
   vLayout->addSpacing(10);
   vLayout->addWidget(buttonBox);

   setLayout(vLayout);


   aboutBox->setReadOnly(true);
   aboutBox->setTabChangesFocus(true);
   aboutBox->setWordWrapMode(QTextOption::NoWrap);
   aboutBox->setLineWrapMode(QPlainTextEdit::NoWrap);
   aboutBox->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
   aboutBox->setFont(QFont("Monospace", 10));

   QFile readme(":/README.txt");
   if (readme.open(QIODevice::ReadOnly))
   {
      QTextStream stream(&readme);
      aboutBox->setPlainText(stream.readAll());
      readme.close();
   }
   else
   {
      aboutBox->setPlainText("Could not open README.txt.");
   }
   QFontMetrics fm(aboutBox->font());
   aboutBox->setMinimumSize(fm.width(QLatin1Char('m')) * 76, 450);

   connect(buttonBox, SIGNAL(accepted()),
               this, SLOT(accept()));
}