Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions Viewer/ecflowUI/src/TextPager/TextPagerEdit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "TextPagerEdit.hpp"

#include <algorithm>
#include <array>
#include <cmath>

#include <QGuiApplication>
Expand Down Expand Up @@ -72,9 +73,11 @@ TextPagerEdit::TextPagerEdit(QWidget* parent)
};

std::array shortcuts = {shortcuts_t{tr("Copy"), SLOT(copy()), QKeySequence::Copy},
shortcuts_t{tr("Select All"), SLOT(selectAll()), QKeySequence::SelectAll},
shortcuts_t{QString(), nullptr, QKeySequence::UnknownKey}};
for (int i = 0; shortcuts[i].member; ++i) {
shortcuts_t{tr("Select All"), SLOT(selectAll()), QKeySequence::SelectAll}};
static_assert(std::tuple_size_v<decltype(shortcuts)> == TextPagerEdit::ActionCount,
"shortcuts must hold exactly one entry per ActionType");

for (std::size_t i = 0; i < shortcuts.size(); ++i) {
d->actions[i] = new QAction(shortcuts[i].text, this);
d->actions[i]->setShortcutContext(Qt::WidgetShortcut);
d->actions[i]->setShortcut(QKeySequence(shortcuts[i].key));
Expand Down
3 changes: 2 additions & 1 deletion Viewer/ecflowUI/src/TextPager/TextPagerEdit.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,8 @@ class TextPagerEdit : public QAbstractScrollArea, public VPropertyObserver {
void setShowLineNumbers(bool b);
void setLineNumberArea(TextPagerLineNumberArea* a);

enum ActionType { CopyAction, SelectAllAction };
/// ActionCount must remain the last enumerator: it defines the size of TextEditPrivate::actions.
enum ActionType { CopyAction, SelectAllAction, ActionCount };
QAction* action(ActionType type) const;

public Q_SLOTS:
Expand Down
2 changes: 1 addition & 1 deletion Viewer/ecflowUI/src/TextPager/TextPagerEdit_p.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class TextEditPrivate : public QObject, public TextPagerLayout {
pendingTimeOut, autoScrollLines;
bool readOnly, cursorVisible, blockScrollBarUpdate, updateScrollBarPageStepPending, inMouseEvent;
QBasicTimer autoScrollTimer, cursorBlinkTimer;
QAction* actions[TextPagerEdit::SelectAllAction];
QAction* actions[TextPagerEdit::ActionCount];
TextPagerSection* sectionPressed;
TextPagerCursor textCursor, dragOverrideCursor;
QBasicTimer tripleClickTimer;
Expand Down
Loading