void Ut_MSettingsLanguageTextFactory::testCreateWidget()
{
    // Create a settings text
    MSettingsLanguageText settingsText("TestKey", "Title");
    MSettingsLanguageWidget dds;
    MockDataStore dataStore;
    MWidget *widget = MSettingsLanguageTextFactory::createWidget(settingsText, dds, &dataStore);
    QVERIFY(widget != NULL);

    // Expecting the widget to have a layout and linear policy
    QGraphicsLinearLayout *layout = dynamic_cast<QGraphicsLinearLayout *>(widget->layout());
    QVERIFY(layout != NULL);

    // Expecting the layout to contain a MLabel and a MTextEdit
    QCOMPARE(layout->count(), 2);

    // The label's title should be the SettingsText's title
    MLabel *label = dynamic_cast<MLabel *>(layout->itemAt(0));
    QVERIFY(label != NULL);
    QCOMPARE(label->text(), settingsText.title());

    // The label's title should be the specified key's value
    MTextEdit *textEdit = dynamic_cast<MTextEdit *>(layout->itemAt(1));
    QVERIFY(textEdit != NULL);
    QCOMPARE(textEdit->text(), dataStore.value("TestKey").toString());

    delete widget;
}
void ToolBarPage::textFieldConfiguration()
{
    initDefaultViewToolBar();

    MTextEdit *entry = new MTextEdit(MTextEditModel::SingleLine, "", centralWidget());
    entry->setObjectName("entry");
    entry->setViewType("toolbar");
    MWidgetAction *action = new MWidgetAction(this);
    action->setObjectName("action");
    action->setLocation(MAction::ToolBarLocation);
    action->setWidget(entry);
    addAction(action);

    currentConfiguration = textField;
}
Пример #3
0
int main(int argc, char **argv)
{
    MApplication app(argc, argv);
    MApplicationWindow window;
    MApplicationPage page;
    MTheme::loadCSS("twocolumns.css");
    /* Create a MLayout that we set the policy for */
    MLayout *layout = new MLayout(page.centralWidget());
    MLinearLayoutPolicy *policy = new MLinearLayoutPolicy(layout, Qt::Horizontal);

    /* Setup first layout with a label and text edit */
    MLayout *nameLayout = new MLayout;
    MLinearLayoutPolicy *namePolicy = new MLinearLayoutPolicy(nameLayout, Qt::Horizontal);
    MLabel *textEditLabel = new MLabel("Name:");
    MTextEdit *textEdit = new MTextEdit(MTextEditModel::MultiLine);
    namePolicy->addItem(textEditLabel);  //Add the label and textedit
    namePolicy->addItem(textEdit);
    textEdit->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);

    /* Setup second layout with a large label */
    MLayout *labelLayout = new MLayout;
    MLinearLayoutPolicy *labelPolicy = new MLinearLayoutPolicy(labelLayout, Qt::Horizontal);
    MLabel *label = new MLabel("Enter the name of the person who likes to listen to music while sorting their socks!");
    label->setObjectName("nameLabel");
    labelPolicy->addItem(label);
    label->setWordWrap(true);

    /* Add the two layouts to the layout */
    policy->addItem(nameLayout);
    policy->addItem(labelLayout);

    /* Make the two layouts have an equal preferred size, so that they get an equal amount of space */
    nameLayout->setPreferredWidth(1);
    labelLayout->setPreferredWidth(1);

    page.appear(&window);
    window.show();

    return app.exec();
}
Пример #4
0
QString AppWindow::getText(QString title, QString prompt, QString text)
{
	MWidget *centralWidget = new MWidget;
	QGraphicsLinearLayout *layout = new QGraphicsLinearLayout(Qt::Vertical);
	centralWidget->setLayout(layout);

	MLabel *label = new MLabel(prompt, centralWidget);
	label->setStyleName("CommonTitleInverted");

	MTextEdit *textEdit = new MTextEdit(MTextEditModel::SingleLine, text, centralWidget);

	layout->addItem(label);
	layout->addItem(textEdit);

	MDialog* dialog = new MDialog(title, M::OkButton | M::CancelButton);
	dialog->setCentralWidget(centralWidget);

	connect(dialog, SIGNAL(disappeared()), SLOT(processDialogResult()));
	if (dialog->exec(this) == M::OkButton)
		return textEdit->text();
	return "";
}
Пример #5
0
void LoginSheet::createCentralWidget()
{
    QGraphicsLinearLayout *mainLayout = new QGraphicsLinearLayout(Qt::Vertical,
                                                                  centralWidget());
    mainLayout->setContentsMargins(0,0,0,0);
    mainLayout->setSpacing(0);

    //% "Connect to Service"
    MLabel *label = new MLabel(qtTrId("xx_wg_sheets_connect_service"));
    label->setStyleName("CommonTitle");
    label->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
    mainLayout->addItem(label);

    mainLayout->addItem(createSpacer());

    //% "Username:"******"xx_wg_sheets_username"));
    label->setStyleName("CommonFieldLabel");

    mainLayout->addItem(label);

    userNameTextEdit = new MTextEdit;
    userNameTextEdit->setStyleName("CommonSingleInputFieldLabeled");
    mainLayout->addItem(userNameTextEdit);

    mainLayout->addItem(createSpacer());

    //% "Password:"******"xx_wg_sheets_password"));
    label->setStyleName("CommonFieldLabel");
    mainLayout->addItem(label);

    MTextEdit *textEdit = new MTextEdit;
    textEdit->setStyleName("CommonSingleInputFieldLabeled");
    textEdit->setEchoMode(MTextEditModel::Password);
    mainLayout->addItem(textEdit);

    mainLayout->addStretch();
}
Пример #6
0
CodeWindow::CodeWindow( QSettings* appSettings, const ConnectorPath& conPath, QWidget* parent)
    : QDialog( parent),
    _ui( new Ui::CodeWindow)
{
    _ui->setupUi( this);

    this->setWindowTitle( QString("CodeEdit ") + conPath.normPath());

    _appSettings = appSettings;
    readSettings();

    _font = QFont("MonoSpace", 10);
    _font.setStyleHint( QFont::TypeWriter);
    MTextEdit*  textEdit = _ui->textEdit;

#ifdef QSCINTILLA
    QsciLexer*  lexer = 0;
    if (path.endsWith(".js"))
        lexer = new QsciLexerJavaScript;
    if (path.endsWith(".html") || path.endsWith(".xhtml"))
        lexer = new QsciLexerHTML;

    if (lexer) {
        lexer->setFont( _font);
        textEdit->editor()->setLexer( lexer);
    }
    else {
        textEdit->setFont( _font);
    }

    textEdit->editor()->setTabWidth(4);
    textEdit->editor()->setMarginWidth(0, 35);
    textEdit->editor()->setMarginLineNumbers(0, true);
    textEdit->editor()->setUtf8(true);
    textEdit->editor()->setAutoIndent(true);
    textEdit->editor()->setBraceMatching( QsciScintilla::StrictBraceMatch);
    textEdit->editor()->setMatchedBraceForegroundColor( Qt::red);
#else
    QFontMetrics fm( _font);
    int  tabWidthInPixels = fm.width("    ");
    textEdit->editor()->setTabStopWidth( tabWidthInPixels);
    textEdit->editor()->setCurrentFont( _font);
#endif

    QString  path = conPath.localPath();
    _isHtml = path.endsWith(".html") || path.endsWith(".xhtml");
    _isSetPlainText = true;  // Default
    _arnItem.open( path);
    setText( _arnItem.toString());
}