QWidget* RuleDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
    Q_UNUSED(option)

    QWidget *editor = new QWidget(parent);
    KLineEdit *ruleLineEdit = new KLineEdit(editor);
    ruleLineEdit->setToolTip(i18n("Expression"));

    KComboBox *matchComboBox = new KComboBox(editor);
    matchComboBox->setToolTip(i18n("Match Mode"));
    matchComboBox->addItem(i18n("Ignore"));
    matchComboBox->addItem(i18n("Regular expression"));
    matchComboBox->addItem(i18n("Partial match"));
    matchComboBox->addItem(i18n("Exact match"));

    QCheckBox *requiredCheckBox = new QCheckBox(editor);
    requiredCheckBox->setToolTip(i18n("Required"));

    QHBoxLayout *layout = new QHBoxLayout(editor);
    layout->addWidget(ruleLineEdit);
    layout->addWidget(matchComboBox);
    layout->addWidget(requiredCheckBox);
    layout->setMargin(0);

    setEditorData(editor, index);

    return editor;
}
Esempio n. 2
0
QWidget* CharactersViewDelegate::createEditor(QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index) const
{
    switch (index.column())
    {
    case 0:
    {
        KLineEdit* lineEdit = new KLineEdit(parent);

        lineEdit->setFrame(false);
        lineEdit->setMaxLength(1);
        return lineEdit;
    }
    case 1:
    {
        KLineEdit* lineEdit = new KLineEdit(parent);

        lineEdit->setFrame(false);

        QStringList wordList;

        for (int i = 0; i < m_keyboardLayout->keyCount(); i++)
        {
            if (SpecialKey* key = qobject_cast<SpecialKey*>(m_keyboardLayout->key(i)))
            {
                wordList << key->modifierId();
            }
        }

        QCompleter* completer = new QCompleter(wordList, lineEdit);
        lineEdit->setCompleter(completer);

        return lineEdit;
    }
    case 2:
    {
        KComboBox* comboBox = new KComboBox(parent);

        comboBox->setEditable(false);
        comboBox->addItem(i18n("Hidden"), KeyChar::Hidden);
        comboBox->addItem(i18n("Top left"), KeyChar::TopLeft);
        comboBox->addItem(i18n("Top right"), KeyChar::TopRight);
        comboBox->addItem(i18n("Bottom left"), KeyChar::BottomLeft);
        comboBox->addItem(i18n("Bottom right"), KeyChar::BottomRight);

        return comboBox;
    }
    default:
        return QStyledItemDelegate::createEditor(parent, option, index);
    }
}
Esempio n. 3
0
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);
}
Esempio n. 4
0
QWidget *TracksDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem & /* option */, const QModelIndex & /*index*/) const
{
    KComboBox *comboBox = new KComboBox(parent);
    comboBox->addItem(i18n("Video"));
    comboBox->addItem(i18n("Audio"));
    connect(comboBox, SIGNAL(activated(int)), this, SLOT(emitCommitData()));
    return comboBox;
}
void HolidayRegionSelector::Private::initItem( QTreeWidgetItem *listItem, HolidayRegion *region )
{
  m_ui.regionTreeWidget->blockSignals( true );
  QString languageName = KGlobal::locale()->languageCodeToName( region->languageCode() );
  listItem->setCheckState( Private::SelectColumn, Qt::Unchecked );
  QString text = i18n( "<p>Select to use Holiday Region</p>" );
  listItem->setToolTip( Private::SelectColumn, text );
  listItem->setToolTip( Private::ComboColumn, text );
  text = i18n( "<p>Select to use Holiday Region</p>" );
  listItem->setToolTip( Private::SelectColumn, text );
  listItem->setToolTip( Private::ComboColumn, text );
  listItem->setText( Private::RegionColumn, region->name() );
  QString toolTip = i18n( "<p><b>Region:</b> %1<br/>"
                          "<b>Language:</b> %2<br/>"
                          "<b>Description:</b> %3</p>",
                          region->name(), languageName, region->description() );
  listItem->setToolTip( Private::RegionColumn, toolTip );
  listItem->setData( Private::RegionColumn, Qt::UserRole, region->regionCode() );
  listItem->setText( Private::LanguageColumn, languageName );
  listItem->setData( Private::LanguageColumn, Qt::UserRole, region->languageCode() );
  listItem->setText( Private::DescriptionColumn, region->description() );
  listItem->setToolTip( Private::DescriptionColumn, region->description() );
  KComboBox *combo = new KComboBox();
  combo->setAutoFillBackground( true );
  QString comboText = i18n( "<p>You can choose to display the Holiday Region for information only, "
                            "or to use the Holiday Region when displaying or calculating days off "
                            "such as Public Holidays.  If you choose to use the Holiday Region for "
                            "Days Off, then only those Holiday Events marked in the Holiday Region "
                            "as Days Off will be used for non-work days, Holiday Events that are "
                            "not marked in the Holiday Region as Days Off will continue to be "
                            "work days.</p>" );
  combo->setToolTip( comboText );
  comboText = i18nc( "Combobox label, Holiday Region not used", "Not Used" );
  combo->addItem( comboText, QVariant( NotUsed ) );
  comboText = i18nc( "Combobox label, use Holiday Region for information only", "Information" );
  combo->addItem( comboText, QVariant( UseInformationOnly ) );
  comboText = i18nc( "Combobox label, use Holiday Region for days off", "Days Off" );
  combo->addItem( comboText, QVariant( UseDaysOff ) );
  combo->setCurrentIndex( 0 );
  listItem->setData( Private::ComboColumn, Qt::UserRole, NotUsed );
  m_ui.regionTreeWidget->setItemWidget( listItem, ComboColumn, combo );
  connect( combo, SIGNAL(currentIndexChanged(int)),
           q, SLOT(itemChanged(int)) );
  m_ui.regionTreeWidget->blockSignals( false );
}
Esempio n. 6
0
void FindFilesDialog::setDirName(const QString &dir)
{
	KComboBox *combo = dir_combo->comboBox();

	if (findListItem(combo, dir) < 0) {
		combo->addItem(dir);
	}
	if (combo->itemText(0) != dir) {
		slotClear();
	}
}
Esempio n. 7
0
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;
}
Esempio n. 8
0
QWidget *KOTodoPriorityDelegate::createEditor( QWidget *parent,
                                               const QStyleOptionViewItem &option,
                                               const QModelIndex &index ) const
{
  Q_UNUSED( option );
  Q_UNUSED( index );

  KComboBox *combo = new KComboBox( parent );

  combo->addItem( i18nc( "@action:inmenu Unspecified priority", "unspecified" ) );
  combo->addItem( i18nc( "@action:inmenu highest priority", "1 (highest)" ) );
  combo->addItem( i18nc( "@action:inmenu", "2" ) );
  combo->addItem( i18nc( "@action:inmenu", "3" ) );
  combo->addItem( i18nc( "@action:inmenu", "4" ) );
  combo->addItem( i18nc( "@action:inmenu medium priority", "5 (medium)" ) );
  combo->addItem( i18nc( "@action:inmenu", "6" ) );
  combo->addItem( i18nc( "@action:inmenu", "7" ) );
  combo->addItem( i18nc( "@action:inmenu", "8" ) );
  combo->addItem( i18nc( "@action:inmenu lowest priority", "9 (lowest)" ) );

  return combo;
}
Esempio n. 9
0
CreateChecksumDlg::CreateChecksumDlg(const QStringList& files, bool containFolders, const QString& path)
    : QDialog(krApp)
{
    setWindowModality(Qt::WindowModal);
    setWindowTitle(i18n("Create Checksum"));

    QVBoxLayout *mainLayout = new QVBoxLayout;
    setLayout(mainLayout);

    QList<CS_Tool *> tools = getTools(containFolders);

    if (tools.count() == 0) { // nothing was suggested?!
        QString error = i18n("<qt>Cannot calculate checksum since no supported tool was found. "
                             "Please check the <b>Dependencies</b> page in Krusader's settings.</qt>");
        if (containFolders)
            error += i18n("<qt><b>Note</b>: you have selected folders, and probably have no recursive checksum tool installed."
                          " Krusader currently supports <i>md5deep, sha1deep, sha256deep, tigerdeep and cfv</i></qt>");
        KMessageBox::error(0, error);
        return;
    }

    QWidget * widget = new QWidget(this);
    QGridLayout *layout = new QGridLayout(widget);

    int row = 0;

    // title (icon+text)
    QHBoxLayout *hlayout = new QHBoxLayout;
    QLabel *p = new QLabel(widget);
    p->setPixmap(krLoader->loadIcon("document-edit-sign", KIconLoader::Desktop, 32));
    hlayout->addWidget(p);
    QLabel *l1 = new QLabel(widget);

    if (containFolders)
        l1->setText(i18n("About to calculate checksum for the following files and folders:"));
    else
        l1->setText(i18n("About to calculate checksum for the following files:"));

    hlayout->addWidget(l1);
    layout->addLayout(hlayout, row, 0, 1, 2, Qt::AlignLeft);
    ++row;

    // file list
    KrListWidget *lb = new KrListWidget(widget);
    lb->addItems(files);
    layout->addWidget(lb, row, 0, 1, 2);
    ++row;

    // checksum method
    QHBoxLayout *hlayout2 = new QHBoxLayout;
    QLabel *l2 = new QLabel(i18n("Select the checksum method:"), widget);
    hlayout2->addWidget(l2);
    KComboBox *method = new KComboBox(widget);
    // -- fill the combo with available methods
    int i;
    for (i = 0; i < tools.count(); ++i)
        method->addItem(cs_typeToText[tools.at(i)->type], i);
    method->setFocus();
    hlayout2->addWidget(method);
    layout->addLayout(hlayout2, row, 0, 1, 2, Qt::AlignLeft);
    ++row;
    mainLayout->addWidget(widget);

    QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok|QDialogButtonBox::Cancel);
    mainLayout->addWidget(buttonBox);

    QPushButton *okButton = buttonBox->button(QDialogButtonBox::Ok);
    okButton->setDefault(true);
    okButton->setShortcut(Qt::CTRL | Qt::Key_Return);
    connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
    connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));

    if (exec() != Accepted) return;
    // else implied: run the process
    QTemporaryFile tmpOut(QDir::tempPath() + QLatin1String("/krusader_XXXXXX.stdout"));
    tmpOut.open(); // necessary to create the filename
    QTemporaryFile tmpErr(QDir::tempPath() + QLatin1String("/krusader_XXXXXX.stderr"));
    tmpErr.open(); // necessary to create the filename
    KProcess proc;
    CS_Tool *mytool = tools.at(method->currentIndex());
    mytool->create(proc, mytool, files, QString(), containFolders, method->currentText());
    proc.setOutputChannelMode(KProcess::SeparateChannels); // without this the next 2 lines have no effect!
    proc.setStandardOutputFile(tmpOut.fileName());
    proc.setStandardErrorFile(tmpErr.fileName());
    proc.setWorkingDirectory(path);

    krApp->startWaiting(i18n("Calculating checksums..."), 0, true);
    QApplication::setOverrideCursor(Qt::WaitCursor);
    proc.start();
    // TODO make use of asynchronous process starting. waitForStarted(int msec = 30000) is blocking
    // it would be better to connect to started(), error() and finished()
    if (proc.waitForStarted())
        while (proc.state() == QProcess::Running) {
            usleep(500);
            qApp->processEvents();
            if (krApp->wasWaitingCancelled()) { // user cancelled
                proc.kill();
                QApplication::restoreOverrideCursor();
                return;
            }
        };
    krApp->stopWait();
    QApplication::restoreOverrideCursor();
    if (proc.exitStatus() != QProcess::NormalExit) {
        KMessageBox::error(0, i18n("<qt>There was an error while running <b>%1</b>.</qt>", mytool->binary));
        return;
    }

    // suggest a filename
    QString suggestedFilename = path + '/';
    if (files.count() > 1) suggestedFilename += ("checksum." + cs_typeToText[mytool->type]);
    else suggestedFilename += (files[0] + '.' + cs_typeToText[mytool->type]);
    // send both stdout and stderr
    QStringList stdOut, stdErr;
    if (!KrServices::fileToStringList(&tmpOut, stdOut) ||
            !KrServices::fileToStringList(&tmpErr, stdErr)) {
        KMessageBox::error(krApp, i18n("Error reading stdout or stderr"));
        return;
    }

    ChecksumResultsDlg dlg(stdOut, stdErr, suggestedFilename, mytool->standardFormat);
}
Esempio n. 10
0
    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);
    }
Esempio n. 11
0
void BGDialog::loadWallpaperFilesList()
{

    // Wallpapers
    // the following QMap is lower cased names mapped to cased names and URLs
    // this way we get case insensitive sorting
    QMap<QString, QPair<QString, QString> > papers;

    //search for .desktop files before searching for images without .desktop files
    QStringList lst = m_pDirs->findAllResources("wallpaper", "*desktop", KStandardDirs::NoDuplicates);
    QStringList files;
    for (QStringList::ConstIterator it = lst.constBegin(); it != lst.constEnd(); ++it) {
        KDesktopFile fileConfig(*it);
        KConfigGroup cg = fileConfig.group("Wallpaper");

        QString imageCaption = cg.readEntry("Name");
        QString fileName = cg.readEntry("File");

        if (imageCaption.isEmpty()) {
            imageCaption = fileName;
            imageCaption.replace('_', ' ');
            imageCaption = KStringHandler::capwords(imageCaption);
        }

        // avoid name collisions
        QString rs = imageCaption;
        QString lrs = rs.toLower();
        for (int n = 1; papers.find(lrs) != papers.end(); ++n) {
            rs = imageCaption + " (" + QString::number(n) + ')';
            lrs = rs.toLower();
        }
        int slash = (*it).lastIndexOf('/') + 1;
        QString directory = (*it).left(slash);
        if (cg.readEntry("ImageType") == QLatin1String("pixmap")) {
            papers[lrs] = qMakePair(rs, QString(directory + fileName));
            files.append(directory + fileName);
        }
    }

    //now find any wallpapers that don't have a .desktop file
    lst = m_pDirs->findAllResources("wallpaper", "*", KStandardDirs::NoDuplicates);
    for (QStringList::ConstIterator it = lst.constBegin(); it != lst.constEnd(); ++it) {
        if (!(*it).endsWith(".desktop") && files.filter(*it).empty()) {
            // First try to see if we have a comment describing the image.  If we do
            // just use the first line of said comment.
            KFileMetaInfo metaInfo(*it);
            QString imageCaption;

            if (metaInfo.isValid() && metaInfo.item("Comment").isValid())
                imageCaption = metaInfo.item("Comment").value().toString().section('\n', 0, 0);

            if (imageCaption.isEmpty()) {
                int slash = (*it).lastIndexOf('/') + 1;
                int endDot = (*it).lastIndexOf('.');

                // strip the extension if it exists
                if (endDot != -1 && endDot > slash)
                    imageCaption = (*it).mid(slash, endDot - slash);
                else
                    imageCaption = (*it).mid(slash);

                imageCaption.replace('_', ' ');
                imageCaption = KStringHandler::capwords(imageCaption);
            }

            // avoid name collisions
            QString rs = imageCaption;
            QString lrs = rs.toLower();
            for (int n = 1; papers.find(lrs) != papers.end(); ++n) {
                rs = imageCaption + " (" + QString::number(n) + ')';
                lrs = rs.toLower();
            }
            papers[lrs] = qMakePair(rs, *it);
        }
    }

    KComboBox *comboWallpaper = m_urlWallpaperBox;
    comboWallpaper->clear();
    m_wallpaper.clear();
    int i = 0;
    for (QMap<QString, QPair<QString, QString> >::Iterator it = papers.begin();
            it != papers.end();
            ++it) {
        comboWallpaper->addItem(it.value().first);
        m_wallpaper[it.value().second] = i;
        i++;
    }
}