void BGDialog::setWallpaper(const QString &s) { KComboBox *comboWallpaper = m_urlWallpaperBox; int i = comboWallpaper->count(); if (i == 0) return; comboWallpaper->blockSignals(true); if (m_wallpaper.find(s) == m_wallpaper.end()) { QString imageCaption; int slash = s.lastIndexOf('/') + 1; int endDot = s.lastIndexOf('.'); // strip the extension if it exists if (endDot != -1 && endDot > slash) imageCaption = s.mid(slash, endDot - slash); else imageCaption = s.mid(slash); if (comboWallpaper->itemText(i - 1) == imageCaption) { i--; comboWallpaper->removeItem(i); } comboWallpaper->addItem(imageCaption); m_wallpaper[s] = i; comboWallpaper->setCurrentIndex(i); } else { comboWallpaper->setCurrentIndex(m_wallpaper[s]); } comboWallpaper->blockSignals(false); }
bool StdWidgetFactory::saveSpecialProperty(const QCString &classname, const QString &name, const QVariant &, QWidget *w, QDomElement &parentNode, QDomDocument &domDoc) { if(name == "list_items" && classname == "KComboBox") { KComboBox *combo = (KComboBox*)w; for(int i=0; i < combo->count(); i++) { QDomElement item = domDoc.createElement("item"); KFormDesigner::FormIO::savePropertyElement(item, domDoc, "property", "text", combo->text(i)); parentNode.appendChild(item); } return true; } else if(name == "list_items" && classname == "KListBox") { KListBox *listbox = (KListBox*)w; for(uint i=0; i < listbox->count(); i++) { QDomElement item = domDoc.createElement("item"); KFormDesigner::FormIO::savePropertyElement(item, domDoc, "property", "text", listbox->text(i)); parentNode.appendChild(item); } return true; } else if(name == "list_contents" && classname == "KListView") { KListView *listview = (KListView*)w; // First we save the columns for(int i = 0; i < listview->columns(); i++) { QDomElement item = domDoc.createElement("column"); KFormDesigner::FormIO::savePropertyElement(item, domDoc, "property", "text", listview->columnText(i)); KFormDesigner::FormIO::savePropertyElement(item, domDoc, "property", "width", listview->columnWidth(i)); KFormDesigner::FormIO::savePropertyElement(item, domDoc, "property", "resizable", listview->header()->isResizeEnabled(i)); KFormDesigner::FormIO::savePropertyElement(item, domDoc, "property", "clickable", listview->header()->isClickEnabled(i)); KFormDesigner::FormIO::savePropertyElement(item, domDoc, "property", "fullwidth", listview->header()->isStretchEnabled(i)); parentNode.appendChild(item); } // Then we save the list view items QListViewItem *item = listview->firstChild(); while(item) { saveListItem(item, parentNode, domDoc); item = item->nextSibling(); } return true; } return false; }
QStringList CMakeBuildDirChooser::extraArgumentsHistory() const { QStringList list; KComboBox* extraArguments = m_chooserUi->extraArguments; if (!extraArguments->currentText().isEmpty()) { list << extraArguments->currentText(); } for (int i = 0; i < qMin(maxExtraArgumentsInHistory, extraArguments->count()); ++i) { if (!extraArguments->itemText(i).isEmpty() && (extraArguments->currentText() != extraArguments->itemText(i))) { list << extraArguments->itemText(i); } } return list; }
void KSelectAction_UnitTest::testChildActionStateChangeComboMode() { KSelectAction selectAction("selectAction", 0); selectAction.setToolBarMode(KSelectAction::ComboBoxMode); QWidget parent; QWidget* widget = selectAction.requestWidget(&parent); KComboBox* comboBox = qobject_cast<KComboBox*>(widget); QVERIFY(comboBox); const QString itemText = "foo"; KAction* childAction = selectAction.addAction(itemText); QCOMPARE(comboBox->itemText(0), itemText); childAction->setEnabled(false); // There's no API for item-is-enabled, need to go via the internal model like kselectaction does... QStandardItemModel *model = qobject_cast<QStandardItemModel *>(comboBox->model()); QVERIFY(model); QVERIFY(!model->item(0)->isEnabled()); // Now remove the action selectAction.removeAction(childAction); QCOMPARE(comboBox->count(), 0); }
LinkDialog::LinkDialog(QWidget* parent, Selection* selection) : KPageDialog(parent) , d(new Private) { setCaption(i18n("Insert Link")); setButtons(Ok | Cancel); setFaceType(List); // link for web or ftp d->internetPage = new QWidget(); d->p1 = addPage(d->internetPage, i18n("Internet")); d->p1->setHeader(i18n("Link to Internet Address")); d->p1->setIcon(KIcon("internet-web-browser")); QVBoxLayout* iLayout = new QVBoxLayout(d->internetPage); iLayout->addWidget(new QLabel(i18n("Text to display:"), d->internetPage)); d->internetText = new KLineEdit(d->internetPage); iLayout->addWidget(d->internetText); iLayout->addWidget(new QLabel(i18n("Internet address:"), d->internetPage)); d->internetLink = new KLineEdit(d->internetPage); iLayout->addWidget(d->internetLink); iLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding)); connect(d->internetText, SIGNAL(textChanged(const QString&)), this, SLOT(setText(const QString&))); // link for e-mail d->mailPage = new QWidget(); d->p2 = addPage(d->mailPage, i18n("Mail")); d->p2->setHeader(i18n("Link to Mail Address")); d->p2->setIcon(KIcon("mail-message")); QVBoxLayout* mLayout = new QVBoxLayout(d->mailPage); mLayout->addWidget(new QLabel(i18n("Text to display:"), d->mailPage)); d->mailText = new KLineEdit(d->mailPage); mLayout->addWidget(d->mailText); mLayout->addWidget(new QLabel(i18n("Email:"), d->mailPage)); d->mailLink = new KLineEdit(d->mailPage); mLayout->addWidget(d->mailLink); connect(d->mailText, SIGNAL(textChanged(const QString&)), this, SLOT(setText(const QString&))); mLayout->addWidget(new QLabel(i18n("Subject:"), d->mailPage)); d->mailSubject = new KLineEdit(d->mailPage); mLayout->addWidget(d->mailSubject); mLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding)); // link for external file d->filePage = new QWidget(); d->p3 = addPage(d->filePage, i18n("File")); d->p3->setHeader(i18n("Link to File")); d->p3->setIcon(KIcon("system-file-manager")); QVBoxLayout* fLayout = new QVBoxLayout(d->filePage); fLayout->addWidget(new QLabel(i18n("Text to display:"), d->filePage)); d->fileText = new KLineEdit(d->filePage); fLayout->addWidget(d->fileText); fLayout->addWidget(new QLabel(i18n("File location:"), d->filePage)); d->fileLink = new KUrlRequester(d->filePage); d->fileLink->completionObject()->setReplaceHome(true); d->fileLink->completionObject()->setReplaceEnv(true); fLayout->addWidget(d->fileLink); fLayout->addWidget(new QLabel(i18n("Recent file:"), d->filePage)); KComboBox* recentFile = new KComboBox(d->filePage); recentFile->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); recentFile->setMinimumContentsLength(40); fLayout->addWidget(recentFile); fLayout->addItem(new QSpacerItem(0, 40, QSizePolicy::Minimum, QSizePolicy::MinimumExpanding)); connect(d->fileText, SIGNAL(textChanged(const QString&)), this, SLOT(setText(const QString&))); QObject::connect(recentFile, SIGNAL(highlighted(const QString &)), d->fileLink->lineEdit(), SLOT(setText(const QString &))); // populate recent files int index = 0; const QStringList fileList = KRecentDocument::recentDocuments(); for (QStringList::ConstIterator it = fileList.constBegin(); it != fileList.constEnd(); ++it) { KDesktopFile f(*it); if (!f.readUrl().isEmpty()) recentFile->insertItem(index++, f.readUrl()); } if (recentFile->count() == 0) { recentFile->insertItem(0, i18n("No Entries")); recentFile->setEnabled(false); } // link to another cell d->cellPage = new QWidget(); d->p4 = addPage(d->cellPage, i18n("Cell")); d->p4->setHeader(i18n("Link to Cell")); d->p4->setIcon(KIcon("table")); QVBoxLayout* cLayout = new QVBoxLayout(d->cellPage); cLayout->addWidget(new QLabel(i18n("Text to display:"), d->cellPage)); d->cellText = new KLineEdit(d->cellPage); cLayout->addWidget(d->cellText); cLayout->addWidget(new QLabel(i18n("Cell or Named Area:"), d->cellPage)); d->cellLink = new KComboBox(d->cellPage); d->cellLink->setEditable(true); const Sheet *sheet = selection->activeSheet(); if (sheet && selection) { Cell cell(sheet, selection->cursor()); d->cellLink->addItem(cell.fullName()); } const NamedAreaManager *manager = selection->activeSheet()->map()->namedAreaManager(); d->cellLink->addItems(manager->areaNames()); d->cellLink->setItemText(d->cellLink->currentIndex(), ""); cLayout->addWidget(d->cellLink); cLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding)); connect(d->cellText, SIGNAL(textChanged(const QString&)), this, SLOT(setText(const QString&))); showButtonSeparator(true); d->internetText->setFocus(); resize(400, 300); connect(this, SIGNAL(okClicked()), this, SLOT(slotOk())); }
bool StdWidgetFactory::startEditing(const QCString &classname, QWidget *w, KFormDesigner::Container *container) { setWidget(w, container); // m_container = container; if(classname == "KLineEdit") { KLineEdit *lineedit = static_cast<KLineEdit*>(w); createEditor(classname, lineedit->text(), lineedit, container, lineedit->geometry(), lineedit->alignment(), true); return true; } else if(classname == "QLabel") { QLabel *label = static_cast<QLabel*>(w); if(label->textFormat() == RichText) { //m_widget = w; // setWidget(w, container); editText(); } else createEditor(classname, label->text(), label, container, label->geometry(), label->alignment()); return true; } else if(classname == "KPushButton") { KPushButton *push = static_cast<KPushButton*>(w); QRect r = w->style().subRect(QStyle::SR_PushButtonContents, w); QRect editorRect = QRect(push->x() + r.x(), push->y() + r.y(), r.width(), r.height()); //r.setX(r.x() + 5); //r.setY(r.y() + 5); //r.setWidth(r.width()-10); //r.setHeight(r.height() - 10); createEditor(classname, push->text(), push, container, editorRect, Qt::AlignCenter, false, false, Qt::PaletteButton); return true; } else if(classname == "QRadioButton") { QRadioButton *radio = static_cast<QRadioButton*>(w); QRect r = w->style().subRect(QStyle::SR_RadioButtonContents, w); QRect editorRect = QRect(radio->x() + r.x(), radio->y() + r.y(), r.width(), r.height()); createEditor(classname, radio->text(), radio, container, editorRect, Qt::AlignAuto); return true; } else if(classname == "QCheckBox") { QCheckBox *check = static_cast<QCheckBox*>(w); //QRect r(check->geometry()); //r.setX(r.x() + 20); QRect r = w->style().subRect(QStyle::SR_CheckBoxContents, w); QRect editorRect = QRect(check->x() + r.x(), check->y() + r.y(), r.width(), r.height()); createEditor(classname, check->text(), check, container, editorRect, Qt::AlignAuto); return true; } else if((classname == "KComboBox") || (classname == "KListBox")) { QStringList list; if(classname == "KListBox") { KListBox *listbox = (KListBox*)w; for(uint i=0; i < listbox->count(); i++) list.append(listbox->text(i)); } else if(classname == "KComboBox") { KComboBox *combo = (KComboBox*)w; for(int i=0; i < combo->count(); i++) list.append(combo->text(i)); } if(editList(w, list)) { if(classname == "KListBox") { ((KListBox*)w)->clear(); ((KListBox*)w)->insertStringList(list); } else if(classname == "KComboBox") { ((KComboBox*)w)->clear(); ((KComboBox*)w)->insertStringList(list); } } return true; } else if((classname == "KTextEdit") || (classname == "KDateTimeWidget") || (classname == "KTimeWidget") || (classname == "KDateWidget") || (classname == "KIntSpinBox")) { disableFilter(w, container); return true; } return false; }