1 //===========================================
2 //  Lumina-DE source code
3 //  Copyright (c) 2014, Ken Moore
4 //  Available under the 3-clause BSD license
5 //  See the LICENSE file for full details
6 //===========================================
7 #ifndef _LUMINA_DESKTOP_TASK_BUTTON_H
8 #define _LUMINA_DESKTOP_TASK_BUTTON_H
9 
10 // Qt includes
11 #include <QWidget>
12 #include <QList>
13 #include <QIcon>
14 #include <QCursor>
15 #include <QMenu>
16 #include <QEvent>
17 #include <QAction>
18 #include <QTimer>
19 
20 // libLumina includes
21 #include <LuminaXDG.h>
22 #include <LuminaX11.h>
23 
24 // Local includes
25 #include "../../LWinInfo.h"
26 #include "../LTBWidget.h"
27 
28 class LTaskButton : public LTBWidget{
29 	Q_OBJECT
30 public:
31 	LTaskButton(QWidget *parent=0, bool smallDisplay = true);
32 	~LTaskButton();
33 
34 	//Window Information
35 	QList<WId> windows();
36 	QString classname();
37 	bool isActive();
38 
39 	//Window Management
40 	void addWindow(WId win); //Add a window to this button
41 	void rmWindow(WId win); //Remove a window from this button
42 
43 private:
44 	QList<LWinInfo> WINLIST;
45 	QList<LWinInfo> LWINLIST;
46 	QMenu *actMenu; // action menu (custom context menu)
47 	QMenu *winMenu; // window menu (if more than 1)
48 	LWinInfo cWin;
49 	QString cname; //class name for the entire button
50 	bool noicon, showText;
51 
52 	LWinInfo currentWindow(); //For getting the currently-active window
53 	LXCB::WINDOWVISIBILITY cstate; //current state of the button
54 
55 public slots:
56 	void UpdateButton(); //re-sync the current window infomation
57 	void UpdateMenus(); //re-create the menus (text + icons)
58 
59 private slots:
60 
61 	void buttonClicked();
62 	void closeWindow(); //send the signal to close a window
63 	void maximizeWindow(); //send the signal to maximize/restore a window
64 	void minimizeWindow(); //send the signal to minimize a window (iconify)
65 	void showAllWindows();
66 	void hideAllWindows();
67 	void closeAllWindows();
68 	void triggerWindow(); //change b/w visible and invisible
69 	void winClicked(QAction*);
70 	void openActionMenu();
71 protected:
changeEvent(QEvent * ev)72 	void changeEvent(QEvent *ev){
73 	  LTBWidget::changeEvent(ev);
74 	  QEvent::Type tmp = ev->type();
75 	  if(tmp==QEvent::ThemeChange || tmp==QEvent::LanguageChange || tmp==QEvent::LocaleChange){
76 	    QTimer::singleShot(qrand()%100+500, this, SLOT(UpdateButton()) );
77 	  }
78 	}
79 signals:
80 	void MenuClosed();
81 };
82 #endif
83