AreaSelectionWidget::AreaSelectionWidget(QWidget* parent): QWidget{parent} { auto lay = new iscore::MarginLess<QHBoxLayout>; this->setLayout(lay); m_comboBox = new QComboBox; m_lineEdit = new QLineEdit; lay->addWidget(m_comboBox); lay->addWidget(m_lineEdit); connect(m_lineEdit, &QLineEdit::editingFinished, this, &AreaSelectionWidget::lineEditChanged); auto& fact = SingletonAreaFactoryList::instance(); for(auto& elt : fact.get()) { m_comboBox->addItem(elt.second->prettyName(), QVariant::fromValue(elt.second->key<AreaFactoryKey>())); } connect(m_comboBox, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, [&] (int index) { if(index == m_comboBox->findData(GenericAreaModel::static_type())) { m_lineEdit->setEnabled(true); } else { m_lineEdit->setText(fact.get(m_comboBox->currentData().value<AreaFactoryKey>())->generic_formula()); m_lineEdit->setEnabled(false); lineEditChanged(); } }); }
LabeledWidget::LabeledWidget(QAction *action, const QString &label, LabelPosition lb, bool warningLabelRequired) : QWidget() , m_action(action) { setMouseTracking(true); QBoxLayout *layout; QLabel *l = new QLabel(label); l->setWordWrap(true); m_lineEdit = new QLineEdit(); if (lb == LabeledWidget::INLINE) { // label followed by line edit layout = new QHBoxLayout(); l->setIndent(l->style()->pixelMetric(QStyle::PM_SmallIconSize) + l->style()->pixelMetric(QStyle::PM_MenuPanelWidth) + 4); } else { //Label goes above the text edit layout = new QVBoxLayout(); m_lineEdit->setFixedWidth(300); //TODO : assuming a reasonable width, is there a better way? } layout->addWidget(l); layout->addWidget(m_lineEdit); if (warningLabelRequired) { m_warningLabel[0] = new QLabel(""); m_warningLabel[1] = new QLabel(""); m_warningLabel[0]->setWordWrap(true); m_warningLabel[1]->setWordWrap(true); layout->addWidget(m_warningLabel[0]); layout->addWidget(m_warningLabel[1]); } layout->setMargin(0); setLayout(layout); connect(m_lineEdit, SIGNAL(returnPressed()), this, SLOT(returnPressed())); connect(m_lineEdit, SIGNAL(textChanged(QString)), this, SIGNAL(lineEditChanged(QString))); }
HashLineEdit::HashLineEdit(const QString &text, bool defaultValue, QWidget *parent) : QLineEdit(text, parent) { connect(this, SIGNAL(editingFinished()), parent, SLOT(lineEditChanged())); m_firstText = text; m_isDefaultValue = defaultValue; if(defaultValue) { setStyleSheet("font-style: italic;"); connect(this,SIGNAL(textChanged(QString)),this,SLOT(updateObjectName())); } else { setStyleSheet("font-style: normal;"); } }
ThresholdSelector::ThresholdSelector(const QString& name, ColorCalibrationWidget* parent, const int min, const int max) : QGroupBox(name, parent), parent(parent) { slider = new QSlider(Qt::Orientation::Horizontal, this); slider->setMinimum(min); slider->setMaximum(max); lineEdit = new QLineEdit(QString::number(min), this); lineEdit->setFixedWidth(40); lineEdit->setValidator(new QIntValidator(min, max, lineEdit)); connect(slider, SIGNAL(valueChanged(int)), this, SLOT(sliderChanged(int))); connect(lineEdit, SIGNAL(textEdited(QString)), this, SLOT(lineEditChanged(QString))); QHBoxLayout* layout = new QHBoxLayout(this); this->setLayout(layout); layout->addWidget(lineEdit); layout->addWidget(slider); }
void ReferencesTool::createActions() { QWidgetAction *wAction = 0; QAction *action = new QAction(i18n("Insert"), this); addAction("insert_tableofcontents", action); action->setToolTip(i18n("Insert a Table of Contents into the document.")); action = new QAction(i18n("Insert Custom..."), this); addAction("insert_configure_tableofcontents", action); action->setToolTip(i18n("Insert a custom Table of Contents into the document.")); action = new QAction(koIcon("configure"), i18n("Configure..."), this); addAction("format_tableofcontents", action); action->setToolTip(i18n("Configure the Table of Contents")); connect(action, SIGNAL(triggered()), this, SLOT(formatTableOfContents())); action = new QAction(i18n("Insert footnote with auto number"),this); addAction("insert_autofootnote",action); connect(action, SIGNAL(triggered()), this, SLOT(insertAutoFootNote())); wAction = new QWidgetAction(this); wAction->setText(i18n("Insert Labeled Footnote")); QWidget *w = new LabeledWidget(wAction, i18n("Insert with label:"), LabeledWidget::INLINE, false); wAction->setDefaultWidget(w); addAction("insert_labeledfootnote", wAction); connect(w, SIGNAL(triggered(QString)), this, SLOT(insertLabeledFootNote(QString))); action = new QAction(i18n("Insert endnote with auto number"),this); addAction("insert_autoendnote",action); connect(action, SIGNAL(triggered()), this, SLOT(insertAutoEndNote())); wAction = new QWidgetAction(this); wAction->setText(i18n("Insert Labeled Endnote")); w = new LabeledWidget(wAction, i18n("Insert with label:"), LabeledWidget::INLINE, false); wAction->setDefaultWidget(w); addAction("insert_labeledendnote", wAction); connect(w, SIGNAL(triggered(QString)), this, SLOT(insertLabeledEndNote(QString))); action = new QAction(koIcon("configure"), i18n("Settings..."), this); addAction("format_footnotes",action); connect(action, SIGNAL(triggered()), this, SLOT(showFootnotesConfigureDialog())); action = new QAction(koIcon("configure"), i18n("Settings..."), this); addAction("format_endnotes",action); connect(action, SIGNAL(triggered()), this, SLOT(showEndnotesConfigureDialog())); action = new QAction(i18n("Insert Citation"), this); addAction("insert_citation",action); action->setToolTip(i18n("Insert a citation into the document.")); connect(action, SIGNAL(triggered()), this, SLOT(insertCitation())); action = new QAction(i18n("Insert Bibliography"), this); addAction("insert_bibliography",action); action->setToolTip(i18n("Insert a bibliography into the document.")); action = new QAction(i18n("Insert Custom Bibliography"), this); addAction("insert_custom_bibliography", action); action->setToolTip(i18n("Insert a custom Bibliography into the document.")); action = new QAction(i18n("Configure"),this); addAction("configure_bibliography",action); action->setToolTip(i18n("Configure the bibliography")); connect(action, SIGNAL(triggered()), this, SLOT(configureBibliography())); action = new QAction(i18n("Insert Link"), this); addAction("insert_link", action); action->setToolTip(i18n("Insert a weblink or link to a bookmark.")); connect(action, SIGNAL(triggered()), this, SLOT(insertLink())); wAction = new QWidgetAction(this); wAction->setText(i18n("Add Bookmark")); m_bmark = new LabeledWidget(wAction, i18n("Add Bookmark :"), LabeledWidget::ABOVE, true); connect(m_bmark, SIGNAL(lineEditChanged(QString)), this, SLOT(validateBookmark(QString))); wAction->setDefaultWidget(m_bmark); addAction("insert_bookmark", wAction); connect(m_bmark, SIGNAL(triggered(QString)), this, SLOT(insertBookmark(QString))); wAction->setToolTip(i18n("Insert a Bookmark. This is useful to create links that point to areas within the document")); action = new QAction(i18n("Bookmarks"), this); addAction("invoke_bookmark_handler", action); action->setToolTip(i18n("Display a pop up that hosts the options to add new Bookmark or handle existing Bookmarks")); action = new QAction(i18n("Manage Bookmarks"), this); addAction("manage_bookmarks", action); action->setToolTip(i18n("Manage your Bookmarks. Check where are they pointing to, Delete or Rename.")); }