From kde-panel-devel Sat May 31 22:57:55 2008 From: =?ISO-8859-1?Q?Lo=EFc_Marteau?= Date: Sat, 31 May 2008 22:57:55 +0000 To: kde-panel-devel Subject: Re: [Icon Plasmoid] Provide a generic plasmoid class for icon based Message-Id: <4841D7F3.1040201 () gmail ! com> X-MARC-Message: https://marc.info/?l=kde-panel-devel&m=121227470913538 MIME-Version: 1 Content-Type: multipart/mixed; boundary="--------------090400030408080306010000" This is a multi-part message in MIME format. --------------090400030408080306010000 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit Sorry i forgot the attached files.... Aaron J. Seigo wrote: > On Saturday 31 May 2008, Loïc Marteau wrote: > >> I would like to have icon plasmoid with the same default size (the same >> as the screenshot) perhaps 75 % >> but size should be configurable (by setting an other percentage in the >> class ?) . >> In the screenshot the K button is bigger than others and i think it's >> great to can do this. >> > > i think this is really up to the Containment, in this case the Panel, > to provide some mechanism for varying the size of select applets. > perhaps something like zones of differing height. > > sebas and alexis have both working on graphics items groupers that > might be applicable in such situations. > > good :) >> What do you think about proposing a recommended way to implement an icon >> plasmoid ? >> > > that's probably a good idea. > > >> In fact there is still a space (too big imho) between each plasmoid. Is >> it possible to reduce it ? >> > > the best way would be to ensure that each applet accurately reports > the size it needs. this can be tricky with icons because they often > have an unspecified amount of whitespace on their edges. > > having them square ensures there is a consistent spacing of them, > though due to the whitespace issue the apparent visual spacing may > vary slightly. in the end it is up to the artists to ensure a > reasonable centering of the image(s) that make up an icon. > > In fact there is two points 1- the most important : due to plasmoid itself : - not correct size setting in the code -> i confirm that plasma::square is a good solution and for the moment a lot of icon based plasmoid doesnt seems to use it - or like you said here too because of icon with "portrait" format -> art issue 2- a less minor one : the constant size between each plasmoid in a panel. I tink that even between 2 square icon plasmoids (implemented with plasma:square sizeconstraint methode) the space between them is too high. But this is certainly subject to discussion. This don't depend direclty of plasmoids but certainly on the panel and probably rejoin what you are talking with zone containments (space on each plasmoid should depends on which zone we are ?!). What do you think reduce (a litlle) the distance between two plasmoids in the default panel settings ? >>> in the case of the icons, we probably don't actually want to be using >>> Plasma::Square, but just set the size policy to be minimum for the >>> growth >>> direction (horizontally on horizontal panels, vertically on vertical >>> panels) >>> >> so isn't the idea to provide a generic class for them not good ? > > i'm just not sure how much code would end up being saved by this, > since making an icon applet takes 6 lines of code: set the form factor > to Square, create the Plasma::Icon, create a layout, set the margins > and spacing to 0, add the icon to the layout. > > if there was a generic applet, you'd still need to define which icon > by name to load, so we save 5 lines per applet. those 5 lines are not > exactly tricky, and i don't think they justify having another library > class. > > what we *could* do, perhaps, it add another special constructor or > method to Plasma::Icon that would put the icon inside a layout in the > applet and make applets that are a simple icon based thing use that. > even that's a bit drastic, but is a nicer solution imho than a whole > new class. > > also remember that some of these applets will expand to be more than > just an icon when moved out of a Vertical or Horizontal Containment, Yes i am aware of the problem and i was thinking that the majority (not all) of plasmoid want in final the same comportment about the adjustment needed with vertical or horizontal containment. By looking the code of some of icon based plasmoid I was thinking that the implementation of this constraint stuff was not trivial. I attach a basic (trivial) iconplasmoid code based on your recommendations. Could you check if this is ok for you. Perhaps the problem with this is that we dont put max size constraint when panel is big. I dont know if it is important. If it is, the solution have to be directly in plasma::square related code or can your proposed solution deal with this ? When we will found a proper solution perhaps i can start to propose patch to existing plasmoid ?! showdesktop (petri already use a layout), showdashboard, trashcan, .desktop shortcut plasmoid, notify, new device notifier... > and others, such as the battery which is essentially just an icon, > need to do extra painting themselves anyways (such as on mouse hover > in the case of the battery)... so the actual code savings would be > pretty low and getting them all consistent isn't very hard ... =) > is it not possible to let the class share the icon and the child class add slot/signal for him, and provide setter to change the icon when he want ? However it's true that (for the moment) the skelet code for icon plasmoid with layout and plasma:square is very simple. I'm not an expert of c++ and dont know plasma, sorry if some of my questions/remarks are stupid :o). Hope this can help. Cheers, Loic --------------090400030408080306010000 Content-Type: text/plain; name="CMakeLists.txt" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="CMakeLists.txt" project(plasma-iconplasmoid) include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${PLASMA_INCLUDE_DIR}) set(iconplasmoid_SRCS iconplasmoid.cpp ) kde4_add_plugin(plasma_applet_iconplasmoid ${iconplasmoid_SRCS}) target_link_libraries(plasma_applet_iconplasmoid ${KDE4_KDEUI_LIBS} ${PLASMA_LIBS} ) install(TARGETS plasma_applet_iconplasmoid DESTINATION ${PLUGIN_INSTALL_DIR}) install(FILES plasma-applet-iconplasmoid.desktop DESTINATION ${SERVICES_INSTALL_DIR}) --------------090400030408080306010000 Content-Type: text/x-c++src; name="iconplasmoid.cpp" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="iconplasmoid.cpp" /* * * 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 . */ #include "iconplasmoid.h" #include #include #include #include #include #include IconPlasmoid::IconPlasmoid(QObject *parent, const QVariantList &args) : Plasma::Applet(parent, args) { } IconPlasmoid::~IconPlasmoid() { } void IconPlasmoid::init() { setBackgroundHints(NoBackground); setAspectRatioMode(Plasma::Square); QGraphicsLinearLayout *layout = new QGraphicsLinearLayout(this); layout->setContentsMargins(0, 0, 0, 0); layout->setSpacing(0); Plasma::Icon *icon = new Plasma::Icon(KIcon("user-desktop"), QString(), this); layout->addItem(icon); connect(icon, SIGNAL(clicked()), this, SLOT(pressed())); } void IconPlasmoid::pressed() { } #include "iconplasmoid.moc" --------------090400030408080306010000 Content-Type: text/x-chdr; name="iconplasmoid.h" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="iconplasmoid.h" /* * 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 . */ #ifndef ICONPLASMOID_HEADER #define ICONPLASMOID_HEADER #include class IconPlasmoid : public Plasma::Applet { Q_OBJECT public: IconPlasmoid(QObject *parent, const QVariantList &args); ~IconPlasmoid(); virtual void init(); public slots: void pressed(); }; K_EXPORT_PLASMA_APPLET(iconplasmoid, IconPlasmoid) #endif --------------090400030408080306010000 Content-Type: text/plain; name="plasma-applet-iconplasmoid.desktop" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="plasma-applet-iconplasmoid.desktop" [Desktop Entry] Name=Icon Plasmoid Comment=Test Type=Service Icon=user-desktop ServiceTypes=Plasma/Applet X-KDE-Library=plasma_applet_iconplasmoid X-KDE-PluginInfo-Author= X-KDE-PluginInfo-Email= X-KDE-PluginInfo-Name=iconplasmoid X-KDE-PluginInfo-Version=pre0.1 X-KDE-PluginInfo-Website=http://plasma.kde.org/ X-KDE-PluginInfo-Category=Windows and Tasks X-KDE-PluginInfo-Depends= X-KDE-PluginInfo-License=GPL X-KDE-PluginInfo-EnabledByDefault=true --------------090400030408080306010000 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Panel-devel mailing list Panel-devel@kde.org https://mail.kde.org/mailman/listinfo/panel-devel --------------090400030408080306010000--