コード例 #1
0
ファイル: menuitem.cpp プロジェクト: 3v1n0/wxWidgets
wxQtAction::wxQtAction( wxMenu *parent, int id, const wxString &text, const wxString &help,
        wxItemKind kind, wxMenu *subMenu, wxMenuItem *handler )
    : QAction( wxQtConvertString( text ), parent->GetHandle() ),
      wxQtSignalHandler< wxMenuItem >( handler )
{
    setStatusTip( wxQtConvertString( help ));

    if ( subMenu != NULL )
        setMenu( subMenu->GetHandle() );

    if ( id == wxID_SEPARATOR )
        setSeparator( true );

    switch ( kind )
    {
        case wxITEM_SEPARATOR:
            setSeparator( true );
            break;
        case wxITEM_CHECK:
        case wxITEM_RADIO:
            setCheckable( true );
            break;
        case wxITEM_NORMAL:
            // Normal for a menu item.
            break;
        case wxITEM_DROPDOWN:
        case wxITEM_MAX:
            // Not applicable for menu items.
            break;
    }

    connect( this, &QAction::triggered, this, &wxQtAction::onActionTriggered );
}
コード例 #2
0
ファイル: module.cpp プロジェクト: Nishant23/pixelsynth
Editor::Modules::Metadata Editor::Modules::Timeline::registerModule()
{
	Metadata m;

	m.setWidget([&](QObject* app, QWidget* parent, Core::Project& project)
	{
		auto widget = new Widget(parent, project);
		app->connect(app, SIGNAL(projectMutated(std::shared_ptr<Core::MutationInfo>)), widget, SLOT(projectMutated(std::shared_ptr<Core::MutationInfo>)));
		return widget;
	});

	m.setDockWidgetArea(Qt::BottomDockWidgetArea);

	// Cut/copy/paste

	m.addAction<Widget>([&](QObject* app, Widget* widget)
	{
		auto action = new QAction(app);
		action->setSeparator(true);
		return action;
	}, "&Redo", ActionFlags::RequiresFocus);

	m.addAction<Widget>([&](QObject* app, Widget* widget)
	{
		auto action = new QAction(app->tr("&Cut"), app);
		action->setShortcuts({ QKeySequence(app->tr("Ctrl+C")) });
		return action;
	}, "&Redo", ActionFlags::RequiresFocus);

	// Debug stuff

	m.addAction<Widget>([&](QObject* app, Widget* widget)
	{
		auto action = new QAction(app);
		action->setSeparator(true);
		return action;
	}, "&Redo");

	m.addAction<Widget>([&](QObject* app, Widget* widget)
	{
		auto action = new QAction(app->tr("&Mutate"), app);
		action->setShortcuts({ QKeySequence(app->tr("Ctrl+M")) });
		action->connect(action, &QAction::triggered, widget, &Widget::mutate);
		return action;
	}, "&Redo");

	return m;
}
コード例 #3
0
void FileItemLinkingPlugin::Private::setActions(const ActionList &actions)
{
    for (auto action: rootMenu->actions()) {
        rootMenu->removeAction(action);
        action->deleteLater();
    }

    for (auto actionInfo: actions) {
        if (actionInfo.icon != "-") {
            auto action = new QAction(Q_NULLPTR);

            action->setText(actionInfo.title);
            action->setIcon(QIcon::fromTheme(actionInfo.icon));
            action->setProperty("activity", actionInfo.activity);
            action->setProperty("link", actionInfo.link);

            rootMenu->addAction(action);

            connect(action, &QAction::triggered,
                    this, &Private::actionTriggered);

        } else {
            auto action = new QAction(actionInfo.title, Q_NULLPTR);
            action->setSeparator(true);

            rootMenu->addAction(action);
        }
    }
}
コード例 #4
0
void MessageModel::setCurrent(bool current)
{
    if (m_current != current) {
        m_current = current;
        if (!current) {
            m_seen.fill(true);
            setSeparator(m_messages.count() - 1);
        } else {
            setBadge(0);
            setActiveHighlights(0);
            if (m_separator == -1)
                setSeparator(m_messages.count() - 1);
        }
        emit currentChanged();
    }
}
コード例 #5
0
SharedBufferChunkReader::SharedBufferChunkReader(SharedBuffer* buffer, const char* separator)
    : m_buffer(buffer)
    , m_bufferPosition(0)
    , m_segment(0)
    , m_segmentLength(0)
    , m_segmentIndex(0)
    , m_reachedEndOfFile(false)
    , m_separatorIndex(0)
{
    setSeparator(separator);
}
コード例 #6
0
ファイル: ScrollText.cpp プロジェクト: CodeUnit/BadRadio
ScrollText::ScrollText(QWidget *parent) :
    QWidget(parent), scrollPos(0)
{
    staticText.setTextFormat(Qt::PlainText);

    setFixedHeight(fontMetrics().height());
    leftMargin = height() / 3;

    setSeparator("   ---   ");

    connect(&timer, SIGNAL(timeout()), this, SLOT(timer_timeout()));
    timer.setInterval(50);
}
コード例 #7
0
ファイル: numbertochar.cpp プロジェクト: pipacker10/pip3line
bool NumberToChar::setConfiguration(QHash<QString, QString> propertiesList)
{
    bool res = TransformAbstract::setConfiguration(propertiesList);

    QString tmp = propertiesList.value(XMLSEPARATOR);
    char tmpChar = '\x00';
    if (!loadChar(tmp,&tmpChar)) {
        res = false;
        emit error(tr("Invalid value for %1").arg(XMLSEPARATOR),id);
    } else {
        res = setSeparator(tmpChar) && res;
    }

    return res;
}
コード例 #8
0
QAction* ActionManager::addSeparator(const QString &id)
{
    if (hasAction(id))
        return nullptr;

    const auto inserted = m_actions.insert(
                              std::make_pair(id, std14_stl::make_unique<QAction>(m_pMainWindow)));

    if (inserted.second) {
        auto pAction = inserted.first->second.get();
        pAction->setSeparator(true);
        return pAction;
    }

    return nullptr;
}
コード例 #9
0
ScrollText::ScrollText(QWidget *parent) :
    QWidget(parent), scrollPos(0)
{
    staticText.setTextFormat(Qt::PlainText);
    //staticText.setTextFormat(Qt::RichText);

    //staticText.setPerformanceHint(QStaticText::ModerateCaching);
    //staticText.setPerformanceHint(QStaticText::AggressiveCaching);

    setFixedHeight(fontMetrics().height());
    leftMargin = height() / 3;

    setSeparator("   ---   ");

    connect(&timer, SIGNAL(timeout()), this, SLOT(timer_timeout()));
    timer.setInterval(50);
}
コード例 #10
0
ファイル: GLWindow.cpp プロジェクト: pl4nkton/drquad32
GLWindow::GLWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::GLWindow)
{
    ui->setupUi(this);

    // Build context menu
    //
    ui->glWidget->setContextMenuPolicy(Qt::ActionsContextMenu);
    ui->glWidget->addAction(ui->actionFront);
    ui->glWidget->addAction(ui->actionRight);
    ui->glWidget->addAction(ui->actionTop);
    ui->glWidget->addAction(ui->actionAngled);

    auto separator = new QAction(this);
    separator->setSeparator(true);
    ui->glWidget->addAction(separator);

    ui->glWidget->addAction(ui->actionOrthogonal);
    ui->glWidget->addAction(ui->actionAuto_rotate);

    // Connect actions
    //
    connect(ui->xSlider, &QSlider::valueChanged, ui->glWidget, &MyGLWidget::setXRotation);
    connect(ui->ySlider, &QSlider::valueChanged, ui->glWidget, &MyGLWidget::setYRotation);
    connect(ui->zSlider, &QSlider::valueChanged, ui->glWidget, &MyGLWidget::setZRotation);

    connect(ui->glWidget, &MyGLWidget::xRotationChanged, ui->xSlider, &QSlider::setValue);
    connect(ui->glWidget, &MyGLWidget::yRotationChanged, ui->ySlider, &QSlider::setValue);
    connect(ui->glWidget, &MyGLWidget::zRotationChanged, ui->zSlider, &QSlider::setValue);

    connect(ui->actionOrthogonal,   &QAction::triggered, ui->glWidget, &MyGLWidget::setOrtho);
    connect(ui->actionAuto_rotate,  &QAction::triggered, ui->glWidget, &MyGLWidget::setAutoRotate);

    // TODO: Dangerous! No automatic disconnect when receiver is destroyed!
    //
    connect(ui->actionFront,  &QAction::triggered, [=]() { ui->glWidget->setRotation(270,   0,    0); } );
    connect(ui->actionRight,  &QAction::triggered, [=]() { ui->glWidget->setRotation(270,   0,  270); } );
    connect(ui->actionTop,    &QAction::triggered, [=]() { ui->glWidget->setRotation(  0,   0,    0); } );
    connect(ui->actionAngled, &QAction::triggered, [=]() { ui->glWidget->setRotation(300,   0,  330); } );

    ui->actionAngled->trigger();
}
コード例 #11
0
ファイル: teacherform.cpp プロジェクト: toptan/paso
TeacherForm::TeacherForm(QWidget *parent)
    : QueryForm(createModelAndEditor(), parent), ui(new Ui::TeacherForm) {
    ui->setupUi(this);
    setupWidgets(ui->tableView);
    ui->tableView->hideColumn(0);

    ui->horizontalLayout->addWidget(recordEditor());
    ui->horizontalLayout->setStretch(0, 3);
    ui->horizontalLayout->setStretch(1, 1);

    auto separator = new QAction(this);
    separator->setSeparator(true);
    mReportAction = new QAction(tr("Entries"), this);
    mReportAction->setObjectName("REPORT_ACTION");
    toolBarActions().append(separator);
    toolBarActions().append(mReportAction);

    connect(mReportAction, &QAction::triggered, this, &TeacherForm::onReport);
    mReportAction->setEnabled(false);
}
コード例 #12
0
ファイル: moc_scrolltext.cpp プロジェクト: junagit/rns510_dtv
int ScrollText::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QLabel::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        if (_id < 5)
            qt_static_metacall(this, _c, _id, _a);
        _id -= 5;
    }
#ifndef QT_NO_PROPERTIES
      else if (_c == QMetaObject::ReadProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: *reinterpret_cast< QString*>(_v) = text(); break;
        case 1: *reinterpret_cast< QString*>(_v) = separator(); break;
        }
        _id -= 2;
    } else if (_c == QMetaObject::WriteProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: setText(*reinterpret_cast< QString*>(_v)); break;
        case 1: setSeparator(*reinterpret_cast< QString*>(_v)); break;
        }
        _id -= 2;
    } else if (_c == QMetaObject::ResetProperty) {
        _id -= 2;
    } else if (_c == QMetaObject::QueryPropertyDesignable) {
        _id -= 2;
    } else if (_c == QMetaObject::QueryPropertyScriptable) {
        _id -= 2;
    } else if (_c == QMetaObject::QueryPropertyStored) {
        _id -= 2;
    } else if (_c == QMetaObject::QueryPropertyEditable) {
        _id -= 2;
    } else if (_c == QMetaObject::QueryPropertyUser) {
        _id -= 2;
    }
#endif // QT_NO_PROPERTIES
    return _id;
}
コード例 #13
0
ファイル: markdownedit.cpp プロジェクト: bezigon/liteide
 Separator(QObject *parent) :
     QAction(parent)
 {
     setSeparator(true);
 }
コード例 #14
0
ImportDialog::ImportDialog( QWidget* parent, Qt::WFlags fl )
: QDialog( parent, fl )
{
	setWindowTitle( tr( "QtiPlot - ASCII Import Options" ) );
	setSizeGripEnabled( true );
	
	QGridLayout * mainLayout = new QGridLayout(this);
	QHBoxLayout * l1 = new QHBoxLayout();
	QHBoxLayout * l2 = new QHBoxLayout();

	sepText = new QLabel(tr( "Separator"));
	l1->addWidget( sepText );

	boxSeparator = new QComboBox();
	boxSeparator->addItem(tr("TAB"));
	boxSeparator->addItem(tr("SPACE"));
	boxSeparator->addItem(";" + tr("TAB"));
	boxSeparator->addItem("," + tr("TAB"));
	boxSeparator->addItem(";" + tr("SPACE"));
	boxSeparator->addItem("," + tr("SPACE"));
	boxSeparator->addItem(";");
	boxSeparator->addItem(",");
	
	boxSeparator->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
	boxSeparator->setEditable( true );
	l1->addWidget( boxSeparator );
	mainLayout->addLayout( l1, 0, 0, 1, 4 );

	QString help = tr("The column separator can be customized. \nThe following special codes can be used:\n\\t for a TAB character \n\\s for a SPACE");
	help += "\n"+tr("The separator must not contain the following characters: \n0-9eE.+-");

	boxSeparator->setWhatsThis(help);
	sepText->setWhatsThis(help);
	boxSeparator->setToolTip(help);
	sepText->setToolTip(help);

	ignoreLabel = new QLabel(tr( "Ignore first" ));
	l2->addWidget( ignoreLabel );

	boxLines = new QSpinBox();
	boxLines->setRange( 0, 10000 );
	boxLines->setSuffix(" " + tr("lines"));
	boxLines->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
	l2->addWidget( boxLines );
	mainLayout->addLayout( l2, 1, 0, 1, 4 );

	boxRenameCols = new QCheckBox(tr("Use first row to &name columns"));
	mainLayout->addWidget( boxRenameCols, 2, 0, 1, 4 );
 
	boxStripSpaces = new QCheckBox(tr("&Remove white spaces from line ends"));

	help = tr("By checking this option all white spaces will be \nremoved from the beginning and the end of \nthe lines in the ASCII file.","when translating this check the what's this functions and tool tips to place the '\\n's correctly");
	help +="\n\n"+tr("Warning: checking this option leads to column \noverlaping if the columns in the ASCII file don't \nhave the same number of rows.");
	help +="\n"+tr("To avoid this problem you should precisely \ndefine the column separator using TAB and \nSPACE characters.","when translating this check the what's this functions and tool tips to place the '\\n's correctly");

	boxStripSpaces->setWhatsThis(help);
	boxStripSpaces->setToolTip(help);
	mainLayout->addWidget( boxStripSpaces, 3, 0, 1, 4 );

	boxSimplifySpaces = new QCheckBox(tr("&Simplify white spaces" ));

	help = tr("By checking this option all white spaces will be \nremoved from the beginning and the end of the \nlines and each sequence of internal \nwhitespaces (including the TAB character) will \nbe replaced with a single space.","when translating this check the what's this functions and tool tips to place the '\\n's correctly");
	help +="\n\n"+tr("Warning: checking this option leads to column \noverlaping if the columns in the ASCII file don't \nhave the same number of rows.","when translating this check the what's this functions and tool tips to place the '\\n's correctly");
	help +="\n"+tr("To avoid this problem you should precisely \ndefine the column separator using TAB and \nSPACE characters.","when translating this check the what's this functions and tool tips to place the '\\n's correctly");

	boxSimplifySpaces->setWhatsThis(help);
	boxSimplifySpaces->setToolTip(help);
	mainLayout->addWidget( boxSimplifySpaces, 4, 0, 1, 4 );

	buttonHelp = new QPushButton(tr( "&Help" ));
	mainLayout->addWidget( buttonHelp, 5, 0 );

	buttonOk = new QPushButton(tr("&Apply"));
	buttonOk->setDefault( true );
	mainLayout->addWidget( buttonOk, 5, 1 );
	buttonOk->setEnabled( false );

	buttonCancel = new QPushButton(tr("&Close"));
	mainLayout->addWidget( buttonCancel, 5, 2 );

	mainLayout->setColumnStretch( 3, 1 );

	ApplicationWindow *app = (ApplicationWindow *)parent;
	boxStripSpaces->setChecked(app->strip_spaces);
	boxSimplifySpaces->setChecked(app->simplify_spaces);
	boxLines->setValue(app->ignoredLines);
	boxRenameCols->setChecked(app->renameColumns);	
	setSeparator(app->columnSeparator);
	
	resize(minimumSize());
	
	connect( buttonOk, SIGNAL( clicked() ), this, SLOT( accept() ) );
	connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( quit() ) );
	connect( buttonHelp, SIGNAL( clicked() ), this, SLOT( help() ) );
	connect(boxSimplifySpaces, SIGNAL(stateChanged (int)), this, SLOT(enableApplyButton(int)));
	connect(boxStripSpaces, SIGNAL(stateChanged (int)), this, SLOT(enableApplyButton(int)));
	connect(boxRenameCols, SIGNAL(stateChanged (int)), this, SLOT(enableApplyButton(int)));
	connect(boxLines, SIGNAL(valueChanged (int)), this, SLOT(enableApplyButton(int)));
	connect(boxSeparator, SIGNAL(activated (int)), this, SLOT(enableApplyButton(int)));	
	connect(boxSeparator, SIGNAL(editTextChanged(const QString &)), this, SLOT(enableApplyButton(const QString &)));
}
コード例 #15
0
QAction *Menu::addSeparator() {
	auto separator = new QAction(this);
	separator->setSeparator(true);
	return addAction(separator);
}
コード例 #16
0
ファイル: mainwindow.cpp プロジェクト: KDE/android-qt5-qtbase
//! [0]
MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent), completer(0), lineEdit(0)
{
    createMenu();

    completer = new TreeModelCompleter(this);
    completer->setModel(modelFromFile(":/resources/treemodel.txt"));
    completer->setSeparator(QLatin1String("."));
    QObject::connect(completer, SIGNAL(highlighted(QModelIndex)),
                     this, SLOT(highlight(QModelIndex)));

    QWidget *centralWidget = new QWidget;

    QLabel *modelLabel = new QLabel;
    modelLabel->setText(tr("Tree Model<br>(Double click items to edit)"));

    QLabel *modeLabel = new QLabel;
    modeLabel->setText(tr("Completion Mode"));
    modeCombo = new QComboBox;
    modeCombo->addItem(tr("Inline"));
    modeCombo->addItem(tr("Filtered Popup"));
    modeCombo->addItem(tr("Unfiltered Popup"));
    modeCombo->setCurrentIndex(1);

    QLabel *caseLabel = new QLabel;
    caseLabel->setText(tr("Case Sensitivity"));
    caseCombo = new QComboBox;
    caseCombo->addItem(tr("Case Insensitive"));
    caseCombo->addItem(tr("Case Sensitive"));
    caseCombo->setCurrentIndex(0);
//! [0]

//! [1]
    QLabel *separatorLabel = new QLabel;
    separatorLabel->setText(tr("Tree Separator"));

    QLineEdit *separatorLineEdit = new QLineEdit;
    separatorLineEdit->setText(completer->separator());
    connect(separatorLineEdit, SIGNAL(textChanged(QString)),
            completer, SLOT(setSeparator(QString)));

    QCheckBox *wrapCheckBox = new QCheckBox;
    wrapCheckBox->setText(tr("Wrap around completions"));
    wrapCheckBox->setChecked(completer->wrapAround());
    connect(wrapCheckBox, SIGNAL(clicked(bool)), completer, SLOT(setWrapAround(bool)));

    contentsLabel = new QLabel;
    contentsLabel->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
    connect(separatorLineEdit, SIGNAL(textChanged(QString)),
            this, SLOT(updateContentsLabel(QString)));

    treeView = new QTreeView;
    treeView->setModel(completer->model());
    treeView->header()->hide();
    treeView->expandAll();
//! [1]

//! [2]
    connect(modeCombo, SIGNAL(activated(int)), this, SLOT(changeMode(int)));
    connect(caseCombo, SIGNAL(activated(int)), this, SLOT(changeCase(int)));

    lineEdit = new QLineEdit;
    lineEdit->setCompleter(completer);
//! [2]

//! [3]
    QGridLayout *layout = new QGridLayout;
    layout->addWidget(modelLabel, 0, 0); layout->addWidget(treeView, 0, 1);
    layout->addWidget(modeLabel, 1, 0);  layout->addWidget(modeCombo, 1, 1);
    layout->addWidget(caseLabel, 2, 0);  layout->addWidget(caseCombo, 2, 1);
    layout->addWidget(separatorLabel, 3, 0); layout->addWidget(separatorLineEdit, 3, 1);
    layout->addWidget(wrapCheckBox, 4, 0);
    layout->addWidget(contentsLabel, 5, 0, 1, 2);
    layout->addWidget(lineEdit, 6, 0, 1, 2);
    centralWidget->setLayout(layout);
    setCentralWidget(centralWidget);

    changeCase(caseCombo->currentIndex());
    changeMode(modeCombo->currentIndex());

    setWindowTitle(tr("Tree Model Completer"));
    lineEdit->setFocus();
}
コード例 #17
0
ファイル: qt_menu.cpp プロジェクト: wgsyd/wgtf
QSharedPointer<QAction> QtMenu::createSharedQAction(IAction& action)
{
	auto qAction = getSharedQAction(action);
	if (qAction)
	{
		return qAction;
	}

	qAction.reset(new QForwardingAction(action.text(), QApplication::instance()), &QObject::deleteLater);
	sharedQActions_[&action] = qAction;

	qAction->setProperty("order", action.order());
	qAction->setEnabled(action.enabled());
	qAction->setVisible(action.visible());

	if (action.isSeparator())
	{
		qAction->setSeparator(true);
	}
	else
	{
		std::vector<QIcon> qIcons;
		auto icons = StringUtils::split(std::string(action.icon()), '|');
		for(auto& icon : icons)
		{			
			StringUtils::trim_string(icon);
			qIcons.push_back(QtMenu_Locals::generateIcon(icon.c_str()));
		}

		if(!qIcons.empty())
		{
			qAction->setIcon(qIcons[0]);
		}

		qAction->setShortcut(QKeySequence(action.shortcut()));

		if (action.isCheckable())
		{
			qAction->setCheckable(true);
			qAction->setChecked(action.checked());
		}

		QObject::connect(qAction.data(), &QAction::triggered, [&action]() {
			if (!action.enabled())
			{
				return;
			}
			action.execute();
		});

		connections_[&action] = action.signalShortcutChanged.connect([qAction](const char* shortcut) {
			TF_ASSERT(qAction != nullptr);
			qAction->setShortcut(QKeySequence(shortcut));
		});

		connections_[&action] = action.signalTextChanged.connect([qAction](const char* text) {
			TF_ASSERT(qAction != nullptr);
			qAction->setText(text);
		});

		connections_[&action] = action.signalVisibilityChanged.connect([qAction](bool visible) {
			TF_ASSERT(qAction != nullptr);
			qAction->setVisible(visible);
		});

		connections_[&action] = action.signalIconChanged.connect([qAction, qIcons](int index) {
			TF_ASSERT(qAction != nullptr);
			if(index >= 0 && index < (int)qIcons.size())
			{
				qAction->setIcon(qIcons[index]);
			}
		});

		const std::string groupID(action.group());
		if (!groupID.empty())
		{
			auto itr = groups_.find(groupID);
			if (itr == groups_.end())
			{
				groups_[groupID].reset(new QActionGroup(&menu_));
			}

			groups_.at(groupID)->addAction(qAction.data());
			TF_ASSERT(qAction->actionGroup());
		}
	}

	return qAction;
}