Changeset View
Changeset View
Standalone View
Standalone View
src/panels/places/placespanel.cpp
Show First 20 Lines • Show All 163 Lines • ▼ Show 20 Line(s) | 160 | { | |||
---|---|---|---|---|---|
164 | } | 164 | } | ||
165 | 165 | | |||
166 | QMenu menu(this); | 166 | QMenu menu(this); | ||
167 | 167 | | |||
168 | QAction* emptyTrashAction = nullptr; | 168 | QAction* emptyTrashAction = nullptr; | ||
169 | QAction* editAction = nullptr; | 169 | QAction* editAction = nullptr; | ||
170 | QAction* teardownAction = nullptr; | 170 | QAction* teardownAction = nullptr; | ||
171 | QAction* ejectAction = nullptr; | 171 | QAction* ejectAction = nullptr; | ||
172 | QAction* mountAction = nullptr; | ||||
172 | 173 | | |||
173 | const bool isDevice = !item->udi().isEmpty(); | 174 | const bool isDevice = !item->udi().isEmpty(); | ||
174 | const bool isTrash = (item->url().scheme() == QLatin1String("trash")); | 175 | const bool isTrash = (item->url().scheme() == QLatin1String("trash")); | ||
175 | if (isDevice) { | 176 | if (isDevice) { | ||
176 | ejectAction = m_model->ejectAction(index); | 177 | ejectAction = m_model->ejectAction(index); | ||
177 | if (ejectAction) { | 178 | if (ejectAction) { | ||
178 | ejectAction->setParent(&menu); | 179 | ejectAction->setParent(&menu); | ||
179 | menu.addAction(ejectAction); | 180 | menu.addAction(ejectAction); | ||
180 | } | 181 | } | ||
181 | 182 | | |||
182 | teardownAction = m_model->teardownAction(index); | 183 | teardownAction = m_model->teardownAction(index); | ||
183 | if (teardownAction) { | 184 | if (teardownAction) { | ||
184 | teardownAction->setParent(&menu); | 185 | teardownAction->setParent(&menu); | ||
185 | menu.addAction(teardownAction); | 186 | menu.addAction(teardownAction); | ||
186 | } | 187 | } | ||
187 | 188 | | |||
188 | if (teardownAction || ejectAction) { | 189 | if (item->storageSetupNeeded()) { | ||
190 | mountAction = menu.addAction(QIcon::fromTheme(QStringLiteral("media-mount")), i18nc("@action:inmenu", "Mount")); | ||||
191 | } | ||||
192 | | ||||
193 | if (teardownAction || ejectAction || mountAction) { | ||||
189 | menu.addSeparator(); | 194 | menu.addSeparator(); | ||
190 | } | 195 | } | ||
191 | } else { | 196 | } else { | ||
192 | if (isTrash) { | 197 | if (isTrash) { | ||
193 | emptyTrashAction = menu.addAction(QIcon::fromTheme(QStringLiteral("trash-empty")), i18nc("@action:inmenu", "Empty Trash")); | 198 | emptyTrashAction = menu.addAction(QIcon::fromTheme(QStringLiteral("trash-empty")), i18nc("@action:inmenu", "Empty Trash")); | ||
194 | emptyTrashAction->setEnabled(item->icon() == QLatin1String("user-trash-full")); | 199 | emptyTrashAction->setEnabled(item->icon() == QLatin1String("user-trash-full")); | ||
195 | menu.addSeparator(); | 200 | menu.addSeparator(); | ||
196 | } | 201 | } | ||
▲ Show 20 Lines • Show All 41 Lines • ▼ Show 20 Line(s) | 229 | } else { | |||
238 | } else if (action == hideAction) { | 243 | } else if (action == hideAction) { | ||
239 | item->setHidden(hideAction->isChecked()); | 244 | item->setHidden(hideAction->isChecked()); | ||
240 | } else if (action == openInNewWindowAction) { | 245 | } else if (action == openInNewWindowAction) { | ||
241 | Dolphin::openNewWindow({KFilePlacesModel::convertedUrl(m_model->data(index).value("url").toUrl())}, this); | 246 | Dolphin::openNewWindow({KFilePlacesModel::convertedUrl(m_model->data(index).value("url").toUrl())}, this); | ||
242 | } else if (action == openInNewTabAction) { | 247 | } else if (action == openInNewTabAction) { | ||
243 | // TriggerItem does set up the storage first and then it will | 248 | // TriggerItem does set up the storage first and then it will | ||
244 | // emit the slotItemMiddleClicked signal, because of Qt::MiddleButton. | 249 | // emit the slotItemMiddleClicked signal, because of Qt::MiddleButton. | ||
245 | triggerItem(index, Qt::MiddleButton); | 250 | triggerItem(index, Qt::MiddleButton); | ||
251 | } else if (action == mountAction) { | ||||
252 | m_model->requestStorageSetup(index); | ||||
246 | } else if (action == teardownAction) { | 253 | } else if (action == teardownAction) { | ||
247 | m_model->requestTearDown(index); | 254 | m_model->requestTearDown(index); | ||
248 | } else if (action == ejectAction) { | 255 | } else if (action == ejectAction) { | ||
249 | m_model->requestEject(index); | 256 | m_model->requestEject(index); | ||
250 | } | 257 | } | ||
251 | } | 258 | } | ||
252 | } | 259 | } | ||
253 | 260 | | |||
▲ Show 20 Lines • Show All 263 Lines • Show Last 20 Lines |