| 458 | } |
| 459 | |
| 460 | TextEditorToolbar::TextEditorToolbar(TextEditor& editor) |
| 461 | : m_editor(editor), m_save(nullptr), m_wordWrap(nullptr), m_explore(nullptr), |
| 462 | m_path(nullptr) |
| 463 | { |
| 464 | m_save = new QAction(QIcon(":/MO/gui/save"), QObject::tr("&Save"), &editor); |
| 465 | |
| 466 | m_save->setShortcutContext(Qt::WidgetWithChildrenShortcut); |
| 467 | m_save->setShortcut(Qt::CTRL + Qt::Key_S); |
| 468 | m_editor.addAction(m_save); |
| 469 | |
| 470 | m_wordWrap = |
| 471 | new QAction(QIcon(":/MO/gui/word-wrap"), QObject::tr("&Word wrap"), &editor); |
| 472 | |
| 473 | m_wordWrap->setCheckable(true); |
| 474 | |
| 475 | m_explore = new QAction(QObject::tr("&Open in Explorer"), &editor); |
| 476 | |
| 477 | m_path = new QLineEdit; |
| 478 | m_path->setReadOnly(true); |
| 479 | |
| 480 | QObject::connect(m_save, &QAction::triggered, [&] { |
| 481 | m_editor.save(); |
| 482 | }); |
| 483 | QObject::connect(m_wordWrap, &QAction::triggered, [&] { |
| 484 | m_editor.toggleWordWrap(); |
| 485 | }); |
| 486 | QObject::connect(m_explore, &QAction::triggered, [&] { |
| 487 | m_editor.explore(); |
| 488 | }); |
| 489 | |
| 490 | auto* layout = new QHBoxLayout(this); |
| 491 | layout->setContentsMargins(0, 0, 0, 0); |
| 492 | layout->setAlignment(Qt::AlignLeft); |
| 493 | |
| 494 | auto* b = new QToolButton; |
| 495 | b->setDefaultAction(m_save); |
| 496 | layout->addWidget(b); |
| 497 | |
| 498 | b = new QToolButton; |
| 499 | b->setDefaultAction(m_wordWrap); |
| 500 | layout->addWidget(b); |
| 501 | |
| 502 | b = new QToolButton; |
| 503 | b->setDefaultAction(m_explore); |
| 504 | layout->addWidget(b); |
| 505 | |
| 506 | layout->addWidget(m_path); |
| 507 | |
| 508 | QObject::connect(&m_editor, &TextEditor::modified, [&](bool b) { |
| 509 | onTextModified(b); |
| 510 | }); |
| 511 | QObject::connect(&m_editor, &TextEditor::wordWrapChanged, [&](bool b) { |
| 512 | onWordWrap(b); |
| 513 | }); |
| 514 | QObject::connect(&m_editor, &TextEditor::loaded, [&](QString f) { |
| 515 | onLoaded(f); |
| 516 | }); |
| 517 | } |
nothing calls this directly
no test coverage detected