Changeset View
Standalone View
app/browsemainpage.cpp
Show First 20 Lines • Show All 46 Lines • ▼ Show 20 Line(s) | |||||
47 | #include <lib/gwenviewconfig.h> | 47 | #include <lib/gwenviewconfig.h> | ||
48 | #include <lib/semanticinfo/abstractsemanticinfobackend.h> | 48 | #include <lib/semanticinfo/abstractsemanticinfobackend.h> | ||
49 | #include <lib/semanticinfo/sorteddirmodel.h> | 49 | #include <lib/semanticinfo/sorteddirmodel.h> | ||
50 | #include <lib/semanticinfo/tagmodel.h> | 50 | #include <lib/semanticinfo/tagmodel.h> | ||
51 | #include <lib/sorting.h> | 51 | #include <lib/sorting.h> | ||
52 | #include <lib/archiveutils.h> | 52 | #include <lib/archiveutils.h> | ||
53 | #include <lib/thumbnailview/previewitemdelegate.h> | 53 | #include <lib/thumbnailview/previewitemdelegate.h> | ||
54 | #include <lib/thumbnailview/thumbnailview.h> | 54 | #include <lib/thumbnailview/thumbnailview.h> | ||
55 | #include <ui_browsemainpage.h> | 55 | #include <ui_browsemainpage.h> | ||
rkflx: We already get that from `lib/gwenviewconfig.h`. | |||||
56 | 56 | | |||
57 | namespace Gwenview | 57 | namespace Gwenview | ||
58 | { | 58 | { | ||
59 | 59 | | |||
60 | inline Sorting::Enum sortingFromSortAction(const QAction* action) | 60 | inline Sorting::Enum sortingFromSortAction(const QAction* action) | ||
61 | { | 61 | { | ||
62 | Q_ASSERT(action); | 62 | Q_ASSERT(action); | ||
63 | return Sorting::Enum(action->data().toInt()); | 63 | return Sorting::Enum(action->data().toInt()); | ||
▲ Show 20 Lines • Show All 146 Lines • ▼ Show 20 Line(s) | 152 | #endif | |||
210 | } | 210 | } | ||
211 | 211 | | |||
212 | void updateUrlNavigatorBackgroundColor() | 212 | void updateUrlNavigatorBackgroundColor() | ||
213 | { | 213 | { | ||
214 | QPalette pal(q->palette()); | 214 | QPalette pal(q->palette()); | ||
215 | pal.setColor(QPalette::Window, pal.color(QPalette::Window).dark(110)); | 215 | pal.setColor(QPalette::Window, pal.color(QPalette::Window).dark(110)); | ||
216 | mUrlNavigatorContainer->setPalette(pal); | 216 | mUrlNavigatorContainer->setPalette(pal); | ||
217 | } | 217 | } | ||
218 | | ||||
219 | void updateContextBarActions() | ||||
220 | { | ||||
221 | PreviewItemDelegate::ContextBarActions actions; | ||||
222 | switch (GwenviewConfig::thumbnailActions()) | ||||
223 | { | ||||
224 | case ThumbnailActions::None: | ||||
225 | actions = PreviewItemDelegate::NoAction; | ||||
226 | break; | ||||
227 | case ThumbnailActions::ShowSelectionButtonOnly: | ||||
228 | actions = PreviewItemDelegate::SelectionAction; | ||||
229 | break; | ||||
230 | case ThumbnailActions::AllButtons: | ||||
231 | default: | ||||
232 | actions = PreviewItemDelegate::SelectionAction | PreviewItemDelegate::RotateAction; | ||||
233 | if (!q->window()->isFullScreen()) { | ||||
234 | actions |= PreviewItemDelegate::FullScreenAction; | ||||
235 | } | ||||
236 | break; | ||||
237 | } | ||||
238 | mDelegate->setContextBarActions(actions); | ||||
239 | } | ||||
218 | }; | 240 | }; | ||
219 | 241 | | |||
220 | BrowseMainPage::BrowseMainPage(QWidget* parent, KActionCollection* actionCollection, GvCore* gvCore) | 242 | BrowseMainPage::BrowseMainPage(QWidget* parent, KActionCollection* actionCollection, GvCore* gvCore) | ||
221 | : QWidget(parent) | 243 | : QWidget(parent) | ||
222 | , d(new BrowseMainPagePrivate) | 244 | , d(new BrowseMainPagePrivate) | ||
223 | { | 245 | { | ||
224 | d->q = this; | 246 | d->q = this; | ||
225 | d->mGvCore = gvCore; | 247 | d->mGvCore = gvCore; | ||
Show All 14 Lines | |||||
240 | BrowseMainPage::~BrowseMainPage() | 262 | BrowseMainPage::~BrowseMainPage() | ||
241 | { | 263 | { | ||
242 | delete d; | 264 | delete d; | ||
243 | } | 265 | } | ||
244 | 266 | | |||
245 | void BrowseMainPage::loadConfig() | 267 | void BrowseMainPage::loadConfig() | ||
246 | { | 268 | { | ||
247 | setPalette(d->mGvCore->palette(GvCore::NormalPalette)); | 269 | setPalette(d->mGvCore->palette(GvCore::NormalPalette)); | ||
248 | d->mThumbnailView->setPalette(d->mGvCore->palette(GvCore::NormalViewPalette)); | 270 | d->mThumbnailView->setPalette(d->mGvCore->palette(GvCore::NormalViewPalette)); | ||
249 | d->mUrlNavigator->setUrlEditable(GwenviewConfig::urlNavigatorIsEditable()); | 271 | d->mUrlNavigator->setUrlEditable(GwenviewConfig::urlNavigatorIsEditable()); | ||
I noticed when saving the config in fullscreen mode, the background colour changed to what it is in non-fullscreen mode (Browse). This fixes that. Should this be done in a different revision/diff though? I couldn't find a bug for it, but maybe I wasn't using the right keywords. huoni: I noticed when saving the config in fullscreen mode, the background colour changed to what it… | |||||
250 | d->mUrlNavigator->setShowFullPath(GwenviewConfig::urlNavigatorShowFullPath()); | 272 | d->mUrlNavigator->setShowFullPath(GwenviewConfig::urlNavigatorShowFullPath()); | ||
251 | 273 | | |||
252 | d->mThumbnailSlider->setValue(GwenviewConfig::thumbnailSize()); | 274 | d->mThumbnailSlider->setValue(GwenviewConfig::thumbnailSize()); | ||
253 | d->mThumbnailSlider->updateToolTip(); | 275 | d->mThumbnailSlider->updateToolTip(); | ||
254 | // If GwenviewConfig::thumbnailSize() returns the current value of | 276 | // If GwenviewConfig::thumbnailSize() returns the current value of | ||
255 | // mThumbnailSlider, it won't emit valueChanged() and the thumbnail view | 277 | // mThumbnailSlider, it won't emit valueChanged() and the thumbnail view | ||
256 | // won't be updated. That's why we do it ourself. | 278 | // won't be updated. That's why we do it ourself. | ||
257 | d->mThumbnailView->setThumbnailAspectRatio(GwenviewConfig::thumbnailAspectRatio()); | 279 | d->mThumbnailView->setThumbnailAspectRatio(GwenviewConfig::thumbnailAspectRatio()); | ||
258 | d->mThumbnailView->setThumbnailWidth(GwenviewConfig::thumbnailSize()); | 280 | d->mThumbnailView->setThumbnailWidth(GwenviewConfig::thumbnailSize()); | ||
259 | 281 | | |||
260 | Q_FOREACH(QAction * action, d->mSortAction->actions()) { | 282 | Q_FOREACH(QAction * action, d->mSortAction->actions()) { | ||
261 | if (sortingFromSortAction(action) == GwenviewConfig::sorting()) { | 283 | if (sortingFromSortAction(action) == GwenviewConfig::sorting()) { | ||
262 | d->mSortAction->setCurrentAction(action); | 284 | d->mSortAction->setCurrentAction(action); | ||
263 | break; | 285 | break; | ||
264 | } | 286 | } | ||
265 | } | 287 | } | ||
288 | | ||||
289 | d->updateContextBarActions(); | ||||
This assumption does not hold, leading to a bug: Configure a shortcut for the config dialog and press it in fullscreen mode. Now you've got 4 buttons instead of three. In general it's better to dynamically determine what mode Gwenview is in. After you rebase your patch on master where we worked on this topic over the last days, a fix should be easy (look at 140393d08972 for inspiration on how to read the fullscreen state). rkflx: > `// Can't change config when in fullscreen, so always pass fullScreen=false`
This assumption… | |||||
266 | } | 290 | } | ||
267 | 291 | | |||
268 | void BrowseMainPage::saveConfig() const | 292 | void BrowseMainPage::saveConfig() const | ||
269 | { | 293 | { | ||
270 | GwenviewConfig::setUrlNavigatorIsEditable(d->mUrlNavigator->isUrlEditable()); | 294 | GwenviewConfig::setUrlNavigatorIsEditable(d->mUrlNavigator->isUrlEditable()); | ||
271 | GwenviewConfig::setUrlNavigatorShowFullPath(d->mUrlNavigator->showFullPath()); | 295 | GwenviewConfig::setUrlNavigatorShowFullPath(d->mUrlNavigator->showFullPath()); | ||
272 | GwenviewConfig::setThumbnailSize(d->mThumbnailSlider->value()); | 296 | GwenviewConfig::setThumbnailSize(d->mThumbnailSlider->value()); | ||
273 | GwenviewConfig::setSorting(sortingFromSortAction(d->mSortAction->currentAction())); | 297 | GwenviewConfig::setSorting(sortingFromSortAction(d->mSortAction->currentAction())); | ||
274 | GwenviewConfig::setThumbnailDetails(d->mDelegate->thumbnailDetails()); | 298 | GwenviewConfig::setThumbnailDetails(d->mDelegate->thumbnailDetails()); | ||
275 | } | 299 | } | ||
276 | 300 | | |||
277 | bool BrowseMainPage::eventFilter(QObject* watched, QEvent* event) | 301 | bool BrowseMainPage::eventFilter(QObject* watched, QEvent* event) | ||
278 | { | 302 | { | ||
279 | if (window()->isFullScreen() && event->type() == QEvent::ShortcutOverride) { | 303 | if (window()->isFullScreen() && event->type() == QEvent::ShortcutOverride) { | ||
I'm not sure this code block sits in the right place, which might be the reason why it does not work in Fullscreen. I wonder where the hover actions for Browse are normally assembled, because there must be some code which adapts it dynamically to the zoom level, i.e. for small thumbnails fewer buttons are shown anyway. rkflx: I'm not sure this code block sits in the right place, which might be the reason why it does not… | |||||
280 | const QKeyEvent* keyEvent = static_cast<QKeyEvent*>(event); | 304 | const QKeyEvent* keyEvent = static_cast<QKeyEvent*>(event); | ||
281 | if (keyEvent->key() == Qt::Key_Escape) { | 305 | if (keyEvent->key() == Qt::Key_Escape) { | ||
282 | d->mActionCollection->action("leave_fullscreen")->trigger(); | 306 | d->mActionCollection->action("leave_fullscreen")->trigger(); | ||
283 | event->accept(); | 307 | event->accept(); | ||
284 | } | 308 | } | ||
285 | } | 309 | } | ||
286 | 310 | | |||
287 | return QWidget::eventFilter(watched, event); | 311 | return QWidget::eventFilter(watched, event); | ||
▲ Show 20 Lines • Show All 81 Lines • ▼ Show 20 Line(s) | |||||
369 | void BrowseMainPage::setFullScreenMode(bool fullScreen) | 393 | void BrowseMainPage::setFullScreenMode(bool fullScreen) | ||
370 | { | 394 | { | ||
371 | setPalette(d->mGvCore->palette(fullScreen ? GvCore::FullScreenPalette : GvCore::NormalPalette)); | 395 | setPalette(d->mGvCore->palette(fullScreen ? GvCore::FullScreenPalette : GvCore::NormalPalette)); | ||
372 | d->mThumbnailView->setPalette(d->mGvCore->palette(fullScreen ? GvCore::FullScreenViewPalette : GvCore::NormalViewPalette)); | 396 | d->mThumbnailView->setPalette(d->mGvCore->palette(fullScreen ? GvCore::FullScreenViewPalette : GvCore::NormalViewPalette)); | ||
373 | d->updateUrlNavigatorBackgroundColor(); | 397 | d->updateUrlNavigatorBackgroundColor(); | ||
374 | d->mUrlNavigatorContainer->setContentsMargins( | 398 | d->mUrlNavigatorContainer->setContentsMargins( | ||
375 | fullScreen ? 6 : 0, | 399 | fullScreen ? 6 : 0, | ||
376 | 0, 0, 0); | 400 | 0, 0, 0); | ||
377 | PreviewItemDelegate::ContextBarActions actions = PreviewItemDelegate::SelectionAction | PreviewItemDelegate::RotateAction; | 401 | d->updateContextBarActions(); | ||
378 | if (!fullScreen) { | | |||
379 | actions |= PreviewItemDelegate::FullScreenAction; | | |||
380 | } | | |||
381 | d->mDelegate->setContextBarActions(actions); | | |||
382 | 402 | | |||
383 | d->mFullScreenToolBar->setVisible(fullScreen); | 403 | d->mFullScreenToolBar->setVisible(fullScreen); | ||
384 | d->mFullScreenToolBar2->setVisible(fullScreen); | 404 | d->mFullScreenToolBar2->setVisible(fullScreen); | ||
385 | if (fullScreen && d->mFullScreenToolBar->actions().isEmpty()) { | 405 | if (fullScreen && d->mFullScreenToolBar->actions().isEmpty()) { | ||
386 | d->setupFullScreenToolBar(); | 406 | d->setupFullScreenToolBar(); | ||
387 | } | 407 | } | ||
388 | } | 408 | } | ||
389 | 409 | | |||
Show All 30 Lines |
We already get that from lib/gwenviewconfig.h.