当前位置: 首页>>代码示例>>C++>>正文


C++ QAction类代码示例

本文整理汇总了C++中QAction的典型用法代码示例。如果您正苦于以下问题:C++ QAction类的具体用法?C++ QAction怎么用?C++ QAction使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了QAction类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: QMainWindow


//.........这里部分代码省略.........
    ui->table_packets->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
    ui->table_packets->horizontalHeader()->setStretchLastSection(true);
    ui->table_packets->verticalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);

    m_sortFilterProxy = new QSortFilterProxyModel(this);
    m_sortFilterProxy->setSourceModel(&model);
    ui->table_packets->setModel(m_sortFilterProxy);

    connect(ui->table_packets->selectionModel(), SIGNAL(currentRowChanged(QModelIndex, QModelIndex)),
            this, SLOT(model_currentRowChanged(QModelIndex, QModelIndex)));
    connect(ui->action_preferences, SIGNAL(triggered()), this, SLOT(open_preference_window()));

    ui->tree_packet->setHeaderLabels(QStringList({QStringLiteral("Key"), QStringLiteral("Value")}));
    ui->tree_packet->setColumnCount(2);
    loadStatsFunctions(HungrySniffer_Core::core->stats, *ui->menuStats);
#ifdef PYTHON_CMD
    QWidget* verticalLayoutWidget = new QWidget(ui->splitter);
    QVBoxLayout* panel_python = new QVBoxLayout(verticalLayoutWidget);
    panel_python->setContentsMargins(0, 0, 0, 0);
    lb_cmd = new QPlainTextEdit(verticalLayoutWidget);
    lb_cmd->setReadOnly(true);
    panel_python->addWidget(lb_cmd);
    QHBoxLayout* horizontalLayout = new QHBoxLayout();
    horizontalLayout->setContentsMargins(0, 0, 0, 0);
    QLabel* img_python = new QLabel(verticalLayoutWidget);
    QSizePolicy sizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
    sizePolicy.setHeightForWidth(img_python->sizePolicy().hasHeightForWidth());
    img_python->setSizePolicy(sizePolicy);
    img_python->setMaximumSize(QSize(32, 32));
    img_python->setPixmap(QPixmap(QStringLiteral(":/icons/python.png")));
#ifndef QT_NO_TOOLTIP
    img_python->setToolTip(PythonThread::getVersionString());
#endif
    horizontalLayout->addWidget(img_python);
    tb_command = new History_Line_Edit(verticalLayoutWidget);
    connect(tb_command, SIGNAL(returnPressed()), this, SLOT(tb_command_returnPressed()));
    horizontalLayout->addWidget(tb_command);
    panel_python->addLayout(horizontalLayout);
    ui->splitter->addWidget(verticalLayoutWidget);

    this->py_checkCommand.reset();
    connect(this, SIGNAL(sig_appendToCmd(QString)), this, SLOT(lb_cmd_appendString(QString)));
    connect(this, SIGNAL(sig_clearCmd()), this, SLOT(lb_cmd_clear()));
#ifndef QT_NO_DEBUG
    python_thread.setObjectName(QStringLiteral("Python Interpreter"));
#endif
    python_thread.start();
#else
    ui->action_Python->setVisible(false);
#endif
    setAcceptDrops(true);

    if(HungrySniffer_Core::core->preferences.empty())
        ui->action_preferences->setVisible(false);

    { // settings block
        QSettings& settings = *Preferences::settings;
        QVariant var;
        settings.beginGroup(QStringLiteral("General"));
        settings.beginGroup(QStringLiteral("UI"));
        bool flag = settings.value(QStringLiteral("splitter_sizes"), false).toBool();
        default_open_location = settings.value(QStringLiteral("default_dir")).toString();
        max_recent_files = settings.value(QStringLiteral("max_recent_files"), 10).toInt();
        model.showColors = settings.value(QStringLiteral("colored_packets"), true).toBool();
        settings.endGroup();
        settings.endGroup();

        settings.beginGroup(QStringLiteral("SniffWindow"));
        if(flag)
        {
            var = settings.value(QStringLiteral("splitter_sizes"));
            if(!var.isNull())
            {
                QList<int> sizes;
                QVariantList list = var.value<QVariantList>();
                for(const auto& i : list)
                    sizes << i.toInt();
                ui->splitter->setSizes(sizes);
            }
        }
        var = settings.value(QStringLiteral("recent_files"));
        if(!var.isNull())
        {
            this->recentFiles_paths = var.toStringList();
        }
        settings.endGroup();
    }

    { // recent files
        recentFiles_actions.resize(max_recent_files, nullptr);
        for(int i = 0; i < max_recent_files; i++)
        {
            QAction* temp = recentFiles_actions[i] = new QAction(ui->menu_recent_files);
            temp->setData(i);
            connect(temp, SIGNAL(triggered(bool)), this, SLOT(recentFile_triggered()));
            ui->menu_recent_files->addAction(temp);
        }
        updateRecentsMenu();
    }
}
开发者ID:arthurzam,项目名称:hungry-sniffer,代码行数:101,代码来源:sniff_window.cpp

示例2: TaskFemConstraint

TaskFemConstraintForce::TaskFemConstraintForce(ViewProviderFemConstraintForce *ConstraintView,QWidget *parent)
    : TaskFemConstraint(ConstraintView, parent, "fem-constraint-force")
{
    // we need a separate container widget to add all controls to
    proxy = new QWidget(this);
    ui = new Ui_TaskFemConstraintForce();
    ui->setupUi(proxy);
    QMetaObject::connectSlotsByName(this);

    // Create a context menu for the listview of the references
    QAction* action = new QAction(tr("Delete"), ui->listReferences);
    action->connect(action, SIGNAL(triggered()),
                    this, SLOT(onReferenceDeleted()));
    ui->listReferences->addAction(action);
    ui->listReferences->setContextMenuPolicy(Qt::ActionsContextMenu);

    connect(ui->spinForce, SIGNAL(valueChanged(double)),
            this, SLOT(onForceChanged(double)));
    connect(ui->buttonReference, SIGNAL(pressed()),
            this, SLOT(onButtonReference()));
    connect(ui->buttonDirection, SIGNAL(pressed()),
            this, SLOT(onButtonDirection()));
    connect(ui->checkReverse, SIGNAL(toggled(bool)),
            this, SLOT(onCheckReverse(bool)));

    this->groupLayout()->addWidget(proxy);

    // Temporarily prevent unnecessary feature recomputes
    ui->spinForce->blockSignals(true);
    ui->listReferences->blockSignals(true);
    ui->buttonReference->blockSignals(true);
    ui->buttonDirection->blockSignals(true);
    ui->checkReverse->blockSignals(true);

    // Get the feature data
    Fem::ConstraintForce* pcConstraint = static_cast<Fem::ConstraintForce*>(ConstraintView->getObject());
    double f = pcConstraint->Force.getValue();
    std::vector<App::DocumentObject*> Objects = pcConstraint->References.getValues();
    std::vector<std::string> SubElements = pcConstraint->References.getSubValues();
    std::vector<std::string> dirStrings = pcConstraint->Direction.getSubValues();
    QString dir;
    if (!dirStrings.empty())
        dir = makeRefText(pcConstraint->Direction.getValue(), dirStrings.front());
    bool reversed = pcConstraint->Reversed.getValue();

    // Fill data into dialog elements
    ui->spinForce->setMinimum(0);
    ui->spinForce->setMaximum(FLOAT_MAX);
    ui->spinForce->setValue(f);
    ui->listReferences->clear();
    for (std::size_t i = 0; i < Objects.size(); i++)
        ui->listReferences->addItem(makeRefText(Objects[i], SubElements[i]));
    if (Objects.size() > 0)
        ui->listReferences->setCurrentRow(0, QItemSelectionModel::ClearAndSelect);
    ui->lineDirection->setText(dir.isEmpty() ? tr("") : dir);
    ui->checkReverse->setChecked(reversed);

    ui->spinForce->blockSignals(false);
    ui->listReferences->blockSignals(false);
    ui->buttonReference->blockSignals(false);
    ui->buttonDirection->blockSignals(false);
    ui->checkReverse->blockSignals(false);

    updateUI();
}
开发者ID:AllenBootung,项目名称:FreeCAD,代码行数:65,代码来源:TaskFemConstraintForce.cpp

示例3: setupContextMenu

void ViewProviderLoft::setupContextMenu(QMenu* menu, QObject* receiver, const char* member)
{
    QAction* act;
    act = menu->addAction(QObject::tr("Edit loft"), receiver, member);
    act->setData(QVariant((int)ViewProvider::Default));
}
开发者ID:abdullahtahiriyo,项目名称:FreeCAD_sf_master,代码行数:6,代码来源:ViewProviderLoft.cpp

示例4: setupUi

    void setupUi(QMainWindow *MainWindow)
    {
        if (MainWindow->objectName().isEmpty())
            MainWindow->setObjectName(QString::fromUtf8("MainWindow"));
        MainWindow->resize(999, 913);
        actionAbout = new QAction(MainWindow);
        actionAbout->setObjectName(QString::fromUtf8("actionAbout"));
        actionAtlas = new QAction(MainWindow);
        actionAtlas->setObjectName(QString::fromUtf8("actionAtlas"));
        actionMapping = new QAction(MainWindow);
        actionMapping->setObjectName(QString::fromUtf8("actionMapping"));
        actionLibrary = new QAction(MainWindow);
        actionLibrary->setObjectName(QString::fromUtf8("actionLibrary"));
        actionToolbox = new QAction(MainWindow);
        actionToolbox->setObjectName(QString::fromUtf8("actionToolbox"));
        centralwidget = new QWidget(MainWindow);
        centralwidget->setObjectName(QString::fromUtf8("centralwidget"));
        gridLayout = new QGridLayout(centralwidget);
        gridLayout->setObjectName(QString::fromUtf8("gridLayout"));
        mainSizer = new QGridLayout();
        mainSizer->setObjectName(QString::fromUtf8("mainSizer"));
        mainSizer->setVerticalSpacing(14);
        mainSizer->setContentsMargins(0, -1, -1, -1);
        renderFrame = new QFrame(centralwidget);
        renderFrame->setObjectName(QString::fromUtf8("renderFrame"));
        renderFrame->setMinimumSize(QSize(800, 600));
        renderFrame->setFrameShape(QFrame::Box);
        renderFrame->setFrameShadow(QFrame::Raised);

        mainSizer->addWidget(renderFrame, 0, 0, 1, 1);


        gridLayout->addLayout(mainSizer, 0, 0, 1, 1);

        MainWindow->setCentralWidget(centralwidget);
        menubar = new QMenuBar(MainWindow);
        menubar->setObjectName(QString::fromUtf8("menubar"));
        menubar->setGeometry(QRect(0, 0, 999, 21));
        menuFile = new QMenu(menubar);
        menuFile->setObjectName(QString::fromUtf8("menuFile"));
        menuTools = new QMenu(menubar);
        menuTools->setObjectName(QString::fromUtf8("menuTools"));
        menuAbout = new QMenu(menubar);
        menuAbout->setObjectName(QString::fromUtf8("menuAbout"));
        menuWindows = new QMenu(menubar);
        menuWindows->setObjectName(QString::fromUtf8("menuWindows"));
        MainWindow->setMenuBar(menubar);
        statusbar = new QStatusBar(MainWindow);
        statusbar->setObjectName(QString::fromUtf8("statusbar"));
        MainWindow->setStatusBar(statusbar);

        menubar->addAction(menuFile->menuAction());
        menubar->addAction(menuTools->menuAction());
        menubar->addAction(menuWindows->menuAction());
        menubar->addAction(menuAbout->menuAction());
        menuTools->addAction(actionAtlas);
        menuTools->addAction(actionMapping);
        menuAbout->addAction(actionAbout);
        menuWindows->addAction(actionLibrary);
        menuWindows->addAction(actionToolbox);

        retranslateUi(MainWindow);

        QMetaObject::connectSlotsByName(MainWindow);
    } // setupUi
开发者ID:yevgeniy-logachev,项目名称:framework2d,代码行数:65,代码来源:ui_MainWindow.hpp

示例5: QAction

void PlotDataGroupWidget::tableContextMenu(const QPoint& pos) {
    PlotDataGroup* plotDataGroup = dynamic_cast<PlotDataGroup*>(processor_);
    QModelIndex index = table_->indexAt(pos);
    contextMenuTable_->clear();
    addFunctionMenu_->clear();
    averageFunctionMenu_->clear();
    histogramFunctionMenu_->clear();
    PlotData* data = const_cast<PlotData*>(plotDataGroup->getPlotData());
    QAction* newAct;
    QList<QVariant>* qlist = new QList<QVariant>();
    std::string s;

    s = "Reset All";
    newAct = new QAction(QString::fromStdString(s),this);
    contextMenuTable_->addAction(newAct);
    QObject::connect(newAct,SIGNAL(triggered()),this,SLOT(selectResetAll()));

    s = "Reset Last";
    newAct = new QAction(QString::fromStdString(s),this);
    contextMenuTable_->addAction(newAct);
    QObject::connect(newAct,SIGNAL(triggered()),this,SLOT(selectResetLast()));

    contextMenuTable_->addSeparator();
    bool found = false;

    s = "Delete Function";
    newAct = new QAction(QString::fromStdString(s),this);
    qlist->push_back(0);
    qlist->push_back(index.column());
    newAct->setData(QVariant(*qlist));
    addFunctionMenu_->addAction(newAct);
    QObject::connect(newAct,SIGNAL(triggered()),this,SLOT(addFunction()));
    qlist->clear();
    for(size_t i=0; i< aggregatedcolumns.size(); ++i){
        if(index.column() == aggregatedcolumns.at(i).first){
            found = true;
            break;
        }
    }
    if (!found || aggregatedcolumns.size() == 0 || data->getColumnType(index.column()) == PlotBase::EMPTY) {
        newAct->setEnabled(false);
    }
    else {
        newAct->setEnabled(true);
    }
    qlist->clear();

    addFunctionMenu_->addSeparator();

    s = "Arithmetic";
    newAct = new QAction(QString::fromStdString(s),this);
    qlist->push_back(static_cast<int>(AggregationFunction::AVERAGE));
    qlist->push_back(index.column());
    newAct->setData(QVariant(*qlist));
    averageFunctionMenu_->addAction(newAct);
    QObject::connect(newAct,SIGNAL(triggered()),this,SLOT(addFunction()));
    qlist->clear();

    s = "Geometric";
    newAct = new QAction(QString::fromStdString(s),this);
    qlist->push_back(static_cast<int>(AggregationFunction::GEOMETRICMEAN));
    qlist->push_back(index.column());
    newAct->setData(QVariant(*qlist));
    averageFunctionMenu_->addAction(newAct);
    QObject::connect(newAct,SIGNAL(triggered()),this,SLOT(addFunction()));
    qlist->clear();

    s = "Harmonic";
    newAct = new QAction(QString::fromStdString(s),this);
    qlist->push_back(static_cast<int>(AggregationFunction::HARMONICMEAN));
    qlist->push_back(index.column());
    newAct->setData(QVariant(*qlist));
    averageFunctionMenu_->addAction(newAct);
    QObject::connect(newAct,SIGNAL(triggered()),this,SLOT(addFunction()));
    qlist->clear();

    addFunctionMenu_->addMenu(averageFunctionMenu_);

    s = "Count";
    newAct = new QAction(QString::fromStdString(s),this);
    qlist->push_back(static_cast<int>(AggregationFunction::COUNT));
    qlist->push_back(index.column());
    newAct->setData(QVariant(*qlist));
    addFunctionMenu_->addAction(newAct);
    QObject::connect(newAct,SIGNAL(triggered()),this,SLOT(addFunction()));
    qlist->clear();

    s = "Max";
    newAct = new QAction(QString::fromStdString(s),this);
    qlist->push_back(static_cast<int>(AggregationFunction::MAX));
    qlist->push_back(index.column());
    newAct->setData(QVariant(*qlist));
    addFunctionMenu_->addAction(newAct);
    QObject::connect(newAct,SIGNAL(triggered()),this,SLOT(addFunction()));
    qlist->clear();

    s = "Median";
    newAct = new QAction(QString::fromStdString(s),this);
    qlist->push_back(static_cast<int>(AggregationFunction::MEDIAN));
    qlist->push_back(index.column());
//.........这里部分代码省略.........
开发者ID:alvatar,项目名称:smartmatter,代码行数:101,代码来源:plotdatagroupwidget.cpp

示例6: QWidget

BlockingClient::BlockingClient(QWidget *parent)
    : QWidget(parent)
{
    hostLabel = new QLabel(tr("&Server name:"));
    portLabel = new QLabel(tr("S&erver port:"));

    // find out which IP to connect to
    QString ipAddress;
    QList<QHostAddress> ipAddressesList = QNetworkInterface::allAddresses();
    // use the first non-localhost IPv4 address
    for (int i = 0; i < ipAddressesList.size(); ++i) {
        if (ipAddressesList.at(i) != QHostAddress::LocalHost &&
            ipAddressesList.at(i).toIPv4Address()) {
            ipAddress = ipAddressesList.at(i).toString();
            break;
        }
    }
    // if we did not find one, use IPv4 localhost
    if (ipAddress.isEmpty())
        ipAddress = QHostAddress(QHostAddress::LocalHost).toString();

    hostLineEdit = new QLineEdit(ipAddress);
    portLineEdit = new QLineEdit;
    portLineEdit->setValidator(new QIntValidator(1, 65535, this));

#if defined(Q_OS_SYMBIAN) || defined(Q_WS_MAEMO_5) || defined(Q_WS_SIMULATOR)
    Qt::InputMethodHint hints = Qt::ImhDigitsOnly;
    portLineEdit->setInputMethodHints(hints);
#endif

    hostLabel->setBuddy(hostLineEdit);
    portLabel->setBuddy(portLineEdit);

    statusLabel = new QLabel(tr("This examples requires that you run the "
                                "Fortune Server example as well."));
    statusLabel->setWordWrap(true);

#ifdef Q_OS_SYMBIAN
    QMenu *menu = new QMenu(this);
    fortuneAction = menu->addAction(tr("Get Fortune"));
    fortuneAction->setVisible(false);

    QAction *optionsAction = new QAction(tr("Options"), this);
    optionsAction->setMenu(menu);
    optionsAction->setSoftKeyRole(QAction::PositiveSoftKey);
    addAction(optionsAction);

    exitAction = new QAction(tr("Exit"), this);
    exitAction->setSoftKeyRole(QAction::NegativeSoftKey);
    addAction(exitAction);

    connect(fortuneAction, SIGNAL(triggered()), this, SLOT(requestNewFortune()));
    connect(exitAction, SIGNAL(triggered()), this, SLOT(close()));
#else
    getFortuneButton = new QPushButton(tr("Get Fortune"));
    getFortuneButton->setDefault(true);
    getFortuneButton->setEnabled(false);

    quitButton = new QPushButton(tr("Quit"));

    buttonBox = new QDialogButtonBox;
    buttonBox->addButton(getFortuneButton, QDialogButtonBox::ActionRole);
    buttonBox->addButton(quitButton, QDialogButtonBox::RejectRole);

    connect(getFortuneButton, SIGNAL(clicked()), this, SLOT(requestNewFortune()));
    connect(quitButton, SIGNAL(clicked()), this, SLOT(close()));
#endif

    connect(hostLineEdit, SIGNAL(textChanged(QString)),
            this, SLOT(enableGetFortuneButton()));
    connect(portLineEdit, SIGNAL(textChanged(QString)),
            this, SLOT(enableGetFortuneButton()));
//! [0]
    connect(&thread, SIGNAL(newFortune(QString)),
            this, SLOT(showFortune(QString)));
//! [0] //! [1]
    connect(&thread, SIGNAL(error(int,QString)),
            this, SLOT(displayError(int,QString)));
//! [1]

    QGridLayout *mainLayout = new QGridLayout;
    mainLayout->addWidget(hostLabel, 0, 0);
    mainLayout->addWidget(hostLineEdit, 0, 1);
    mainLayout->addWidget(portLabel, 1, 0);
    mainLayout->addWidget(portLineEdit, 1, 1);
    mainLayout->addWidget(statusLabel, 2, 0, 1, 2);
#ifndef Q_OS_SYMBIAN
    mainLayout->addWidget(buttonBox, 3, 0, 1, 2);
#endif
    setLayout(mainLayout);

    setWindowTitle(tr("Blocking Fortune Client"));
    portLineEdit->setFocus();
}
开发者ID:AtlantisCD9,项目名称:Qt,代码行数:94,代码来源:blockingclient.cpp

示例7: showEvent

void GUIManager::showEvent(QShowEvent * /*event*/)
{
    QAction *a = KStars::Instance()->actionCollection()->action( "show_control_panel" );
    a->setEnabled(true);
    a->setChecked(true);
}
开发者ID:seanhoughton,项目名称:kstars,代码行数:6,代码来源:guimanager.cpp

示例8: QVERIFY

void TestGui::testSearch()
{
    QAction* searchAction = m_mainWindow->findChild<QAction*>("actionSearch");
    QVERIFY(searchAction->isEnabled());
    QToolBar* toolBar = m_mainWindow->findChild<QToolBar*>("toolBar");
    QWidget* searchActionWidget = toolBar->widgetForAction(searchAction);
    EntryView* entryView = m_dbWidget->findChild<EntryView*>("entryView");
    QLineEdit* searchEdit = m_dbWidget->findChild<QLineEdit*>("searchEdit");
    QToolButton* clearSearch = m_dbWidget->findChild<QToolButton*>("clearButton");

    QVERIFY(!searchEdit->hasFocus());

    // Enter search
    QTest::mouseClick(searchActionWidget, Qt::LeftButton);
    QTRY_VERIFY(searchEdit->hasFocus());
    // Search for "ZZZ"
    QTest::keyClicks(searchEdit, "ZZZ");
    QTRY_COMPARE(entryView->model()->rowCount(), 0);
    // Escape
    QTest::keyClick(m_mainWindow, Qt::Key_Escape);
    QTRY_VERIFY(!searchEdit->hasFocus());
    // Enter search again
    QTest::mouseClick(searchActionWidget, Qt::LeftButton);
    QTRY_VERIFY(searchEdit->hasFocus());
    // Input and clear
    QTest::keyClicks(searchEdit, "ZZZ");
    QTRY_COMPARE(searchEdit->text(), QString("ZZZ"));
    QTest::mouseClick(clearSearch, Qt::LeftButton);
    QTRY_COMPARE(searchEdit->text(), QString(""));
    // Triggering search should select the existing text
    QTest::keyClicks(searchEdit, "ZZZ");
    QTest::mouseClick(searchActionWidget, Qt::LeftButton);
    QTRY_VERIFY(searchEdit->hasFocus());
    // Search for "some"
    QTest::keyClicks(searchEdit, "some");
    QTRY_COMPARE(entryView->model()->rowCount(), 4);

    clickIndex(entryView->model()->index(0, 1), entryView, Qt::LeftButton);
    QAction* entryEditAction = m_mainWindow->findChild<QAction*>("actionEntryEdit");
    QVERIFY(entryEditAction->isEnabled());
    QWidget* entryEditWidget = toolBar->widgetForAction(entryEditAction);
    QVERIFY(entryEditWidget->isVisible());
    QVERIFY(entryEditWidget->isEnabled());
    QTest::mouseClick(entryEditWidget, Qt::LeftButton);

    QCOMPARE(m_dbWidget->currentMode(), DatabaseWidget::EditMode);

    EditEntryWidget* editEntryWidget = m_dbWidget->findChild<EditEntryWidget*>("editEntryWidget");
    QDialogButtonBox* editEntryWidgetButtonBox = editEntryWidget->findChild<QDialogButtonBox*>("buttonBox");
    QTest::mouseClick(editEntryWidgetButtonBox->button(QDialogButtonBox::Ok), Qt::LeftButton);

    QCOMPARE(m_dbWidget->currentMode(), DatabaseWidget::ViewMode);

    clickIndex(entryView->model()->index(1, 0), entryView, Qt::LeftButton);
    QAction* entryDeleteAction = m_mainWindow->findChild<QAction*>("actionEntryDelete");

    QWidget* entryDeleteWidget = toolBar->widgetForAction(entryDeleteAction);
    QVERIFY(entryDeleteWidget->isVisible());
    QVERIFY(entryDeleteWidget->isEnabled());
    QVERIFY(!m_db->metadata()->recycleBin());

    QTest::mouseClick(entryDeleteWidget, Qt::LeftButton);

    QCOMPARE(entryView->model()->rowCount(), 3);
    QCOMPARE(m_db->metadata()->recycleBin()->entries().size(), 1);

    clickIndex(entryView->model()->index(1, 0), entryView, Qt::LeftButton);
    clickIndex(entryView->model()->index(2, 0), entryView, Qt::LeftButton, Qt::ControlModifier);
    QCOMPARE(entryView->selectionModel()->selectedRows().size(), 2);

    MessageBox::setNextAnswer(QMessageBox::No);
    QTest::mouseClick(entryDeleteWidget, Qt::LeftButton);
    QCOMPARE(entryView->model()->rowCount(), 3);
    QCOMPARE(m_db->metadata()->recycleBin()->entries().size(), 1);

    MessageBox::setNextAnswer(QMessageBox::Yes);
    QTest::mouseClick(entryDeleteWidget, Qt::LeftButton);
    QCOMPARE(entryView->model()->rowCount(), 1);
    QCOMPARE(m_db->metadata()->recycleBin()->entries().size(), 3);

    QWidget* closeSearchButton = m_dbWidget->findChild<QToolButton*>("closeSearchButton");
    QTest::mouseClick(closeSearchButton, Qt::LeftButton);

    QCOMPARE(entryView->model()->rowCount(), 1);
}
开发者ID:sebastianhaas,项目名称:keepassx,代码行数:85,代码来源:TestGui.cpp

示例9: tabAt

void TabBarWidget::contextMenuEvent(QContextMenuEvent *event)
{
	if (event->reason() == QContextMenuEvent::Mouse)
	{
		event->accept();

		return;
	}

	m_clickedTab = tabAt(event->pos());

	hidePreview();

	MainWindow *mainWindow = MainWindow::findMainWindow(this);
	QVariantMap parameters;
	QMenu menu(this);
	menu.addAction(ActionsManager::getAction(ActionsManager::NewTabAction, this));
	menu.addAction(ActionsManager::getAction(ActionsManager::NewTabPrivateAction, this));

	if (m_clickedTab >= 0)
	{
		Window *window = getWindow(m_clickedTab);

		if (window)
		{
			parameters[QLatin1String("window")] = window->getIdentifier();
		}

		const int amount = (count() - getPinnedTabsAmount());
		const bool isPinned = getTabProperty(m_clickedTab, QLatin1String("isPinned"), false).toBool();
		Action *cloneTabAction = new Action(ActionsManager::CloneTabAction, &menu);
		cloneTabAction->setEnabled(getTabProperty(m_clickedTab, QLatin1String("canClone"), false).toBool());
		cloneTabAction->setData(parameters);

		Action *pinTabAction = new Action(ActionsManager::PinTabAction, &menu);
		pinTabAction->setOverrideText(isPinned ? QT_TRANSLATE_NOOP("actions", "Unpin Tab") : QT_TRANSLATE_NOOP("actions", "Pin Tab"));
		pinTabAction->setData(parameters);

		Action *detachTabAction = new Action(ActionsManager::DetachTabAction, &menu);
		detachTabAction->setEnabled(count() > 1);
		detachTabAction->setData(parameters);

		Action *closeTabAction = new Action(ActionsManager::CloseTabAction, &menu);
		closeTabAction->setEnabled(!isPinned);
		closeTabAction->setData(parameters);

		Action *closeOtherTabsAction = new Action(ActionsManager::CloseOtherTabsAction, &menu);
		closeOtherTabsAction->setEnabled(amount > 0 && !(amount == 1 && !isPinned));
		closeOtherTabsAction->setData(parameters);

		menu.addAction(cloneTabAction);
		menu.addAction(pinTabAction);
		menu.addSeparator();
		menu.addAction(detachTabAction);
		menu.addSeparator();
		menu.addAction(closeTabAction);
		menu.addAction(closeOtherTabsAction);
		menu.addAction(ActionsManager::getAction(ActionsManager::ClosePrivateTabsAction, this));

		connect(cloneTabAction, SIGNAL(triggered()), mainWindow, SLOT(triggerAction()));
		connect(pinTabAction, SIGNAL(triggered()), mainWindow, SLOT(triggerAction()));
		connect(detachTabAction, SIGNAL(triggered()), mainWindow, SLOT(triggerAction()));
		connect(closeTabAction, SIGNAL(triggered()), mainWindow, SLOT(triggerAction()));
		connect(closeOtherTabsAction, SIGNAL(triggered()), mainWindow, SLOT(triggerAction()));
	}

	menu.addSeparator();

	QMenu *arrangeMenu = menu.addMenu(tr("Arrange"));
	Action *restoreTabAction = new Action(ActionsManager::RestoreTabAction, &menu);
	restoreTabAction->setEnabled(m_clickedTab >= 0);
	restoreTabAction->setData(parameters);

	Action *minimizeTabAction = new Action(ActionsManager::MinimizeTabAction, &menu);
	minimizeTabAction->setEnabled(m_clickedTab >= 0);
	minimizeTabAction->setData(parameters);

	Action *maximizeTabAction = new Action(ActionsManager::MaximizeTabAction, &menu);
	maximizeTabAction->setEnabled(m_clickedTab >= 0);
	maximizeTabAction->setData(parameters);

	arrangeMenu->addAction(restoreTabAction);
	arrangeMenu->addAction(minimizeTabAction);
	arrangeMenu->addAction(maximizeTabAction);
	arrangeMenu->addSeparator();
	arrangeMenu->addAction(ActionsManager::getAction(ActionsManager::RestoreAllAction, this));
	arrangeMenu->addAction(ActionsManager::getAction(ActionsManager::MaximizeAllAction, this));
	arrangeMenu->addAction(ActionsManager::getAction(ActionsManager::MinimizeAllAction, this));
	arrangeMenu->addSeparator();
	arrangeMenu->addAction(ActionsManager::getAction(ActionsManager::CascadeAllAction, this));
	arrangeMenu->addAction(ActionsManager::getAction(ActionsManager::TileAllAction, this));

	QAction *cycleAction = new QAction(tr("Switch tabs using the mouse wheel"), this);
	cycleAction->setCheckable(true);
	cycleAction->setChecked(!SettingsManager::getValue(QLatin1String("TabBar/RequireModifierToSwitchTabOnScroll")).toBool());

	connect(cycleAction, SIGNAL(toggled(bool)), this, SLOT(setCycle(bool)));
	connect(restoreTabAction, SIGNAL(triggered()), mainWindow, SLOT(triggerAction()));
	connect(minimizeTabAction, SIGNAL(triggered()), mainWindow, SLOT(triggerAction()));
	connect(maximizeTabAction, SIGNAL(triggered()), mainWindow, SLOT(triggerAction()));
//.........这里部分代码省略.........
开发者ID:insionng,项目名称:otter-browser,代码行数:101,代码来源:TabBarWidget.cpp

示例10: QDialog

FileRenamerDlgImpl::FileRenamerDlgImpl(QWidget* pParent, CommonData* pCommonData, bool bUseCurrentView) : QDialog(pParent, getDialogWndFlags()), Ui::FileRenamerDlg(), m_pCommonData(pCommonData), m_bUseCurrentView(bUseCurrentView), m_pEditor(0)
{
    setupUi(this);

    resizeIcons();

    m_pHndlrListModel = new HndlrListModel(m_pCommonData, this, bUseCurrentView);

    {
        m_pCurrentAlbumG->verticalHeader()->setResizeMode(QHeaderView::Interactive);
        m_pCurrentAlbumG->verticalHeader()->setMinimumSectionSize(CELL_HEIGHT + 1);
        m_pCurrentAlbumG->verticalHeader()->setDefaultSectionSize(CELL_HEIGHT + 1);//*/

        m_pCurrentAlbumG->setModel(m_pHndlrListModel);

        CurrentAlbumDelegate* pDel (new CurrentAlbumDelegate(this, m_pHndlrListModel));
        m_pCurrentAlbumG->setItemDelegate(pDel);

        m_pCurrentAlbumG->viewport()->installEventFilter(this);
    }

    m_pButtonGroup = new QButtonGroup(this);

    loadPatterns();
    updateButtons();

    {
        int nWidth, nHeight;
        bool bKeepOriginal, bUnratedAsDuplicate;
        m_pCommonData->m_settings.loadRenamerSettings(nWidth, nHeight, m_nSaButton, m_nVaButton, bKeepOriginal, bUnratedAsDuplicate);
        if (nWidth > 400 && nHeight > 400)
        {
            resize(nWidth, nHeight);
        }
        else
        {
            defaultResize(*this);
        }

        if (m_nVaButton >= cSize(m_vstrPatterns) || m_nVaButton <= 0) { m_nVaButton = 0; }
        if (m_nSaButton >= cSize(m_vstrPatterns) || m_nSaButton <= 0) { m_nSaButton = 0; }
        m_pKeepOriginalCkB->setChecked(bKeepOriginal);
        m_pMarkUnratedAsDuplicatesCkB->setChecked(bUnratedAsDuplicate);
    }


    { m_pModifRenameB = new ModifInfoToolButton(m_pRenameB); connect(m_pModifRenameB, SIGNAL(clicked()), this, SLOT(on_m_pRenameB_clicked())); m_pRenameB = m_pModifRenameB; }

    { QAction* p (new QAction(this)); p->setShortcut(QKeySequence("F1")); connect(p, SIGNAL(triggered()), this, SLOT(onHelp())); addAction(p); }

    if (m_bUseCurrentView)
    {
        m_pCrtDirTagEdtE->setEnabled(false);
        m_pPrevB->setEnabled(false);
        m_pNextB->setEnabled(false);
    }

    if (!m_pCommonData->m_bShowCustomCloseButtons)
    {
        m_pCloseB->hide();
    }



    QTimer::singleShot(1, this, SLOT(onShow())); // just calls reloadTable(); !!! needed to properly resize the table columns; album and file tables have very small widths until they are actually shown, so calling resizeTagEditor() earlier is pointless; calling update() on various layouts seems pointless as well; (see also DoubleList::resizeEvent() )
}
开发者ID:frispete,项目名称:mp3diags,代码行数:66,代码来源:FileRenamerDlgImpl.cpp

示例11: QMenu

void TitleWidget::initAction()
{
	m_menu = new QMenu(this);
	m_menu->setObjectName("MainMenu");

	QAction *searchAction = new QAction("搜索", m_menu);
	searchAction->setIcon(QIcon(":/menu_icon/search"));
	searchAction->setShortcut(tr("Ctrl+S"));
	searchAction->setStatusTip("搜索单曲,歌单...");
	connect(searchAction, SIGNAL(triggered()), this, SIGNAL(search()));

	QAction *logOutAction = new QAction("注销", m_menu);
	logOutAction->setIcon(QIcon(":/menu_icon/logout"));
	logOutAction->setShortcut(tr("Ctrl+E"));
	logOutAction->setStatusTip("退出登录...");
	connect(logOutAction, SIGNAL(triggered()), this, SIGNAL(logOut()));

	allLoopAction = new QAction("列表循环", m_menu);
	//allLoopAction->setIcon(QIcon(":/menu_icon/list_loop"));
	allLoopAction->setShortcut(tr("Ctrl+A"));
	allLoopAction->setCheckable(true);
	allLoopAction->setChecked(true);
	allLoopAction->setStatusTip("列表循环播放歌曲...");
	connect(allLoopAction, SIGNAL(triggered()), this, SLOT(setAllLoopChecked()));

	oneLoopAction = new QAction("单曲循环", m_menu);
	//oneLoopAction->setIcon(QIcon(":/menu_icon/one_loop"));
	oneLoopAction->setShortcut(tr("Ctrl+O"));
	oneLoopAction->setCheckable(true);
	oneLoopAction->setChecked(false);
	oneLoopAction->setStatusTip("单曲循环播放歌曲...");
	connect(oneLoopAction, SIGNAL(triggered()), this, SLOT(setOneLoopChecked()));

	randomLoopAction = new QAction("随机循环", m_menu);
	//randomLoopAction->setIcon(QIcon(":/menu_icon/random_loop"));
	randomLoopAction->setCheckable(true);
	randomLoopAction->setChecked(false);
	randomLoopAction->setShortcut(tr("Ctrl+R"));
	randomLoopAction->setStatusTip("随机循环播放歌曲...");
	connect(randomLoopAction, SIGNAL(triggered()), this, SLOT(setRandomLoopChecked()));

	QAction *exitAction = new QAction("退出软件", m_menu);
	exitAction->setIcon(QIcon(":/menu_icon/exit"));
	exitAction->setShortcut(tr("Ctrl+Q"));
	connect(exitAction, SIGNAL(triggered()), this, SIGNAL(exitWidget()));


	m_menu->addAction(searchAction);
	m_menu->addSeparator();
	m_menu->addAction(oneLoopAction);
	m_menu->addAction(allLoopAction);
	m_menu->addAction(randomLoopAction);
	m_menu->addSeparator();
	m_menu->addAction(logOutAction);
	m_menu->addSeparator();
	m_menu->addAction(exitAction);
	m_menu->adjustSize();

	m_menu->setVisible(false);
}
开发者ID:fengleyl,项目名称:NetEase,代码行数:60,代码来源:titlewidget.cpp

示例12: menu

// main tab slots
void MainWindow::mainTabContextualMenu(const QPoint &pos)
{
    if (debug) qDebug() << PDEBUG;
    if (ui->tableWidget_main->currentItem() == nullptr) return;

    // create menu
    QMenu menu(this);
    QAction *refreshTable = menu.addAction(QApplication::translate("MainWindow", "Refresh"));
    refreshTable->setIcon(QIcon::fromTheme("view-refresh"));
    menu.addSeparator();
    QAction *startProfile = menu.addAction(QApplication::translate("MainWindow", "Start profile"));
    QAction *restartProfile = menu.addAction(QApplication::translate("MainWindow", "Restart profile"));
    restartProfile->setIcon(QIcon::fromTheme("view-refresh"));
    QAction *enableProfile = menu.addAction(QApplication::translate("MainWindow", "Enable profile"));
    menu.addSeparator();
    QAction *editProfile = menu.addAction(QApplication::translate("MainWindow", "Edit profile"));
    editProfile->setIcon(QIcon::fromTheme("document-edit"));
    QAction *removeProfile = menu.addAction(QApplication::translate("MainWindow", "Remove profile"));
    removeProfile->setIcon(QIcon::fromTheme("edit-delete"));

    // set text
    if (!ui->tableWidget_main->item(ui->tableWidget_main->currentItem()->row(), 2)->text().isEmpty()) {
        restartProfile->setVisible(true);
        startProfile->setText(QApplication::translate("MainWindow", "Stop profile"));
        startProfile->setIcon(QIcon::fromTheme("process-stop"));
    } else {
        restartProfile->setVisible(false);
        startProfile->setText(QApplication::translate("MainWindow", "Start profile"));
        startProfile->setIcon(QIcon::fromTheme("system-run"));
    }
    if (!ui->tableWidget_main->item(ui->tableWidget_main->currentItem()->row(), 3)->text().isEmpty()) {
        enableProfile->setText(QApplication::translate("MainWindow", "Disable profile"));
        enableProfile->setIcon(QIcon::fromTheme("edit-remove"));
    } else {
        enableProfile->setText(QApplication::translate("MainWindow", "Enable profile"));
        enableProfile->setIcon(QIcon::fromTheme("edit-add"));
    }

    // actions
    QAction *action = menu.exec(ui->tableWidget_main->viewport()->mapToGlobal(pos));
    if (action == refreshTable) {
        if (debug) qDebug() << PDEBUG << ":" << "Refresh table";
        updateMainTab();
    } else if (action == startProfile) {
        if (debug) qDebug() << PDEBUG << ":" << "Start profile";
        mainTabStartProfile();
    } else if (action == restartProfile) {
        if (debug) qDebug() << PDEBUG << ":" << "Restart profile";
        mainTabRestartProfile();
    } else if (action == enableProfile) {
        if (debug) qDebug() << PDEBUG << ":" << "Enable profile";
        mainTabEnableProfile();
    } else if (action == editProfile) {
        if (debug) qDebug() << PDEBUG << ":" << "Edit profile";
        mainTabEditProfile();
    } else if (action == removeProfile) {
        if (debug) qDebug() << PDEBUG << ":" << "Remove profile";
        mainTabRemoveProfile();
    }
}
开发者ID:nosada,项目名称:netctl-gui,代码行数:61,代码来源:mainprivateslots.cpp

示例13: testActionGroup

void tst_QActionGroup::enabledPropagation()
{
    QActionGroup testActionGroup( 0 );

    QAction* childAction = new QAction( &testActionGroup );
    QAction* anotherChildAction = new QAction( &testActionGroup );
    QAction* freeAction = new QAction(0);

    QVERIFY( testActionGroup.isEnabled() );
    QVERIFY( childAction->isEnabled() );

    testActionGroup.setEnabled( false );
    QVERIFY( !testActionGroup.isEnabled() );
    QVERIFY( !childAction->isEnabled() );
    QVERIFY( !anotherChildAction->isEnabled() );

    childAction->setEnabled(true);
    QVERIFY( !childAction->isEnabled());

    anotherChildAction->setEnabled( false );

    testActionGroup.setEnabled( true );
    QVERIFY( testActionGroup.isEnabled() );
    QVERIFY( childAction->isEnabled() );
    QVERIFY( !anotherChildAction->isEnabled() );

    testActionGroup.setEnabled( false );
    QAction *lastChildAction = new QAction(&testActionGroup);

    QVERIFY(!lastChildAction->isEnabled());
    testActionGroup.setEnabled( true );
    QVERIFY(lastChildAction->isEnabled());

    freeAction->setEnabled(false);
    testActionGroup.addAction(freeAction);
    QVERIFY(!freeAction->isEnabled());
    delete freeAction;
}
开发者ID:kuailexs,项目名称:symbiandump-mw3,代码行数:38,代码来源:tst_qactiongroup.cpp

示例14: group

void tst_QActionGroup::exclusive()
{
    QActionGroup group(0);
    group.setExclusive(false);
    QVERIFY( !group.isExclusive() );

    QAction* actOne = new QAction( &group );
    actOne->setCheckable( true );
    QAction* actTwo = new QAction( &group );
    actTwo->setCheckable( true );
    QAction* actThree = new QAction( &group );
    actThree->setCheckable( true );

    group.setExclusive( true );
    QVERIFY( !actOne->isChecked() );
    QVERIFY( !actTwo->isChecked() );
    QVERIFY( !actThree->isChecked() );

    actOne->setChecked( true );
    QVERIFY( actOne->isChecked() );
    QVERIFY( !actTwo->isChecked() );
    QVERIFY( !actThree->isChecked() );

    actTwo->setChecked( true );
    QVERIFY( !actOne->isChecked() );
    QVERIFY( actTwo->isChecked() );
    QVERIFY( !actThree->isChecked() );
}
开发者ID:kuailexs,项目名称:symbiandump-mw3,代码行数:28,代码来源:tst_qactiongroup.cpp

示例15: SLOT

void Kiten::setupActions()
{
  /* Add the basic quit/print/prefs actions, use the gui factory for keybindings */
  (void) KStandardAction::quit( this, SLOT(close()), actionCollection() );
  //Why the heck is KSA:print adding it's own toolbar!?
  //	(void) KStandardAction::print(this, SLOT(print()), actionCollection());
  (void) KStandardAction::preferences( this, SLOT(slotConfigure()), actionCollection() );
  //old style cast seems needed here, (const QObject*)
  KStandardAction::keyBindings(   (const QObject*)guiFactory()
                                , SLOT(configureShortcuts())
                                , actionCollection() );

  /* Setup the Go-to-learn-mode actions */
  /* TODO: put back when Dictionary Editor is reorganised */
// 	(void) new KAction(   i18n( "&Dictionary Editor..." )
//                             , "document-properties"
//                             , 0
//                             , this
//                             , SLOT(createEEdit())
//                             , actionCollection()
//                             , "dict_editor");
  QAction *radselect = actionCollection()->addAction( "radselect" );
  radselect->setText( i18n( "Radical Selector" ) );
//	radselect->setIcon( "edit-find" );
  actionCollection()->setDefaultShortcut(radselect, Qt::CTRL+Qt::Key_R );
  connect(radselect, &QAction::triggered, this, &Kiten::radicalSearch);

  QAction *kanjibrowser = actionCollection()->addAction( "kanjibrowser" );
  kanjibrowser->setText( i18n( "Kanji Browser" ) );
  actionCollection()->setDefaultShortcut(kanjibrowser, Qt::CTRL+Qt::Key_K );
  connect(kanjibrowser, &QAction::triggered, this, &Kiten::kanjiBrowserSearch);

  /* Setup the Search Actions and our custom Edit Box */
  _inputManager = new SearchStringInput( this );

  QAction *searchButton = actionCollection()->addAction( "search" );
  searchButton->setText( i18n( "S&earch" ) );
  // Set the search button to search
  connect(searchButton, &QAction::triggered, this, &Kiten::searchFromEdit);
  searchButton->setIcon( KStandardGuiItem::find().icon() );

  // That's not it, that's "find as you type"...
//   connect( Edit, SIGNAL(completion(QString)),
//            this,   SLOT(searchFromEdit()) );

  /* Setup our widgets that handle preferences */
//   deinfCB = new KToggleAction(   i18n( "&Deinflect Verbs in Regular Search" )
//                                 , 0
//                                 , this
//                                 , SLOT(kanjiDictChange())
//                                 , actionCollection()
//                                 , "deinf_toggle" );

  _autoSearchToggle = actionCollection()->add<KToggleAction>( "autosearch_toggle" );
  _autoSearchToggle->setText( i18n( "&Automatically Search Clipboard Selections" ) );

  _irAction = actionCollection()->add<QAction>( "search_in_results" );
  _irAction->setText( i18n( "Search &in Results" ) );
  connect(_irAction, &QAction::triggered, this, &Kiten::searchInResults);


  QAction *actionFocusResultsView;
  actionFocusResultsView = actionCollection()->addAction(  "focusresultview"
                                                         , this
                                                         , SLOT(focusResultsView()) );
  actionCollection()->setDefaultShortcut(actionFocusResultsView, Qt::Key_Escape );
  actionFocusResultsView->setText( i18n( "Focus result view" ) );


  (void) KStandardAction::configureToolbars(   this
                                             , SLOT(configureToolBars())
                                             , actionCollection() );

  //TODO: this should probably be a standard action
  /*
  globalShortcutsAction = actionCollection()->addAction( "options_configure_global_keybinding" );
  globalShortcutsAction->setText( i18n( "Configure &Global Shortcuts..." ) );
  connect( globalShortcutsAction, SIGNAL(triggered()), this, SLOT(configureGlobalKeys()) );
  */

  //TODO: implement this
  //_globalSearchAction = actionCollection()->add<KToggleAction>( "search_on_the_spot" );
  //_globalSearchAction->setText( i18n( "On The Spo&t Search" ) );
  //KAction *temp = qobject_cast<KAction*>( _globalSearchAction );
  //KShortcut shrt( "Ctrl+Alt+S" );
  //globalSearchAction->setGlobalShortcut(shrt);  //FIXME: Why does this take ~50 seconds to return!?
  //connect(globalSearchAction, SIGNAL(triggered()), this, SLOT(searchOnTheSpot()));

  _backAction = KStandardAction::back( this, SLOT(back()), actionCollection() );
  _forwardAction = KStandardAction::forward( this, SLOT(forward()), actionCollection() );
  _backAction->setEnabled( false );
  _forwardAction->setEnabled( false );
}
开发者ID:KDE,项目名称:kiten,代码行数:93,代码来源:kiten.cpp


注:本文中的QAction类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。