Example #1
0
void SpawnPointListMenu::init_menu()
{
  setItemEnabled(m_id_rename, (m_currentItem != NULL));
  setItemEnabled(m_id_delete, (m_currentItem != NULL));

  // make sure the menu bar settings are correct
  for (int i = 0; i < tSpawnPointMaxCols; i++)
    setItemChecked(m_id_cols[i], 
		   m_spawnPointList->columnVisible(i));
}
Example #2
0
void KAccel::connectItem( const char * action,
			  const QObject* receiver, const char* member,
			  bool activate )
{
  if (!action)
    return;
    KKeyEntry *pEntry = aKeyDict[ action ];

	if ( !pEntry ) {
		QString str;
		str.sprintf( "KAccel : Cannot connect action %s ", action );
		str.append( "which is not in the object dictionary" );
		warning(str);
		return;
	}
	
	pEntry->receiver = receiver;
	pEntry->member = member;
	pEntry->aAccelId = aAvailableId;
	aAvailableId++;
	
	pAccel->insertItem( pEntry->aCurrentKeyCode, pEntry->aAccelId );
	pAccel->connectItem( pEntry->aAccelId, receiver, member );
	
	if ( !activate )
		setItemEnabled( action, FALSE );
}
void MPToolBox::EnableMediationsTable(MediationTableSortTypes sortType)
{
    if(!_mpBrowser)
    {
        _mpBrowser = new MediationBrowser(this, sortType);
        connect(_mpBrowser, SIGNAL(on_mediationProcessSelected(MediationProcess*)), this, SLOT(DoMPSelected(MediationProcess*)));
        _mpBrowserIndex = this->addItem(_mpBrowser, TNAME_PROCESSES);
        setItemEnabled(_mpBrowserIndex, true);
        setCurrentIndex(_mpBrowserIndex);
        qDebug() << "_mpBrowserIndex = " << _mpBrowserIndex;
    }
Example #4
0
void MainWindow::close_database()
{
	QByteArray ba;
	if (!dbfile.isEmpty()) {
		ba += db::intToData(size().width());
		ba += db::intToData(size().height());
		ba += db::intToData(tabView->currentIndex());
		db mydb(dbfile);
		mydb.set((const unsigned char *)ba.constData(), ba.size(), 1,
			setting, "mw_geometry");
	}
	setItemEnabled(false);
	dbindex->clear();

	keyView->setModel(NULL);
	reqView->setModel(NULL);
	certView->setModel(NULL);
	tempView->setModel(NULL);
	crlView->setModel(NULL);

	if (crls)
		delete(crls);
	if (reqs)
		delete(reqs);
	if (certs)
		delete(certs);
	if (temps)
		delete(temps);
	if (keys)
		delete(keys);

	reqs = NULL;
	certs = NULL;
	temps = NULL;
	keys = NULL;

	pki_evp::passwd.cleanse();
	pki_evp::passwd = QByteArray();

	if (!crls)
		return;
	crls = NULL;


	try {
		db mydb(dbfile);
		mydb.shrink( DBFLAG_OUTDATED | DBFLAG_DELETED );
	}
	catch (errorEx &err) {
		MainWindow::Error(err);
	}
	pkcs11::remove_libs();
	enableTokenMenu(pkcs11::loaded());
}
Example #5
0
void KGlobalAccel::setEnabled( bool activate )
{
	QDictIterator<KKeyEntry> aKeyIt( aKeyDict );
	aKeyIt.toFirst();
#define pE aKeyIt.current()
	while ( pE ) {
		setItemEnabled( aKeyIt.currentKey(), activate );
		++aKeyIt;
	}
#undef pE
	bEnabled = activate;
}
Example #6
0
void MarbleControlBox::setCurrentLocationTabShown( bool show )
{
    QString  title = tr( "Current Location" );
    setWidgetTabShown( d->m_currentLocationWidget, 4, show, title );
    if ( d->m_widget && d->m_widget->mapTheme() ) {
        bool enabled = d->m_widget->mapTheme()->head()->target() == "earth";
        int locationIndex = indexOf( d->m_currentLocationWidget );
        if ( locationIndex >= 0 ) {
            setItemEnabled( locationIndex, enabled );
        }
    }
}
Example #7
0
void SpawnListMenu::setCurrentCategory(const Category* cat)
{
    // set the current category
    m_currentCategory = cat;

    // update the menu item names
    if (cat != NULL)
    {
        changeItem(m_id_edit_category,
                   "&Edit '" + cat->name() + "' Category...");
        setItemEnabled(m_id_edit_category, true);
        changeItem(m_id_delete_category,
                   "&Delete '" + cat->name() + "' Category...");
        setItemEnabled(m_id_delete_category, true);
    }
    else
    {
        changeItem(m_id_edit_category, "&Edit Category...");
        setItemEnabled(m_id_edit_category, false);
        changeItem(m_id_delete_category, "&Delete Category...");
        setItemEnabled(m_id_delete_category, false);
    }
}
Example #8
0
void SpawnListMenu::setCurrentItem(const Item* item)
{
    // set the current item
    m_currentItem = item;

    // enable/disable item depending on if there is one
    setItemEnabled(m_id_filterMenu, (item != NULL));
    setItemEnabled(m_id_zoneFilterMenu, (item != NULL));

    if (item != NULL)
    {
        changeItem(m_id_filterMenu,
                   "Add '" + item->name() + "' &Filter");
        changeItem(m_id_zoneFilterMenu,
                   "Add '" + item->name() + "' &Zone Filter");
    }
    else
    {
        changeItem(m_id_filterMenu,
                   "Add &Filter");
        changeItem(m_id_zoneFilterMenu,
                   "Add &Zone Filter");
    }
}
void MyMenuBar::setItemState(ZLToolbar::ItemPtr item, bool visible, bool enabled) {
	switch (item->type()) {
		case ZLToolbar::Item::PLAIN_BUTTON:
		case ZLToolbar::Item::TOGGLE_BUTTON:
		case ZLToolbar::Item::MENU_BUTTON:
		{
			ZLToolbar::AbstractButtonItem &button =
				(ZLToolbar::AbstractButtonItem&)*item;
			const std::string &id = button.actionId();
			std::map<std::string,int> ::const_iterator iter = myActionIndices.find(id);
			int actionIndex = (iter != myActionIndices.end()) ? iter->second : 0;
			if (visible) {
				if ((actionIndex == 0) || (idAt(myIndex) != actionIndex)) {
					ToolBarButton *tbButton = myButtons[id];
					if (actionIndex == 0) {
						tbButton = new ToolBarButton(myWindow, button);
						myButtons[id] = tbButton;
						actionIndex = myActionIndices.size() + 1;
						myActionIndices[id] = actionIndex;
					}
					insertItem(tbButton->pixmap(), tbButton, SLOT(doActionSlot()), 0, actionIndex, myIndex);
				}
				setItemEnabled(actionIndex, enabled);
				++myIndex;
			} else {
				if ((actionIndex != 0) && (idAt(myIndex) == actionIndex)) {
					removeItem(actionIndex);
				}
			}
			break;
		}
		/*
		case ZLToolbar::Item::OPTION_ENTRY:
			if (idAt(myIndex) < 10001) {
				shared_ptr<ZLOptionEntry> entry = ((ZLToolbar::OptionEntryItem&)*item).entry();
				if (entry->isVisible()) {
					ZLOptionView *view = createViewByEntry("", "", entry);
					view->setVisible(true);
				}
			} else {
				++myIndex;
			}
			break;
		*/
		case ZLToolbar::Item::SEPARATOR:
			break;
	}
}
Example #10
0
// create and fill "recent" section at first
void PanelKMenu::createRecentMenuItems()
{
    RecentlyLaunchedApps::the().m_nNumMenuItems = 0;

    QStringList RecentApps;
    RecentlyLaunchedApps::the().getRecentApps(RecentApps);

    if (RecentApps.count() > 0)
    {
        bool bSeparator = KickerSettings::showMenuTitles();
        int nId = serviceMenuEndId() + 1;
        int nIndex = KickerSettings::showMenuTitles() ? 1 : 0;

        for (QValueList<QString>::ConstIterator it =
             RecentApps.fromLast(); /*nop*/; --it)
        {
            KService::Ptr s = KService::serviceByDesktopPath(*it);
            if (!s)
            {
                RecentlyLaunchedApps::the().removeItem(*it);
            }
            else
            {
                if (bSeparator)
                {
                    bSeparator = false;
                    int id = insertItem(
                        new PopupMenuTitle(
                            RecentlyLaunchedApps::the().caption(), font()),
                        serviceMenuEndId(), 0);
                    setItemEnabled( id, false );
                }
                insertMenuItem(s, nId++, nIndex);
                RecentlyLaunchedApps::the().m_nNumMenuItems++;
            }

            if (it == RecentApps.begin())
            {
                break;
            }
        }

        if (!KickerSettings::showMenuTitles())
        {
            insertSeparator(RecentlyLaunchedApps::the().m_nNumMenuItems);
        }
    }
}
Example #11
0
void KGlobalAccel::connectItem( const char * action,
							const QObject* receiver, const char* member,
							bool activate )
{
    KKeyEntry *pEntry = aKeyDict[ action ];
	if ( !pEntry ) {
		QString str;
		str.sprintf(
			"KGlobalAccel : Cannot connect action %s"\
			"which is not in the object dictionary", action );
		warning( str );
		return;
	}
	
	pEntry->receiver = receiver;
	pEntry->member = new QString( member );
	pEntry->aAccelId = aAvailableId;
	aAvailableId++;
	
	setItemEnabled( action, activate );
}
Example #12
0
void KOEventPopupMenu::showIncidencePopup(Incidence *incidence, const QDate &qd)
{
    mCurrentIncidence = incidence;
    mCurrentDate = qd;

    if(mCurrentIncidence)
    {
        // Enable/Disabled menu items only valid for editable events.
        QValueList<int>::Iterator it;
        for(it = mEditOnlyItems.begin(); it != mEditOnlyItems.end(); ++it)
        {
            setItemEnabled(*it, !mCurrentIncidence->isReadOnly());
        }
        for(it = mRecurrenceItems.begin(); it != mRecurrenceItems.end(); ++it)
        {
            setItemVisible(*it, mCurrentIncidence->doesRecur());
        }
        popup(QCursor::pos());
    }
    else
    {
        kdDebug(5850) << "KOEventPopupMenu::showEventPopup(): No event selected" << endl;
    }
}
Example #13
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);
}
Example #14
0
SpawnListMenu::SpawnListMenu(SEQListView* spawnlist,
                             SEQWindow* spawnlistWindow,
                             FilterMgr* filterMgr,
                             CategoryMgr* categoryMgr,
                             QWidget* parent, const char* name)
    : m_spawnlist(spawnlist),
      m_spawnlistWindow(spawnlistWindow),
      m_filterMgr(filterMgr),
      m_categoryMgr(categoryMgr)
{
    // Show Columns
    QPopupMenu* spawnListColMenu = new QPopupMenu;
    insertItem( "Show &Column", spawnListColMenu);
    spawnListColMenu->setCheckable(true);
    m_id_spawnList_Cols[tSpawnColName] =
        spawnListColMenu->insertItem("&Name");
    spawnListColMenu->setItemParameter(m_id_spawnList_Cols[tSpawnColName],
                                       tSpawnColName);
    m_id_spawnList_Cols[tSpawnColLevel] = spawnListColMenu->insertItem("&Level");
    spawnListColMenu->setItemParameter(m_id_spawnList_Cols[tSpawnColLevel],
                                       tSpawnColLevel);
    m_id_spawnList_Cols[tSpawnColHP] = spawnListColMenu->insertItem("&HP");
    spawnListColMenu->setItemParameter(m_id_spawnList_Cols[tSpawnColHP],
                                       tSpawnColHP);
    m_id_spawnList_Cols[tSpawnColMaxHP] = spawnListColMenu->insertItem("&Max HP");
    spawnListColMenu->setItemParameter(m_id_spawnList_Cols[tSpawnColMaxHP],
                                       tSpawnColMaxHP);
    m_id_spawnList_Cols[tSpawnColXPos] = spawnListColMenu->insertItem("Coord &1");
    spawnListColMenu->setItemParameter(m_id_spawnList_Cols[tSpawnColXPos],
                                       tSpawnColXPos);
    m_id_spawnList_Cols[tSpawnColYPos] = spawnListColMenu->insertItem("Coord &2");
    spawnListColMenu->setItemParameter(m_id_spawnList_Cols[tSpawnColYPos],
                                       tSpawnColYPos);
    m_id_spawnList_Cols[tSpawnColZPos] = spawnListColMenu->insertItem("Coord &3");
    spawnListColMenu->setItemParameter(m_id_spawnList_Cols[tSpawnColZPos],
                                       tSpawnColZPos);
    m_id_spawnList_Cols[tSpawnColID] = spawnListColMenu->insertItem("I&D");
    spawnListColMenu->setItemParameter(m_id_spawnList_Cols[tSpawnColID],
                                       tSpawnColID);
    m_id_spawnList_Cols[tSpawnColDist] = spawnListColMenu->insertItem("&Dist");
    spawnListColMenu->setItemParameter(m_id_spawnList_Cols[tSpawnColDist],
                                       tSpawnColDist);
    m_id_spawnList_Cols[tSpawnColRace] = spawnListColMenu->insertItem("&Race");
    spawnListColMenu->setItemParameter(m_id_spawnList_Cols[tSpawnColRace],
                                       tSpawnColRace);
    m_id_spawnList_Cols[tSpawnColClass] = spawnListColMenu->insertItem("&Class");
    spawnListColMenu->setItemParameter(m_id_spawnList_Cols[tSpawnColClass],
                                       tSpawnColClass);
    m_id_spawnList_Cols[tSpawnColInfo] = spawnListColMenu->insertItem("&Info");
    spawnListColMenu->setItemParameter(m_id_spawnList_Cols[tSpawnColInfo],
                                       tSpawnColInfo);
    m_id_spawnList_Cols[tSpawnColSpawnTime] = spawnListColMenu->insertItem("Spawn &Time");
    spawnListColMenu->setItemParameter(m_id_spawnList_Cols[tSpawnColSpawnTime],
                                       tSpawnColSpawnTime);
    m_id_spawnList_Cols[tSpawnColDeity] = spawnListColMenu->insertItem("&Deity");
    spawnListColMenu->setItemParameter(m_id_spawnList_Cols[tSpawnColDeity],
                                       tSpawnColDeity);
    m_id_spawnList_Cols[tSpawnColBodyType] = spawnListColMenu->insertItem("&Body Type");
    spawnListColMenu->setItemParameter(m_id_spawnList_Cols[tSpawnColBodyType],
                                       tSpawnColBodyType);
    m_id_spawnList_Cols[tSpawnColGuildID] = spawnListColMenu->insertItem("Guild Tag");
    spawnListColMenu->setItemParameter(m_id_spawnList_Cols[tSpawnColGuildID],
                                       tSpawnColGuildID);

    connect (spawnListColMenu, SIGNAL(activated(int)),
             this, SLOT(toggle_spawnListCol(int)));

    int x;
    QPopupMenu* filterMenu = new QPopupMenu;
    m_id_filterMenu = insertItem("Add &Filter", filterMenu);
    setItemEnabled(m_id_filterMenu, false);
    x = filterMenu->insertItem("&Hunt...");
    filterMenu->setItemParameter(x, HUNT_FILTER);
    x = filterMenu->insertItem("&Caution...");
    filterMenu->setItemParameter(x, CAUTION_FILTER);
    x = filterMenu->insertItem("&Danger...");
    filterMenu->setItemParameter(x, DANGER_FILTER);
    x = filterMenu->insertItem("&Locate...");
    filterMenu->setItemParameter(x, LOCATE_FILTER);
    x = filterMenu->insertItem("&Alert...");
    filterMenu->setItemParameter(x, ALERT_FILTER);
    x = filterMenu->insertItem("&Filtered...");
    filterMenu->setItemParameter(x, FILTERED_FILTER);
    x = filterMenu->insertItem("&Tracer...");
    filterMenu->setItemParameter(x, TRACER_FILTER);
    connect (filterMenu, SIGNAL(activated(int)),
             this, SLOT(add_filter(int)));

    QPopupMenu* zoneFilterMenu = new QPopupMenu;
    m_id_zoneFilterMenu = insertItem("Add &Zone Filter", zoneFilterMenu);
    setItemEnabled(m_id_zoneFilterMenu, false);
    x = zoneFilterMenu->insertItem("&Hunt...");
    zoneFilterMenu->setItemParameter(x, HUNT_FILTER);
    x = zoneFilterMenu->insertItem("&Caution...");
    zoneFilterMenu->setItemParameter(x, CAUTION_FILTER);
    x = zoneFilterMenu->insertItem("&Danger...");
    zoneFilterMenu->setItemParameter(x, DANGER_FILTER);
    x = zoneFilterMenu->insertItem("&Locate...");
    zoneFilterMenu->setItemParameter(x, LOCATE_FILTER);
    x = zoneFilterMenu->insertItem("&Alert...");
    zoneFilterMenu->setItemParameter(x, ALERT_FILTER);
    x = zoneFilterMenu->insertItem("&Filtered...");
    zoneFilterMenu->setItemParameter(x, FILTERED_FILTER);
    x = zoneFilterMenu->insertItem("&Tracer...");
    zoneFilterMenu->setItemParameter(x, TRACER_FILTER);
    connect (zoneFilterMenu, SIGNAL(activated(int)),
             this, SLOT(add_zoneFilter(int)));

    insertSeparator(-1);

    x = insertItem("&Add Category...", this, SLOT(add_category(int)));
    m_id_edit_category =
        insertItem("&Edit Category...", this, SLOT(edit_category(int)));
    m_id_delete_category =
        insertItem("&Delete Category...", this, SLOT(delete_category(int)));
    insertItem("&Reload Categories", this, SLOT(reload_categories(int)));
    insertSeparator(-1);
    insertItem("&Font...", this, SLOT(set_font(int)));
    insertItem("&Caption...", this, SLOT(set_caption(int)));

    connect(this, SIGNAL(aboutToShow()),
            this, SLOT(init_Menu()));
}
Example #15
0
void KWindowListMenu::init()
{
    int i, d;
    i = 0;

    int nd = twin_module->numberOfDesktops();
    int cd = twin_module->currentDesktop();
    WId active_window = twin_module->activeWindow();

    // Make sure the popup is not too wide, otherwise clicking in the middle of kdesktop
    // wouldn't leave any place for the popup, and release would activate some menu entry.    
    int maxwidth = kapp->desktop()->screenGeometry( this ).width() / 2 - 100;

    clear();
    map.clear();

    int unclutter = insertItem( i18n("Unclutter Windows"),
                                this, TQT_SLOT( slotUnclutterWindows() ) );
    int cascade = insertItem( i18n("Cascade Windows"),
                              this, TQT_SLOT( slotCascadeWindows() ) );

    // if we only have one desktop we won't be showing titles, so put a separator in
    if (nd == 1)
    {
        insertSeparator();
    }


    TQValueList<KWin::WindowInfo> windows;
    for (TQValueList<WId>::ConstIterator it = twin_module->windows().begin();
         it != twin_module->windows().end(); ++it) {
         windows.append( KWin::windowInfo( *it, NET::WMDesktop ));
    }
    bool show_all_desktops_group = ( nd > 1 );
    for (d = 1; d <= nd + (show_all_desktops_group ? 1 : 0); d++) {
        bool on_all_desktops = ( d > nd );
	int items = 0;

	if (!active_window && d == cd)
	    setItemChecked(1000 + d, true);

        NameSortedInfoList list;
        list.setAutoDelete(true);

	for (TQValueList<KWin::WindowInfo>::ConstIterator it = windows.begin();
             it != windows.end(); ++it) {
	    if (((*it).desktop() == d) || (on_all_desktops && (*it).onAllDesktops())
                || (!show_all_desktops_group && (*it).onAllDesktops())) {
	        list.inSort(new KWin::WindowInfo( (*it).win(),
                    NET::WMVisibleName | NET::WMState | NET::XAWMState | NET::WMWindowType,
                    NET::WM2GroupLeader | NET::WM2TransientFor ));
            }
        }

        for (KWin::WindowInfo* info = list.first(); info; info = list.next(), ++i)
        {
            TQString itemText = KStringHandler::cPixelSqueeze(info->visibleNameWithState(), fontMetrics(), maxwidth);
            NET::WindowType windowType = info->windowType( NET::NormalMask | NET::DesktopMask
                | NET::DockMask | NET::ToolbarMask | NET::MenuMask | NET::DialogMask
                | NET::OverrideMask | NET::TopMenuMask | NET::UtilityMask | NET::SplashMask );
            if ( (windowType == NET::Normal || windowType == NET::Unknown
                    || (windowType == NET::Dialog && standaloneDialog( info, list )))
                && !(info->state() & NET::SkipTaskbar) ) {
                TQPixmap pm = KWin::icon(info->win(), 16, 16, true );
                items++;

                // ok, we have items on this desktop, let's show the title
                if ( items == 1 && nd > 1 )
                {
                    if( !on_all_desktops )
                        insertTitle(twin_module->desktopName( d ), 1000 + d);
                    else
                        insertTitle(i18n("On All Desktops"), 2000 );
                }

                // Avoid creating unwanted accelerators.
                itemText.replace('&', TQString::fromLatin1("&&"));
                insertItem( pm, itemText, i);
                map.insert(i, info->win());
                if (info->win() == active_window)
                    setItemChecked(i, true);
            }
        }

        if (d == cd)
        {
            setItemEnabled(unclutter, items > 0);
            setItemEnabled(cascade, items > 0);
        }
    }

    // no windows?
    if (i == 0)
    {
        if (nd > 1)
        {
            // because we don't have any titles, nor a separator
            insertSeparator();
        }

        setItemEnabled(insertItem(i18n("No Windows")), false);
    }
}
Example #16
0
void PanelKMenu::updateRecent()
{
    if (!RecentlyLaunchedApps::the().m_bNeedToUpdate)
    {
        return;
    }

    RecentlyLaunchedApps::the().m_bNeedToUpdate = false;

    int nId = serviceMenuEndId() + 1;

    // remove previous items
    if (RecentlyLaunchedApps::the().m_nNumMenuItems > 0)
    {
        // -1 --> menu title
        int i = KickerSettings::showMenuTitles() ? -1 : 0;
        for (; i < RecentlyLaunchedApps::the().m_nNumMenuItems; i++)
        {
            removeItem(nId + i);
            entryMap_.remove(nId + i);
        }
        RecentlyLaunchedApps::the().m_nNumMenuItems = 0;

        if (!KickerSettings::showMenuTitles())
        {
            removeItemAt(0);
        }
    }

    // insert new items
    QStringList RecentApps;
    RecentlyLaunchedApps::the().getRecentApps(RecentApps);

    if (RecentApps.count() > 0)
    {
        bool bNeedSeparator = KickerSettings::showMenuTitles();
        for (QValueList<QString>::ConstIterator it = RecentApps.fromLast();
             /*nop*/; --it)
        {
            KService::Ptr s = KService::serviceByDesktopPath(*it);
            if (!s)
            {
                RecentlyLaunchedApps::the().removeItem(*it);
            }
            else
            {
                if (bNeedSeparator)
                {
                    bNeedSeparator = false;
                    int id = insertItem(new PopupMenuTitle(
                        RecentlyLaunchedApps::the().caption(),
                            font()), nId - 1, 0);
                    setItemEnabled( id, false );
                }
                insertMenuItem(s, nId++, KickerSettings::showMenuTitles() ?
                    1 : 0);
                RecentlyLaunchedApps::the().m_nNumMenuItems++;
            }

            if (it == RecentApps.begin())
                break;
        }

        if (!KickerSettings::showMenuTitles())
        {
            insertSeparator(RecentlyLaunchedApps::the().m_nNumMenuItems);
        }
    }
}
Example #17
0
void MainWindow::close_database()
{
	QByteArray ba;
	if (!dbfile.isEmpty()) {
		ba += db::intToData(size().width());
		ba += db::intToData(size().height());
		ba += db::intToData(tabView->currentIndex());
		db mydb(dbfile);
		mydb.set((const unsigned char *)ba.constData(), ba.size(), 1,
			setting, "mw_geometry");
	}
	setItemEnabled(false);
	statusBar()->removeWidget(searchEdit);
	dbindex->clear();

	keyView->setModel();
	reqView->setModel();
	certView->setModel();
	tempView->setModel();
	crlView->setModel();

	if (crls)
		delete(crls);
	if (reqs)
		delete(reqs);
	if (certs)
		delete(certs);
	if (temps)
		delete(temps);
	if (keys)
		delete(keys);

	reqs = NULL;
	certs = NULL;
	temps = NULL;
	keys = NULL;

	pki_evp::passwd.cleanse();
	pki_evp::passwd = QByteArray();

	if (!crls)
		return;
	crls = NULL;


	try {
		int ret;
		db mydb(dbfile);
		ret = mydb.shrink( DBFLAG_OUTDATED | DBFLAG_DELETED );
		if (ret == 1)
			XCA_INFO(tr("Errors detected and repaired while deleting outdated items from the database. A backup file was created"));
		if (ret == 2)
			XCA_INFO(tr("Removing deleted or outdated items from the database failed."));
	}
	catch (errorEx &err) {
		MainWindow::Error(err);
	}
	update_history(dbfile);
	pkcs11::remove_libs();
	enableTokenMenu(pkcs11::loaded());
	dbfile.clear();
}
Example #18
0
int MainWindow::init_database()
{
	int ret = 2;
	qDebug("Opening database: %s", QString2filename(dbfile));
	keys = NULL; reqs = NULL; certs = NULL; temps = NULL; crls = NULL;

	Entropy::seed_rng();
	certView->setRootIsDecorated(db_x509::treeview);

	try {
		ret = initPass();
		if (ret == 2)
			return ret;
		keys = new db_key(dbfile, this);
		reqs = new db_x509req(dbfile, this);
		certs = new db_x509(dbfile, this);
		temps = new db_temp(dbfile, this);
		crls = new db_crl(dbfile, this);
		certs->updateAfterDbLoad();
	}
	catch (errorEx &err) {
		Error(err);
		dbfile = "";
		return ret;
	}

	searchEdit->setText("");
	searchEdit->show();
	statusBar()->addWidget(searchEdit, 1);
	mandatory_dn = "";
	explicit_dn = explicit_dn_default;

	string_opt = QString("MASK:0x2002");
	ASN1_STRING_set_default_mask_asc((char*)CCHAR(string_opt));
	hashBox::resetDefault();
	pkcs11path = QString();
	workingdir = QDir::currentPath();
	setOptFlags((QString()));

	connect( keys, SIGNAL(newKey(pki_key *)),
		certs, SLOT(newKey(pki_key *)) );
	connect( keys, SIGNAL(delKey(pki_key *)),
		certs, SLOT(delKey(pki_key *)) );
	connect( keys, SIGNAL(newKey(pki_key *)),
		reqs, SLOT(newKey(pki_key *)) );
	connect( keys, SIGNAL(delKey(pki_key *)),
		reqs, SLOT(delKey(pki_key *)) );

	connect( certs, SIGNAL(connNewX509(NewX509 *)), this,
		SLOT(connNewX509(NewX509 *)) );
	connect( reqs, SIGNAL(connNewX509(NewX509 *)), this,
		SLOT(connNewX509(NewX509 *)) );

	connect( reqs, SIGNAL(newCert(pki_x509req *)),
		certs, SLOT(newCert(pki_x509req *)) );
	connect( tempView, SIGNAL(newCert(pki_temp *)),
		certs, SLOT(newCert(pki_temp *)) );
	connect( tempView, SIGNAL(newReq(pki_temp *)),
		reqs, SLOT(newItem(pki_temp *)) );

	keyView->setIconSize(pki_evp::icon[0]->size());
	reqView->setIconSize(pki_x509req::icon[0]->size());
	certView->setIconSize(pki_x509::icon[0]->size());
	tempView->setIconSize(pki_temp::icon->size());
	crlView->setIconSize(pki_crl::icon->size());

	keyView->setModel(keys);
	reqView->setModel(reqs);
	certView->setModel(certs);
	tempView->setModel(temps);
	crlView->setModel(crls);
	try {
		db mydb(dbfile);

		while (mydb.find(setting, QString()) == 0) {
			QString key;
			db_header_t head;
			char *p = (char *)mydb.load(&head);
			if (!p) {
				if (mydb.next())
					break;
				continue;
			}
			key = head.name;

			if (key == "workingdir")
				workingdir = p;
			else if (key == "pkcs11path")
				pkcs11path = p;
			else if (key == "default_hash")
				hashBox::setDefault(p);
			else if (key == "mandatory_dn")
				mandatory_dn = p;
			else if (key == "explicit_dn")
				explicit_dn = p;
			/* what a stupid idea.... */
			else if (key == "multiple_key_use")
				mydb.erase();
			else if (key == "string_opt")
				string_opt = p;
			else if (key == "suppress")
				mydb.erase();
			else if (key == "optionflags1")
				setOptFlags((QString(p)));
			/* Different optionflags, since setOptFlags()
			 * does an abort() for unknown flags in
			 * older versions.   *Another stupid idea*
			 * This is for backward compatibility
			 */
			else if (key == "optionflags")
				setOptFlags_old((QString(p)));
			else if (key == "defaultkey")
				NewKey::setDefault((QString(p)));
			else if (key == "mw_geometry")
				set_geometry(p, &head);
			free(p);
			if (mydb.next())
				break;
		}
	} catch (errorEx &err) {
		Error(err);
		return ret;
	}
	ASN1_STRING_set_default_mask_asc((char*)CCHAR(string_opt));
	if (explicit_dn.isEmpty())
		explicit_dn = explicit_dn_default;
	setWindowTitle(tr(XCA_TITLE));
	setItemEnabled(true);
	if (pki_evp::passwd.isNull())
		XCA_INFO(tr("Using or exporting private keys will not be possible without providing the correct password"));

	dbindex->setText(tr("Database") + ": " + dbfile);
	load_engine();
	return ret;
}
Example #19
0
int MainWindow::init_database()
{
	int ret = 2;
	fprintf(stderr, "Opening database: %s\n", QString2filename(dbfile));
	keys = NULL; reqs = NULL; certs = NULL; temps = NULL; crls = NULL;

	certView->setRootIsDecorated(db_x509::treeview);

	try {
		ret = initPass();
		if (ret == 2)
			return ret;
		keys = new db_key(dbfile, this);
		reqs = new db_x509req(dbfile, this);
		certs = new db_x509(dbfile, this);
		temps = new db_temp(dbfile, this);
		crls = new db_crl(dbfile, this);
	}
	catch (errorEx &err) {
		Error(err);
		dbfile = "";
		return ret;
	}

	mandatory_dn = "";
	string_opt = QString("MASK:0x2002");
	ASN1_STRING_set_default_mask_asc((char*)CCHAR(string_opt));
	hashBox::resetDefault();
	pkcs11path = getDefaultPkcs11Lib();
	workingdir = QDir::currentPath();
	setOptFlags((QString()));
	try {
		pkcs11_lib p(pkcs11path);
	} catch (errorEx &e) {
		pkcs11path = QString();
	}

	connect( keys, SIGNAL(newKey(pki_key *)),
		certs, SLOT(newKey(pki_key *)) );
	connect( keys, SIGNAL(delKey(pki_key *)),
		certs, SLOT(delKey(pki_key *)) );
	connect( keys, SIGNAL(newKey(pki_key *)),
		reqs, SLOT(newKey(pki_key *)) );
	connect( keys, SIGNAL(delKey(pki_key *)),
		reqs, SLOT(delKey(pki_key *)) );

	connect( certs, SIGNAL(connNewX509(NewX509 *)), this,
		SLOT(connNewX509(NewX509 *)) );
	connect( reqs, SIGNAL(connNewX509(NewX509 *)), this,
		SLOT(connNewX509(NewX509 *)) );

	connect( reqs, SIGNAL(newCert(pki_x509req *)),
		certs, SLOT(newCert(pki_x509req *)) );
	connect( temps, SIGNAL(newCert(pki_temp *)),
		certs, SLOT(newCert(pki_temp *)) );
	connect( temps, SIGNAL(newReq(pki_temp *)),
		reqs, SLOT(newItem(pki_temp *)) );

	keyView->setIconSize(pki_evp::icon[0]->size());
	reqView->setIconSize(pki_x509req::icon[0]->size());
	certView->setIconSize(pki_x509::icon[0]->size());
	tempView->setIconSize(pki_temp::icon->size());
	crlView->setIconSize(pki_crl::icon->size());

	keyView->setModel(keys);
	reqView->setModel(reqs);
	certView->setModel(certs);
	tempView->setModel(temps);
	crlView->setModel(crls);

	try {
		db mydb(dbfile);
		char *p;
		if (!mydb.find(setting, "workingdir")) {
			if ((p = (char *)mydb.load(NULL))) {
				workingdir = p;
				free(p);
			}
		}
		mydb.first();
		if (!mydb.find(setting, "pkcs11path")) {
			if ((p = (char *)mydb.load(NULL))) {
				pkcs11path = p;
				free(p);
			}
		}
		mydb.first();
		if (!mydb.find(setting, "default_hash")) {
			if ((p = (char *)mydb.load(NULL))) {
				hashBox::setDefault(p);
				free(p);
			}
		}
		mydb.first();
		if (!mydb.find(setting, "mandatory_dn")) {
			if ((p = (char *)mydb.load(NULL))) {
				mandatory_dn = p;
				free(p);
			}
		}
		// what a stupid idea....
		mydb.first();
		if (!mydb.find(setting, "multiple_key_use")) {
			mydb.erase();
		}
		mydb.first();
		if (!mydb.find(setting, "string_opt")) {
			if ((p = (char *)mydb.load(NULL))) {
				string_opt = p;
				free(p);
			}
		}
		mydb.first();
		if (!mydb.find(setting, "suppress")) {
			if ((p = (char *)mydb.load(NULL))) {
				QString x = p;
				free(p);
				if (x == "1")
					pki_base::suppress_messages = 1;
			}
		}
		mydb.first();
		if (!mydb.find(setting, "optionflags")) {
			if ((p = (char *)mydb.load(NULL))) {
				setOptFlags((QString(p)));
				free(p);
			}
		}
		ASN1_STRING_set_default_mask_asc((char*)CCHAR(string_opt));
		mydb.first();
		if (!mydb.find(setting, "mw_geometry")) {
			db_header_t h;
			if ((p = (char *)mydb.load(&h))) {
				if (h.version == 1) {
					QByteArray ba;
					ba = QByteArray::fromRawData(p, h.len);
					int w, h, i;
					w = db::intFromData(ba);
					h = db::intFromData(ba);
					i = db::intFromData(ba);
					resize(w,h);
					if (i != -1)
						tabView->setCurrentIndex(i);
					}
				free(p);
			}
		}
	} catch (errorEx &err) {
		Error(err);
		return ret;
	}
	setWindowTitle(tr(XCA_TITLE));
	setItemEnabled(true);
	if (pki_evp::passwd.isNull())
		QMessageBox::information(this, XCA_TITLE,
			tr("Using or exporting private keys will not be possible without providing the correct password"));

	dbindex->setText(tr("Database") + ":" + dbfile);
	load_engine();
	return ret;
}