Changeset 0b8acbb3


Ignore:
Timestamp:
05/08/14 10:45:41 (16 months ago)
Author:
susannej <susanne_j@…>
Branches:
master, enter/10, releng/10.0.2, releng/10.0.3, releng/10.1, releng/10.1.1, releng/10.1.2, releng/10.2, stable/10
Children:
eaea8ff, 02d90f1
Parents:
7ae73d3
Message:

another icon selected for the switcher, several code changes and enhancements

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lumina/lumina-desktop/panel-plugins/desktopswitcher/LDesktopSwitcher.cpp

    r7ae73d3 r0b8acbb3  
    77#include "LDesktopSwitcher.h" 
    88 
    9 LDesktopSwitcher::LDesktopSwitcher(QWidget *parent) : LPPlugin(parent, "desktopswitcher"){ 
     9LDesktopSwitcher::LDesktopSwitcher(QWidget *parent) : LPPlugin(parent, "desktopswitcher") { 
    1010  iconOld = -1; 
     11 
    1112  //Setup the widget 
    1213  label = new LTBWidget(this); 
    13   label->setIcon( LXDG::findIcon("kde-windows", ":/images/kde-windows.png") ); 
     14  label->setIcon( LXDG::findIcon("preferences-desktop-display-color", ":/images/preferences-desktop-display-color.png") ); 
     15  label->setToolTip(QString("Workspace 1")); 
    1416  menu = new QMenu(this); 
    1517  connect(menu, SIGNAL(triggered(QAction*)), this, SLOT(menuActionTriggered(QAction*))); 
    1618  label->setMenu(menu); 
    1719  this->layout()->addWidget(label); 
     20 
     21  // Maybe a timer should be set to set the toolTip of the button, 
     22  // becasue the workspace could be switched via Keyboard-shortcuts ... 
    1823 
    1924  createMenu(); 
     
    2328} 
    2429 
    25 void LDesktopSwitcher::setNumberOfDesktops(int number) 
    26 { 
    27         Display *display = QX11Info::display(); 
    28         Window rootWindow = QX11Info::appRootWindow(); 
     30void LDesktopSwitcher::setNumberOfDesktops(int number) { 
     31  Display *display = QX11Info::display(); 
     32  Window rootWindow = QX11Info::appRootWindow(); 
    2933 
    30         Atom atom = XInternAtom(display, "_NET_NUMBER_OF_DESKTOPS", False); 
    31         XEvent xevent; 
    32         xevent.type                 = ClientMessage; 
    33         xevent.xclient.type         = ClientMessage;  
    34         xevent.xclient.display      = display; 
    35         xevent.xclient.window       = rootWindow; 
    36         xevent.xclient.message_type = atom; 
    37         xevent.xclient.format       = 32; 
    38         xevent.xclient.data.l[0]    = number; 
    39         xevent.xclient.data.l[1]    = CurrentTime; 
    40         xevent.xclient.data.l[2]    = 0; 
    41         xevent.xclient.data.l[3]    = 0; 
    42         xevent.xclient.data.l[4]    = 0; 
    43         XSendEvent(display, rootWindow, False, SubstructureNotifyMask | SubstructureRedirectMask, &xevent); 
     34  Atom atom = XInternAtom(display, "_NET_NUMBER_OF_DESKTOPS", False); 
     35  XEvent xevent; 
     36  xevent.type                 = ClientMessage; 
     37  xevent.xclient.type         = ClientMessage;  
     38  xevent.xclient.display      = display; 
     39  xevent.xclient.window       = rootWindow; 
     40  xevent.xclient.message_type = atom; 
     41  xevent.xclient.format       = 32; 
     42  xevent.xclient.data.l[0]    = number; 
     43  xevent.xclient.data.l[1]    = CurrentTime; 
     44  xevent.xclient.data.l[2]    = 0; 
     45  xevent.xclient.data.l[3]    = 0; 
     46  xevent.xclient.data.l[4]    = 0; 
     47  XSendEvent(display, rootWindow, False, SubstructureNotifyMask | SubstructureRedirectMask, &xevent); 
    4448 
    45         XFlush(display); 
     49  XFlush(display); 
    4650} 
    4751 
    48 void LDesktopSwitcher::setCurrentDesktop(int number) 
    49 { 
    50         Display *display = QX11Info::display(); 
    51         Window rootWindow = QX11Info::appRootWindow(); 
     52void LDesktopSwitcher::setCurrentDesktop(int number) { 
     53  Display *display = QX11Info::display(); 
     54  Window rootWindow = QX11Info::appRootWindow(); 
    5255 
    53         Atom atom = XInternAtom(display, "_NET_CURRENT_DESKTOP", False); 
    54         XEvent xevent; 
    55         xevent.type                 = ClientMessage; 
    56         xevent.xclient.type         = ClientMessage;  
    57         xevent.xclient.display      = display; 
    58         xevent.xclient.window       = rootWindow; 
    59         xevent.xclient.message_type = atom; 
    60         xevent.xclient.format       = 32; 
    61         xevent.xclient.data.l[0]    = number; 
    62         xevent.xclient.data.l[1]    = CurrentTime; 
    63         xevent.xclient.data.l[2]    = 0; 
    64         xevent.xclient.data.l[3]    = 0; 
    65         xevent.xclient.data.l[4]    = 0; 
    66         XSendEvent(display, rootWindow, False, SubstructureNotifyMask | SubstructureRedirectMask, &xevent); 
     56  Atom atom = XInternAtom(display, "_NET_CURRENT_DESKTOP", False); 
     57  XEvent xevent; 
     58  xevent.type                 = ClientMessage; 
     59  xevent.xclient.type         = ClientMessage;  
     60  xevent.xclient.display      = display; 
     61  xevent.xclient.window       = rootWindow; 
     62  xevent.xclient.message_type = atom; 
     63  xevent.xclient.format       = 32; 
     64  xevent.xclient.data.l[0]    = number; 
     65  xevent.xclient.data.l[1]    = CurrentTime; 
     66  xevent.xclient.data.l[2]    = 0; 
     67  xevent.xclient.data.l[3]    = 0; 
     68  xevent.xclient.data.l[4]    = 0; 
     69  XSendEvent(display, rootWindow, False, SubstructureNotifyMask | SubstructureRedirectMask, &xevent); 
    6770 
    68         XFlush(display); 
     71  XFlush(display); 
    6972} 
    7073 
    71 int LDesktopSwitcher::getNumberOfDesktops(){ 
     74int LDesktopSwitcher::getNumberOfDesktops() { 
    7275  int number = -1; 
    7376  Atom a = XInternAtom(QX11Info::display(), "_NET_NUMBER_OF_DESKTOPS", true); 
     
    8588} 
    8689 
    87 int LDesktopSwitcher::getCurrentDesktop(){ 
     90int LDesktopSwitcher::getCurrentDesktop() { 
    8891  int number = -1; 
    8992  Atom a = XInternAtom(QX11Info::display(), "_NET_CURRENT_DESKTOP", true); 
     
    102105 
    103106QAction* LDesktopSwitcher::newAction(int what, QString name) { 
    104   QAction *act = new QAction(LXDG::findIcon("kde-windows", ":/images/kde-windows.png"), name, this); 
     107  QAction *act = new QAction(LXDG::findIcon("preferences-desktop-display-color", ":/images/preferences-desktop-display-color.png"), name, this); 
    105108  act->setWhatsThis(QString::number(what)); 
    106109  return act; 
    107110} 
    108111 
    109 void LDesktopSwitcher::createMenu(){ 
     112void LDesktopSwitcher::createMenu() { 
    110113  qDebug() << "-- vor getCurrentDesktop SWITCH"; 
    111114  qDebug() << getCurrentDesktop(); 
     
    118121void LDesktopSwitcher::menuActionTriggered(QAction* act) { 
    119122  setCurrentDesktop(act->whatsThis().toInt()); 
     123  label->setToolTip(QString("Workspace %1").arg(act->whatsThis().toInt() +1)); 
    120124} 
Note: See TracChangeset for help on using the changeset viewer.