source: src-qt4/pc-softwaremanager/largeItemWidget.h @ efbe467

releng/10.0.1releng/10.0.2releng/10.0.3releng/10.1releng/10.1.1
Last change on this file since efbe467 was efbe467, checked in by Ken Moore <ken@…>, 13 months ago

Add a quick application type identification when looking at just the short app listing through a small icon in the corner.

  • Property mode set to 100644
File size: 4.2 KB
Line 
1/***************************************************************************
2 *   Copyright (C) 2011 - iXsystems                                       *
3 *   kris@pcbsd.org  *
4 *   tim@pcbsd.org   *
5 *   ken@pcbsd.org   *
6 *                                                                         *
7 *   Permission is hereby granted, free of charge, to any person obtaining *
8 *   a copy of this software and associated documentation files (the       *
9 *   "Software"), to deal in the Software without restriction, including   *
10 *   without limitation the rights to use, copy, modify, merge, publish,   *
11 *   distribute, sublicense, and/or sell copies of the Software, and to    *
12 *   permit persons to whom the Software is furnished to do so, subject to *
13 *   the following conditions:                                             *
14 *                                                                         *
15 *   The above copyright notice and this permission notice shall be        *
16 *   included in all copies or substantial portions of the Software.       *
17 *                                                                         *
18 *   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,       *
19 *   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF    *
20 *   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
21 *   IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR     *
22 *   OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, *
23 *   ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR *
24 *   OTHER DEALINGS IN THE SOFTWARE.                                       *
25 ***************************************************************************/
26#ifndef _APPCAFE_LARGE_WIDGET_H
27#define _APPCAFE_LARGE_WIDGET_H
28
29#include <QWidget>
30#include <QToolButton>
31#include <QLabel>
32#include <QGridLayout>
33#include <QAction>
34#include <QString>
35#include <QIcon>
36#include <QHBoxLayout>
37#include <QPixmap>
38
39class LargeItemWidget : public QWidget{
40        Q_OBJECT
41       
42  private:
43    QString uniqueAppID; //should be something unique like <name>-<version>-<arch>     
44    QLabel *type;
45  signals:
46    void appClicked(QString);
47   
48  private slots:
49    void sendSignal(){ emit appClicked(uniqueAppID); }
50   
51  public:
52    LargeItemWidget(QString appID, QString name, QString description, QString icon) : QWidget(){
53
54      //Create the toolbutton
55      QToolButton *button = new QToolButton();
56        button->setIconSize(QSize(34,34));
57          QAction *act = new QAction( QIcon(icon), "", 0);
58        button->setDefaultAction(act);
59        button->setToolButtonStyle(Qt::ToolButtonIconOnly);
60
61      //Create the labels
62      QLabel *appName = new QLabel("<b>"+name+"</b>");
63            appName->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
64      QLabel *appDesc = new QLabel(description);
65        appDesc->setWordWrap(TRUE);
66      type = new QLabel();
67            //type->setScaledContents(true);
68            type->setVisible(false);
69      QHBoxLayout *hl = new QHBoxLayout;
70            hl->addWidget(appName);
71            hl->addWidget(type);
72      //Add the items to the widget
73      QGridLayout *layout = new QGridLayout;
74      layout->addWidget(button,0,0,2,1);
75      layout->addLayout(hl,0,1);
76      layout->addWidget(appDesc,1,1);
77      this->setLayout(layout);
78     
79      //Save the app identifier
80      uniqueAppID=appID;
81      connect(button,SIGNAL(clicked()), this, SLOT(sendSignal()) );
82    }
83    virtual ~LargeItemWidget(){}
84   
85    void setType(QString typ){
86      if(typ.toLower()=="graphical"){
87        type->setPixmap(QPixmap(":icons/graphicalapp.png").scaled(16,16));
88        type->setToolTip(tr("Graphical Application"));
89        type->setVisible(true);
90      }else if(typ.toLower()=="text"){
91        type->setPixmap(QPixmap(":icons/textapp.png").scaled(16,16));
92        type->setToolTip(tr("Command-line Application"));
93        type->setVisible(true);       
94      }else if(typ.toLower()=="server"){
95        type->setPixmap(QPixmap(":icons/serverapp.png").scaled(16,16));
96        type->setToolTip(tr("Server Application"));
97        type->setVisible(true);       
98      }else{
99        type->setVisible(false);             
100      }
101    }
102   
103  protected:
104    void mousePressEvent(QMouseEvent *ev){ Q_UNUSED(ev); sendSignal(); } 
105 
106         
107};
108
109#endif
Note: See TracBrowser for help on using the repository browser.