void ColorLabel::paintEvent(QPaintEvent *event)
{

    Q_UNUSED(event);

    QCommonStyle style;

    QPainter painter(this);
    QFont font = painter.font();
    font.setPointSize(9);
    painter.setPen(QPen(QColor(Qt::black)));
    painter.setFont(font);

    int txtWidth = painter.fontMetrics().width(text());
    int txtHeight = painter.fontMetrics().height();

    QRectF rect = QRectF((width() - txtWidth)/2 -2, (height() - txtHeight)/2 -2,
                         txtWidth+4, txtHeight+4);

    painter.setBrush(QBrush(QColor(255,255,255,128)));
    painter.setPen(QPen(QColor(255,255,255,128)));
    painter.drawRoundedRect(rect, 3, 3);

    style.drawItemText(&painter, rect.toRect(), Qt::AlignCenter, palette(),
                       true, text(), QPalette::Foreground);
}
Example #2
0
Form::Form(QWidget *parent)
    : QMainWindow(parent)
{
    setupUi(this);

    QCommonStyle* myStyle = new QCommonStyle;
    QIcon openIcon = myStyle->standardIcon(QStyle::SP_DriveCDIcon );
    QAction* openAction = new QAction(openIcon, "&Open...", this);

    toolBar->addAction(openAction);

    // Can also use the following if the action is already created (i.e. by adding a QtDesigner file menu item)
    //openAction->setIcon(openIcon);
}
Example #3
0
DlgErrorReport::DlgErrorReport(const QString &xmlWithoutDocument,
                               const QString &xmlWithDocument,
                               QWidget *parent) :
  QDialog (parent),
  m_xmlWithoutDocument (xmlWithoutDocument),
  m_xmlWithDocument (xmlWithDocument)
{
  QVBoxLayout *layout = new QVBoxLayout;
  layout->setSizeConstraint (QLayout::SetFixedSize);
  setLayout (layout);

  QCommonStyle style;
  setModal(true);
  setWindowTitle (tr ("Error Report"));
  setWindowIcon(style.standardIcon (QStyle::SP_MessageBoxCritical));

  QLabel *lblPreview = new QLabel (tr ("An unrecoverable error has occurred. Would you like to send an error report to "
                                       "the Engauge developers?\n\n"
                                       "Adding document information to the error report greatly increases the chances of finding "
                                       "and fixing the problems. However, document information should not be included if your document "
                                       "contains any information that should remain private."));
  lblPreview->setWordWrap(true);
  layout->addWidget (lblPreview);

  m_chkWithDocument = new QCheckBox ("Include document information");
  m_chkWithDocument->setChecked (true);
  updateFile ();
  layout->addWidget (m_chkWithDocument);
  connect (m_chkWithDocument, SIGNAL (stateChanged (int)), this, SLOT (slotDocumentCheckboxChanged (int)));

  QHBoxLayout *layoutButtons = new QHBoxLayout;

  QWidget *panelButtons = new QWidget;
  panelButtons->setLayout (layoutButtons);
  layout->addWidget (panelButtons);

  m_btnSend = new QPushButton(tr ("Send"));
  m_btnSend->setMaximumWidth (MAX_BTN_WIDTH);
  layoutButtons->addWidget (m_btnSend);
  connect (m_btnSend, SIGNAL (released ()), this, SLOT (slotSend()));

  m_btnCancel = new QPushButton(tr ("Cancel"));
  m_btnCancel->setMaximumWidth (MAX_BTN_WIDTH);
  layoutButtons->addWidget (m_btnCancel);
  connect (m_btnCancel, SIGNAL (released ()), this, SLOT (reject ()));
}
Example #4
0
HelpDialog::HelpDialog(QString fileName, QWidget *parent) : QDialog(parent)
{
    setupUi(this);
    QCommonStyle style;
    connect(pushButton, SIGNAL(clicked()), this, SLOT(accept()));
    connect(homeButton,SIGNAL(clicked()),this,SLOT(home()));
    homeButton->setIcon(style.standardIcon(QStyle::SP_ArrowUp));
    connect(backButton,SIGNAL(clicked()),HelpTextEdit,SLOT(backward()));
    backButton->setIcon(style.standardIcon(QStyle::SP_ArrowBack));
    connect(forwardButton,SIGNAL(clicked()),HelpTextEdit,SLOT(forward()));
    forwardButton->setIcon(style.standardIcon(QStyle::SP_ArrowForward));

    QFile file(fileName);
    if (file.open(QIODevice::ReadOnly | QIODevice::Text)) {
        QTextStream ts(&file);
        HelpTextEdit->setText(ts.readAll());
    }
    file.close();
}
Example #5
0
void AppConfigPage_Main::setupUi(void)
{
 qDebug() << "Create main config page";
 
 // Блок работы с путем до каталога данных
 tetradirLabel=new QLabel(this);
 tetradirLabel->setText(tr("Data directory"));

 tetradirInput=new QLineEdit(this);
 tetradirInput->setMinimumWidth(50);
 tetradirInput->setText(mytetraConfig.get_tetradir());

 tetradirButton=new QToolButton(this);
 tetradirButton->setText(tr("..."));


 // Блок работы с путем до корзины
 trashdirLabel=new QLabel(this);
 trashdirLabel->setText(tr("Trash directory"));

 trashdirInput=new QLineEdit(this);
 trashdirInput->setMinimumWidth(50);
 trashdirInput->setText(mytetraConfig.get_trashdir());

 trashdirButton=new QToolButton(this);
 trashdirButton->setText(tr("..."));

 
 // Блок работы с размером корзины
 trashsizeLabel=new QLabel(this);
 trashsizeLabel->setText(tr("Trash size"));
 
 trashsizeInput=new QSpinBox(this);
 trashsizeInput->setRange(1,1000);
 trashsizeInput->setValue(mytetraConfig.get_trashsize());
 
 trashsizeFlexion=new QLabel(this);
 trashsizeFlexion->setText(tr("Mb"));


 // Блок работы с максимальным количеством файлов в корзине
 trashmaxfilecountLabel=new QLabel(this);
 trashmaxfilecountLabel->setText(tr("Maximum files in trash"));
 
 trashmaxfilecountInput=new QSpinBox(this);
 trashmaxfilecountInput->setRange(1,3000);
 trashmaxfilecountInput->setValue(mytetraConfig.get_trashmaxfilecount());
 
 trashmaxfilecountFlexion=new QLabel(this);
 trashmaxfilecountFlexion->setText(tr("files"));


 // Блок работы с выбором языка интерфейса
 interfaceLanguageLabel=new QLabel(this);
 interfaceLanguageLabel->setText(tr("Language"));

 interfaceLanguage=new MtComboBox(this);
 interfaceLanguage->setMinimumContentsLength(2);
 interfaceLanguage->addItem("en");
 interfaceLanguage->addItem("ru");
 interfaceLanguage->setCurrentIndex(interfaceLanguage->findText(mytetraConfig.get_interfacelanguage(), Qt::MatchCaseSensitive));


 // Блок работы с отображением даты и времени
 dateTimeFormatBox=new QGroupBox(this);
 dateTimeFormatBox->setTitle(tr("Displaying date and time format"));

 disableCustomDateTimeFormat=new QRadioButton(tr("Locale settings"));
 enableCustomDateTimeFormat=new QRadioButton(tr("Custom format"));
 customDateTimeFormat=new QLineEdit();
 dateTimeFormatHelpButton=new QToolButton();
 QCommonStyle styleHelp;
 dateTimeFormatHelpButton->setIcon( styleHelp.standardIcon(QStyle::SP_MessageBoxQuestion) );

 // Точка устанавливается возле того пункта, который настроен в конфиге
 if(mytetraConfig.getEnableCustomDateTimeFormat()==false)
 {
   disableCustomDateTimeFormat->setChecked(true);
   enableCustomDateTimeFormat->setChecked(false);
   customDateTimeFormat->setEnabled(false);
 }
 else
 {
   // Если разрешен пользовательский формат даты и времени
   disableCustomDateTimeFormat->setChecked(false);
   enableCustomDateTimeFormat->setChecked(true);
   customDateTimeFormat->setEnabled(true);
   customDateTimeFormat->setText( mytetraConfig.getCustomDateTimeFormat() );
 }

}