aboutsummaryrefslogtreecommitdiff
path: root/src-qt5/core/lumina-desktop/panel-plugins/jsonmenu/PPJsonMenu.cpp
blob: 14880f9ba6585dec188b44ce352bd7e7c5b521d5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
//===========================================
//  Lumina Desktop source code
//  Copyright (c) 2016, Ken Moore
//  Available under the 3-clause BSD license
//  See the LICENSE file for full details
//===========================================
#include "PPJsonMenu.h"
#include "../../JsonMenu.h"

LPJsonMenu::LPJsonMenu(QWidget *parent, QString id, bool horizontal) : LPPlugin(parent, id, horizontal){
  //Setup the button
    button = new QToolButton(this);
    button->setAutoRaise(true);
    button->setToolButtonStyle(Qt::ToolButtonIconOnly);
    button->setPopupMode(QToolButton::InstantPopup); //make sure it runs the update routine first
    //connect(button, SIGNAL(clicked()), this, SLOT(openMenu()));
    this->layout()->setContentsMargins(0,0,0,0);
    this->layout()->addWidget(button);
  //Parse the id and get the extra information needed for the plugin
  QStringList info = id.section("---",0,0).split("::::"); //FORMAT:[ "jsonmenu---<number>",exec,name, icon(optional)]
  if(info.length()>=3){
        qDebug() << "Custom JSON Menu Loaded:" << info;
        JsonMenu *menu = new JsonMenu(info[1], button);
        button->setText(info[2]);
        //connect(menu, SIGNAL(triggered(QAction*)), this, SLOT(SystemApplication(QAction*)) );
        if(info.length()>=4){ button->setIcon( LXDG::findIcon(info[3],"run-build") ); }
        else{ button->setIcon( LXDG::findIcon("run-build","") ); }
        button->setMenu(menu);
      }
  //Now start up the widgets
  QTimer::singleShot(0,this,SLOT(OrientationChange()) ); //update the sizing/icon
}

LPJsonMenu::~LPJsonMenu(){
}
bgstack15