aboutsummaryrefslogtreecommitdiff
path: root/src-qt5/core/lumina-desktop-unified/src-desktop/src-widgets/plugins/NetworkButton.cpp
blob: 1108878da3f107fbe79c249dcecb0e7d8132b8bf (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
36
//===========================================
//  Lumina-desktop source code
//  Copyright (c) 2018, Ken Moore
//  Available under the 3-clause BSD license
//  See the LICENSE file for full details
//===========================================
#include "NetworkButton.h"
#include <global-objects.h>

NetworkButton::NetworkButton(QWidget *parent) : QToolButton(parent){
  this->setAutoRaise(true);
  this->setPopupMode(QToolButton::InstantPopup);
  this->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
  //Setup the menu

  //Now start the initial update routine in a moment
  connect(OSInterface::instance(), SIGNAL(networkStatusChanged()), this, SLOT(updateButton()) );
  QTimer::singleShot(10, this, SLOT(updateButton()) );
}

NetworkButton::~NetworkButton(){

}

void NetworkButton::updateButton(){
  this->setIcon( QIcon::fromTheme( OSInterface::instance()->networkIcon() ) );
  //Now get all the info about the battery for the tooltip
  this->setToolTip( OSInterface::instance()->networkStatus() );
  //qDebug() << "Network Button Sync:" << OSInterface::instance()->networkIcon();
}

void NetworkButton::buttonClicked(){
  if(OSInterface::instance()->hasNetworkManager()){
    LSession::instance()->LaunchStandardApplication( OSInterface::instance()->networkManagerUtility() );
  }
}
bgstack15