Example #1
0
Window::Window()
{
    setWindowTitle(tr("CSC 205 Assignment 1"));

    // define our drawing widget (see GLWidget.h / .cpp)
    glWidget = new GLWidget;

    menubar = new QMenuBar;
    QMenu *file = new QMenu("&File");
    QMenu *edit = new QMenu("&Edit");
    menubar->addMenu(file);
    menubar->addMenu(edit);

    QAction *quitAct = new QAction(tr("&Close"), this);
    file->addAction(quitAct);

    // define our color sliders
    hSlider = new QSlider(Qt::Horizontal);
    sSlider = new QSlider(Qt::Horizontal);
    vSlider = new QSlider(Qt::Horizontal);

    rSlider = new QSlider(Qt::Horizontal);
    gSlider = new QSlider(Qt::Horizontal);
    bSlider = new QSlider(Qt::Horizontal);

    // added slider
    bSizeSlider = new QSlider(Qt::Horizontal);

    // configure our color sliders
    hSlider->setRange(0,360);
    hSlider->setTickInterval(360/8);
    hSlider->setTickPosition(QSlider::TicksBelow);
    hSlider->setMinimumWidth(200);


    sSlider->setRange(0,100);
    sSlider->setTickInterval(100/8);
    sSlider->setTickPosition(QSlider::TicksBelow);

    vSlider->setRange(0,100);
    vSlider->setTickInterval(100/8);
    vSlider->setTickPosition(QSlider::TicksBelow);

    rSlider->setRange(0,255);
    rSlider->setTickInterval(255/8);
    rSlider->setTickPosition(QSlider::TicksBelow);

    gSlider->setRange(0,255);
    gSlider->setTickInterval(255/8);
    gSlider->setTickPosition(QSlider::TicksBelow);

    bSlider->setRange(0,255);
    bSlider->setTickInterval(255/8);
    bSlider->setTickPosition(QSlider::TicksBelow);

    bSizeSlider->setRange(2,80);
    bSizeSlider->setTickInterval(80/6);
    bSizeSlider->setTickPosition(QSlider::TicksBelow);

    // labels for our sliders
    hLabel = new QLabel("0");
    sLabel = new QLabel("0");
    vLabel = new QLabel("0");

    rLabel = new QLabel("0");
    gLabel = new QLabel("0");
    bLabel = new QLabel("0");

    bSizeLabel = new QLabel("2");


    // The main (biggest) layout for our screen is a horizontal layout
    // This means items added to this layout will be added horizontally
    QHBoxLayout *mainLayout = new QHBoxLayout;

    // add our drawing widget as the first (leftmost) widget in our horizontal layout
    mainLayout->addWidget(glWidget);

    // our sliders are going to be in a vertical column
    QVBoxLayout *sliderLayout = new QVBoxLayout;
    sliderLayout->setAlignment(Qt::AlignTop);
    sliderLayout->setSizeConstraint(QLayout::SizeConstraint());

    // each slider has 2 labels below it in a horizontal box
    QHBoxLayout *hLabels = new QHBoxLayout;
    // first is just a name that never changes
    hLabels->addWidget(new QLabel(QString("Hue")));
    // we keep a reference to the next one because it's the label we're going to use to show
    // the value of this slider, and we'll need to update it accordingly
    hLabels->addWidget(hLabel);


    QHBoxLayout *sLabels = new QHBoxLayout;
    sLabels->addWidget(new QLabel(QString("Saturation")));
    sLabels->addWidget(sLabel);

    QHBoxLayout *vLabels = new QHBoxLayout;
    vLabels->addWidget(new QLabel(QString("Value")));
    vLabels->addWidget(vLabel);

    QHBoxLayout *rLabels = new QHBoxLayout;
    rLabels->addWidget(new QLabel(QString("Red")));
    rLabels->addWidget(rLabel);

    QHBoxLayout *gLabels = new QHBoxLayout;
    gLabels->addWidget(new QLabel(QString("Green")));
    gLabels->addWidget(gLabel);

    QHBoxLayout *bLabels = new QHBoxLayout;
    bLabels->addWidget(new QLabel(QString("Blue")));
    bLabels->addWidget(bLabel);

    QHBoxLayout *bSizeLabels = new QHBoxLayout;
    bSizeLabels->addWidget(new QLabel(QString("Brush Size")));
    bSizeLabels->addWidget(bSizeLabel);


    // we're going to have a box that shows the currently selected color
    // this is that box
    colorFrame = new QFrame;
    colorFrame->setFrameStyle(QFrame::Panel | QFrame::Raised);
    colorFrame->setLineWidth(2);
    colorFrame->setAutoFillBackground(true);
    colorFrame->setMinimumHeight(75);
    colorFrame->setMinimumWidth(75);

    // this is how we change the color of a QFrame
    QPalette pal = colorFrame->palette();
    pal.setColor(colorFrame->backgroundRole(), QColor(0,0,0));
    colorFrame->setPalette(pal);

    // add all of our sliders and our color box to our vertical slider layout
    sliderLayout->addWidget(hSlider);
    sliderLayout->addLayout(hLabels);

    sliderLayout->addWidget(sSlider);
    sliderLayout->addLayout(sLabels);

    sliderLayout->addWidget(vSlider);
    sliderLayout->addLayout(vLabels);

    sliderLayout->addWidget(colorFrame);

    sliderLayout->addWidget(rSlider);
    sliderLayout->addLayout(rLabels);

    sliderLayout->addWidget(gSlider);
    sliderLayout->addLayout(gLabels);

    sliderLayout->addWidget(bSlider);
    sliderLayout->addLayout(bLabels);

    sliderLayout->addSpacing(30);
    sliderLayout->addWidget(bSizeSlider);
    sliderLayout->addLayout(bSizeLabels);

    // add the slider layout to the main layout
    mainLayout->addLayout(sliderLayout);

    QGridLayout *buttonsLayout = new QGridLayout;
    QPushButton *rectButton[14];

    //declare buttons
    rectButton[0] = new QPushButton("Brush 1");
    rectButton[1] = new QPushButton("Brush 2");
    rectButton[2] = new QPushButton("Brush 3");
    rectButton[3] = new QPushButton("Brush 4");
    rectButton[4] = new QPushButton("Bresenham's Line");
    rectButton[5] = new QPushButton("Wu's Line");
    rectButton[6] = new QPushButton("Rectangle");
    rectButton[7] = new QPushButton("Filled Rectangle");
    rectButton[8] = new QPushButton("Circle");
    rectButton[9] = new QPushButton("Filled Circle");
    rectButton[10] = new QPushButton("Polygon");
    rectButton[11] = new QPushButton("Filled Polygon");
    rectButton[12] = new QPushButton("Edit a Vertex");
    rectButton[13] = new QPushButton("Clear");

    for (int i=0; i < 14; i++)
        buttonsLayout->addWidget(rectButton[i], i/2, i%2, Qt::AlignTop);

    sliderLayout->addLayout(buttonsLayout);
    setLayout(mainLayout);

    /*  Connections between our sliders and their labels */
    connect(hSlider, SIGNAL(valueChanged(int)), hLabel, SLOT(setNum(int)));
    connect(bSizeSlider, SIGNAL(valueChanged(int)), bSizeLabel, SLOT(setNum(int)));

    // had to use a special method for saturation and value because sliders go from 0 - 100 and we want 0 - 1
    connect(sSlider, SIGNAL(valueChanged(int)), this, SLOT(updateSVal(int)));
    connect(vSlider, SIGNAL(valueChanged(int)), this, SLOT(updateVVal(int)));

    connect(rSlider, SIGNAL(valueChanged(int)), rLabel, SLOT(setNum(int)));
    connect(gSlider, SIGNAL(valueChanged(int)), gLabel, SLOT(setNum(int)));
    connect(bSlider, SIGNAL(valueChanged(int)), bLabel, SLOT(setNum(int)));

    connect(hSlider, SIGNAL(valueChanged(int)), this, SLOT(hsvChanged()));
    connect(sSlider, SIGNAL(valueChanged(int)), this, SLOT(hsvChanged()));
    connect(vSlider, SIGNAL(valueChanged(int)), this, SLOT(hsvChanged()));

    connect(rSlider, SIGNAL(valueChanged(int)), this, SLOT(rgbChanged()));
    connect(gSlider, SIGNAL(valueChanged(int)), this, SLOT(rgbChanged()));
    connect(bSlider, SIGNAL(valueChanged(int)), this, SLOT(rgbChanged()));

    connect(bSizeSlider, SIGNAL(valueChanged(int)), glWidget, SLOT(setSize(int)));

    connect(this, SIGNAL(colorChanged(RGBColor)), glWidget, SLOT(setColor(RGBColor)));

    connect(rectButton[0], SIGNAL(clicked()), glWidget, SLOT(setBrush1() ));
    connect(rectButton[1], SIGNAL(clicked()), glWidget, SLOT(setBrush2() ));
    connect(rectButton[2], SIGNAL(clicked()), glWidget, SLOT(setBrush3() ));
    connect(rectButton[3], SIGNAL(clicked()), glWidget, SLOT(setBrush4() ));
    connect(rectButton[4], SIGNAL(clicked()), glWidget, SLOT(setBresenhamLine() ));
    connect(rectButton[5], SIGNAL(clicked()), glWidget, SLOT(setWuLine() ));
    connect(rectButton[6], SIGNAL(clicked()), glWidget, SLOT(setRectangle() ));
    connect(rectButton[7], SIGNAL(clicked()), glWidget, SLOT(setFillRectangle() ));
    connect(rectButton[8], SIGNAL(clicked()), glWidget, SLOT(setCircle() ));
    connect(rectButton[9], SIGNAL(clicked()), glWidget, SLOT(setFillCircle() ));
    connect(rectButton[10], SIGNAL(clicked()), glWidget, SLOT(setPolygon() ));
    connect(rectButton[11], SIGNAL(clicked()), glWidget, SLOT(setFillPolygon() ));
    connect(rectButton[12], SIGNAL(clicked()), glWidget, SLOT(setEditVertex() ));
    connect(rectButton[13], SIGNAL(clicked()), glWidget, SLOT(clear() ));

    connect(quitAct, SIGNAL(triggered()), this, SLOT(close()));
}
Example #2
0
void MainWindow::addWidgets()
{
    Q_D(MainWindow);

    int i = 0;

    d->mainContainer = new QWidget(this);

    // Selectors and file chooser
    d->deviceSel = new QComboBox(d->mainContainer);
    d->instLocSel = new QComboBox(d->mainContainer);
    d->instLocDesc = new QLabel(d->mainContainer);

    // Labels
    d->deviceLbl = new QLabel(tr("Device:"), d->mainContainer);
    d->instLocLbl = new QLabel(tr("Install to:"), d->mainContainer);

    // Text boxes
    d->instLocLe = new QLineEdit(d->mainContainer);
    d->instLocLe->setPlaceholderText(tr("Enter an ID"));
    QRegExp re(QStringLiteral("[a-z0-9]+"));
    QValidator *validator = new QRegExpValidator(re, this);
    d->instLocLe->setValidator(validator);

    QGridLayout *layout = new QGridLayout(d->mainContainer);
    layout->setContentsMargins(0, 0, 0, 0);
    layout->addWidget(d->deviceLbl, i, 0);
    layout->addWidget(d->deviceSel, i, 1, 1, -1);
    layout->addWidget(d->instLocLbl, ++i, 0);
    layout->addWidget(d->instLocSel, i, 1, 1, -1);
    layout->addWidget(d->instLocLe, ++i, 1, 1, -1);
    layout->addWidget(d->instLocDesc, ++i, 1, 1, -1);

    d->messageLbl = new QLabel(d->mainContainer);
    // Don't allow the window to grow too big
    d->messageLbl->setWordWrap(true);
    d->messageLbl->setMaximumWidth(550);

    d->chooseFileBtn = new QPushButton(tr("Choose file"), d->mainContainer);
    d->chooseAnotherFileBtn = new QPushButton(tr("Choose another file"), d->mainContainer);
    d->startPatchingBtn = new QPushButton(tr("Start patching"), d->mainContainer);

    d->buttons = new QDialogButtonBox(d->mainContainer);
    d->buttons->addButton(d->chooseFileBtn, QDialogButtonBox::ActionRole);
    d->buttons->addButton(d->chooseAnotherFileBtn, QDialogButtonBox::ActionRole);
    d->buttons->addButton(d->startPatchingBtn, QDialogButtonBox::ActionRole);

    QWidget *horiz1 = newHorizLine(d->mainContainer);

    layout->setColumnStretch(0, 0);
    layout->setColumnStretch(1, 0);
    layout->setColumnStretch(2, 0);
    layout->setColumnStretch(3, 1);

    layout->addWidget(horiz1,             ++i, 0, 1, -1);
    layout->addWidget(d->messageLbl,      ++i, 0, 1, -1);

    layout->addWidget(newHorizLine(d->mainContainer), ++i, 0, 1, -1);

    layout->addWidget(d->buttons,         ++i, 0, 1, -1);


    d->mainContainer->setLayout(layout);

    // List of widgets related to the message label
    d->messageWidgets << horiz1;
    d->messageWidgets << d->messageLbl;

    // Buttons
    d->progressContainer = new QWidget(this);
    QBoxLayout *progressLayout = new QVBoxLayout(d->progressContainer);
    progressLayout->setContentsMargins(0, 0, 0, 0);

    QGroupBox *detailsBox = new QGroupBox(d->progressContainer);
    detailsBox->setTitle(tr("Details"));

    d->detailsLbl = new QLabel(detailsBox);
    d->detailsLbl->setWordWrap(true);
    // Make sure the window doesn't change size while patching
    d->detailsLbl->setFixedWidth(500);

    QVBoxLayout *detailsLayout = new QVBoxLayout(detailsBox);
    detailsLayout->addWidget(d->detailsLbl);
    detailsBox->setLayout(detailsLayout);

    d->progressBar = new QProgressBar(d->progressContainer);
    //d->progressBar->setFormat(tr("%p% - %v / %m files"));
    d->progressBar->setMaximum(0);
    d->progressBar->setMinimum(0);
    d->progressBar->setValue(0);

    progressLayout->addWidget(detailsBox);
    //progressLayout->addStretch(1);
    progressLayout->addWidget(newHorizLine(d->progressContainer));
    progressLayout->addWidget(d->progressBar);
    d->progressContainer->setLayout(progressLayout);


    QVBoxLayout *mainLayout = new QVBoxLayout(this);
    mainLayout->setSizeConstraint(QLayout::SetFixedSize);
    mainLayout->addWidget(d->mainContainer);
    mainLayout->addWidget(d->progressContainer);
    setLayout(mainLayout);
}
CFullTestIOInWindow::CFullTestIOInWindow(QWidget *parent) :
    QWidget(parent)
{
    setProperty("testFlag",0);
    setProperty("init",0);
    setProperty("in",0);

    cf = ((CApp*)qApp)->_tjob->_mconfig;

    _ioItemCount = cf->_map_ioin.size();
    if(!property("init").toInt())
    {
        setProperty("init",1);
        QVBoxLayout *top = new QVBoxLayout;

        for(int i=0; i != _ioItemCount; ++i)
        {
            QLabel *_tempLabel = new QLabel;
            _tempLabel->setStyleSheet("border-radius:20px;background:#fff;border:1px solid #666;");
            _tempLabel->setFixedSize(40,40);
            _vec32IO.push_back(_tempLabel);
        }
        _testButton1 = new QPushButton(tr("检测低电平"));
        _testButton2 = new QPushButton(tr("检测高电平"));
        _statusLabel = new QLabel(tr("点击高低电平测试所有通道,点击圆圈发生检测单个通道。"));
        _statusLabel->setStyleSheet("font:bold 16px;color:#0099FF;max-height:26px;min-height:26px;background:#CCFF99;");
        _statusLabel_1 = new QLabel(tr("当前电平为:"));
        _statusLabel_1->setStyleSheet("font:bold 18px;color:#0099FF;max-height:30px;min-height:30px;background:#CCFF99;");
        _testButton1->setFocusPolicy(Qt::NoFocus);
        _testButton2->setFocusPolicy(Qt::NoFocus);
        _bReadCurrent = new QCheckBox("读取激励电流");
        _bReadCurrent->setFocusPolicy(Qt::NoFocus);

        //***Layout
        QGroupBox *_mainGroupBox = new QGroupBox(QString::number(_ioItemCount) + tr("路IO输入量测试"));
        QGridLayout *_mainGridLay = new QGridLayout(_mainGroupBox);

        _mainGridLay->addWidget(_statusLabel,0,0,1,8);
        _mainGridLay->addWidget(_statusLabel_1,1,0,1,8);
        for(int i=0; i != _ioItemCount; ++i)
        {
            QVBoxLayout *_tempVLay = new QVBoxLayout;
            int kk = ((CApp*)qApp)->_tjob->getIOInMapVoltage(i);
            QLabel *io = new QLabel( kk?tr("高电平有效"):tr("低电平有效") );
            if(kk)
                io->setStyleSheet("background-color:wheat;");
            else
                io->setStyleSheet("background-color:yellow;");

            _vec32IO[i]->installEventFilter(this);
            _tempVLay->addWidget(new QLabel("I/O量"+QString("%1").arg(i)));
            _tempVLay->addWidget(_vec32IO.at(i));
            _tempVLay->addWidget(io);

            _mainGridLay->addLayout(_tempVLay,i/8+2,i%8,1,1);

            if( ((CApp*)qApp)->_tjob->getIOInMapCurrent(i)!=-1 )
                _vec32IO[i]->setText(tr("电流"));
        }
        _mainGridLay->addWidget(_bReadCurrent,6,2,1,2);
        _mainGridLay->addWidget(_testButton1,6,4,1,2);
        _mainGridLay->addWidget(_testButton2,6,6,1,2);

        top->addWidget(_mainGroupBox);
        top->setSizeConstraint(QLayout::SetFixedSize);
        setLayout(top);

        //***Signal
        connect(_testButton1,SIGNAL(clicked()),this,SLOT(testButton1Clicked()));
        connect(_testButton2,SIGNAL(clicked()),this,SLOT(testButton2Clicked()));
        connect((CApp*)qApp,SIGNAL(sendBackFullTestData_ioi_485(QByteArray)),this,SLOT(sendBackData485(QByteArray)));
        connect((CApp*)qApp,SIGNAL(sendBackFullTestData_ioi_232(QByteArray)),this,SLOT(sendBackData232(QByteArray)));
    }
}
Example #4
0
void VNotebookInfoDialog::setupUI(const QString &p_title, const QString &p_info)
{
    QLabel *infoLabel = NULL;
    if (!p_info.isEmpty()) {
        infoLabel = new QLabel(p_info);
    }

    m_nameEdit = new VMetaWordLineEdit(m_notebook->getName());
    QValidator *validator = new QRegExpValidator(QRegExp(VUtils::c_fileNameRegExp),
                                                 m_nameEdit);
    m_nameEdit->setValidator(validator);
    m_nameEdit->selectAll();

    m_pathEdit = new VLineEdit(m_notebook->getPath());
    m_pathEdit->setReadOnly(true);

    // Image folder.
    m_imageFolderEdit = new VLineEdit(m_notebook->getImageFolderConfig());
    m_imageFolderEdit->setPlaceholderText(tr("Use global configuration (%1)")
                                            .arg(g_config->getImageFolder()));
    m_imageFolderEdit->setToolTip(tr("Set the name of the folder to hold images of all the notes in this notebook "
                                     "(empty to use global configuration)"));
    validator = new QRegExpValidator(QRegExp(VUtils::c_fileNameRegExp), m_imageFolderEdit);
    m_imageFolderEdit->setValidator(validator);

    // Attachment folder.
    Q_ASSERT(!m_notebook->getAttachmentFolder().isEmpty());
    m_attachmentFolderEdit = new VLineEdit(m_notebook->getAttachmentFolder());
    m_attachmentFolderEdit->setPlaceholderText(tr("Use global configuration (%1)")
                                                 .arg(g_config->getAttachmentFolder()));
    m_attachmentFolderEdit->setToolTip(tr("The folder to hold attachments of all the notes in this notebook"));
    m_attachmentFolderEdit->setReadOnly(true);

    // Recycle bin folder.
    VLineEdit *recycleBinFolderEdit = new VLineEdit(m_notebook->getRecycleBinFolder());
    recycleBinFolderEdit->setReadOnly(true);
    recycleBinFolderEdit->setToolTip(tr("The folder to hold deleted files from within VNote of all the notes in this notebook"));

    // Created time.
    QString createdTimeStr = VUtils::displayDateTime(const_cast<VNotebook *>(m_notebook)->getCreatedTimeUtc().toLocalTime());
    QLabel *createdTimeLabel = new QLabel(createdTimeStr);

    QFormLayout *topLayout = new QFormLayout();
    topLayout->addRow(tr("Notebook &name:"), m_nameEdit);
    topLayout->addRow(tr("Notebook &root folder:"), m_pathEdit);
    topLayout->addRow(tr("&Image folder:"), m_imageFolderEdit);
    topLayout->addRow(tr("Attachment folder:"), m_attachmentFolderEdit);
    topLayout->addRow(tr("Recycle bin folder:"), recycleBinFolderEdit);
    topLayout->addRow(tr("Created time:"), createdTimeLabel);

    // Warning label.
    m_warnLabel = new QLabel();
    m_warnLabel->setWordWrap(true);
    m_warnLabel->hide();

    // Ok is the default button.
    m_btnBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
    connect(m_btnBox, &QDialogButtonBox::accepted, this, &QDialog::accept);
    connect(m_btnBox, &QDialogButtonBox::rejected, this, &QDialog::reject);

    QPushButton *okBtn = m_btnBox->button(QDialogButtonBox::Ok);
    okBtn->setProperty("SpecialBtn", true);
    m_pathEdit->setMinimumWidth(okBtn->sizeHint().width() * 3);

    QVBoxLayout *mainLayout = new QVBoxLayout();
    if (infoLabel) {
        mainLayout->addWidget(infoLabel);
    }

    mainLayout->addLayout(topLayout);
    mainLayout->addWidget(m_warnLabel);
    mainLayout->addWidget(m_btnBox);

    setLayout(mainLayout);
    mainLayout->setSizeConstraint(QLayout::SetFixedSize);
    setWindowTitle(p_title);
}
void CLogisticMainWindow::setupDockWindow(const bool &visible)
{
    if (!visible) return;

    QDockWidget *dockDictionary = new QDockWidget(tr("Справочники"));
                 dockDictionary->setFeatures(QDockWidget::NoDockWidgetFeatures);

    QFrame *frameDictionary = new QFrame(this);

    QCommandLinkButton *client = new QCommandLinkButton(tr("Заказчики"), tr("Справочник клиентов"), frameDictionary);
                        client->setIcon(QIcon("data/picture/sidebar/customer.ico"));
    connect(client, SIGNAL(clicked()), this, SLOT(slotCustomerDictionary()));

    QCommandLinkButton *supplier = new QCommandLinkButton(tr("Поставщики"), tr("Справочник поставщиков"), frameDictionary);
                        supplier->setIcon(QIcon("data/picture/sidebar/suppliers.ico"));
    connect(supplier, SIGNAL(clicked()), this, SLOT(slotSuppliersDictionary()));

    QCommandLinkButton *producer = new QCommandLinkButton(tr("Производители"), tr("Справочник производителей"), frameDictionary);
                        producer->setIcon(QIcon("data/picture/sidebar/producers.ico"));
    connect(producer, SIGNAL(clicked()), this, SLOT(slotProdusersDictionary()));

    QCommandLinkButton *contact = new QCommandLinkButton(tr("Контакты"), tr("Справочник контактов"), frameDictionary);
                        contact->setIcon(QIcon("data/picture/sidebar/contacts.ico"));
    connect(contact, SIGNAL(clicked()), this, SLOT(slotContactsDictionary()));

    QCommandLinkButton *position = new QCommandLinkButton (tr("Должности"), tr("Справочник должностей"), frameDictionary);
                        position->setIcon(QIcon("data/picture/sidebar/positions.ico"));
    connect(position, SIGNAL(clicked()), this, SLOT(slotPositionsDictionary()));

    QCommandLinkButton *tasktype = new QCommandLinkButton (tr("Типы задач"), tr("Справочник типов задач"), frameDictionary);
                        tasktype->setIcon(QIcon("data/picture/sidebar/tasktype.ico"));
    connect(tasktype, SIGNAL(clicked()), this, SLOT(slotTaskTypesDictionary()));

    QCommandLinkButton *contractor = new QCommandLinkButton(tr("Контрагенты"), tr("Справочник контрагентов"), frameDictionary);
                        contractor->setIcon(QIcon("data/picture/sidebar/contractortype.ico"));
    connect(contractor, SIGNAL(clicked()), this, SLOT(slotContractorTypesDictionary()));

    QCommandLinkButton *status = new QCommandLinkButton (tr("Статусы"), tr("Справочник статусов"), frameDictionary);
                        status->setIcon(QIcon("data/picture/sidebar/status.ico"));
    connect(status, SIGNAL(clicked()), this, SLOT(slotStatusDictionary()));

    QCommandLinkButton *priority = new QCommandLinkButton (tr("Приоритеты"), tr("Справочник приоритетов"), frameDictionary);
                        priority->setIcon(QIcon("data/picture/sidebar/priority.ico"));
    connect(priority, SIGNAL(clicked()), this, SLOT(slotPrioritiesDictionary()));

    QCommandLinkButton *countrycity = new QCommandLinkButton (tr("Страны и города"), tr("Справочник стран и городов"), frameDictionary);
                        countrycity->setIcon(QIcon("data/picture/sidebar/countryandcity.ico"));
    connect(countrycity, SIGNAL(clicked()), this, SLOT(slotCountryCityDictionary()));

    QVBoxLayout *vboxDictionary = new QVBoxLayout(frameDictionary);
                 vboxDictionary->setSizeConstraint(QVBoxLayout::SetMinAndMaxSize);
                 vboxDictionary->addWidget(client);
                 vboxDictionary->addWidget(supplier);
                 vboxDictionary->addWidget(producer);
                 vboxDictionary->addWidget(contact);
                 vboxDictionary->addWidget(position);
                 vboxDictionary->addWidget(tasktype);
                 vboxDictionary->addWidget(contractor);
                 vboxDictionary->addWidget(status);
                 vboxDictionary->addWidget(priority);
                 vboxDictionary->addWidget(countrycity);

    dockDictionary->setLayout(vboxDictionary);
    dockDictionary->setWidget(frameDictionary);

    QDockWidget *dockFolder = new QDockWidget(tr("Папки"));
                 dockFolder->setFeatures(QDockWidget::NoDockWidgetFeatures);

    QFrame *frameFolder = new QFrame(this);

    QCommandLinkButton *relation = new QCommandLinkButton(tr("Взаимоотношения"), frameFolder);
                        relation->setIcon(QIcon("data/picture/sidebar/relations.ico"));
    connect(relation, SIGNAL(clicked()), this, SLOT(slotRelationsFolder()));

    QCommandLinkButton *calendar = new QCommandLinkButton (tr("Календарь"), frameFolder);
                        calendar->setIcon(QIcon("data/picture/sidebar/calendar.ico"));
    connect(calendar, SIGNAL(clicked()), this, SLOT(slotCalendarFolder()));

    QCommandLinkButton *reminder = new QCommandLinkButton (tr("Напоминания"), frameFolder);
                        reminder->setIcon(QIcon("data/picture/sidebar/reminder.ico"));
    connect(reminder, SIGNAL(clicked()), this, SLOT(slotReminderFolder()));

    QVBoxLayout *vboxFolder = new QVBoxLayout(frameFolder);
                 vboxFolder->setSizeConstraint(QVBoxLayout::SetMinAndMaxSize);
                 vboxFolder->addWidget(relation);
                 vboxFolder->addWidget(calendar);
                 vboxFolder->addWidget(reminder);

    dockFolder->setLayout(vboxFolder);
    dockFolder->setWidget(frameFolder);

    QDockWidget *dockAdditionally = new QDockWidget(tr("Дополнительно"));
                 dockAdditionally->setFeatures(QDockWidget::NoDockWidgetFeatures);

    QFrame *frameAdditionally = new QFrame(this);

    QCommandLinkButton *accounting = new QCommandLinkButton(tr("Учетные операции"), tr("Справочник УО"), frameAdditionally);
                        accounting->setIcon(QIcon("data/picture/sidebar/accounting.png"));
    connect(accounting, SIGNAL(clicked()), this, SLOT(slotAccountingAdditionally()));

    QVBoxLayout *vboxAdditionally = new QVBoxLayout(frameAdditionally);
                 vboxAdditionally->setSizeConstraint(QVBoxLayout::SetMinAndMaxSize);
                 vboxAdditionally->addWidget(accounting);

    dockAdditionally->setLayout(vboxAdditionally);
    dockAdditionally->setWidget(frameAdditionally);

    addDockWidget(Qt::LeftDockWidgetArea, dockDictionary);
    addDockWidget(Qt::LeftDockWidgetArea, dockFolder);
    addDockWidget(Qt::LeftDockWidgetArea, dockAdditionally);

    tabifyDockWidget(dockDictionary, dockFolder);
    tabifyDockWidget(dockFolder, dockAdditionally);
}
Example #6
0
void VNewFileDialog::setupUI(const QString &p_title,
                             const QString &p_info,
                             const QString &p_defaultName)
{
    QLabel *infoLabel = NULL;
    if (!p_info.isEmpty()) {
        infoLabel = new QLabel(p_info);
    }

    // Name.
    m_nameEdit = new VMetaWordLineEdit(p_defaultName);
    QValidator *validator = new QRegExpValidator(QRegExp(VUtils::c_fileNameRegExp),
                                                 m_nameEdit);
    m_nameEdit->setValidator(validator);
    int dotIndex = p_defaultName.lastIndexOf('.');
    m_nameEdit->setSelection(0, (dotIndex == -1) ? p_defaultName.size() : dotIndex);

    // Template.
    m_templateCB = VUtils::getComboBox();
    m_templateCB->setToolTip(tr("Choose a template (magic word supported)"));
    m_templateCB->setSizeAdjustPolicy(QComboBox::AdjustToContents);

    QPushButton *templateBtn = new QPushButton(VIconUtils::buttonIcon(":/resources/icons/manage_template.svg"),
                                               "");
    templateBtn->setToolTip(tr("Manage Templates"));
    templateBtn->setProperty("FlatBtn", true);
    connect(templateBtn, &QPushButton::clicked,
            this, [this]() {
                QUrl url = QUrl::fromLocalFile(g_config->getTemplateConfigFolder());
                QDesktopServices::openUrl(url);
            });

    QHBoxLayout *tempBtnLayout = new QHBoxLayout();
    tempBtnLayout->addWidget(m_templateCB);
    tempBtnLayout->addWidget(templateBtn);
    tempBtnLayout->addStretch();

    m_templateEdit = new QTextEdit();
    m_templateEdit->setReadOnly(true);

    QVBoxLayout *templateLayout = new QVBoxLayout();
    templateLayout->addLayout(tempBtnLayout);
    templateLayout->addWidget(m_templateEdit);

    m_templateEdit->hide();

    // InsertTitle.
    m_insertTitleCB = new QCheckBox(tr("Insert note name as title (for Markdown only)"));
    m_insertTitleCB->setToolTip(tr("Insert note name into the new note as a title"));
    m_insertTitleCB->setChecked(g_config->getInsertTitleFromNoteName());
    connect(m_insertTitleCB, &QCheckBox::stateChanged,
            this, [this](int p_state) {
                g_config->setInsertTitleFromNoteName(p_state == Qt::Checked);
            });

    QFormLayout *topLayout = new QFormLayout();
    topLayout->addRow(tr("Note &name:"), m_nameEdit);
    topLayout->addWidget(m_insertTitleCB);
    topLayout->addRow(tr("Template:"), templateLayout);

    m_nameEdit->setMinimumWidth(m_insertTitleCB->sizeHint().width());

    m_warnLabel = new QLabel();
    m_warnLabel->setWordWrap(true);
    m_warnLabel->hide();

    // Ok is the default button.
    m_btnBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
    connect(m_btnBox, &QDialogButtonBox::accepted,
            this, [this]() {
                s_lastTemplateFile = m_templateCB->currentData().toString();
                QDialog::accept();
            });
    connect(m_btnBox, &QDialogButtonBox::rejected, this, &QDialog::reject);

    QPushButton *okBtn = m_btnBox->button(QDialogButtonBox::Ok);
    okBtn->setProperty("SpecialBtn", true);
    m_templateCB->setMaximumWidth(okBtn->sizeHint().width() * 4);

    QVBoxLayout *mainLayout = new QVBoxLayout();
    if (infoLabel) {
        mainLayout->addWidget(infoLabel);
    }

    mainLayout->addLayout(topLayout);
    mainLayout->addWidget(m_warnLabel);
    mainLayout->addWidget(m_btnBox);
    mainLayout->setSizeConstraint(QLayout::SetFixedSize);
    setLayout(mainLayout);

    setWindowTitle(p_title);
}