• Skip to content
  • Skip to link menu
KDE 4.2 API Reference
  • KDE API Reference
  • API Reference
  • Sitemap
  • Contact Us
 

Applets

quicklaunchApplet.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2008 by Lukas Appelhans                                 *
00003  *   l.appelhans@gmx.de                                                    *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU General Public License as published by  *
00007  *   the Free Software Foundation; either version 2 of the License, or     *
00008  *   (at your option) any later version.                                   *
00009  *                                                                         *
00010  *   This program is distributed in the hope that it will be useful,       *
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00013  *   GNU General Public License for more details.                          *
00014  *                                                                         *
00015  *   You should have received a copy of the GNU General Public License     *
00016  *   along with this program; if not, write to the                         *
00017  *   Free Software Foundation, Inc.,                                       *
00018  *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.          *
00019  ***************************************************************************/
00020 #ifndef QUICKLAUNCHAPPLET_H
00021 #define QUICKLAUNCHAPPLET_H
00022 
00023 #include <plasma/applet.h>
00024 #include <plasma/widgets/iconwidget.h>
00025 #include <QGraphicsLinearLayout>
00026 #include <QGraphicsGridLayout>
00027 #include <QGraphicsLayoutItem>
00028 #include <QList>
00029 #include <KIcon>
00030 #include <KDialog>
00031 
00032 #include "ui_quicklaunchConfig.h"
00033 #include "ui_quicklaunchAdd.h"
00034 
00035 #include "quicklaunchIcon.h"
00036 
00037 namespace Plasma
00038 {
00039     class Dialog;
00040 }
00041 
00042 class QuicklaunchLayout : public QGraphicsGridLayout
00043 {
00044     public:
00045         QuicklaunchLayout(QGraphicsLayoutItem *parent, int rowCount)
00046          : QGraphicsGridLayout(parent), m_rowCount(rowCount)
00047         {}
00048         void setRowCount(int rowCount) { m_rowCount = rowCount; }
00049         void addItem(Plasma::IconWidget *icon) {
00050             //kDebug() << "Row count is" << rowCount() << "Wanted row count is" << m_rowCount;
00051             //int row = m_rowCount == rowCount() || rowCount() == -1 ? 0 : rowCount();
00052             //int column = m_rowCount == rowCount()  || columnCount() == 0 ? columnCount() : columnCount() - 1;
00053             //kDebug() << "Adding icon to row = " << row << ", column = " << column;
00054             int row = 0;
00055             int column = 0;
00056             while (itemAt(row, column))
00057             {
00058                 kDebug() << "Row is" << row << "column is" << column;
00059                 if (row < m_rowCount - 1) {
00060                     row++;
00061                 }
00062                 else {
00063                     kDebug() << "column++";
00064                     row = 0;
00065                     column++;
00066                 }
00067             }
00068             QGraphicsGridLayout::addItem(icon, row, column);
00069         }
00070         QSizeF sizeHint(Qt::SizeHint which, const QSizeF & constraint = QSizeF()) const
00071         {
00072             if (which == Qt::PreferredSize) {
00073                 return QSizeF(columnCount() * geometry().height() / m_rowCount, QGraphicsGridLayout::sizeHint(which, constraint).height());
00074             }
00075             return QGraphicsGridLayout::sizeHint(which, constraint);
00076         }
00077     private:
00078         int m_rowCount;
00079 };
00080 
00081 class QuicklaunchApplet : public Plasma::Applet
00082 {
00083     Q_OBJECT
00084     public:
00085         QuicklaunchApplet(QObject *parent, const QVariantList &args);
00086         ~QuicklaunchApplet();
00087 
00092         QSizeF sizeHint(Qt::SizeHint which, const QSizeF & constraint = QSizeF()) const;
00093 
00098         Qt::Orientations expandingDirections() const { return 0; }
00099 
00104         virtual QList<QAction*> contextActions(QuicklaunchIcon *icon = 0);
00105 
00106     public slots:
00107         void createConfigurationInterface(KConfigDialog *parent);
00111         void showAddInterface();
00112 
00113     protected:
00117         void saveState(KConfigGroup &config) const;
00118 
00119         virtual bool eventFilter(QObject * object, QEvent * event);
00120 
00125         void dragEnterEvent(QGraphicsSceneDragDropEvent *event);
00126 
00131         void dragMoveEvent(QGraphicsSceneDragDropEvent *event);
00132 
00138         void dropEvent(QGraphicsSceneDragDropEvent *event);
00139 
00143         void constraintsEvent(Plasma::Constraints constraints);
00144 
00145     protected slots:
00149     void addAccepted();
00150 
00154     void configAccepted();
00155 
00156     private slots:
00157         void refactorUi();
00158         void showDialog();
00159         void removeCurrentIcon();
00160 
00161     private:
00162         void init();
00163 
00169         void addProgram(int index, const QString &desktopFile);
00170 
00175         void loadPrograms(const QStringList &desktopFiles);
00176 
00181         void clearLayout(QGraphicsLayout *layout);
00182 
00186         void saveConfig() {}
00187 
00188         bool dropHandler(const int pos, const QMimeData *mimedata);
00189 
00190         QGraphicsLinearLayout *m_layout;
00191         QuicklaunchLayout *m_innerLayout;
00192         QList<QuicklaunchIcon*> m_icons;
00193         Plasma::IconWidget *m_arrow;
00194         int m_visibleIcons;
00195         int m_rowCount;
00196         int m_dialogRowCount;
00197         Plasma::Dialog *m_dialog;
00198         QGraphicsWidget * m_dialogWidget;
00199         QuicklaunchLayout *m_dialogLayout;
00200         KDialog *m_addDialog;
00201         Ui::quicklaunchConfig uiConfig;
00202         Ui::quicklaunchAdd addUi;
00203         QuicklaunchIcon *m_rightClickedIcon;
00204         QPointF m_mousePressPos;
00205 
00206         QAction* m_addAction;
00207         QAction* m_removeAction;
00208 };
00209 
00210 #endif

Applets

Skip menu "Applets"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members

API Reference

Skip menu "API Reference"
  • KWin
  •   KWin Libraries
  • Libraries
  •   libkworkspace
  •   libsolidcontrol
  •   libtaskmanager
  • Plasma
  •   Animators
  •   Applets
  •   Engines
  • Solid Modules
Generated for API Reference by doxygen 1.5.7
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal