X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/7fbae445277374fb2bacfcd7c04e8d7fbb2c3f05..d8669c68e40a6571dfcbdf38e3281a4aeb8c2be6:/src/infosidebarpage.cpp diff --git a/src/infosidebarpage.cpp b/src/infosidebarpage.cpp index bf3d5f4fc..3a8099d6e 100644 --- a/src/infosidebarpage.cpp +++ b/src/infosidebarpage.cpp @@ -14,7 +14,7 @@ * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * ***************************************************************************/ #include "infosidebarpage.h" @@ -47,12 +47,12 @@ #include #include -#include "dolphin.h" +#include "dolphinmainwindow.h" #include "pixmapviewer.h" #include "dolphinsettings.h" -InfoSidebarPage::InfoSidebarPage(QWidget* parent) : - SidebarPage(parent), +InfoSidebarPage::InfoSidebarPage(DolphinMainWindow* mainWindow, QWidget* parent) : + SidebarPage(mainWindow, parent), m_multipleSelection(false), m_pendingPreview(false), m_timer(0), @@ -111,7 +111,7 @@ InfoSidebarPage::InfoSidebarPage(QWidget* parent) : layout->addWidget(m_actionBox); layout->addWidget(dummy); - connect(&Dolphin::mainWin(), SIGNAL(selectionChanged()), + connect(mainWindow, SIGNAL(selectionChanged()), this, SLOT(showItemInfo())); connectToActiveView(); @@ -132,7 +132,8 @@ void InfoSidebarPage::requestDelayedItemInfo(const KUrl& url) if (!url.isEmpty() && !m_multipleSelection) { m_urlCandidate = url; - m_timer->start(300, true); + m_timer->setSingleShot(true); + m_timer->start(300); } } @@ -153,9 +154,9 @@ void InfoSidebarPage::showItemInfo() m_multipleSelection = false; // show the preview... - DolphinView* view = Dolphin::mainWin().activeView(); - const KFileItemList* selectedItems = view->selectedItems(); - if ((selectedItems != 0) && selectedItems->count() > 1) { + DolphinView* view = mainWindow()->activeView(); + const KFileItemList selectedItems = view->selectedItems(); + if (selectedItems.count() > 1) { m_multipleSelection = true; } @@ -165,7 +166,7 @@ void InfoSidebarPage::showItemInfo() K3Icon::NoGroup, K3Icon::SizeEnormous); m_preview->setPixmap(icon); - m_name->setText(i18n("%1 items selected",selectedItems->count())); + m_name->setText(i18n("%1 items selected",selectedItems.count())); } else if (!applyBookmark()) { // try to get a preview pixmap from the item... @@ -218,7 +219,7 @@ void InfoSidebarPage::gotPreview(const KFileItem* /* item */, void InfoSidebarPage::startService(int index) { - DolphinView* view = Dolphin::mainWin().activeView(); + DolphinView* view = mainWindow()->activeView(); if (view->hasSelection()) { KUrl::List selectedUrls = view->selectedUrls(); KDEDesktopMimeType::executeService(selectedUrls, m_actionsVector[index]); @@ -232,8 +233,8 @@ void InfoSidebarPage::connectToActiveView() { cancelRequest(); - DolphinView* view = Dolphin::mainWin().activeView(); - connect(view, SIGNAL(signalRequestItemInfo(const KUrl&)), + DolphinView* view = mainWindow()->activeView(); + connect(view, SIGNAL(requestItemInfo(const KUrl&)), this, SLOT(requestDelayedItemInfo(const KUrl&))); connect(view, SIGNAL(signalUrlChanged(const KUrl&)), this, SLOT(requestItemInfo(const KUrl&))); @@ -279,7 +280,7 @@ void InfoSidebarPage::createMetaInfo() // The methods beginInfoLines(), addInfoLine() and endInfoLines() // take care of this. beginInfoLines(); - DolphinView* view = Dolphin::mainWin().activeView(); + DolphinView* view = mainWindow()->activeView(); if (!view->hasSelection()) { KFileItem fileItem(S_IFDIR, KFileItem::Unknown, m_shownUrl); fileItem.refresh(); @@ -429,12 +430,10 @@ void InfoSidebarPage::insertActions() // of KFileItems. If no selection is given, a temporary KFileItem // by the given Url 'url' is created and added to the list. KFileItem fileItem(S_IFDIR, KFileItem::Unknown, m_shownUrl); - KFileItemList localList; - const KFileItemList* itemList = Dolphin::mainWin().activeView()->selectedItems(); - if ((itemList == 0) || itemList->isEmpty()) { + KFileItemList itemList = mainWindow()->activeView()->selectedItems(); + if (itemList.isEmpty()) { fileItem.refresh(); - localList.append(&fileItem); - itemList = &localList; + itemList.append(&fileItem); } // 'itemList' contains now all KFileItems, where an item information should be shown. @@ -458,7 +457,7 @@ void InfoSidebarPage::insertActions() if ((*it) == "all/allfiles") { // The service type is valid for all files, but not for directories. // Check whether the selected items only consist of files... - QListIterator mimeIt(*itemList); + QListIterator mimeIt(itemList); insert = true; while (insert && mimeIt.hasNext()) { KFileItem* item = mimeIt.next(); @@ -470,16 +469,16 @@ void InfoSidebarPage::insertActions() // Check whether the MIME types of all selected files match // to the mimetype of the service action. As soon as one MIME // type does not match, no service menu is shown at all. - QListIterator mimeIt(*itemList); + QListIterator mimeIt(itemList); insert = true; while (insert && mimeIt.hasNext()) { KFileItem* item = mimeIt.next(); const QString mimeType(item->mimetype()); - const QString mimeGroup(mimeType.left(mimeType.find('/'))); + const QString mimeGroup(mimeType.left(mimeType.indexOf('/'))); insert = (*it == mimeType) || ((*it).right(1) == "*") && - ((*it).left((*it).find('/')) == mimeGroup); + ((*it).left((*it).indexOf('/')) == mimeGroup); } } @@ -538,7 +537,7 @@ ServiceButton::ServiceButton(const QIcon& icon, m_hover(false), m_index(index) { - setEraseColor(colorGroup().background()); + setEraseColor(palette().brush(QPalette::Background).color()); setFocusPolicy(Qt::NoFocus); connect(this, SIGNAL(released()), this, SLOT(slotReleased())); @@ -548,8 +547,9 @@ ServiceButton::~ServiceButton() { } -void ServiceButton::drawButton(QPainter* painter) +void ServiceButton::paintEvent(QPaintEvent* event) { + QPainter painter(this); const int buttonWidth = width(); const int buttonHeight = height(); @@ -560,14 +560,14 @@ void ServiceButton::drawButton(QPainter* painter) foregroundColor = KGlobalSettings::highlightedTextColor(); } else { - backgroundColor = colorGroup().background(); + backgroundColor = palette().brush(QPalette::Background).color(); foregroundColor = KGlobalSettings::buttonTextColor(); } // draw button background - painter->setPen(Qt::NoPen); - painter->setBrush(backgroundColor); - painter->drawRect(0, 0, buttonWidth, buttonHeight); + painter.setPen(Qt::NoPen); + painter.setBrush(backgroundColor); + painter.drawRect(0, 0, buttonWidth, buttonHeight); const int spacing = KDialog::spacingHint(); @@ -576,18 +576,18 @@ void ServiceButton::drawButton(QPainter* painter) const int y = (buttonHeight - K3Icon::SizeSmall) / 2; const QIcon* set = iconSet(); if (set != 0) { - painter->drawPixmap(x, y, set->pixmap(QIcon::Small, QIcon::Normal)); + painter.drawPixmap(x, y, set->pixmap(QIcon::Small, QIcon::Normal)); } x += K3Icon::SizeSmall + spacing; // draw text - painter->setPen(foregroundColor); + painter.setPen(foregroundColor); const int textWidth = buttonWidth - x; QFontMetrics fontMetrics(font()); const bool clipped = fontMetrics.width(text()) >= textWidth; //const int align = clipped ? Qt::AlignVCenter : Qt::AlignCenter; - painter->drawText(QRect(x, 0, textWidth, buttonHeight), Qt::AlignVCenter, text()); + painter.drawText(QRect(x, 0, textWidth, buttonHeight), Qt::AlignVCenter, text()); if (clipped) { // Blend the right area of the text with the background, as the @@ -601,9 +601,9 @@ void ServiceButton::drawButton(QPainter* painter) const int greenInc = (foregroundColor.green() - backgroundColor.green()) / blendSteps; const int blueInc = (foregroundColor.blue() - backgroundColor.blue()) / blendSteps; for (int i = 0; i < blendSteps; ++i) { - painter->setClipRect(QRect(x + textWidth - i, 0, 1, buttonHeight)); - painter->setPen(blendColor); - painter->drawText(QRect(x, 0, textWidth, buttonHeight), Qt::AlignVCenter, text()); + painter.setClipRect(QRect(x + textWidth - i, 0, 1, buttonHeight)); + painter.setPen(blendColor); + painter.drawText(QRect(x, 0, textWidth, buttonHeight), Qt::AlignVCenter, text()); blendColor.setRgb(blendColor.red() + redInc, blendColor.green() + greenInc,