diff --git a/NEWS b/NEWS index 2c6f358d80..137501e535 100644 --- a/NEWS +++ b/NEWS @@ -1,239 +1,241 @@ digiKam 6.0.0 - Release date: 2018-xx-xx ***************************************************************************************************** NEW FEATURES: ImageEditor : New clone tool to replace old CImg in-painting tool. ImageEditor : Add Web services Import and Export tools. Showfoto : Add Web services Import and Export tools. LightTable : Add Web services Import and Export tools. Database : Similarity database has been moved to a dedicated file to not bloat core database with computed finger-prints. This will speed-up query in core database in case of Similarity feature is used. Database : New video metadata parser based on ffmpeg to populate database. Search : Add video support to find files based on properties registered on database. General : Add QWebEngine support. General : Update internal Libraw to last 0.18.11. General : Fix all Krazy static analyzer reports. Tags : Add possibility to merge tags by drag & drop. HTML Gallery : New Vanilla theme to emulate export to HTML from Adobe LightRoom. HTML Gallery : New Blue Frame theme. HTML Gallery : New Kiosk-Mode theme. ***************************************************************************************************** BUGFIXES: 001 ==> 172650 - No export tools available. 002 ==> 149591 - The export menu is blank. 003 ==> 300424 - Export tools not detected. 004 ==> 327743 - MediaWiki export not displayed. 005 ==> 348146 - Export tools configuration module. 006 ==> 243275 - Crashing when calling configuration. 007 ==> 257134 - Crashes when entering its settings. 008 ==> 230666 - Crash during start. 009 ==> 306698 - Crashes after update to KDE. 010 ==> 207640 - Crashes immediately at startup, sometimes at closing. 011 ==> 245628 - Crash when enabling/disabling Facebook import/export. 012 ==> 097317 - sigsegv [New Thread 1100241184 (LWP 5665)]. 013 ==> 245776 - Crashes when selecting Settings. 014 ==> 245775 - Crashes even without export tools installed. 015 ==> 254283 - Crash as soon as i click settings. 016 ==> 255733 - crash when reopening configuration dialog. 017 ==> 262050 - Crash after new install and scan to mysql database. 018 ==> 263871 - Crashed after searching for duplicates. 019 ==> 268242 - Crashes after I clicked on 'Settings'. 020 ==> 276882 - Add export tool buttons to toolbar. 021 ==> 284801 - Export to picasaweb crashes. 022 ==> 277669 - Crash after files moved. 023 ==> 281250 - Crash after disabling Export tools. 024 ==> 202637 - Crash trying to start export tool. 025 ==> 306693 - after update to KDE host application crashes on startup. 026 ==> 282781 - Crashes when reopening configuration dialog after disabling export tools. 027 ==> 285499 - Crash when settings window opened. 028 ==> 297629 - Crashed when importing from Nikon P7000. 029 ==> 303338 - Crashes when clicking "send to" button. 030 ==> 307619 - Refuses to load Export tools. 031 ==> 311812 - Export tools not loading, SO version not defined. 032 ==> 313186 - Crashes on attempt to use the "Send to" menu. 033 ==> 313356 - Crashed when clicking the "send to" button. 034 ==> 313577 - Crashes when pressing the "send to" button. 035 ==> 313890 - Crash when clicking "Send to...". 036 ==> 315033 - Crashes on pressing Send To... button. 037 ==> 315914 - The facebook tool crashes everytime on initialization. 038 ==> 326556 - Export tools are not loaded when starting host application for second time. 039 ==> 095175 - crash on loading, signal 11 SIGSEGV. 040 ==> 175844 - Crashes at startup loading Export tools. 041 ==> 306511 - Crash during start. 042 ==> 234021 - Crash on loading. 043 ==> 219772 - Opening the application causes crash. 044 ==> 294173 - Crash after Image resize start. 045 ==> 306881 - Crashed when attempting to open Export tools. 046 ==> 306495 - Crash changing settings linux ubuntu lucid. 047 ==> 306497 - Crash after changing settings segmentation fault possible 2nd report? 048 ==> 185470 - "Import from facebook" is listed twice in import menu. 049 ==> 334045 - MediaWiki option not available in Export menu when plugin activated. 050 ==> 142112 - Can't save on my webspace with ShowFoto. 051 ==> 167417 - Showfoto cannot save files of CIFS mount. 052 ==> 125164 - Flickr export tool should respect host application selection. 053 ==> 238927 - Host application quits when uploading to Flickr. 054 ==> 326740 - Selection of tools is set to default after each update. 055 ==> 233063 - Add progress indicator when moving or copy files [patch]. 056 ==> 361829 - Rotated MP4 video with "Orientation" flag are not played back in the correct rotation angle. 057 ==> 329854 - digiKam doesn't rotate video thumbnail. 058 ==> 376661 - When importing ~200,000 video files Digikam crashes in about 2-5 seconds of starting. 059 ==> 377072 - Cannot read video metadata. 060 ==> 374453 - Extract right video date from MP4 files metadata. 061 ==> 377177 - Geolocation / GPS information doesn't appear in video metadata. 062 ==> 383588 - Imported video files have time shifted exactly 2 hours later. 063 ==> 380847 - MP4 video not importing with correct date. 064 ==> 373682 - geolocalisation filter does not take care of the videos geolocalisation tags. 065 ==> 340925 - digiKam crash when start it. 066 ==> 331506 - digiKam crashes on startup. 067 ==> 335816 - Crash when trying to add a big collection. 068 ==> 353295 - digiKam repeatedly crashes while importing pictures. 069 ==> 341433 - Crash when opening digiKam application. 070 ==> 375562 - digiKam crashes while scanning images into sqlite database. 071 ==> 334782 - Crash while doing nothing. 072 ==> 362672 - Crash on start of digiKam. 073 ==> 341023 - Crash after startup during check for updated images. 074 ==> 386891 - Crashed while adding pictures. 075 ==> 342666 - digiKam crashes during find new items. 076 ==> 341274 - digiKam crash on startup. 077 ==> 343708 - Crash when scanning album. 078 ==> 332721 - Crash when reading a certain MP4 video file. 079 ==> 343736 - Crashes when rebuilding thumbnails from database. 080 ==> 346356 - digiKam crashes when adding 90.000 pictures to library. 081 ==> 343714 - digiKam crash when scanning for new items. 082 ==> 341091 - digiKam crashes when updating the MySQL database of a a hudge photo collection. 083 ==> 340879 - digiKam crashes after getting unexpected but reasonable output from libexiv2. 084 ==> 342712 - Crash on collection scanning. 085 ==> 356704 - digiKam still crashes while scanning a new photo directory and subdirs. 086 ==> 339269 - Segfault when opening a folder that contains unknown file types (mov, avi, xcf). 087 ==> 364635 - digiKam crashes on startup. 088 ==> 357356 - digiKam crash on startup while scanning photos. 089 ==> 341554 - digiKam crashed by Data-Import from NFS. 090 ==> 345457 - digiKam crashes at "loading tools". 091 ==> 349635 - Crash of digiKam - moving album. 092 ==> 342604 - digiKam crash. 093 ==> 331450 - Signal 8 on album opening. 094 ==> 342030 - digiKam crashes when checking an AVI video file using exiv2. 095 ==> 352777 - Crash during scan. 096 ==> 352944 - digiKam crashes on start. 097 ==> 343643 - digiKam crashes while perform initial scanning of custom photo folder. 098 ==> 342000 - digiKam crash when opening folder with Videos (Album or SD Card import). 099 ==> 353447 - digiKam crashes when scanning files. 100 ==> 346807 - Crashes on startup. 101 ==> 364639 - digiKam crashed while opening database. 102 ==> 341504 - Crash while using application. 103 ==> 367691 - Searching for pictures crashes at 30% every time. 104 ==> 334604 - Crash after changing disk partions. 105 ==> 351689 - Crash on opening digiKam. 106 ==> 149267 - digiKam crashes after finding avi and so on. 107 ==> 170387 - Add movies management. 108 ==> 369629 - digiKam does not use GPS data from video files. 109 ==> 367880 - Nexus 5X videos show up upside-down in digiKam. 110 ==> 330116 - digiKam does not take care about GPS info stored in MP4 video files. 111 ==> 339150 - digikam crashes when trying to display video file. 112 ==> 344406 - Crash at start. 113 ==> 339909 - digiKam Segmentation Fault on open. 114 ==> 343231 - Crash at scanning for new fotos. 115 ==> 340373 - Crash on scanning video directory. 116 ==> 134679 - Video and audio files are not imported. 117 ==> 375357 - No video preview. 118 ==> 261773 - Batch renaming does not complete when MP4 video file is processed. 119 ==> 185915 - Album View: "Created" time of video set to "00:00". 120 ==> 303218 - digiKam import crashes when you select video files. 121 ==> 374241 - Bad video date rename. 122 ==> 375646 - Be able to scan only photo, not video and audio. 123 ==> 262499 - Cannot rename .AVI files. 124 ==> 199261 - Import avi movies from sdcard wrong date and no thumbnail. 125 ==> 181521 - NEF's in descending order, AVI in ascending order in import from SD-card. 126 ==> 392019 - Two persons can point to the same face tag in pictures. 127 ==> 392013 - Metadata explorer does not show XMP face rectangles. 128 ==> 389508 - Dates Side Menu Is Not Updated Automatically After Exif Date Change [patch]. 129 ==> 331864 - Merge Tags with same name when moving to same hierarchy level. 130 ==> 347302 - Reassign name to face. 131 ==> 391747 - BQM Tool "Remove Metadata" doesn't remove all metadata from image. 132 ==> 285683 - Already imported pictures not recognized after daylight savings time. 133 ==> 392309 - Icons are pixelated when my display scale factor is 1.2 134 ==> 392405 - Function 'getImageIdsFromArea' argument order different. 135 ==> 386224 - Metadata is not updated when moving tags. 136 ==> 370245 - Be able to rename tags which have been setted in pictures. 137 ==> 374470 - Deleted tags are not removed from file metadata. 138 ==> 374516 - Persons metadata are not updated after a tag removed. 139 ==> 392436 - Count Files in directory. 140 ==> 363859 - digiKam core port from QWebKit to QWebEngine [patch]. 141 ==> 392427 - Cannot add collection on network drive. 142 ==> 392022 - Position of a face tag appears on top of bottom of the list, instead of being sorted alphabetically. 143 ==> 372763 - Rename does not give options on Conflict. 144 ==> 391533 - Feature request: add "NOT" tag matching condition in "Filters" panel. 145 ==> 381222 - digiKam crash on fuzzy search. 146 ==> 386275 - Crash caused by QtAV. 147 ==> 372342 - Face tag area is very short [patch]. 148 ==> 391348 - People Side Menu Shows Only Faces Not People Tagged Images. 149 ==> 385630 - Views Requiring Maps Takes ~30s to Launch. 150 ==> 192908 - Allow to split icon-view in order to show multiple albums at the same time. 151 ==> 339088 - GIT master: crash when clicking through images in preview, with face recognition running in background. 152 ==> 341605 - Crash if I attempt to use left-sidebar tags tab. 153 ==> 227266 - Handle Video Date from metadata. 154 ==> 227259 - Needs to Edit Video Date. 155 ==> 373284 - digiKam crashed with SIGSEGV in QSortFilterProxyModel::parent(). 156 ==> 384807 - digikam 5.7.0 AppImage bundle : provide a more recent ffmpeg version for video support. 157 ==> 391835 - Deleted pictures still appear in group. 158 ==> 387483 - Elegant theme: Selected frame colors swapped [patch]. 159 ==> 375424 - Thumbnails are not being removed from AlbumsView after moving the images to Trash. 160 ==> 368796 - Problem with Exif-tags: ImageDescription and UserComment. 161 ==> 392417 - AppImage (5.9.0-01-x86-64) does not support "--install" cli parameter. 162 ==> 392922 - digikam-6.0.0 fail to start. 163 ==> 391399 - Not possible to add location bookmarks in Digikam >5.6.0. 164 ==> 380876 - Tags in Digikam DB maintained after being removed from file and file re-scanned. 165 ==> 392017 - Merging, renaming and removing face tags. 166 ==> 352711 - Externally removed tags are not removed from digiKam. 167 ==> 393108 - Tags not always visible when selecting multiple pictures in a group. 168 ==> 392656 - Selecting a root album for face scan doesn't include subfolders, but rather scans an unexpected album set. 169 ==> 329438 - Rename function with Date & Time does not work with NTFS. 170 ==> 376473 - Can"t set empty IPTC country code when using metadata templates. 171 ==> 380289 - Cannot write to Albums residing on NFS. 172 ==> 384465 - With Compact Flash Card Created date in thumbnails is wrong. 173 ==> 381958 - Cannot add additional collection. 174 ==> 383747 - "Rotate only by setting a flag" Changes Image Instead. 175 ==> 387977 - No icon only view of "Extras sidebar": sidebar taking up a lot of space. 176 ==> 277502 - All versions of version set always displayed in Album view [patch]. 177 ==> 393283 - Caption not updating Exif.Image.ImageDescription field. 178 ==> 391060 - Crashes on undo of very large tif. 179 ==> 366305 - Add a message at startup about the lack of temporary space to perform Undo operations. 180 ==> 366391 - Rotating an image seems to forget to reset the orientation flag. 181 ==> 393654 - Not able to select gpx file. 182 ==> 367596 - Sub-folder count images but don't show them (unsupported JPEG file?). 183 ==> 379922 - Digikam won't remove tags set by Windows Explorer. 184 ==> 379081 - GPS data are in file but geolocation indicator is not shown and map view empty. 185 ==> 354819 - Specific pictures not showing up in digikam. 186 ==> 393855 - MySQL/MariaDB upgrade fails. 187 ==> 384603 - Camera Creation Date not set from EXIF data. 188 ==> 386959 - Properties view: wrong creation date [patch]. 189 ==> 393970 - No mts video thumbnails. 190 ==> 393728 - Reread metadata from Video uses sidecar only. 191 ==> 393925 - UpdateSchemaFromV7ToV9 fails due to duplicate key in album_2. 192 ==> 393773 - showfoto crashes when geotagging. 193 ==> 388199 - No context menu to copy coordinates from map. 194 ==> 393399 - Windows defender freaks out in windows 10 and Edge. 195 ==> 392134 - SIGSEGV While Scanning Faces [patch]. 196 ==> 394168 - OSM Search Yields No Results. 197 ==> 377719 - Cannot rename file with overwrite [patch]. 198 ==> 388002 - remove kio related legacy [patch] 199 ==> 394242 - Import settings unneccesarily asks to overwrite image database, and crashes when I decline. 200 ==> 394278 - A slideshow theme for kiosk mode. 201 ==> 340389 - digiKam crashes while editing pictures for color balancing on OSX [patch]. 202 ==> 394413 - Unify group handling [patch]. 203 ==> 394573 - Revers geodata from open street map does not work. 204 ==> 394590 - Feature request: being able to filter on all metadatas fields. 205 ==> 394671 - Distortion on Panasonic DMC-LX15. 206 ==> 393205 - Advanced rename very slow. 207 ==> 382474 - Thumbnail regeneration. 208 ==> 394865 - digikam suspicious crash on exit. -209 ==> +209 ==> 390541 - Tooltip background cannot be changed. +210 ==> 391521 - "Tool-tip" box difficult to read due to default color scheme. +211 ==> diff --git a/core/libs/widgets/itemview/ditemtooltip.cpp b/core/libs/widgets/itemview/ditemtooltip.cpp index b624149af8..a6824b94af 100644 --- a/core/libs/widgets/itemview/ditemtooltip.cpp +++ b/core/libs/widgets/itemview/ditemtooltip.cpp @@ -1,413 +1,413 @@ /* ============================================================ * * This file is a part of digiKam project * http://www.digikam.org * * Date : 2008-12-10 * Description : tool tip widget for iconview, thumbbar, and folderview items * * Copyright (C) 2008-2018 by Gilles Caulier * * This program is free software; you can redistribute it * and/or modify it under the terms of the GNU General * Public License as published by the Free Software Foundation; * either version 2, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * ============================================================ */ #include "ditemtooltip.h" // Qt includes #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include // KDE includes #include namespace Digikam { DToolTipStyleSheet::DToolTipStyleSheet(const QFont& font) : maxStringLength(30) { unavailable = i18n("unavailable"); QString fontSize = (font.pointSize() == -1) ? QString::fromUtf8("font-size: %1px;").arg(font.pixelSize()) : QString::fromUtf8("font-size: %1pt;").arg(font.pointSize()); tipHeader = QLatin1String(""); tipFooter = QLatin1String("
"); headBeg = QString::fromLatin1("" "

") .arg(qApp->palette().color(QPalette::Base).name()) .arg(qApp->palette().color(QPalette::Text).name()) .arg(font.family()) .arg(fontSize); headEnd = QLatin1String("

"); cellBeg = QString::fromLatin1("

") .arg(qApp->palette().color(QPalette::ToolTipText).name()) .arg(font.family()) .arg(fontSize); cellMid = QString::fromLatin1("

") .arg(qApp->palette().color(QPalette::ToolTipText).name()) .arg(font.family()) .arg(fontSize); cellEnd = QLatin1String("

"); cellSpecBeg = QString::fromLatin1("

") .arg(qApp->palette().color(QPalette::ToolTipText).name()) .arg(font.family()) .arg(fontSize); cellSpecMid = QString::fromLatin1("

") .arg(qApp->palette().color(QPalette::ToolTipText).name()) .arg(font.family()) .arg(fontSize); cellSpecEnd = QLatin1String("

"); } QString DToolTipStyleSheet::breakString(const QString& input) const { QString str = input.simplified(); str = str.toHtmlEscaped(); if (str.length() <= maxStringLength) { return str; } QString br; int i = 0; int count = 0; while (i < str.length()) { if (count >= maxStringLength && str.at(i).isSpace()) { count = 0; br.append(QLatin1String("
")); } else { br.append(str.at(i)); } ++i; ++count; } return br; } QString DToolTipStyleSheet::elidedText(const QString& str, Qt::TextElideMode elideMode) const { if (str.length() <= maxStringLength) { return str; } switch (elideMode) { case Qt::ElideLeft: return QLatin1String("...") + str.right(maxStringLength-3); case Qt::ElideRight: return str.left(maxStringLength-3) + QLatin1String("..."); case Qt::ElideMiddle: return str.left(maxStringLength / 2 - 2) + QLatin1String("...") + str.right(maxStringLength / 2 - 1); case Qt::ElideNone: return str.left(maxStringLength); default: return str; } } QString DToolTipStyleSheet::imageAsBase64(const QImage& img) const { QByteArray byteArray; QBuffer buffer(&byteArray); img.save(&buffer, "PNG"); QString iconBase64 = QString::fromLatin1(byteArray.toBase64().data()); return QString::fromLatin1("").arg(iconBase64); } // -------------------------------------------------------------------------------------------------- class DItemToolTip::Private { public: explicit Private() : tipBorder(5) { corner = 0; } const int tipBorder; int corner; QPixmap corners[4]; }; DItemToolTip::DItemToolTip(QWidget* const parent) : QLabel(parent, Qt::ToolTip), d(new Private) { hide(); + setForegroundRole(QPalette::ToolTipText); setBackgroundRole(QPalette::ToolTipBase); - setPalette(QToolTip::palette()); ensurePolished(); const int fwidth = qMax(d->tipBorder, 1 + style()->pixelMetric(QStyle::PM_ToolTipLabelFrameWidth, 0, this)); setContentsMargins(fwidth, fwidth, fwidth, fwidth); setWindowOpacity(style()->styleHint(QStyle::SH_ToolTipLabel_Opacity, 0, this) / 255.0); setAlignment(Qt::AlignHCenter | Qt::AlignVCenter); setFrameStyle(QFrame::StyledPanel); /* Old-style box: setFrameStyle(QFrame::Plain | QFrame::Box); setLineWidth(1); */ renderArrows(); } DItemToolTip::~DItemToolTip() { delete d; } void DItemToolTip::updateToolTip() { renderArrows(); QString contents = tipContents(); //setWordWrap(Qt::mightBeRichText(contents)); setText(contents); resize(sizeHint()); } bool DItemToolTip::toolTipIsEmpty() const { return(text().isEmpty()); } void DItemToolTip::reposition() { QRect rect = repositionRect(); if (rect.isNull()) { return; } QPoint pos = rect.center(); // d->corner: // 0: upperleft // 1: upperright // 2: lowerleft // 3: lowerright d->corner = 0; // should the tooltip be shown to the left or to the right of the ivi ? QRect desk = QApplication::desktop()->screenGeometry(rect.center()); if (rect.center().x() + width() > desk.right()) { // to the left if (pos.x() - width() < 0) { pos.setX(0); d->corner = 4; } else { pos.setX( pos.x() - width() ); d->corner = 1; } } // should the tooltip be shown above or below the ivi ? if (rect.bottom() + height() > desk.bottom()) { // above pos.setY( rect.top() - height() - 5); d->corner += 2; } else { pos.setY( rect.bottom() + 5 ); } move( pos ); } void DItemToolTip::renderArrows() { int w = d->tipBorder; // -- left top arrow ------------------------------------- QPixmap& pix0 = d->corners[0]; pix0 = QPixmap(w, w); pix0.fill(Qt::transparent); QPainter p0(&pix0); p0.setPen(QPen(qApp->palette().color(QPalette::Text), 1)); for (int j=0; jcorners[1]; pix1 = QPixmap(w, w); pix1.fill(Qt::transparent); QPainter p1(&pix1); p1.setPen(QPen(qApp->palette().color(QPalette::Text), 1)); for (int j=0; jcorners[2]; pix2 = QPixmap(w, w); pix2.fill(Qt::transparent); QPainter p2(&pix2); p2.setPen(QPen(qApp->palette().color(QPalette::Text), 1)); for (int j=0; jcorners[3]; pix3 = QPixmap(w, w); pix3.fill(Qt::transparent); QPainter p3(&pix3); p3.setPen(QPen(qApp->palette().color(QPalette::Text), 1)); for (int j=0; jtype() ) { case QEvent::Leave: case QEvent::MouseButtonPress: case QEvent::MouseButtonRelease: case QEvent::FocusIn: case QEvent::FocusOut: case QEvent::Wheel: hide(); break; default: break; } return QFrame::event(e); } void DItemToolTip::resizeEvent(QResizeEvent* e) { QStyleHintReturnMask frameMask; QStyleOption option; option.init(this); if (style()->styleHint(QStyle::SH_ToolTip_Mask, &option, this, &frameMask)) { setMask(frameMask.region); } update(); QLabel::resizeEvent(e); } void DItemToolTip::paintEvent(QPaintEvent* e) { { QStylePainter p(this); QStyleOptionFrame opt; opt.init(this); p.drawPrimitive(QStyle::PE_PanelTipLabel, opt); } QLabel::paintEvent(e); QPainter p(this); if (d->corner >= 4) { return; } QPixmap& pix = d->corners[d->corner]; switch (d->corner) { case 0: p.drawPixmap( 3, 3, pix ); break; case 1: p.drawPixmap( width() - pix.width() - 3, 3, pix ); break; case 2: p.drawPixmap( 3, height() - pix.height() - 3, pix ); break; case 3: p.drawPixmap( width() - pix.width() - 3, height() - pix.height() - 3, pix ); break; } } } // namespace Digikam diff --git a/core/libs/widgets/itemview/itemviewtooltip.cpp b/core/libs/widgets/itemview/itemviewtooltip.cpp index 0db4f8c8b9..0c7b571253 100644 --- a/core/libs/widgets/itemview/itemviewtooltip.cpp +++ b/core/libs/widgets/itemview/itemviewtooltip.cpp @@ -1,211 +1,211 @@ /* ============================================================ * * This file is a part of digiKam project * http://www.digikam.org * * Date : 2009-04-24 * Description : A DItemToolTip prepared for use in QAbstractItemViews * * Copyright (C) 2009-2011 by Marcel Wiesweg * * This program is free software; you can redistribute it * and/or modify it under the terms of the GNU General * Public License as published by the Free Software Foundation; * either version 2, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * ============================================================ */ #include "itemviewtooltip.h" // Qt includes #include #include // Local includes #include "digikam_debug.h" namespace Digikam { class ItemViewToolTip::Private { public: explicit Private() { view = 0; filterInstalled = false; } QAbstractItemView* view; QModelIndex index; QRect rect; QString text; bool filterInstalled; }; ItemViewToolTip::ItemViewToolTip(QAbstractItemView* const view) : DItemToolTip(view), d(new Private) { d->view = view; + setForegroundRole(QPalette::ToolTipText); setBackgroundRole(QPalette::ToolTipBase); - setPalette(QToolTip::palette()); setMouseTracking(true); } ItemViewToolTip::~ItemViewToolTip() { delete d; } QAbstractItemView* ItemViewToolTip::view() const { return d->view; } QAbstractItemModel* ItemViewToolTip::model() const { return d->view ? d->view->model() : 0; } QModelIndex ItemViewToolTip::currentIndex() const { return d->index; } void ItemViewToolTip::show(const QStyleOptionViewItem& option, const QModelIndex& index) { d->index = index; d->rect = option.rect; d->rect.moveTopLeft(d->view->viewport()->mapToGlobal(d->rect.topLeft())); updateToolTip(); reposition(); if (isHidden() && !toolTipIsEmpty()) { if (!d->filterInstalled) { qApp->installEventFilter(this); d->filterInstalled = true; } DItemToolTip::show(); } } void ItemViewToolTip::setTipContents(const QString& tipContents) { d->text = tipContents; updateToolTip(); } QString ItemViewToolTip::tipContents() { return d->text; } QRect ItemViewToolTip::repositionRect() { return d->rect; } void ItemViewToolTip::hideEvent(QHideEvent*) { d->rect = QRect(); d->index = QModelIndex(); if (d->filterInstalled) { d->filterInstalled = false; qApp->removeEventFilter(this); } } // The following code is inspired by qtooltip.cpp, // Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). bool ItemViewToolTip::eventFilter(QObject* o, QEvent* e) { switch (e->type()) { #ifdef Q_OS_OSX case QEvent::KeyPress: case QEvent::KeyRelease: { int key = static_cast(e)->key(); Qt::KeyboardModifiers mody = static_cast(e)->modifiers(); if (!(mody & Qt::KeyboardModifierMask) && key != Qt::Key_Shift && key != Qt::Key_Control && key != Qt::Key_Alt && key != Qt::Key_Meta) { hide(); } break; } #endif // Q_OS_OSX case QEvent::Leave: hide(); // could add a 300ms timer here, like Qt break; case QEvent::WindowActivate: case QEvent::WindowDeactivate: case QEvent::MouseButtonPress: case QEvent::MouseButtonRelease: case QEvent::MouseButtonDblClick: case QEvent::FocusIn: case QEvent::FocusOut: case QEvent::Wheel: hide(); break; case QEvent::MouseMove: { // needs mouse tracking, obviously if (o == d->view->viewport() && !d->rect.isNull() && !d->rect.contains(static_cast(e)->globalPos())) { hide(); } break; } default: break; } return false; } void ItemViewToolTip::mouseMoveEvent(QMouseEvent* e) { if (d->rect.isNull()) { return; } QPoint pos = e->globalPos(); pos = d->view->viewport()->mapFromGlobal(pos); if (!d->rect.contains(pos)) { hide(); } DItemToolTip::mouseMoveEvent(e); } } // namespace Digikam diff --git a/core/libs/widgets/mainview/dcursortracker.cpp b/core/libs/widgets/mainview/dcursortracker.cpp index a9661c9668..83263ee489 100644 --- a/core/libs/widgets/mainview/dcursortracker.cpp +++ b/core/libs/widgets/mainview/dcursortracker.cpp @@ -1,233 +1,232 @@ /* ============================================================ * * This file is a part of digiKam project * http://www.digikam.org * * Date : 2007-23-03 * Description : A tool tip widget which follows cursor movements. * Tool tip content is displayed without delay. * * Copyright (C) 2007-2018 by Gilles Caulier * Copyright (C) 2009-2010 by Andi Clemens * * This program is free software; you can redistribute it * and/or modify it under the terms of the GNU General * Public License as published by the Free Software Foundation; * either version 2, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * ============================================================ */ #include "dcursortracker.h" // Qt includes #include #include #include #include #include #include #include #include #include #include namespace Digikam { class DCursorTracker::Private { public: explicit Private() { keepOpen = false; enable = true; autoHideTimer = 0; parent = 0; } Qt::Alignment alignment; bool enable; bool keepOpen; QTimer* autoHideTimer; QPointer parent; }; DCursorTracker::DCursorTracker(const QString& txt, QWidget* const parent, Qt::Alignment align) : QLabel(txt, parent, Qt::ToolTip | Qt::BypassGraphicsProxyWidget), d(new Private) { setForegroundRole(QPalette::ToolTipText); setBackgroundRole(QPalette::ToolTipBase); - setPalette(QToolTip::palette()); ensurePolished(); const int fwidth = 1 + style()->pixelMetric(QStyle::PM_ToolTipLabelFrameWidth, 0, this); setContentsMargins(fwidth, fwidth, fwidth, fwidth); setFrameStyle(QFrame::NoFrame); setAlignment(Qt::AlignLeft | Qt::AlignTop); setIndent(1); setWindowOpacity(style()->styleHint(QStyle::SH_ToolTipLabel_Opacity, 0, this) / 255.0); d->alignment = align; d->parent = parent; d->parent->setMouseTracking(true); d->parent->installEventFilter(this); d->autoHideTimer = new QTimer(this); d->autoHideTimer->setSingleShot(true); connect(d->autoHideTimer, SIGNAL(timeout()), this, SLOT(slotAutoHide())); } DCursorTracker::~DCursorTracker() { delete d; } /** * Overload to make sure the widget size is correct */ void DCursorTracker::setText(const QString& txt) { QLabel::setText(txt); adjustSize(); } void DCursorTracker::setEnable(bool b) { d->enable = b; } void DCursorTracker::setKeepOpen(bool b) { d->keepOpen = b; } void DCursorTracker::setTrackerAlignment(Qt::Alignment alignment) { d->alignment = alignment; } void DCursorTracker::triggerAutoShow(int timeout) { if (canBeDisplayed()) { show(); moveToParent(d->parent); d->autoHideTimer->start(timeout); } } void DCursorTracker::refresh() { moveToParent(d->parent); } void DCursorTracker::slotAutoHide() { hide(); } bool DCursorTracker::eventFilter(QObject* object, QEvent* e) { QWidget* const widget = static_cast(object); switch (e->type()) { case QEvent::MouseMove: { QMouseEvent* event = static_cast(e); if (canBeDisplayed() && (widget->rect().contains(event->pos()) || (event->buttons() & Qt::LeftButton))) { show(); moveToParent(widget); } else if (!d->keepOpen) { hide(); } break; } case QEvent::Leave: { if (!d->keepOpen) { hide(); } break; } default: break; } return false; } void DCursorTracker::moveToParent(QWidget* const parent) { if (!parent) { return; } switch (d->alignment) { case Qt::AlignLeft: { QPoint p = parent->mapToGlobal(QPoint(0, 0)); int y = p.y() - height(); move(p.x(), (y < 0) ? (p.y() + parent->height()) : y); break; } case Qt::AlignRight: { QPoint p = parent->mapToGlobal(QPoint(parent->width(), 0)); int y = p.y() - height(); move(p.x()-width(), (y < 0) ? (p.y() + parent->height()) : y); break; } case Qt::AlignCenter: default: { QPoint p = parent->mapToGlobal(QPoint(parent->width()/2, 0)); int y = p.y() - height(); move(p.x()-width()/2, (y < 0) ? (p.y() + parent->height()) : y); break; } } } void DCursorTracker::paintEvent(QPaintEvent* e) { QStylePainter p(this); QStyleOptionFrame opt; opt.init(this); p.drawPrimitive(QStyle::PE_PanelTipLabel, opt); p.end(); QLabel::paintEvent(e); } bool DCursorTracker::canBeDisplayed() { return d->enable && d->parent->isVisible(); } } // namespace Digikam