void MetaQueryWidget::makeFormatComboSelection() { KComboBox* combo = new KComboBox( this ); combo->setSizePolicy( QSizePolicy::Ignored, QSizePolicy::Preferred ); QStringList filetypes = Amarok::FileTypeSupport::possibleFileTypes(); for (int listpos=0;listpos<filetypes.size();listpos++) { combo->addItem(filetypes.at(listpos),listpos); } int index = m_fieldSelection->findData( (int)m_filter.numValue ); combo->setCurrentIndex( index == -1 ? 0 : index ); connect( combo, SIGNAL( currentIndexChanged(int) ), SLOT( numValueFormatChanged(int) ) ); m_valueSelection1 = combo; }
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())); }
void setupGUI() { QBoxLayout *layout = new QVBoxLayout(p); tabWidget = new QTabWidget(p); layout->addWidget(tabWidget); QWidget *container = new QWidget(tabWidget); tabWidget->addTab(container, QIcon::fromTheme(QStringLiteral("preferences-web-browser-identification")), i18n("Library")); connect(tabWidget, &QTabWidget::currentChanged, p, &ZoteroBrowser::tabChanged); QBoxLayout *containerLayout = new QVBoxLayout(container); /// Personal or Group Library QGridLayout *gridLayout = new QGridLayout(); containerLayout->addLayout(gridLayout); gridLayout->setMargin(0); gridLayout->setColumnMinimumWidth(0, 16); // TODO determine size of a radio button radioPersonalLibrary = new QRadioButton(i18n("Personal library"), container); gridLayout->addWidget(radioPersonalLibrary, 0, 0, 1, 2); radioGroupLibrary = new QRadioButton(i18n("Group library"), container); gridLayout->addWidget(radioGroupLibrary, 1, 0, 1, 2); comboBoxGroupList = new KComboBox(false, container); gridLayout->addWidget(comboBoxGroupList, 2, 1, 1, 1); QSizePolicy sizePolicy = comboBoxGroupList->sizePolicy(); sizePolicy.setHorizontalPolicy(QSizePolicy::MinimumExpanding); comboBoxGroupList->setSizePolicy(sizePolicy); radioPersonalLibrary->setChecked(true); comboBoxGroupList->setEnabled(false); comboBoxGroupList->addItem(i18n("No groups available")); connect(radioGroupLibrary, &QRadioButton::toggled, p, &ZoteroBrowser::radioButtonsToggled); connect(radioPersonalLibrary, &QRadioButton::toggled, p, &ZoteroBrowser::radioButtonsToggled); connect(comboBoxGroupList, static_cast<void (KComboBox::*)(int)>(&KComboBox::currentIndexChanged), p, &ZoteroBrowser::groupListChanged); containerLayout->addStretch(10); /// Credentials QFormLayout *containerForm = new QFormLayout(); containerLayout->addLayout(containerForm, 1); containerForm->setMargin(0); lineEditNumericUserId = new KLineEdit(container); lineEditNumericUserId->setSizePolicy(sizePolicy); lineEditNumericUserId->setReadOnly(true); containerForm->addRow(i18n("Numeric user id:"), lineEditNumericUserId); connect(lineEditNumericUserId, &KLineEdit::textChanged, p, &ZoteroBrowser::invalidateGroupList); lineEditApiKey = new KLineEdit(container); lineEditApiKey->setSizePolicy(sizePolicy); lineEditApiKey->setReadOnly(true); containerForm->addRow(i18n("API key:"), lineEditApiKey); connect(lineEditApiKey, &KLineEdit::textChanged, p, &ZoteroBrowser::invalidateGroupList); QBoxLayout *containerButtonLayout = new QHBoxLayout(); containerLayout->addLayout(containerButtonLayout, 0); containerButtonLayout->setMargin(0); QPushButton *buttonGetOAuthCredentials = new QPushButton(QIcon::fromTheme(QStringLiteral("preferences-web-browser-identification")), i18n("Get New Credentials"), container); containerButtonLayout->addWidget(buttonGetOAuthCredentials, 0); connect(buttonGetOAuthCredentials, &QPushButton::clicked, p, &ZoteroBrowser::getOAuthCredentials); containerButtonLayout->addStretch(1); /// Collection browser collectionBrowser = new QTreeView(tabWidget); tabWidget->addTab(collectionBrowser, QIcon::fromTheme(QStringLiteral("folder-yellow")), i18n("Collections")); collectionBrowser->setHeaderHidden(true); collectionBrowser->setExpandsOnDoubleClick(false); connect(collectionBrowser, &QTreeView::doubleClicked, p, &ZoteroBrowser::collectionDoubleClicked); /// Tag browser tagBrowser = new QListView(tabWidget); tabWidget->addTab(tagBrowser, QIcon::fromTheme(QStringLiteral("mail-tagged")), i18n("Tags")); connect(tagBrowser, &QListView::doubleClicked, p, &ZoteroBrowser::tagDoubleClicked); }