SkypeMainOptionsWidget::SkypeMainOptionsWidget(ParameterEditModel *model, QWidget *parent)
 : AbstractAccountParametersWidget(model, parent)
{
    // Set up the UI.
    m_ui = new Ui::SkypeMainOptionsWidget;
    m_ui->setupUi(this);

    handleParameter(QLatin1String("account"), QVariant::String, m_ui->accountLineEdit, m_ui->accountLabel);

#ifdef Q_WS_X11
    // get autocomplete choices for the accountname
    // Skype stores data for each account that has been used in $HOME/.Skype/<accountname>/
    QDir skypeConfigDir(QDir::home().filePath(QLatin1String(".Skype")));

    skypeConfigDir.setFilter(QDir::Dirs | QDir::NoDotAndDotDot);
    QFileInfoList folderList = skypeConfigDir.entryInfoList();

    KCompletion *completion = new KCompletion;
    Q_FOREACH (const QFileInfo &info, folderList) {
        completion->addItem(info.fileName());
    }
Пример #2
0
void ConsoleDockWidget::executeCommand( const QString &_commandString )
{
    if ( _commandString.isEmpty() ) {
        kDebug() << "No command given";
        return;
    }

    Project *project = m_projectModel->activeProject();
    if ( !project ) {
        kDebug() << "No active project";
        return;
    }

    setState( EvaluatingResult );

    // Check if the command string ends with a '\'. If it does, add the command to the current
    // multiline command and wait for more input. If not, check if there are entered multiline
    // command lines.
    QString commandString = _commandString;
    if ( commandString.endsWith('\\') ) {
        const QString correctedCommandString = commandString.left( commandString.length() - 1 );
        if ( m_enteredMultilineCommandLines.isEmpty() ) {
            // Write first line of a multiline command to console
            appendToConsole( QString("<b> &gt; %1</b>").arg(encodeInput(correctedCommandString)) );
        } else {
            // Write following line of a multiline command to console
            appendToConsole( QString("<b>   %1</b>").arg(encodeInput(correctedCommandString)) );
        }
        m_enteredMultilineCommandLines << correctedCommandString;
        setState( WaitingForInput );
        return;
    } else if ( !m_enteredMultilineCommandLines.isEmpty() ) {
        // Write last line of a multiline command to console
        appendToConsole( QString("<b>   %1</b>").arg(encodeInput(commandString)) );

        // Prepend already entered lines
        commandString.prepend( m_enteredMultilineCommandLines.join("\n") + '\n' );
        m_enteredMultilineCommandLines.clear();
    } else {
        // Write executed command to console
        appendToConsole( QString("<b> &gt; %1</b>").arg(encodeInput(commandString)) );
    }

    // Store executed command in history (use up/down keys)
    if ( m_consoleHistory.isEmpty() || m_consoleHistory.first() != commandString ) {
        m_consoleHistory.prepend( commandString );
    }
    m_consoleHistoryIndex = -1;

    // Add executed command to completion object
    KCompletion *completion = m_commandLineEdit->completionObject();
    if ( !completion->items().contains(commandString) ) {
        completion->addItem( commandString );
    }

    // Check if commandString contains a command of the form ".<command> ..."
    Debugger::ConsoleCommand command = Debugger::ConsoleCommand::fromString( commandString );
    if ( command.isValid() )  {
        if ( command.command() == ConsoleCommand::ClearCommand ) {
            // The clear command cannot be executed in the debugger,
            // simply clear the console history here
            m_consoleWidget->clear();
            setState( WaitingForInput );
        } else {
            // Execute the command
            project->debugger()->executeCommand( command );
        }
    } else {
        // No command given, execute string as script code
        project->debugger()->evaluateInContext( commandString,
                                                i18nc("@info/plain", "Console Command (%1)", commandString) );
    }
}
Пример #3
0
void FindBarBase::addToCompletion(const QString &text)
{
    KCompletion *comp = mSearch->completionObject();
    comp->addItem(text);
}