示例#1
0
void PanelKMenu::doNewSession( bool lock )
{
    int result = KMessageBox::warningContinueCancel(
        kapp->desktop()->screen(kapp->desktop()->screenNumber(this)),
        i18n("<p>You have chosen to open another desktop session.<br>"
               "The current session will be hidden "
               "and a new login screen will be displayed.<br>"
               "An F-key is assigned to each session; "
               "F%1 is usually assigned to the first session, "
               "F%2 to the second session and so on. "
               "You can switch between sessions by pressing "
               "Ctrl, Alt and the appropriate F-key at the same time. "
               "Additionally, the KDE Panel and Desktop menus have "
               "actions for switching between sessions.</p>",
                            7, 8),
        i18n("Warning - New Session"),
        KGuiItem(i18n("&Start New Session"), "fork"),
        KStandardGuiItem::cancel(),
        ":confirmNewSession",
        KMessageBox::PlainCaption | KMessageBox::Notify);

    if (result==KMessageBox::Cancel)
        return;

    if (lock)
        slotLock();

    KDisplayManager().startReserve();
}
CScrollerWidgetSet::CScrollerWidgetSet(QWidget *parent) : QWidget(parent) {
	m_layout = new QVBoxLayout(this);
	m_layout->setSpacing(0);
	m_layout->setContentsMargins(0,0,0,0);
	m_layout->setAlignment(this, Qt::AlignHCenter | Qt::AlignCenter);

	//setAlignment(Qt::AlignHCenter | Qt::AlignCenter);

	//TODO: old constructor gave "name" argument, is that needed? "btn_up" etc.
	btn_up = new QToolButton(this);
	btn_up->setArrowType(Qt::UpArrow);
	
	btn_up->setFixedSize(WIDTH, ARROW_HEIGHT);
	btn_up->setFocusPolicy(Qt::NoFocus);
	btn_up->setAutoRaise(true);

	btn_fx = new CScrollButton(this);
	btn_fx->setFixedSize(WIDTH, MOVER_HEIGHT);
	btn_fx->setFocusPolicy(Qt::NoFocus);

	btn_down = new QToolButton(this);
	btn_down->setArrowType(Qt::DownArrow);
	btn_down->setFixedSize(WIDTH, ARROW_HEIGHT);
	btn_down->setFocusPolicy(Qt::NoFocus);
	btn_down->setAutoRaise(true);

	m_layout->addWidget( btn_up,0 );
	m_layout->addWidget( btn_fx,0 );
	m_layout->addWidget( btn_down,0 );
	setMinimumWidth(WIDTH); // Kludge to add some spacing but seems to work.

	connect(btn_fx, SIGNAL(lock()), SLOT(slotLock()));
	connect(btn_fx, SIGNAL(unlock()), SLOT(slotUnlock()));
	connect(btn_fx, SIGNAL(change_requested(int)), SLOT(slotScroller(int)));
	connect(btn_up, SIGNAL(clicked()), SLOT(slotUpClick()));
	connect(btn_down, SIGNAL(clicked()), SLOT(slotDownClick()));
}
示例#3
0
void PanelKMenu::initialize()
{
//    kDebug(1210) << "PanelKMenu::initialize()";
    updateRecent();

    if (initialized())
    {
        return;
    }

    if (loadSidePixmap())
    {
        // in case we've been through here before, let's disconnect
        disconnect(KGlobalSettings::self(), SIGNAL(kdisplayPaletteChanged()),
                   this, SLOT(paletteChanged()));
        connect(KGlobalSettings::self(), SIGNAL(kdisplayPaletteChanged()),
                this, SLOT(paletteChanged()));
    }
    else
    {
        sidePixmap = sideTilePixmap = QPixmap();
    }

    // add services
    PanelServiceMenu::initialize();

    /*
     FIXME: no more insertTitle! now what?
    if (KickerSettings::showMenuTitles())
    {
        int id;
        id = insertTitle(i18n("All Applications"), -1, 0);
        setItemEnabled( id, false );
        id = insertTitle(i18n("Actions"), -1 , -1);
        setItemEnabled( id, false );
    }
    */

    // create recent menu section
    createRecentMenuItems();

    bool need_separator = false;

    // insert bookmarks
    if (KickerSettings::useBookmarks() && KAuthorized::authorizeKAction("bookmarks"))
    {
        // Need to create a new popup each time, it's deleted by subMenus.clear()
        KMenu * bookmarkParent = new KMenu(this);
        bookmarkParent->setObjectName("bookmarks" );
        delete bookmarkMenu; // can't reuse old one, the popup has been deleted
        bookmarkMenu = new KBookmarkMenu( KBookmarkManager::userBookmarksManager(), 0, bookmarkParent, actionCollection );

        insertItem(Plasma::menuIconSet("bookmark"),
                   i18n("Bookmarks"), bookmarkParent);

        subMenus.append(bookmarkParent);
        need_separator = true;
    }

    // insert quickbrowser
    if (KickerSettings::useBrowser())
    {
        PanelQuickBrowser *browserMnu = new PanelQuickBrowser(this);
        browserMnu->initialize();

        insertItem(Plasma::menuIconSet("kdisknav"),
                   i18n("Quick Browser"),
                   Plasma::reduceMenu(browserMnu));
        subMenus.append(browserMnu);
        need_separator = true;
    }

    // insert dynamic menus
    QStringList menu_ext = KickerSettings::menuExtensions();
    if (!menu_ext.isEmpty())
    {
        for (QStringList::ConstIterator it=menu_ext.begin(); it!=menu_ext.end(); ++it)
        {
            MenuInfo info(*it);
            if (!info.isValid())
               continue;

            KPanelMenu *menu = info.load();
            if (menu)
            {
                insertItem(Plasma::menuIconSet(info.icon()), info.name(), menu);
                dynamicSubMenus.append(menu);
                need_separator = true;
            }
        }
    }

    if (need_separator)
        addSeparator();

    // run command
    if (KAuthorized::authorizeKAction("run_command"))
    {
        insertItem(Plasma::menuIconSet("system-run"),
                   i18n("Run Command..."),
                   this,
                   SLOT( slotRunCommand()));
        addSeparator();
    }

    if (KDisplayManager().isSwitchable() && KAuthorized::authorizeKAction("switch_user"))
    {
        sessionsMenu = new QMenu( this );
        insertItem(Plasma::menuIconSet("switchuser"),
                   i18n("Switch User"), sessionsMenu);
        connect( sessionsMenu, SIGNAL(aboutToShow()), SLOT(slotPopulateSessions()) );
        connect( sessionsMenu, SIGNAL(activated(int)), SLOT(slotSessionActivated(int)) );
    }

    /*
      If  the user configured ksmserver to
    */
    KConfig ksmserver("ksmserverrc", KConfig::CascadeConfig);
    if (ksmserver.group("General").readEntry( "loginMode" ) == "restoreSavedSession")
    {
        insertItem(Plasma::menuIconSet("document-save"),
                   i18n("Save Session"), this, SLOT(slotSaveSession()));
    }

    if (KAuthorized::authorizeKAction("lock_screen"))
    {
        insertItem(Plasma::menuIconSet("system-lock-screen"),
                   i18n("Lock Session"), this, SLOT(slotLock()));
    }

    if (KAuthorized::authorizeKAction("logout"))
    {
        insertItem(Plasma::menuIconSet("application-exit"),
                   i18n("Log Out..."), this, SLOT(slotLogout()));
    }

#if 0
    // WABA: tear off handles don't work together with dynamically updated
    // menus. We can't update the menu while torn off, and we don't know
    // when it is torn off.
    if (KGlobalSettings::insertTearOffHandle())
      insertTearOffHandle();
#endif

    setInitialized(true);
}
示例#4
0
void MenuActions::initialize()
{
    bool need_separator = false;
    QStringList menu_ext = KickerSettings::menuExtensions();
    if (!menu_ext.isEmpty())
    {
        if (!menu_ext.grep("prefmenu.desktop").isEmpty())
        {
            //moves the Configuration menu to the top because that's where I
            //think it belongs.
            menu_ext.remove("prefmenu.desktop");
            insertDynamicMenu("prefmenu.desktop");
            insertSeparator();
        }

        if (!menu_ext.grep("remotemenu.desktop").isEmpty())
        {
            //removed here because we use it in menu_desktop.cpp
            menu_ext.remove("remotemenu.desktop");
        }

        for (QStringList::ConstIterator it=menu_ext.begin(); it!=menu_ext.end(); ++it)
        {
            insertDynamicMenu(*it);
            need_separator = true;
        }
    }

    if (need_separator)
        insertSeparator();

    // insert client menus, if any
    if (clients.count() > 0)
    {
        QIntDictIterator<MenuClient> it(clients);
        while (it)
        {
            if (it.current()->text.at(0) != '.')
                insertItem(
                    it.current()->icon,
                    it.current()->text,
                    it.current(),
                    it.currentKey()
                    );
            ++it;
        }
        insertSeparator();
    }

    if (DM().isSwitchable())
    {
        if (!need_separator)
            insertSeparator();

        m_sessionsMenu = new QPopupMenu(this);

        if (KickerSettings::menuEntryHeight() > -1)
        {

            QString faceIcon = QString("%1/.face.icon").arg(QDir::homeDirPath());
            if (QFile::exists(faceIcon) == true)
            {
                insertItem(SmallIconSet(faceIcon, KickerSettings::menuEntryHeight()),
                           i18n("Switch User"),
                           m_sessionsMenu);
            }
            else
            {
                insertItem(SmallIconSet("switchuser",
                           KickerSettings::menuEntryHeight()),
                           i18n("Switch User"),
                           m_sessionsMenu);
            }
        }
        else
        {
            insertItem(i18n("Switch User"), m_sessionsMenu);
        }

        connect( m_sessionsMenu, SIGNAL(aboutToShow()),
                 SLOT(slotPopulateSessions()) );
        connect( m_sessionsMenu, SIGNAL(activated(int)),
                 SLOT(slotSessionActivated(int)) );
    }

    insertSeparator();

    KConfig ksmserver("ksmserverrc", false, false);
    ksmserver.setGroup("General");

    if (ksmserver.readEntry("loginMode") == "restoreSavedSession")
    {
        if (KickerSettings::menuEntryHeight() > -1)
        {
            insertItem(SmallIconSet("filesave", KickerSettings::menuEntryHeight()),
                       i18n("Save Session"),
                       this,
                       SLOT(slotSaveSession())
                      );
        }
        else
        {
            insertItem(i18n("Save Session"), this, SLOT(slotSaveSession()));
        }
    }

    if (kapp->authorize("lock_session"))
    {
        if (KickerSettings::menuEntryHeight() > -1)
        {
            insertItem(SmallIconSet("lock", KickerSettings::menuEntryHeight()),
                       i18n("Lock Session"),
                       this,
                       SLOT(slotLock())
                      );
        }
        else
        {
            insertItem(i18n("Lock Session"), this, SLOT(slotLock()));
        }
    }

    if (kapp->authorize("logout"))
    {
        if (KickerSettings::menuEntryHeight() > -1)
        {
            insertItem(SmallIconSet("exit", KickerSettings::menuEntryHeight()),
                       i18n("Log Out..."),
                       this,
                       SLOT(slotLogout())
                      );
        }
        else
        {
            insertItem(i18n("Log Out..."), this, SLOT(slotLogout()));
        }
    }
    setInitialized( true );
}
TLLayerManager::TLLayerManager( QWidget *parent, QWidget *grandparent )
    : QWidget( parent )
{
    Q_CHECK_PTR( parent );
    Q_CHECK_PTR( grandparent );
    
    //Initializations
    resize( 200, 150 );
    parent_widget = parent;
    grandparent_widget = grandparent;
    eye_status = EYE_DESELECT_ALL;
    lock_status = LOCK_ALL;
    square_status = SQUARE_SELECT_ALL;
    current_time = 0.0;
    total_time = 0.04;

    //------------- Icon initializations --------------------

    i_eye = QPixmap( show_hide_all_layers_xpm );
    i_lock = QPixmap( kilit_pic_xpm );
    i_square = QPixmap( outline_pic_xpm );
    i_insert_layer = QPixmap( layerplus_xpm );
    i_remove_layer = QPixmap( layerminus_xpm );
    i_move_layer_up = QPixmap( arrowup_xpm );
    i_move_layer_down = QPixmap( arrowdown_xpm );

    //---------- Top Panel ---------------

    utils = new QFrame( this );
    utils -> setFrameStyle( QFrame::Box | QFrame::Plain );
    utils -> resize( 192, 24 );
    utils -> setMinimumSize( 192, 24 );
    utils -> move( 0, 0 );

    square = new QPushButton( i_square, tr( "" ), utils );
    square -> setFlat( true );
    square -> setAutoDefault( false );
    square -> resize( 20, 20 );
    square -> move( utils -> width() - square -> width() - 22, 2 );
    connect( square, SIGNAL( clicked() ), SLOT( slotSquare() ) );
    QToolTip::add( square, tr( "Show only outlines" ) );

    lock = new QPushButton( i_lock, tr( "" ), utils );
    lock -> setFlat( true );
    lock -> setAutoDefault( false );
    lock -> resize( 20, 20 );
    lock -> move( square -> x() - lock -> width() - 2, 2 );
    connect( lock, SIGNAL( clicked() ), SLOT( slotLock() ) );
    QToolTip::add( lock, tr( "Lock all Layers" ) );

    eye = new QPushButton( i_eye, tr( "" ), utils );
    eye -> setFlat( true );
    eye -> setAutoDefault( false );
    eye -> resize( 20, 20 );
    eye -> move( lock -> x() - eye -> width() - 2, 2 );
    connect( eye, SIGNAL( clicked() ), SLOT( slotEye() ) );
    QToolTip::add( eye, tr( "Show / Hide all Layers" ) );

    //Layer Sequence Initialization
    layer_sequence = new TLLayerSequence( this );
    layer_sequence -> move( 0, utils -> height() );
    layer_sequence -> resize( 200, 90 );
    layer_sequence -> resizeContents( 200, 90 );
    connect( this, SIGNAL( frameSelected( TLFrameSequence * ) ), layer_sequence, SLOT( slotSelectLayerFromFrameSelected( TLFrameSequence * ) ) );
    connect( layer_sequence, SIGNAL( layerSelected( TLLayer* ) ), SIGNAL( layerSelected( TLLayer* ) ) );
    connect( layer_sequence, SIGNAL( layerReleasedAbove( int, int ) ), SIGNAL( layerReleasedAbove( int, int ) ) );
    connect( layer_sequence, SIGNAL( layerReleasedBelow( int, int ) ), SIGNAL( layerReleasedBelow( int, int ) ) );

    //---------- Bottom Panel ---------------

    utils2 = new QFrame( this );
    utils2 -> setFrameStyle( QFrame::Box | QFrame::Plain );
    utils2 -> resize( 192, 24 );
    utils2 -> setMinimumSize( 192, 24 );
    utils2 -> move( 0, layer_sequence -> height() + layer_sequence -> y() );

    insert_layer = new QPushButton( i_insert_layer, tr( "" ), utils2 );
    insert_layer -> setFlat( true );
    insert_layer -> setAutoDefault( false );
    insert_layer -> resize( 20, 20 );
    insert_layer -> move( 2, 2 );
    connect( insert_layer, SIGNAL( clicked() ), layer_sequence, SLOT( slotInsertLayer() ) );
    connect( insert_layer, SIGNAL( clicked() ), grandparent, SIGNAL( insertLayerClicked() ) );
    QToolTip::add( insert_layer, tr( "Insert Layer" ) );

    remove_layer = new QPushButton( i_remove_layer, tr( "" ), utils2 );
    remove_layer -> setFlat( true );
    remove_layer -> setAutoDefault( false );
    remove_layer -> resize( 20, 20 );
    remove_layer -> move( insert_layer -> x() + insert_layer -> width() + 2, 2 );
    connect( remove_layer, SIGNAL( clicked() ), layer_sequence, SLOT( slotRemoveLayer() ) );
    connect( remove_layer, SIGNAL( clicked() ), grandparent, SIGNAL( removeLayerClicked() ) );
    QToolTip::add( remove_layer, tr( "Remove Layer" ) );

    move_layer_up = new QPushButton( i_move_layer_up, tr( "" ), utils2 );
    move_layer_up -> setFlat( true );
    move_layer_up -> setAutoDefault( false );
    move_layer_up -> resize( 20, 20 );
    move_layer_up -> move( remove_layer -> x() + remove_layer -> width() + 2, 2 );
    connect( move_layer_up, SIGNAL( clicked() ), layer_sequence, SLOT( slotMoveLayerUp() ) );
    connect( move_layer_up, SIGNAL( clicked() ), grandparent, SIGNAL( layerMovedUp() ) );
    QToolTip::add( move_layer_up, tr( "Move Layer Up" ) );

    move_layer_down = new QPushButton( i_move_layer_down, tr( "" ), utils2 );
    move_layer_down -> setFlat( true );
    move_layer_down -> setAutoDefault( false );
    move_layer_down -> resize( 20, 20 );
    move_layer_down -> move( move_layer_up -> x() + move_layer_up -> width() + 2, 2 );
    connect( move_layer_down, SIGNAL( clicked() ), layer_sequence, SLOT( slotMoveLayerDown() ) );
    connect( move_layer_down, SIGNAL( clicked() ), grandparent, SIGNAL( layerMovedDown() ) );
    QToolTip::add( move_layer_down, tr( "Move Layer Down" ) );

    time = new QLabel( QString::number( current_time, 'f', 2 ) + " / " + QString::number( total_time, 'f', 2 ), utils2 );
    time -> setFont( QFont( "helvetica", 7 ) );
    time -> setAlignment( Qt::AlignCenter );
    time -> resize( 80, 20 );
    time -> move( utils2 -> width() - time -> width(), 2 );
}
示例#6
0
void PanelKMenu::initialize()
{
//    kdDebug(1210) << "PanelKMenu::initialize()" << endl;
    updateRecent();

    if (initialized())
    {
        return;
    }

    if (loadSidePixmap())
    {
        // in case we've been through here before, let's disconnect
        disconnect(kapp, SIGNAL(kdisplayPaletteChanged()),
                   this, SLOT(paletteChanged()));
        connect(kapp, SIGNAL(kdisplayPaletteChanged()),
                this, SLOT(paletteChanged()));
    }
    else
    {
        sidePixmap = sideTilePixmap = QPixmap();
    }

    // add services
    PanelServiceMenu::initialize();

    if (KickerSettings::showMenuTitles())
    {
        int id;
        id = insertItem(new PopupMenuTitle(i18n("All Applications"), font()), -1 /* id */, 0);
        setItemEnabled( id, false );
        id = insertItem(new PopupMenuTitle(i18n("Actions"), font()), -1 /* id */, -1);
        setItemEnabled( id, false );
    }

    // create recent menu section
    createRecentMenuItems();

    bool need_separator = false;

    // insert bookmarks
    if (KickerSettings::useBookmarks() && kapp->authorizeKAction("bookmarks"))
    {
        // Need to create a new popup each time, it's deleted by subMenus.clear()
        KPopupMenu * bookmarkParent = new KPopupMenu( this, "bookmarks" );
        if(!bookmarkOwner)
            bookmarkOwner = new KBookmarkOwner;
        delete bookmarkMenu; // can't reuse old one, the popup has been deleted
        bookmarkMenu = new KBookmarkMenu( KonqBookmarkManager::self(), bookmarkOwner, bookmarkParent, actionCollection, true, false );

        insertItem(KickerLib::menuIconSet("bookmark"), i18n("Bookmarks"), bookmarkParent);

        subMenus.append(bookmarkParent);
        need_separator = true;
    }

    // insert quickbrowser
    if (KickerSettings::useBrowser())
    {
        PanelQuickBrowser *browserMnu = new PanelQuickBrowser(this);
        browserMnu->initialize();

        insertItem(KickerLib::menuIconSet("kdisknav"),
                   i18n("Quick Browser"),
                   KickerLib::reduceMenu(browserMnu));
        subMenus.append(browserMnu);
        need_separator = true;
    }

    // insert dynamic menus
    QStringList menu_ext = KickerSettings::menuExtensions();
    if (!menu_ext.isEmpty())
    {
        for (QStringList::ConstIterator it=menu_ext.begin(); it!=menu_ext.end(); ++it)
        {
            MenuInfo info(*it);
            if (!info.isValid())
               continue;

            KPanelMenu *menu = info.load();
            if (menu)
            {
                insertItem(KickerLib::menuIconSet(info.icon()), info.name(), menu);
                dynamicSubMenus.append(menu);
                need_separator = true;
            }
        }
    }

    if (need_separator)
        insertSeparator();

    // insert client menus, if any
    if (clients.count() > 0) {
        QIntDictIterator<KickerClientMenu> it(clients);
        while (it){
            if (it.current()->text.at(0) != '.')
                insertItem(
                    it.current()->icon,
                    it.current()->text,
                    it.current(),
                    it.currentKey()
                    );
            ++it;
        }
        insertSeparator();
    }

    // run command
    if (kapp->authorize("run_command"))
    {
        insertItem(KickerLib::menuIconSet("run"),
                   i18n("Run Command..."),
                   this,
                   SLOT( slotRunCommand()));
        insertSeparator();
    }

    if (DM().isSwitchable() && kapp->authorize("switch_user"))
    {
        sessionsMenu = new QPopupMenu( this );
        insertItem(KickerLib::menuIconSet("switchuser"), i18n("Switch User"), sessionsMenu);
        connect( sessionsMenu, SIGNAL(aboutToShow()), SLOT(slotPopulateSessions()) );
        connect( sessionsMenu, SIGNAL(activated(int)), SLOT(slotSessionActivated(int)) );
    }

    /*
      If  the user configured ksmserver to
    */
    KConfig ksmserver("ksmserverrc", false, false);
    ksmserver.setGroup("General");
    if (ksmserver.readEntry( "loginMode" ) == "restoreSavedSession")
    {
        insertItem(KickerLib::menuIconSet("filesave"), i18n("Save Session"), this, SLOT(slotSaveSession()));
    }

    if (kapp->authorize("lock_screen"))
    {
        insertItem(KickerLib::menuIconSet("lock"), i18n("Lock Session"), this, SLOT(slotLock()));
    }

    if (kapp->authorize("logout"))
    {
        insertItem(KickerLib::menuIconSet("exit"), i18n("Log Out..."), this, SLOT(slotLogout()));
    }

#if 0
    // WABA: tear off handles don't work together with dynamically updated
    // menus. We can't update the menu while torn off, and we don't know
    // when it is torn off.
    if (KGlobalSettings::insertTearOffHandle())
      insertTearOffHandle();
#endif

    setInitialized(true);
}