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))); }
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))); }
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 }
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()); }
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(); */ } { QMenu* subMenu = menu->addMenu(tr("&Vertical Opening Angle")); QAction* action = subMenu->menuAction(); action->setIcon(QIcon(":/Icons/opening_angle.png")); QActionGroup* actionGroup = new QActionGroup(subMenu); QSignalMapper* signalMapper = new QSignalMapper(subMenu); connect(signalMapper, SIGNAL(mapped(int)), SLOT(setFovY(int))); action = subMenu->addAction(tr("&20°")); actionGroup->addAction(action); signalMapper->setMapping(action, 20); action->setShortcut(QKeySequence(Qt::Key_1)); action->setCheckable(true); connect(action, SIGNAL(triggered()), signalMapper, SLOT(map())); action = subMenu->addAction(tr("&40°")); actionGroup->addAction(action); signalMapper->setMapping(action, 40); action->setShortcut(QKeySequence(Qt::Key_2)); action->setCheckable(true); connect(action, SIGNAL(triggered()), signalMapper, SLOT(map())); action = subMenu->addAction(tr("&60°")); actionGroup->addAction(action); signalMapper->setMapping(action, 60); action->setShortcut(QKeySequence(Qt::Key_3)); action->setCheckable(true); connect(action, SIGNAL(triggered()), signalMapper, SLOT(map())); action = subMenu->addAction(tr("&80°")); actionGroup->addAction(action); signalMapper->setMapping(action, 80); action->setShortcut(QKeySequence(Qt::Key_4)); action->setCheckable(true); connect(action, SIGNAL(triggered()), signalMapper, SLOT(map())); action = subMenu->addAction(tr("100°")); actionGroup->addAction(action); signalMapper->setMapping(action, 100); action->setShortcut(QKeySequence(Qt::Key_5)); action->setCheckable(true); connect(action, SIGNAL(triggered()), signalMapper, SLOT(map())); action = subMenu->addAction(tr("120°")); actionGroup->addAction(action); signalMapper->setMapping(action, 120); action->setShortcut(QKeySequence(Qt::Key_6)); action->setCheckable(true); connect(action, SIGNAL(triggered()), signalMapper, SLOT(map())); qobject_cast<QAction*>(signalMapper->mapping(objectRenderer.getFovY()))->setChecked(true); } menu->addSeparator(); { QMenu* subMenu = menu->addMenu(tr("&Appearances Rendering")); QActionGroup* actionGroup = new QActionGroup(subMenu); QSignalMapper* signalMapper = new QSignalMapper(subMenu); connect(signalMapper, SIGNAL(mapped(int)), SLOT(setSurfaceShadeMode(int))); QAction* action = subMenu->menuAction(); action->setIcon(QIcon(":/Icons/layers.png")); action->setStatusTip(tr("Select different shading techniques for displaying the scene")); action = subMenu->addAction(tr("&Off")); actionGroup->addAction(action); //action->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_W)); action->setCheckable(true); signalMapper->setMapping(action, SimRobotCore2::Renderer::noShading); connect(action, SIGNAL(triggered()), signalMapper, SLOT(map())); action = subMenu->addAction(tr("&Wire Frame")); actionGroup->addAction(action); action->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_W)); action->setCheckable(true); signalMapper->setMapping(action, SimRobotCore2::Renderer::wireframeShading); connect(action, SIGNAL(triggered()), signalMapper, SLOT(map())); action = subMenu->addAction(tr("&Flat Shading")); actionGroup->addAction(action); action->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_F)); action->setCheckable(true); signalMapper->setMapping(action, SimRobotCore2::Renderer::flatShading); connect(action, SIGNAL(triggered()), signalMapper, SLOT(map())); action = subMenu->addAction(tr("&Smooth Shading")); actionGroup->addAction(action); action->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_M)); action->setCheckable(true); signalMapper->setMapping(action, SimRobotCore2::Renderer::smoothShading); connect(action, SIGNAL(triggered()), signalMapper, SLOT(map())); qobject_cast<QAction*>(signalMapper->mapping(objectRenderer.getSurfaceShadeMode()))->setChecked(true); } { QMenu* subMenu = menu->addMenu(tr("&Physics Rendering")); QActionGroup* actionGroup = new QActionGroup(subMenu); QSignalMapper* signalMapper = new QSignalMapper(subMenu); connect(signalMapper, SIGNAL(mapped(int)), SLOT(setPhysicsShadeMode(int))); QAction* action = subMenu->menuAction(); //action->setIcon(QIcon(":/Icons/layers.png")); action->setStatusTip(tr("Select different shading techniques for displaying the physical representation of objects")); action = subMenu->addAction(tr("&Off")); actionGroup->addAction(action); //action->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_W)); action->setCheckable(true); signalMapper->setMapping(action, SimRobotCore2::Renderer::noShading); connect(action, SIGNAL(triggered()), signalMapper, SLOT(map())); action = subMenu->addAction(tr("&Wire Frame")); actionGroup->addAction(action); //action->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_W)); action->setCheckable(true); signalMapper->setMapping(action, SimRobotCore2::Renderer::wireframeShading); connect(action, SIGNAL(triggered()), signalMapper, SLOT(map())); action = subMenu->addAction(tr("&Flat Shading")); actionGroup->addAction(action); //action->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_F)); action->setCheckable(true); signalMapper->setMapping(action, SimRobotCore2::Renderer::flatShading); connect(action, SIGNAL(triggered()), signalMapper, SLOT(map())); action = subMenu->addAction(tr("&Smooth Shading")); actionGroup->addAction(action); //action->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_M)); action->setCheckable(true); signalMapper->setMapping(action, SimRobotCore2::Renderer::smoothShading); connect(action, SIGNAL(triggered()), signalMapper, SLOT(map())); qobject_cast<QAction*>(signalMapper->mapping(objectRenderer.getPhysicsShadeMode()))->setChecked(true); } { QMenu* subMenu = menu->addMenu(tr("&Drawings Rendering")); QActionGroup* actionGroup = new QActionGroup(subMenu); QSignalMapper* signalMapper = new QSignalMapper(subMenu); connect(signalMapper, SIGNAL(mapped(int)), SLOT(setDrawingsShadeMode(int))); QAction* action = subMenu->menuAction(); action->setIcon(QIcon(":/Icons/chart_line.png")); action->setStatusTip(tr("Select different shading techniques for displaying controller drawings")); action = subMenu->addAction(tr("&Off")); actionGroup->addAction(action); //action->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_W)); action->setCheckable(true); signalMapper->setMapping(action, SimRobotCore2::Renderer::noShading); connect(action, SIGNAL(triggered()), signalMapper, SLOT(map())); action = subMenu->addAction(tr("&Wire Frame")); actionGroup->addAction(action); //action->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_W)); action->setCheckable(true); signalMapper->setMapping(action, SimRobotCore2::Renderer::wireframeShading); connect(action, SIGNAL(triggered()), signalMapper, SLOT(map())); action = subMenu->addAction(tr("&Flat Shading")); actionGroup->addAction(action); //action->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_F)); action->setCheckable(true); signalMapper->setMapping(action, SimRobotCore2::Renderer::flatShading); connect(action, SIGNAL(triggered()), signalMapper, SLOT(map())); action = subMenu->addAction(tr("&Smooth Shading")); actionGroup->addAction(action); //action->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_M)); action->setCheckable(true); signalMapper->setMapping(action, SimRobotCore2::Renderer::smoothShading); connect(action, SIGNAL(triggered()), signalMapper, SLOT(map())); qobject_cast<QAction*>(signalMapper->mapping(objectRenderer.getDrawingsShadeMode()))->setChecked(true); subMenu->addSeparator(); subMenu = subMenu->addMenu(tr("&Occlusion")); actionGroup = new QActionGroup(subMenu); signalMapper = new QSignalMapper(subMenu); connect(signalMapper, SIGNAL(mapped(int)), SLOT(setDrawingsOcclusion(int))); action = subMenu->menuAction(); action->setStatusTip(tr("Select different drawings occlusion modes")); action = subMenu->addAction(tr("&On")); actionGroup->addAction(action); action->setCheckable(true); signalMapper->setMapping(action, SimRobotCore2::Renderer::enableDrawingsOcclusion); connect(action, SIGNAL(triggered()), signalMapper, SLOT(map())); action = subMenu->addAction(tr("O&ff")); actionGroup->addAction(action); action->setCheckable(true); signalMapper->setMapping(action, 0); connect(action, SIGNAL(triggered()), signalMapper, SLOT(map())); action = subMenu->addAction(tr("&Transparent")); actionGroup->addAction(action); action->setCheckable(true); signalMapper->setMapping(action, SimRobotCore2::Renderer::enableDrawingsTransparentOcclusion); connect(action, SIGNAL(triggered()), signalMapper, SLOT(map())); qobject_cast<QAction*>(signalMapper->mapping(objectRenderer.getRenderFlags() & (SimRobotCore2::Renderer::enableDrawingsOcclusion | SimRobotCore2::Renderer::enableDrawingsTransparentOcclusion)))->setChecked(true); } menu->addSeparator(); QAction* action = menu->addAction(tr("Enable &Lights")); action->setStatusTip(tr("Enable lightning")); action->setCheckable(true); action->setChecked(objectRenderer.getRenderFlags() & SimRobotCore2::Renderer::enableLights); flagsSignalMapper->setMapping(action, SimRobotCore2::Renderer::enableLights); connect(action, SIGNAL(triggered()), flagsSignalMapper, SLOT(map())); action = menu->addAction(tr("Enable &Textures")); action->setStatusTip(tr("Enable textures")); action->setCheckable(true); action->setChecked(objectRenderer.getRenderFlags() & SimRobotCore2::Renderer::enableTextures); flagsSignalMapper->setMapping(action, SimRobotCore2::Renderer::enableTextures); connect(action, SIGNAL(triggered()), flagsSignalMapper, SLOT(map())); action = menu->addAction(tr("Enable &Multisample")); action->setStatusTip(tr("Enable multisampling")); action->setCheckable(true); action->setChecked(objectRenderer.getRenderFlags() & SimRobotCore2::Renderer::enableMultisample); flagsSignalMapper->setMapping(action, SimRobotCore2::Renderer::enableMultisample); connect(action, SIGNAL(triggered()), flagsSignalMapper, SLOT(map())); menu->addSeparator(); action = menu->addAction(tr("Show &Coordinate System")); action->setStatusTip(tr("Show the coordinate system of the displayed object")); action->setCheckable(true); action->setChecked(objectRenderer.getRenderFlags() & SimRobotCore2::Renderer::showCoordinateSystem); flagsSignalMapper->setMapping(action, SimRobotCore2::Renderer::showCoordinateSystem); connect(action, SIGNAL(triggered()), flagsSignalMapper, SLOT(map())); action = menu->addAction(QIcon(":/Icons/transmit_go.png"), tr("Show &Sensors")); action->setStatusTip(tr("Show the values of the sensors in the scene view")); action->setCheckable(true); action->setChecked(objectRenderer.getRenderFlags() & SimRobotCore2::Renderer::showSensors); flagsSignalMapper->setMapping(action, SimRobotCore2::Renderer::showSensors); connect(action, SIGNAL(triggered()), flagsSignalMapper, SLOT(map())); menu->addSeparator(); { QMenu* subMenu = menu->addMenu(tr("Export as Image...")); QSignalMapper* signalMapper = new QSignalMapper(subMenu); connect(signalMapper, SIGNAL(mapped(int)), SLOT(exportAsImage(int))); action = subMenu->addAction(tr("3840x2160")); signalMapper->setMapping(action, (3840 << 16) | 2160); connect(action, SIGNAL(triggered()), signalMapper, SLOT(map())); action = subMenu->addAction(tr("2880x1620")); signalMapper->setMapping(action, (2880 << 16) | 1620); connect(action, SIGNAL(triggered()), signalMapper, SLOT(map())); action = subMenu->addAction(tr("1920x1080")); signalMapper->setMapping(action, (1920 << 16) | 1080); connect(action, SIGNAL(triggered()), signalMapper, SLOT(map())); action = subMenu->addAction(tr("1280x1024")); signalMapper->setMapping(action, (1280 << 16) | 1024); connect(action, SIGNAL(triggered()), signalMapper, SLOT(map())); } return menu; }
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))); }
void ScorbotConsole::start2() { //loadParams(); QWidget* centralWidget = new QWidget(this); QVBoxLayout *mainVertLayout = new QVBoxLayout(centralWidget); QHBoxLayout *mainHorizLayout = new QHBoxLayout(centralWidget); mainVertLayout->addLayout(mainHorizLayout); //Create joint labels QGridLayout *controlLayout = new QGridLayout(centralWidget); controlLayout->setVerticalSpacing(0); int row = 0; int column = 0; //Create the horizontal control names QLabel* jointLbl = new QLabel("<b>Joint</b>", this); jointLbl->setAlignment(Qt::AlignHCenter); QLabel* pwmLbl = new QLabel("<b>PWM<b>", this); pwmLbl->setAlignment(Qt::AlignHCenter); QLabel* encoderLbl = new QLabel("<b>Encoder Val<b>", this); encoderLbl->setAlignment(Qt::AlignHCenter); QLabel* desiredLbl = new QLabel("<b>Desired Encoder<b>", this); desiredLbl->setAlignment(Qt::AlignHCenter); QLabel* durationLbl = new QLabel("<b>Duration<b>", this); durationLbl->setAlignment(Qt::AlignHCenter); QLabel* setLbl = new QLabel("<b>Set Position<b>", this); setLbl->setAlignment(Qt::AlignHCenter); controlLayout->addWidget(jointLbl, row, column++); controlLayout->addWidget(pwmLbl, row, column++); controlLayout->addWidget(encoderLbl, row, column++); controlLayout->addWidget(desiredLbl, row, column++); controlLayout->addWidget(durationLbl, row, column++); controlLayout->addWidget(setLbl, row, column++); controlLayout->setRowStretch(0, 0); //Create the vertical axis labels row=1; column=0; controlLayout->addWidget(new QLabel("<b>Base<b>", this) , row++, column); controlLayout->addWidget(new QLabel("<b>Shoulder<b>", this), row++, column); controlLayout->addWidget(new QLabel("<b>Elbow<b>", this) , row++, column); controlLayout->addWidget(new QLabel("<b>Wrist1<b>", this) , row++, column); controlLayout->addWidget(new QLabel("<b>Wrist2<b>", this) , row++, column); controlLayout->addWidget(new QLabel("<b>Gripper<b>", this) , row++, column); controlLayout->addWidget(new QLabel("<b>Slider<b>", this) , row++, column); //Create the pwm labels row=1; column++; pwmLbls[ScorbotIce::Base] = new QLabel(centralWidget); controlLayout->addWidget(pwmLbls[ScorbotIce::Base], row++, column); pwmLbls[ScorbotIce::Shoulder] = new QLabel(centralWidget); controlLayout->addWidget(pwmLbls[ScorbotIce::Shoulder], row++, column); pwmLbls[ScorbotIce::Elbow] = new QLabel(centralWidget); controlLayout->addWidget(pwmLbls[ScorbotIce::Elbow], row++, column); pwmLbls[ScorbotIce::Wrist1] = new QLabel(centralWidget); controlLayout->addWidget(pwmLbls[ScorbotIce::Wrist1], row++, column); pwmLbls[ScorbotIce::Wrist2] = new QLabel(centralWidget); controlLayout->addWidget(pwmLbls[ScorbotIce::Wrist2], row++, column); pwmLbls[ScorbotIce::Gripper] = new QLabel(centralWidget); controlLayout->addWidget(pwmLbls[ScorbotIce::Gripper], row++, column); pwmLbls[ScorbotIce::Slider] = new QLabel(centralWidget); controlLayout->addWidget(pwmLbls[ScorbotIce::Slider], row++, column); for(QMap<ScorbotIce::JointType, QLabel*>::iterator it=pwmLbls.begin(); it!=pwmLbls.end(); ++it) { it.value()->setMaximumWidth(50); it.value()->setMinimumWidth(50); } //Create the encoder labels row=1; column++; encoderLbls[ScorbotIce::Base] = new QLabel(centralWidget); controlLayout->addWidget(encoderLbls[ScorbotIce::Base], row++, column); encoderLbls[ScorbotIce::Shoulder] = new QLabel(centralWidget); controlLayout->addWidget(encoderLbls[ScorbotIce::Shoulder], row++, column); encoderLbls[ScorbotIce::Elbow] = new QLabel(centralWidget); controlLayout->addWidget(encoderLbls[ScorbotIce::Elbow], row++, column); encoderLbls[ScorbotIce::Wrist1] = new QLabel(centralWidget); controlLayout->addWidget(encoderLbls[ScorbotIce::Wrist1], row++, column); encoderLbls[ScorbotIce::Wrist2] = new QLabel(centralWidget); controlLayout->addWidget(encoderLbls[ScorbotIce::Wrist2], row++, column); encoderLbls[ScorbotIce::Gripper] = new QLabel(centralWidget); controlLayout->addWidget(encoderLbls[ScorbotIce::Gripper], row++, column); encoderLbls[ScorbotIce::Slider] = new QLabel(centralWidget); controlLayout->addWidget(encoderLbls[ScorbotIce::Slider], row++, column); for(QMap<ScorbotIce::JointType, QLabel*>::iterator it=encoderLbls.begin(); it!=encoderLbls.end(); ++it) { it.value()->setMaximumWidth(50); it.value()->setMinimumWidth(50); } //Create the encoder edits row=1; column++; encoderEdits[ScorbotIce::Base] = new QLineEdit(centralWidget); controlLayout->addWidget(encoderEdits[ScorbotIce::Base], row++, column); encoderEdits[ScorbotIce::Shoulder] = new QLineEdit(centralWidget); controlLayout->addWidget(encoderEdits[ScorbotIce::Shoulder], row++, column); 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())); connect(posButtonMapper, SIGNAL(mapped(int)), this, SLOT(setPosition(int))); //Gravity Compensation Label controlLayout->addWidget(new QLabel("<b>Gravity Compensation<b>", this), ++row, 0); gravityCompLbl = new QLabel(this); gravityCompLbl->setMaximumWidth(50); gravityCompLbl->setMinimumWidth(50); controlLayout->addWidget(gravityCompLbl, row++, 1); //Create the extra buttons row=1; column=7; //Reset Encoder Button QPushButton* resetEncoderButton = new QPushButton("Reset Encoders",centralWidget); controlLayout->addWidget(resetEncoderButton, row++, column); connect(resetEncoderButton, SIGNAL(pressed()), this, SLOT(resetEncoders())); //Enable Motors Button enableMotorsButton = new QPushButton("Enable Motors", centralWidget); controlLayout->addWidget(enableMotorsButton, row++, column); connect(enableMotorsButton, SIGNAL(pressed()), this, SLOT(toggleMotorsEnabled())); itsMotorsEnabled = false; itsScorbot->setEnabled(false); //Print Position Code Buton QPushButton* printPosCodeButton = new QPushButton("Print Position Code", centralWidget); controlLayout->addWidget(printPosCodeButton, row++, column); connect(printPosCodeButton, SIGNAL(pressed()), this, SLOT(printPosCode())); mainHorizLayout->addLayout(controlLayout); mainHorizLayout->addSpacing(10); mainHorizLayout->addStretch(10); //Make the PID layout row=1; column = 0; QGridLayout *pidLayout = new QGridLayout(this); itsAxisComboBox = new QComboBox(this); itsAxisComboBox->addItem("Base", 0); itsAxisComboBox->addItem("Shoulder", 1); itsAxisComboBox->addItem("Elbow", 2); itsAxisComboBox->addItem("Wrist1", 3); itsAxisComboBox->addItem("Wrist2", 4); itsAxisComboBox->addItem("Gripper", 5); itsAxisComboBox->addItem("Slider", 6); connect(itsAxisComboBox, SIGNAL(activated(int)), this, SLOT(pidAxisSelected(int))); pidLayout->addWidget(itsAxisComboBox, 0, 1); pGainEdit = new QLineEdit(this); pidLayout->addWidget(new QLabel("P Gain", this), row, 0); pidLayout->addWidget(pGainEdit, row++, 1); iGainEdit = new QLineEdit(this); pidLayout->addWidget(new QLabel("I Gain", this), row, 0); pidLayout->addWidget(iGainEdit, row++, 1); dGainEdit = new QLineEdit(this); pidLayout->addWidget(new QLabel("D Gain", this), row, 0); pidLayout->addWidget(dGainEdit, row++, 1); maxIEdit = new QLineEdit(this); pidLayout->addWidget(new QLabel("Max I", this), row, 0); pidLayout->addWidget(maxIEdit, row++, 1); maxPWMEdit = new QLineEdit(this); pidLayout->addWidget(new QLabel("Max PWM", this), row, 0); pidLayout->addWidget(maxPWMEdit, row++, 1); pwmOffsetEdit = new QLineEdit(this); pidLayout->addWidget(new QLabel("PWM Offset", this), row, 0); pidLayout->addWidget(pwmOffsetEdit, row++, 1); foreArmMassEdit = new QLineEdit(this); pidLayout->addWidget(new QLabel("Fore Arm Mass", this), row, 0); pidLayout->addWidget(foreArmMassEdit, row++, 1); upperArmMassEdit = new QLineEdit(this); pidLayout->addWidget(new QLabel("Upper Arm Mass", this), row, 0); pidLayout->addWidget(upperArmMassEdit, row++, 1); gravityCompScaleEdit = new QLineEdit(this); pidLayout->addWidget(new QLabel("Gravity Scale", this), row, 0); pidLayout->addWidget(gravityCompScaleEdit, row++, 1); QPushButton* setPIDButton = new QPushButton("Set PID", this); connect(setPIDButton, SIGNAL(pressed()), this, SLOT(setPIDVals())); pidLayout->addWidget(setPIDButton, row++, 1); mainHorizLayout->addLayout(pidLayout); pidAxisSelected(0); //Create the plot itsGraphicsScene = new QGraphicsScene(this); itsGraphicsView = new QGraphicsView(itsGraphicsScene); itsImageDisplay = new ImageGraphicsItem; itsGraphicsScene->addItem(itsImageDisplay); itsGraphicsView->show(); mainVertLayout->addWidget(itsGraphicsView); itsGraphicsView->setMinimumSize(640, 550); //Set the main layout to display setCentralWidget(centralWidget); centralWidget->setLayout(mainVertLayout); itsScorbotThread->start(); }
// --- 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); toolBar->addAction(m_addGradientAction); toolBar->addAction(m_addColorAction); toolBar->addAction(m_addFontAction); m_editor->setFocus(); QDesignerSettingsInterface *settings = core->settingsManager(); settings->beginGroup(QLatin1String(StyleSheetDialogC)); if (settings->contains(QLatin1String(Geometry))) restoreGeometry(settings->value(QLatin1String(Geometry)).toByteArray()); settings->endGroup(); }
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>"); }
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()); connect(action, SIGNAL(triggered()), this, SLOT(snapToRoot())); subMenu = menu->addMenu(tr("&Vertical Opening Angle")); action = subMenu->menuAction(); action->setIcon(QIcon(":/icons/opening_angle.png")); actionGroup = new QActionGroup(subMenu); signalMapper = new QSignalMapper(subMenu); connect(signalMapper, SIGNAL(mapped(int)), SLOT(setFovY(int))); action = subMenu->addAction(tr("&20°")); actionGroup->addAction(action); signalMapper->setMapping(action, 20); action->setShortcut(QKeySequence(Qt::Key_1)); action->setCheckable(true); connect(action, SIGNAL(triggered()), signalMapper, SLOT(map())); action = subMenu->addAction(tr("&40°")); actionGroup->addAction(action); signalMapper->setMapping(action, 40); action->setShortcut(QKeySequence(Qt::Key_2)); action->setCheckable(true); connect(action, SIGNAL(triggered()), signalMapper, SLOT(map())); action = subMenu->addAction(tr("&60°")); actionGroup->addAction(action); signalMapper->setMapping(action, 60); action->setShortcut(QKeySequence(Qt::Key_3)); action->setCheckable(true); connect(action, SIGNAL(triggered()), signalMapper, SLOT(map())); action = subMenu->addAction(tr("&80°")); actionGroup->addAction(action); signalMapper->setMapping(action, 80); action->setShortcut(QKeySequence(Qt::Key_4)); action->setCheckable(true); connect(action, SIGNAL(triggered()), signalMapper, SLOT(map())); action = subMenu->addAction(tr("100°")); actionGroup->addAction(action); signalMapper->setMapping(action, 100); action->setShortcut(QKeySequence(Qt::Key_5)); action->setCheckable(true); connect(action, SIGNAL(triggered()), signalMapper, SLOT(map())); action = subMenu->addAction(tr("120°")); actionGroup->addAction(action); signalMapper->setMapping(action, 120); action->setShortcut(QKeySequence(Qt::Key_6)); action->setCheckable(true); connect(action, SIGNAL(triggered()), signalMapper, SLOT(map())); qobject_cast<QAction*>(signalMapper->mapping(objectRenderer.getFovY()))->setChecked(true); subMenu = menu->addMenu(tr("&Surface Rendering")); actionGroup = new QActionGroup(subMenu); signalMapper = new QSignalMapper(subMenu); connect(signalMapper, SIGNAL(mapped(int)), SLOT(setSurfaceStyle(int))); action = subMenu->menuAction(); action->setIcon(QIcon(":/icons/layers.png")); action->setStatusTip(tr("Select different rendering techniques for displaying the scene")); action = subMenu->addAction(tr("Appearance &Wire Frame")); actionGroup->addAction(action); action->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_W)); action->setCheckable(true); signalMapper->setMapping(action, VisualizationParameterSet::WIREFRAME); connect(action, SIGNAL(triggered()), signalMapper, SLOT(map())); action = subMenu->addAction(tr("Appearance &Flat Shading")); actionGroup->addAction(action); action->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_F)); action->setCheckable(true); signalMapper->setMapping(action, VisualizationParameterSet::FLAT_SHADING); connect(action, SIGNAL(triggered()), signalMapper, SLOT(map())); action = subMenu->addAction(tr("Appearance &Smooth Shading")); actionGroup->addAction(action); action->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_M)); action->setCheckable(true); signalMapper->setMapping(action, VisualizationParameterSet::SMOOTH_SHADING); connect(action, SIGNAL(triggered()), signalMapper, SLOT(map())); action = subMenu->addAction(tr("Appearance &Texture Shading")); actionGroup->addAction(action); action->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_T)); action->setCheckable(true); signalMapper->setMapping(action, VisualizationParameterSet::TEXTURE_SHADING); connect(action, SIGNAL(triggered()), signalMapper, SLOT(map())); action = subMenu->addAction(tr("Appearance &Camera Simulation")); actionGroup->addAction(action); action->setCheckable(true); signalMapper->setMapping(action, VisualizationParameterSet::CAMERA_SIMULATION); connect(action, SIGNAL(triggered()), signalMapper, SLOT(map())); subMenu->addSeparator(); action = subMenu->addAction(tr("Physics &Wire Frame")); actionGroup->addAction(action); action->setCheckable(true); signalMapper->setMapping(action, VisualizationParameterSet::PHYSICS_WIREFRAME); connect(action, SIGNAL(triggered()), signalMapper, SLOT(map())); action = subMenu->addAction(tr("Physics &Flat Shading")); actionGroup->addAction(action); action->setCheckable(true); signalMapper->setMapping(action, VisualizationParameterSet::PHYSICS_FLAT); connect(action, SIGNAL(triggered()), signalMapper, SLOT(map())); action = subMenu->addAction(tr("Physics &Smooth Shading")); actionGroup->addAction(action); action->setCheckable(true); signalMapper->setMapping(action, VisualizationParameterSet::PHYSICS_SMOOTH); connect(action, SIGNAL(triggered()), signalMapper, SLOT(map())); subMenu->addSeparator(); action = subMenu->addAction(tr("Mixed Mode &1 (Shaded Physics)")); actionGroup->addAction(action); action->setCheckable(true); signalMapper->setMapping(action, VisualizationParameterSet::MIXED_PHYSICS); connect(action, SIGNAL(triggered()), signalMapper, SLOT(map())); action = subMenu->addAction(tr("Mixed Mode &2 (Shaded Appearance)")); actionGroup->addAction(action); action->setCheckable(true); signalMapper->setMapping(action, VisualizationParameterSet::MIXED_APPEARANCE); connect(action, SIGNAL(triggered()), signalMapper, SLOT(map())); qobject_cast<QAction*>(signalMapper->mapping(objectRenderer.getSurfaceStyle()))->setChecked(true); menu->addSeparator(); if(!showSensorsAct) { showSensorsAct = new QAction(QIcon(":/icons/transmit_go.png"), tr("Show &Sensors"), this); showSensorsAct->setStatusTip(tr("Show the values of the sensors in the scene view")); showSensorsAct->setCheckable(true); showSensorsAct->setChecked(objectRenderer.hasShowDetailSensors()); connect(showSensorsAct, SIGNAL(triggered()), this, SLOT(showDetailSensors())); } menu->addAction(showSensorsAct); if(!showDrawingsAct) { showDrawingsAct = new QAction(QIcon(":/icons/chart_line.png"), tr("Show Controller &Drawings"), this); showDrawingsAct->setStatusTip(tr("Show the controller 3D drawings in the scene view")); showDrawingsAct->setCheckable(true); showDrawingsAct->setChecked(objectRenderer.hasShowControllerDrawings()); connect(showDrawingsAct, SIGNAL(triggered()), this, SLOT(showControllerDrawings())); } menu->addAction(showDrawingsAct); return menu; }
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"); connect(bouton4, SIGNAL(clicked()), signalMapper, SLOT(map())); signalMapper->setMapping(bouton4, "4"); QPushButton *bouton5= new QPushButton(); bouton5->setText("5"); connect(bouton5, SIGNAL(clicked()), signalMapper, SLOT(map())); signalMapper->setMapping(bouton5, "5"); QPushButton *bouton6= new QPushButton(); bouton6->setText("6"); connect(bouton6, SIGNAL(clicked()), signalMapper, SLOT(map())); signalMapper->setMapping(bouton6, "6"); QPushButton *bouton7= new QPushButton(); bouton7->setText("7"); connect(bouton7, SIGNAL(clicked()), signalMapper, SLOT(map())); signalMapper->setMapping(bouton7, "7"); QPushButton *bouton8= new QPushButton(); bouton8->setText("8"); connect(bouton8, SIGNAL(clicked()), signalMapper, SLOT(map())); signalMapper->setMapping(bouton8, "8"); QPushButton *bouton9= new QPushButton(); bouton9->setText("9"); connect(bouton9, SIGNAL(clicked()), signalMapper, SLOT(map())); signalMapper->setMapping(bouton9, "9"); QPushButton *boutonEspace= new QPushButton(); boutonEspace->setText(""); connect(boutonEspace, SIGNAL(clicked()), signalMapper, SLOT(map())); signalMapper->setMapping(boutonEspace, " "); QPushButton *boutonAddition= new QPushButton(); boutonAddition->setText("+"); connect(boutonAddition, SIGNAL(clicked()), signalMapper, SLOT(map())); signalMapper->setMapping(boutonAddition, "+"); QPushButton *boutonSoustraction= new QPushButton(); boutonSoustraction->setText("-"); connect(boutonSoustraction, SIGNAL(clicked()), signalMapper, SLOT(map())); signalMapper->setMapping(boutonSoustraction, "-"); QPushButton *boutonMulitplication= new QPushButton(); boutonMulitplication->setText("*"); connect(boutonMulitplication, SIGNAL(clicked()), signalMapper, SLOT(map())); signalMapper->setMapping(boutonMulitplication, "*"); QPushButton *boutonDivision= new QPushButton(); boutonDivision->setText("/"); connect(boutonDivision, SIGNAL(clicked()), signalMapper, SLOT(map())); signalMapper->setMapping(boutonDivision, "/"); connect(signalMapper, SIGNAL(mapped(QString)), this, SLOT(appendInputKeyboard(QString))); QPushButton *boutonEntree= new QPushButton(); boutonEntree->setText("Entrée"); connect(boutonEntree, SIGNAL(clicked()), this, SLOT(returnPressedStr())); QVBoxLayout *layoutOperateurs = new QVBoxLayout(); layoutOperateurs->addWidget(boutonAddition); layoutOperateurs->addWidget(boutonSoustraction); layoutOperateurs->addWidget(boutonMulitplication); layoutOperateurs->addWidget(boutonDivision); layoutOperateurs->addWidget(boutonEntree); //Crée un layout contenant le clavier numérique layoutClavier->addWidget(bouton1, 0,0); layoutClavier->addWidget(bouton2, 0,1); layoutClavier->addWidget(bouton3, 0,2); layoutClavier->addWidget(bouton4, 1,0); layoutClavier->addWidget(bouton5, 1,1); layoutClavier->addWidget(bouton6, 1,2); layoutClavier->addWidget(bouton7, 2,0); layoutClavier->addWidget(bouton8, 2,1); layoutClavier->addWidget(bouton9, 2,2); layoutClavier->addWidget(boutonEspace,3,0,1,3); layoutClavier->addLayout(layoutOperateurs, 0,3,4,1); conteneurClavier = new QWidget(); conteneurClavier->setLayout(layoutClavier); //Crée un layout avec l'historique de commandes, la zone d'entrée et le clavier verticalLayout->addWidget(vueHistoriqueCommandes); verticalLayout->addWidget(inputLine); verticalLayout->addWidget(conteneurClavier); //Assemble les layouts mainLayout->addWidget(vuePile); mainLayout->addLayout(verticalLayout); QWidget* tab1 = new QWidget(); tab1->setLayout(mainLayout); tabWidget->addTab(tab1, "Principal"); QObject::connect(inputLine, SIGNAL(textChanged(QString)), this, SLOT(interpreter(QString))) ; QObject::connect(inputLine,SIGNAL(returnPressed()), this, SLOT(returnPressedStr())); pile->setView(vuePile); //---------------------------------TAB2-------------------------------------------- QHBoxLayout *layoutProgramme = new QHBoxLayout(); QVBoxLayout *layoutEditionProgramme = new QVBoxLayout(); QHBoxLayout *layoutBoutonsProgramme = new QHBoxLayout(); listeProgrammes = new QListView(); zoneProgramme = new QTextEdit(); zoneIdentifiant = new QLineEdit(); boutonValider = new QPushButton("Ajouter"); boutonEffacer = new QPushButton("Effacer"); boutonModifier = new QPushButton("Modifier"); boutonSupprimer = new QPushButton("Supprimer"); boutonSupprimer->setEnabled(false); boutonModifier->setEnabled(false); layoutBoutonsProgramme->addWidget(boutonValider); layoutBoutonsProgramme->addWidget(boutonEffacer); layoutBoutonsProgramme->addWidget(boutonModifier); layoutBoutonsProgramme->addWidget(boutonSupprimer); layoutEditionProgramme->addWidget(zoneProgramme); layoutEditionProgramme->addWidget(zoneIdentifiant); layoutEditionProgramme->addLayout(layoutBoutonsProgramme); layoutProgramme->addLayout(layoutEditionProgramme); layoutProgramme->addWidget(listeProgrammes); QWidget* tab2 = new QWidget(); tab2->setLayout(layoutProgramme); tabWidget->addTab(tab2, "Programmes"); QXmlStreamReader xmlReader; QFile fileProgramme("programmes.xml"); fileProgramme.open(QFile::ReadOnly); xmlReader.setDevice(&fileProgramme); xmlReader.readNext(); QString strIdentifiant; QString str; while(!xmlReader.atEnd() && !xmlReader.hasError()) { QXmlStreamReader::TokenType token = xmlReader.readNext(); if(token == QXmlStreamReader::StartDocument) { continue; } if(token == QXmlStreamReader::StartElement) { if(xmlReader.name() == "identifiant") { strIdentifiant= xmlReader.readElementText(); } if(xmlReader.name() == "string") { str= xmlReader.readElementText(); manager->insererProgramme(strIdentifiant, str); } } } QStringList* listeProgrammesStr = manager->getListProgrammes(); modeleProgrammes = new QStringListModel(*listeProgrammesStr, this); listeProgrammes->setEditTriggers(QAbstractItemView::NoEditTriggers); listeProgrammes->setModel(modeleProgrammes); fileProgramme.close(); QObject::connect(boutonValider, SIGNAL(clicked(bool)), this, SLOT(ajouterProgramme())); QObject::connect(listeProgrammes, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(afficherProgrammeListe(QModelIndex))); QObject::connect(boutonEffacer, SIGNAL(clicked(bool)), this, SLOT(effacerChampsProgramme())); QObject::connect(boutonSupprimer, SIGNAL(clicked(bool)), this, SLOT(supprimerProgramme())); QObject::connect(boutonModifier, SIGNAL(clicked(bool)), this, SLOT(modifierProgramme())); //---------------------------------TAB3-------------------------------------------- QHBoxLayout *layoutVariable = new QHBoxLayout(); QVBoxLayout *layoutEditionVariable = new QVBoxLayout(); QHBoxLayout *layoutBoutonsVariable = new QHBoxLayout(); listeVariables = new QListView(); zoneVariable = new QTextEdit(); zoneIdentifiantVariable = new QLineEdit(); boutonValiderVariable = new QPushButton("Ajouter"); boutonEffacerVariable = new QPushButton("Effacer"); boutonModifierVariable = new QPushButton("Modifier"); boutonSupprimerVariable = new QPushButton("Supprimer"); boutonSupprimerVariable->setEnabled(false); boutonModifierVariable->setEnabled(false); layoutBoutonsVariable->addWidget(boutonValiderVariable); layoutBoutonsVariable->addWidget(boutonEffacerVariable); layoutBoutonsVariable->addWidget(boutonModifierVariable); layoutBoutonsVariable->addWidget(boutonSupprimerVariable); layoutEditionVariable->addWidget(zoneVariable); layoutEditionVariable->addWidget(zoneIdentifiantVariable); layoutEditionVariable->addLayout(layoutBoutonsVariable); layoutVariable->addLayout(layoutEditionVariable); layoutVariable->addWidget(listeVariables); QWidget* tab3 = new QWidget(); tab3->setLayout(layoutVariable); tabWidget->addTab(tab3, "Variables"); QXmlStreamReader xmlReader2; QFile fileVariable("variables.xml"); fileVariable.open(QFile::ReadOnly); xmlReader2.setDevice(&fileVariable); xmlReader2.readNext(); while(!xmlReader2.atEnd() && !xmlReader2.hasError()) { QXmlStreamReader::TokenType token = xmlReader2.readNext(); if(token == QXmlStreamReader::StartDocument) { continue; } if(token == QXmlStreamReader::StartElement) { if(xmlReader2.name() == "identifiant") { strIdentifiant= xmlReader2.readElementText(); } if(xmlReader2.name() == "string") { str= xmlReader2.readElementText(); manager->insererVariable(strIdentifiant, str); } } } QStringList* listeVariablesStr = manager->getListVariables(); modeleVariables = new QStringListModel(*listeVariablesStr, this); listeVariables->setEditTriggers(QAbstractItemView::NoEditTriggers); listeVariables->setModel(modeleVariables); fileVariable.close(); QObject::connect(boutonValiderVariable, SIGNAL(clicked(bool)), this, SLOT(ajouterVariable())); QObject::connect(listeVariables, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(afficherVariableListe(QModelIndex))); QObject::connect(boutonEffacerVariable, SIGNAL(clicked(bool)), this, SLOT(effacerChampsVariable())); QObject::connect(boutonSupprimerVariable, SIGNAL(clicked(bool)), this, SLOT(supprimerVariable())); QObject::connect(boutonModifierVariable, SIGNAL(clicked(bool)), this, SLOT(modifierVariable())); QObject::connect(tabWidget, SIGNAL(currentChanged(int)), this, SLOT(updateTab(int))); setCentralWidget(tabWidget); }
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 ); CONNECT( searchEdit, textChanged( const QString& ), mainView, search( const QString& ) ); CONNECT( searchEdit, searchDelayedChanged( const QString& ), mainView, searchDelayed( const QString & ) ); CONNECT( mainView, viewChanged( const QModelIndex& ), this, changeView( const QModelIndex &) ); /* Connect the activation of the selector to a redefining of the PL */ DCONNECT( selector, categoryActivated( playlist_item_t *, bool ), mainView, setRootItem( playlist_item_t *, bool ) ); mainView->setRootItem( p_root, false ); /* */ split = new PlaylistSplitter( this ); /* Add the two sides of the QSplitter */ split->addWidget( leftSplitter ); split->addWidget( mainView ); QList<int> sizeList; sizeList << 180 << 420 ; split->setSizes( sizeList ); split->setStretchFactor( 0, 0 ); split->setStretchFactor( 1, 3 ); split->setCollapsible( 1, false ); leftSplitter->setMaximumWidth( 250 ); /* In case we want to keep the splitter information */ // components shall never write there setting to a fixed location, may infer // with other uses of the same component... getSettings()->beginGroup("Playlist"); split->restoreState( getSettings()->value("splitterSizes").toByteArray()); leftSplitter->restoreState( getSettings()->value("leftSplitterGeometry").toByteArray() ); getSettings()->endGroup(); layout->addWidget( split, 1, 0, 1, -1 ); setAcceptDrops( true ); setWindowTitle( qtr( "Playlist" ) ); setWindowRole( "vlc-playlist" ); setWindowIcon( QApplication::windowIcon() ); }
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))); } // keyboard shortcut only actions nextViewAction->setShortcut(QKeySequence(Qt::SHIFT + Qt::Key_Right)); connect(nextViewAction, SIGNAL(triggered()) , this , SLOT(nextView())); _viewSplitter->addAction(nextViewAction); previousViewAction->setShortcut(QKeySequence(Qt::SHIFT + Qt::Key_Left)); connect(previousViewAction, SIGNAL(triggered()) , this , SLOT(previousView())); _viewSplitter->addAction(previousViewAction); nextContainerAction->setShortcut(QKeySequence(Qt::SHIFT + Qt::Key_Tab)); connect(nextContainerAction , SIGNAL(triggered()) , this , SLOT(nextContainer())); _viewSplitter->addAction(nextContainerAction); moveViewLeftAction->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_Left)); connect(moveViewLeftAction , SIGNAL(triggered()) , this , SLOT(moveActiveViewLeft())); _viewSplitter->addAction(moveViewLeftAction); moveViewRightAction->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_Right)); connect(moveViewRightAction , SIGNAL(triggered()) , this , SLOT(moveActiveViewRight())); _viewSplitter->addAction(moveViewRightAction); connect(lastViewAction, SIGNAL(triggered()) , this , SLOT(lastView())); _viewSplitter->addAction(lastViewAction); }
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))); }
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); sideLayout->addWidget(removed_display_, pos_offset, 1); ++pos_offset; sideLayout->addWidget(new QLabel("Aircrafts in progress:"), pos_offset, 0); in_progress_display_ = new QLabel(this); sideLayout->addWidget(in_progress_display_, pos_offset, 1); ++pos_offset; sidePanel->setLayout(sideLayout); //layout->addWidget(view, 0, 0); /* qwt_demo_ = new QwtSchedDemo(this); layout->addWidget(qwt_demo_, 1, 0); */ demo2_src = new qwt_demo_2(this); demo2_src->setAxisScale(QwtPlot::xBottom, -30, 30); demo2 = new qwt_demo_2(this); demo2->setAxisScale(QwtPlot::xBottom, -30, 30); layout->addWidget(demo2_src, 0, 0); layout->addWidget(demo2, 0, 1); layout->addWidget(sidePanel, 0, 3, 2, 1); setLayout(layout); //scene_->invalidateItems(); updateCost(); }
void BarWidget::setUp(Storage *storage) { DataWidget::setUp(storage); m_min = 0; m_max = 1000; m_numberType = NUM_UINT8; m_rotation = 0; QMenu *bitsMenu = contextMenu->addMenu(tr("Data type")); QMenu *rotMenu = contextMenu->addMenu(tr("Rotation")); QSignalMapper *signalMapBits = new QSignalMapper(this); for(quint8 i = 0; i < NUM_COUNT; ++i) { static const QString dataTypes[] = { tr("unsigned 8bit"), tr("unsigned 16bit"), tr("unsigned 32bit"), tr("unsigned 64bit"), tr("signed 8bit"), tr("signed 16bit"), tr("signed 32bit"), tr("signed 64bit"), tr("float (4 bytes)"), tr("double (8 bytes)") }; if(i%4 == 0 && i != 0) bitsMenu->addSeparator(); m_bitsAct[i] = bitsMenu->addAction(dataTypes[i]); m_bitsAct[i]->setCheckable(true); signalMapBits->setMapping(m_bitsAct[i], i); connect(m_bitsAct[i], SIGNAL(triggered()), signalMapBits, SLOT(map())); } m_bitsAct[0]->setChecked(true); connect(signalMapBits, SIGNAL(mapped(int)), SLOT(setDataType(int))); QSignalMapper *signalMapRot = new QSignalMapper(this); for(quint8 i = 0; i < 2; ++i) { static const QString rotText[] = { tr("Vertical"), tr("Horizontal") }; m_rotAct[i] = rotMenu->addAction(rotText[i]); m_rotAct[i]->setCheckable(true); signalMapRot->setMapping(m_rotAct[i], i); connect(m_rotAct[i], SIGNAL(triggered()), signalMapRot, SLOT(map())); } rotationSelected(0); connect(signalMapRot, SIGNAL(mapped(int)), SLOT(setRotation(int))); QMenu *alarmMenu = contextMenu->addMenu(tr("Alarm")); m_alarmEnable = alarmMenu->addAction(tr("Enable alarm")); m_alarmEnable->setCheckable(true); m_alarmLevel = alarmMenu->addAction(tr("Set alarm level...")); m_alarmLevel->setEnabled(false); m_rangeAct = contextMenu->addAction(tr("Set range...")); m_showScaleAct = contextMenu->addAction(tr("Show scale")); m_showValAct = contextMenu->addAction(tr("Show value")); m_showScaleAct->setCheckable(true); m_showValAct->setCheckable(true); m_showScaleAct->setChecked(true); m_showValAct->setChecked(true); QAction *colorAct = contextMenu->addAction(tr("Set colors")); QAction *formula = contextMenu->addAction(tr("Set formula...")); connect(m_rangeAct, SIGNAL(triggered()), SLOT(rangeSelected())); connect(m_showScaleAct, SIGNAL(triggered(bool)), SLOT(showScale(bool))); connect(m_showValAct, SIGNAL(triggered(bool)), SLOT(showVal(bool))); connect(m_alarmEnable, SIGNAL(triggered(bool)), SLOT(setAlarmEnabled(bool))); connect(m_alarmLevel, SIGNAL(triggered()), SLOT(alarmLevelAct())); connect(colorAct, SIGNAL(triggered()), SLOT(showColorsDialog())); connect(formula, SIGNAL(triggered()), SLOT(showFormulaDialog())); }
/** Constructor */ GxsChannelPostsWidget::GxsChannelPostsWidget(const RsGxsGroupId &channelId, QWidget *parent) : GxsMessageFramePostWidget(rsGxsChannels, parent), ui(new Ui::GxsChannelPostsWidget) { /* Invoke the Qt Designer generated object setup routine */ ui->setupUi(this); /* Setup UI helper */ mStateHelper->addWidget(mTokenTypeAllPosts, ui->progressBar, UISTATE_LOADING_VISIBLE); mStateHelper->addWidget(mTokenTypeAllPosts, ui->loadingLabel, UISTATE_LOADING_VISIBLE); mStateHelper->addWidget(mTokenTypeAllPosts, ui->filterLineEdit); mStateHelper->addWidget(mTokenTypePosts, ui->loadingLabel, UISTATE_LOADING_VISIBLE); mStateHelper->addLoadPlaceholder(mTokenTypeGroupData, ui->nameLabel); mStateHelper->addWidget(mTokenTypeGroupData, ui->postButton); mStateHelper->addWidget(mTokenTypeGroupData, ui->logoLabel); mStateHelper->addWidget(mTokenTypeGroupData, ui->subscribeToolButton); /* Connect signals */ connect(ui->postButton, SIGNAL(clicked()), this, SLOT(createMsg())); connect(ui->subscribeToolButton, SIGNAL(subscribe(bool)), this, SLOT(subscribeGroup(bool))); connect(NotifyQt::getInstance(), SIGNAL(settingsChanged()), this, SLOT(settingsChanged())); /* add filter actions */ ui->filterLineEdit->addFilter(QIcon(), tr("Title"), FILTER_TITLE, tr("Search Title")); ui->filterLineEdit->addFilter(QIcon(), tr("Message"), FILTER_MSG, tr("Search Message")); ui->filterLineEdit->addFilter(QIcon(), tr("Filename"), FILTER_FILE_NAME, tr("Search Filename")); connect(ui->filterLineEdit, SIGNAL(textChanged(QString)), ui->feedWidget, SLOT(setFilterText(QString))); connect(ui->filterLineEdit, SIGNAL(textChanged(QString)), ui->fileWidget, SLOT(setFilterText(QString))); connect(ui->filterLineEdit, SIGNAL(filterChanged(int)), this, SLOT(filterChanged(int))); /* Initialize view button */ //setViewMode(VIEW_MODE_FEEDS); see processSettings ui->infoWidget->hide(); QSignalMapper *signalMapper = new QSignalMapper(this); connect(ui->feedToolButton, SIGNAL(clicked()), signalMapper, SLOT(map())); connect(ui->fileToolButton, SIGNAL(clicked()), signalMapper, SLOT(map())); signalMapper->setMapping(ui->feedToolButton, VIEW_MODE_FEEDS); signalMapper->setMapping(ui->fileToolButton, VIEW_MODE_FILES); connect(signalMapper, SIGNAL(mapped(int)), this, SLOT(setViewMode(int))); /*************** Setup Left Hand Side (List of Channels) ****************/ ui->loadingLabel->hide(); ui->progressBar->hide(); ui->nameLabel->setMinimumWidth(20); /* Initialize feed widget */ ui->feedWidget->setSortRole(ROLE_PUBLISH, Qt::DescendingOrder); ui->feedWidget->setFilterCallback(filterItem); /* load settings */ processSettings(true); /* Initialize subscribe button */ QIcon icon; icon.addPixmap(QPixmap(":/images/redled.png"), QIcon::Normal, QIcon::On); icon.addPixmap(QPixmap(":/images/start.png"), QIcon::Normal, QIcon::Off); mAutoDownloadAction = new QAction(icon, "", this); mAutoDownloadAction->setCheckable(true); connect(mAutoDownloadAction, SIGNAL(triggered()), this, SLOT(toggleAutoDownload())); ui->subscribeToolButton->addSubscribedAction(mAutoDownloadAction); /* Initialize GUI */ setAutoDownload(false); settingsChanged(); setGroupId(channelId); }
SwitchesControl::SwitchesControl(QWidget *parent, Qt::WindowFlags f) : QWidget(parent, f), ui(new Ui::SwitchesControl) { qDebug() << "SwitchesControl::SwitchesControl"; ui->setupUi(this); /* QIcon icon; icon.addFile(":/HAC01/button-background-normal-128x128.png", QSize(), QIcon::Normal); icon.addFile(":/HAC01/button-background-active-128x128.png", QSize(), QIcon::Active); if (!icon.isNull()) { ui->switch1Button->setAutoFillBackground(false); ui->switch1Button->setBackgroundIcon(icon); ui->switch2Button->setAutoFillBackground(false); ui->switch2Button->setBackgroundIcon(icon); ui->switch3Button->setAutoFillBackground(false); ui->switch3Button->setBackgroundIcon(icon); } else { qDebug() << "Can not found button-background-128x128.png"; } //icon.addFile(":/HAC01/button-background-normal-64x128.png", QSize(), QIcon::Normal); //icon.addFile(":/HAC01/button-background-active-64x128.png", QSize(), QIcon::Active); if (!icon.isNull()) { ui->singleOnButton->setAutoFillBackground(false); ui->singleOnButton->setBackgroundIcon(icon); ui->singleOffButton->setAutoFillBackground(false); ui->singleOffButton->setBackgroundIcon(icon); } else { qDebug() << "Can not found button-background-64x128.png"; } icon.addFile(":/HAC01/button-background-normal-64x64.png", QSize(), QIcon::Normal); icon.addFile(":/HAC01/button-background-active-64x64.png", QSize(), QIcon::Active); if (!icon.isNull()) { ui->allOnButton->setAutoFillBackground(false); ui->allOnButton->setBackgroundIcon(icon); ui->allOffButton->setAutoFillBackground(false); ui->allOffButton->setBackgroundIcon(icon); } else { qDebug() << "Can not found button-background-64x64.png"; } */ QSignalMapper *buttonsSignalMapper = new QSignalMapper(this); connect(ui->switch1Button, SIGNAL(clicked()), buttonsSignalMapper, SLOT(map())); buttonsSignalMapper->setMapping(ui->switch1Button, ui->switch1Button->objectName()); connect(ui->switch2Button, SIGNAL(clicked()), buttonsSignalMapper, SLOT(map())); buttonsSignalMapper->setMapping(ui->switch2Button, ui->switch2Button->objectName()); connect(ui->switch3Button, SIGNAL(clicked()), buttonsSignalMapper, SLOT(map())); buttonsSignalMapper->setMapping(ui->switch3Button, ui->switch3Button->objectName()); connect(ui->singleOnButton, SIGNAL(clicked()), buttonsSignalMapper, SLOT(map())); buttonsSignalMapper->setMapping(ui->singleOnButton, ui->singleOnButton->objectName()); connect(ui->singleOffButton, SIGNAL(clicked()), buttonsSignalMapper, SLOT(map())); buttonsSignalMapper->setMapping(ui->singleOffButton, ui->singleOffButton->objectName()); connect(ui->allOnButton, SIGNAL(clicked()), buttonsSignalMapper, SLOT(map())); buttonsSignalMapper->setMapping(ui->allOnButton, ui->allOnButton->objectName()); connect(ui->allOffButton, SIGNAL(clicked()), buttonsSignalMapper, SLOT(map())); buttonsSignalMapper->setMapping(ui->allOffButton, ui->allOffButton->objectName()); connect(buttonsSignalMapper, SIGNAL(mapped(const QString &)), this, SLOT(OnButtonClicked(const QString &))); }
void MapBox::createOptionsDialog() { if (m_optionsWidget) delete m_optionsWidget; m_optionsWidget = new QWidget(this); QGridLayout * optionsLayout = new QGridLayout; QVector<QString> mapTypeNames; QVector<QGraphicsGeoMap::MapType> mapControlTypes; mapControlTypes.append(QGraphicsGeoMap::StreetMap); mapTypeNames.append(tr("Street")); mapControlTypes.append(QGraphicsGeoMap::SatelliteMapDay); mapTypeNames.append(tr("Satellite")); mapControlTypes.append(QGraphicsGeoMap::SatelliteMapNight); mapTypeNames.append(tr("Satellite - Night")); mapControlTypes.append(QGraphicsGeoMap::TerrainMap); mapTypeNames.append(tr("Terrain")); { // map types QSignalMapper * mapper = new QSignalMapper(m_optionsWidget); connect(mapper, SIGNAL(mapped(int)), this, SLOT(mapTypeToggled(int))); QLabel * mapTypesLabel = new QLabel(tr("Map types")); mapTypesLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); mapTypesLabel->setAlignment(Qt::AlignHCenter); optionsLayout->addWidget(mapTypesLabel, 0, 0); QList<QGraphicsGeoMap::MapType> types = m_mapWidget->supportedMapTypes(); for (int controlIndex = 0; controlIndex < mapControlTypes.size(); ++controlIndex) { QPushButton *button = new QPushButton(mapTypeNames[controlIndex], m_optionsWidget); button->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); QFont font = button->font(); font.setPointSize(24); button->setFont(font); optionsLayout->addWidget(button, controlIndex+1, 0); int supportedTypeIndex = types.indexOf(mapControlTypes[controlIndex]); if (supportedTypeIndex == -1) { button->setEnabled(false); } else { connect(button, SIGNAL(clicked()), mapper, SLOT(map())); mapper->setMapping(button, mapControlTypes[controlIndex]); button->setEnabled(true); //button->setChecked(mapControlTypes[controlIndex] == m_mapWidget->mapType()); } } } { // connectivity modes QVector<QString> connectivityModeNames; QVector<QGraphicsGeoMap::ConnectivityMode> connectivityModes; connectivityModes.append(QGraphicsGeoMap::NoConnectivity); connectivityModeNames.append(tr("No connectivity")); connectivityModes.append(QGraphicsGeoMap::OfflineMode); connectivityModeNames.append(tr("Offline")); connectivityModes.append(QGraphicsGeoMap::OnlineMode); connectivityModeNames.append(tr("Online")); connectivityModes.append(QGraphicsGeoMap::HybridMode); connectivityModeNames.append(tr("Hybrid")); // map types QSignalMapper * mapper = new QSignalMapper(m_optionsWidget); connect(mapper, SIGNAL(mapped(int)), this, SLOT(connectivityModeToggled(int))); QLabel * connectivityModesLabel = new QLabel(tr("Connectivity")); connectivityModesLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); connectivityModesLabel->setAlignment(Qt::AlignHCenter); optionsLayout->addWidget(connectivityModesLabel, 0, 1); QList<QGraphicsGeoMap::ConnectivityMode> modes = m_mapWidget->supportedConnectivityModes(); for (int controlIndex = 0; controlIndex < connectivityModes.size(); ++controlIndex) { QPushButton *button = new QPushButton(connectivityModeNames[controlIndex], m_optionsWidget); button->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); QFont font = button->font(); font.setPointSize(24); button->setFont(font); optionsLayout->addWidget(button, controlIndex+1, 1); int supportedTypeIndex = modes.indexOf(connectivityModes[controlIndex]); if (supportedTypeIndex == -1) { button->setEnabled(false); } else { connect(button, SIGNAL(clicked()), mapper, SLOT(map())); mapper->setMapping(button, connectivityModes[controlIndex]); button->setEnabled(true); //button->setChecked(connectivityModes[controlIndex] == m_mapWidget->connectivityMode()); } } } /* { // plugins, TODO QList<QString> providers = QGeoServiceProvider::availableServiceProviders(); for (int i = 0; i < providers.count(); ++i) { QAction *providerAction = new QAction(providers[i], this); providerAction->setCheckable(true); providerAction->setChecked(i == 0); m_pluginMenu->addAction(providerAction); } } */ m_optionsWidget->setLayout(optionsLayout); if (displayMode() == DisplayOptions) { setDisplayMode(DisplayNone); setDisplayMode(DisplayOptions); } }
void JobEditorWindow::createInsertTaskMenuItems() { // ensure that plugins are loaded PluginManager::getInstance().loadPlugins(); QSignalMapper* signalMapper = new QSignalMapper(this); vector<const char*> tools = RSTool::getTools(); // acquire list of tool categories vector<string> categories; for (vector<const char*>::iterator it = tools.begin(); it != tools.end(); ++it) { char* code = (char*)*it; rsToolRegistration* reg = RSTool::findRegistration(code); string category = reg->category; if ( std::find(categories.begin(), categories.end(), category) == categories.end() ) { categories.push_back(category); } } std::sort(categories.begin(), categories.end()); // create submenus typedef tr1::unordered_map<string, QMenu*> hashmap; hashmap submenus; for (vector<string>::iterator it = categories.begin(); it != categories.end(); ++it) { string category = (string)*it; if ( submenus.find(category) == submenus.end() ) { QMenu* submenu = insertMenu->addMenu(category.c_str()); submenus[category] = submenu; } } // create insert actions size_t i=0; //std::sort(tools.begin(), tools.end()); for (vector<const char*>::iterator it = tools.begin(); it != tools.end(); ++it) { const char* code = (char*)*it; RSTask* task = RSTask::taskFactory(code); const char* name = task->getName(); QAction *action = new QAction(tr(name), this); connect(action, SIGNAL(triggered()), signalMapper, SLOT(map())); signalMapper->setMapping(action, i); rsToolRegistration* reg = RSTool::findRegistration(code); string category = reg->category; submenus[category]->addAction(action); i++; } connect(signalMapper, SIGNAL(mapped(int)), this, SLOT(insertNewTask(int))) ; }
void RPCConsole::setClientModel(ClientModel *model) { clientModel = model; ui->trafficGraph->setClientModel(model); if (model && clientModel->getPeerTableModel() && clientModel->getBanTableModel()) { // Keep up to date with client setNumConnections(model->getNumConnections()); connect(model, SIGNAL(numConnectionsChanged(int)), this, SLOT(setNumConnections(int))); setNumBlocks(model->getNumBlocks(), model->getLastBlockDate(), model->getVerificationProgress(nullptr), false); connect(model, SIGNAL(numBlocksChanged(int,QDateTime,double,bool)), this, SLOT(setNumBlocks(int,QDateTime,double,bool))); updateNetworkState(); connect(model, SIGNAL(networkActiveChanged(bool)), this, SLOT(setNetworkActive(bool))); updateTrafficStats(model->getTotalBytesRecv(), model->getTotalBytesSent()); connect(model, SIGNAL(bytesChanged(quint64,quint64)), this, SLOT(updateTrafficStats(quint64, quint64))); connect(model, SIGNAL(mempoolSizeChanged(long,size_t)), this, SLOT(setMempoolSize(long,size_t))); // set up peer table ui->peerWidget->setModel(model->getPeerTableModel()); ui->peerWidget->verticalHeader()->hide(); ui->peerWidget->setEditTriggers(QAbstractItemView::NoEditTriggers); ui->peerWidget->setSelectionBehavior(QAbstractItemView::SelectRows); ui->peerWidget->setSelectionMode(QAbstractItemView::ExtendedSelection); ui->peerWidget->setContextMenuPolicy(Qt::CustomContextMenu); ui->peerWidget->setColumnWidth(PeerTableModel::Address, ADDRESS_COLUMN_WIDTH); ui->peerWidget->setColumnWidth(PeerTableModel::Subversion, SUBVERSION_COLUMN_WIDTH); ui->peerWidget->setColumnWidth(PeerTableModel::Ping, PING_COLUMN_WIDTH); ui->peerWidget->horizontalHeader()->setStretchLastSection(true); // create peer table context menu actions QAction* disconnectAction = new QAction(tr("&Disconnect"), this); QAction* banAction1h = new QAction(tr("Ban for") + " " + tr("1 &hour"), this); QAction* banAction24h = new QAction(tr("Ban for") + " " + tr("1 &day"), this); QAction* banAction7d = new QAction(tr("Ban for") + " " + tr("1 &week"), this); QAction* banAction365d = new QAction(tr("Ban for") + " " + tr("1 &year"), this); // create peer table context menu peersTableContextMenu = new QMenu(this); peersTableContextMenu->addAction(disconnectAction); peersTableContextMenu->addAction(banAction1h); peersTableContextMenu->addAction(banAction24h); peersTableContextMenu->addAction(banAction7d); peersTableContextMenu->addAction(banAction365d); // Add a signal mapping to allow dynamic context menu arguments. // We need to use int (instead of int64_t), because signal mapper only supports // int or objects, which is okay because max bantime (1 year) is < int_max. QSignalMapper* signalMapper = new QSignalMapper(this); signalMapper->setMapping(banAction1h, 60*60); signalMapper->setMapping(banAction24h, 60*60*24); signalMapper->setMapping(banAction7d, 60*60*24*7); signalMapper->setMapping(banAction365d, 60*60*24*365); connect(banAction1h, SIGNAL(triggered()), signalMapper, SLOT(map())); connect(banAction24h, SIGNAL(triggered()), signalMapper, SLOT(map())); connect(banAction7d, SIGNAL(triggered()), signalMapper, SLOT(map())); connect(banAction365d, SIGNAL(triggered()), signalMapper, SLOT(map())); connect(signalMapper, SIGNAL(mapped(int)), this, SLOT(banSelectedNode(int))); // peer table context menu signals connect(ui->peerWidget, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(showPeersTableContextMenu(const QPoint&))); connect(disconnectAction, SIGNAL(triggered()), this, SLOT(disconnectSelectedNode())); // peer table signal handling - update peer details when selecting new node connect(ui->peerWidget->selectionModel(), SIGNAL(selectionChanged(const QItemSelection &, const QItemSelection &)), this, SLOT(peerSelected(const QItemSelection &, const QItemSelection &))); // peer table signal handling - update peer details when new nodes are added to the model connect(model->getPeerTableModel(), SIGNAL(layoutChanged()), this, SLOT(peerLayoutChanged())); // peer table signal handling - cache selected node ids connect(model->getPeerTableModel(), SIGNAL(layoutAboutToBeChanged()), this, SLOT(peerLayoutAboutToChange())); // set up ban table ui->banlistWidget->setModel(model->getBanTableModel()); ui->banlistWidget->verticalHeader()->hide(); ui->banlistWidget->setEditTriggers(QAbstractItemView::NoEditTriggers); ui->banlistWidget->setSelectionBehavior(QAbstractItemView::SelectRows); ui->banlistWidget->setSelectionMode(QAbstractItemView::SingleSelection); ui->banlistWidget->setContextMenuPolicy(Qt::CustomContextMenu); ui->banlistWidget->setColumnWidth(BanTableModel::Address, BANSUBNET_COLUMN_WIDTH); ui->banlistWidget->setColumnWidth(BanTableModel::Bantime, BANTIME_COLUMN_WIDTH); ui->banlistWidget->horizontalHeader()->setStretchLastSection(true); // create ban table context menu action QAction* unbanAction = new QAction(tr("&Unban"), this); // create ban table context menu banTableContextMenu = new QMenu(this); banTableContextMenu->addAction(unbanAction); // ban table context menu signals connect(ui->banlistWidget, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(showBanTableContextMenu(const QPoint&))); connect(unbanAction, SIGNAL(triggered()), this, SLOT(unbanSelectedNode())); // ban table signal handling - clear peer details when clicking a peer in the ban table connect(ui->banlistWidget, SIGNAL(clicked(const QModelIndex&)), this, SLOT(clearSelectedNode())); // ban table signal handling - ensure ban table is shown or hidden (if empty) connect(model->getBanTableModel(), SIGNAL(layoutChanged()), this, SLOT(showOrHideBanTableIfRequired())); showOrHideBanTableIfRequired(); // Provide initial values ui->clientVersion->setText(model->formatFullVersion()); ui->clientUserAgent->setText(model->formatSubVersion()); ui->dataDir->setText(model->dataDir()); ui->startupTime->setText(model->formatClientStartupTime()); ui->networkName->setText(QString::fromStdString(Params().NetworkIDString())); //Setup autocomplete and attach it QStringList wordList; std::vector<std::string> commandList = tableRPC.listCommands(); for (size_t i = 0; i < commandList.size(); ++i) { wordList << commandList[i].c_str(); wordList << ("help " + commandList[i]).c_str(); } wordList << "help-console"; wordList.sort(); autoCompleter = new QCompleter(wordList, this); autoCompleter->setModelSorting(QCompleter::CaseSensitivelySortedModel); ui->lineEdit->setCompleter(autoCompleter); autoCompleter->popup()->installEventFilter(this); // Start thread to execute RPC commands. startExecutor(); }
FITSViewer::FITSViewer (QWidget *parent) : KXmlGuiWindow (parent) { #ifdef Q_OS_OSX if(Options::independentWindowFITS()) setWindowFlags(Qt::Window); else{ setWindowFlags(Qt::Window | Qt::WindowStaysOnTopHint); connect(QApplication::instance(), SIGNAL(applicationStateChanged(Qt::ApplicationState)), this, SLOT(changeAlwaysOnTop(Qt::ApplicationState))); } #endif fitsTab = new QTabWidget(this); undoGroup = new QUndoGroup(this); fitsID = 0; debayerDialog= NULL; markStars = false; lastURL = QUrl(QDir::homePath()); fitsTab->setTabsClosable(true); setWindowIcon(QIcon::fromTheme("kstars_fitsviewer", QIcon(":/icons/breeze/default/kstars_fitsviewer.svg"))); setCentralWidget(fitsTab); connect(fitsTab, SIGNAL(currentChanged(int)), this, SLOT(tabFocusUpdated(int))); connect(fitsTab, SIGNAL(tabCloseRequested(int)), this, SLOT(closeTab(int))); //These two connections will enable or disable the scope button if a scope is available or not. //Of course this is also dependent on the presence of WCS data in the image. #ifdef HAVE_INDI connect(INDIListener::Instance(), SIGNAL(newTelescope(ISD::GDInterface *)), this, SLOT(updateWCSFunctions())); connect(INDIListener::Instance(), SIGNAL(deviceRemoved(ISD::GDInterface *)), this, SLOT(updateWCSFunctions())); #endif led.setColor(Qt::green); fitsPosition.setAlignment(Qt::AlignCenter); fitsValue.setAlignment(Qt::AlignCenter); //fitsPosition.setFixedWidth(100); //fitsValue.setFixedWidth(100); fitsWCS.setVisible(false); statusBar()->insertPermanentWidget(FITS_WCS, &fitsWCS); statusBar()->insertPermanentWidget(FITS_VALUE, &fitsValue); statusBar()->insertPermanentWidget(FITS_POSITION, &fitsPosition); statusBar()->insertPermanentWidget(FITS_ZOOM, &fitsZoom); statusBar()->insertPermanentWidget(FITS_RESOLUTION, &fitsResolution); statusBar()->insertPermanentWidget(FITS_LED, &led); QAction *action; action = actionCollection()->addAction("rotate_right", this, SLOT(rotateCW())); action->setText(i18n("Rotate Right")); action->setIcon(QIcon::fromTheme("object-rotate-right", QIcon(":/icons/breeze/default/object-rotate-right.svg"))); action = actionCollection()->addAction("rotate_left", this, SLOT(rotateCCW())); action->setText(i18n("Rotate Left")); action->setIcon(QIcon::fromTheme("object-rotate-left", QIcon(":/icons/breeze/default/object-rotate-left.svg"))); action = actionCollection()->addAction("flip_horizontal", this, SLOT(flipHorizontal())); action->setText(i18n("Flip Horizontal")); action->setIcon(QIcon::fromTheme("object-flip-horizontal", QIcon(":/icons/breeze/default/object-flip-horizontal.svg"))); action = actionCollection()->addAction("flip_vertical", this, SLOT(flipVertical())); action->setText(i18n("Flip Vertical")); action->setIcon(QIcon::fromTheme("object-flip-vertical", QIcon(":/icons/breeze/default/object-flip-vertical.svg"))); action = actionCollection()->addAction("image_histogram"); action->setText(i18n("Histogram")); connect(action, SIGNAL(triggered(bool)), SLOT (histoFITS())); actionCollection()->setDefaultShortcut(action, QKeySequence::Replace); action->setIcon(QIcon(":/icons/histogram.png")); action = KStandardAction::open(this, SLOT(openFile()), actionCollection()); action->setIcon(QIcon::fromTheme("document-open", QIcon(":/icons/breeze/default/document-open.svg"))); saveFileAction = KStandardAction::save(this, SLOT(saveFile()), actionCollection()); saveFileAction->setIcon(QIcon::fromTheme("document-save", QIcon(":/icons/breeze/default/document-save.svg"))); action=saveFileAsAction = KStandardAction::saveAs(this, SLOT(saveFileAs()), actionCollection()); saveFileAsAction->setIcon(QIcon::fromTheme("document-save_as", QIcon(":/icons/breeze/default/document-save-as.svg"))); action = actionCollection()->addAction("fits_header"); actionCollection()->setDefaultShortcut(action, QKeySequence(Qt::CTRL+Qt::Key_H)); action->setIcon(QIcon::fromTheme("document-properties", QIcon(":/icons/breeze/default/document-properties.svg"))); action->setText(i18n( "FITS Header")); connect(action, SIGNAL(triggered(bool) ), SLOT(headerFITS())); action = actionCollection()->addAction("fits_debayer"); actionCollection()->setDefaultShortcut(action, QKeySequence(Qt::CTRL+Qt::Key_D)); action->setIcon(QIcon::fromTheme("view-preview", QIcon(":/icons/breeze/default/view-preview.svg"))); action->setText(i18n( "Debayer...")); connect(action, SIGNAL(triggered(bool) ), SLOT(debayerFITS())); action = actionCollection()->addAction("image_stretch"); action->setText(i18n("Auto stretch")); connect(action, SIGNAL(triggered(bool)), SLOT (stretchFITS())); actionCollection()->setDefaultShortcut(action, QKeySequence::SelectAll); action->setIcon(QIcon::fromTheme("transform-move", QIcon(":/icons/breeze/default/transform-move.svg"))); action = KStandardAction::close(this, SLOT(close()), actionCollection()); action->setIcon(QIcon::fromTheme("window-close", QIcon(":/icons/breeze/default/window-close.svg"))); action = KStandardAction::copy(this, SLOT(copyFITS()), actionCollection()); action->setIcon(QIcon::fromTheme("edit-copy", QIcon(":/icons/breeze/default/edit-copy.svg"))); action=KStandardAction::zoomIn(this, SLOT(ZoomIn()), actionCollection()); action->setIcon(QIcon::fromTheme("zoom-in", QIcon(":/icons/breeze/default/zoom-in.svg"))); action=KStandardAction::zoomOut(this, SLOT(ZoomOut()), actionCollection()); action->setIcon(QIcon::fromTheme("zoom-out", QIcon(":/icons/breeze/default/zoom-out.svg"))); action=KStandardAction::actualSize(this, SLOT(ZoomDefault()), actionCollection()); action->setIcon(QIcon::fromTheme("zoom-fit-best", QIcon(":/icons/breeze/default/zoom-fit-best.svg"))); QAction *kundo = KStandardAction::undo(undoGroup, SLOT(undo()), actionCollection()); kundo->setIcon(QIcon::fromTheme("edit-undo", QIcon(":/icons/breeze/default/edit-undo.svg"))); QAction *kredo = KStandardAction::redo(undoGroup, SLOT(redo()), actionCollection()); kredo->setIcon(QIcon::fromTheme("edit-redo", QIcon(":/icons/breeze/default/edit-redo.svg"))); connect(undoGroup, SIGNAL(canUndoChanged(bool)), kundo, SLOT(setEnabled(bool))); connect(undoGroup, SIGNAL(canRedoChanged(bool)), kredo, SLOT(setEnabled(bool))); action = actionCollection()->addAction("image_stats"); action->setIcon(QIcon::fromTheme("view-statistics", QIcon(":/icons/breeze/default/view-statistics.svg"))); action->setText(i18n( "Statistics")); connect(action, SIGNAL(triggered(bool)), SLOT(statFITS())); action = actionCollection()->addAction("view_crosshair"); action->setIcon(QIcon::fromTheme("crosshairs", QIcon(":/icons/breeze/default/crosshairs.svg"))); action->setText(i18n( "Show Cross Hairs")); action->setCheckable(true); connect(action, SIGNAL(triggered(bool)), SLOT(toggleCrossHair())); action = actionCollection()->addAction("view_pixel_grid"); action->setIcon(QIcon::fromTheme("map-flat", QIcon(":/icons/breeze/default/map-flat.svg"))); action->setText(i18n( "Show Pixel Gridlines")); action->setCheckable(true); connect(action, SIGNAL(triggered(bool)), SLOT(togglePixelGrid())); action = actionCollection()->addAction("view_eq_grid"); action->setIcon(QIcon::fromTheme("kstars_grid", QIcon(":/icons/breeze/default/kstars_grid.svg"))); action->setText(i18n( "Show Equatorial Gridlines")); action->setCheckable(true); action->setDisabled(true); connect(action, SIGNAL(triggered(bool)), SLOT(toggleEQGrid())); action = actionCollection()->addAction("view_objects"); action->setIcon(QIcon::fromTheme("help-hint", QIcon(":/icons/breeze/default/help-hint.svg"))); action->setText(i18n( "Show Objects in Image")); action->setCheckable(true); action->setDisabled(true); connect(action, SIGNAL(triggered(bool)), SLOT(toggleObjects())); action = actionCollection()->addAction("center_telescope"); action->setIcon(QIcon(":/icons/center_telescope.svg")); action->setText(i18n( "Center Telescope\n*No Telescopes Detected*")); action->setDisabled(true); action->setCheckable(true); connect(action, SIGNAL(triggered(bool)), SLOT(centerTelescope())); action = actionCollection()->addAction("view_zoom_fit"); action->setIcon(QIcon::fromTheme("zoom-fit-width", QIcon(":/icons/breeze/default/zoom-fit-width.svg"))); action->setText(i18n( "Zoom To Fit")); connect(action, SIGNAL(triggered(bool)), SLOT(ZoomToFit())); action = actionCollection()->addAction("mark_stars"); action->setText(i18n( "Mark Stars")); connect(action, SIGNAL(triggered(bool)), SLOT(toggleStars())); QSignalMapper *filterMapper = new QSignalMapper(this); int filterCounter=1; foreach(QString filter, FITSViewer::filterTypes) { action = actionCollection()->addAction(QString("filter%1").arg(filterCounter)); action->setText(i18n(filter.toUtf8().constData())); filterMapper->setMapping(action, filterCounter++); connect(action, SIGNAL(triggered()), filterMapper, SLOT(map())); }
void LorrisProgrammer::initMenus() { // top menu bar QMenu *chipBar = new QMenu(tr("Chip"), this); addTopMenu(chipBar); m_start_act = chipBar->addAction(QIcon(":/actions/start"), tr("Start chip")); m_stop_act = chipBar->addAction(QIcon(":/actions/stop"), tr("Stop chip")); m_restart_act = chipBar->addAction(QIcon(":/actions/refresh"), tr("Restart chip")); m_start_act->setEnabled(false); m_stop_act->setEnabled(false); m_restart_act->setShortcut(QKeySequence("R")); m_restart_act->setShortcutContext(Qt::WidgetWithChildrenShortcut); m_restart_act->setEnabled(false); connect(m_start_act, SIGNAL(triggered()), SLOT(startChip())); connect(m_stop_act, SIGNAL(triggered()), SLOT(stopChip())); connect(m_restart_act, SIGNAL(triggered()), SLOT(restartChip())); m_modeBar = new QMenu(tr("Mode"), this); addTopMenu(m_modeBar); QMenu *verifyMenu = m_modeBar->addMenu(tr("Verify write")); QSignalMapper *verifyMap = new QSignalMapper(this); for(quint8 i = 0; i < VERIFY_MAX; ++i) { static const QString verifyText[] = { tr("None"), tr("Verify only non-empty pages"), tr("Verify all") }; m_verify[i] = verifyMenu->addAction(verifyText[i]); m_verify[i]->setCheckable(true); verifyMap->setMapping(m_verify[i], i); connect(m_verify[i], SIGNAL(triggered()), verifyMap, SLOT(map())); } connect(verifyMap, SIGNAL(mapped(int)), SLOT(verifyChanged(int))); verifyChanged(sConfig.get(CFG_QUINT32_SHUPITO_VERIFY)); m_set_tunnel_name_act = m_modeBar->addAction(tr("Set RS232 tunnel name...")); m_set_tunnel_name_act->setVisible(false); connect(m_set_tunnel_name_act, SIGNAL(triggered()), SLOT(setTunnelName())); m_enableHardwareButton = m_modeBar->addAction(tr("Enable hardware button")); m_enableHardwareButton->setCheckable(true); m_enableHardwareButton->setChecked(sConfig.get(CFG_BOOL_SHUPITO_ENABLE_HW_BUTTON)); connect(m_enableHardwareButton, SIGNAL(toggled(bool)), this, SLOT(enableHardwareButtonToggled(bool))); m_load_flash = new QAction(QIcon(":/actions/open"), tr("Load..."), this); m_load_flash->setShortcut(QKeySequence("Ctrl+O")); m_load_flash->setShortcutContext(Qt::WidgetWithChildrenShortcut); connect(m_load_flash, SIGNAL(triggered()), this, SLOT(loadFromFile())); addTopAction(m_load_flash); m_save_flash = new QAction(QIcon(":/actions/save"), tr("Save..."), this); m_save_flash->setShortcut(QKeySequence("Ctrl+S")); m_save_flash->setShortcutContext(Qt::WidgetWithChildrenShortcut); connect(m_save_flash, SIGNAL(triggered()), this, SLOT(saveToFile())); addTopAction(m_save_flash); m_blink_led = new QAction(tr("Blink LED"), this); m_blink_led->setEnabled(false); connect(m_blink_led, SIGNAL(triggered()), this, SLOT(blinkLed())); addTopAction(m_blink_led); m_miniUi = new QAction(tr("Minimal UI"), this); m_miniUi->setCheckable(true); addTopAction(m_miniUi); connect(m_miniUi, SIGNAL(triggered(bool)), SLOT(setMiniUi(bool))); }
Calendar::Calendar() { eventListCounter = 0; loadEvents(); actualDate = new QDate; *actualDate = QDate::currentDate(); //get's information about current date and sets proper label int actualDay, actualMonth, actualYear; actualDate->getDate(&actualDay, &actualMonth, &actualYear); // essential variables initialization actualDate->getDate(&year,&month,&day); QDate dayOfWeek(year,month,1); //gets information about first day of selected month and year whatDay = dayOfWeek.dayOfWeek(); // end of essential variables initialization actualWeek = actualDate->weekNumber(); // future note: array are better than days[0], days[1], days[2]... :P days = new Day*[7]; days[0] = new Day("Monday"); days[1] = new Day("Tuesday"); days[2] = new Day("Wednesday"); days[3] = new Day("Thursday"); days[4] = new Day("Friday"); days[5] = new Day("Saturday"); days[6] = new Day("Sunday"); daysLayout = new QHBoxLayout; navigationLayout = new QHBoxLayout; // horizontal layout for navigation elements // creating elements for navigation box navigationLeft = new QPushButton("<<"); navigationRight = new QPushButton(">>"); dateLabel = new QLabel(); // QLabel initialization navigationLayout->addWidget(navigationLeft); navigationLayout->addWidget(dateLabel); navigationLayout->addWidget(navigationRight); mainLayout = new QVBoxLayout; // vertical layout for navigation and days boxes mainLayout->addLayout(navigationLayout); mainLayout->addLayout(daysLayout); this->setLayout(mainLayout); QString initialDateLabel = dateToString(actualYear, actualMonth, actualDay); dateLabel->setText("<center>" + initialDateLabel + "</center>"); sortButtons(); connect(navigationLeft,SIGNAL(pressed()),this,SLOT(navigationLeftClicked())); //connects navigation buttons with action (changing day's range or month) connect(navigationRight,SIGNAL(pressed()),this,SLOT(navigationRightClicked())); /* Signal mapper is used to send parameter to slot method. The parameter here is * integer which reprenets offset of certain days of week. */ QSignalMapper* signalMapper = new QSignalMapper(this); // signal mapping is needed to parametrize slot :( connect(days[0], SIGNAL(pressed()), signalMapper, SLOT(map())); connect(days[1], SIGNAL(pressed()), signalMapper, SLOT(map())); connect(days[2], SIGNAL(pressed()), signalMapper, SLOT(map())); connect(days[3], SIGNAL(pressed()), signalMapper, SLOT(map())); connect(days[4], SIGNAL(pressed()), signalMapper, SLOT(map())); connect(days[5], SIGNAL(pressed()), signalMapper, SLOT(map())); connect(days[6], SIGNAL(pressed()), signalMapper, SLOT(map())); signalMapper->setMapping(days[0], 0); signalMapper->setMapping(days[1], 1); signalMapper->setMapping(days[2], 2); signalMapper->setMapping(days[3], 3); signalMapper->setMapping(days[4], 4); signalMapper->setMapping(days[5], 5); signalMapper->setMapping(days[6], 6); connect(signalMapper, SIGNAL(mapped(int)), this, SLOT(scheduleDay(int))); colorTask(); }
MotorDials::MotorDials(RosWorker* rosWorker, QWidget* parent) : mRosWorker(rosWorker), QWidget(parent), mSelectedMotor(-1) { setWindowTitle("Motor Position Dials"); QGridLayout* mainGridLayout = new QGridLayout; QSignalMapper* signalMapper = new QSignalMapper(this); groupBoxes.resize(NUM_OF_MOTORS); QVector<QGridLayout*> gridLayouts; gridLayouts.resize(NUM_OF_MOTORS); dials.resize(NUM_OF_MOTORS); presentPosLineEdits.resize(NUM_OF_MOTORS); presentSpeedLineEdits.resize(NUM_OF_MOTORS); int row; int col; for (int i = 0; i < NUM_OF_MOTORS; ++i) { groupBoxes[i] = new QGroupBox("Motor " + QString::number(i + 1)); gridLayouts[i] = new QGridLayout; dials[i] = new QDial; dials[i]->setMinimum(-2606); dials[i]->setMaximum(2606); dials[i]->setWrapping(false); dials[i]->setNotchesVisible(true); //dials[i]->setNotchTarget(10); std::ostringstream oss; oss.precision(4); oss.width(8); oss.fill(' '); oss.setf(std::ios::fixed, std::ios::floatfield); oss << 0.0; QString str = QString::fromStdString(oss.str()); presentPosLineEdits[i] = new QLineEdit(str); presentSpeedLineEdits[i] = new QLineEdit(str); connect( dials[i], SIGNAL(valueChanged(int)), signalMapper, SLOT(map()) ); connect( dials[i], SIGNAL(valueChanged(int)), this, SLOT(setValue(int)) ); signalMapper->setMapping(dials[i], i + 1); QLabel* presentPosLabel = new QLabel("Position:"); QLabel* goalPosLabel = new QLabel("Speed:"); row = 0; col = 0; gridLayouts[i]->addWidget(dials[i], row++, col, 1, -1, Qt::AlignCenter); gridLayouts[i]->addWidget(presentPosLabel, row, col++, 1, 1, Qt::AlignCenter); gridLayouts[i]->addWidget(goalPosLabel, row++, col--, 1, 1, Qt::AlignCenter); gridLayouts[i]->addWidget(presentPosLineEdits[i], row, col++, 1, 1, Qt::AlignCenter); gridLayouts[i]->addWidget(presentSpeedLineEdits[i], row, col--, 1, 1, Qt::AlignCenter); groupBoxes[i]->setLayout(gridLayouts[i]); int gridCols = 6; row = i / gridCols; col = i % gridCols; mainGridLayout->addWidget(groupBoxes[i], row, col); } setLayout(mainGridLayout); customiseLayout(); callTime.start(); connect( signalMapper, SIGNAL(mapped(int)), this, SLOT(setMotor(int)) ); connect( mRosWorker, SIGNAL(jointStateUpdated(sensor_msgs::JointState)), this, SLOT(updateJointStateValues(sensor_msgs::JointState)) ); }
TemplatesInsertCommand::TemplatesInsertCommand( QWidget *parent, const char *name ) : QPushButton( parent, name ) { setText( i18n( "&Insert Command..." ) ); connect( this, SIGNAL( clicked() ), this, SLOT( slotClicked() ) ); KAction *action; KActionMenu *menu; QSignalMapper *mapper = new QSignalMapper( this ); connect( mapper, SIGNAL( mapped(int) ), this, SLOT( slotMapped(int) ) ); mMenu = new KActionMenu( i18n( "Insert Command..." ), this ); // ****************************************************** menu = new KActionMenu( i18n( "Original Message" ), mMenu ); mMenu->insert( menu ); action = new KAction( i18n("Quoted Message"), 0, mapper, SLOT( map() ), menu ); mapper->setMapping( action, CQuote ); menu->insert( action ); action = new KAction( i18n("Message Text as Is"), 0, mapper, SLOT( map() ), menu ); mapper->setMapping( action, CText ); menu->insert( action ); action = new KAction( i18n("Message Id"), 0, mapper, SLOT( map() ), menu ); mapper->setMapping( action, COMsgId ); menu->insert( action ); action = new KAction( i18n("Date"), 0, mapper, SLOT( map() ), menu ); mapper->setMapping( action, CODate ); menu->insert( action ); action = new KAction( i18n("Date in Short Format"), 0, mapper, SLOT( map() ), menu ); mapper->setMapping( action, CODateShort ); menu->insert( action ); action = new KAction( i18n("Date in C Locale"), 0, mapper, SLOT( map() ), menu ); mapper->setMapping( action, CODateEn ); menu->insert( action ); action = new KAction( i18n("Day of Week"), 0, mapper, SLOT( map() ), menu ); mapper->setMapping( action, CODow ); menu->insert( action ); action = new KAction( i18n("Time"), 0, mapper, SLOT( map() ), menu ); mapper->setMapping( action, COTime ); menu->insert( action ); action = new KAction( i18n("Time in Long Format"), 0, mapper, SLOT( map() ), menu ); mapper->setMapping( action, COTimeLong ); menu->insert( action ); action = new KAction( i18n("Time in C Locale"), 0, mapper, SLOT( map() ), menu ); mapper->setMapping( action, COTimeLongEn ); menu->insert( action ); action = new KAction( i18n("To Field Address"), 0, mapper, SLOT( map() ), menu ); mapper->setMapping( action, COToAddr ); menu->insert( action ); action = new KAction( i18n("To Field Name"), 0, mapper, SLOT( map() ), menu ); mapper->setMapping( action, COToName ); menu->insert( action ); action = new KAction( i18n("To Field First Name"), 0, mapper, SLOT( map() ), menu ); mapper->setMapping( action, COToFName ); menu->insert( action ); action = new KAction( i18n("To Field Last Name"), 0, mapper, SLOT( map() ), menu ); mapper->setMapping( action, COToLName ); menu->insert( action ); action = new KAction( i18n( "CC Field Address" ), 0, mapper, SLOT( map() ), menu ); mapper->setMapping( action, COCCAddr ); menu->insert( action ); action = new KAction( i18n( "CC Field Name" ), 0, mapper, SLOT( map() ), menu ); mapper->setMapping( action, COCCName ); menu->insert( action ); action = new KAction( i18n( "CC Field First Name" ), 0, mapper, SLOT( map() ), menu ); mapper->setMapping( action, COCCFName ); menu->insert( action ); action = new KAction( i18n( "CC Field Last Name" ), 0, mapper, SLOT( map() ), menu ); mapper->setMapping( action, COCCLName ); menu->insert( action ); action = new KAction( i18n( "From Field Address" ), 0, mapper, SLOT( map() ), menu ); mapper->setMapping( action, COFromAddr ); menu->insert( action ); action = new KAction( i18n( "From Field Name" ), 0, mapper, SLOT( map() ), menu ); mapper->setMapping( action, COFromName ); menu->insert( action ); action = new KAction( i18n( "From Field First Name" ), 0, mapper, SLOT( map() ), menu ); mapper->setMapping( action, COFromFName ); menu->insert( action ); action = new KAction( i18n( "From Field Last Name" ), 0, mapper, SLOT( map() ), menu ); mapper->setMapping( action, COFromLName ); menu->insert( action ); action = new KAction( i18n( "Subject" ), 0, mapper, SLOT( map() ), menu ); mapper->setMapping( action, COFullSubject ); menu->insert( action ); action = new KAction( i18n( "Quoted Headers" ), 0, mapper, SLOT( map() ), menu ); mapper->setMapping( action, CQHeaders ); menu->insert( action ); action = new KAction( i18n( "Headers as Is" ), 0, mapper, SLOT( map() ), menu ); mapper->setMapping( action, CHeaders ); menu->insert( action ); action = new KAction( i18n( "Header Content" ), 0, mapper, SLOT( map() ), menu ); mapper->setMapping( action, COHeader ); menu->insert( action ); // ****************************************************** menu = new KActionMenu( i18n( "Current Message" ), mMenu ); mMenu->insert( menu ); action = new KAction( i18n( "Message Id" ), 0, mapper, SLOT( map() ), menu ); mapper->setMapping( action, CMsgId ); menu->insert( action ); action = new KAction( i18n( "Date" ), 0, mapper, SLOT( map() ), menu ); mapper->setMapping( action, CDate ); menu->insert( action ); action = new KAction( i18n( "Date in Short Format" ), 0, mapper, SLOT( map() ), menu ); mapper->setMapping( action, CDateShort ); menu->insert( action ); action = new KAction( i18n( "Date in C Locale" ), 0, mapper, SLOT( map() ), menu ); mapper->setMapping( action, CDateEn ); menu->insert( action ); action = new KAction( i18n( "Day of Week" ), 0, mapper, SLOT( map() ), menu ); mapper->setMapping( action, CDow ); menu->insert( action ); action = new KAction( i18n( "Time" ), 0, mapper, SLOT( map() ), menu ); mapper->setMapping( action, CTime ); menu->insert( action ); action = new KAction( i18n( "Time in Long Format" ), 0, mapper, SLOT( map() ), menu ); mapper->setMapping( action, CTimeLong ); menu->insert( action ); action = new KAction( i18n( "Time in C Locale" ), 0, mapper, SLOT( map() ), menu ); mapper->setMapping( action, CTimeLongEn ); menu->insert( action ); action = new KAction( i18n( "To Field Address" ), 0, mapper, SLOT( map() ), menu ); mapper->setMapping( action, CToAddr ); menu->insert( action ); action = new KAction( i18n( "To Field Name" ), 0, mapper, SLOT( map() ), menu ); mapper->setMapping( action, CToName ); menu->insert( action ); action = new KAction( i18n( "To Field First Name" ), 0, mapper, SLOT( map() ), menu ); mapper->setMapping( action, CToFName ); menu->insert( action ); action = new KAction( i18n( "To Field Last Name" ), 0, mapper, SLOT( map() ), menu ); mapper->setMapping( action, CToLName ); menu->insert( action ); action = new KAction( i18n( "CC Field Address" ), 0, mapper, SLOT( map() ), menu ); mapper->setMapping( action, CCCAddr ); menu->insert( action ); action = new KAction( i18n( "CC Field Name" ), 0, mapper, SLOT( map() ), menu ); mapper->setMapping( action, CCCName ); menu->insert( action ); action = new KAction( i18n( "CC Field First Name" ), 0, mapper, SLOT( map() ), menu ); mapper->setMapping( action, CCCFName ); menu->insert( action ); action = new KAction( i18n( "CC Field Last Name" ), 0, mapper, SLOT( map() ), menu ); mapper->setMapping( action, CCCLName ); menu->insert( action ); action = new KAction( i18n( "From Field Address" ), 0, mapper, SLOT( map() ), menu ); mapper->setMapping( action, CFromAddr ); menu->insert( action ); action = new KAction( i18n( "From Field Name" ), 0, mapper, SLOT( map() ), menu ); mapper->setMapping( action, CFromName ); menu->insert( action ); action = new KAction( i18n( "From Field First Name" ), 0, mapper, SLOT( map() ), menu ); mapper->setMapping( action, CFromFName ); menu->insert( action ); action = new KAction( i18n( "From Field Last Name" ), 0, mapper, SLOT( map() ), menu ); mapper->setMapping( action, CFromLName ); menu->insert( action ); action = new KAction( i18n( "Subject" ), 0, mapper, SLOT( map() ), menu ); mapper->setMapping( action, CFullSubject ); menu->insert( action ); action = new KAction( i18n( "Header Content" ), 0, mapper, SLOT( map() ), menu ); mapper->setMapping( action, CHeader ); menu->insert( action ); // ****************************************************** menu = new KActionMenu( i18n( "Process With External Programs" ), mMenu ); mMenu->insert( menu ); action = new KAction( i18n( "Insert Result of Command" ), 0, mapper, SLOT( map() ), menu ); mapper->setMapping( action, CSystem ); menu->insert( action ); action = new KAction( i18n( "Pipe Original Message Body and Insert Result as Quoted Text" ), 0, mapper, SLOT( map() ), menu ); mapper->setMapping( action, CQuotePipe ); menu->insert( action ); action = new KAction( i18n( "Pipe Original Message Body and Insert Result as Is" ), 0, mapper, SLOT( map() ), menu ); mapper->setMapping( action, CTextPipe ); menu->insert( action ); action = new KAction( i18n( "Pipe Original Message with Headers and Insert Result as Is" ), 0, mapper, SLOT( map() ), menu ); mapper->setMapping( action, CMsgPipe ); menu->insert( action ); action = new KAction( i18n( "Pipe Current Message Body and Insert Result as Is" ), 0, mapper, SLOT( map() ), menu ); mapper->setMapping( action, CBodyPipe ); menu->insert( action ); action = new KAction( i18n( "Pipe Current Message Body and Replace with Result" ), 0, mapper, SLOT( map() ), menu ); mapper->setMapping( action, CClearPipe ); menu->insert( action ); // ****************************************************** menu = new KActionMenu( i18n( "Miscellaneous" ), mMenu ); mMenu->insert( menu ); action = new KAction( i18n( "Set Cursor Position" ), 0, mapper, SLOT( map() ), menu ); mapper->setMapping( action, CCursor ); menu->insert( action ); action = new KAction( i18n( "Insert File Content" ), 0, mapper, SLOT( map() ), menu ); mapper->setMapping( action, CInsert ); menu->insert( action ); action = new KAction( i18n( "DNL" ), 0, mapper, SLOT( map() ), menu ); mapper->setMapping( action, CDnl ); menu->insert( action ); action = new KAction( i18n( "Template Comment" ), 0, mapper, SLOT( map() ), menu ); mapper->setMapping( action, CRem ); menu->insert( action ); action = new KAction( i18n( "No Operation" ), 0, mapper, SLOT( map() ), menu ); mapper->setMapping( action, CNop ); menu->insert( action ); action = new KAction( i18n( "Clear Generated Message" ), 0, mapper, SLOT( map() ), menu ); mapper->setMapping( action, CClear ); menu->insert( action ); action = new KAction( i18n( "Turn Debug On" ), 0, mapper, SLOT( map() ), menu ); mapper->setMapping( action, CDebug ); menu->insert( action ); action = new KAction( i18n( "Turn Debug Off" ), 0, mapper, SLOT( map() ), menu ); mapper->setMapping( action, CDebugOff ); menu->insert( action ); }
void RPCConsole::setClientModel(ClientModel *model) { clientModel = model; ui->trafficGraph->setClientModel(model); if (model && clientModel->getPeerTableModel() && clientModel->getBanTableModel()) { // Keep up to date with client setNumConnections(model->getNumConnections()); connect(model, SIGNAL(numConnectionsChanged(int)), this, SLOT(setNumConnections(int))); setNumBlocks(model->getNumBlocks(), model->getLastBlockDate()); connect(model, SIGNAL(numBlocksChanged(int,QDateTime)), this, SLOT(setNumBlocks(int,QDateTime))); updateTrafficStats(model->getTotalBytesRecv(), model->getTotalBytesSent()); connect(model, SIGNAL(bytesChanged(quint64,quint64)), this, SLOT(updateTrafficStats(quint64, quint64))); // set up peer table ui->peerWidget->setModel(model->getPeerTableModel()); ui->peerWidget->verticalHeader()->hide(); ui->peerWidget->setEditTriggers(QAbstractItemView::NoEditTriggers); ui->peerWidget->setSelectionBehavior(QAbstractItemView::SelectRows); ui->peerWidget->setSelectionMode(QAbstractItemView::SingleSelection); ui->peerWidget->setContextMenuPolicy(Qt::CustomContextMenu); ui->peerWidget->setColumnWidth(PeerTableModel::Address, ADDRESS_COLUMN_WIDTH); ui->peerWidget->setColumnWidth(PeerTableModel::Subversion, SUBVERSION_COLUMN_WIDTH); ui->peerWidget->setColumnWidth(PeerTableModel::Ping, PING_COLUMN_WIDTH); ui->peerWidget->horizontalHeader()->setStretchLastSection(true); // create peer table context menu actions QAction* disconnectAction = new QAction(tr("&Disconnect Node"), this); QAction* banAction1h = new QAction(tr("Ban Node for") + " " + tr("1 &hour"), this); QAction* banAction24h = new QAction(tr("Ban Node for") + " " + tr("1 &day"), this); QAction* banAction7d = new QAction(tr("Ban Node for") + " " + tr("1 &week"), this); QAction* banAction365d = new QAction(tr("Ban Node for") + " " + tr("1 &year"), this); // create peer table context menu peersTableContextMenu = new QMenu(); peersTableContextMenu->addAction(disconnectAction); peersTableContextMenu->addAction(banAction1h); peersTableContextMenu->addAction(banAction24h); peersTableContextMenu->addAction(banAction7d); peersTableContextMenu->addAction(banAction365d); // Add a signal mapping to allow dynamic context menu arguments. // We need to use int (instead of int64_t), because signal mapper only supports // int or objects, which is okay because max bantime (1 year) is < int_max. QSignalMapper* signalMapper = new QSignalMapper(this); signalMapper->setMapping(banAction1h, 60*60); signalMapper->setMapping(banAction24h, 60*60*24); signalMapper->setMapping(banAction7d, 60*60*24*7); signalMapper->setMapping(banAction365d, 60*60*24*365); connect(banAction1h, SIGNAL(triggered()), signalMapper, SLOT(map())); connect(banAction24h, SIGNAL(triggered()), signalMapper, SLOT(map())); connect(banAction7d, SIGNAL(triggered()), signalMapper, SLOT(map())); connect(banAction365d, SIGNAL(triggered()), signalMapper, SLOT(map())); connect(signalMapper, SIGNAL(mapped(int)), this, SLOT(banSelectedNode(int))); // peer table context menu signals connect(ui->peerWidget, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(showPeersTableContextMenu(const QPoint&))); connect(disconnectAction, SIGNAL(triggered()), this, SLOT(disconnectSelectedNode())); // peer table signal handling - update peer details when selecting new node connect(ui->peerWidget->selectionModel(), SIGNAL(selectionChanged(const QItemSelection &, const QItemSelection &)), this, SLOT(peerSelected(const QItemSelection &, const QItemSelection &))); // peer table signal handling - update peer details when new nodes are added to the model connect(model->getPeerTableModel(), SIGNAL(layoutChanged()), this, SLOT(peerLayoutChanged())); // set up ban table ui->banlistWidget->setModel(model->getBanTableModel()); ui->banlistWidget->verticalHeader()->hide(); ui->banlistWidget->setEditTriggers(QAbstractItemView::NoEditTriggers); ui->banlistWidget->setSelectionBehavior(QAbstractItemView::SelectRows); ui->banlistWidget->setSelectionMode(QAbstractItemView::SingleSelection); ui->banlistWidget->setContextMenuPolicy(Qt::CustomContextMenu); ui->banlistWidget->setColumnWidth(BanTableModel::Address, BANSUBNET_COLUMN_WIDTH); ui->banlistWidget->setColumnWidth(BanTableModel::Bantime, BANTIME_COLUMN_WIDTH); ui->banlistWidget->horizontalHeader()->setStretchLastSection(true); // create ban table context menu action QAction* unbanAction = new QAction(tr("&Unban Node"), this); // create ban table context menu banTableContextMenu = new QMenu(); banTableContextMenu->addAction(unbanAction); // ban table context menu signals connect(ui->banlistWidget, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(showBanTableContextMenu(const QPoint&))); connect(unbanAction, SIGNAL(triggered()), this, SLOT(unbanSelectedNode())); // ban table signal handling - clear peer details when clicking a peer in the ban table connect(ui->banlistWidget, SIGNAL(clicked(const QModelIndex&)), this, SLOT(clearSelectedNode())); // ban table signal handling - ensure ban table is shown or hidden (if empty) connect(model->getBanTableModel(), SIGNAL(layoutChanged()), this, SLOT(showOrHideBanTableIfRequired())); showOrHideBanTableIfRequired(); // Provide initial values ui->clientVersion->setText(model->formatFullVersion()); ui->clientUserAgent->setText(model->formatSubVersion()); ui->clientName->setText(model->clientName()); ui->buildDate->setText(model->formatBuildDate()); ui->startupTime->setText(model->formatClientStartupTime()); ui->networkName->setText(QString::fromStdString(Params().NetworkIDString())); }
// build a context menu void UserMenuTree::contextMenuRequested(const QPoint &pos) { KILE_DEBUG() << "context menu requested ..." ; m_popupItem = dynamic_cast<UserMenuItem*>(itemAt(pos)); if ( !m_popupItem ) { KILE_DEBUG() << "... no item found"; return; } KILE_DEBUG() << "... popup item found: " << m_popupItem->text(0); bool submenu = ( m_popupItem->menutype() == UserMenuData::Submenu ); bool separator = ( m_popupItem->menutype() == UserMenuData::Separator ); KMenu popup; QAction *action = NULL; QSignalMapper signalMapper; connect(&signalMapper, SIGNAL(mapped(int)), this, SLOT(slotPopupActivated(int))); // insert standard menu items action = popup.addAction(KIcon("usermenu-insert-above.png"),i18n("Insert above"), &signalMapper, SLOT(map())); signalMapper.setMapping(action, POPUP_INSERT_ABOVE); action = popup.addAction(KIcon("usermenu-insert-below.png"),i18n("Insert below"), &signalMapper, SLOT(map())); signalMapper.setMapping(action, POPUP_INSERT_BELOW); popup.addSeparator(); // insert separators if ( !separator ) { action = popup.addAction(KIcon("usermenu-separator-above.png"),i18n("Insert a separator above"), &signalMapper, SLOT(map())); signalMapper.setMapping(action, POPUP_SEPARATOR_ABOVE); action = popup.addAction(KIcon("usermenu-separator-below.png"),i18n("Insert a separator below"), &signalMapper, SLOT(map())); signalMapper.setMapping(action, POPUP_SEPARATOR_BELOW); popup.addSeparator(); } // insert submenus action = popup.addAction(KIcon("usermenu-submenu-above.png"),i18n("Insert a submenu above"), &signalMapper, SLOT(map())); signalMapper.setMapping(action, POPUP_SUBMENU_ABOVE); action = popup.addAction(KIcon("usermenu-submenu-below.png"),i18n("Insert a submenu below"), &signalMapper, SLOT(map())); signalMapper.setMapping(action, POPUP_SUBMENU_BELOW); popup.addSeparator(); // insert into submenus if ( submenu ) { action = popup.addAction(KIcon("usermenu-into-submenu.png"),i18n("Insert into this submenu"), &signalMapper, SLOT(map())); signalMapper.setMapping(action, POPUP_INTO_SUBMENU); action = popup.addAction(i18n("Insert a separator into this submenu"), &signalMapper, SLOT(map())); signalMapper.setMapping(action, POPUP_SEPARATOR_INTO_SUBMENU); action = popup.addAction(i18n("Insert a submenu into this submenu"), &signalMapper, SLOT(map())); signalMapper.setMapping(action, POPUP_SUBMENU_INTO_SUBMENU); popup.addSeparator(); } // delete actions action = popup.addAction(KIcon("usermenu-delete.png"),i18n("Delete this item"), &signalMapper, SLOT(map())); signalMapper.setMapping(action,POPUP_DELETE_ITEM); popup.addSeparator(); action = popup.addAction(KIcon("usermenu-clear.png"),i18n("Delete the complete tree"), &signalMapper, SLOT(map())); signalMapper.setMapping(action, POPUP_DELETE_TREE); // expand/collapse tree if ( submenu ) { popup.addSeparator(); if ( m_popupItem->isExpanded() ) { action = popup.addAction(i18n("Collapse submenu"), &signalMapper, SLOT(map())); signalMapper.setMapping(action,POPUP_COLLAPSE_ITEM); } else { action = popup.addAction(i18n("Expand submenu"), &signalMapper, SLOT(map())); signalMapper.setMapping(action,POPUP_EXPAND_ITEM); } popup.addSeparator(); action = popup.addAction(i18n("Collapse complete tree"), &signalMapper, SLOT(map())); signalMapper.setMapping(action,POPUP_COLLAPSE_TREE); action = popup.addAction(i18n("Expand complete tree"), &signalMapper, SLOT(map())); signalMapper.setMapping(action,POPUP_EXPAND_TREE); } // if there are any errors with this item, some info is available int error = m_popupItem->data(0,Qt::UserRole+2).toInt(); if ( error != UserMenuItem::MODEL_ERROR_NONE ) { popup.addSeparator(); action = popup.addAction(KIcon("help-about.png"),i18n("Info"), &signalMapper, SLOT(map())); signalMapper.setMapping(action, POPUP_ITEM_INFO); } // const QPoint& pos parameter in the customContextMenuRequested() signal is normally in widget coordinates. // But classes like QTreeWidget, which inherit from QAbstractScrollArea1 instead use the coordinates of their viewport() if ( !popup.isEmpty() ) { popup.exec( viewport()->mapToGlobal(pos) ); } }
LMaster::LMaster(QWidget* parent, const char* name) : MidiEditor(TopWin::LMASTER, 0, 0, parent, name) { pos_editor = 0; tempo_editor = 0; sig_editor = 0; key_editor = 0; editedItem = 0; editingNewItem = false; setWindowTitle(tr("MusE: Mastertrack")); setMinimumHeight(100); //setFixedWidth(400); // FIXME: Arbitrary. But without this, sig editor is too wide. Must fix sig editor width... setFocusPolicy(Qt::NoFocus); comboboxTimer=new QTimer(this); comboboxTimer->setInterval(150); comboboxTimer->setSingleShot(true); connect(comboboxTimer, SIGNAL(timeout()), this, SLOT(comboboxTimerSlot())); //---------Pulldown Menu---------------------------- menuEdit = menuBar()->addMenu(tr("&Edit")); QSignalMapper *signalMapper = new QSignalMapper(this); menuEdit->addActions(MusEGlobal::undoRedo->actions()); menuEdit->addSeparator(); tempoAction = menuEdit->addAction(tr("Insert Tempo")); signAction = menuEdit->addAction(tr("Insert Signature")); keyAction = menuEdit->addAction(tr("Insert Key")); posAction = menuEdit->addAction(tr("Edit Position")); valAction = menuEdit->addAction(tr("Edit Value")); delAction = menuEdit->addAction(tr("Delete Event")); delAction->setShortcut(Qt::Key_Delete); QMenu* settingsMenu = menuBar()->addMenu(tr("Window &Config")); settingsMenu->addAction(subwinAction); settingsMenu->addAction(shareAction); settingsMenu->addAction(fullscreenAction); connect(tempoAction, SIGNAL(triggered()), signalMapper, SLOT(map())); connect(signAction, SIGNAL(triggered()), signalMapper, SLOT(map())); connect(keyAction, SIGNAL(triggered()), signalMapper, SLOT(map())); connect(posAction, SIGNAL(triggered()), signalMapper, SLOT(map())); connect(valAction, SIGNAL(triggered()), signalMapper, SLOT(map())); connect(delAction, SIGNAL(triggered()), signalMapper, SLOT(map())); signalMapper->setMapping(tempoAction, CMD_INSERT_TEMPO); signalMapper->setMapping(signAction, CMD_INSERT_SIG); signalMapper->setMapping(keyAction, CMD_INSERT_KEY); signalMapper->setMapping(posAction, CMD_EDIT_BEAT); signalMapper->setMapping(valAction, CMD_EDIT_VALUE); signalMapper->setMapping(delAction, CMD_DELETE); connect(signalMapper, SIGNAL(mapped(int)), SLOT(cmd(int))); // Toolbars --------------------------------------------------------- // NOTICE: Please ensure that any tool bar object names here match the names assigned // to identical or similar toolbars in class MusE or other TopWin classes. // This allows MusE::setCurrentMenuSharingTopwin() to do some magic // to retain the original toolbar layout. If it finds an existing // toolbar with the same object name, it /replaces/ it using insertToolBar(), // instead of /appending/ with addToolBar(). addToolBarBreak(); QToolBar* edit = addToolBar(tr("Edit tools")); edit->setObjectName("Master List Edit Tools"); QToolButton* tempoButton = new QToolButton(); QToolButton* timeSigButton = new QToolButton(); QToolButton* keyButton = new QToolButton(); tempoButton->setFocusPolicy(Qt::NoFocus); timeSigButton->setFocusPolicy(Qt::NoFocus); keyButton->setFocusPolicy(Qt::NoFocus); tempoButton->setText(tr("Tempo")); timeSigButton->setText(tr("Timesig")); keyButton->setText(tr("Key")); tempoButton->setToolTip(tr("new tempo")); timeSigButton->setToolTip(tr("new signature")); keyButton->setToolTip(tr("new key")); edit->addWidget(tempoButton); edit->addWidget(timeSigButton); edit->addWidget(keyButton); //--------------------------------------------------- // master //--------------------------------------------------- view = new QTreeWidget; view->setAllColumnsShowFocus(true); view->setSelectionMode(QAbstractItemView::SingleSelection); QStringList columnnames; columnnames << tr("Meter") << tr("Time") << tr("Type") << tr("Value"); view->setHeaderLabels(columnnames); view->setColumnWidth(2,80); view->header()->setStretchLastSection(true); //--------------------------------------------------- // Rest //--------------------------------------------------- mainGrid->setRowStretch(0, 100); mainGrid->setColumnStretch(0, 100); mainGrid->addWidget(view, 0, 0); updateList(); tempo_editor = new QLineEdit(view->viewport()); tempo_editor->setFrame(false); tempo_editor->hide(); connect(tempo_editor, SIGNAL(returnPressed()), SLOT(returnPressed())); sig_editor = new SigEdit(view->viewport()); sig_editor->setFrame(false); sig_editor->hide(); connect(sig_editor, SIGNAL(returnPressed()), SLOT(returnPressed())); pos_editor = new PosEdit(view->viewport()); pos_editor->setFrame(false); pos_editor->hide(); connect(pos_editor, SIGNAL(returnPressed()), SLOT(returnPressed())); key_editor = new QComboBox(view->viewport()); key_editor->setFrame(false); key_editor->addItems(MusECore::keyStrs); key_editor->hide(); connect(key_editor, SIGNAL(activated(int)), SLOT(returnPressed())); connect(view, SIGNAL(currentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*)), SLOT(select(QTreeWidgetItem*, QTreeWidgetItem*))); connect(view, SIGNAL(itemPressed(QTreeWidgetItem*, int)), SLOT(itemPressed(QTreeWidgetItem*, int))); connect(view, SIGNAL(itemDoubleClicked(QTreeWidgetItem*, int)), SLOT(itemDoubleClicked(QTreeWidgetItem*))); connect(MusEGlobal::song, SIGNAL(songChanged(MusECore::SongChangedStruct_t)), SLOT(songChanged(MusECore::SongChangedStruct_t))); connect(this, SIGNAL(seekTo(int)), MusEGlobal::song, SLOT(seekTo(int))); connect(tempoButton, SIGNAL(clicked()), SLOT(tempoButtonClicked())); connect(timeSigButton, SIGNAL(clicked()), SLOT(timeSigButtonClicked())); connect(keyButton, SIGNAL(clicked()), SLOT(insertKey())); initShortcuts(); finalizeInit(); }
//////////////////////////////////////////////////////////////////////////////// // Methods inherited from the StelModule class // init(), update(), draw(), getCallOrder() void TelescopeControl::init() { //TODO: I think I've overdone the try/catch... try { //Main configuration loadConfiguration(); //Make sure that such a section is created, if it doesn't exist saveConfiguration(); //Make sure that the module directory exists QString moduleDirectoryPath = StelFileMgr::getUserDir() + "/modules/TelescopeControl"; if(!StelFileMgr::exists(moduleDirectoryPath)) StelFileMgr::mkDir(moduleDirectoryPath); //Load the device models loadDeviceModels(); if(deviceModels.isEmpty()) { qWarning() << "[TelescopeControl] No device model descriptions have been loaded. Stellarium will not be able to control a telescope on its own, but it is still possible to do it through an external application or to connect to a remote host."; } //Unload Stellarium's internal telescope control module //(not necessary since revision 6308; remains as an example) //StelApp::getInstance().getModuleMgr().unloadModule("TelescopeMgr", false); /*If the alsoDelete parameter is set to true, Stellarium crashes with a segmentation fault when an object is selected. TODO: Find out why. unloadModule() didn't work prior to revision 5058: the module unloaded normally, but Stellarium crashed later with a segmentation fault, because LandscapeMgr::getCallOrder() depended on the module's existence to return a value.*/ //Load and start all telescope clients loadTelescopes(); //Load OpenGL textures reticleTexture = StelApp::getInstance().getTextureManager().createTexture(":/telescopeControl/telescope_reticle.png"); selectionTexture = StelApp::getInstance().getTextureManager().createTexture(StelFileMgr::getInstallationDir()+"/textures/pointeur2.png"); QSignalMapper* slewObj = new QSignalMapper(this); QSignalMapper* slewDir = new QSignalMapper(this); //Create telescope key bindings /* StelAction-s with these key bindings existed in Stellarium prior to revision 6311. Any future backports should account for that. */ QString section = N_("Telescope Control"); for (int i = MIN_SLOT_NUMBER; i <= MAX_SLOT_NUMBER; i++) { // "Slew to object" commands QString name = moveToSelectedActionId.arg(i); QString shortcut = QString("Ctrl+%1").arg(i); QString text; text = q_("Move telescope #%1 to selected object").arg(i); StelAction* actionSlewObj = addAction(name, section, text, slewObj, "map()", shortcut); slewObj->setMapping(actionSlewObj, i); // "Slew to the center of the screen" commands name = moveToCenterActionId.arg(i); shortcut = QString("Alt+%1").arg(i); text = q_("Move telescope #%1 to the point currently in the center of the screen").arg(i); StelAction* actionSlewDir = addAction(name, section, text, slewDir, "map()", shortcut); slewDir->setMapping(actionSlewDir, i); } connect(slewObj,SIGNAL(mapped(int)),this,SLOT(slewTelescopeToSelectedObject(int))); connect(slewDir,SIGNAL(mapped(int)),this,SLOT(slewTelescopeToViewDirection(int))); connect(&StelApp::getInstance(), SIGNAL(languageChanged()), this, SLOT(translateActionDescriptions())); //Create and initialize dialog windows telescopeDialog = new TelescopeDialog(); slewDialog = new SlewDialog(); addAction("actionShow_Slew_Window", N_("Telescope Control"), N_("Move a telescope to a given set of coordinates"), slewDialog, "visible", "Ctrl+0"); //Create toolbar button StelGui* gui = dynamic_cast<StelGui*>(StelApp::getInstance().getGui()); if (gui!=NULL) { toolbarButton = new StelButton(NULL, QPixmap(":/telescopeControl/button_Slew_Dialog_on.png"), QPixmap(":/telescopeControl/button_Slew_Dialog_off.png"), QPixmap(":/graphicGui/glow32x32.png"), "actionShow_Slew_Window"); gui->getButtonBar()->addButton(toolbarButton, "065-pluginsGroup"); } } catch (std::runtime_error &e) { qWarning() << "[TelescopeControl] init() error: " << e.what(); return; } GETSTELMODULE(StelObjectMgr)->registerStelObjectMgr(this); }