Changeset View
Changeset View
Standalone View
Standalone View
krusader/DiskUsage/radialMap/widgetEvents.cpp
Show First 20 Lines • Show All 102 Lines • ▼ Show 20 Line(s) | 102 | if (length >= m_map.m_innerRadius) { //not hovering over inner circle | |||
---|---|---|---|---|---|
103 | uint depth = ((int)length - m_map.m_innerRadius) / m_map.m_ringBreadth; | 103 | uint depth = ((int)length - m_map.m_innerRadius) / m_map.m_ringBreadth; | ||
104 | 104 | | |||
105 | if (depth <= m_map.m_visibleDepth) { //**** do earlier since you can //** check not outside of range | 105 | if (depth <= m_map.m_visibleDepth) { //**** do earlier since you can //** check not outside of range | ||
106 | //vector calculation, reduces to simple trigonometry | 106 | //vector calculation, reduces to simple trigonometry | ||
107 | //cos angle = (aibi + ajbj) / albl | 107 | //cos angle = (aibi + ajbj) / albl | ||
108 | //ai = x, bi=1, aj=y, bj=0 | 108 | //ai = x, bi=1, aj=y, bj=0 | ||
109 | //cos angle = x / (length) | 109 | //cos angle = x / (length) | ||
110 | 110 | | |||
111 | uint a = (uint)(acos((double)e.x() / length) * 916.736); //916.7324722 = #radians in circle * 16 | 111 | auto a = (uint)(acos((double)e.x() / length) * 916.736); //916.7324722 = #radians in circle * 16 | ||
112 | 112 | | |||
113 | //acos only understands 0-180 degrees | 113 | //acos only understands 0-180 degrees | ||
114 | if (e.y() < 0) a = 5760 - a; | 114 | if (e.y() < 0) a = 5760 - a; | ||
115 | 115 | | |||
116 | #define ring (m_map.m_signature + depth) | 116 | #define ring (m_map.m_signature + depth) | ||
117 | for (ConstIterator<Segment> it = ring->constIterator(); it != ring->end(); ++it) | 117 | for (ConstIterator<Segment> it = ring->constIterator(); it != ring->end(); ++it) | ||
118 | if ((*it)->intersects(a)) | 118 | if ((*it)->intersects(a)) | ||
119 | return *it; | 119 | return *it; | ||
120 | #undef ring | 120 | #undef ring | ||
121 | } | 121 | } | ||
122 | } else return m_rootSegment; //hovering over inner circle | 122 | } else return m_rootSegment; //hovering over inner circle | ||
123 | } | 123 | } | ||
124 | 124 | | |||
125 | return 0; | 125 | return nullptr; | ||
126 | } | 126 | } | ||
127 | 127 | | |||
128 | void | 128 | void | ||
129 | RadialMap::Widget::mouseMoveEvent(QMouseEvent *e) | 129 | RadialMap::Widget::mouseMoveEvent(QMouseEvent *e) | ||
130 | { | 130 | { | ||
131 | //set m_focus to what we hover over, update UI if it's a new segment | 131 | //set m_focus to what we hover over, update UI if it's a new segment | ||
132 | 132 | | |||
133 | Segment const * const oldFocus = m_focus; | 133 | Segment const * const oldFocus = m_focus; | ||
Show All 31 Lines | 161 | { | |||
165 | if (m_focus && !m_focus->isFake()) { | 165 | if (m_focus && !m_focus->isFake()) { | ||
166 | const QUrl url = Widget::url(m_focus->file()); | 166 | const QUrl url = Widget::url(m_focus->file()); | ||
167 | const bool isDir = m_focus->file()->isDir(); | 167 | const bool isDir = m_focus->file()->isDir(); | ||
168 | 168 | | |||
169 | if (e->button() == Qt::RightButton) { | 169 | if (e->button() == Qt::RightButton) { | ||
170 | QMenu popup; | 170 | QMenu popup; | ||
171 | popup.setTitle(m_focus->file()->fullPath(m_tree)); | 171 | popup.setTitle(m_focus->file()->fullPath(m_tree)); | ||
172 | 172 | | |||
173 | QAction * actKonq = 0, * actKonsole = 0, *actViewMag = 0, * actFileOpen = 0, * actEditDel = 0; | 173 | QAction * actKonq = nullptr, * actKonsole = nullptr, *actViewMag = nullptr, * actFileOpen = nullptr, * actEditDel = nullptr; | ||
174 | 174 | | |||
175 | if (isDir) { | 175 | if (isDir) { | ||
176 | actKonq = popup.addAction(Icon("system-file-manager"), i18n("Open File Manager Here")); | 176 | actKonq = popup.addAction(Icon("system-file-manager"), i18n("Open File Manager Here")); | ||
177 | if (url.scheme() == "file") | 177 | if (url.scheme() == "file") | ||
178 | actKonsole = popup.addAction(Icon("utilities-terminal"), i18n("Open Terminal Here")); | 178 | actKonsole = popup.addAction(Icon("utilities-terminal"), i18n("Open Terminal Here")); | ||
179 | 179 | | |||
180 | if (m_focus->file() != m_tree) { | 180 | if (m_focus->file() != m_tree) { | ||
181 | popup.addSeparator(); | 181 | popup.addSeparator(); | ||
182 | actViewMag = popup.addAction(Icon("zoom-original"), i18n("&Center Map Here")); | 182 | actViewMag = popup.addAction(Icon("zoom-original"), i18n("&Center Map Here")); | ||
183 | } | 183 | } | ||
184 | } else | 184 | } else | ||
185 | actFileOpen = popup.addAction(Icon("document-open"), i18n("&Open")); | 185 | actFileOpen = popup.addAction(Icon("document-open"), i18n("&Open")); | ||
186 | 186 | | |||
187 | popup.addSeparator(); | 187 | popup.addSeparator(); | ||
188 | actEditDel = popup.addAction(Icon("edit-delete"), i18n("&Delete")); | 188 | actEditDel = popup.addAction(Icon("edit-delete"), i18n("&Delete")); | ||
189 | 189 | | |||
190 | QAction * result = popup.exec(e->globalPos()); | 190 | QAction * result = popup.exec(e->globalPos()); | ||
191 | if (result == 0) | 191 | if (result == nullptr) | ||
192 | result = (QAction *) - 1; // sanity | 192 | result = (QAction *) - 1; // sanity | ||
193 | 193 | | |||
194 | if (result == actKonq) | 194 | if (result == actKonq) | ||
195 | //KRun::runCommand will show an error message if there was trouble | 195 | //KRun::runCommand will show an error message if there was trouble | ||
196 | KRun::runCommand(QString("kfmclient openURL '%1'").arg(url.url()), this); | 196 | KRun::runCommand(QString("kfmclient openURL '%1'").arg(url.url()), this); | ||
197 | else if (result == actKonsole) | 197 | else if (result == actKonsole) | ||
198 | KRun::runCommand(QString("konsole --workdir '%1'").arg(url.url()), this); | 198 | KRun::runCommand(QString("konsole --workdir '%1'").arg(url.url()), this); | ||
199 | else if (result == actViewMag || result == actFileOpen) | 199 | else if (result == actViewMag || result == actFileOpen) | ||
200 | goto sectionTwo; | 200 | goto sectionTwo; | ||
201 | else if (result == actEditDel) { | 201 | else if (result == actEditDel) { | ||
202 | const QUrl url = Widget::url(m_focus->file()); | 202 | const QUrl url = Widget::url(m_focus->file()); | ||
203 | const QString message = (m_focus->file()->isDir() | 203 | const QString message = (m_focus->file()->isDir() | ||
204 | ? i18n("<qt>The folder at <i>'%1'</i> will be <b>recursively</b> and <b>permanently</b> deleted.</qt>", url.toDisplayString()) | 204 | ? i18n("<qt>The folder at <i>'%1'</i> will be <b>recursively</b> and <b>permanently</b> deleted.</qt>", url.toDisplayString()) | ||
205 | : i18n("<qt><i>'%1'</i> will be <b>permanently</b> deleted.</qt>", url.toDisplayString())); | 205 | : i18n("<qt><i>'%1'</i> will be <b>permanently</b> deleted.</qt>", url.toDisplayString())); | ||
206 | const int userIntention = KMessageBox::warningContinueCancel(this, message, QString(), KStandardGuiItem::del()); | 206 | const int userIntention = KMessageBox::warningContinueCancel(this, message, QString(), KStandardGuiItem::del()); | ||
207 | 207 | | |||
208 | if (userIntention == KMessageBox::Continue) { | 208 | if (userIntention == KMessageBox::Continue) { | ||
209 | KIO::Job *job = KIO::del(url); | 209 | KIO::Job *job = KIO::del(url); | ||
210 | KIO::JobUiDelegate *ui = static_cast<KIO::JobUiDelegate*>(job->uiDelegate()); | 210 | auto *ui = dynamic_cast<KIO::JobUiDelegate*>(job->uiDelegate()); | ||
211 | ui->setWindow(this); | 211 | ui->setWindow(this); | ||
212 | connect(job, SIGNAL(result(KJob*)), SLOT(deleteJobFinished(KJob*))); | 212 | connect(job, SIGNAL(result(KJob*)), SLOT(deleteJobFinished(KJob*))); | ||
213 | QApplication::setOverrideCursor(Qt::BusyCursor); | 213 | QApplication::setOverrideCursor(Qt::BusyCursor); | ||
214 | } | 214 | } | ||
215 | } else | 215 | } else | ||
216 | //ensure m_focus is set for new mouse position | 216 | //ensure m_focus is set for new mouse position | ||
217 | sendFakeMouseEvent(); | 217 | sendFakeMouseEvent(); | ||
218 | 218 | | |||
Show All 34 Lines |