Ejemplo n.º 1
0
/**
 * NOTE: we assume kate is installed
 */
void KMoreToolsTest2::test_buildMenu_ShowConfigureMenuItem()
{
    {
        KMoreTools kmt(_("unittest-kmoretools/2"));
        const auto kateApp = kmt.registerServiceByDesktopEntryName(_("org.kde.kate"));
        // porcelain: other (interactive) tests will reuse the kmt id so we make sure that
        // no user configurment disburbs this test:
        const auto menuBuilder = kmt.menuBuilder(_("porcelain"));
        menuBuilder->addMenuItem(kateApp);
        QMenu menu;
        menuBuilder->buildByAppendingToMenu(&menu); // == KMoreTools::ConfigureDialogAccessible_Always
        qDebug() << menuBuilder->menuStructureAsString(true);
        QVERIFY(menuAtLeastOneActionWithText(&menu, _("Configure..."))); // "Kate", "Separator", "Configure..."

        {
            menu.clear();
            menuBuilder->buildByAppendingToMenu(&menu, KMoreTools::ConfigureDialogAccessible_Defensive);
            QVERIFY(menuAtLeastNoActionWithText(&menu, _("Configure...")));
        }
    }

    {
        KMoreTools kmt(_("unittest-kmoretools/2"));
        const auto kateApp = kmt.registerServiceByDesktopEntryName(_("org.kde.kate"));
        const auto mynotInstalledApp = kmt.registerServiceByDesktopEntryName(_("mynotinstalledapp"));
        const auto menuBuilder = kmt.menuBuilder(_("porcelain"));
        menuBuilder->addMenuItem(kateApp);
        menuBuilder->addMenuItem(mynotInstalledApp);
        QMenu menu;
        menuBuilder->buildByAppendingToMenu(&menu); // == KMoreTools::ConfigureDialogAccessible_Always

        auto doAssert = [](QMenu* menu) {
            QCOMPARE(menu->actions().count(), 3); // "Kate", "Separator", "More..."
            auto moreMenu = menu->actions()[2]->menu();
            QCOMPARE(moreMenu->actions().count(), 4); // "Not-installed-section", "Not installed app", "Separator", "Configure menu..."
            auto configureMenu = moreMenu->actions()[3];
            QCOMPARE(configureMenu->data().toString(), QString(_("configureItem")));
        };

        doAssert(&menu);

        {
            menu.clear();
            menuBuilder->buildByAppendingToMenu(&menu, KMoreTools::ConfigureDialogAccessible_Defensive);
            doAssert(&menu); // = same as _Always because there is one not-installed item
        }
    }
}
Ejemplo n.º 2
0
void BookmarksToolbar::aboutToShowFolderMenu()
{
    QMenu* menu = qobject_cast<QMenu*> (sender());
    if (!menu) {
        return;
    }

    menu->clear();
    QString folder = menu->title();

    foreach (const Bookmark &b, m_bookmarksModel->folderBookmarks(folder)) {
        QString title = b.title;
        if (title.length() > 40) {
            title.truncate(40);
            title += "..";
        }

        Action* act = new Action(qIconProvider->iconFromImage(b.image), title);
        act->setData(b.url);
        connect(act, SIGNAL(triggered()), p_QupZilla, SLOT(loadActionUrl()));
        connect(act, SIGNAL(middleClicked()), p_QupZilla, SLOT(loadActionUrlInNewNotSelectedTab()));
        menu->addAction(act);
    }

    if (menu->isEmpty()) {
        menu->addAction(tr("Empty"))->setEnabled(false);
    }
}
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
void StandardSIMPLViewApplication::updateRecentFileList(const QString& file)
{
  SIMPLViewMenuItems* menuItems = SIMPLViewMenuItems::Instance();

  for (int i = 0; i < m_SIMPLViewInstances.size(); i++)
  {
    SIMPLView_UI* window = m_SIMPLViewInstances[i];

    if (NULL != window)
    {
      QMenu* recentFilesMenu = menuItems->getMenuRecentFiles();
      QAction* clearRecentFilesAction = menuItems->getActionClearRecentFiles();

      // Clear the Recent Items Menu
      recentFilesMenu->clear();

      // Get the list from the static object
      QStringList files = QRecentFileList::instance()->fileList();
      foreach(QString file, files)
      {
        QAction* action = new QAction(recentFilesMenu);
        action->setText(QRecentFileList::instance()->parentAndFileName(file));
        action->setData(file);
        action->setVisible(true);
        recentFilesMenu->addAction(action);
        connect(action, SIGNAL(triggered()), this, SLOT(openRecentFile()));
      }

      recentFilesMenu->addSeparator();
      recentFilesMenu->addAction(clearRecentFilesAction);
    }
Ejemplo n.º 4
0
void KateFileTree::slotFixOpenWithMenu()
{
  QMenu *menu = (QMenu*)sender();
  menu->clear();
  
   KTextEditor::Document *doc = model()->data(m_indexContextMenu, KateFileTreeModel::DocumentRole).value<KTextEditor::Document *>();
  if (!doc) return;

  // get a list of appropriate services.
  KMimeType::Ptr mime = KMimeType::mimeType(doc->mimeType());
  //kDebug(13001) << "mime type: " << mime->name();

  QAction *a = 0;
  KService::List offers = KMimeTypeTrader::self()->query(mime->name(), "Application");
  // for each one, insert a menu item...
  for(KService::List::Iterator it = offers.begin(); it != offers.end(); ++it)
  {
    KService::Ptr service = *it;
    if (service->name() == "Kate") continue;
    a = menu->addAction(KIcon(service->icon()), service->name());
    a->setData(service->entryPath());
  }
  // append "Other..." to call the KDE "open with" dialog.
  a = menu->addAction(i18n("&Other..."));
  a->setData(QString());
}
void ZLQtApplicationWindow::setToolbarItemState(ZLToolbar::ItemPtr item, bool visible, bool enabled) {
	QAction *action = myActions[&*item];
	if (action != 0) {
		action->setEnabled(enabled);
		action->setVisible(visible);
	}
	switch (item->type()) {
		default:
			break;
		case ZLToolbar::Item::MENU_BUTTON:
		{
			ZLToolbar::MenuButtonItem &buttonItem = (ZLToolbar::MenuButtonItem&)*item;
			shared_ptr<ZLPopupData> data = buttonItem.popupData();
			if (!data.isNull() && (data->id() != myPopupIdMap[&buttonItem])) {
				myPopupIdMap[&buttonItem] = data->id();
				QToolButton *button = myMenuButtons[&buttonItem];
				QMenu *menu = button->menu();
				menu->clear();
				const size_t count = data->count();
				for (size_t i = 0; i < count; ++i) {
					menu->addAction(new ZLQtRunPopupAction(menu, data, i));
				}
			}
			break;
		}
	}
}
Ejemplo n.º 6
0
void BookmarksToolbar::aboutToShowFolderMenu()
{
    QMenu* menu = qobject_cast<QMenu*> (sender());
    if (!menu) {
        return;
    }

    menu->clear();
    QString folder = menu->title();

    QSqlQuery query;
    query.prepare("SELECT title, url, icon FROM bookmarks WHERE folder=?");
    query.addBindValue(folder);
    query.exec();
    while (query.next()) {
        QString title = query.value(0).toString();
        QUrl url = query.value(1).toUrl();
        QIcon icon = IconProvider::iconFromBase64(query.value(2).toByteArray());
        if (title.length() > 40) {
            title.truncate(40);
            title += "..";
        }

        Action* act = new Action(icon, title);
        act->setData(url);
        connect (act, SIGNAL(triggered()), p_QupZilla, SLOT(loadActionUrl()));
        connect (act, SIGNAL(middleClicked()), p_QupZilla, SLOT(loadActionUrlInNewTab()));
        menu->addAction(act);
    }

    if (menu->isEmpty()) {
        menu->addAction(tr("Empty"));
    }
}
Ejemplo n.º 7
0
void MenuManager::UnInstall_MainMenu()
{
	QMenu* pMenu = m_pMainWnd->menuGameObject;
	if(pMenu)
	{
		pMenu->clear();
		pMenu->menuAction()->setVisible(false);
	}

	pMenu = m_pMainWnd->menuComponent;
	if(pMenu)
	{
		pMenu->clear();
		pMenu->menuAction()->setVisible(false);
	}
}
Ejemplo n.º 8
0
void MenuManager::Install_MainMenu()
{
	UnInstall_MainMenu();

	QMenu* pMenu = m_pMainWnd->menuGameObject;
	pMenu->clear();
	Install_Menu_GameObject(pMenu);
	pMenu->menuAction()->setVisible(true);


	pMenu = m_pMainWnd->menuComponent;
	pMenu->clear();
	Install_Menu_Component(pMenu);
	pMenu->menuAction()->setVisible(true);

}
Ejemplo n.º 9
0
    void setupMenu() {
        menuTypes->clear();

        if (typeFlags.testFlag(KBibTeX::tfPlainText)) {
            QAction *action = menuTypes->addAction(iconForTypeFlag(KBibTeX::tfPlainText), i18n("Plain Text"), menuTypesSignalMapper, SLOT(map()));
            menuTypesSignalMapper->setMapping(action, KBibTeX::tfPlainText);
        }
        if (typeFlags.testFlag(KBibTeX::tfReference)) {
            QAction *action = menuTypes->addAction(iconForTypeFlag(KBibTeX::tfReference), i18n("Reference"), menuTypesSignalMapper, SLOT(map()));
            menuTypesSignalMapper->setMapping(action, KBibTeX::tfReference);
        }
        if (typeFlags.testFlag(KBibTeX::tfPerson)) {
            QAction *action = menuTypes->addAction(iconForTypeFlag(KBibTeX::tfPerson), i18n("Person"), menuTypesSignalMapper, SLOT(map()));
            menuTypesSignalMapper->setMapping(action, KBibTeX::tfPerson);
        }
        if (typeFlags.testFlag(KBibTeX::tfKeyword)) {
            QAction *action = menuTypes->addAction(iconForTypeFlag(KBibTeX::tfKeyword), i18n("Keyword"), menuTypesSignalMapper, SLOT(map()));
            menuTypesSignalMapper->setMapping(action, KBibTeX::tfKeyword);
        }
        if (typeFlags.testFlag(KBibTeX::tfSource)) {
            QAction *action = menuTypes->addAction(iconForTypeFlag(KBibTeX::tfSource), i18n("Source Code"), menuTypesSignalMapper, SLOT(map()));
            menuTypesSignalMapper->setMapping(action, KBibTeX::tfSource);
        }
        if (typeFlags.testFlag(KBibTeX::tfVerbatim)) {
            QAction *action = menuTypes->addAction(iconForTypeFlag(KBibTeX::tfVerbatim), i18n("Verbatim Text"), menuTypesSignalMapper, SLOT(map()));
            menuTypesSignalMapper->setMapping(action, KBibTeX::tfVerbatim);
        }
    }
Ejemplo n.º 10
0
void MainWindow::updateRecent()
{
    // update the display
    QMenu *menu = actionR_ecent->menu();
    menu->clear();
    int i=1;
    QAction *action;
    for (QStringList::iterator it=slRecent.begin(); it != slRecent.end(); it++)
    {
        QFileInfo file(*it);
        if (file.exists())
        {
            // file exists, so we add it into the menu
            action = menu->addAction(QString("&%1 ").arg(i)+file.fileName());
            // mapping
            smMapper->setMapping(action,i);
            connect(action,SIGNAL(triggered()),smMapper,SLOT(map()));
            action->setStatusTip(*it);
            i++; 
            if (i == RECENT_NUMBER)
            {
                // deletes all remaining files in the list
                slRecent.erase(it,slRecent.end());
                break;
            }
        }
        else
        {
            // mark the list item to be deleted
            (*it) = "";
        }
    }
    // delete empty items from the list
    slRecent = slRecent.filter(QRegExp(".+"));
}
Ejemplo n.º 11
0
void DefaultProxyAction::prepareMenu()
{
	QMenu *menu = qobject_cast<QMenu *>(sender());
	if (!menu)
		return;

	menu->clear();

	NetworkProxy defaultProxy = m_networkProxyManager->defaultProxy();

	QAction *proxyAction = menu->addAction(tr(" - No proxy - "));

	// this parenting allows proxyActions to be removed on menu->clear() whats prevents memory leak
	QActionGroup *proxyActions = new QActionGroup(proxyAction);
	proxyActions->addAction(proxyAction);
	proxyAction->setCheckable(true);
	if (!defaultProxy)
		proxyAction->setChecked(true);

	populateMenu(menu, proxyActions, defaultProxy);

	menu->addSeparator();
	QAction *editProxyConfigurationAction = menu->addAction(tr("Edit proxy configuration..."));
	connect(editProxyConfigurationAction, SIGNAL(triggered()), this, SLOT(editProxyConfiguration()));
}
Ejemplo n.º 12
0
void FormStyle::resetColorMnu()
{
	mnuReset.clear();
	if ( ReadOnly )
		return;
	mnuReset.addAction( Texts[127] /* Resetuj kolor */, this, SLOT( resetColor() ) );
	mnuReset.popup(QCursor::pos());
}
Ejemplo n.º 13
0
static int l_clear(lua_State* L)
{
	QMenu* c = lua_tomenu(L, 1);
	if(!c) return 0;

	c->clear();
	return 0;
}
Ejemplo n.º 14
0
void MenuBarManager::update( SMenuPanel *menu )
{
    QMenu *mn = hash.value( menu );
        mn->clear();

    for( int i=0 ; i<menu->count() ; i++ )
        mn->addAction( menu->at(i) );
}
Ejemplo n.º 15
0
void KLanguageButtonPrivate::clear()
{
  ids.clear();
  popup->clear();

  if ( !staticText ) {
    button->setText( QString() );
  }
}
Ejemplo n.º 16
0
void Sensor::refresh() {   
    QMenu* serverList = pcv_->getServerList();
    serverList->clear();

    lock_guard<mutex> guard(serversMutex_);
    for(auto & server : oldServers_) {
        serverList->addAction(server);
    }
}
Ejemplo n.º 17
0
void AnalyseForm::aboutToShowOpenMenu()
{
    QMenu * menu = ui->open_btn->menu();
    menu->clear();

    Folders * folders = page->foldersObject();
    for (int i = 0; i < folders->count(); ++i) {
        menu->addAction(folders->at(i)->label());
    }
}
Ejemplo n.º 18
0
void MainMenu::aboutToShowEncodingMenu()
{
    QMenu* menu = qobject_cast<QMenu*>(sender());
    Q_ASSERT(menu);

    if (m_window) {
        menu->clear();
        m_window->createEncodingMenu(menu);
    }
}
Ejemplo n.º 19
0
void StatusLabel::fillStatusMenu(QMenu& menu)
{
    menu.clear();
    menu.setTitle(m_client->name());
    QStringList statusNames = m_client->protocol()->statuses();
    foreach(const QString& statusId, statusNames) {
        IMStatusPtr status = m_client->protocol()->status(statusId);
        QAction* action = menu.addAction(status->icon(), status->name());
        action->setProperty("status_id", status->id());
    }
void CLexiconReadWindow::slotFillForwardHistory() {
    qDebug() << "CLexiconReadWindow::slotFillForwardHistory";

    QMenu* menu = m_actions.forwardInHistory->popupMenu();
    menu->clear();
    /// \todo take the history list and fill the menu using addAction
    QListIterator<QAction*> it(keyChooser()->history()->getFwList());
    while (it.hasNext()) {
        menu->addAction(it.next());
    }
}
Ejemplo n.º 21
0
void UndoRedoToolButton::updatePopup()
{
	QMenu * pp = new QMenu( this );//popup();
	if( !pp ) {
		pp = new QMenu( this );
		connect( pp, SIGNAL( activated( int ) ), SLOT( menuItemClicked( int ) ) );
	}
	pp->clear();
	QStringList items = mIsUndo ? mUndoManager->undoTitles( 10 ) : mUndoManager->redoTitles( 10 );
	foreach( QString item, items )
		pp->addAction( item );
	setMenu( pp );
}
void UserCameraManager::setUserCameraMenu(QMenu &menu)
{
	menu.clear();

	for(int i=0;i<userCameraList.size();++i)
	{
		DynamicAction *aCameraAction=new DynamicAction(&menu);
		aCameraAction->setText(userCameraList[i]->cameraName());
		aCameraAction->setData(QVariant(i));

		menu.addAction(aCameraAction);
	}
}
Ejemplo n.º 23
0
void MainWindow::showConsoleContextMenu(const QPoint &pt)
{
    // Set console output popup menu
    QMenu *menu = ui->consoleOutputTextEdit->createStandardContextMenu();
    menu->clear();
    menu->addAction(ui->actionClear_ConsoleOutput);
    menu->addAction(ui->actionConsoleSync_with_core);
    ui->actionConsoleSync_with_core->setChecked(true);
    ui->consoleOutputTextEdit->setContextMenuPolicy(Qt::CustomContextMenu);

    menu->exec(ui->consoleOutputTextEdit->mapToGlobal(pt));
    delete menu;
}
void CLexiconReadWindow::slotFillBackHistory()
{
	qDebug("CLexiconReadWindow::slotFillBackHistory");

	QMenu* menu = m_actions.backInHistory->popupMenu();
	menu->clear();

	//TODO: take the history list and fill the menu
	QListIterator<QAction*> it(keyChooser()->history()->getBackList());
	while (it.hasNext()) {
		menu->addAction(it.next());
	}
}
Ejemplo n.º 25
0
void QgsComposerMapWidget::aboutToShowKeepLayersVisibilityPresetsMenu()
{
  // this menu is for the case when setting "keep layers" and "keep layer styles"
  // and the preset configuration is copied. The preset is not followed further.

  QMenu *menu = qobject_cast<QMenu *>( sender() );
  if ( !menu )
    return;

  menu->clear();
  Q_FOREACH ( const QString &presetName, QgsProject::instance()->mapThemeCollection()->mapThemes() )
  {
    menu->addAction( presetName, this, SLOT( keepLayersVisibilityPresetSelected() ) );
  }
Ejemplo n.º 26
0
void AnalyseForm::aboutToShowBlacklistMenu()
{
    QMenu * menu = ui->blacklist_btn->menu();
    menu->clear();

    QAction * action;

    for (int i = 0; i < page->exceptionBundleCount(); ++i) {
        ExceptionBundle * bundle = page->exceptionBundleAt(i);
        action = new QAction(menu);
        action->setText(bundle->name());
        action->setData(bundle->index());
        menu->addAction(action);
    }
}
Ejemplo n.º 27
0
SeparateChatWindow::SeparateChatWindow(const QString &protocol_name,
                                       const QString &account_name, const QString &item_name,
                                       QWidget *parent)
    : QWidget(parent)
    , m_abstract_chat_layer(AbstractChatLayer::instance())
    , m_protocol_name(protocol_name)
    , m_account_name(account_name)
    , m_item_name(item_name)
    , m_plugin_system(PluginSystem::instance())
    , m_last_message_sender(true)
    , m_lock_for_first_message(false)
    , m_text_changed(false)
    , m_last_message_icon_position(0)
    , m_last_message_position(0)
{
  ui.setupUi(this);
  m_edit = ui.chatInputEdit;
  m_log = ui.chatLog;
  m_log->setOpenExternalLinks(true);
  m_edit->installEventFilter(this);

  QSoftMenuBar::setLabel(this, Qt::Key_Back, QSoftMenuBar::NoLabel);
  QSoftMenuBar::setLabel(m_log, Qt::Key_Back, QSoftMenuBar::NoLabel);
  QSoftMenuBar::setLabel(m_edit, Qt::Key_Back, QString::null, tr("Send"));
  QMenu *menu = QSoftMenuBar::menuFor(this);
  menu->clear();
  menu->addAction(tr("Clear Chat"), this, SLOT(clearChat()));
  menu->addSeparator();
  menu->addAction(tr("Close Chat"), this, SLOT(deleteLater()));

  m_contact_name = m_item_name;
  m_own_name = m_account_name;

  updateInfo();

  setWindowTitle(QString("%1").arg(m_contact_name));
  m_edit->setFocus();

  connect(this, SIGNAL(customContextMenuRequested(const QPoint &)),
          SLOT(onCustomContextMenuRequested(const QPoint &)));
  //setIconsToButtons();

  m_scroll_at_max = true;
  m_current_scroll_position = 0;
  m_last_history = true;
}
Ejemplo n.º 28
0
void ShowXmlConsoleAction::updateShowXmlConsoleMenu()
{
    QVector<Account> jabberAccounts = m_accountManager->byProtocolName("jabber");

    for (auto action : actions())
    {
        QMenu *menu = action->menu();
        if (jabberAccounts.isEmpty() || 1 == m_accountManager->items().count())
        {
            delete menu;
            action->setMenu(0);

            if (jabberAccounts.isEmpty())
            {
                action->setData(QVariant());
                action->setVisible(false);
            }
            else
            {
                action->setData(QVariant::fromValue(jabberAccounts.at(0)));
                action->setVisible(true);
            }
        }
        else
        {
            if (menu)
                menu->clear();
            else
            {
                menu = new QMenu();
                action->setMenu(menu);
                connect(menu, SIGNAL(triggered(QAction *)), this, SLOT(menuActionTriggered(QAction *)));
            }

            for (auto const &account : jabberAccounts)
            {
                QAction *menuAction =
                    menu->addAction(QString("%1 (%2)").arg(account.accountIdentity().name(), account.id()));
                menuAction->setData(QVariant::fromValue(account));
            }

            action->setData(QVariant());
            action->setVisible(true);
        }
    }
}
Ejemplo n.º 29
0
QMenu* MaterialCollectionItem::get_single_item_context_menu() const
{
    QMenu* menu = ItemBase::get_single_item_context_menu();
    menu->clear();

    menu->addSeparator();
    menu->addAction("Create Generic Material...", this, SLOT(slot_create_generic()));
#ifdef APPLESEED_WITH_OSL
    menu->addAction("Create OSL Material...", this, SLOT(slot_create_osl()));
#endif

#ifdef APPLESEED_WITH_DISNEY_MATERIAL
    menu->addSeparator();
    menu->addAction("Create Disney Material...", this, SLOT(slot_create_disney()));
    menu->addAction("Import Disney Material...", this, SLOT(slot_import_disney()));
#endif

    return menu;
}
Ejemplo n.º 30
0
void VersionController::onNewerVersionMenuAboutToShow()
{
    QMenu *menu = mSetToNewerVersionAction->menu();
    menu->clear();

    int menuEntries = 0;
    for( int versionIndex = mVersionControl->versionIndex()+1;
         versionIndex < mVersionControl->versionCount() && menuEntries < MaxMenuEntries;
         ++versionIndex, ++menuEntries )
    {
        DocumentVersionData versionData = mVersionControl->versionData( versionIndex );

        const QString changeComment = versionData.changeComment();

        const QString actionText = i18nc( "@action Redo: [change]", "Redo: %1", changeComment );

        QAction *action = menu->addAction( actionText );
        action->setData( versionIndex );
    }
}