Changeset View
Changeset View
Standalone View
Standalone View
src/commandentry.cpp
Show First 20 Lines • Show All 68 Lines • ▼ Show 20 Line(s) | 59 | CommandEntry::CommandEntry(Worksheet* worksheet) : WorksheetEntry(worksheet), | |||
---|---|---|---|---|---|
69 | m_textColorActionGroup(nullptr), | 69 | m_textColorActionGroup(nullptr), | ||
70 | m_textColorMenu(nullptr), | 70 | m_textColorMenu(nullptr), | ||
71 | m_fontMenu(nullptr) | 71 | m_fontMenu(nullptr) | ||
72 | { | 72 | { | ||
73 | 73 | | |||
74 | m_promptItem->setPlainText(Prompt); | 74 | m_promptItem->setPlainText(Prompt); | ||
75 | m_promptItem->setItemDragable(true); | 75 | m_promptItem->setItemDragable(true); | ||
76 | m_commandItem->enableCompletion(true); | 76 | m_commandItem->enableCompletion(true); | ||
77 | if (worksheet->isReadOnly()) | ||||
78 | m_commandItem->setTextInteractionFlags(Qt::TextBrowserInteraction | Qt::TextSelectableByKeyboard); | ||||
77 | 79 | | |||
78 | KColorScheme scheme = KColorScheme(QPalette::Normal, KColorScheme::View); | 80 | KColorScheme scheme = KColorScheme(QPalette::Normal, KColorScheme::View); | ||
79 | m_commandItem->setBackgroundColor(scheme.background(KColorScheme::AlternateBackground).color()); | 81 | m_commandItem->setBackgroundColor(scheme.background(KColorScheme::AlternateBackground).color()); | ||
80 | 82 | | |||
81 | m_promtItemTimer = new QTimer(this); | 83 | m_promtItemTimer = new QTimer(this); | ||
82 | connect(m_promtItemTimer, &QTimer::timeout, this, &CommandEntry::animatePromptItem); | 84 | connect(m_promtItemTimer, &QTimer::timeout, this, &CommandEntry::animatePromptItem); | ||
83 | 85 | | |||
84 | connect(m_commandItem, &WorksheetTextItem::tabPressed, this, &CommandEntry::showCompletion); | 86 | connect(m_commandItem, &WorksheetTextItem::tabPressed, this, &CommandEntry::showCompletion); | ||
▲ Show 20 Lines • Show All 335 Lines • ▼ Show 20 Line(s) | 406 | { | |||
420 | m_commandItem->setFont(font); | 422 | m_commandItem->setFont(font); | ||
421 | } | 423 | } | ||
422 | 424 | | |||
423 | setExpression(expr); | 425 | setExpression(expr); | ||
424 | } | 426 | } | ||
425 | 427 | | |||
426 | void CommandEntry::showCompletion() | 428 | void CommandEntry::showCompletion() | ||
427 | { | 429 | { | ||
430 | if (worksheet()->isReadOnly()) | ||||
asemke: Is this really required if we don't allow any interaction for the item? | |||||
This patch doesn't forbid completions in worksheet (for example, if we add completion in Latex, or Markdown entries (for latex and markdown langs, of cource), we could use it even in read only mode) sirgienko: This patch doesn't forbid completions in worksheet (for example, if we add completion in Latex… | |||||
431 | return; | ||||
432 | | ||||
428 | const QString line = currentLine(); | 433 | const QString line = currentLine(); | ||
429 | 434 | | |||
430 | if(!worksheet()->completionEnabled() || line.trimmed().isEmpty()) | 435 | if(!worksheet()->completionEnabled() || line.trimmed().isEmpty()) | ||
431 | { | 436 | { | ||
432 | if (m_commandItem->hasFocus()) | 437 | if (m_commandItem->hasFocus()) | ||
433 | m_commandItem->insertTab(); | 438 | m_commandItem->insertTab(); | ||
434 | return; | 439 | return; | ||
435 | } else if (isShowingCompletionPopup()) { | 440 | } else if (isShowingCompletionPopup()) { | ||
▲ Show 20 Lines • Show All 116 Lines • ▼ Show 20 Line(s) | 555 | } else if (informationItemHasFocus()) { | |||
552 | return true; | 557 | return true; | ||
553 | } | 558 | } | ||
554 | 559 | | |||
555 | return false; | 560 | return false; | ||
556 | } | 561 | } | ||
557 | 562 | | |||
558 | bool CommandEntry::evaluate(EvaluationOption evalOp) | 563 | bool CommandEntry::evaluate(EvaluationOption evalOp) | ||
559 | { | 564 | { | ||
565 | if (worksheet()->isReadOnly()) | ||||
566 | { | ||||
567 | // Worksheet is read only, so evaluate next | ||||
568 | evaluateNext(evalOp); | ||||
569 | return true; | ||||
570 | } | ||||
571 | | ||||
560 | removeContextHelp(); | 572 | removeContextHelp(); | ||
561 | QToolTip::hideText(); | 573 | QToolTip::hideText(); | ||
562 | 574 | | |||
563 | QString cmd = command(); | 575 | QString cmd = command(); | ||
564 | m_evaluationOption = evalOp; | 576 | m_evaluationOption = evalOp; | ||
565 | 577 | | |||
566 | if(cmd.isEmpty()) { | 578 | if(cmd.isEmpty()) { | ||
567 | removeResult(); | 579 | removeResult(); | ||
▲ Show 20 Lines • Show All 571 Lines • Show Last 20 Lines |
Is this really required if we don't allow any interaction for the item?