Esempio n. 1
0
//-----------------------------------------------------------------------------
// Window removed
//FIXME
void daisy::windowRemoved(WId id)
{
  if (!m_drawerscleared)clearDrawers();
  m_closingwindow = -1;
    
  KWindowInfo taskInfo = KWindowSystem::windowInfo( id, NET::WMName | NET::WMVisibleName , NET::WM2WindowClass );
  if ( m_alias.indexOf( taskInfo.windowClassName() ) != -1 )
  {
    m_closingwindow = m_alias.indexOf( taskInfo.windowClassName() );
    if ( m_showindicons )m_up_tmr->setInterval(1500);m_up_tmr->start();
  }
  else if ( m_alias.indexOf( QString(taskInfo.windowClassClass().toLower()) ) != -1 )
  {
    m_closingwindow = m_alias.indexOf( QString(taskInfo.windowClassClass().toLower()) );
    if ( m_showindicons )m_up_tmr->setInterval(1500);m_up_tmr->start();
  }
  else if ( m_alias.indexOf( taskInfo.name() ) != -1 )
  {
    m_closingwindow = m_alias.indexOf( taskInfo.name() );
    if ( m_showindicons )m_up_tmr->setInterval(1500);m_up_tmr->start();
  }
  else if ( m_alias.indexOf( taskInfo.visibleName() ) != -1 )
  {
    m_closingwindow = m_alias.indexOf( taskInfo.visibleName() );
    if ( m_showindicons )m_up_tmr->setInterval(1500);m_up_tmr->start();
  }
  
  else
  {
    getAllTasks();
  }
  
  
  if ( m_showindicons )emit update();
  
}
Esempio n. 2
0
//-----------------------------------------------------------------------------
// Get task
bool daisy::getTaskPtr( QString name  )
{
  
  QList<WId> taskDict = KWindowSystem::windows();
  QList<WId>::ConstIterator it;
  for (it = taskDict.begin(); it != taskDict.end(); ++it )
  {
    KWindowInfo taskInfo = KWindowSystem::windowInfo( *it, NET::WMName | NET::WMVisibleName, NET::WM2WindowClass );
    
    if ( taskInfo.windowClassName() == name || taskInfo.visibleName() == name || taskInfo.name() == name || QString(taskInfo.windowClassClass().toLower()) == name  )
    {
      m_task = TaskManager::TaskManager::self()->findTask( *it );
      return true;
    }
  }
  return false;
  
}
Esempio n. 3
0
void WindowList::showMenu(bool onlyCurrentDesktop)
{
    QList<WId> windows = KWindowSystem::windows();
    QList<QAction*> actionList;
    QList< QList<QAction*> > windowList;
    int amount = 0;
    int number = 0;

    qDeleteAll(m_listMenu->actions());
    //m_listMenu->clear();

    if (!onlyCurrentDesktop) {
        m_listMenu->addTitle(i18n("Actions"));

        QAction *unclutterAction = m_listMenu->addAction(i18n("Unclutter Windows"));
        QAction *cascadeAction = m_listMenu->addAction(i18n("Cascade Windows"));

        connect(unclutterAction, SIGNAL(triggered()), m_listMenu, SLOT(slotUnclutterWindows()));
        connect(cascadeAction, SIGNAL(triggered()), m_listMenu, SLOT(slotCascadeWindows()));
    }

    for (int i = 0; i <= KWindowSystem::numberOfDesktops(); ++i) {
        windowList.append(QList<QAction*>());
    }

    for (int i = 0; i < windows.count(); ++i) {
        KWindowInfo window = KWindowSystem::windowInfo(windows.at(i), (NET::WMGeometry | NET::WMFrameExtents | NET::WMWindowType | NET::WMDesktop | NET::WMState | NET::XAWMState | NET::WMVisibleName));
        NET::WindowType type = window.windowType(NET::NormalMask | NET::DialogMask | NET::OverrideMask | NET::UtilityMask | NET::DesktopMask | NET::DockMask | NET::TopMenuMask | NET::SplashMask | NET::ToolbarMask | NET::MenuMask);

        if ((onlyCurrentDesktop && !window.isOnDesktop(KWindowSystem::currentDesktop())) || type == NET::Desktop || type == NET::Dock || type == NET::TopMenu || type == NET::Splash || type == NET::Menu || type == NET::Toolbar || window.hasState(NET::SkipPager)) {
            windows.removeAt(i);

            --i;

            continue;
        }

        ++amount;

        QAction *action = new QAction(QIcon(KWindowSystem::icon(windows.at(i))), window.visibleName(), this);
        action->setData((unsigned long long) windows.at(i));

        QString window_title = QString(action->text());
        window_title.truncate(55);
        action->setText(window_title);

        QFont font = QFont(action->font());

        if (window.isMinimized()) {
            font.setItalic(true);
        } else if (KWindowSystem::activeWindow() == windows.at(i)) {
            font.setUnderline(true);
            font.setBold(true);
        }

        action->setFont(font);

        number = ((onlyCurrentDesktop || window.onAllDesktops()) ? 0 : window.desktop());

        QList<QAction*> subList = windowList.value(number);
        subList.append(action);

        windowList.replace(number, subList);
    }

    const bool useSubMenus = (!onlyCurrentDesktop && KWindowSystem::numberOfDesktops() > 1 && (amount / KWindowSystem::numberOfDesktops()) > 5);

    if (amount && useSubMenus) {
        m_listMenu->addTitle(i18n("Desktops"));
    }

    for (int i = 0; i <= KWindowSystem::numberOfDesktops(); ++i) {
        if (windowList.value(i).isEmpty()) {
            continue;
        }

        KMenu *subMenu = NULL;
        QAction *subMenuAction = NULL;
        QString title = (i ? KWindowSystem::desktopName(i) : (onlyCurrentDesktop ? i18n("Current desktop") : i18n("On all desktops")));

        if (useSubMenus) {
            subMenuAction = m_listMenu->addAction(title);

            subMenu = new KMenu(m_listMenu);
            subMenu->installEventFilter(this);
        } else {
            m_listMenu->addTitle(title);
        }

        for (int j = 0; j < windowList.value(i).count(); ++j) {
            if (useSubMenus) {
                subMenu->addAction(windowList.value(i).value(j));
            } else {
                m_listMenu->addAction(windowList.value(i).value(j));
            }
        }

        if (useSubMenus) {
            subMenuAction->setMenu(subMenu);
        }
    }

    if (!amount) {
        qDeleteAll(m_listMenu->actions());

        m_listMenu->clear();

        QAction *noWindows = m_listMenu->addAction(i18n("No windows"));
        noWindows->setEnabled(false);
    }

    if (formFactor() == Plasma::Vertical || formFactor() == Plasma::Horizontal) {
        m_listMenu->popup(popupPosition(m_listMenu->sizeHint()));
    } else {
        m_listMenu->popup(QCursor::pos());
    }
}
Esempio n. 4
0
//-----------------------------------------------------------------------------
// Create Drawers
void daisy::elabDrawers( QList<WId> taskDict, int clickedlaunch_tmp )
{
    m_drawerscleared = false;
    int i = 0;
    QRect drawerrect_tmp;
    bool invert_tmp = true;
    qreal rotval_tmp = 1.00;
    QList<WId>::ConstIterator it;
    for (it = taskDict.begin(); it != taskDict.end(); ++it )
    {

        KWindowInfo taskInfo = KWindowSystem::windowInfo( *it, NET::WMName | NET::WMVisibleName | NET::WMWindowType | NET::WMVisibleIconName , NET::WM2StartupId | NET::WM2WindowClass | NET::WM2WindowRole );

        QString visiconame_tmp = taskInfo.visibleIconName();
        QString visname_tmp = taskInfo.visibleName();
        QString iconame_tmp = m_values[clickedlaunch_tmp][2];

        m_drawericons << new Plasma::IconWidget( KIcon( iconame_tmp ), visiconame_tmp, this );
        m_drawericons[i]->setOrientation(Qt::Horizontal);
        m_drawericons[i]->setCursor(Qt::PointingHandCursor);
        m_drawericons[i]->setAcceptHoverEvents(true);
        m_drawericons[i]->setWindowFrameMargins(0,0,0,0);
        m_drawericons[i]->setNumDisplayLines(1);
        m_drawericons[i]->setDrawBackground(m_draw_icoback);
        //m_drawericons[i]->setToolTip ( visname_tmp );

        connect( m_drawericons[i], SIGNAL(clicked()), this, SLOT( drawerClicked() ) );
        m_drawericons[i]->installEventFilter(this);


        taskDrawers << *it;



        if ( m_position == QString("buttom_center") || m_position == QString("buttom_left") || m_position == QString("buttom_right") )
        {
            rotval_tmp = m_drawerrotation*i;
            invert_tmp = true;
            drawerrect_tmp = QRect( (drawerpopspot_x+(m_icodimension/1.5)+(5*i))-(m_drawersize*8.33), drawerpopspot_y - (m_drawersize*1.27),
                                    (m_drawersize*8.33), m_drawersize);
        }

        else if ( m_position == QString("top_center") || m_position == QString("top_left") || m_position == QString("top_right") )
        {
            rotval_tmp = -m_drawerrotation*i;
            invert_tmp = true;
            drawerrect_tmp = QRect( (drawerpopspot_x+(m_icodimension/1.5)+(5*i))-(m_drawersize*8.33), drawerpopspot_y + (m_icodimension*1.27),
                                    (m_drawersize*8.33), m_drawersize);
        }

        else if ( m_position == QString("left_center") || m_position == QString("left_top") || m_position == QString("left_buttom") )
        {
            rotval_tmp = -m_drawerrotation*i;
            invert_tmp = false;
            drawerrect_tmp = QRect( (drawerpopspot_x+(m_icodimension*1.3)+(5*i)), drawerpopspot_y,
                                    (m_drawersize*8.33), m_drawersize);
        }

        else if ( m_position == QString("right_center") || m_position == QString("right_top") || m_position == QString("right_buttom") )
        {
            rotval_tmp = m_drawerrotation*i;
            invert_tmp = true;
            drawerrect_tmp = QRect( (drawerpopspot_x-((m_drawersize*8.33)+m_icodimension/3)-(5*i)), drawerpopspot_y,
                                    (m_drawersize*8.33), m_drawersize);
        }




        m_drawericons[i]->invertLayout( invert_tmp );
        m_drawericons[i]->setGeometry( drawerrect_tmp );
        m_drawericons[i]->setTransform(QTransform().rotate(rotval_tmp));


        i++;

    }

    raise();
    emit update();


}