aboutsummaryrefslogtreecommitdiff
path: root/lumina-desktop/panel-plugins/systemtray/LSysTray.h
blob: 13eb0df1ad722c229dfaa525cce7ef781a402704 (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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
//===========================================
//  Lumina-DE source code
//  Copyright (c) 2012, Ken Moore
//  Available under the 3-clause BSD license
//  See the LICENSE file for full details
//===========================================
#ifndef _LUMINA_DESKTOP_SYSTRAY_H
#define _LUMINA_DESKTOP_SYSTRAY_H

//Qt includes
#include <QFrame>
#include <QHBoxLayout>
#include <QDebug>
#include <QX11Info>
#include <QX11EmbedContainer>
#include <QCoreApplication>

//Local includes
#include "../LPPlugin.h"
#include "TrayIcon.h"

//SYSTEM TRAY STANDARD DEFINITIONS
#define SYSTEM_TRAY_REQUEST_DOCK 0
#define SYSTEM_TRAY_BEGIN_MESSAGE 1
#define SYSTEM_TRAY_CANCEL_MESSAGE 2

class LSysTray : public LPPlugin{
	Q_OBJECT
public:
	LSysTray(QWidget *parent = 0, QString id="systemtray", bool horizontal=true);
	~LSysTray();

	void start();
	void stop();

private:
	bool isRunning;
	QList<TrayIcon*> trayIcons;
	QFrame *frame;
	QBoxLayout *LI; //layout items
	WId TrayID;
	QTimer *upTimer; //manual timer to force refresh of all items
	
private slots:
	void checkXEvent(XEvent *event);
	void closeAll();
	void checkAll();

	void initialTrayIconDetect(); //initial scan for previously running tray apps
	void addTrayIcon(WId win);
	void removeTrayIcon(WId win);

	void updateStatus();
	void trayAppClosed();

public slots:
	virtual void OrientationChange(){
	   //make sure the internal layout has the same orientation as the main widget
	   LI->setDirection( this->layout()->direction() );
	   //Re-adjust the maximum widget size
	  int sz;
	  if(this->layout()->direction()==QBoxLayout::LeftToRight){
	    this->setMaximumSize( trayIcons.length()*this->height(), 10000);
	    sz = this->height()-2*frame->frameWidth();
	  }else{
	    this->setMaximumSize(10000, trayIcons.length()*this->width());
	    sz = this->width()-2*frame->frameWidth();
	  }
	  for(int i=0; i<trayIcons.length(); i++){
	    trayIcons[i]->setSizeSquare(sz);
	    trayIcons[i]->repaint();
	  }
	}
};

#endif
bgstack15