File indexing completed on 2024-05-05 04:19:16
0001 // vim: set tabstop=4 shiftwidth=4 expandtab: 0002 /* 0003 Gwenview: an image viewer 0004 Copyright 2008 Aurélien Gâteau <agateau@kde.org> 0005 0006 This program is free software; you can redistribute it and/or 0007 modify it under the terms of the GNU General Public License 0008 as published by the Free Software Foundation; either version 2 0009 of the License, or (at your option) any later version. 0010 0011 This program is distributed in the hope that it will be useful, 0012 but WITHOUT ANY WARRANTY; without even the implied warranty of 0013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0014 GNU General Public License for more details. 0015 0016 You should have received a copy of the GNU General Public License 0017 along with this program; if not, write to the Free Software 0018 Foundation, Inc., 51 Franklin Street, Fifth Floor, Cambridge, MA 02110-1301, USA. 0019 0020 */ 0021 // Self 0022 #include "fullscreencontent.h" 0023 0024 // Qt 0025 #include <QAction> 0026 #include <QApplication> 0027 #include <QCheckBox> 0028 #include <QEvent> 0029 #include <QLabel> 0030 #include <QMenu> 0031 #include <QTimer> 0032 #include <QToolButton> 0033 #include <QWidgetAction> 0034 0035 // KF 0036 #include <KActionCollection> 0037 #include <KActionMenu> 0038 #include <KIconLoader> 0039 #include <KLocalizedString> 0040 0041 // Local 0042 #include "gwenview_app_debug.h" 0043 #include <gvcore.h> 0044 #include <lib/document/documentfactory.h> 0045 #include <lib/eventwatcher.h> 0046 #include <lib/fullscreenbar.h> 0047 #include <lib/gwenviewconfig.h> 0048 #include <lib/imagemetainfomodel.h> 0049 #include <lib/shadowfilter.h> 0050 #include <lib/slideshow.h> 0051 #include <lib/stylesheetutils.h> 0052 #include <lib/thumbnailview/thumbnailbarview.h> 0053 0054 namespace Gwenview 0055 { 0056 /** 0057 * A widget which behaves more or less like a QToolBar, but which uses real 0058 * widgets for the toolbar items. We need a real widget to be able to position 0059 * the option menu. 0060 */ 0061 class FullScreenToolBar : public QWidget 0062 { 0063 public: 0064 explicit FullScreenToolBar(QWidget *parent = nullptr) 0065 : QWidget(parent) 0066 , mLayout(new QHBoxLayout(this)) 0067 { 0068 setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); 0069 mLayout->setSpacing(0); 0070 mLayout->setContentsMargins(0, 0, 0, 0); 0071 } 0072 0073 void addAction(QAction *action, Qt::ToolButtonStyle style = Qt::ToolButtonIconOnly) 0074 { 0075 auto button = new QToolButton; 0076 button->setDefaultAction(action); 0077 button->setToolButtonStyle(style); 0078 button->setAutoRaise(true); 0079 const int extent = KIconLoader::SizeMedium; 0080 button->setIconSize(QSize(extent, extent)); 0081 mLayout->addWidget(button); 0082 } 0083 0084 void addSeparator() 0085 { 0086 mLayout->addSpacing(QApplication::style()->pixelMetric(QStyle::PM_LayoutVerticalSpacing)); 0087 } 0088 0089 void addStretch() 0090 { 0091 mLayout->addStretch(); 0092 } 0093 0094 void setDirection(QBoxLayout::Direction direction) 0095 { 0096 mLayout->setDirection(direction); 0097 } 0098 0099 private: 0100 QBoxLayout *const mLayout; 0101 }; 0102 0103 FullScreenContent::FullScreenContent(QObject *parent, GvCore *gvCore) 0104 : QObject(parent) 0105 { 0106 mGvCore = gvCore; 0107 mViewPageVisible = false; 0108 } 0109 0110 void FullScreenContent::init(KActionCollection *actionCollection, QWidget *autoHideParentWidget, SlideShow *slideShow) 0111 { 0112 mSlideShow = slideShow; 0113 mActionCollection = actionCollection; 0114 connect(actionCollection->action(QStringLiteral("view")), &QAction::toggled, this, &FullScreenContent::slotViewModeActionToggled); 0115 0116 // mAutoHideContainer 0117 mAutoHideContainer = new FullScreenBar(autoHideParentWidget); 0118 mAutoHideContainer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); 0119 auto layout = new QVBoxLayout(mAutoHideContainer); 0120 layout->setContentsMargins(0, 0, 0, 0); 0121 layout->setSpacing(0); 0122 0123 EventWatcher::install(autoHideParentWidget, QEvent::Resize, this, SLOT(adjustSize())); 0124 0125 // mContent 0126 mContent = new QWidget; 0127 mContent->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); 0128 mContent->setAutoFillBackground(true); 0129 EventWatcher::install(mContent, QEvent::Show, this, SLOT(updateCurrentUrlWidgets())); 0130 layout->addWidget(mContent); 0131 0132 createOptionsAction(); 0133 0134 // mToolBar 0135 mToolBar = new FullScreenToolBar(mContent); 0136 0137 #define addAction(name) mToolBar->addAction(actionCollection->action(name)) 0138 addAction(QStringLiteral("toggle_sidebar")); 0139 mToolBar->addSeparator(); 0140 addAction(QStringLiteral("browse")); 0141 addAction(QStringLiteral("view")); 0142 mToolBar->addSeparator(); 0143 addAction(QStringLiteral("go_previous")); 0144 addAction(QStringLiteral("toggle_slideshow")); 0145 addAction(QStringLiteral("go_next")); 0146 mToolBar->addSeparator(); 0147 addAction(QStringLiteral("rotate_left")); 0148 addAction(QStringLiteral("rotate_right")); 0149 #undef addAction 0150 mToolBarShadow = new ShadowFilter(mToolBar); 0151 0152 // mInformationLabel 0153 mInformationLabel = new QLabel; 0154 mInformationLabel->setWordWrap(true); 0155 mInformationLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); 0156 0157 // mDocumentCountLabel 0158 mDocumentCountLabel = new QLabel; 0159 0160 mInformationContainer = new QWidget; 0161 const int infoContainerTopMargin = 6; 0162 const int infoContainerBottomMargin = 2; 0163 mInformationContainer->setContentsMargins(6, infoContainerTopMargin, 6, infoContainerBottomMargin); 0164 mInformationContainer->setAutoFillBackground(true); 0165 mInformationContainer->setBackgroundRole(QPalette::Mid); 0166 mInformationContainerShadow = new ShadowFilter(mInformationContainer); 0167 auto hLayout = new QHBoxLayout(mInformationContainer); 0168 hLayout->setContentsMargins(0, 0, 0, 0); 0169 hLayout->addWidget(mInformationLabel); 0170 hLayout->addWidget(mDocumentCountLabel); 0171 0172 // Thumbnail bar 0173 mThumbnailBar = new ThumbnailBarView(mContent); 0174 mThumbnailBar->setThumbnailScaleMode(ThumbnailView::ScaleToSquare); 0175 auto delegate = new ThumbnailBarItemDelegate(mThumbnailBar); 0176 mThumbnailBar->setItemDelegate(delegate); 0177 mThumbnailBar->setSelectionMode(QAbstractItemView::ExtendedSelection); 0178 // Calculate minimum bar height to give mInformationLabel exactly two lines height 0179 const int lineHeight = mInformationLabel->fontMetrics().lineSpacing(); 0180 mMinimumThumbnailBarHeight = mToolBar->sizeHint().height() + lineHeight * 2 + infoContainerTopMargin + infoContainerBottomMargin; 0181 0182 // Ensure document count is updated when items added/removed from folder 0183 connect(mThumbnailBar, &ThumbnailBarView::rowsInsertedSignal, this, &FullScreenContent::updateDocumentCountLabel); 0184 connect(mThumbnailBar, &ThumbnailBarView::rowsRemovedSignal, this, &FullScreenContent::updateDocumentCountLabel); 0185 connect(mThumbnailBar, &ThumbnailBarView::indexActivated, this, &FullScreenContent::updateDocumentCountLabel); 0186 0187 // Right bar 0188 mRightToolBar = new FullScreenToolBar(mContent); 0189 mRightToolBar->addAction(mActionCollection->action(QStringLiteral("leave_fullscreen")), Qt::ToolButtonFollowStyle); 0190 mRightToolBar->addAction(mOptionsAction, Qt::ToolButtonFollowStyle); 0191 mRightToolBar->addStretch(); 0192 mRightToolBar->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding); 0193 mRightToolBarShadow = new ShadowFilter(mRightToolBar); 0194 0195 updateLayout(); 0196 0197 updateContainerAppearance(); 0198 } 0199 0200 ThumbnailBarView *FullScreenContent::thumbnailBar() const 0201 { 0202 return mThumbnailBar; 0203 } 0204 0205 void FullScreenContent::setCurrentUrl(const QUrl &url) 0206 { 0207 if (url.isEmpty()) { 0208 mCurrentDocument = Document::Ptr(); 0209 } else { 0210 mCurrentDocument = DocumentFactory::instance()->load(url); 0211 connect(mCurrentDocument.data(), &Document::metaInfoUpdated, this, &FullScreenContent::updateCurrentUrlWidgets); 0212 } 0213 updateCurrentUrlWidgets(); 0214 0215 // Give the thumbnail view time to update its "current index" 0216 QTimer::singleShot(0, this, &FullScreenContent::updateDocumentCountLabel); 0217 } 0218 0219 void FullScreenContent::updateInformationLabel() 0220 { 0221 if (!mCurrentDocument) { 0222 return; 0223 } 0224 0225 if (!mInformationLabel->isVisible()) { 0226 return; 0227 } 0228 0229 ImageMetaInfoModel *model = mCurrentDocument->metaInfo(); 0230 0231 QStringList valueList; 0232 const QStringList fullScreenPreferredMetaInfoKeyList = GwenviewConfig::fullScreenPreferredMetaInfoKeyList(); 0233 for (const QString &key : fullScreenPreferredMetaInfoKeyList) { 0234 const QString value = model->getValueForKey(key); 0235 if (!value.isEmpty()) { 0236 valueList << value; 0237 } 0238 } 0239 const QString text = valueList.join(i18nc("@item:intext fullscreen meta info separator", ", ")); 0240 0241 mInformationLabel->setText(text); 0242 } 0243 0244 void FullScreenContent::updateCurrentUrlWidgets() 0245 { 0246 updateInformationLabel(); 0247 updateMetaInfoDialog(); 0248 } 0249 0250 void FullScreenContent::showImageMetaInfoDialog() 0251 { 0252 if (!mImageMetaInfoDialog) { 0253 mImageMetaInfoDialog = new ImageMetaInfoDialog(mInformationLabel); 0254 // Do not let the fullscreen theme propagate to this dialog for now, 0255 // it's already quite complicated to create a theme 0256 mImageMetaInfoDialog->setStyle(QApplication::style()); 0257 mImageMetaInfoDialog->setAttribute(Qt::WA_DeleteOnClose, true); 0258 connect(mImageMetaInfoDialog.data(), 0259 &ImageMetaInfoDialog::preferredMetaInfoKeyListChanged, 0260 this, 0261 &FullScreenContent::slotPreferredMetaInfoKeyListChanged); 0262 connect(mImageMetaInfoDialog.data(), &QObject::destroyed, this, &FullScreenContent::slotImageMetaInfoDialogClosed); 0263 } 0264 if (mCurrentDocument) { 0265 mImageMetaInfoDialog->setMetaInfo(mCurrentDocument->metaInfo(), GwenviewConfig::fullScreenPreferredMetaInfoKeyList()); 0266 } 0267 mAutoHideContainer->setAutoHidingEnabled(false); 0268 mImageMetaInfoDialog->show(); 0269 } 0270 0271 void FullScreenContent::slotPreferredMetaInfoKeyListChanged(const QStringList &list) 0272 { 0273 GwenviewConfig::setFullScreenPreferredMetaInfoKeyList(list); 0274 GwenviewConfig::self()->save(); 0275 updateInformationLabel(); 0276 } 0277 0278 void FullScreenContent::updateMetaInfoDialog() 0279 { 0280 if (!mImageMetaInfoDialog) { 0281 return; 0282 } 0283 ImageMetaInfoModel *model = mCurrentDocument ? mCurrentDocument->metaInfo() : nullptr; 0284 mImageMetaInfoDialog->setMetaInfo(model, GwenviewConfig::fullScreenPreferredMetaInfoKeyList()); 0285 } 0286 0287 static QString formatSlideShowIntervalText(int value) 0288 { 0289 return i18ncp("Slideshow interval in seconds", "%1 sec", "%1 secs", value); 0290 } 0291 0292 void FullScreenContent::updateLayout() 0293 { 0294 delete mContent->layout(); 0295 0296 if (GwenviewConfig::showFullScreenThumbnails()) { 0297 mRightToolBar->setDirection(QBoxLayout::TopToBottom); 0298 0299 auto layout = new QHBoxLayout(mContent); 0300 layout->setContentsMargins(0, 0, 0, 0); 0301 layout->setSpacing(0); 0302 QVBoxLayout *vLayout; 0303 0304 // First column 0305 vLayout = new QVBoxLayout; 0306 vLayout->addWidget(mToolBar); 0307 vLayout->addWidget(mInformationContainer); 0308 layout->addLayout(vLayout); 0309 // Second column 0310 layout->addSpacing(2); 0311 layout->addWidget(mThumbnailBar); 0312 layout->addSpacing(2); 0313 // Third column 0314 vLayout = new QVBoxLayout; 0315 vLayout->addWidget(mRightToolBar); 0316 layout->addLayout(vLayout); 0317 0318 mInformationContainer->setMaximumWidth(mToolBar->sizeHint().width()); 0319 const int barHeight = qMax(GwenviewConfig::fullScreenBarHeight(), mMinimumThumbnailBarHeight); 0320 mThumbnailBar->setFixedHeight(barHeight); 0321 mAutoHideContainer->setFixedHeight(barHeight); 0322 0323 mInformationLabel->setAlignment(Qt::AlignTop); 0324 mDocumentCountLabel->setAlignment(Qt::AlignBottom | Qt::AlignRight); 0325 0326 // Shadows 0327 mToolBarShadow->reset(); 0328 mToolBarShadow->setShadow(ShadowFilter::RightEdge, QColor(0, 0, 0, 64)); 0329 mToolBarShadow->setShadow(ShadowFilter::BottomEdge, QColor(255, 255, 255, 8)); 0330 0331 mInformationContainerShadow->reset(); 0332 mInformationContainerShadow->setShadow(ShadowFilter::LeftEdge, QColor(0, 0, 0, 64)); 0333 mInformationContainerShadow->setShadow(ShadowFilter::TopEdge, QColor(0, 0, 0, 64)); 0334 mInformationContainerShadow->setShadow(ShadowFilter::RightEdge, QColor(0, 0, 0, 128)); 0335 mInformationContainerShadow->setShadow(ShadowFilter::BottomEdge, QColor(255, 255, 255, 8)); 0336 0337 mRightToolBarShadow->reset(); 0338 mRightToolBarShadow->setShadow(ShadowFilter::LeftEdge, QColor(0, 0, 0, 64)); 0339 mRightToolBarShadow->setShadow(ShadowFilter::BottomEdge, QColor(255, 255, 255, 8)); 0340 } else { 0341 mRightToolBar->setDirection(QBoxLayout::RightToLeft); 0342 0343 auto layout = new QHBoxLayout(mContent); 0344 layout->setContentsMargins(0, 0, 0, 0); 0345 layout->setSpacing(0); 0346 layout->addWidget(mToolBar); 0347 layout->addWidget(mInformationContainer); 0348 layout->addWidget(mRightToolBar); 0349 0350 mInformationContainer->setMaximumWidth(QWIDGETSIZE_MAX); 0351 mAutoHideContainer->setFixedHeight(mToolBar->sizeHint().height()); 0352 0353 mInformationLabel->setAlignment(Qt::AlignVCenter); 0354 mDocumentCountLabel->setAlignment(Qt::AlignVCenter | Qt::AlignRight); 0355 0356 // Shadows 0357 mToolBarShadow->reset(); 0358 0359 mInformationContainerShadow->reset(); 0360 mInformationContainerShadow->setShadow(ShadowFilter::LeftEdge, QColor(0, 0, 0, 64)); 0361 mInformationContainerShadow->setShadow(ShadowFilter::RightEdge, QColor(0, 0, 0, 32)); 0362 0363 mRightToolBarShadow->reset(); 0364 mRightToolBarShadow->setShadow(ShadowFilter::LeftEdge, QColor(255, 255, 255, 8)); 0365 } 0366 } 0367 0368 void FullScreenContent::updateContainerAppearance() 0369 { 0370 if (!mContent->window()->isFullScreen() || !mViewPageVisible) { 0371 mAutoHideContainer->setActivated(false); 0372 return; 0373 } 0374 0375 mThumbnailBar->setVisible(GwenviewConfig::showFullScreenThumbnails()); 0376 mAutoHideContainer->adjustSize(); 0377 mAutoHideContainer->setActivated(true); 0378 } 0379 0380 void FullScreenContent::adjustSize() 0381 { 0382 if (mContent->window()->isFullScreen() && mViewPageVisible) { 0383 mAutoHideContainer->adjustSize(); 0384 } 0385 } 0386 0387 void FullScreenContent::createOptionsAction() 0388 { 0389 // We do not use a KActionMenu because: 0390 // 0391 // - It causes the button to show a small down arrow on its right, 0392 // which makes it wider 0393 // 0394 // - We can't control where the menu shows: in no-thumbnail-mode, the 0395 // menu should not be aligned to the right edge of the screen because 0396 // if the mode is changed to thumbnail-mode, we want the option button 0397 // to remain visible 0398 mOptionsAction = new QAction(this); 0399 mOptionsAction->setIcon(QIcon::fromTheme(QStringLiteral("configure"))); 0400 mOptionsAction->setText(i18n("Configure")); 0401 mOptionsAction->setToolTip(i18nc("@info:tooltip", "Configure full screen mode")); 0402 QObject::connect(mOptionsAction, &QAction::triggered, this, &FullScreenContent::showOptionsMenu); 0403 } 0404 0405 void FullScreenContent::updateSlideShowIntervalLabel() 0406 { 0407 Q_ASSERT(mConfigWidget); 0408 const int value = mConfigWidget->mSlideShowIntervalSlider->value(); 0409 const QString text = formatSlideShowIntervalText(value); 0410 mConfigWidget->mSlideShowIntervalLabel->setText(text); 0411 } 0412 0413 void FullScreenContent::setFullScreenBarHeight(int value) 0414 { 0415 mThumbnailBar->setFixedHeight(value); 0416 mAutoHideContainer->setFixedHeight(value); 0417 GwenviewConfig::setFullScreenBarHeight(value); 0418 } 0419 0420 void FullScreenContent::showOptionsMenu() 0421 { 0422 Q_ASSERT(!mConfigWidget); 0423 0424 mConfigWidget = new FullScreenConfigWidget; 0425 FullScreenConfigWidget *widget = mConfigWidget; 0426 0427 // Put widget in a menu 0428 QMenu menu; 0429 auto action = new QWidgetAction(&menu); 0430 action->setDefaultWidget(widget); 0431 menu.addAction(action); 0432 0433 // Slideshow checkboxes 0434 widget->mSlideShowLoopCheckBox->setChecked(mSlideShow->loopAction()->isChecked()); 0435 connect(widget->mSlideShowLoopCheckBox, &QAbstractButton::toggled, mSlideShow->loopAction(), &QAction::trigger); 0436 0437 widget->mSlideShowRandomCheckBox->setChecked(mSlideShow->randomAction()->isChecked()); 0438 connect(widget->mSlideShowRandomCheckBox, &QAbstractButton::toggled, mSlideShow->randomAction(), &QAction::trigger); 0439 0440 // Interval slider 0441 widget->mSlideShowIntervalSlider->setValue(int(GwenviewConfig::interval())); 0442 connect(widget->mSlideShowIntervalSlider, &QAbstractSlider::valueChanged, mSlideShow, &SlideShow::setInterval); 0443 connect(widget->mSlideShowIntervalSlider, &QAbstractSlider::valueChanged, this, &FullScreenContent::updateSlideShowIntervalLabel); 0444 0445 // Interval label 0446 QString text = formatSlideShowIntervalText(88); 0447 int width = widget->mSlideShowIntervalLabel->fontMetrics().boundingRect(text).width(); 0448 widget->mSlideShowIntervalLabel->setFixedWidth(width); 0449 updateSlideShowIntervalLabel(); 0450 0451 // Image information 0452 connect(widget->mConfigureDisplayedInformationButton, &QAbstractButton::clicked, this, &FullScreenContent::showImageMetaInfoDialog); 0453 0454 // Thumbnails 0455 widget->mThumbnailGroupBox->setVisible(mViewPageVisible); 0456 if (mViewPageVisible) { 0457 widget->mShowThumbnailsCheckBox->setChecked(GwenviewConfig::showFullScreenThumbnails()); 0458 widget->mHeightSlider->setMinimum(mMinimumThumbnailBarHeight); 0459 widget->mHeightSlider->setValue(mThumbnailBar->height()); 0460 connect(widget->mShowThumbnailsCheckBox, &QAbstractButton::toggled, this, &FullScreenContent::slotShowThumbnailsToggled); 0461 connect(widget->mHeightSlider, &QAbstractSlider::valueChanged, this, &FullScreenContent::setFullScreenBarHeight); 0462 } 0463 0464 // Show menu below its button 0465 QPoint pos; 0466 QWidget *button = mOptionsAction->associatedWidgets().constFirst(); 0467 Q_ASSERT(button); 0468 qCWarning(GWENVIEW_APP_LOG) << button << button->geometry(); 0469 if (QApplication::isRightToLeft()) { 0470 pos = button->mapToGlobal(button->rect().bottomLeft()); 0471 } else { 0472 pos = button->mapToGlobal(button->rect().bottomRight()); 0473 pos.rx() -= menu.sizeHint().width(); 0474 } 0475 qCWarning(GWENVIEW_APP_LOG) << pos; 0476 menu.exec(pos); 0477 } 0478 0479 void FullScreenContent::setFullScreenMode(bool fullScreenMode) 0480 { 0481 Q_UNUSED(fullScreenMode); 0482 updateContainerAppearance(); 0483 setupThumbnailBarStyleSheet(); 0484 } 0485 0486 void FullScreenContent::setDistractionFreeMode(bool distractionFreeMode) 0487 { 0488 mAutoHideContainer->setEdgeTriggerEnabled(!distractionFreeMode); 0489 } 0490 0491 void FullScreenContent::slotImageMetaInfoDialogClosed() 0492 { 0493 mAutoHideContainer->setAutoHidingEnabled(true); 0494 } 0495 0496 void FullScreenContent::slotShowThumbnailsToggled(bool value) 0497 { 0498 GwenviewConfig::setShowFullScreenThumbnails(value); 0499 GwenviewConfig::self()->save(); 0500 mThumbnailBar->setVisible(value); 0501 updateLayout(); 0502 mContent->adjustSize(); 0503 mAutoHideContainer->adjustSize(); 0504 } 0505 0506 void FullScreenContent::slotViewModeActionToggled(bool value) 0507 { 0508 mViewPageVisible = value; 0509 updateContainerAppearance(); 0510 } 0511 0512 void FullScreenContent::setupThumbnailBarStyleSheet() 0513 { 0514 const QPalette pal = mGvCore->palette(GvCore::NormalPalette); 0515 const QPalette fsPal = mGvCore->palette(GvCore::FullScreenPalette); 0516 QColor bgColor = fsPal.color(QPalette::Normal, QPalette::Base); 0517 QColor bgSelColor = pal.color(QPalette::Normal, QPalette::Highlight); 0518 QColor bgHovColor = pal.color(QPalette::Normal, QPalette::Highlight); 0519 0520 // Darken the select color a little to suit dark theme of fullscreen mode 0521 bgSelColor.setHsv(bgSelColor.hue(), bgSelColor.saturation(), (bgSelColor.value() * 0.8)); 0522 0523 // Calculate hover color based on background color in case it changes (matches ViewMainPage thumbnail bar) 0524 bgHovColor.setHsv(bgHovColor.hue(), (bgHovColor.saturation() / 2), ((bgHovColor.value() + bgColor.value()) / 2)); 0525 0526 QString genCss = 0527 "QListView {" 0528 " background-color: %1;" 0529 "}"; 0530 genCss = genCss.arg(StyleSheetUtils::rgba(bgColor)); 0531 0532 QString itemSelCss = 0533 "QListView::item:selected {" 0534 " background-color: %1;" 0535 "}"; 0536 itemSelCss = itemSelCss.arg(StyleSheetUtils::rgba(bgSelColor)); 0537 0538 QString itemHovCss = 0539 "QListView::item:hover:!selected {" 0540 " background-color: %1;" 0541 "}"; 0542 itemHovCss = itemHovCss.arg(StyleSheetUtils::rgba(bgHovColor)); 0543 0544 QString css = genCss + itemSelCss + itemHovCss; 0545 mThumbnailBar->setStyleSheet(css); 0546 } 0547 0548 void FullScreenContent::updateDocumentCountLabel() 0549 { 0550 const int current = mThumbnailBar->currentIndex().row() + 1; 0551 const int total = mThumbnailBar->model()->rowCount(); 0552 const QString text = i18nc("@info:status %1 current document index, %2 total documents", "%1 of %2", current, total); 0553 mDocumentCountLabel->setText(text); 0554 } 0555 0556 } // namespace 0557 0558 #include "moc_fullscreencontent.cpp"