delay a few things on startup, such as setting the visibility mode, which ensures...
[personal-kdebase.git] / apps / plasma / applets / folderview / style.cpp
blobb35f62426ded4b1e0cdf274b451f975a07b5f653
1 /*
2 * Copyright © 2008 Fredrik Höglund <fredrik@kde.org>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public License
15 * along with this library; see the file COPYING.LIB. If not, write to
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
20 #include "style.h"
22 #include <QStyleOption>
24 #include <plasma/framesvg.h>
26 FolderViewStyle::FolderViewStyle()
27 : QCommonStyle()
29 m_frame = new Plasma::FrameSvg(this);
30 m_frame->setImagePath("widgets/viewitem");
31 m_frame->setCacheAllRenderedFrames(true);
32 m_frame->setElementPrefix("normal");
35 FolderViewStyle::~FolderViewStyle()
39 void FolderViewStyle::drawPrimitive(PrimitiveElement element, const QStyleOption *option,
40 QPainter *painter, const QWidget *widget) const
42 if (element != PE_PanelItemViewItem) {
43 return QCommonStyle::drawPrimitive(element, option, painter, widget);
46 bool hover = (option->state & State_MouseOver);
47 bool selected = (option->state & State_Selected);
49 if (selected && hover) {
50 m_frame->setElementPrefix("selected+hover");
51 } else if (selected) {
52 m_frame->setElementPrefix("selected");
53 } else if (hover) {
54 m_frame->setElementPrefix("hover");
55 } else {
56 m_frame->setElementPrefix("normal");
59 if (selected || hover) {
60 m_frame->resizeFrame(option->rect.size());
61 m_frame->paintFrame(painter, option->rect.topLeft());