Esempio n. 1
0
void Menu::populateCharacterEncodingMenu()
{
	if (!m_actionGroup)
	{
		QList<int> textCodecs;
		textCodecs << 106 << 1015 << 1017 << 4 << 5 << 6 << 7 << 8 << 82 << 10 << 85 << 12 << 13 << 109 << 110 << 112 << 2250 << 2251 << 2252 << 2253 << 2254 << 2255 << 2256 << 2257 << 2258 << 18 << 39 << 17 << 38 << 2026;

		m_actionGroup = new QActionGroup(this);
		m_actionGroup->setExclusive(true);

		QAction *defaultAction = QMenu::addAction(tr("Auto Detect"));
		defaultAction->setData(-1);
		defaultAction->setCheckable(true);

		m_actionGroup->addAction(defaultAction);

		addSeparator();

		for (int i = 0; i < textCodecs.count(); ++i)
		{
			QTextCodec *codec = QTextCodec::codecForMib(textCodecs.at(i));

			if (!codec)
			{
				continue;
			}

			QAction *textCodecAction = QMenu::addAction(Utils::elideText(codec->name(), this));
			textCodecAction->setData(textCodecs.at(i));
			textCodecAction->setCheckable(true);

			m_actionGroup->addAction(textCodecAction);
		}
	}

	MainWindow *mainWindow = MainWindow::findMainWindow(parent());
	const QString encoding = (mainWindow ? mainWindow->getWindowsManager()->getOption(QLatin1String("Content/DefaultCharacterEncoding")).toString().toLower() : QString());

	for (int i = 2; i < actions().count(); ++i)
	{
		QAction *action = actions().at(i);

		if (!action)
		{
			continue;
		}

		action->setChecked(encoding == action->text().toLower());

		if (action->isChecked())
		{
			break;
		}
	}

	if (!m_actionGroup->checkedAction() && !actions().isEmpty())
	{
		actions().first()->setChecked(true);
	}
}
Esempio n. 2
0
void StatusBarToolButton::paintEvent(QPaintEvent* event) {
	if (mGroupPosition == NotGrouped) {
		QToolButton::paintEvent(event);
		return;
	}
	QStylePainter painter(this);
	QStyleOptionToolButton opt;
	initStyleOption(&opt);
	QStyleOptionToolButton panelOpt = opt;

	// Panel
	QRect& panelRect = panelOpt.rect;
	switch (mGroupPosition) {
	case GroupLeft:
		panelRect.setWidth(panelRect.width() * 2);
		break;
	case GroupCenter:
		panelRect.setLeft(panelRect.left() - panelRect.width());
		panelRect.setWidth(panelRect.width() * 3);
		break;
	case GroupRight:
		panelRect.setLeft(panelRect.left() - panelRect.width());
		break;
	case NotGrouped:
		Q_ASSERT(0);
	}
	painter.drawPrimitive(QStyle::PE_PanelButtonTool, panelOpt);

	// Separator
	const int y1 = opt.rect.top() + 6;
	const int y2 = opt.rect.bottom() - 6;
	if (mGroupPosition & GroupRight) {
		const int x = opt.rect.left();
		painter.setPen(opt.palette.color(QPalette::Light));
		painter.drawLine(x, y1, x, y2);
	}
	if (mGroupPosition & GroupLeft) {
		const int x = opt.rect.right();
		painter.setPen(opt.palette.color(QPalette::Mid));
		painter.drawLine(x, y1, x, y2);
	}

	// Text
	painter.drawControl(QStyle::CE_ToolButtonLabel, opt);

	// Filtering message on tooltip text for CJK to remove accelerators.
	// Quoting ktoolbar.cpp:
	// """
	// CJK languages use more verbose accelerator marker: they add a Latin
	// letter in parenthesis, and put accelerator on that. Hence, the default
	// removal of ampersand only may not be enough there, instead the whole
	// parenthesis construct should be removed. Provide these filtering i18n
	// messages so that translators can use Transcript for custom removal.
	// """
	if (!actions().isEmpty()) {
		QAction* action = actions().first();
		setToolTip(i18nc("@info:tooltip of custom toolbar button", "%1", action->toolTip()));
	}
}
Esempio n. 3
0
QList<QAction *> BOpenSaveEditorModule::actions(bool extended)
{
    QList<QAction *> list;
    list << actions(OpenActionGroup, extended);
    list << actions(SaveActionGroup, extended);
    list << actions(CloseActionGroup, extended);
    return list;
}
 // DocumentUndoObserver
 void onAddUndoState(DocumentUndo* history) override {
   ASSERT(history->currentState());
   Item* item = new Item(history->currentState());
   actions()->addChild(item);
   actions()->layout();
   view()->updateView();
   actions()->selectChild(item);
 }
  void clearList() {
    ui::Widget* child;
    while ((child = actions()->getFirstChild()))
      delete child;

    actions()->layout();
    view()->updateView();
  }
Esempio n. 6
0
QList<QAction *> BEditEditorModule::actions(bool extended)
{
    QList<QAction *> list;
    list << actions(ClipboardActionGroup, extended);
    list << actions(UndoRedoActionGroup, extended);
    if (!d_func()->actSwitchMode.isNull())
        list << d_func()->actSwitchMode;
    return list;
}
 void selectState(const undo::UndoState* state) {
   for (auto child : actions()->getChildren()) {
     Item* item = static_cast<Item*>(child);
     if (item->state() == state) {
       actions()->selectChild(item);
       break;
     }
   }
 }
Esempio n. 8
0
KPlayerActionList::~KPlayerActionList()
{
#ifdef DEBUG_KPLAYER_ACTIONLIST
  kdDebugTime() << "Destroying action list\n";
#endif
  for ( QList<QAction*>::ConstIterator iterator (actions().begin()); iterator != actions().end(); ++ iterator )
    delete *iterator;
  m_actions.clear();
}
Esempio n. 9
0
void Hotkey::saveSettings(QSettings& settings) const
{
	keySequence().saveSettings(settings);

	settings.beginWriteArray("actions");
	for (int i = 0; i < actions().size(); i++)
	{
		settings.setArrayIndex(i);
		actions()[i].saveSettings(settings);
	}
	settings.endArray();
}
void DataWidget::updateAction(DataWidgetType newWidget)
{
    for (int i = 0; i < actions().count(); i++)
    {
        if (actions().at(i)->text().compare(_dataWidgetNames->value(newWidget))
            == 0)
            {
            actions().at(i)->setChecked(true);
            return;
        }
    }
}
Esempio n. 11
0
void pDockWidgetTitleBar::addSeparator( int index )
{
	if ( index != -1 ) {
		index++;
	}
	
	if ( index >= 0 && index < actions().count() ) {
		QToolBar::insertSeparator( actions().value( index ) );
	}
	else {
		QToolBar::addSeparator();
	}
}
Esempio n. 12
0
void
LauncherContextualMenu::setFolded(int folded)
{
    if (folded == m_folded) {
        return;
    }

    if (folded) {
        /* Remove all actions but the title. */
        for (int i = actions().size(); i > 0; --i) {
            QAction* action = actions().at(i - 1);
            if (action != m_titleAction) {
                removeAction(action);
                if (action->parent() == this) {
                    /* Delete the action only if we "own" it,
                       otherwise let its parent take care of it. */
                    delete action;
                }
            }
        }
    } else {
        int prevWidth = width();
        int left = x(), top = y();
        addSeparator();
        m_launcherItem->createMenuActions();

        QRect screenGeometry = QApplication::desktop()->screenGeometry(this);
        if (QApplication::isRightToLeft()) {
            left -= width() - prevWidth;
        }
        if (height() <= screenGeometry.height()) {
            /* Adjust the position of the menu only if it fits entirely on the screen. */
            int menuBottomEdge = y() + height();
            int screenBottomEdge = screenGeometry.y() + screenGeometry.height();
            if (menuBottomEdge > screenBottomEdge) {
                /* The menu goes offscreen, shift it upwards. */
                m_arrowY += menuBottomEdge - screenBottomEdge;
                top = screenBottomEdge - height();
            }
        }
        move(left, top);
        if (!transparencyAvailable()) {
            /* The arrow has moved relatively to the menu. */
            updateMask();
        }
    }

    m_folded = folded;

    Q_EMIT foldedChanged(m_folded);
}
Esempio n. 13
0
void ActionLineEdit::contextMenuEvent(QContextMenuEvent *e)
{
	QMenu *menu = createStandardContextMenu();
	if (actions().count() > 0) {
		QAction *before = NULL;
		if (menu->actions().count() > 0) {
			before = menu->actions().first();
		}
		menu->insertActions(before, actions());
		menu->insertSeparator(before);
	}
	menu->exec(e->globalPos());
	delete menu;
}
Esempio n. 14
0
void Menu::populateUserAgentMenu()
{
	if (m_actionGroup)
	{
		m_actionGroup->deleteLater();

		clear();
	}

	MainWindow *mainWindow = MainWindow::findMainWindow(parent());
	const QStringList userAgents = NetworkManagerFactory::getUserAgents();
	const QString userAgent = (mainWindow ? mainWindow->getWindowsManager()->getOption(QLatin1String("Network/UserAgent")).toString() : QString());

	m_actionGroup = new QActionGroup(this);
	m_actionGroup->setExclusive(true);

	QAction *defaultAction = QMenu::addAction(tr("Default"));
	defaultAction->setData(QLatin1String("default"));
	defaultAction->setCheckable(true);
	defaultAction->setChecked(userAgent == QLatin1String("default"));

	m_actionGroup->addAction(defaultAction);

	addSeparator();

	for (int i = 0; i < userAgents.count(); ++i)
	{
		const QString title = NetworkManagerFactory::getUserAgent(userAgents.at(i)).title;
		QAction *userAgentAction = QMenu::addAction((title.isEmpty() ? tr("(Untitled)") : Utils::elideText(title, this)));
		userAgentAction->setData(userAgents.at(i));
		userAgentAction->setCheckable(true);
		userAgentAction->setChecked(userAgent == userAgents.at(i));

		m_actionGroup->addAction(userAgentAction);
	}

	addSeparator();

	QAction *customAction = QMenu::addAction(tr("Custom"));
	customAction->setData(QLatin1String("custom"));
	customAction->setCheckable(true);
	customAction->setChecked(userAgent.startsWith(QLatin1String("custom;")));

	m_actionGroup->addAction(customAction);

	if (!m_actionGroup->checkedAction() && actions().count() > 2)
	{
		actions().first()->setChecked(true);
	}
}
Esempio n. 15
0
void djvViewFileMenu::menuUpdate()
{
    _p->recent->clear();

    Q_FOREACH(QAction * action,
        actions()->group(djvViewFileActions::RECENT_GROUP)->actions())
        _p->recent->addAction(action);

    _p->layer->clear();

    Q_FOREACH(QAction * action,
        actions()->group(djvViewFileActions::LAYER_GROUP)->actions())
        _p->layer->addAction(action);
}
Esempio n. 16
0
QWidget* pDockWidgetTitleBar::addAction( QAction* action, int index )
{
	if ( index != -1 ) {
		index++;
	}
	
	if ( index >= 0 && index < actions().count() ) {
		QToolBar::insertAction( actions().value( index ), action );
	}
	else {
		QToolBar::addAction( action );
	}
	
	return widgetForAction( action );
}
Esempio n. 17
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
        }
    }
}
Esempio n. 18
0
bool EffectTruncSilence::SetAutomationParameters(EffectAutomationParameters & parms)
{
   wxArrayString actions(kNumActions, kActionStrings);
   actions.Insert(wxT("0"), 0); // Compatible with 2.1.0 and before
   actions.Insert(wxT("1"), 1); // Compatible with 2.1.0 and before

   ReadAndVerifyDouble(Minimum);
   ReadAndVerifyDouble(Truncate);
   ReadAndVerifyDouble(Compress);
   ReadAndVerifyEnum(DbIndex, mDbChoices);
   ReadAndVerifyEnum(ActIndex, actions);
   ReadAndVerifyBool(Independent);

   mInitialAllowedSilence = Minimum;
   mTruncLongestAllowedSilence = Truncate;
   mSilenceCompressPercent = Compress;
   mTruncDbChoiceIndex = DbIndex;
   mActionIndex = ActIndex;
   mbIndependent = Independent;

   // Readjust for 2.1.0 or before
   if (mActionIndex >= kNumActions)
   {
      mActionIndex -= kNumActions;
   }

   return true;
}
Esempio n. 19
0
CoverArtLabel::~CoverArtLabel()
{
    QList< QAction* > artActions = actions();
    foreach( QAction *act, artActions )
        removeAction( act );
    if ( p_item ) vlc_gc_decref( p_item );
}
Esempio n. 20
0
void powermen(void)
  {

  /* Xor graphics context */
  icontxxt = setxor(icontx);

  /* Set default color in temporary GC for box */
  wicolor(icontxxt,colorgo+icolorov);

  chksiz = TRUE;
  erase = FALSE;

  if (iwintyp == 3) 
     {  /* Fixed window size and location */

     /* Put a box */
     xorbox(iwin,icontxxt, TRUE, ixulw, iyulw, nsamw, nroww);

     /* show power spectrum */
     wid_power(TRUE,&chksiz); 
     XFlush(idispl);
     return;
     }

  showbutx("Set temporary power spectrum.",
           "Set permanent power spectrum.",
           "Stop this routine.",FALSE);

  /* Setup movement on pointer motion, button press etc... */
  actions(iw_win,"powerbut_pop",powerbut_pop,"M123L");

  XFlush(idispl);
  }
int main(){

    const long N = 100007;
    std::vector<long> number(N, 0);
    std::vector<long> actions(N, 0);

    long n; scanf("%ld", &n);
    for(long p = 0; p < n; p++){
        long a; scanf("%ld", &a);
        long count(0);
        while(a){
            ++number[a];
            actions[a] += count;
            a /= 2;
            ++count;
        }
    }

    long target(N);
    for(long p = N - 1; p >= 0; p--){if(number[p] == n){target = p; break;}}

    long total = actions[target];
    target *= 2; while((target < N) && (2 * number[target] >= n)){total -= (2 * number[target] - n); target *= 2;}
    printf("%ld\n", total);

    return 0;
}
Esempio n. 22
0
void InventoryTreeView::contextMenuEvent(QContextMenuEvent *event)
{
    // Do mousePressEvent so that the right item gets selected before we show the menu
    // (right-click doesn't do this automatically).
    QMouseEvent mouseEvent(QEvent::MouseButtonPress, event->pos(), event->globalPos(),
        Qt::LeftButton, Qt::LeftButton, Qt::NoModifier);

    mousePressEvent(&mouseEvent);

    QModelIndex index = selectionModel()->currentIndex();
    if (!index.isValid())
        return;

    QMenu *menu = new QMenu(this);
    QListIterator<QAction *> it(actions());
    while(it.hasNext())
    {
        QAction *action = it.next();
        if (action->isEnabled())
        {
            // This is kind of hack, but we might have case that base language is not english. 
            InventoryAction* act = qobject_cast<InventoryAction* >(action);
            QString text = QApplication::translate("Inventory::InventoryWindow", act->GetText().toStdString().c_str());
            action->setText(text);

            menu->addAction(action);
        } 
   }

    if (menu->actions().size() > 1) // separator "action" is always enabled, hence the 1
        menu->popup(event->globalPos());
}
Esempio n. 23
0
void PreviewActionGroup::updateDeviceProfiles()
{
    typedef QList<DeviceProfile> DeviceProfileList;
    typedef QList<QAction *> ActionList;

    const QDesignerSharedSettings settings(m_core);
    const DeviceProfileList profiles = settings.deviceProfiles();
    const ActionList al = actions();
    // Separator?
    const bool hasProfiles = !profiles.empty();
    al.at(MaxDeviceActions)->setVisible(hasProfiles);
    int index = 0;
    if (hasProfiles) {
        // Make actions visible
        const int maxIndex = qMin(static_cast<int>(MaxDeviceActions), profiles.size());
        for (; index < maxIndex; index++) {
            const QString name = profiles.at(index).name();
            al.at(index)->setText(name);
            al.at(index)->setVisible(true);
        }
    }
    // Hide rest
    for ( ; index < MaxDeviceActions; index++)
        al.at(index)->setVisible(false);
}
Esempio n. 24
0
QAction* PopupMenu::findActionFromData(const QVariant& v) const
{
   QList<QAction*> list = actions();
   for(int i = 0; i < list.size(); ++i)
   {
      QAction* act = list[i];
      if(PopupMenu* menu = qobject_cast<PopupMenu*>(act->menu()))
      {
         if(QAction* actm = menu->findActionFromData(v))      // Recursive.
            return actm;
      }

      // "Operator == Compares this QVariant with v and returns true if they are equal,
      //   otherwise returns false. In the case of custom types, their equalness operators
      //   are not called. Instead the values' addresses are compared."
      //
      // Take care of struct Route first. Insert other future custom structures here too !
      if(act->data().canConvert<MusECore::Route>() && v.canConvert<MusECore::Route>())
      {
         if(act->data().value<MusECore::Route>() == v.value<MusECore::Route>())
            return act;
      }
      else
         if(act->data() == v)
            return act;
   }
   return 0;
}
Esempio n. 25
0
void MessageWidget::removeAllActions()
{
     QList<QAction *> acts=actions();
     for (QAction *a: acts) {
         removeAction(a);
     }
}
Esempio n. 26
0
void Actions_AxisymmetricFudge_InterpTables::testActions(void){
    VecDoub X ={8.,0.,0.,0.2,2.1,0.3};
    bool withfreq = true;
    for(auto i:actions(X,&withfreq))std::cout<<i<<" ";
    for(auto i:UV->actions(X))std::cout<<i<<" ";
    std::cout<<std::endl;
}
Esempio n. 27
0
bool TitleWidget::eventFilter(QObject *o, QEvent *event)
{
    switch(event->type()) {
    case QEvent::HoverEnter:
        if (isEnabled() && o==this) {
            #ifdef Q_OS_MAC
            setStyleSheet(QString("QLabel{color:%1;}").arg(OSXStyle::self()->viewPalette().highlight().color().name()));
            #else
            setStyleSheet(QLatin1String("QLabel{color:palette(highlight);}"));
            #endif
        }
        break;
    case QEvent::HoverLeave:
        if (isEnabled() && o==this) {
            setStyleSheet(QString());
        }
        break;
    case QEvent::MouseButtonPress:
        if (Qt::LeftButton==static_cast<QMouseEvent *>(event)->button() && Qt::NoModifier==static_cast<QMouseEvent *>(event)->modifiers()) {
            pressed=true;
        }
        break;
    case QEvent::MouseButtonRelease:
        if (pressed && Qt::LeftButton==static_cast<QMouseEvent *>(event)->button() && !QApplication::overrideCursor()) {
            actions().first()->trigger();
        }
        pressed=false;
        break;
    default:
        break;
    }
    return QWidget::eventFilter(o, event);
}
Esempio n. 28
0
void djvViewImageMenu::menuUpdate()
{
    _p->displayProfileMenu->clear();

    _p->displayProfileMenu->addActions(
        actions()->group(djvViewImageActions::DISPLAY_PROFILE_GROUP)->actions());
}
Esempio n. 29
0
CoverArtLabel::~CoverArtLabel()
{
    QList< QAction* > artActions = actions();
    foreach( QAction *act, artActions )
        removeAction( act );
    if ( p_item ) input_item_Release( p_item );
}
 void MotionPlanningFrame::loadWaypointsToDisplay(QList<QListWidgetItem*> items)
 {
     std::vector<apc_msgs::PrimitiveAction> actions(items.count());
     for (int i = 0; i < items.count(); i++)
         loadActionFromData(actions[i], items[i]->data(Qt::UserRole));
     loadWaypointsToDisplay(actions);
 }