[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-panel-devel
Subject: Re: [Icon Plasmoid] Provide a generic plasmoid class for icon based
From: Loïc_Marteau <loic.marteau () gmail ! com>
Date: 2008-05-31 16:02:39
Message-ID: 4841769F.2090500 () gmail ! com
[Download RAW message or body]
Aaron J. Seigo wrote:
> On Saturday 24 May 2008, Loïc Marteau wrote:
>
>> Each plasmoid have a particular way to implement the size stuff and the
>> result is not often perfect.
>>
>
> setAspectRatioMode(Plasma::Square)?
>
> if that isn't working, it needs to be fixed. but that's what it is there for.
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Panel-devel mailing list
> Panel-devel@kde.org
> https://mail.kde.org/mailman/listinfo/panel-devel
>
ok
Here is what i have when i try to use
setAspectRatioMode(Plasma::Square) and make it the most simple as possible.
void ShowDesktop::init()
{
setBackgroundHints(NoBackground);
setAspectRatioMode(Plasma::Square);
m_icon = new Plasma::Icon(KIcon("user-desktop"),QString(),this);
connect(m_icon, SIGNAL(clicked()), this, SLOT(pressed()));
[...]
}
void ShowDesktop::constraintsEvent(Plasma::Constraints constraints)
{
Plasma::Applet::constraintsEvent(constraints);
m_icon->resize(contentsRect().size());
}
i attach the files for the showdesktop plasmoid.
Question 1 :
Is this the good way (tm) to implement icon based plasmoid ?
There is a lot of icon plasmoid and they have all different way to
implement size constraint stuff. The result is unequal.
The result with this code is a little better than with the actual
showdesktop plasmoid (he take less unused width space in border).
Question 2 :
Can this code be commited to trunk for showdesktop ?
However, wee still need to implement the constraintsevent function to
correctly resize the icon. I think that if we have a generic class icon
it will be more useful to use.
I think that such icon plasmoid should be a little more little (*0.75
would be fine) and still take too much unused width space (it is much
better with setAspectRatioMode(Plasma::Square) but still not perfect).
Question 3 :
How can i do to reduce the size to 75 % ?
Question 4 :
It is possible to reduce the width of unused space when we use the
setAspectRatioMode(Plasma::Square) shortcut ?
I would like to have a result like this :
http://nuno-icons.com//images/estilo/imagefoldersclock.png
I would like to help, i think that there is some plasmoid to polish with
the size constraint stuff (showdesktop, showdashboard, trashcan,
.desktop shortcut plasmoid, notify, new device notifier). I can perhaps
help to patch them if we found the correct way to deal with this problem.
Best regards,
Loic
["showdesktop.cpp" (text/x-c++src)]
/*
* Copyright 2008 Petri Damsten <damu@iki.fi>
*
* 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 of
* the License, 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.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "showdesktop.h"
#include <plasma/containment.h>
#include <KIcon>
#include <kwindowsystem.h>
#include <netwm.h>
#include <KIconLoader>
#include <QX11Info>
#include <QTimer>
#include <QGraphicsLinearLayout>
ShowDesktop::ShowDesktop(QObject *parent, const QVariantList &args)
: Plasma::Applet(parent, args), m_wm2ShowingDesktop(false)
#ifndef MINIMIZE_ONLY
, m_down(false), m_goingDown(false)
#endif
{
}
ShowDesktop::~ShowDesktop()
{
}
void ShowDesktop::init()
{
//setBackgroundHints(NoBackground);
setAspectRatioMode(Plasma::Square);
m_icon = new Plasma::Icon(KIcon("user-desktop"),QString(),this);
connect(m_icon, SIGNAL(clicked()), this, SLOT(pressed()));
//resize(IconSize(KIconLoader::Desktop)/3,IconSize(KIconLoader::Desktop)/3);
//m_icon->resize(contentsRect().size());
NETRootInfo info(QX11Info::display(), NET::Supported);
m_wm2ShowingDesktop = info.isSupported(NET::WM2ShowingDesktop);
#ifndef MINIMIZE_ONLY
if (m_wm2ShowingDesktop) {
connect(KWindowSystem::self(), SIGNAL(activeWindowChanged(WId)), this, SLOT(reset()));
}
#endif
}
void ShowDesktop::constraintsEvent(Plasma::Constraints constraints)
{
Plasma::Applet::constraintsEvent(constraints);
m_icon->resize(contentsRect().size());
}
void ShowDesktop::pressed()
{
if (m_wm2ShowingDesktop) {
NETRootInfo info(QX11Info::display(), 0);
#ifndef MINIMIZE_ONLY
m_down = !m_down;
m_goingDown = m_down;
info.setShowingDesktop(m_down);
// NETRootInfo::showingDesktop() returns always false
QTimer::singleShot(500, this, SLOT(delay()));
#else
info.setShowingDesktop(true);
#endif
}
}
#ifndef MINIMIZE_ONLY
void ShowDesktop::delay()
{
m_goingDown = false;
}
void ShowDesktop::reset()
{
if (!m_goingDown) {
m_down = false;
}
}
#endif
#include "showdesktop.moc"
["showdesktop.h" (text/x-chdr)]
/*
* Copyright 2008 Petri Damsten <damu@iki.fi>
*
* 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 of
* the License, 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.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef SHOWDESKTOP_HEADER
#define SHOWDESKTOP_HEADER
//#define MINIMIZE_ONLY
#include <Plasma/Applet>
#include <plasma/widgets/icon.h>
class ShowDesktop : public Plasma::Applet
{
Q_OBJECT
public:
ShowDesktop(QObject *parent, const QVariantList &args);
~ShowDesktop();
virtual void init();
public slots:
void pressed();
#ifndef MINIMIZE_ONLY
void reset();
void delay();
#endif
protected:
void constraintsEvent(Plasma::Constraints constraints);
private:
Plasma::Icon * m_icon;
bool m_wm2ShowingDesktop;
#ifndef MINIMIZE_ONLY
bool m_down;
bool m_goingDown;
#endif
};
K_EXPORT_PLASMA_APPLET(showdesktop, ShowDesktop)
#endif
_______________________________________________
Panel-devel mailing list
Panel-devel@kde.org
https://mail.kde.org/mailman/listinfo/panel-devel
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic