Changeset View
Changeset View
Standalone View
Standalone View
src/webquery/webqueryview.cpp
Show First 20 Lines • Show All 47 Lines • ▼ Show 20 Line(s) | |||||
48 | #include <klocalizedstring.h> | 48 | #include <klocalizedstring.h> | ||
49 | 49 | | |||
50 | #include "webquerycontroller.h" | 50 | #include "webquerycontroller.h" | ||
51 | 51 | | |||
52 | #include <QDragEnterEvent> | 52 | #include <QDragEnterEvent> | ||
53 | #include <QTime> | 53 | #include <QTime> | ||
54 | #include <QSplitter> | 54 | #include <QSplitter> | ||
55 | #include <QTextBrowser> | 55 | #include <QTextBrowser> | ||
56 | #include <QSignalMapper> | | |||
57 | #include <QTimer> | 56 | #include <QTimer> | ||
58 | 57 | | |||
59 | // #include <QShortcutEvent> | 58 | // #include <QShortcutEvent> | ||
60 | #include "myactioncollectionview.h" | 59 | #include "myactioncollectionview.h" | ||
61 | 60 | | |||
62 | using namespace Kross; | 61 | using namespace Kross; | ||
63 | 62 | | |||
64 | WebQueryView::WebQueryView(QWidget* parent, Catalog* catalog, const QVector<QAction*>& actions) | 63 | WebQueryView::WebQueryView(QWidget* parent, Catalog* catalog, const QVector<QAction*>& actions) | ||
Show All 37 Lines | 99 | // | ActionCollectionModel::ToolTips | ActionCollectionModel::UserCheckable );*/ | |||
102 | ui_queryControl->actionzView->setModel(m); | 101 | ui_queryControl->actionzView->setModel(m); | ||
103 | // m_boxLayout->addWidget(w); | 102 | // m_boxLayout->addWidget(w); | ||
104 | ui_queryControl->actionzView->data.webQueryView = this; | 103 | ui_queryControl->actionzView->data.webQueryView = this; | ||
105 | 104 | | |||
106 | 105 | | |||
107 | m_browser->setToolTip(i18nc("@info:tooltip", "Double-click any word to insert it into translation")); | 106 | m_browser->setToolTip(i18nc("@info:tooltip", "Double-click any word to insert it into translation")); | ||
108 | 107 | | |||
109 | 108 | | |||
110 | QSignalMapper* signalMapper = new QSignalMapper(this); | | |||
111 | int i = m_actions.size(); | 109 | int i = m_actions.size(); | ||
112 | while (--i >= 0) { | 110 | while (--i >= 0) { | ||
113 | connect(m_actions.at(i), &QAction::triggered, signalMapper, QOverload<>::of(&QSignalMapper::map)); | 111 | connect(m_actions.at(i), &QAction::triggered, this, [this, i] { slotUseSuggestion(i); }); | ||
114 | signalMapper->setMapping(m_actions.at(i), i); | | |||
115 | } | 112 | } | ||
116 | connect(signalMapper, QOverload<int>::of(&QSignalMapper::mapped), this, &WebQueryView::slotUseSuggestion); | | |||
117 | connect(m_browser, &QTextBrowser::selectionChanged, this, &WebQueryView::slotSelectionChanged); | 113 | connect(m_browser, &QTextBrowser::selectionChanged, this, &WebQueryView::slotSelectionChanged); | ||
118 | 114 | | |||
119 | } | 115 | } | ||
120 | 116 | | |||
121 | void WebQueryView::slotSelectionChanged() | 117 | void WebQueryView::slotSelectionChanged() | ||
122 | { | 118 | { | ||
123 | //NOTE works fine only for dbl-click word selection | 119 | //NOTE works fine only for dbl-click word selection | ||
124 | //(actually, quick word insertion is exactly the purpose of this slot:) | 120 | //(actually, quick word insertion is exactly the purpose of this slot:) | ||
▲ Show 20 Lines • Show All 60 Lines • Show Last 20 Lines |