예제 #1
0
 void CreateCollectionDialog::onAdvancedButtonToggled(bool state)
 {
     _advancedOptions->setVisible(state);
     if (state)  // resize, dialog is expanding
     {
         setMinimumSize(530, 400);
         QSettings settings("Paralect", "Robomongo");
         if (settings.contains("CreateCollectionDialog/geometry"))
         {
             restoreWindowSettings();
         }
         else
         {
             resize(530, 400);
             adjustSize();
         }
     }
     else        // resize, dialog is shrinking
     {
         saveWindowSettings();       // save expanded geometry first
         setMinimumSize(300, 150);
         adjustSize();
     }
 }
예제 #2
0
    DocumentTextEditor::DocumentTextEditor(const CollectionInfo &info, const QString &json, bool readonly /* = false */, QWidget *parent) :
        QDialog(parent),
        _info(info),
        _readonly(readonly)
    {
        QRect screenGeometry = QApplication::desktop()->availableGeometry();
        int horizontalMargin = (int)(screenGeometry.width() * 0.35);
        int verticalMargin = (int)(screenGeometry.height() * 0.20);
        QSize size(screenGeometry.width() - horizontalMargin,
                   screenGeometry.height() - verticalMargin);

        QSettings settings("3T", "Robomongo");
        if (settings.contains("DocumentTextEditor/size"))
        {
            restoreWindowSettings();
        }
        else
        {
            resize(size);
        }

        setWindowFlags(Qt::Window | Qt::WindowMaximizeButtonHint | Qt::WindowCloseButtonHint);

        Indicator *collectionIndicator = new Indicator(GuiRegistry::instance().collectionIcon(), QtUtils::toQString(_info._ns.collectionName()));
        Indicator *databaseIndicator = new Indicator(GuiRegistry::instance().databaseIcon(), QtUtils::toQString(_info._ns.databaseName()));
        Indicator *serverIndicator = new Indicator(GuiRegistry::instance().serverIcon(), QtUtils::toQString(detail::prepareServerAddress(_info._serverAddress)));

        QPushButton *validate = new QPushButton("Validate");
        validate->setIcon(qApp->style()->standardIcon(QStyle::SP_MessageBoxInformation));
        VERIFY(connect(validate, SIGNAL(clicked()), this, SLOT(onValidateButtonClicked())));

        _queryText = new FindFrame(this);
        _configureQueryText();
        _queryText->sciScintilla()->setText(json);
        // clear modification state after setting the content
        _queryText->sciScintilla()->setModified(false);

        VERIFY(connect(_queryText->sciScintilla(), SIGNAL(textChanged()), this, SLOT(onQueryTextChanged())));

        QHBoxLayout *hlayout = new QHBoxLayout();
        hlayout->setContentsMargins(2, 0, 5, 1);
        hlayout->setSpacing(0);
        hlayout->addWidget(serverIndicator, 0, Qt::AlignLeft);
        hlayout->addWidget(databaseIndicator, 0, Qt::AlignLeft);
        hlayout->addWidget(collectionIndicator, 0, Qt::AlignLeft);
        hlayout->addStretch(1);

        QDialogButtonBox *buttonBox = new QDialogButtonBox (this);
        buttonBox->setOrientation(Qt::Horizontal);
        buttonBox->setStandardButtons(QDialogButtonBox::Cancel | QDialogButtonBox::Save);
        VERIFY(connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept())));
        VERIFY(connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject())));

        QHBoxLayout *bottomlayout = new QHBoxLayout();
        bottomlayout->addWidget(validate);
        bottomlayout->addStretch(1);
        bottomlayout->addWidget(buttonBox);

        QVBoxLayout *layout = new QVBoxLayout();

        // show top bar only if we have info for it
        if (_info.isValid())
            layout->addLayout(hlayout);

        layout->addWidget(_queryText);
        layout->addLayout(bottomlayout);
        setLayout(layout);

        if (_readonly) {
            validate->hide();
            buttonBox->button(QDialogButtonBox::Save)->hide();
            _queryText->sciScintilla()->setReadOnly(true);
        }
    }