Changeset View
Changeset View
Standalone View
Standalone View
src/QuickEditor/QuickEditor.cpp
Show All 26 Lines | |||||
27 | const qreal QuickEditor::cornerHandleRadius = 8.0; | 27 | const qreal QuickEditor::cornerHandleRadius = 8.0; | ||
28 | const qreal QuickEditor::midHandleRadius = 5.0; | 28 | const qreal QuickEditor::midHandleRadius = 5.0; | ||
29 | const int QuickEditor::selectionSizeThreshold = 100; | 29 | const int QuickEditor::selectionSizeThreshold = 100; | ||
30 | 30 | | |||
31 | const int QuickEditor::selectionBoxPaddingX = 5; | 31 | const int QuickEditor::selectionBoxPaddingX = 5; | ||
32 | const int QuickEditor::selectionBoxPaddingY = 4; | 32 | const int QuickEditor::selectionBoxPaddingY = 4; | ||
33 | const int QuickEditor::selectionBoxMarginY = 2; | 33 | const int QuickEditor::selectionBoxMarginY = 2; | ||
34 | 34 | | |||
35 | std::pair<QStaticText, std::vector<QStaticText>> QuickEditor::bottomHelpText[]{ | | |||
36 | {QStaticText(i18n("Enter, double-click:")), {QStaticText(i18n("Take screenshot"))}}, | | |||
37 | {QStaticText(i18n("Shift:")), { | | |||
38 | QStaticText(i18n("Hold to toggle magnifier")), | | |||
39 | QStaticText(i18n("while dragging selection handles")) | | |||
40 | }}, | | |||
41 | {QStaticText(i18n("Arrow keys:")), { | | |||
42 | QStaticText(i18n("Move selection rectangle")), | | |||
43 | QStaticText(i18n("Hold Alt to resize, Shift to fine‑tune")) | | |||
44 | }}, | | |||
45 | {QStaticText(i18n("Right-click:")), {QStaticText(i18n("Reset selection"))}}, | | |||
46 | {QStaticText(i18n("Esc:")), {QStaticText(i18n("Cancel"))}}, | | |||
47 | }; | | |||
48 | bool QuickEditor::bottomHelpTextPrepared = false; | 35 | bool QuickEditor::bottomHelpTextPrepared = false; | ||
49 | const int QuickEditor::bottomHelpBoxPaddingX = 12; | 36 | const int QuickEditor::bottomHelpBoxPaddingX = 12; | ||
50 | const int QuickEditor::bottomHelpBoxPaddingY = 8; | 37 | const int QuickEditor::bottomHelpBoxPaddingY = 8; | ||
51 | const int QuickEditor::bottomHelpBoxPairSpacing = 6; | 38 | const int QuickEditor::bottomHelpBoxPairSpacing = 6; | ||
52 | const int QuickEditor::bottomHelpBoxMarginBottom = 5; | 39 | const int QuickEditor::bottomHelpBoxMarginBottom = 5; | ||
53 | const int QuickEditor::midHelpTextFontSize = 12; | 40 | const int QuickEditor::midHelpTextFontSize = 12; | ||
54 | 41 | | |||
55 | const int QuickEditor::magnifierLargeStep = 15; | 42 | const int QuickEditor::magnifierLargeStep = 15; | ||
Show All 10 Lines | 52 | mLabelBackgroundColor(QColor::fromRgbF( | |||
66 | palette().light().color().redF(), | 53 | palette().light().color().redF(), | ||
67 | palette().light().color().greenF(), | 54 | palette().light().color().greenF(), | ||
68 | palette().light().color().blueF(), | 55 | palette().light().color().blueF(), | ||
69 | 0.85 | 56 | 0.85 | ||
70 | )), | 57 | )), | ||
71 | mLabelForegroundColor(palette().windowText().color()), | 58 | mLabelForegroundColor(palette().windowText().color()), | ||
72 | mMidHelpText(i18n("Click and drag to draw a selection rectangle,\nor press Esc to quit")), | 59 | mMidHelpText(i18n("Click and drag to draw a selection rectangle,\nor press Esc to quit")), | ||
73 | mMidHelpTextFont(font()), | 60 | mMidHelpTextFont(font()), | ||
61 | mBottomHelpText{ | ||||
62 | {QStaticText(i18nc("Keyboard/mouse action", "Enter, double-click:")), {QStaticText(i18n("Take screenshot"))}}, | ||||
63 | {QStaticText(i18nc("Keyboard action", "Shift:")), { | ||||
64 | QStaticText(i18nc("Shift key action first half", "Hold to toggle magnifier")), | ||||
65 | QStaticText(i18nc("Shift key action second half", "while dragging selection handles")) | ||||
66 | }}, | ||||
67 | {QStaticText(i18nc("Keyboard action", "Arrow keys:")), { | ||||
68 | QStaticText(i18nc("Shift key action first line", "Move selection rectangle")), | ||||
yurchor: Typo: seletion -> selection | |||||
69 | QStaticText(i18nc("Shift key action second line", "Hold Alt to resize, Shift to fine‑tune")) | ||||
70 | }}, | ||||
71 | {QStaticText(i18nc("Mouse action", "Right-click:")), {QStaticText(i18n("Reset selection"))}}, | ||||
72 | {QStaticText(i18nc("Keyboard action", "Esc:")), {QStaticText(i18n("Cancel"))}}, | ||||
73 | }, | ||||
74 | mBottomHelpTextFont(font()), | 74 | mBottomHelpTextFont(font()), | ||
75 | mBottomHelpGridLeftWidth(0), | 75 | mBottomHelpGridLeftWidth(0), | ||
76 | mMouseDragState(MouseState::None), | 76 | mMouseDragState(MouseState::None), | ||
77 | mPixmap(pixmap), | 77 | mPixmap(pixmap), | ||
78 | mMagnifierAllowed(false), | 78 | mMagnifierAllowed(false), | ||
79 | mShowMagnifier(SpectacleConfig::instance()->showMagnifierChecked()), | 79 | mShowMagnifier(SpectacleConfig::instance()->showMagnifierChecked()), | ||
80 | mToggleMagnifier(false) | 80 | mToggleMagnifier(false) | ||
81 | { | 81 | { | ||
Show All 27 Lines | |||||
109 | 109 | | |||
110 | mMidHelpTextFont.setPointSize(midHelpTextFontSize); | 110 | mMidHelpTextFont.setPointSize(midHelpTextFontSize); | ||
111 | if (!bottomHelpTextPrepared) { | 111 | if (!bottomHelpTextPrepared) { | ||
112 | bottomHelpTextPrepared = true; | 112 | bottomHelpTextPrepared = true; | ||
113 | const auto prepare = [this](QStaticText& item) { | 113 | const auto prepare = [this](QStaticText& item) { | ||
114 | item.prepare(QTransform(), mBottomHelpTextFont); | 114 | item.prepare(QTransform(), mBottomHelpTextFont); | ||
115 | item.setPerformanceHint(QStaticText::AggressiveCaching); | 115 | item.setPerformanceHint(QStaticText::AggressiveCaching); | ||
116 | }; | 116 | }; | ||
117 | for (auto& pair : bottomHelpText) { | 117 | for (auto& pair : mBottomHelpText) { | ||
118 | prepare(pair.first); | 118 | prepare(pair.first); | ||
119 | for (auto item : pair.second) { | 119 | for (auto item : pair.second) { | ||
120 | prepare(item); | 120 | prepare(item); | ||
121 | } | 121 | } | ||
122 | } | 122 | } | ||
123 | } | 123 | } | ||
124 | layoutBottomHelpText(); | 124 | layoutBottomHelpText(); | ||
125 | 125 | | |||
▲ Show 20 Lines • Show All 347 Lines • ▼ Show 20 Line(s) | |||||
473 | 473 | | |||
474 | void QuickEditor::layoutBottomHelpText() | 474 | void QuickEditor::layoutBottomHelpText() | ||
475 | { | 475 | { | ||
476 | int maxRightWidth = 0; | 476 | int maxRightWidth = 0; | ||
477 | int contentWidth = 0; | 477 | int contentWidth = 0; | ||
478 | int contentHeight = 0; | 478 | int contentHeight = 0; | ||
479 | mBottomHelpGridLeftWidth = 0; | 479 | mBottomHelpGridLeftWidth = 0; | ||
480 | int i = 0; | 480 | int i = 0; | ||
481 | for (const auto& item : bottomHelpText) { | 481 | for (const auto& item : mBottomHelpText) { | ||
482 | const auto& left = item.first; | 482 | const auto& left = item.first; | ||
483 | const auto& right = item.second; | 483 | const auto& right = item.second; | ||
484 | const auto leftSize = left.size().toSize(); | 484 | const auto leftSize = left.size().toSize(); | ||
485 | mBottomHelpGridLeftWidth = qMax(mBottomHelpGridLeftWidth, leftSize.width()); | 485 | mBottomHelpGridLeftWidth = qMax(mBottomHelpGridLeftWidth, leftSize.width()); | ||
486 | for (const auto& item : right) { | 486 | for (const auto& item : right) { | ||
487 | const auto rightItemSize = item.size().toSize(); | 487 | const auto rightItemSize = item.size().toSize(); | ||
488 | maxRightWidth = qMax(maxRightWidth, rightItemSize.width()); | 488 | maxRightWidth = qMax(maxRightWidth, rightItemSize.width()); | ||
489 | contentHeight += rightItemSize.height(); | 489 | contentHeight += rightItemSize.height(); | ||
Show All 22 Lines | 506 | { | |||
512 | painter.setPen(mLabelForegroundColor); | 512 | painter.setPen(mLabelForegroundColor); | ||
513 | painter.setFont(mBottomHelpTextFont); | 513 | painter.setFont(mBottomHelpTextFont); | ||
514 | painter.setRenderHint(QPainter::Antialiasing, false); | 514 | painter.setRenderHint(QPainter::Antialiasing, false); | ||
515 | painter.drawRect(mBottomHelpBorderBox); | 515 | painter.drawRect(mBottomHelpBorderBox); | ||
516 | painter.setRenderHint(QPainter::Antialiasing, true); | 516 | painter.setRenderHint(QPainter::Antialiasing, true); | ||
517 | 517 | | |||
518 | int topOffset = mBottomHelpContentPos.y(); | 518 | int topOffset = mBottomHelpContentPos.y(); | ||
519 | int i = 0; | 519 | int i = 0; | ||
520 | for (const auto& item : bottomHelpText) { | 520 | for (const auto& item : mBottomHelpText) { | ||
521 | const auto& left = item.first; | 521 | const auto& left = item.first; | ||
522 | const auto& right = item.second; | 522 | const auto& right = item.second; | ||
523 | const auto leftSize = left.size().toSize(); | 523 | const auto leftSize = left.size().toSize(); | ||
524 | painter.drawStaticText(mBottomHelpGridLeftWidth - leftSize.width(), topOffset, left); | 524 | painter.drawStaticText(mBottomHelpGridLeftWidth - leftSize.width(), topOffset, left); | ||
525 | for (const auto& item : right) { | 525 | for (const auto& item : right) { | ||
526 | const auto rightItemSize = item.size().toSize(); | 526 | const auto rightItemSize = item.size().toSize(); | ||
527 | painter.drawStaticText(mBottomHelpGridLeftWidth + bottomHelpBoxPairSpacing, topOffset, item); | 527 | painter.drawStaticText(mBottomHelpGridLeftWidth + bottomHelpBoxPairSpacing, topOffset, item); | ||
528 | topOffset += rightItemSize.height(); | 528 | topOffset += rightItemSize.height(); | ||
▲ Show 20 Lines • Show All 245 Lines • Show Last 20 Lines |
Typo: seletion -> selection