SymbolDialog::SymbolDialog(CharSet charSet, QWidget* parent, Qt::WFlags fl )
    : QDialog( parent, fl )
{
    setAttribute(Qt::WA_DeleteOnClose);
    setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed );
    setSizeGripEnabled( false );

    buttons = new QButtonGroup(this);
    mainLayout = new QVBoxLayout(this);
    gridLayout = new QGridLayout();

    if (charSet == SymbolDialog::lowerGreek)
        initLowerGreekChars();
    else if (charSet == SymbolDialog::upperGreek)
        initUpperGreekChars();
    else if (charSet == SymbolDialog::mathSymbols)
        initMathSymbols();
    else if (charSet == SymbolDialog::arrowSymbols)
        initArrowSymbols();
    else
        initNumberSymbols();

    closeButton = new QPushButton(tr("&Close"), this);

    mainLayout->addLayout( gridLayout );
    mainLayout->addStretch();
    mainLayout->addWidget( closeButton );

    languageChange();

    connect(buttons, SIGNAL(buttonClicked(int)), this, SLOT(getChar(int)));
    connect(closeButton, SIGNAL(clicked()), this, SLOT(close()));
    QShortcut *shortcut = new QShortcut(Qt::Key_Return, this);
    connect( shortcut , SIGNAL(activated()), this, SLOT(addCurrentChar()) );
}
示例#2
0
GuiDelimiter::GuiDelimiter(GuiView & lv)
	: GuiDialog(lv, "mathdelimiter", qt_("Math Delimiter"))
{
	setupUi(this);

	connect(closePB, SIGNAL(clicked()), this, SLOT(accept()));

	setFocusProxy(leftLW);

	leftLW->setViewMode(QListView::IconMode);
	rightLW->setViewMode(QListView::IconMode);

	leftLW->setDragDropMode(QAbstractItemView::NoDragDrop);
	rightLW->setDragDropMode(QAbstractItemView::NoDragDrop);

	initMathSymbols();

	typedef map<char_type, QListWidgetItem *> ListItems;
	ListItems list_items;
	// The last element is the empty one.
	int const end = nr_latex_delimiters - 1;
	for (int i = 0; i < end; ++i) {
		string const delim = latex_delimiters[i];
		MathSymbol const & ms =	mathSymbol(delim);
		QString symbol(ms.fontcode?
			QChar(ms.fontcode) : toqstr(docstring(1, ms.unicode)));
		QListWidgetItem * lwi = new QListWidgetItem(symbol);
		lwi->setToolTip(toqstr(delim));
		FontInfo lyxfont;
		lyxfont.setFamily(ms.fontfamily);
		lwi->setFont(frontend::getFont(lyxfont));
		list_items[ms.unicode] = lwi;
		leftLW->addItem(lwi);
	}

	for (int i = 0; i != leftLW->count(); ++i) {
		MathSymbol const & ms =	mathSymbol(
			fromqstr(leftLW->item(i)->toolTip()));
		rightLW->addItem(list_items[doMatch(ms.unicode)]->clone());
	}

	// The last element is the empty one.
	leftLW->addItem(qt_("(None)"));
	rightLW->addItem(qt_("(None)"));

	sizeCO->addItem(qt_("Variable"));

	for (int i = 0; *biggui[i]; ++i)
		sizeCO->addItem(qt_(biggui[i]));

	on_leftLW_currentRowChanged(0);
	bc().setPolicy(ButtonPolicy::IgnorantPolicy);
}