Changeset View
Changeset View
Standalone View
Standalone View
src/ksqueezedtextlabel.cpp
Show First 20 Lines • Show All 140 Lines • ▼ Show 20 Line(s) | 139 | { | |||
---|---|---|---|---|---|
141 | squeezeTextToLabel(); | 141 | squeezeTextToLabel(); | ||
142 | } | 142 | } | ||
143 | 143 | | |||
144 | QString KSqueezedTextLabel::fullText() const | 144 | QString KSqueezedTextLabel::fullText() const | ||
145 | { | 145 | { | ||
146 | return d->fullText; | 146 | return d->fullText; | ||
147 | } | 147 | } | ||
148 | 148 | | |||
149 | bool KSqueezedTextLabel::isSqueezed() const | ||||
150 | { | ||||
151 | return d->fullText != text(); | ||||
152 | } | ||||
153 | | ||||
149 | void KSqueezedTextLabel::contextMenuEvent(QContextMenuEvent *ev) | 154 | void KSqueezedTextLabel::contextMenuEvent(QContextMenuEvent *ev) | ||
150 | { | 155 | { | ||
151 | // We want to reimplement "Copy" to include the elided text. | 156 | // We want to reimplement "Copy" to include the elided text. | ||
152 | // But this means reimplementing the full popup menu, so no more | 157 | // But this means reimplementing the full popup menu, so no more | ||
153 | // copy-link-address or copy-selection support anymore, since we | 158 | // copy-link-address or copy-selection support anymore, since we | ||
154 | // have no access to the QTextDocument. | 159 | // have no access to the QTextDocument. | ||
155 | // Maybe we should have a boolean flag in KSqueezedTextLabel itself for | 160 | // Maybe we should have a boolean flag in KSqueezedTextLabel itself for | ||
156 | // whether to show the "Copy Full Text" custom popup? | 161 | // whether to show the "Copy Full Text" custom popup? | ||
157 | // For now I chose to show it when the text is squeezed; when it's not, the | 162 | // For now I chose to show it when the text is squeezed; when it's not, the | ||
158 | // standard popup menu can do the job (select all, copy). | 163 | // standard popup menu can do the job (select all, copy). | ||
159 | 164 | | |||
160 | const bool squeezed = text() != d->fullText; | 165 | if (isSqueezed()) { | ||
161 | const bool showCustomPopup = squeezed; | | |||
162 | if (showCustomPopup) { | | |||
163 | QMenu menu(this); | 166 | QMenu menu(this); | ||
164 | 167 | | |||
165 | QAction *act = new QAction(tr("&Copy Full Text"), &menu); | 168 | QAction *act = new QAction(tr("&Copy Full Text"), &menu); | ||
166 | connect(act, SIGNAL(triggered()), this, SLOT(_k_copyFullText())); | 169 | connect(act, SIGNAL(triggered()), this, SLOT(_k_copyFullText())); | ||
167 | menu.addAction(act); | 170 | menu.addAction(act); | ||
168 | 171 | | |||
169 | ev->accept(); | 172 | ev->accept(); | ||
170 | menu.exec(ev->globalPos()); | 173 | menu.exec(ev->globalPos()); | ||
▲ Show 20 Lines • Show All 43 Lines • Show Last 20 Lines |