本文整理汇总了C++中QSignalMapper::setMapping方法的典型用法代码示例。如果您正苦于以下问题:C++ QSignalMapper::setMapping方法的具体用法?C++ QSignalMapper::setMapping怎么用?C++ QSignalMapper::setMapping使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QSignalMapper
的用法示例。
在下文中一共展示了QSignalMapper::setMapping方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: on_tableView_activated
void ViewParsedReferences::on_tableView_activated(const QModelIndex &index)
{
QString data = ui->tableView->model()->data(ui->tableView->model()->index(index.row(),0)).toString();
qDebug()<<data.toInt();
QSqlQuery qry;
qry.exec(QString("SELECT * from citation where reference_id='%1'").arg(data.toInt()));
QWidget *central = new QWidget;
QVBoxLayout *layout = new QVBoxLayout(central);
ui->scrollArea->setWidget(central);
ui->scrollArea->setWidgetResizable(true);
int j=0;
QSignalMapper *mapper = new QSignalMapper(this);
contents.clear();
errcount.clear();
while(qry.next())
{
QPushButton *pb = new QPushButton;
pb->setText(QString("Output %1").arg(j+1));
layout->addWidget(pb);
contents.push_back(qry.value(1).toString());
errcount.push_back(qry.value(3).toInt());
connect(pb,SIGNAL(clicked()),mapper,SLOT(map()));
mapper->setMapping(pb,j++);
}
connect(mapper,SIGNAL(mapped(int)),this,SLOT(viewContent(int)));
}
示例2: init
void OperazioniDlg::init()
{
//setMaximumSize(size());
//setMinimumSize(size());
QSignalMapper* mapper = new QSignalMapper(this);
connect(ui->gestioneBtn, SIGNAL(clicked()), mapper, SLOT(map()));
mapper->setMapping(ui->gestioneBtn, 1);
connect(ui->cassaBtn, SIGNAL(clicked()), mapper, SLOT(map()));
mapper->setMapping(ui->cassaBtn, 2);
connect(ui->testBtn, SIGNAL(clicked()), mapper, SLOT(map()));
mapper->setMapping(ui->testBtn, 3);
connect(ui->ricaricaBtn, SIGNAL(clicked()), mapper, SLOT(map()));
mapper->setMapping(ui->ricaricaBtn, 4);
connect(ui->buoniBtn, SIGNAL(clicked()), mapper, SLOT(map()));
mapper->setMapping(ui->buoniBtn, 6);
connect(ui->aboutBtn, SIGNAL(clicked()), mapper, SLOT(map()));
mapper->setMapping(ui->aboutBtn, 7);
connect(mapper, SIGNAL(mapped(int)), this, SLOT(pulsanteClicked(int)));
}
示例3: QMainWindow
VPiano::VPiano() : QMainWindow()
{
QWidget *central = new QWidget(this);
QVBoxLayout *vb = new QVBoxLayout;
QHBoxLayout *octaves = new QHBoxLayout;
QSignalMapper *octaveSignalMapper = new QSignalMapper(this);
for(int i = 0; i < 9; i++)
{
QString title;
title.setNum(i);
QPushButton *o = new QPushButton(title, central);
o->setFixedSize(fontMetrics().width(title)*4, o->height());
QString shortcut;
shortcut.setNum(i+1);
o->setShortcut(QKeySequence(QString("F") + shortcut));
octaves->addWidget(o);
connect(o, SIGNAL(clicked()), octaveSignalMapper, SLOT(map()));
octaveSignalMapper->setMapping(o, i);
}
OctaveRangeWidget *octRange = new OctaveRangeWidget(central);
octaves->addWidget(octRange);
QSlider *velocity = new QSlider(Qt::Horizontal, central);
velocity->setMinimum(1);
velocity->setMaximum(127);
velocity->setValue(96); // TODO: read prev value from config
velocity->setToolTip(tr("Velocity"));
octaves->addWidget(velocity);
QSpinBox *channel = new QSpinBox(central);
channel->setPrefix(tr("Ch ", "Midi Channel number"));
channel->setMinimum(0);
channel->setMaximum(127);
channel->setValue(0); // TODO: read prev value from config
channel->setToolTip(tr("Select MIDI channel number to send messages to"));
octaves->addWidget(channel);
vb->addLayout(octaves);
QHBoxLayout *keyarea = new QHBoxLayout;
KeyboardWidget *kw = new KeyboardWidget(central);
keyarea->addWidget(kw);
QVBoxLayout *rightside = new QVBoxLayout;
QSlider *pitchWheel = new QSlider(Qt::Vertical, central);
pitchWheel->setMinimum(-64);
pitchWheel->setMaximum(63);
pitchWheel->setValue(0); // TODO: read prev value from config
pitchWheel->setToolTip(tr("Pitch wheel"));
rightside->addWidget(pitchWheel);
QCheckBox *porta = new QCheckBox(central);
porta->setToolTip(tr("Enable portamento"));
rightside->addWidget(porta);
keyarea->addLayout(rightside);
vb->addLayout(keyarea);
central->setLayout(vb);
setCentralWidget(central);
setWindowTitle(tr("Virtual MIDI keyboard"));
// TODO: connect pitchWheel
connect(octaveSignalMapper, SIGNAL(mapped(int)), kw, SLOT(octaveSelected(int)));
connect(channel, SIGNAL(valueChanged(int)), kw, SLOT(midiChannelSelected(int)));
connect(kw, SIGNAL(highlightOctaves(int,int)), octRange, SLOT(highlightOctaves(int,int)));
kw->octaveSelected(0); // TODO: use value read from config
}
示例4: pixmap
listMemberDialog::listMemberDialog(QWidget *parent,QString classId)
{
conn = database::connectByC();
QVBoxLayout *topLeftLayout = new QVBoxLayout;
view = new QTableView(this);
model = new QStandardItemModel(this);
view->setModel(model);
model->setHorizontalHeaderItem(0, new QStandardItem(tr("ID")));
model->setHorizontalHeaderItem(1, new QStandardItem(tr("Name")));
model->setHorizontalHeaderItem(2, new QStandardItem(tr("Birth year")));
model->setHorizontalHeaderItem(3, new QStandardItem(tr("Note")));
model->setHorizontalHeaderItem(4, new QStandardItem(tr("-")));
view->setColumnWidth(0,20);
view->setColumnWidth(1,90);
view->setColumnWidth(2,57);
view->setColumnWidth(3,40);
view->setColumnWidth(4,30);
label = new QLabel("Member list");
topLeftLayout->addWidget(label);
int rowCurrent = 0;
MYSQL_RES *res = database::classMember_searchClassId(conn,classId);
while(MYSQL_ROW classMemberRow = mysql_fetch_row(res))
{
QString memberId = classMemberRow[1];
MYSQL_ROW memberRow = database::member_searchMemberId(conn,memberId);
model->setItem(rowCurrent, 0, new QStandardItem(memberRow[0]));
model->setItem(rowCurrent, 1, new QStandardItem(memberRow[1]));
model->setItem(rowCurrent, 2, new QStandardItem(memberRow[2]));
model->setItem(rowCurrent, 3, new QStandardItem(memberRow[3]));
QPushButton *button = new QPushButton("");
QPixmap pixmap("Resources/Delete_icon.png");
QIcon buttonIcon(pixmap);
button->setIcon(buttonIcon);
QSignalMapper *signalMapper = new QSignalMapper(this);
signalMapper->setMapping(button,memberId);
QObject::connect(button,SIGNAL(clicked()),signalMapper,SLOT(map()));
QObject::connect(signalMapper,SIGNAL(mapped(QString)),this,SLOT(deleteMemberAction(QString)));
view->setIndexWidget(model->index(rowCurrent,4),button);
rowCurrent++;
}
numOldMemberInDialog = rowCurrent;
topLeftLayout->addWidget(view);
QHBoxLayout *horizontalLayout = new QHBoxLayout();
QPushButton *saveButton = new QPushButton("Save");
QPixmap pixmap1("Resources/save_icon.png");
QIcon ButtonIcon1(pixmap1);
saveButton->setIcon(ButtonIcon1);
QSignalMapper *saveMapper = new QSignalMapper(this);
saveMapper->setMapping(saveButton,classId);
QObject::connect(saveButton,SIGNAL(clicked()),saveMapper,SLOT(map()));
QObject::connect(saveMapper,SIGNAL(mapped(QString)),this,SLOT(saveListAction(QString)));
horizontalLayout->addWidget(saveButton);
QPushButton *addMemberButton = new QPushButton("Add Member");
QPixmap pixmap("Resources/add-icon.png");
QIcon ButtonIcon(pixmap);
addMemberButton->setIcon(ButtonIcon);
QObject::connect(addMemberButton,SIGNAL(clicked()),this,SLOT(addMemberAction()));
horizontalLayout->addWidget(addMemberButton);
setLayout(topLeftLayout);
topLeftLayout->addLayout(horizontalLayout);
setWindowTitle(tr("Member list"));
setFixedHeight(sizeHint().height());
}
示例5: createUserMenu
QMenu* SimObjectWidget::createUserMenu() const
{
QMenu* menu = new QMenu(tr(&object == Simulation::simulation->scene ? "S&cene" : "&Object"));
QSignalMapper* flagsSignalMapper = new QSignalMapper(menu);
connect(flagsSignalMapper, SIGNAL(mapped(int)), SLOT(toggleRenderFlag(int)));
{
QMenu* subMenu = menu->addMenu(tr("&Drag and Drop"));
QAction* action = subMenu->menuAction();
action->setIcon(QIcon(":/Icons/DragPlane.png"));
action->setStatusTip(tr("Select the drag and drop dynamics mode and plane along which operations are performed"));
QActionGroup* actionGroup = new QActionGroup(subMenu);
QSignalMapper* signalMapper = new QSignalMapper(subMenu);
connect(signalMapper, SIGNAL(mapped(int)), SLOT(setDragPlane(int)));
action = subMenu->addAction(tr("X/Y Plane"));
actionGroup->addAction(action);
signalMapper->setMapping(action, SimRobotCore2::Renderer::xyPlane);
action->setShortcut(QKeySequence(Qt::Key_Z));
action->setCheckable(true);
connect(action, SIGNAL(triggered()), signalMapper, SLOT(map()));
action = subMenu->addAction(tr("X/Z Plane"));
actionGroup->addAction(action);
signalMapper->setMapping(action, SimRobotCore2::Renderer::xzPlane);
action->setShortcut(QKeySequence(Qt::Key_Y));
action->setCheckable(true);
connect(action, SIGNAL(triggered()), signalMapper, SLOT(map()));
action = subMenu->addAction(tr("Y/Z Plane"));
actionGroup->addAction(action);
signalMapper->setMapping(action, SimRobotCore2::Renderer::yzPlane);
action->setShortcut(QKeySequence(Qt::Key_X));
action->setCheckable(true);
connect(action, SIGNAL(triggered()), signalMapper, SLOT(map()));
qobject_cast<QAction*>(signalMapper->mapping(objectRenderer.getDragPlane()))->setChecked(true);
subMenu->addSeparator();
actionGroup = new QActionGroup(subMenu);
signalMapper = new QSignalMapper(subMenu);
connect(signalMapper, SIGNAL(mapped(int)), SLOT(setDragMode(int)));
action = subMenu->addAction(tr("&Keep Dynamics"));
actionGroup->addAction(action);
signalMapper->setMapping(action, SimRobotCore2::Renderer::keepDynamics);
action->setShortcut(QKeySequence(Qt::Key_7));
action->setCheckable(true);
connect(action, SIGNAL(triggered()), signalMapper, SLOT(map()));
action = subMenu->addAction(tr("&Reset Dynamics"));
actionGroup->addAction(action);
signalMapper->setMapping(action, SimRobotCore2::Renderer::resetDynamics);
action->setShortcut(QKeySequence(Qt::Key_8));
action->setCheckable(true);
connect(action, SIGNAL(triggered()), signalMapper, SLOT(map()));
action = subMenu->addAction(tr("A&dopt Dynamics"));
actionGroup->addAction(action);
signalMapper->setMapping(action, SimRobotCore2::Renderer::adoptDynamics);
action->setShortcut(QKeySequence(Qt::Key_9));
action->setCheckable(true);
connect(action, SIGNAL(triggered()), signalMapper, SLOT(map()));
action = subMenu->addAction(tr("&Apply Dynamics"));
actionGroup->addAction(action);
signalMapper->setMapping(action, SimRobotCore2::Renderer::applyDynamics);
action->setShortcut(QKeySequence(Qt::Key_0));
action->setCheckable(true);
connect(action, SIGNAL(triggered()), signalMapper, SLOT(map()));
qobject_cast<QAction*>(signalMapper->mapping(objectRenderer.getDragMode()))->setChecked(true);
}
menu->addSeparator();
{
QMenu* subMenu = menu->addMenu(tr("&Camera"));
QAction* action = subMenu->menuAction();
action->setIcon(QIcon(":/Icons/camera.png"));
action->setStatusTip(tr("Select different camera modes for displaying the scene"));
QActionGroup* actionGroup = new QActionGroup(subMenu);
QSignalMapper* signalMapper = new QSignalMapper(subMenu);
connect(signalMapper, SIGNAL(mapped(int)), SLOT(setCameraMode(int)));
action = subMenu->addAction(tr("&Target Mode"));
action->setCheckable(true);
actionGroup->addAction(action);
signalMapper->setMapping(action, SimRobotCore2::Renderer::targetCam);
connect(action, SIGNAL(triggered()), signalMapper, SLOT(map()));
action = subMenu->addAction(tr("&Free Mode"));
action->setCheckable(true);
actionGroup->addAction(action);
signalMapper->setMapping(action, SimRobotCore2::Renderer::freeCam);
connect(action, SIGNAL(triggered()), signalMapper, SLOT(map()));
qobject_cast<QAction*>(signalMapper->mapping(objectRenderer.getCameraMode()))->setChecked(true);
subMenu->addSeparator();
action = subMenu->addAction(tr("&Reset"));
action->setShortcut(QKeySequence(Qt::Key_R));
connect(action, SIGNAL(triggered()), this, SLOT(resetCamera()));
action = subMenu->addAction(tr("&Toggle"));
action->setShortcut(QKeySequence(Qt::Key_T));
connect(action, SIGNAL(triggered()), this, SLOT(toggleCameraMode()));
/*
action = subMenu->addAction(tr("&Fit"));
action->setShortcut(QKeySequence(Qt::Key_F));
connect(action, SIGNAL(triggered()), this, SLOT(fitCamera()));
subMenu->addSeparator();
//.........这里部分代码省略.........
示例6: container
PaintFillstyle::PaintFillstyle(QWidget* parent, int width)
:QWidget(parent), container(5, Qt::Horizontal, "Fill Style", this) {
setFixedSize(width, 100);
//Set margin
container.setFixedSize(width - 20, 100);
container.move(10, 0);
//Set exclusive
container.setExclusive(true);
QRadioButton *solid, *d1, *d2, *d3, *d4, *d5, *d6,
*d7, *hor, *ver, *cross, *bd, *fd, *dc, *nb;
//Used to map signals to one slot
QSignalMapper *signalMapper = new QSignalMapper(this);
solid = new QRadioButton("Solid", &container);
signalMapper->setMapping(solid, 0);
QObject::connect(solid, SIGNAL(clicked()),
signalMapper, SLOT(map()));
d1 = new QRadioButton("Dense 1", &container);
signalMapper->setMapping(d1, 1);
QObject::connect(d1, SIGNAL(clicked()),
signalMapper, SLOT(map()));
d2 = new QRadioButton("Dense 2", &container);
signalMapper->setMapping(d2, 2);
QObject::connect(d2, SIGNAL(clicked()),
signalMapper, SLOT(map()));
d3 = new QRadioButton("Dense 3", &container);
signalMapper->setMapping(d3, 3);
QObject::connect(d3, SIGNAL(clicked()),
signalMapper, SLOT(map()));
d4 = new QRadioButton("Dense 4", &container);
signalMapper->setMapping(d4, 4);
QObject::connect(d4, SIGNAL(clicked()),
signalMapper, SLOT(map()));
d5 = new QRadioButton("Dense 5", &container);
signalMapper->setMapping(d5, 5);
QObject::connect(d5, SIGNAL(clicked()),
signalMapper, SLOT(map()));
d6 = new QRadioButton("Dense 6", &container);
signalMapper->setMapping(d6, 6);
QObject::connect(d6, SIGNAL(clicked()),
signalMapper, SLOT(map()));
d7 = new QRadioButton("Dense 7", &container);
signalMapper->setMapping(d7, 7);
QObject::connect(d7, SIGNAL(clicked()),
signalMapper, SLOT(map()));
hor = new QRadioButton("Horizontal", &container);
signalMapper->setMapping(hor, 8);
QObject::connect(hor, SIGNAL(clicked()),
signalMapper, SLOT(map()));
ver = new QRadioButton("Vertical", &container);
signalMapper->setMapping(ver, 9);
QObject::connect(ver, SIGNAL(clicked()),
signalMapper, SLOT(map()));
cross = new QRadioButton("Cross", &container);
signalMapper->setMapping(cross, 10);
QObject::connect(cross, SIGNAL(clicked()),
signalMapper, SLOT(map()));
bd = new QRadioButton("B. Diag", &container);
signalMapper->setMapping(bd, 11);
QObject::connect(bd, SIGNAL(clicked()),
signalMapper, SLOT(map()));
fd = new QRadioButton("F. Diag", &container);
signalMapper->setMapping(fd, 12);
QObject::connect(fd, SIGNAL(clicked()),
signalMapper, SLOT(map()));
dc = new QRadioButton("C. Diag", &container);
signalMapper->setMapping(dc, 13);
QObject::connect(dc, SIGNAL(clicked()),
signalMapper, SLOT(map()));
nb = new QRadioButton("No Pattern", &container);
//Default
nb->setChecked(true);
signalMapper->setMapping(nb, 14);
QObject::connect(nb, SIGNAL(clicked()),
signalMapper, SLOT(map()));
QObject::connect(signalMapper, SIGNAL(mapped(int)),
this, SLOT(selectorValueChanged(int)));
}
示例7: QWidget
//.........这里部分代码省略.........
encoderEdits[ScorbotIce::Elbow] = new QLineEdit(centralWidget);
controlLayout->addWidget(encoderEdits[ScorbotIce::Elbow], row++, column);
encoderEdits[ScorbotIce::Wrist1] = new QLineEdit(centralWidget);
controlLayout->addWidget(encoderEdits[ScorbotIce::Wrist1], row++, column);
encoderEdits[ScorbotIce::Wrist2] = new QLineEdit(centralWidget);
controlLayout->addWidget(encoderEdits[ScorbotIce::Wrist2], row++, column);
encoderEdits[ScorbotIce::Gripper] = new QLineEdit(centralWidget);
controlLayout->addWidget(encoderEdits[ScorbotIce::Gripper], row++, column);
encoderEdits[ScorbotIce::Slider] = new QLineEdit(centralWidget);
controlLayout->addWidget(encoderEdits[ScorbotIce::Slider], row++, column);
//Create the duration edits
row=1; column++;
durationEdits[ScorbotIce::Base] = new QLineEdit(centralWidget);
controlLayout->addWidget(durationEdits[ScorbotIce::Base], row++, column);
durationEdits[ScorbotIce::Shoulder] = new QLineEdit(centralWidget);
controlLayout->addWidget(durationEdits[ScorbotIce::Shoulder], row++, column);
durationEdits[ScorbotIce::Elbow] = new QLineEdit(centralWidget);
controlLayout->addWidget(durationEdits[ScorbotIce::Elbow], row++, column);
durationEdits[ScorbotIce::Wrist1] = new QLineEdit(centralWidget);
controlLayout->addWidget(durationEdits[ScorbotIce::Wrist1], row++, column);
durationEdits[ScorbotIce::Wrist2] = new QLineEdit(centralWidget);
controlLayout->addWidget(durationEdits[ScorbotIce::Wrist2], row++, column);
durationEdits[ScorbotIce::Gripper] = new QLineEdit(centralWidget);
controlLayout->addWidget(durationEdits[ScorbotIce::Gripper], row++, column);
durationEdits[ScorbotIce::Slider] = new QLineEdit(centralWidget);
controlLayout->addWidget(durationEdits[ScorbotIce::Slider], row++, column);
//Create the set position buttons
row=1; column++;
QSignalMapper* posButtonMapper = new QSignalMapper(this);
setPosButtons[ScorbotIce::Base] = new QPushButton("Set Position", centralWidget);
controlLayout->addWidget(setPosButtons[ScorbotIce::Base], row++, column);
posButtonMapper->setMapping(setPosButtons[ScorbotIce::Base], (int)ScorbotIce::Base);
connect(setPosButtons[ScorbotIce::Base], SIGNAL(pressed()), posButtonMapper, SLOT(map()));
setPosButtons[ScorbotIce::Shoulder] = new QPushButton("Set Position", centralWidget);
controlLayout->addWidget(setPosButtons[ScorbotIce::Shoulder], row++, column);
posButtonMapper->setMapping(setPosButtons[ScorbotIce::Shoulder], (int)ScorbotIce::Shoulder);
connect(setPosButtons[ScorbotIce::Shoulder], SIGNAL(pressed()), posButtonMapper, SLOT(map()));
setPosButtons[ScorbotIce::Elbow] = new QPushButton("Set Position", centralWidget);
controlLayout->addWidget(setPosButtons[ScorbotIce::Elbow], row++, column);
posButtonMapper->setMapping(setPosButtons[ScorbotIce::Elbow], (int)ScorbotIce::Elbow);
connect(setPosButtons[ScorbotIce::Elbow], SIGNAL(pressed()), posButtonMapper, SLOT(map()));
setPosButtons[ScorbotIce::Wrist1] = new QPushButton("Set Position", centralWidget);
controlLayout->addWidget(setPosButtons[ScorbotIce::Wrist1], row++, column);
posButtonMapper->setMapping(setPosButtons[ScorbotIce::Wrist1], (int)ScorbotIce::Wrist1);
connect(setPosButtons[ScorbotIce::Wrist1], SIGNAL(pressed()), posButtonMapper, SLOT(map()));
setPosButtons[ScorbotIce::Wrist2] = new QPushButton("Set Position", centralWidget);
controlLayout->addWidget(setPosButtons[ScorbotIce::Wrist2], row++, column);
posButtonMapper->setMapping(setPosButtons[ScorbotIce::Wrist2], (int)ScorbotIce::Wrist2);
connect(setPosButtons[ScorbotIce::Wrist2], SIGNAL(pressed()), posButtonMapper, SLOT(map()));
setPosButtons[ScorbotIce::Gripper] = new QPushButton("Set Position", centralWidget);
controlLayout->addWidget(setPosButtons[ScorbotIce::Gripper], row++, column);
posButtonMapper->setMapping(setPosButtons[ScorbotIce::Gripper], (int)ScorbotIce::Gripper);
connect(setPosButtons[ScorbotIce::Gripper], SIGNAL(pressed()), posButtonMapper, SLOT(map()));
setPosButtons[ScorbotIce::Slider] = new QPushButton("Set Position", centralWidget);
controlLayout->addWidget(setPosButtons[ScorbotIce::Slider], row++, column);
posButtonMapper->setMapping(setPosButtons[ScorbotIce::Slider], (int)ScorbotIce::Slider);
connect(setPosButtons[ScorbotIce::Slider], SIGNAL(pressed()), posButtonMapper, SLOT(map()));
示例8: QDialog
// --- StyleSheetEditorDialog
StyleSheetEditorDialog::StyleSheetEditorDialog(QDesignerFormEditorInterface *core, QWidget *parent, Mode mode):
QDialog(parent),
m_buttonBox(new QDialogButtonBox(QDialogButtonBox::Ok|QDialogButtonBox::Cancel|QDialogButtonBox::Help)),
m_editor(new StyleSheetEditor),
m_validityLabel(new QLabel(tr("Valid Style Sheet"))),
m_core(core),
m_addResourceAction(new QAction(tr("Add Resource..."), this)),
m_addGradientAction(new QAction(tr("Add Gradient..."), this)),
m_addColorAction(new QAction(tr("Add Color..."), this)),
m_addFontAction(new QAction(tr("Add Font..."), this))
{
setWindowTitle(tr("Edit Style Sheet"));
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
connect(m_buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
connect(m_buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
connect(m_buttonBox, SIGNAL(helpRequested()), this, SLOT(slotRequestHelp()));
m_buttonBox->button(QDialogButtonBox::Help)->setShortcut(QKeySequence::HelpContents);
connect(m_editor, SIGNAL(textChanged()), this, SLOT(validateStyleSheet()));
QToolBar *toolBar = new QToolBar;
QGridLayout *layout = new QGridLayout;
layout->addWidget(toolBar, 0, 0, 1, 2);
layout->addWidget(m_editor, 1, 0, 1, 2);
layout->addWidget(m_validityLabel, 2, 0, 1, 1);
layout->addWidget(m_buttonBox, 2, 1, 1, 1);
setLayout(layout);
m_editor->setContextMenuPolicy(Qt::CustomContextMenu);
connect(m_editor, SIGNAL(customContextMenuRequested(QPoint)),
this, SLOT(slotContextMenuRequested(QPoint)));
QSignalMapper *resourceActionMapper = new QSignalMapper(this);
QSignalMapper *gradientActionMapper = new QSignalMapper(this);
QSignalMapper *colorActionMapper = new QSignalMapper(this);
resourceActionMapper->setMapping(m_addResourceAction, QString());
gradientActionMapper->setMapping(m_addGradientAction, QString());
colorActionMapper->setMapping(m_addColorAction, QString());
connect(m_addResourceAction, SIGNAL(triggered()), resourceActionMapper, SLOT(map()));
connect(m_addGradientAction, SIGNAL(triggered()), gradientActionMapper, SLOT(map()));
connect(m_addColorAction, SIGNAL(triggered()), colorActionMapper, SLOT(map()));
connect(m_addFontAction, SIGNAL(triggered()), this, SLOT(slotAddFont()));
m_addResourceAction->setEnabled(mode == ModePerForm);
const char * const resourceProperties[] = {
"background-image",
"border-image",
"image",
0
};
const char * const colorProperties[] = {
"color",
"background-color",
"alternate-background-color",
"border-color",
"border-top-color",
"border-right-color",
"border-bottom-color",
"border-left-color",
"gridline-color",
"selection-color",
"selection-background-color",
0
};
QMenu *resourceActionMenu = new QMenu(this);
QMenu *gradientActionMenu = new QMenu(this);
QMenu *colorActionMenu = new QMenu(this);
for (int resourceProperty = 0; resourceProperties[resourceProperty]; ++resourceProperty) {
QAction *action = resourceActionMenu->addAction(QLatin1String(resourceProperties[resourceProperty]));
connect(action, SIGNAL(triggered()), resourceActionMapper, SLOT(map()));
resourceActionMapper->setMapping(action, QLatin1String(resourceProperties[resourceProperty]));
}
for (int colorProperty = 0; colorProperties[colorProperty]; ++colorProperty) {
QAction *gradientAction = gradientActionMenu->addAction(QLatin1String(colorProperties[colorProperty]));
QAction *colorAction = colorActionMenu->addAction(QLatin1String(colorProperties[colorProperty]));
connect(gradientAction, SIGNAL(triggered()), gradientActionMapper, SLOT(map()));
connect(colorAction, SIGNAL(triggered()), colorActionMapper, SLOT(map()));
gradientActionMapper->setMapping(gradientAction, QLatin1String(colorProperties[colorProperty]));
colorActionMapper->setMapping(colorAction, QLatin1String(colorProperties[colorProperty]));
}
connect(resourceActionMapper, SIGNAL(mapped(QString)), this, SLOT(slotAddResource(QString)));
connect(gradientActionMapper, SIGNAL(mapped(QString)), this, SLOT(slotAddGradient(QString)));
connect(colorActionMapper, SIGNAL(mapped(QString)), this, SLOT(slotAddColor(QString)));
m_addResourceAction->setMenu(resourceActionMenu);
m_addGradientAction->setMenu(gradientActionMenu);
m_addColorAction->setMenu(colorActionMenu);
toolBar->addAction(m_addResourceAction);
//.........这里部分代码省略.........
示例9: ActionsBase
ListPanelActions::ListPanelActions(QObject *parent, FileManagerWindow *mainWindow) :
ActionsBase(parent, mainWindow)
{
// set view type
QSignalMapper *mapper = new QSignalMapper(this);
connect(mapper, SIGNAL(mapped(int)), SLOT(setView(int)));
QActionGroup *group = new QActionGroup(this);
group->setExclusive(true);
QList<KrViewInstance*> views = KrViewFactory::registeredViews();
for(int i = 0; i < views.count(); i++) {
KrViewInstance *inst = views[i];
QAction *action = new QAction(QIcon::fromTheme(inst->icon()), inst->description(), group);
action->setCheckable(true);
connect(action, SIGNAL(triggered()), mapper, SLOT(map()));
mapper->setMapping(action, inst->id());
_mainWindow->actions()->addAction("view" + QString::number(i), action);
_mainWindow->actions()->setDefaultShortcut(action, inst->shortcut());
setViewActions.insert(inst->id(), action);
}
// standard actions
actHistoryBackward = stdAction(KStandardAction::Back, _func, SLOT(historyBackward()));
actHistoryForward = stdAction(KStandardAction::Forward, _func, SLOT(historyForward()));
//FIXME: second shortcut for up: see actDirUp
// KStandardAction::up( this, SLOT( dirUp() ), actionCollection )->setShortcut(Qt::Key_Backspace);
/* Shortcut disabled because of the Terminal Emulator bug. */
actDirUp = stdAction(KStandardAction::Up, _func, SLOT(dirUp()));
actHome = stdAction(KStandardAction::Home, _func, SLOT(home()));
stdAction(KStandardAction::Cut, _func, SLOT(cut()));
actCopy = stdAction(KStandardAction::Copy, _func, SLOT(copyToClipboard()));
actPaste = stdAction(KStandardAction::Paste, _func, SLOT(pasteFromClipboard()));
// Fn keys
actF2 = action(i18n("Rename"), 0, Qt::Key_F2, _func, SLOT(rename()) , "F2_Rename");
actF3 = action(i18n("View File"), 0, Qt::Key_F3, _func, SLOT(view()), "F3_View");
actF4 = action(i18n("Edit File"), 0, Qt::Key_F4, _func, SLOT(edit()) , "F4_Edit");
actF5 = action(i18n("Copy to other panel"), 0, Qt::Key_F5, _func, SLOT(copyFiles()) , "F5_Copy");
actF6 = action(i18n("Move..."), 0, Qt::Key_F6, _func, SLOT(moveFiles()) , "F6_Move");
actShiftF5 = action(i18n("Copy by queue..."), 0, Qt::SHIFT + Qt::Key_F5, _func, SLOT(copyFilesByQueue()) , "F5_Copy_Queue");
actShiftF6 = action(i18n("Move by queue..."), 0, Qt::SHIFT + Qt::Key_F6, _func, SLOT(moveFilesByQueue()) , "F6_Move_Queue");
actF7 = action(i18n("New Directory..."), "folder-new", Qt::Key_F7, _func, SLOT(mkdir()) , "F7_Mkdir");
actF8 = action(i18n("Delete"), "edit-delete", Qt::Key_F8, _func, SLOT(deleteFiles()) , "F8_Delete");
actF9 = action(i18n("Start Terminal Here"), "utilities-terminal", Qt::Key_F9, _func, SLOT(terminal()) , "F9_Terminal");
action(i18n("&New Text File..."), "document-new", Qt::SHIFT + Qt::Key_F4, _func, SLOT(editNew()), "edit_new_file");
action(i18n("F3 View Dialog"), 0, Qt::SHIFT + Qt::Key_F3, _func, SLOT(viewDlg()), "F3_ViewDlg");
// file operations
action(i18n("Right-click Menu"), 0, Qt::Key_Menu, _gui, SLOT(rightclickMenu()), "rightclick menu");
actProperties = action(i18n("&Properties..."), 0, Qt::ALT + Qt::Key_Return, _func, SLOT(properties()), "properties");
actCompDirs = action(i18n("&Compare Directories"), "kr_comparedirs", Qt::ALT + Qt::SHIFT + Qt::Key_C, _gui, SLOT(compareDirs()), "compare dirs");
actCalculate = action(i18n("Calculate &Occupied Space"), "accessories-calculator", 0, _func, SLOT(calcSpace()), "calculate");
actPack = action(i18n("Pac&k..."), "archive-insert", Qt::ALT + Qt::SHIFT + Qt::Key_P, _func, SLOT(pack()), "pack");
actUnpack = action(i18n("&Unpack..."), "archive-extract", Qt::ALT + Qt::SHIFT + Qt::Key_U, _func, SLOT(unpack()), "unpack");
actCreateChecksum = action(i18n("Create Checksum..."), "document-edit-sign", 0, _func, SLOT(createChecksum()), "create checksum");
actMatchChecksum = action(i18n("Verify Checksum..."), "document-edit-decrypt-verify", 0, _func, SLOT(matchChecksum()), "match checksum");
action(i18n("New Symlink..."), 0, Qt::CTRL + Qt::ALT + Qt::Key_S, _func, SLOT(krlink()), "new symlink");
actTest = action(i18n("T&est Archive"), "archive-extract", Qt::ALT + Qt::SHIFT + Qt::Key_E, _func, SLOT(testArchive()), "test archives");
// navigation
actRoot = action(i18n("Root"), "folder-red", Qt::CTRL + Qt::Key_Backspace, _func, SLOT(root()), "root");
actCdToOther = action(i18n("Go to Other Panel's Directory"), 0, Qt::CTRL + Qt::Key_Equal, _func, SLOT(cdToOtherPanel()), "cd to other panel");
action(i18n("&Reload"), "view-refresh", Qt::CTRL + Qt::Key_R, _func, SLOT(refresh()), "std_redisplay");
actCancelRefresh = action(i18n("Cancel Refresh of View"), "dialog-cancel", 0, _gui, SLOT(inlineRefreshCancel()), "cancel refresh");
actFTPNewConnect = action(i18n("New Net &Connection..."), "network-connect", Qt::CTRL + Qt::Key_N, _func, SLOT(newFTPconnection()), "ftp new connection");
actFTPDisconnect = action(i18n("Disconnect &from Net"), "network-disconnect", Qt::SHIFT + Qt::CTRL + Qt::Key_F, _func, SLOT(FTPDisconnect()), "ftp disconnect");
action(i18n("Sync Panels"), 0, Qt::ALT + Qt::SHIFT + Qt::Key_O, _func, SLOT(syncOtherPanel()), "sync panels");
actJumpBack = action(i18n("Jump Back"), "go-jump", Qt::CTRL + Qt::Key_J, _gui, SLOT(jumpBack()), "jump_back");
actSetJumpBack = action(i18n("Set Jump Back Point"), "go-jump-definition", Qt::CTRL + Qt::SHIFT + Qt::Key_J, _gui, SLOT(setJumpBack()), "set_jump_back");
actSyncBrowse = action(i18n("S&ynchron Directory Changes"), "kr_syncbrowse_off", Qt::ALT + Qt::SHIFT + Qt::Key_Y, _gui, SLOT(toggleSyncBrowse()), "sync browse");
actLocationBar = action(i18n("Go to Location Bar"), 0, Qt::CTRL + Qt::Key_L, _gui, SLOT(editLocation()), "location_bar");
toggleAction(i18n("Toggle Popup Panel"), 0, Qt::ALT + Qt::Key_Down, _gui, SLOT(togglePanelPopup()), "toggle popup panel");
action(i18n("Bookmarks"), 0, Qt::CTRL + Qt::Key_D, _gui, SLOT(openBookmarks()), "bookmarks");
action(i18n("Left Bookmarks"), 0, 0, this, SLOT(openLeftBookmarks()), "left bookmarks");
action(i18n("Right Bookmarks"), 0, 0, this, SLOT(openRightBookmarks()), "right bookmarks");
action(i18n("History"), 0, Qt::CTRL + Qt::Key_H, _gui, SLOT(openHistory()), "history");
action(i18n("Left History"), 0, Qt::ALT + Qt::CTRL + Qt::Key_Left, this, SLOT(openLeftHistory()), "left history");
action(i18n("Right History"), 0, Qt::ALT + Qt::CTRL + Qt::Key_Right, this, SLOT(openRightHistory()), "right history");
action(i18n("Media"), 0, Qt::CTRL + Qt::Key_M, _gui, SLOT(openMedia()), "media");
action(i18n("Left Media"), 0, Qt::CTRL + Qt::SHIFT + Qt::Key_Left, this, SLOT(openLeftMedia()), "left media");
action(i18n("Right Media"), 0, Qt::CTRL + Qt::SHIFT + Qt::Key_Right, this, SLOT(openRightMedia()), "right media");
// and at last we can set the tool-tips
actRoot->setToolTip(i18n("ROOT (/)"));
actF2->setToolTip(i18n("Rename file, directory, etc."));
actF3->setToolTip(i18n("Open file in viewer."));
actF4->setToolTip("<qt>" + i18n("<p>Edit file.</p>"
"<p>The editor can be defined in Konfigurator, "
"default is <b>internal editor</b>.</p>") + "</qt>");
actF5->setToolTip(i18n("Copy file from one panel to the other."));
actF6->setToolTip(i18n("Move file from one panel to the other."));
actF7->setToolTip(i18n("Create directory in current panel."));
actF8->setToolTip(i18n("Delete file, directory, etc."));
actF9->setToolTip("<qt>" + i18n("<p>Open terminal in current directory.</p>"
"<p>The terminal can be defined in Konfigurator, "
"default is <b>konsole</b>.</p>") + "</qt>");
}
示例10: createPopupMenu
QMenu* ObjectWidget::createPopupMenu()
{
QMenu* menu = new QMenu(tr("&Object"));
QAction* action;
action = menu->addAction(QIcon(":/icons/page_copy.png"), tr("&Copy"));
action->setShortcut(QKeySequence(QKeySequence::Copy));
action->setStatusTip(tr("Copy the current selection's contents or view to the clipboard"));
connect(action, SIGNAL(triggered()), this, SLOT(copy()));
menu->addSeparator();
QMenu* subMenu = menu->addMenu(tr("&Drag and Drop"));
action = subMenu->menuAction();
action->setIcon(QIcon(":/icons/DragPlane.png"));
action->setStatusTip(tr("Select the drag and drop dynamics mode and plane along which operations are performed"));
QActionGroup* actionGroup = new QActionGroup(subMenu);
QSignalMapper* signalMapper = new QSignalMapper(subMenu);
connect(signalMapper, SIGNAL(mapped(int)), SLOT(setDragPlane(int)));
action = subMenu->addAction(tr("X/Y Plane"));
actionGroup->addAction(action);
signalMapper->setMapping(action, XY_PLANE);
action->setShortcut(QKeySequence(Qt::Key_Z));
action->setCheckable(true);
connect(action, SIGNAL(triggered()), signalMapper, SLOT(map()));
action = subMenu->addAction(tr("X/Z Plane"));
actionGroup->addAction(action);
signalMapper->setMapping(action, XZ_PLANE);
action->setShortcut(QKeySequence(Qt::Key_Y));
action->setCheckable(true);
connect(action, SIGNAL(triggered()), signalMapper, SLOT(map()));
action = subMenu->addAction(tr("Y/Z Plane"));
actionGroup->addAction(action);
signalMapper->setMapping(action, YZ_PLANE);
action->setShortcut(QKeySequence(Qt::Key_X));
action->setCheckable(true);
connect(action, SIGNAL(triggered()), signalMapper, SLOT(map()));
qobject_cast<QAction*>(signalMapper->mapping(objectRenderer.getDragPlane()))->setChecked(true);
subMenu->addSeparator();
actionGroup = new QActionGroup(subMenu);
signalMapper = new QSignalMapper(subMenu);
connect(signalMapper, SIGNAL(mapped(int)), SLOT(setDragMode(int)));
action = subMenu->addAction(tr("&Keep Dynamics"));
actionGroup->addAction(action);
signalMapper->setMapping(action, KEEP_DYNAMICS);
action->setShortcut(QKeySequence(Qt::Key_8));
action->setCheckable(true);
connect(action, SIGNAL(triggered()), signalMapper, SLOT(map()));
action = subMenu->addAction(tr("&Reset Dynamics"));
actionGroup->addAction(action);
signalMapper->setMapping(action, RESET_DYNAMICS);
action->setShortcut(QKeySequence(Qt::Key_9));
action->setCheckable(true);
connect(action, SIGNAL(triggered()), signalMapper, SLOT(map()));
action = subMenu->addAction(tr("&Apply Dynamics"));
actionGroup->addAction(action);
signalMapper->setMapping(action, APPLY_DYNAMICS);
action->setShortcut(QKeySequence(Qt::Key_0));
action->setCheckable(true);
connect(action, SIGNAL(triggered()), signalMapper, SLOT(map()));
qobject_cast<QAction*>(signalMapper->mapping(objectRenderer.getDragMode()))->setChecked(true);
menu->addSeparator();
subMenu = menu->addMenu(tr("&Camera"));
action = subMenu->menuAction();
action->setIcon(QIcon(":/icons/camera.png"));
action->setStatusTip(tr("Select different camera modes for displaying the scene"));
actionGroup = new QActionGroup(subMenu);
signalMapper = new QSignalMapper(subMenu);
connect(signalMapper, SIGNAL(mapped(int)), SLOT(setCameraMode(int)));
action = subMenu->addAction(tr("&Target Mode"));
action->setCheckable(true);
actionGroup->addAction(action);
signalMapper->setMapping(action, VisualizationParameterSet::TARGETCAM);
connect(action, SIGNAL(triggered()), signalMapper, SLOT(map()));
action = subMenu->addAction(tr("&Free Mode"));
action->setCheckable(true);
actionGroup->addAction(action);
signalMapper->setMapping(action, VisualizationParameterSet::FREECAM);
connect(action, SIGNAL(triggered()), signalMapper, SLOT(map()));
action = subMenu->addAction(tr("&Presentation Mode"));
action->setCheckable(true);
actionGroup->addAction(action);
signalMapper->setMapping(action, VisualizationParameterSet::PRESENTATION);
connect(action, SIGNAL(triggered()), signalMapper, SLOT(map()));
qobject_cast<QAction*>(signalMapper->mapping(objectRenderer.getCameraMode()))->setChecked(true);
subMenu->addSeparator();
action = subMenu->addAction(tr("&Reset"));
action->setShortcut(QKeySequence(Qt::Key_R));
connect(action, SIGNAL(triggered()), this, SLOT(resetCamera()));
action = subMenu->addAction(tr("&Toggle"));
action->setShortcut(QKeySequence(Qt::Key_T));
connect(action, SIGNAL(triggered()), this, SLOT(toggleCameraMode()));
action = subMenu->addAction(tr("&Fit"));
action->setShortcut(QKeySequence(Qt::Key_F));
connect(action, SIGNAL(triggered()), this, SLOT(fitCamera()));
subMenu->addSeparator();
action = subMenu->addAction(tr("&Snap To Root"));
action->setCheckable(true);
action->setChecked(objectRenderer.hasSnapToRoot());
//.........这里部分代码省略.........
示例11: fileProgramme
MainWindow::MainWindow(Manager *man, QWidget *parent) : QMainWindow(parent), manager(man), nbElementsAffichablesPile(1)
{
pile = manager->getPile();
QXmlStreamReader xmlReader3;
QFile filePile3("parametres.xml");
filePile3.open(QFile::ReadOnly);
xmlReader3.setDevice(&filePile3);
xmlReader3.readNext();
QString valeur;
while(!xmlReader3.atEnd() && !xmlReader3.hasError()) {
QXmlStreamReader::TokenType token = xmlReader3.readNext();
if(token == QXmlStreamReader::StartDocument) {
continue;
}
if(token == QXmlStreamReader::StartElement) {
if(xmlReader3.name() == "clavierVisible") {
xmlReader3.readElementText();
}
if(xmlReader3.name() == "valeur") {
valeur= xmlReader3.readElementText();
if(valeur=="1")
clavierVisible=true;
else
clavierVisible=false;
}
if(xmlReader3.name() == "nbElementsVisiblesPile") {
xmlReader3.readElementText();
}
if(xmlReader3.name() == "valeur") {
valeur = xmlReader3.readElementText();
nbElementsAffichablesPile = valeur.toInt();
}
}
}
//paramètres d'affichage
QMenu *menuAfficher = menuBar()->addMenu("&Afficher");
actionAfficherClavier = new QAction("&Afficher le clavier", this);
actionAfficherClavier->setCheckable(true);
actionAfficherClavier->setChecked(true);
QAction* actionNbElementsPile = new QAction("&Modifier le nombre d'élements affichables dans la pile", this);
menuAfficher->addAction(actionAfficherClavier);
menuAfficher->addAction(actionNbElementsPile);
QObject::connect(actionAfficherClavier, SIGNAL(toggled(bool)), this, SLOT(afficherClavier(bool)));
QObject::connect(actionNbElementsPile, SIGNAL(triggered(bool)), this, SLOT(modifierNbElementsAffichesPile()));
// Général
QHBoxLayout *mainLayout= new QHBoxLayout();
tabWidget = new QTabWidget();
QVBoxLayout *verticalLayout = new QVBoxLayout();
layoutClavier = new QGridLayout;
//Vue de la pile (gauche)
QListView *vuePile = new QListView();
vuePile->setGeometry(0,0,100,300);
//Vue de l'historique de commandes (droite)
QTextEdit *vueHistoriqueCommandes = new QTextEdit();
inputLine = new QLineEdit();
//Clavier numérique
QSignalMapper *signalMapper = new QSignalMapper(this);
QPushButton *bouton1= new QPushButton();
bouton1->setText("1");
connect(bouton1, SIGNAL(clicked()), signalMapper, SLOT(map()));
signalMapper->setMapping(bouton1, "1");
QPushButton *bouton2= new QPushButton();
bouton2->setText("2");
connect(bouton2, SIGNAL(clicked()), signalMapper, SLOT(map()));
signalMapper->setMapping(bouton2, "2");
QPushButton *bouton3= new QPushButton();
bouton3->setText("3");
connect(bouton3, SIGNAL(clicked()), signalMapper, SLOT(map()));
signalMapper->setMapping(bouton3, "3");
QPushButton *bouton4= new QPushButton();
bouton4->setText("4");
//.........这里部分代码省略.........
示例12: QWidget
PlaylistWidget::PlaylistWidget( intf_thread_t *_p_i, QWidget *_par )
: QWidget( _par ), p_intf ( _p_i )
{
setContentsMargins( 0, 3, 0, 3 );
QGridLayout *layout = new QGridLayout( this );
layout->setMargin( 0 ); layout->setSpacing( 0 );
/*******************
* Left *
*******************/
/* We use a QSplitter for the left part */
leftSplitter = new QSplitter( Qt::Vertical, this );
/* Source Selector */
selector = new PLSelector( this, p_intf );
leftSplitter->addWidget( selector );
/* Create a Container for the Art Label
in order to have a beautiful resizing for the selector above it */
artContainer = new QStackedWidget;
artContainer->setMaximumHeight( 256 );
/* Art label */
CoverArtLabel *art = new CoverArtLabel( artContainer, p_intf );
art->setToolTip( qtr( "Double click to get media information" ) );
artContainer->addWidget( art );
CONNECT( THEMIM->getIM(), artChanged( QString ),
art, showArtUpdate( const QString& ) );
CONNECT( THEMIM->getIM(), artChanged( input_item_t * ),
art, showArtUpdate( input_item_t * ) );
leftSplitter->addWidget( artContainer );
/*******************
* Right *
*******************/
/* Initialisation of the playlist */
playlist_t * p_playlist = THEPL;
PL_LOCK;
playlist_item_t *p_root = p_playlist->p_playing;
PL_UNLOCK;
setMinimumWidth( 400 );
PLModel *model = PLModel::getPLModel( p_intf );
#ifdef MEDIA_LIBRARY
MLModel *mlmodel = new MLModel( p_intf, this );
mainView = new StandardPLPanel( this, p_intf, p_root, selector, model, mlmodel );
#else
mainView = new StandardPLPanel( this, p_intf, p_root, selector, model, NULL );
#endif
/* Location Bar */
locationBar = new LocationBar( model );
locationBar->setSizePolicy( QSizePolicy::Ignored, QSizePolicy::Preferred );
layout->addWidget( locationBar, 0, 0, 1, 2 );
layout->setColumnStretch( 0, 5 );
CONNECT( locationBar, invoked( const QModelIndex & ),
mainView, browseInto( const QModelIndex & ) );
QHBoxLayout *topbarLayout = new QHBoxLayout();
layout->addLayout( topbarLayout, 0, 1 );
topbarLayout->setSpacing( 10 );
/* Button to switch views */
QToolButton *viewButton = new QToolButton( this );
viewButton->setIcon( style()->standardIcon( QStyle::SP_FileDialogDetailedView ) );
viewButton->setToolTip( qtr("Change playlistview") );
topbarLayout->addWidget( viewButton );
/* View selection menu */
QSignalMapper *viewSelectionMapper = new QSignalMapper( this );
CONNECT( viewSelectionMapper, mapped( int ), mainView, showView( int ) );
QActionGroup *actionGroup = new QActionGroup( this );
# define MAX_VIEW StandardPLPanel::VIEW_COUNT
for( int i = 0; i < MAX_VIEW; i++ )
{
viewActions[i] = actionGroup->addAction( viewNames[i] );
viewActions[i]->setCheckable( true );
viewSelectionMapper->setMapping( viewActions[i], i );
CONNECT( viewActions[i], triggered(), viewSelectionMapper, map() );
}
viewActions[mainView->currentViewIndex()]->setChecked( true );
QMenu *viewMenu = new QMenu( viewButton );
viewMenu->addActions( actionGroup->actions() );
viewButton->setMenu( viewMenu );
CONNECT( viewButton, clicked(), mainView, cycleViews() );
/* Search */
searchEdit = new SearchLineEdit( this );
searchEdit->setMaximumWidth( 250 );
searchEdit->setMinimumWidth( 80 );
searchEdit->setToolTip( qtr("Search the playlist") );
topbarLayout->addWidget( searchEdit );
//.........这里部分代码省略.........
示例13: setupActions
void ViewManager::setupActions()
{
KActionCollection* collection = _actionCollection;
KAction* nextViewAction = new KAction(i18nc("@action Shortcut entry", "Next Tab") , this);
KAction* previousViewAction = new KAction(i18nc("@action Shortcut entry", "Previous Tab") , this);
KAction* lastViewAction = new KAction(i18nc("@action Shortcut entry", "Switch to Last Tab") , this);
KAction* nextContainerAction = new KAction(i18nc("@action Shortcut entry", "Next View Container") , this);
KAction* moveViewLeftAction = new KAction(i18nc("@action Shortcut entry", "Move Tab Left") , this);
KAction* moveViewRightAction = new KAction(i18nc("@action Shortcut entry", "Move Tab Right") , this);
// list of actions that should only be enabled when there are multiple view
// containers open
QList<QAction*> multiViewOnlyActions;
multiViewOnlyActions << nextContainerAction;
if (collection) {
KAction* splitLeftRightAction = new KAction(KIcon("view-split-left-right"),
i18nc("@action:inmenu", "Split View Left/Right"),
this);
splitLeftRightAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_ParenLeft));
collection->addAction("split-view-left-right", splitLeftRightAction);
connect(splitLeftRightAction , SIGNAL(triggered()) , this , SLOT(splitLeftRight()));
KAction* splitTopBottomAction = new KAction(KIcon("view-split-top-bottom") ,
i18nc("@action:inmenu", "Split View Top/Bottom"), this);
splitTopBottomAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_ParenRight));
collection->addAction("split-view-top-bottom", splitTopBottomAction);
connect(splitTopBottomAction , SIGNAL(triggered()) , this , SLOT(splitTopBottom()));
KAction* closeActiveAction = new KAction(i18nc("@action:inmenu Close Active View", "Close Active") , this);
closeActiveAction->setIcon(KIcon("view-close"));
closeActiveAction->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_S));
closeActiveAction->setEnabled(false);
collection->addAction("close-active-view", closeActiveAction);
connect(closeActiveAction , SIGNAL(triggered()) , this , SLOT(closeActiveView()));
multiViewOnlyActions << closeActiveAction;
KAction* closeOtherAction = new KAction(i18nc("@action:inmenu Close Other Views", "Close Others") , this);
closeOtherAction->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_O));
closeOtherAction->setEnabled(false);
collection->addAction("close-other-views", closeOtherAction);
connect(closeOtherAction , SIGNAL(triggered()) , this , SLOT(closeOtherViews()));
multiViewOnlyActions << closeOtherAction;
KAction* detachViewAction = collection->addAction("detach-view");
detachViewAction->setIcon(KIcon("tab-detach"));
detachViewAction->setText(i18nc("@action:inmenu", "D&etach Current Tab"));
// Ctrl+Shift+D is not used as a shortcut by default because it is too close
// to Ctrl+D - which will terminate the session in many cases
detachViewAction->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_H));
connect(this , SIGNAL(splitViewToggle(bool)) , this , SLOT(updateDetachViewState()));
connect(detachViewAction , SIGNAL(triggered()) , this , SLOT(detachActiveView()));
// Expand & Shrink Active View
KAction* expandActiveAction = new KAction(i18nc("@action:inmenu", "Expand View") , this);
expandActiveAction->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_BracketRight));
expandActiveAction->setEnabled(false);
collection->addAction("expand-active-view", expandActiveAction);
connect(expandActiveAction , SIGNAL(triggered()) , this , SLOT(expandActiveView()));
multiViewOnlyActions << expandActiveAction;
KAction* shrinkActiveAction = new KAction(i18nc("@action:inmenu", "Shrink View") , this);
shrinkActiveAction->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_BracketLeft));
shrinkActiveAction->setEnabled(false);
collection->addAction("shrink-active-view", shrinkActiveAction);
connect(shrinkActiveAction , SIGNAL(triggered()) , this , SLOT(shrinkActiveView()));
multiViewOnlyActions << shrinkActiveAction;
// Next / Previous View , Next Container
collection->addAction("next-view", nextViewAction);
collection->addAction("previous-view", previousViewAction);
collection->addAction("last-tab", lastViewAction);
collection->addAction("next-container", nextContainerAction);
collection->addAction("move-view-left", moveViewLeftAction);
collection->addAction("move-view-right", moveViewRightAction);
// Switch to tab N shortcuts
const int SWITCH_TO_TAB_COUNT = 10;
QSignalMapper* switchToTabMapper = new QSignalMapper(this);
connect(switchToTabMapper, SIGNAL(mapped(int)), this, SLOT(switchToView(int)));
for (int i = 0; i < SWITCH_TO_TAB_COUNT; i++) {
KAction* switchToTabAction = new KAction(i18nc("@action Shortcut entry", "Switch to Tab %1", i + 1), this);
switchToTabMapper->setMapping(switchToTabAction, i);
connect(switchToTabAction, SIGNAL(triggered()), switchToTabMapper,
SLOT(map()));
collection->addAction(QString("switch-to-tab-%1").arg(i), switchToTabAction);
}
}
QListIterator<QAction*> iter(multiViewOnlyActions);
while (iter.hasNext()) {
connect(this , SIGNAL(splitViewToggle(bool)) , iter.next() , SLOT(setEnabled(bool)));
}
//.........这里部分代码省略.........
示例14: setupExtCommands
void JKGStudio::setupExtCommands()
{
QSignalMapper *mapper = new QSignalMapper(this);
mapper->setMapping(ui.actionAddEntrypoint, (int)MdiSubBase::DlgAddEntrypoint);
connect(ui.actionAddEntrypoint, SIGNAL(triggered()), mapper, SLOT(map()));
mapper->setMapping(ui.actionAddSpeechNode, (int)MdiSubBase::DlgAddSpeech);
connect(ui.actionAddSpeechNode, SIGNAL(triggered()), mapper, SLOT(map()));
mapper->setMapping(ui.actionAddOptionNode, (int)MdiSubBase::DlgAddOption);
connect(ui.actionAddOptionNode, SIGNAL(triggered()), mapper, SLOT(map()));
mapper->setMapping(ui.actionAddEndNode, (int)MdiSubBase::DlgAddEnd);
connect(ui.actionAddEndNode, SIGNAL(triggered()), mapper, SLOT(map()));
mapper->setMapping(ui.actionAddScriptNode, (int)MdiSubBase::DlgAddScript);
connect(ui.actionAddScriptNode, SIGNAL(triggered()), mapper, SLOT(map()));
mapper->setMapping(ui.actionAddInterruptNode, (int)MdiSubBase::DlgAddInterrupt);
connect(ui.actionAddInterruptNode, SIGNAL(triggered()), mapper, SLOT(map()));
mapper->setMapping(ui.actionAddLinkNode, (int)MdiSubBase::DlgAddLink);
connect(ui.actionAddLinkNode, SIGNAL(triggered()), mapper, SLOT(map()));
mapper->setMapping(ui.actionAddDynOptionNode, (int)MdiSubBase::DlgAddDynOpt);
connect(ui.actionAddDynOptionNode, SIGNAL(triggered()), mapper, SLOT(map()));
mapper->setMapping(ui.actionAddTextEntryNode, (int)MdiSubBase::DlgAddTextEntry);
connect(ui.actionAddTextEntryNode, SIGNAL(triggered()), mapper, SLOT(map()));
mapper->setMapping(ui.actionAddCinematicNode, (int)MdiSubBase::DlgAddCinematic);
connect(ui.actionAddCinematicNode, SIGNAL(triggered()), mapper, SLOT(map()));
mapper->setMapping(ui.actionRemoveNode, (int)MdiSubBase::DlgRemoveNode);
connect(ui.actionRemoveNode, SIGNAL(triggered()), mapper, SLOT(map()));
connect(mapper, SIGNAL(mapped(int)), this, SLOT(onExtCommand(int)));
}
示例15: sws
SchedDemo::SchedDemo(const size_t num_planes, const moment_t timespan, const moment_t bounds, const moment_t window_span, QWidget *parent/* = 0*/, Qt::WFlags flags/* = 0*/)
: QWidget(parent, flags)
, jobs_removed_(0)
, original_task_(planes_task_with_bounds(num_planes, timespan, bounds))
//, original_perm_(num_planes)
, window_pos_(-2)
, window_span_(window_span)
, next_job_(0)
, total_cost(0)
{
resetDemo();
sched_ = perm2sched(task_, perm_);
sched_src_ = perm2sched(task_src_, perm_);
auto clb = boost::bind(&SchedDemo::updateCost, this);
//scene_->setCostCallback(clb);
//scene_->setWeightScale(100);
//scene_->setTimeScale(20);
//QGraphicsView *view = new QGraphicsView(scene_);
//view->setMouseTracking(true);
//solver_slots_.push_back(solver_slot_t("Original", order_solver));
solver_slots_.push_back(solver_slot_t("Due dates", due_dates_solver));
selected_solver_ = solver_slots_.size() - 1;
solver_slots_.push_back(solver_slot_t("Random pair", boost::bind(random_solver, _1, _2, 10000)));
solver_slots_.push_back(solver_slot_t("Best pair", all_pairs_solver));
//solver_slots_.push_back(solver_slot_t("Best triple", boost::bind(all_triples_solver, _1, _2, 7)));
//solver_slots_.push_back(solver_slot_t("Annealing", annealing_solver));
sliding_window_solver sws(5, boost::bind(&SchedDemo::updateOffset, this, _1));
solver_slots_.push_back(solver_slot_t("Window", sws));
QGridLayout *layout = new QGridLayout;
QWidget *sidePanel = new QWidget;
QGridLayout *sideLayout = new QGridLayout;
sideLayout->setAlignment(Qt::AlignTop);
QSignalMapper *mapper = new QSignalMapper(this);
for (size_t i = 0; i < solver_slots_.size(); ++i)
{
solver_slots_[i].btn = new QPushButton(solver_slots_[i].name, this);
mapper->setMapping(solver_slots_[i].btn, i);
connect(solver_slots_[i].btn, SIGNAL(clicked()), mapper, SLOT(map()));
solver_slots_[i].lbl = new QLabel(this);
sideLayout->addWidget(solver_slots_[i].btn, i, 0);
sideLayout->addWidget(solver_slots_[i].lbl, i, 1);
}
connect(mapper, SIGNAL(mapped(int)), this, SLOT(setSolver(int)));
/*
QPushButton *advanceBtn = new QPushButton("Advance");
sideLayout->addWidget(advanceBtn, solver_slots_.size() + 1, 0);
connect(advanceBtn, SIGNAL(clicked()), this, SLOT(advanceSubtask()));*/
/*QPushButton *resetBtn = new QPushButton("Reset");
sideLayout->addWidget(resetBtn, solver_slots_.size() + 2, 0);
connect(resetBtn, SIGNAL(clicked()), this, SLOT(resetSubtask()));*/
QPushButton *playBtn = new QPushButton("Play", this);
sideLayout->addWidget(playBtn, solver_slots_.size() + 1, 0);
connect(playBtn, SIGNAL(clicked()), this, SLOT(playDemo()));
QPushButton *pauseBtn = new QPushButton("Pause", this);
sideLayout->addWidget(pauseBtn, solver_slots_.size() + 1, 1);
connect(pauseBtn, SIGNAL(clicked()), this, SLOT(pauseDemo()));
speedBar_ = new QScrollBar(Qt::Horizontal, this);
sideLayout->addWidget(speedBar_, solver_slots_.size() + 3, 0, 1, 2);
play_timer_ = new QTimer(this);
connect(play_timer_, SIGNAL(timeout()), this, SLOT(playTick()));
QPushButton *resetBtn = new QPushButton("Reset", this);
sideLayout->addWidget(resetBtn, solver_slots_.size() + 2, 0);
connect(resetBtn, SIGNAL(clicked()), this, SLOT(resetDemo()));
size_t pos_offset = solver_slots_.size() + 5;
sideLayout->addWidget(new QLabel("Cost:"), pos_offset, 0);
cost_display_ = new QLabel(this);
sideLayout->addWidget(cost_display_, pos_offset, 1);
++pos_offset;
sideLayout->addWidget(new QLabel("Aircrafts Processed:"), pos_offset, 0);
processed_display_ = new QLabel(this);
sideLayout->addWidget(processed_display_, pos_offset, 1);
++pos_offset;
sideLayout->addWidget(new QLabel("Aircrafts Removed:"), pos_offset, 0);
removed_display_ = new QLabel(this);
//.........这里部分代码省略.........