static PyObject *meth_QSignalMapper_setMapping(PyObject *sipSelf, PyObject *sipArgs) { PyObject *sipParseErr = NULL; { QObject* a0; int a1; QSignalMapper *sipCpp; if (sipParseArgs(&sipParseErr, sipArgs, "BJ8i", &sipSelf, sipType_QSignalMapper, &sipCpp, sipType_QObject, &a0, &a1)) { Py_BEGIN_ALLOW_THREADS sipCpp->setMapping(a0,a1); Py_END_ALLOW_THREADS Py_INCREF(Py_None); return Py_None; } } { QObject* a0; const QString* a1; int a1State = 0; QSignalMapper *sipCpp; if (sipParseArgs(&sipParseErr, sipArgs, "BJ8J1", &sipSelf, sipType_QSignalMapper, &sipCpp, sipType_QObject, &a0, sipType_QString,&a1, &a1State)) { Py_BEGIN_ALLOW_THREADS sipCpp->setMapping(a0,*a1); Py_END_ALLOW_THREADS sipReleaseType(const_cast<QString *>(a1),sipType_QString,a1State); Py_INCREF(Py_None); return Py_None; } } { QObject* a0; QWidget* a1; QSignalMapper *sipCpp; if (sipParseArgs(&sipParseErr, sipArgs, "BJ8J8", &sipSelf, sipType_QSignalMapper, &sipCpp, sipType_QObject, &a0, sipType_QWidget, &a1)) { Py_BEGIN_ALLOW_THREADS sipCpp->setMapping(a0,a1); Py_END_ALLOW_THREADS Py_INCREF(Py_None); return Py_None; } } { QObject* a0; QObject* a1; QSignalMapper *sipCpp; if (sipParseArgs(&sipParseErr, sipArgs, "BJ8J8", &sipSelf, sipType_QSignalMapper, &sipCpp, sipType_QObject, &a0, sipType_QObject, &a1)) { Py_BEGIN_ALLOW_THREADS sipCpp->setMapping(a0,a1); Py_END_ALLOW_THREADS Py_INCREF(Py_None); return Py_None; } } /* Raise an exception if the arguments couldn't be parsed. */ sipNoMethod(sipParseErr, sipName_QSignalMapper, sipName_setMapping, doc_QSignalMapper_setMapping); return NULL; }
ScriptDebugger::ScriptDebugger(const MODELMAP &models, QStandardItemModel *triggerModel) : QDialog(NULL, Qt::Window) { modelMap = models; QSignalMapper *signalMapper = new QSignalMapper(this); // Add main page QWidget *mainWidget = new QWidget(this); QVBoxLayout *mainLayout = new QVBoxLayout(); QHBoxLayout *placementLayout = new QHBoxLayout(); placementLayout->addWidget(createButton("Add droids", SLOT(droidButtonClicked()), this)); placementLayout->addWidget(createButton("Add structures", SLOT(structButtonClicked()), this)); placementLayout->addWidget(createButton("Add features", SLOT(featButtonClicked()), this)); mainLayout->addLayout(placementLayout); QHBoxLayout *miscLayout = new QHBoxLayout(); miscLayout->addWidget(createButton("Research all", SLOT(researchButtonClicked()), this)); miscLayout->addWidget(createButton("Show sensors", SLOT(sensorsButtonClicked()), this)); miscLayout->addWidget(createButton("Shadows", SLOT(shadowButtonClicked()), this)); miscLayout->addWidget(createButton("Fog", SLOT(fogButtonClicked()), this)); mainLayout->addLayout(miscLayout); QHBoxLayout *worldLayout = new QHBoxLayout(); worldLayout->addWidget(createButton("Show all", SLOT(deityButtonClicked()), this)); worldLayout->addWidget(createButton("Weather", SLOT(weatherButtonClicked()), this)); worldLayout->addWidget(createButton("Reveal mode", SLOT(revealButtonClicked()), this)); mainLayout->addLayout(worldLayout); QHBoxLayout *selectedPlayerLayout = new QHBoxLayout(); QLabel *selectPlayerLabel = new QLabel("Selected Player:"); QComboBox *playerComboBox = new QComboBox; for (int i = 0; i < game.maxPlayers; i++) { playerComboBox->addItem(QString::number(i)); } connect(playerComboBox, SIGNAL(activated(int)), this, SLOT(playerButtonClicked(int))); selectedPlayerLayout->addWidget(selectPlayerLabel); selectedPlayerLayout->addWidget(playerComboBox); mainLayout->addLayout(selectedPlayerLayout); QHBoxLayout *powerLayout = new QHBoxLayout(); QLabel *powerLabel = new QLabel("Power:"); QLineEdit *powerLineEdit = new QLineEdit; powerLineEdit->setText(QString::number(getPower(selectedPlayer))); connect(powerLineEdit, SIGNAL(textEdited(const QString&)), this, SLOT(powerEditing(const QString&))); connect(powerLineEdit, SIGNAL(returnPressed()), this, SLOT(powerEditingFinished())); powerLayout->addWidget(powerLabel); powerLayout->addWidget(powerLineEdit); mainLayout->addLayout(powerLayout); mainWidget->setLayout(mainLayout); tab.addTab(mainWidget, "Main"); // Add globals for (MODELMAP::const_iterator i = models.constBegin(); i != models.constEnd(); ++i) { QWidget *dummyWidget = new QWidget(this); QScriptEngine *engine = i.key(); QStandardItemModel *m = i.value(); m->setParent(this); // take ownership to avoid memory leaks QTreeView *view = new QTreeView(this); view->setSelectionMode(QAbstractItemView::NoSelection); view->setModel(m); QString scriptName = engine->globalObject().property("scriptName").toString(); int player = engine->globalObject().property("me").toInt32(); QLineEdit *lineEdit = new QLineEdit(this); QVBoxLayout *layout = new QVBoxLayout(); QHBoxLayout *layout2 = new QHBoxLayout(); QPushButton *updateButton = new QPushButton("Update", this); QPushButton *button = new QPushButton("Run", this); connect(button, SIGNAL(pressed()), signalMapper, SLOT(map())); connect(updateButton, SIGNAL(pressed()), this, SLOT(updateModels())); signalMapper->setMapping(button, engine); editMap.insert(engine, lineEdit); // store this for slot layout->addWidget(view); layout2->addWidget(updateButton); layout2->addWidget(lineEdit); layout2->addWidget(button); layout->addLayout(layout2); dummyWidget->setLayout(layout); tab.addTab(dummyWidget, scriptName + ":" + QString::number(player)); } connect(signalMapper, SIGNAL(mapped(QObject *)), this, SLOT(runClicked(QObject *))); // Add triggers triggerModel->setParent(this); // take ownership to avoid memory leaks triggerView.setModel(triggerModel); triggerView.resizeColumnToContents(0); triggerView.setSelectionMode(QAbstractItemView::NoSelection); triggerView.setSelectionBehavior(QAbstractItemView::SelectRows); tab.addTab(&triggerView, "Triggers"); // Add labels labelModel = createLabelModel(); labelModel->setParent(this); // take ownership to avoid memory leaks labelView.setModel(labelModel); labelView.resizeColumnToContents(0); labelView.setSelectionMode(QAbstractItemView::SingleSelection); labelView.setSelectionBehavior(QAbstractItemView::SelectRows); connect(&labelView, SIGNAL(doubleClicked(const QModelIndex &)), this, SLOT(labelClickedIdx(const QModelIndex &))); QPushButton *button = new QPushButton("Show", this); connect(button, SIGNAL(pressed()), this, SLOT(labelClicked())); QVBoxLayout *labelLayout = new QVBoxLayout(this); labelLayout->addWidget(&labelView); labelLayout->addWidget(button); QWidget *dummyWidget = new QWidget(this); dummyWidget->setLayout(labelLayout); tab.addTab(dummyWidget, "Labels"); // Set up dialog QHBoxLayout *layout = new QHBoxLayout(this); layout->addWidget(&tab); setLayout(layout); resize(400, 500); setSizeGripEnabled(true); show(); raise(); powerLineEdit->setFocusPolicy(Qt::StrongFocus); powerLineEdit->setFocus(); activateWindow(); }
void RfxDialog::DrawIFace(QGridLayout *parent, RfxUniform *u, int uidx, int rows, int columns) { enum controlType { INT_CTRL, FLOAT_CTRL, BOOL_CTRL, COLOR_CTRL }; enum ColorComponentsType { R, G, B, A }; float *val = u->GetValue(); controlType ctrl; ColorComponentsType rgba = R; QWidget **controls = new QWidget*[rows * columns]; QGridLayout *uniLayout = parent; QHBoxLayout *sliderEditLayout = NULL; bool multipleControls = false; QSignalMapper *valMapper = new QSignalMapper(this); switch (u->GetType()) { case RfxUniform::INT: case RfxUniform::IVEC2: case RfxUniform::IVEC3: case RfxUniform::IVEC4: ctrl = INT_CTRL; break; case RfxUniform::FLOAT: case RfxUniform::VEC2: case RfxUniform::VEC3: case RfxUniform::VEC4: if(u->isRmColorVariable()){ ctrl = COLOR_CTRL; break; } case RfxUniform::MAT2: case RfxUniform::MAT3: case RfxUniform::MAT4: ctrl = FLOAT_CTRL; break; case RfxUniform::BOOL: case RfxUniform::BVEC2: case RfxUniform::BVEC3: case RfxUniform::BVEC4: ctrl = BOOL_CTRL; break; default: return; } if(ctrl == COLOR_CTRL) { RfxColorBox* mycolorBox = new RfxColorBox(100, 25, QColor(val[0] * 255, val[1] * 255, val[2] * 255, val[3] * 255)); uniLayout->addWidget(mycolorBox, 0,0); connect(mycolorBox, SIGNAL(colorChanged()), valMapper, SLOT(map())); connect(mycolorBox,SIGNAL(colorChanged()),mGLWin, SLOT(update())); valMapper->setMapping(mycolorBox, QString().setNum(uidx) + '-' + QString().setNum(1) + '-' + QString().setNum(selPass)); } else{ // controls in a grid layout for (int i = 0; i < rows; ++i) { for (int j = 0; j < columns; ++j) { int arrayIdx = j + (i * rows); switch (ctrl) { case INT_CTRL: controls[arrayIdx] = new QSpinBox(this); ((QSpinBox*)controls[arrayIdx])->setRange(-99, 99); ((QSpinBox*)controls[arrayIdx])->setValue((int)val[arrayIdx]); connect(controls[arrayIdx], SIGNAL(valueChanged(int)), valMapper, SLOT(map())); connect(controls[arrayIdx], SIGNAL(valueChanged(int)), this, SLOT(extendRange(int))); break; case FLOAT_CTRL: if (u->HasMinMax()) { controls[arrayIdx] = new QSlider(this); ((QSlider*)controls[arrayIdx])->setTickPosition(QSlider::NoTicks); ((QSlider*)controls[arrayIdx])->setOrientation(Qt::Horizontal); // since qslider only deals with integers, do a little conversion // of values // keep as much as 5 decimal values, others will be lost in conversion int valAsInt = (int)(val[arrayIdx] * DECTOINT); int tickAsInt = (int)(((u->GetMaxRange() - u->GetMinRange()) * 0.01) * DECTOINT); ((QSlider*)controls[arrayIdx])->setTickInterval(tickAsInt); ((QSlider*)controls[arrayIdx])->setRange((int)(u->GetMinRange() * DECTOINT), (int)(u->GetMaxRange() * DECTOINT)); ((QSlider*)controls[arrayIdx])->setValue(valAsInt); ((QSlider*)controls[arrayIdx])->setToolTip(QString().setNum(val[arrayIdx])); connect(controls[arrayIdx], SIGNAL(valueChanged(int)), valMapper, SLOT(map())); // as per request, if value is a single float, also show a qlineedit to allow // more accurate settings. if (u->GetType() == RfxUniform::FLOAT) { QLineEdit *slideValue = new QLineEdit(); slideValue->setAlignment(Qt::AlignRight); slideValue->setText(QString().setNum(val[arrayIdx])); QSignalMapper *yaMapper = new QSignalMapper(); connect(controls[arrayIdx], SIGNAL(valueChanged(int)), yaMapper, SLOT(map())); connect(slideValue, SIGNAL(editingFinished()), yaMapper, SLOT(map())); yaMapper->setMapping(controls[arrayIdx], slideValue); yaMapper->setMapping(slideValue, controls[arrayIdx]); connect(yaMapper, SIGNAL(mapped(QWidget*)), this, SLOT(mapSliderLineEdit(QWidget*))); if (!u->GetSemantic().isNull()) slideValue->setDisabled(true); multipleControls = true; sliderEditLayout = new QHBoxLayout(); sliderEditLayout->addWidget(controls[arrayIdx]); sliderEditLayout->addWidget(slideValue); } } else { controls[arrayIdx] = new QDoubleSpinBox(this); ((QDoubleSpinBox*)controls[arrayIdx])->setRange(-99.0, 99.0); ((QDoubleSpinBox*)controls[arrayIdx])->setValue(val[arrayIdx]); ((QDoubleSpinBox*)controls[arrayIdx])->setDecimals(4); ((QDoubleSpinBox*)controls[arrayIdx])->setSingleStep(0.01); connect(controls[arrayIdx], SIGNAL(valueChanged(double)), valMapper, SLOT(map())); connect(controls[arrayIdx], SIGNAL(valueChanged(double)), this, SLOT(extendRange(double))); } break; case BOOL_CTRL: controls[arrayIdx] = new QComboBox(this); ((QComboBox*)controls[arrayIdx])->addItem("FALSE"); ((QComboBox*)controls[arrayIdx])->addItem("TRUE"); if (!val[arrayIdx]) ((QComboBox*)controls[arrayIdx])->setCurrentIndex(0); connect(controls[arrayIdx], SIGNAL(currentIndexChanged(int)), valMapper, SLOT(map())); break; } valMapper->setMapping(controls[arrayIdx], QString().setNum(uidx) + '-' + QString().setNum(arrayIdx) + '-' + QString().setNum(selPass)); if (!u->GetSemantic().isNull()) controls[arrayIdx]->setDisabled(true); if (multipleControls) uniLayout->addLayout(sliderEditLayout, i, j); else uniLayout->addWidget(controls[arrayIdx], i, j); multipleControls = false; }
StartDialog::StartDialog(MainWindow &mainWindow, ProjectManager &projectManager) : QDialog(&mainWindow, false) , mMainWindow(mainWindow) , mProjectManager(projectManager) { setMinimumSize(mMinimumSize); setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); QTabWidget *tabWidget = new QTabWidget; RecentProjectsListWidget *recentProjects = new RecentProjectsListWidget(this); tabWidget->addTab(recentProjects, tr("&Recent projects")); Id const theOnlyDiagram = mMainWindow.editorManager().theOnlyDiagram(); if (theOnlyDiagram.isNull()) { SuggestToCreateDiagramWidget *diagrams = new SuggestToCreateDiagramWidget(&mMainWindow, this); tabWidget->addTab(diagrams, tr("&New project with diagram")); connect(diagrams, SIGNAL(userDataSelected(QString)), this, SLOT(createProjectWithDiagram(QString))); if (recentProjects->count() == 0) { tabWidget->setCurrentWidget(diagrams); } } QCommandLinkButton *openIDLink = new QCommandLinkButton(tr("&Open interpreted diagram")); QCommandLinkButton *createIDLink = new QCommandLinkButton(tr("&Create interpreted diagram")); QHBoxLayout *openIDLinkLayout = new QHBoxLayout; openIDLinkLayout->addWidget(openIDLink); mInterpreterButton = openIDLink; QHBoxLayout *createIDLinkLayout = new QHBoxLayout; createIDLinkLayout->addWidget(createIDLink); mCreateInterpreterButton = createIDLink; QHBoxLayout *commandLinksLayout = new QHBoxLayout; if (theOnlyDiagram != Id()) { Id const editor = mMainWindow.editorManager().editors()[0]; QString const diagramIdString = mMainWindow.editorManager().diagramNodeNameString(editor, theOnlyDiagram); QSignalMapper *newProjectMapper = new QSignalMapper(this); QCommandLinkButton *newLink = createCommandButton(tr("New project") , newProjectMapper, SLOT(map()), QKeySequence::New); newProjectMapper->setMapping(newLink, diagramIdString); connect(newProjectMapper, SIGNAL(mapped(QString)), this, SLOT(createProjectWithDiagram(QString))); commandLinksLayout->addWidget(newLink); } commandLinksLayout->addWidget(createCommandButton(tr("Open existing project") , this, SLOT(openExistingProject()), QKeySequence::Open)); QVBoxLayout *mainLayout = new QVBoxLayout; mainLayout->addWidget(tabWidget); mainLayout->addLayout(openIDLinkLayout); mainLayout->addLayout(createIDLinkLayout); mainLayout->addLayout(commandLinksLayout); setLayout(mainLayout); setWindowTitle(tr("Start page")); connect(openIDLink, SIGNAL(clicked()), this, SLOT(openInterpretedDiagram())); connect(createIDLink, SIGNAL(clicked()), this, SLOT(createInterpretedDiagram())); connect(recentProjects, SIGNAL(userDataSelected(QString)), this, SLOT(openRecentProject(QString))); connect(this, SIGNAL(rejected()), this, SLOT(exitApp())); }
TumblerWindow::TumblerWindow(TumblerStruct *xtum, bool rgba, bool doubleBuffer, bool enableDepth, QWidget * parent, const char * name, Qt::WindowFlags f) : QMainWindow(parent, f) { int j; QString str; mTum = xtum; setAttribute(Qt::WA_DeleteOnClose); setAttribute(Qt::WA_AlwaysShowToolTips); if (firstTime) utilFileListsToIcons(fileList, icons, MAX_XTUM_TOGGLES); firstTime = 0; // Make central vbox and top frame containing an hboxlayout QWidget *central = new QWidget(this); setCentralWidget(central); QVBoxLayout *cenlay = new QVBoxLayout(central); cenlay->setContentsMargins(0,0,0,0); cenlay->setSpacing(0); QFrame * topFrame = new QFrame(central); cenlay->addWidget(topFrame); topFrame->setFrameStyle(QFrame::Raised | QFrame::StyledPanel); QHBoxLayout *topLayout = new QHBoxLayout(topFrame); topLayout->setContentsMargins(2,2,2,2); topLayout->setSpacing(3); QVBoxLayout *topVBox = diaVBoxLayout(topLayout); topVBox->setSpacing(4); QHBoxLayout *topHBox = diaHBoxLayout(topVBox); topHBox->setContentsMargins(0,0,0,0); topHBox->setSpacing(3); // Add the toolbar widgets // Zoom spin box // If you try to make a spin box narrower, it makes the arrows tiny mZoomBox = (QSpinBox *)diaLabeledSpin(0, 1., XTUM_MAX_ZOOM, 1., "Zoom", topFrame, topHBox); mZoomBox->setValue(xtum->zoom); connect(mZoomBox, SIGNAL(valueChanged(int)), this, SLOT(zoomChanged(int))); mZoomBox->setToolTip("Change zoom of display"); // Make the 2 toggle buttons and their signal mapper QSignalMapper *toggleMapper = new QSignalMapper(topFrame); connect(toggleMapper, SIGNAL(mapped(int)), this, SLOT(toggleClicked(int))); for (j = 0; j < 2; j++) { utilSetupToggleButton(topFrame, NULL, topHBox, toggleMapper, icons, toggleTips, mToggleButs, mToggleStates, j); connect(mToggleButs[j], SIGNAL(clicked()), toggleMapper, SLOT(map())); } // Help button mHelpButton = diaPushButton("Help", topFrame, topHBox); connect(mHelpButton, SIGNAL(clicked()), this, SLOT(help())); setFontDependentWidths(); topHBox->addStretch(); // Make second row for size spin boxes, and signal map them QHBoxLayout *botHBox = diaHBoxLayout(topVBox); botHBox->setContentsMargins(0,0,0,0); botHBox->setSpacing(3); QSignalMapper *sizeMapper = new QSignalMapper(topFrame); connect(sizeMapper, SIGNAL(mapped(int)), this, SLOT(sizeChanged(int))); // Make the spin boxes for (j = 0; j < 3; j++) { str = xyzLabels[j]; mSizeBoxes[j] = (QSpinBox *)diaLabeledSpin(0, XTUM_SIZE_MIN, XTUM_SIZE_MAX, XTUM_SIZE_INC, LATIN1(str), topFrame, botHBox); mSizeBoxes[j]->setValue(XTUM_SIZE_INI); sizeMapper->setMapping(mSizeBoxes[j], j); connect(mSizeBoxes[j], SIGNAL(valueChanged(int)), sizeMapper, SLOT(map())); mSizeBoxes[j]->setToolTip("Change size of box in " + str); } // Spacer for the second row botHBox->addStretch(); // Add a vertical line QFrame *vertLine = new QFrame(topFrame); vertLine->setFrameStyle(QFrame::Sunken | QFrame::VLine); topLayout->addWidget(vertLine); // Threshold sliders mSliders = new MultiSlider(topFrame, 2, sliderLabels); topLayout->addLayout(mSliders->getLayout()); connect(mSliders, SIGNAL(sliderChanged(int, int, bool)), this, SLOT(thresholdChanged(int, int, bool))); mSliders->setValue(0, xtum->minval); mSliders->setValue(1, xtum->maxval); mSliders->getSlider(0)->setToolTip( "Level below which pixels will be set to black"); mSliders->getSlider(1)->setToolTip( "Level above which pixels will be set to white"); QGLFormat glFormat; glFormat.setRgba(rgba); glFormat.setDoubleBuffer(doubleBuffer); glFormat.setDepth(enableDepth); mGLw = new TumblerGL(xtum, glFormat, central); cenlay->addWidget(mGLw); cenlay->setStretchFactor(mGLw, 1); resize(XTUM_WIDTH, XTUM_HEIGHT); setFocusPolicy(Qt::StrongFocus); }
SettingsTabOther::SettingsTabOther(QWidget *parent, QMap<QString, QVariant> set, bool v) : QWidget(parent) { // The global settings globSet = set; verbose = v; this->setObjectName("tabother"); this->setStyleSheet("#tabother { background: transparent; color: white; }"); tabs = new TabWidget; tabs->expand(false); tabs->setBorderTop("rgba(150,150,150,100)",2); tabs->setBorderBot("rgba(150,150,150,100)",2); QVBoxLayout *mainLay = new QVBoxLayout; mainLay->addWidget(tabs); this->setLayout(mainLay); // the main scroll widget for all LOOK content scrollbarOther = new CustomScrollbar; QScrollArea *scrollOther = new QScrollArea; QVBoxLayout *layOther = new QVBoxLayout(scrollOther); QWidget *scrollWidgOther = new QWidget(scrollOther); scrollWidgOther->setLayout(layOther); scrollOther->setWidget(scrollWidgOther); scrollOther->setWidgetResizable(true); scrollOther->setVerticalScrollBar(scrollbarOther); // the main scroll widget for all FEEL content scrollbarFile = new CustomScrollbar; QScrollArea *scrollFile = new QScrollArea; QVBoxLayout *layFile = new QVBoxLayout(scrollFile); QWidget *scrollWidgFile = new QWidget(scrollFile); scrollWidgFile->setLayout(layFile); scrollFile->setWidget(scrollWidgFile); scrollFile->setWidgetResizable(true); scrollFile->setVerticalScrollBar(scrollbarFile); tabOther = new QWidget; tabFile = new QWidget; QVBoxLayout *scrollLayOther = new QVBoxLayout; scrollLayOther->addWidget(scrollOther); tabOther->setLayout(scrollLayOther); QVBoxLayout *scrollLayFile = new QVBoxLayout; scrollLayFile->addWidget(scrollFile); tabFile->setLayout(scrollLayFile); tabs->addTab(tabOther,tr("Other")); tabs->addTab(tabFile,tr("File Types")); // The titles CustomLabel *titleOther = new CustomLabel("<center><h1>" + tr("Other Settings") + "</h1></center>"); layOther->addWidget(titleOther); layOther->addSpacing(20); CustomLabel *titleFile = new CustomLabel("<center><h1>" + tr("Known File Types") + "</h1></center>"); layFile->addWidget(titleFile); layFile->addSpacing(20); // CHOOSE A LANGUAGE CustomLabel *langLabel = new CustomLabel("<b><span style=\"font-size:12pt\">" + tr("Choose Language") + "</span></b><br><br>" + tr("There are a good few different languages available. Thanks to everybody who took the time to translate PhotoQt!")); langLabel->setWordWrap(true); layOther->addWidget(langLabel); layOther->addSpacing(15); // All the languages available. They are sorted according to their language code (except English) // A GOOD FEW OF THE TRANSLATIONS HAVEN'T BEEN UPDATED IN A LONG TIME AND ARE STANDING AT 0-5% // These translations are NOT included! langDesc << "English"; langShort << "en"; // Arabic // langDesc << QString::fromUtf8("العربية (Amar T.)"); // langShort << "ar"; // Czech langDesc << QString::fromUtf8("Čeština (Robin H. & Petr Š.)"); langShort << "cs"; // German langDesc << "Deutsch"; langShort << "de"; // Greek langDesc << QString::fromUtf8("Ελληνικά (Dimitrios G.)"); langShort << "el"; // Spanish langDesc << QString::fromUtf8("Español (Hector C. & Victoria P.)"); langShort << "es_ES"; // Finnish langDesc << QString::fromUtf8("Suomen kieli (Jiri G.)"); langShort << "fi"; // French langDesc << QString::fromUtf8("Français (Olivier D. & Tubuntu)"); langShort << "fr"; // Hungarian // langDesc << QString::fromUtf8("Magyar (Zoltan H.)"); // langShort << "hu"; // Hebrew langDesc << QString::fromUtf8("עברית (GenghisKhan)"); langShort << "he"; // Italian langDesc << "Italiano (Vincenzo C. & Fabio M.)"; langShort << "it"; // Japanese langDesc << QString::fromUtf8("日本語 (Obytetest)"); langShort << "ja"; // Norwegian Bokmal // langDesc << QString::fromUtf8("Bokmål (Ola Haugen H.)"); // langShort << "nb_NO"; // Norwegian Nynorsk // langDesc << "Nynorsk (Ola Haugen H.)"; // langShort << "nn_NO"; // Polish // langDesc << "Polski (Daniel K.)"; // langShort << "pl"; // Portugal (Brazil) langDesc << QString::fromUtf8("Português (Brasil) (Rafael N. & Everton)"); langShort << "pt_BR"; // Portugal (Portugal) langDesc << QString::fromUtf8("Português (Portugal) (Sérgio M. & Manuela S. & Willow)"); langShort << "pt_PT"; // Russian langDesc << QString::fromUtf8("Pусский (Yuriy T.)"); langShort << "ru_RU"; //Slovak langDesc << QString::fromUtf8("Slovenčina (Lukáš D.)"); langShort << "sk"; // Serbian // langDesc << QString::fromUtf8("српски екавски (Mladen Pejaković)"); // langShort << "sr_RS"; // Turkish // langDesc << QString::fromUtf8("Türkçe (Onuralp SEZER)"); // langShort << "tr"; // Ukrainian langDesc << QString::fromUtf8("Українська (neeesdfsdf & zubr139)"); langShort << "uk_UA"; // Viatnemese // langDesc << QString::fromUtf8("Tiếng Việt (Nguyễn Hữu Tài)"); // langShort << "vi"; // Chinese (China) langDesc << "Chinese (Min Zhang)"; langShort << "zh_CN"; langDesc << "Chinese (traditional) (Min Zhang)"; langShort << "zh_TW"; FlowLayout *langLay = new FlowLayout; QButtonGroup *langButGrp = new QButtonGroup; for(int i = 0; i < langDesc.length(); ++i) { SettingsTabOtherLanguageTiles *tile = new SettingsTabOtherLanguageTiles(langDesc.at(i), langShort.at(i)); allLangTiles << tile; langButGrp->addButton(tile->button); langLay->addWidget(tile); } QHBoxLayout *langWidgLay = new QHBoxLayout; langWidgLay->addSpacing(50); langWidgLay->addLayout(langLay); langWidgLay->addSpacing(50); layOther->addLayout(langWidgLay); layOther->addSpacing(30); // Adjust quick settings trigering CustomLabel *quickSetLabel = new CustomLabel("<b><span style=\"font-size:12pt\">" + tr("Quick Settings") + "</span></b><br><br>" + tr("The 'Quick Settings' is a widget hidden on the right side of the screen. When you move the cursor there, it shows up, and you can adjust a few simple settings on the spot without having to go through this settings dialog. Of course, only a small subset of settings is available (the ones needed most often). Here you can disable the dialog so that it doesn't show on mouse movement anymore.")); quickSet = new CustomCheckBox(tr("Show 'Quick Settings' on mouse hovering")); QHBoxLayout *quickSetLay = new QHBoxLayout; quickSetLay->addStretch(); quickSetLay->addWidget(quickSet); quickSetLay->addStretch(); layOther->addWidget(quickSetLabel); layOther->addSpacing(20); layOther->addLayout(quickSetLay); layOther->addSpacing(30); // Adjust context menu CustomLabel *contextMenuLabel = new CustomLabel("<b><span style=\"font-size:12pt\">" + tr("Adjust Context Menu") + "</span></b><br><br>" + tr("Here you can adjust the context menu. You can simply drag and drop the entries, edit them, add a new one and remove an existing one.")); context = new Context; QHBoxLayout *contextLay = new QHBoxLayout; contextLay->addStretch(); contextLay->addWidget(context); contextLay->addStretch(); CustomPushButton *addNew = new CustomPushButton("+ " + tr("Add new Entry"),this); QHBoxLayout *addNewLay = new QHBoxLayout; connect(addNew, SIGNAL(clicked()), context, SLOT(addNewEntry())); addNewLay->addStretch(); addNewLay->addWidget(addNew); addNewLay->addStretch(); layOther->addWidget(contextMenuLabel); layOther->addSpacing(10); layOther->addLayout(contextLay); layOther->addLayout(addNewLay); layOther->addSpacing(20); allCheckQt.clear(); allCheckGm.clear(); allCheckGmUnstable.clear(); // Adjust known file formats CustomLabel *titleQt = new CustomLabel("<b><span style=\"font-size:12pt\">" + tr("File Types - Qt") + "</span></b><br><br>" + tr("These are the standard file types supported by Qt. Depending on your system, this list can vary a little.") + "<br>" + tr("If you want to add a file type not in the list, you can add them in the text box below. You have to enter the formats like '*.ending', all seperated by commas.") + "</b>"); titleQt->setWordWrap(true); FlowLayout *layQt = new FlowLayout; QStringList formatsQt; formatsQt << ".bmp" << ".gif" << ".tif" << ".tiff" << ".jpeg2000" << ".jpeg" << ".jpg" << ".png" << ".pbm" << ".pgm" << ".ppm" << ".xbm" << ".xpm"; formatsQt.sort(); for(int i = 0; i < formatsQt.length(); ++i) { SettingsTabOtherFileTypesTiles *check = new SettingsTabOtherFileTypesTiles(formatsQt.at(i)); check->setToolTip(formatsQt.at(i)); allCheckQt.insert(formatsQt.at(i),check); layQt->addWidget(check); } QHBoxLayout *layQtBut = new QHBoxLayout; CustomLabel *extraQt = new CustomLabel(tr("Extra File Types:")); extraQt->setWordWrap(false); extraQtEdit = new CustomLineEdit; CustomPushButton *qtMarkAll = new CustomPushButton(tr("Mark All")); CustomPushButton *qtMarkNone = new CustomPushButton(tr("Mark None")); layQtBut->addWidget(extraQt); layQtBut->addWidget(extraQtEdit); layQtBut->addStretch(); layQtBut->addWidget(qtMarkAll); layQtBut->addWidget(qtMarkNone); layFile->addWidget(titleQt); layFile->addSpacing(10); layFile->addLayout(layQt); layFile->addSpacing(5); layFile->addLayout(layQtBut); layFile->addSpacing(35); QSignalMapper *mapQtMark = new QSignalMapper; mapQtMark->setMapping(qtMarkAll,"qtMark"); connect(qtMarkAll, SIGNAL(clicked()), mapQtMark, SLOT(map())); connect(mapQtMark, SIGNAL(mapped(QString)), this, SLOT(markAllNone(QString))); QSignalMapper *mapQtNone = new QSignalMapper; mapQtNone->setMapping(qtMarkNone,"qtNone"); connect(qtMarkNone, SIGNAL(clicked()), mapQtNone, SLOT(map())); connect(mapQtNone, SIGNAL(mapped(QString)), this, SLOT(markAllNone(QString))); #ifndef GM CustomLabel *gmDisabled = new CustomLabel("<b><i>" + tr("Use of GraphicsMagick has been disabled as PhotoQt was compiled/installed!") + "</i></b>"); gmDisabled->setWordWrap(true); #endif CustomLabel *titleGmWorking = new CustomLabel("<b><span style=\"font-size:12pt\">" + tr("File Types - GraphicsMagick") + "</span></b><br><br>" + tr("PhotoQt makes use of GraphicsMagick for support of many different file types. Not all of the formats supported by GraphicsMagick make sense in an image viewer. There are some that aren't quite working at the moment, you can find them in the 'Unstable' category below.") + "<br>" + tr("If you want to add a file type not in the list, you can add them in the text box below. You have to enter the formats like '*.ending', all seperated by commas.") + "</b>"); titleGmWorking->setWordWrap(true); FlowLayout *layGm = new FlowLayout; QStringList formatsGm; formatsGm << ".art" << ".avs" << ".x" << ".cals" << ".cgm" << ".cur" << ".cut" << ".acr" << ".dcm" << ".dicom" << ".dic" << ".dcx" << ".dib" << ".dpx" << ".emf" << ".epdf" << ".epi" << ".eps" << ".eps2" << ".eps3" << ".epsf" << ".epsi" << ".ept" << ".fax" << ".fig" << ".fits" << ".fts" << ".fit" << ".fpx" << ".gplt" << ".ico" << ".jbg" << ".jbig" << ".jng" << ".jp2" << ".j2k" << ".jpf" << ".jpx" << ".jpm" << ".mj2" << ".jpc" << ".mat" << ".miff" << ".mng" << ".mpc" << ".mtv" << ".otb" << ".p7" << ".palm" << ".pam" << ".pcd" << ".pcds" << ".pcx" << ".pdb" << ".pdf" << ".picon" << ".pict" << ".pct" << ".pic" << ".pix" << ".pnm" << ".ps" << ".ps2" << ".ps3" << ".psd" << ".ptif" << ".ras" << ".rast" << ".rad" << ".sgi" << ".sun" << ".svg" << ".tga" << ".vicar" << ".viff" << ".wbmp" << ".wbm" << ".xcf" << ".xwd"; formatsGm.sort(); for(int i = 0; i < formatsGm.length(); ++i) { SettingsTabOtherFileTypesTiles *check = new SettingsTabOtherFileTypesTiles(formatsGm.at(i)); allCheckGm.insert(formatsGm.at(i),check); check->setToolTip(formatsGm.at(i)); layGm->addWidget(check); #ifndef GM check->setEnabled(false); #endif } QHBoxLayout *layGmBut = new QHBoxLayout; CustomLabel *extraGm = new CustomLabel(tr("Extra File Types:")); extraGm->setWordWrap(false); extraGmEdit = new CustomLineEdit; CustomPushButton *gmMarkAll = new CustomPushButton(tr("Mark All")); CustomPushButton *gmMarkNone = new CustomPushButton(tr("Mark None")); layGmBut->addWidget(extraGm); layGmBut->addWidget(extraGmEdit); layGmBut->addStretch(); layGmBut->addWidget(gmMarkAll); layGmBut->addWidget(gmMarkNone); #ifndef GM titleGmWorking->setEnabled(false); gmMarkAll->setEnabled(false); gmMarkNone->setEnabled(false); extraGm->setEnabled(false); extraGmEdit->setEnabled(false); layFile->addWidget(gmDisabled); layFile->addSpacing(10); #endif layFile->addWidget(titleGmWorking); layFile->addSpacing(10); layFile->addLayout(layGm); layFile->addSpacing(5); layFile->addLayout(layGmBut); layFile->addSpacing(35); QSignalMapper *mapGmMark = new QSignalMapper; mapGmMark->setMapping(gmMarkAll,"gmMark"); connect(gmMarkAll, SIGNAL(clicked()), mapGmMark, SLOT(map())); connect(mapGmMark, SIGNAL(mapped(QString)), this, SLOT(markAllNone(QString))); QSignalMapper *mapGmNone = new QSignalMapper; mapGmNone->setMapping(gmMarkNone,"gmNone"); connect(gmMarkNone, SIGNAL(clicked()), mapGmNone, SLOT(map())); connect(mapGmNone, SIGNAL(mapped(QString)), this, SLOT(markAllNone(QString))); CustomLabel *titleGmUnstable = new CustomLabel("<b><span style=\"font-size:12pt\">" + tr("File Types - GraphicsMagick (Unstable)") + "</span></b><br><br>" + tr("The following file types are supported by GraphicsMagick, but aren't quite working in PhotoQt just yet. If you want to experiment around a little, feel free to enable some of them. They shouldn't cause PhotoQt to crash, but you might see an error image instead of the actual image.") + "</b>"); titleGmUnstable->setWordWrap(true); FlowLayout *layGmUnstable = new FlowLayout; QStringList formatsGmUnstable; formatsGmUnstable << ".gray" << ".hpgl" << ".mono" << ".msl" << ".mvg" << ".pcl" << ".pfa" << ".pfb" << ".pwp" << ".rgb" << ".rgba" << ".rla" << ".rle" << ".sct" << ".sfw" << ".tim" << ".uil" << ".uyvy" << ".wmf" << ".wpg" << ".yuv"; formatsGmUnstable.sort(); for(int i = 0; i < formatsGmUnstable.length(); ++i) { SettingsTabOtherFileTypesTiles *check = new SettingsTabOtherFileTypesTiles(formatsGmUnstable.at(i)); check->setToolTip(formatsGmUnstable.at(i)); allCheckGmUnstable.insert(formatsGmUnstable.at(i),check); layGmUnstable->addWidget(check); #ifndef GM check->setEnabled(false); #endif } QHBoxLayout *layGmButUnstable = new QHBoxLayout; CustomPushButton *gmMarkAllUnstable = new CustomPushButton(tr("Mark All")); CustomPushButton *gmMarkNoneUnstable = new CustomPushButton(tr("Mark None")); layGmButUnstable->addStretch(); layGmButUnstable->addWidget(gmMarkAllUnstable); layGmButUnstable->addWidget(gmMarkNoneUnstable); layFile->addWidget(titleGmUnstable); layFile->addSpacing(10); layFile->addLayout(layGmUnstable); layFile->addSpacing(5); layFile->addLayout(layGmButUnstable); layFile->addSpacing(35); #ifndef GM titleGmUnstable->setEnabled(false); gmMarkAllUnstable->setEnabled(false); gmMarkNoneUnstable->setEnabled(false); #endif QSignalMapper *mapGmMarkUnst = new QSignalMapper; mapGmMarkUnst->setMapping(gmMarkAllUnstable,"gmunstMark"); connect(gmMarkAllUnstable, SIGNAL(clicked()), mapGmMarkUnst, SLOT(map())); connect(mapGmMarkUnst, SIGNAL(mapped(QString)), this, SLOT(markAllNone(QString))); QSignalMapper *mapGmNoneUnst = new QSignalMapper; mapGmNoneUnst->setMapping(gmMarkNoneUnstable,"gmunstNone"); connect(gmMarkNoneUnstable, SIGNAL(clicked()), mapGmNoneUnst, SLOT(map())); connect(mapGmNoneUnst, SIGNAL(mapped(QString)), this, SLOT(markAllNone(QString))); layOther->addStretch(); layFile->addStretch(); }
void ResultsTree::contextMenuEvent(QContextMenuEvent * e) { QModelIndex index = indexAt(e->pos()); if (index.isValid()) { bool multipleSelection = false; mSelectionModel = selectionModel(); if (mSelectionModel->selectedRows().count() > 1) multipleSelection = true; mContextItem = mModel.itemFromIndex(index); //Create a new context menu QMenu menu(this); //Store all applications in a list QList<QAction*> actions; //Create a signal mapper so we don't have to store data to class //member variables QSignalMapper *signalMapper = new QSignalMapper(this); if (mContextItem && mApplications->GetApplicationCount() > 0 && mContextItem->parent()) { //Go through all applications and add them to the context menu for (int i = 0; i < mApplications->GetApplicationCount(); i++) { //Create an action for the application const Application app = mApplications->GetApplication(i); QAction *start = new QAction(app.getName(), &menu); if (multipleSelection) start->setDisabled(true); //Add it to our list so we can disconnect later on actions << start; //Add it to context menu menu.addAction(start); //Connect the signal to signal mapper connect(start, SIGNAL(triggered()), signalMapper, SLOT(map())); //Add a new mapping signalMapper->setMapping(start, i); } connect(signalMapper, SIGNAL(mapped(int)), this, SLOT(Context(int))); } // Add menuitems to copy full path/filename to clipboard if (mContextItem) { if (mApplications->GetApplicationCount() > 0) { menu.addSeparator(); } //Create an action for the application QAction *copyfilename = new QAction(tr("Copy filename"), &menu); QAction *copypath = new QAction(tr("Copy full path"), &menu); QAction *copymessage = new QAction(tr("Copy message"), &menu); QAction *hide = new QAction(tr("Hide"), &menu); if (multipleSelection) { copyfilename->setDisabled(true); copypath->setDisabled(true); copymessage->setDisabled(true); } menu.addAction(copyfilename); menu.addAction(copypath); menu.addAction(copymessage); menu.addAction(hide); connect(copyfilename, SIGNAL(triggered()), this, SLOT(CopyFilename())); connect(copypath, SIGNAL(triggered()), this, SLOT(CopyFullPath())); connect(copymessage, SIGNAL(triggered()), this, SLOT(CopyMessage())); connect(hide, SIGNAL(triggered()), this, SLOT(HideResult())); } //Start the menu menu.exec(e->globalPos()); if (mContextItem && mApplications->GetApplicationCount() > 0 && mContextItem->parent()) { //Disconnect all signals for (int i = 0; i < actions.size(); i++) { disconnect(actions[i], SIGNAL(triggered()), signalMapper, SLOT(map())); } disconnect(signalMapper, SIGNAL(mapped(int)), this, SLOT(Context(int))); //And remove the signal mapper delete signalMapper; } }
/** 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); }
// adds dynamic actions to the toolbar (example settings) void RenderWindow::slotPopulateToolbar(bool completeRefresh) { WriteLog("cInterface::PopulateToolbar(QWidget *window, QToolBar *toolBar) started", 2); QDir toolbarDir = QDir(systemData.dataDirectory + "toolbar"); toolbarDir.setSorting(QDir::Time); QStringList toolbarFiles = toolbarDir.entryList(QDir::NoDotAndDotDot | QDir::Files); QSignalMapper *mapPresetsFromExamplesLoad = new QSignalMapper(this); QSignalMapper *mapPresetsFromExamplesRemove = new QSignalMapper(this); ui->toolBar->setIconSize( QSize(gPar->Get<int>("toolbar_icon_size"), gPar->Get<int>("toolbar_icon_size"))); QList<QAction *> actions = ui->toolBar->actions(); QStringList toolbarInActions; for (int i = 0; i < actions.size(); i++) { QAction *action = actions.at(i); if (action->objectName() == "actionAdd_Settings_to_Toolbar") continue; if (!toolbarFiles.contains(action->objectName()) || completeRefresh) { // preset has been removed ui->toolBar->removeAction(action); } else { toolbarInActions << action->objectName(); } } for (int i = 0; i < toolbarFiles.size(); i++) { if (toolbarInActions.contains(toolbarFiles.at(i))) { // already present continue; } QString filename = systemData.dataDirectory + "toolbar/" + toolbarFiles.at(i); cThumbnailWidget *thumbWidget = NULL; if (QFileInfo(filename).suffix() == QString("fract")) { WriteLogString("Generating thumbnail for preset", filename, 2); cSettings parSettings(cSettings::formatFullText); parSettings.BeQuiet(true); if (parSettings.LoadFromFile(filename)) { cParameterContainer *par = new cParameterContainer; cFractalContainer *parFractal = new cFractalContainer; InitParams(par); for (int i = 0; i < NUMBER_OF_FRACTALS; i++) InitFractalParams(&parFractal->at(i)); /****************** TEMPORARY CODE FOR MATERIALS *******************/ InitMaterialParams(1, par); /*******************************************************************/ if (parSettings.Decode(par, parFractal)) { thumbWidget = new cThumbnailWidget( gPar->Get<int>("toolbar_icon_size"), gPar->Get<int>("toolbar_icon_size"), 2, this); thumbWidget->UseOneCPUCore(true); thumbWidget->AssignParameters(*par, *parFractal); } delete par; delete parFractal; } } if (thumbWidget) { QWidgetAction *action = new QWidgetAction(this); QToolButton *buttonLoad = new QToolButton; QVBoxLayout *tooltipLayout = new QVBoxLayout; QToolButton *buttonRemove = new QToolButton; tooltipLayout->setContentsMargins(3, 3, 3, 3); tooltipLayout->addWidget(thumbWidget); QIcon iconDelete = QIcon::fromTheme("list-remove", QIcon(":system/icons/list-remove.svg")); buttonRemove->setIcon(iconDelete); buttonRemove->setMaximumSize(QSize(15, 15)); buttonRemove->setStyleSheet("margin-bottom: -2px; margin-left: -2px;"); tooltipLayout->addWidget(buttonRemove); buttonLoad->setToolTip(QObject::tr("Toolbar settings: ") + filename); buttonLoad->setLayout(tooltipLayout); action->setDefaultWidget(buttonLoad); action->setObjectName(toolbarFiles.at(i)); ui->toolBar->addAction(action); mapPresetsFromExamplesLoad->setMapping(buttonLoad, filename); mapPresetsFromExamplesRemove->setMapping(buttonRemove, filename); QApplication::connect(buttonLoad, SIGNAL(clicked()), mapPresetsFromExamplesLoad, SLOT(map())); QApplication::connect( buttonRemove, SIGNAL(clicked()), mapPresetsFromExamplesRemove, SLOT(map())); } } QApplication::connect( mapPresetsFromExamplesLoad, SIGNAL(mapped(QString)), this, SLOT(slotMenuLoadPreset(QString))); QApplication::connect(mapPresetsFromExamplesRemove, SIGNAL(mapped(QString)), this, SLOT(slotMenuRemovePreset(QString))); WriteLog("cInterface::PopulateToolbar(QWidget *window, QToolBar *toolBar) finished", 2); }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); QPushButton *buttonUp = new QPushButton(this); QPushButton *buttonDown = new QPushButton; QPushButton *buttonLeft = new QPushButton; QPushButton *buttonRight = new QPushButton; this->gridLayout = new QGridLayout; this->boardBoundX = 11; this->boardBoundY = 11; this->_curX = 0; this->_curY = this->boardBoundY; for (int y = 0; y <= this->boardBoundY; y++) { for (int x = 0; x <= this->boardBoundX; x++) { QLabel *textBlock = new QLabel; if (x == 0 && y == this->boardBoundY) textBlock->setText("<span style='color:red'>X</span>"); else { textBlock->setText(QString("<span style='color:black'>%1</span>").arg(this->boardMatrix[y][x])); } gridLayout->addWidget(textBlock, y, x, 1, 1, Qt::AlignCenter); } } buttonUp->setText("UP"); buttonDown->setText("DOWN"); buttonLeft->setText("LEFT"); buttonRight->setText("RIGHT"); QSignalMapper *signalMapper = new QSignalMapper(this); QObject::connect(signalMapper, SIGNAL(mapped(int)), this, SLOT(moveCharacter(int))); QObject::connect(buttonUp, SIGNAL(clicked()), signalMapper, SLOT(map())); QObject::connect(buttonDown, SIGNAL(clicked()), signalMapper, SLOT(map())); QObject::connect(buttonLeft, SIGNAL(clicked()), signalMapper, SLOT(map())); QObject::connect(buttonRight, SIGNAL(clicked()), signalMapper, SLOT(map())); signalMapper->setMapping(buttonUp, MOVE_UP); signalMapper->setMapping(buttonDown, MOVE_DOWN); signalMapper->setMapping(buttonLeft, MOVE_LEFT); signalMapper->setMapping(buttonRight, MOVE_RIGHT); gridLayout->addWidget(buttonUp, this->boardBoundY + 1, 0, 1, 3, Qt::AlignCenter); gridLayout->addWidget(buttonDown, this->boardBoundY + 1, 3, 1, 3, Qt::AlignCenter); gridLayout->addWidget(buttonLeft, this->boardBoundY + 1, 6, 1, 3, Qt::AlignCenter); gridLayout->addWidget(buttonRight, this->boardBoundY + 1, 9, 1, 3, Qt::AlignCenter); QWidget *mainWidget = new QWidget; mainWidget->setLayout(gridLayout); mainWidget->setWindowTitle("Test"); if (this->centralWidget()) this->centralWidget()->setParent(0); // Preserve current central widget this->setCentralWidget(mainWidget); }
void ChalRespPage::connectHelpButtons() { //Map the values of the help buttons //Create a QMapper QSignalMapper *mapper = new QSignalMapper(this); //Connect the clicked signal with the QSignalMapper connect(ui->quickHelpBtn, SIGNAL(clicked()), mapper, SLOT(map())); connect(ui->advHelpBtn, SIGNAL(clicked()), mapper, SLOT(map())); connect(ui->quickConfigHelpBtn, SIGNAL(clicked()), mapper, SLOT(map())); connect(ui->quickParamGenSchemeHelpBtn, SIGNAL(clicked()), mapper, SLOT(map())); connect(ui->quickChalRespOptionsHelpBtn, SIGNAL(clicked()), mapper, SLOT(map())); connect(ui->quickPvtIdHelpBtn, SIGNAL(clicked()), mapper, SLOT(map())); connect(ui->quickSecretKeyHelpBtn, SIGNAL(clicked()), mapper, SLOT(map())); connect(ui->advConfigHelpBtn, SIGNAL(clicked()), mapper, SLOT(map())); connect(ui->advChalRespOptionsHelpBtn, SIGNAL(clicked()), mapper, SLOT(map())); connect(ui->advSecretKeyHelpBtn, SIGNAL(clicked()), mapper, SLOT(map())); //Set a value for each button mapper->setMapping(ui->quickHelpBtn, HelpBox::Help_ChalRespYubico); mapper->setMapping(ui->advHelpBtn, HelpBox::Help_ChalRespHmac); mapper->setMapping(ui->quickConfigHelpBtn, HelpBox::Help_ConfigurationSlot); mapper->setMapping(ui->quickParamGenSchemeHelpBtn, HelpBox::Help_ParameterGeneration); mapper->setMapping(ui->quickChalRespOptionsHelpBtn, HelpBox::Help_ChalRespOption); mapper->setMapping(ui->quickPvtIdHelpBtn, HelpBox::Help_PrivateID); mapper->setMapping(ui->quickSecretKeyHelpBtn, HelpBox::Help_SecretKey); mapper->setMapping(ui->advConfigHelpBtn, HelpBox::Help_ConfigurationSlot); mapper->setMapping(ui->advChalRespOptionsHelpBtn, HelpBox::Help_ChalRespOption); mapper->setMapping(ui->advSecretKeyHelpBtn, HelpBox::Help_SecretKey); //Connect the mapper connect(mapper, SIGNAL(mapped(int)), this, SIGNAL(showHelp(int))); connect(ui->quickConfigProtectionBox, SIGNAL(showHelp(int)), this, SIGNAL(showHelp(int))); connect(ui->advConfigProtectionBox, SIGNAL(showHelp(int)), this, SIGNAL(showHelp(int))); }
void RPCConsole::setClientModel(ClientModel *model) { clientModel = model; ui->trafficGraph->setClientModel(model); if (model && clientModel->getPeerTableModel() && clientModel->getBanTableModel()) { // Subscribe to information, replies, messages, errors connect(model, SIGNAL(numConnectionsChanged(int)), this, SLOT(setNumConnections(int))); setNumBlocks(model->getNumBlocks()); connect(model, SIGNAL(numBlocksChanged(int)), this, SLOT(setNumBlocks(int))); setMasternodeCount(model->getMasternodeCountString()); connect(model, SIGNAL(strMasternodesChanged(QString)), this, SLOT(setMasternodeCount(QString))); 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); // create 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->clientName->setText(model->clientName()); ui->buildDate->setText(model->formatBuildDate()); ui->startupTime->setText(model->formatClientStartupTime()); setNumConnections(model->getNumConnections()); ui->isTestNet->setChecked(model->isTestNet()); }
ScriptDebugger::ScriptDebugger(const MODELMAP &models, QStandardItemModel *triggerModel) : QDialog(NULL, Qt::Window) { modelMap = models; QSignalMapper *signalMapper = new QSignalMapper(this); // Add globals for (MODELMAP::const_iterator i = models.constBegin(); i != models.constEnd(); ++i) { QWidget *dummyWidget = new QWidget(this); QScriptEngine *engine = i.key(); QStandardItemModel *m = i.value(); m->setParent(this); // take ownership to avoid memory leaks QTreeView *view = new QTreeView(this); view->setSelectionMode(QAbstractItemView::NoSelection); view->setModel(m); QString scriptName = engine->globalObject().property("scriptName").toString(); int player = engine->globalObject().property("me").toInt32(); QLineEdit *lineEdit = new QLineEdit(this); QVBoxLayout *layout = new QVBoxLayout(); QHBoxLayout *layout2 = new QHBoxLayout(); QPushButton *updateButton = new QPushButton("Update", this); QPushButton *button = new QPushButton("Run", this); connect(button, SIGNAL(pressed()), signalMapper, SLOT(map())); connect(updateButton, SIGNAL(pressed()), this, SLOT(updateModels())); signalMapper->setMapping(button, engine); editMap.insert(engine, lineEdit); // store this for slot layout->addWidget(view); layout2->addWidget(updateButton); layout2->addWidget(lineEdit); layout2->addWidget(button); layout->addLayout(layout2); dummyWidget->setLayout(layout); tab.addTab(dummyWidget, scriptName + ":" + QString::number(player)); } connect(signalMapper, SIGNAL(mapped(QObject *)), this, SLOT(runClicked(QObject *))); // Add triggers triggerModel->setParent(this); // take ownership to avoid memory leaks triggerView.setModel(triggerModel); triggerView.resizeColumnToContents(0); triggerView.setSelectionMode(QAbstractItemView::NoSelection); triggerView.setSelectionBehavior(QAbstractItemView::SelectRows); tab.addTab(&triggerView, "Triggers"); // Add labels labelModel = createLabelModel(); labelModel->setParent(this); // take ownership to avoid memory leaks labelView.setModel(labelModel); labelView.resizeColumnToContents(0); labelView.setSelectionMode(QAbstractItemView::SingleSelection); labelView.setSelectionBehavior(QAbstractItemView::SelectRows); connect(&labelView, SIGNAL(doubleClicked(const QModelIndex &)), this, SLOT(labelClickedIdx(const QModelIndex &))); QPushButton *button = new QPushButton("Show", this); connect(button, SIGNAL(pressed()), this, SLOT(labelClicked())); QVBoxLayout *labelLayout = new QVBoxLayout(this); labelLayout->addWidget(&labelView); labelLayout->addWidget(button); QWidget *dummyWidget = new QWidget(this); dummyWidget->setLayout(labelLayout); tab.addTab(dummyWidget, "Labels"); // Set up dialog QHBoxLayout *layout = new QHBoxLayout(this); layout->addWidget(&tab); setLayout(layout); setSizeGripEnabled(true); show(); raise(); activateWindow(); }
StaffTextProperties::StaffTextProperties(const StaffTextBase* st, QWidget* parent) : QDialog(parent) { setObjectName("StaffTextProperties"); setupUi(this); if (st->systemFlag()) { setWindowTitle(tr("System Text Properties")); tabWidget->removeTab(tabWidget->indexOf(tabAeolusStops)); // Aeolus settings for staff text only //if (!enableExperimental) tabWidget->removeTab(tabWidget->indexOf(tabMIDIAction)); tabWidget->removeTab(tabWidget->indexOf(tabChangeChannel)); // Channel switching for staff text only } else { setWindowTitle(tr("Staff Text Properties")); //tabWidget->removeTab(tabWidget->indexOf(tabSwingSettings)); // Swing settings for system text only, could be disabled here, if desired #ifndef AEOLUS tabWidget->removeTab(tabWidget->indexOf(tabAeolusStops)); #endif //if (!enableExperimental) tabWidget->removeTab(tabWidget->indexOf(tabMIDIAction)); } setWindowFlags(this->windowFlags() & ~Qt::WindowContextHelpButtonHint); _staffText = static_cast<StaffTextBase*>(st->clone()); vb[0][0] = voice1_1; vb[0][1] = voice1_2; vb[0][2] = voice1_3; vb[0][3] = voice1_4; vb[1][0] = voice2_1; vb[1][1] = voice2_2; vb[1][2] = voice2_3; vb[1][3] = voice2_4; vb[2][0] = voice3_1; vb[2][1] = voice3_2; vb[2][2] = voice3_3; vb[2][3] = voice3_4; vb[3][0] = voice4_1; vb[3][1] = voice4_2; vb[3][2] = voice4_3; vb[3][3] = voice4_4; channelCombo[0] = channelCombo1; channelCombo[1] = channelCombo2; channelCombo[2] = channelCombo3; channelCombo[3] = channelCombo4; //--------------------------------------------------- // setup "switch channel" //--------------------------------------------------- for (int i = 0; i < 4; ++i) initChannelCombo(channelCombo[i], _staffText); Part* part = _staffText->staff()->part(); int tick = static_cast<Segment*>(st->parent())->tick(); int n = part->instrument(tick)->channel().size(); int rows = 0; for (int voice = 0; voice < VOICES; ++voice) { if (_staffText->channelName(voice).isEmpty()) continue; for (int i = 0; i < n; ++i) { const Channel* a = part->instrument(tick)->channel(i); if (a->name != _staffText->channelName(voice)) continue; int row = 0; for (row = 0; row < rows; ++row) { if (channelCombo[row]->currentIndex() == i) { vb[voice][row]->setChecked(true); break; } } if (row == rows) { vb[voice][rows]->setChecked(true); channelCombo[row]->setCurrentIndex(i); ++rows; } break; } } QSignalMapper* mapper = new QSignalMapper(this); for (int row = 0; row < 4; ++row) { for (int col = 0; col < 4; ++col) { connect(vb[col][row], SIGNAL(clicked()), mapper, SLOT(map())); mapper->setMapping(vb[col][row], (col << 8) + row); } } if (_staffText->swing()) { setSwingBox->setChecked(true); if (_staffText->swingParameters()->swingUnit == MScore::division/2) { swingBox->setEnabled(true); swingEighth->setChecked(true); swingBox->setValue(_staffText->swingParameters()->swingRatio); } else if (_staffText->swingParameters()->swingUnit == MScore::division/4) { swingBox->setEnabled(true); swingSixteenth->setChecked(true); swingBox->setValue(_staffText->swingParameters()->swingRatio); } else if (_staffText->swingParameters()->swingUnit == 0) { swingBox->setEnabled(false); SwingOff->setChecked(true); swingBox->setValue(_staffText->swingParameters()->swingRatio); } } connect(mapper, SIGNAL(mapped(int)), SLOT(voiceButtonClicked(int))); connect(SwingOff, SIGNAL(toggled(bool)), SLOT(setSwingControls(bool))); connect(swingEighth, SIGNAL(toggled(bool)), SLOT(setSwingControls(bool))); connect(swingSixteenth, SIGNAL(toggled(bool)), SLOT(setSwingControls(bool))); //--------------------------------------------------- // setup midi actions //--------------------------------------------------- QTreeWidgetItem* selectedItem = 0; for (int i = 0; i < n; ++i) { const Channel* a = part->instrument(tick)->channel(i); QTreeWidgetItem* item = new QTreeWidgetItem(channelList); item->setData(0, Qt::UserRole, i); if (a->name.isEmpty() || a->name == "normal") item->setText(0, tr("normal")); else item->setText(0, qApp->translate("InstrumentsXML", a->name.toUtf8().data())); item->setText(1, qApp->translate("InstrumentsXML", a->descr.toUtf8().data())); if (i == 0) selectedItem = item; } connect(channelList, SIGNAL(currentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*)), SLOT(channelItemChanged(QTreeWidgetItem*, QTreeWidgetItem*))); connect(this, SIGNAL(accepted()), SLOT(saveValues())); channelList->setCurrentItem(selectedItem); //--------------------------------------------------- // setup aeolus stops //--------------------------------------------------- changeStops->setChecked(_staffText->setAeolusStops()); for (int i = 0; i < 4; ++i) { for (int k = 0; k < 16; ++k) stops[i][k] = 0; } stops[0][0] = stop_3_0; stops[0][1] = stop_3_1; stops[0][2] = stop_3_2; stops[0][3] = stop_3_3; stops[0][4] = stop_3_4; stops[0][5] = stop_3_5; stops[0][6] = stop_3_6; stops[0][7] = stop_3_7; stops[0][8] = stop_3_8; stops[0][9] = stop_3_9; stops[0][10] = stop_3_10; stops[0][11] = stop_3_11; stops[1][0] = stop_2_0; stops[1][1] = stop_2_1; stops[1][2] = stop_2_2; stops[1][3] = stop_2_3; stops[1][4] = stop_2_4; stops[1][5] = stop_2_5; stops[1][6] = stop_2_6; stops[1][7] = stop_2_7; stops[1][8] = stop_2_8; stops[1][9] = stop_2_9; stops[1][10] = stop_2_10; stops[1][11] = stop_2_11; stops[1][12] = stop_2_12; stops[2][0] = stop_1_0; stops[2][1] = stop_1_1; stops[2][2] = stop_1_2; stops[2][3] = stop_1_3; stops[2][4] = stop_1_4; stops[2][5] = stop_1_5; stops[2][6] = stop_1_6; stops[2][7] = stop_1_7; stops[2][8] = stop_1_8; stops[2][9] = stop_1_9; stops[2][10] = stop_1_10; stops[2][11] = stop_1_11; stops[2][12] = stop_1_12; stops[2][13] = stop_1_13; stops[2][14] = stop_1_14; stops[2][15] = stop_1_15; stops[3][0] = stop_p_0; stops[3][1] = stop_p_1; stops[3][2] = stop_p_2; stops[3][3] = stop_p_3; stops[3][4] = stop_p_4; stops[3][5] = stop_p_5; stops[3][6] = stop_p_6; stops[3][7] = stop_p_7; stops[3][8] = stop_p_8; stops[3][9] = stop_p_9; stops[3][10] = stop_p_10; stops[3][11] = stop_p_11; stops[3][12] = stop_p_12; stops[3][13] = stop_p_13; stops[3][14] = stop_p_14; stops[3][15] = stop_p_15; curTabIndex = tabWidget->currentIndex(); connect(tabWidget, SIGNAL(currentChanged(int)), SLOT(tabChanged(int))); MuseScore::restoreGeometry(this); }
void Xaman::menuMusica(const QPoint &pos) { //Menu desplegable de musica con sus correspondientes opciones QTreeWidgetItem *nd = ui->Content_Musica->itemAt(pos); if(nd){ //Configuracion de las opciones del menu QAction *newAct = new QAction(tr("&Añadir a Reproduccion"), this); newAct->setStatusTip(tr("new sth")); QAction *newAct1 = new QAction(tr("&Agregar"), this); newAct1->setStatusTip(tr("new sth")); QSignalMapper *sigmapper = new QSignalMapper(this); connect(newAct, SIGNAL(triggered(bool)), sigmapper, SLOT(map())); sigmapper->setMapping(newAct,"Reproducir,Musica/" + nd->text(0)); connect(sigmapper, SIGNAL(mapped(QString)), this, SLOT(reproducirContenido(QString))); //Agregar las opciones al menu desplegable QMenu menu(this); menu.addAction(newAct); menu.addAction(newAct1); //Submenu de la parte de reproduccion QMenu menu2(this); QDomDocument playlist; QFile file (QDir::currentPath() + "/PlayList/ListasdeReproduccion.xml"); if(!file.open(QIODevice::ReadOnly | QIODevice::Text)){ //return -1; }else{ if(!playlist.setContent(&file)){ //return -1; } file.close(); } QDomElement root = playlist.firstChildElement(); QDomNodeList items= root.elementsByTagName("List"); QSignalMapper *mapper = new QSignalMapper(this); int cont=1; for(int i=0; i< items.count();i++){ QDomNode itemnode =items.at(i); if(itemnode.isElement()){ QDomElement element = itemnode.toElement(); QAction *act = new QAction(element.attribute("name"), this); connect(act, SIGNAL(triggered(bool)), mapper, SLOT(map())); mapper->setMapping(act, element.attribute("name") + "," + QDir::currentPath() + "/Content/Musica/" + nd->text(0)); if(cont==1){ connect(mapper, SIGNAL(mapped(QString)), this, SLOT(addToList(QString))); cont++; } menu2.addAction(act); } } //Agregar el submenu newAct1->setMenu(&menu2); //Posicionamiento del menu de acuerdo al posicionamiento del item en la pantalla QPoint pt(pos); menu.exec( ui->Content_Shows->mapToGlobal(pos) ); } }
Calculator::Calculator(QWidget *parent) : QWidget(parent), ui(new Ui::Calculator), memory(0), result(0), currOperand(0), currOper("") { ui->setupUi(this); QSignalMapper *numberPressed = new QSignalMapper(this); { QObject::connect(ui->n0Button, SIGNAL(clicked()), numberPressed, SLOT(map())); QObject::connect(ui->n1Button, SIGNAL(clicked()), numberPressed, SLOT(map())); QObject::connect(ui->n2Button, SIGNAL(clicked()), numberPressed, SLOT(map())); QObject::connect(ui->n3Button, SIGNAL(clicked()), numberPressed, SLOT(map())); QObject::connect(ui->n4Button, SIGNAL(clicked()), numberPressed, SLOT(map())); QObject::connect(ui->n5Button, SIGNAL(clicked()), numberPressed, SLOT(map())); QObject::connect(ui->n6Button, SIGNAL(clicked()), numberPressed, SLOT(map())); QObject::connect(ui->n7Button, SIGNAL(clicked()), numberPressed, SLOT(map())); QObject::connect(ui->n8Button, SIGNAL(clicked()), numberPressed, SLOT(map())); QObject::connect(ui->n9Button, SIGNAL(clicked()), numberPressed, SLOT(map())); QObject::connect(ui->nDotButton, SIGNAL(clicked()), numberPressed, SLOT(map())); } { numberPressed->setMapping(ui->n0Button, "0"); numberPressed->setMapping(ui->n1Button, "1"); numberPressed->setMapping(ui->n2Button, "2"); numberPressed->setMapping(ui->n3Button, "3"); numberPressed->setMapping(ui->n4Button, "4"); numberPressed->setMapping(ui->n5Button, "5"); numberPressed->setMapping(ui->n6Button, "6"); numberPressed->setMapping(ui->n7Button, "7"); numberPressed->setMapping(ui->n8Button, "8"); numberPressed->setMapping(ui->n9Button, "9"); numberPressed->setMapping(ui->nDotButton, "."); } QObject::connect(numberPressed, SIGNAL(mapped(QString)), this, SLOT(appendToDisplayString(QString))); QObject::connect(this, SIGNAL(displayStringChanged(QString)), ui->lineEdit, SLOT(setText(QString))); QObject::connect(ui->cClearButton, SIGNAL(clicked()), this, SLOT(clearDisplayString())); QObject::connect(ui->cCEButton, SIGNAL(clicked()), this, SLOT(clearExpression())); QObject::connect(ui->cACButton, SIGNAL(clicked()), this, SLOT(clearAll())); QObject::connect(ui->cBackSpaceButton, SIGNAL(clicked()), this, SLOT(backSpace())); QSignalMapper *operatorPressed = new QSignalMapper; QObject::connect(ui->oDivButton, SIGNAL(clicked()), operatorPressed, SLOT(map())); QObject::connect(ui->oMultButton, SIGNAL(clicked()), operatorPressed, SLOT(map())); QObject::connect(ui->oPlusButton, SIGNAL(clicked()), operatorPressed, SLOT(map())); QObject::connect(ui->oMinusButton, SIGNAL(clicked()), operatorPressed, SLOT(map())); QObject::connect(ui->oEqButton, SIGNAL(clicked()), operatorPressed, SLOT(map())); operatorPressed->setMapping(ui->oDivButton, "/"); operatorPressed->setMapping(ui->oMultButton, "*"); operatorPressed->setMapping(ui->oPlusButton, "+"); operatorPressed->setMapping(ui->oMinusButton, "-"); operatorPressed->setMapping(ui->oEqButton, "="); QObject::connect(operatorPressed, SIGNAL(mapped(QString)), this, SLOT(operButtonPressed(QString))); QObject::connect(ui->nDotButton, SIGNAL(clicked(bool)), ui->nDotButton, SLOT(setEnabled(bool))); QObject::connect(ui->mClearButton, SIGNAL(clicked()), this, SLOT(clearMemory())); QObject::connect(ui->mReadButton, SIGNAL(clicked()), this, SLOT(memoryRead())); QObject::connect(ui->mPlusButton, SIGNAL(clicked()), this, SLOT(memoryAdd())); QObject::connect(ui->mMinusButton, SIGNAL(clicked()), this, SLOT(memoryDec())); }
void Xaman::menuImagenes(const QPoint &pos) { QTreeWidgetItem *nd = ui->Content_Imagenes->itemAt(pos); QAction *newAct = new QAction(tr("&Añadir a Reproduccion"), this); newAct->setStatusTip(tr("new sth")); QAction *newAct1 = new QAction(tr("&Agregar"), this); newAct1->setStatusTip(tr("new sth")); QSignalMapper *sigmapper = new QSignalMapper(this); connect(newAct, SIGNAL(triggered(bool)), sigmapper, SLOT(map())); sigmapper->setMapping(newAct,"Reproducir,Imagenes/" + nd->text(0)); connect(sigmapper, SIGNAL(mapped(QString)), this, SLOT(toAll(QString))); connect(sigmapper, SIGNAL(mapped(QString)), this, SLOT(reproducirContenido(QString))); QMenu menu(this); menu.addAction(newAct); menu.addAction(newAct1); QMenu menu2(this); QDomDocument playlist; QFile file (QDir::currentPath() + "/PlayList/ListasdeReproduccion.xml"); if(!file.open(QIODevice::ReadOnly | QIODevice::Text)){ //return -1; }else{ if(!playlist.setContent(&file)){ //return -1; } file.close(); } QDomElement root = playlist.firstChildElement(); QDomNodeList items= root.elementsByTagName("List"); QSignalMapper *mapper = new QSignalMapper(this); int cont=1; for(int i=0; i< items.count();i++){ QDomNode itemnode =items.at(i); if(itemnode.isElement()){ QDomElement element = itemnode.toElement(); QAction *act = new QAction(element.attribute("name"), this); connect(act, SIGNAL(triggered(bool)), mapper, SLOT(map())); mapper->setMapping(act, element.attribute("name") + "," + QDir::currentPath() + "/Content/Imagenes/" + nd->text(0)); if(cont==1){ connect(mapper, SIGNAL(mapped(QString)), this, SLOT(addToList(QString))); cont++; } menu2.addAction(act); } } newAct1->setMenu(&menu2); QPoint pt(pos); menu.exec( ui->Content_Shows->mapToGlobal(pos) ); }
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(NULL), false); connect(model, SIGNAL(numBlocksChanged(int,QDateTime,double,bool)), this, SLOT(setNumBlocks(int,QDateTime,double,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::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->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(); } autoCompleter = new QCompleter(wordList, this); ui->lineEdit->setCompleter(autoCompleter); autoCompleter->popup()->installEventFilter(this); }
/* * The constructor. The central button is optional, centerIcon and centerTip are the * icon and tooltip for it and can be NULL. size specifies the size of the buttons. * The autoRaise flag is used to set whether the buttons autoraise. A step size label * is optional and provided if stepSize >= 0. */ RotationTool::RotationTool(QWidget *parent, QIcon *centerIcon, const char *centerTip, int size, bool autoRaise, float stepSize) : QWidget(parent) { int ind, row, col; mStepLabel = NULL; mCenterBut = NULL; if (sFirstTime) { for (ind = 0; ind < 8; ind++) { sIcons[ind] = new QIcon(); sIcons[ind]->addFile(QString(sFileList[ind]), QSize(size - 4, size - 4)); } } QHBoxLayout *hLayout = new QHBoxLayout(this); hLayout->setContentsMargins(0, 0, 0, 0); hLayout->setSpacing(0); QVBoxLayout *vLayout = new QVBoxLayout(); hLayout->addLayout(vLayout); vLayout->setContentsMargins(0, 0, 0, 0); vLayout->setSpacing(2); hLayout->addStretch(); // Make the grid and the signal mapper QGridLayout *grid = new QGridLayout(); vLayout->addLayout(grid); grid->setContentsMargins(0, 0, 0, 0); grid->setSpacing(autoRaise ? 0 : 4); QSignalMapper *rotMapper = new QSignalMapper(this); connect(rotMapper, SIGNAL(mapped(int)), this, SLOT(buttonClicked(int))); // Fill the grid ind = 0; for (row = 0; row < 3; row++) { for (col = 0; col < 3; col++) { QToolButton *button = new QToolButton(this); button->setAutoRaise(autoRaise); button->setFixedSize(size, size); button->setFocusPolicy(Qt::NoFocus); grid->addWidget(button, row, col); if (col == 1 && row == 1) { // Set center toggle button properties button->setCheckable(true); button->setChecked(false); mCenterBut = button; if (centerTip) button->setToolTip(centerTip); if (centerIcon) button->setIcon(*centerIcon); connect(mCenterBut, SIGNAL(toggled(bool)), this, SLOT(centerToggled(bool))); } else { // Set rotation button properties and mapping, and autorepeat for non-step ones button->setToolTip(sButtonTips[ind]); button->setIcon(*sIcons[ind]); rotMapper->setMapping(button, ind); connect(button, SIGNAL(clicked()), rotMapper, SLOT(map())); if (!sStepSign[ind]) { button->setAutoRepeat(true); button->setAutoRepeatDelay(300); button->setAutoRepeatInterval(100); } ind++; } }
void _GUI::createActions() { m_helpContents = new QAction( tr( "&Contents" ), this ); m_helpContents->setShortcut( tr( "F1" ) ); m_helpContents->setStatusTip( tr( "Open Online Help For This Game" ) ); connect( m_helpContents, SIGNAL(triggered()), this, SLOT(helpContents()) ); m_helpLikeUs = new QAction( tr( "&Like Us On Facebook!" ), this ); connect( m_helpLikeUs, SIGNAL(triggered()), this, SLOT(helpLikeUs()) ); m_helpAbout = new QAction( tr( "&About" ), this ); m_helpAbout->setStatusTip( tr( "About The Visualizer" ) ); connect( m_helpAbout, SIGNAL(triggered()), this, SLOT(helpAbout()) ); m_fileOpen = new QAction( tr( "&Open" ), this ); m_fileOpen->setShortcut( tr( "Ctrl+O" ) ); m_fileOpen->setStatusTip( tr( "Open A Gamelog" ) ); connect( m_fileOpen, SIGNAL(triggered()), this, SLOT(fileOpen()) ); m_fileSpectate = new QAction( tr( "&Spectate" ), this ); m_fileSpectate->setShortcut( tr( "Ctrl+s" ) ); m_fileSpectate->setStatusTip( tr( "Spectate or Join a Game" ) ); connect( m_fileSpectate, SIGNAL(triggered()), this, SLOT(fileSpectate()) ); toggleFullScreenAct = new QAction( tr("&Full Screen"), this ); toggleFullScreenAct->setShortcut( tr("F11" ) ); toggleFullScreenAct->setStatusTip( tr("Toggle Fullscreen Mode") ); connect( toggleFullScreenAct, SIGNAL(triggered()), this, SLOT(toggleFullScreen()) ); showDebugWindowAct = new QAction( tr("&Show Debug Window"), this ); showDebugWindowAct->setShortcut( tr("Ctrl+d") ); showDebugWindowAct->setStatusTip( tr( "Show the debug window." ) ); connect( showDebugWindowAct, SIGNAL(triggered()), this, SLOT(showDebugWindow()) ); m_editOptions = new QAction( tr( "&Options" ), this ); m_editOptions->setShortcut( tr("F10") ); m_editOptions->setStatusTip( tr( "Edit Program Options" ) ); connect( m_editOptions, SIGNAL( triggered() ), this, SLOT( optionsDialog() ) ); m_fileExit = new QAction( tr( "&Quit" ), this ); m_fileExit->setShortcut( tr( "Ctrl+Q" ) ); m_fileExit->setStatusTip( tr( "Close the Visualizer" ) ); connect( m_fileExit, SIGNAL(triggered()), this, SLOT(close()) ); (void) new QShortcut( QKeySequence( tr( "Space" ) ), this, SLOT( togglePlayPause() ) ); (void) new QShortcut( QKeySequence( tr( "Ctrl+F" ) ), this, SLOT( fastForwardShortcut() ) ); (void) new QShortcut( QKeySequence( tr( "Ctrl+R" ) ), this, SLOT( rewindShortcut() ) ); (void) new QShortcut( QKeySequence( tr( "Right" ) ), this, SLOT( stepTurnForwardShortcut() ) ); (void) new QShortcut( QKeySequence( tr( "Left" ) ), this, SLOT( stepTurnBackShortcut() ) ); (void) new QShortcut( QKeySequence( tr("Escape") ), this, SLOT( catchEscapeKey() ) ); QSignalMapper* mapper = new QSignalMapper(this); QShortcut *cut; for( size_t i = 0; i < 10; i++ ) { cut = new QShortcut( QKeySequence( Qt::Key_0+i ), this ); mapper->setMapping( cut, i-1 ); connect( cut, SIGNAL( activated() ), mapper, SLOT( map() ) ); } connect( mapper, SIGNAL( mapped( int ) ), this, SLOT( turnPercentageCalc(int) ) ); }
LightingsControl::LightingsControl(QWidget *parent, Qt::WindowFlags f) : QWidget(parent, f), ui(new Ui::LightingsControl) { qDebug() << "LightingsControl::LightingsControl"; ui->setupUi(this); QPixmap normalPixmap; QPixmap activePixmap; QPalette pal; normalPixmap.load(":/hac01/images/button-background-normal-128x64.png"); activePixmap.load(":/hac01/images/button-background-active-128x64.png"); pal = ui->allOnButton->palette(); pal.setBrush(QPalette::Button, normalPixmap); pal.setBrush(QPalette::Light, activePixmap); ui->allOnButton->setPalette(pal); ui->allOnButton->setPaletteBrushPanel(true); pal = ui->allOffButton->palette(); pal.setBrush(QPalette::Button, normalPixmap); pal.setBrush(QPalette::Light, activePixmap); ui->allOffButton->setPalette(pal); ui->allOffButton->setPaletteBrushPanel(true); normalPixmap.load(":/hac01/images/button-background-normal-64x128.png"); activePixmap.load(":/hac01/images/button-background-active-64x128.png"); pal = ui->singleOnButton->palette(); pal.setBrush(QPalette::Button, normalPixmap); pal.setBrush(QPalette::Light, activePixmap); ui->singleOnButton->setPalette(pal); ui->singleOnButton->setPaletteBrushPanel(true); pal = ui->singleOffButton->palette(); pal.setBrush(QPalette::Button, normalPixmap); pal.setBrush(QPalette::Light, activePixmap); ui->singleOffButton->setPalette(pal); ui->singleOffButton->setPaletteBrushPanel(true); normalPixmap.load(":/hac01/images/button-background-normal-32x32.png"); activePixmap.load(":/hac01/images/button-background-active-32x32.png"); pal = ui->pushButton_1->palette(); pal.setBrush(QPalette::Button, normalPixmap); pal.setBrush(QPalette::Light, activePixmap); ui->pushButton_1->setPalette(pal); ui->pushButton_1->setPaletteBrushPanel(true); pal = ui->pushButton_2->palette(); pal.setBrush(QPalette::Button, normalPixmap); pal.setBrush(QPalette::Light, activePixmap); ui->pushButton_2->setPalette(pal); ui->pushButton_2->setPaletteBrushPanel(true); pal = ui->pushButton_3->palette(); pal.setBrush(QPalette::Button, normalPixmap); pal.setBrush(QPalette::Light, activePixmap); ui->pushButton_3->setPalette(pal); ui->pushButton_3->setPaletteBrushPanel(true); pal = ui->pushButton_4->palette(); pal.setBrush(QPalette::Button, normalPixmap); pal.setBrush(QPalette::Light, activePixmap); ui->pushButton_4->setPalette(pal); ui->pushButton_4->setPaletteBrushPanel(true); pal = ui->pushButton_5->palette(); pal.setBrush(QPalette::Button, normalPixmap); pal.setBrush(QPalette::Light, activePixmap); ui->pushButton_5->setPalette(pal); ui->pushButton_5->setPaletteBrushPanel(true); pal = ui->pushButton_6->palette(); pal.setBrush(QPalette::Button, normalPixmap); pal.setBrush(QPalette::Light, activePixmap); ui->pushButton_6->setPalette(pal); ui->pushButton_6->setPaletteBrushPanel(true); pal = ui->pushButton_7->palette(); pal.setBrush(QPalette::Button, normalPixmap); pal.setBrush(QPalette::Light, activePixmap); ui->pushButton_7->setPalette(pal); ui->pushButton_7->setPaletteBrushPanel(true); pal = ui->pushButton_8->palette(); pal.setBrush(QPalette::Button, normalPixmap); pal.setBrush(QPalette::Light, activePixmap); ui->pushButton_8->setPalette(pal); ui->pushButton_8->setPaletteBrushPanel(true); pal = ui->pushButton_9->palette(); pal.setBrush(QPalette::Button, normalPixmap); pal.setBrush(QPalette::Light, activePixmap); ui->pushButton_9->setPalette(pal); ui->pushButton_9->setPaletteBrushPanel(true); pal = ui->pushButton_10->palette(); pal.setBrush(QPalette::Button, normalPixmap); pal.setBrush(QPalette::Light, activePixmap); ui->pushButton_10->setPalette(pal); ui->pushButton_10->setPaletteBrushPanel(true); pal = ui->pushButton_11->palette(); pal.setBrush(QPalette::Button, normalPixmap); pal.setBrush(QPalette::Light, activePixmap); ui->pushButton_11->setPalette(pal); ui->pushButton_11->setPaletteBrushPanel(true); pal = ui->pushButton_12->palette(); pal.setBrush(QPalette::Button, normalPixmap); pal.setBrush(QPalette::Light, activePixmap); ui->pushButton_12->setPalette(pal); ui->pushButton_12->setPaletteBrushPanel(true); /* QIcon icon; icon.addFile(":/HAC01/button-background-normal-128x64.png", QSize(), QIcon::Normal); icon.addFile(":/HAC01/button-background-active-128x64.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-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-32x32.png", QSize(), QIcon::Normal); icon.addFile(":/HAC01/button-background-active-32x32.png", QSize(), QIcon::Active); if (!icon.isNull()) { ui->pushButton_1->setAutoFillBackground(false); ui->pushButton_1->setBackgroundIcon(icon); ui->pushButton_2->setAutoFillBackground(false); ui->pushButton_2->setBackgroundIcon(icon); ui->pushButton_3->setAutoFillBackground(false); ui->pushButton_3->setBackgroundIcon(icon); ui->pushButton_4->setAutoFillBackground(false); ui->pushButton_4->setBackgroundIcon(icon); ui->pushButton_5->setAutoFillBackground(false); ui->pushButton_5->setBackgroundIcon(icon); ui->pushButton_6->setAutoFillBackground(false); ui->pushButton_6->setBackgroundIcon(icon); ui->pushButton_7->setAutoFillBackground(false); ui->pushButton_7->setBackgroundIcon(icon); ui->pushButton_8->setAutoFillBackground(false); ui->pushButton_8->setBackgroundIcon(icon); ui->pushButton_9->setAutoFillBackground(false); ui->pushButton_9->setBackgroundIcon(icon); ui->pushButton_10->setAutoFillBackground(false); ui->pushButton_10->setBackgroundIcon(icon); ui->pushButton_11->setAutoFillBackground(false); ui->pushButton_11->setBackgroundIcon(icon); ui->pushButton_12->setAutoFillBackground(false); ui->pushButton_12->setBackgroundIcon(icon); } else { qDebug() << "Can not found button-background-32x32.png"; } */ QSignalMapper *buttonsSignalMapper = new QSignalMapper(this); connect(ui->pushButton_1, SIGNAL(clicked()), buttonsSignalMapper, SLOT(map())); buttonsSignalMapper->setMapping(ui->pushButton_1, ui->pushButton_1->objectName()); connect(ui->pushButton_2, SIGNAL(clicked()), buttonsSignalMapper, SLOT(map())); buttonsSignalMapper->setMapping(ui->pushButton_2, ui->pushButton_2->objectName()); connect(ui->pushButton_3, SIGNAL(clicked()), buttonsSignalMapper, SLOT(map())); buttonsSignalMapper->setMapping(ui->pushButton_3, ui->pushButton_3->objectName()); connect(ui->pushButton_4, SIGNAL(clicked()), buttonsSignalMapper, SLOT(map())); buttonsSignalMapper->setMapping(ui->pushButton_4, ui->pushButton_4->objectName()); connect(ui->pushButton_5, SIGNAL(clicked()), buttonsSignalMapper, SLOT(map())); buttonsSignalMapper->setMapping(ui->pushButton_5, ui->pushButton_5->objectName()); connect(ui->pushButton_6, SIGNAL(clicked()), buttonsSignalMapper, SLOT(map())); buttonsSignalMapper->setMapping(ui->pushButton_6, ui->pushButton_6->objectName()); connect(ui->pushButton_7, SIGNAL(clicked()), buttonsSignalMapper, SLOT(map())); buttonsSignalMapper->setMapping(ui->pushButton_7, ui->pushButton_7->objectName()); connect(ui->pushButton_8, SIGNAL(clicked()), buttonsSignalMapper, SLOT(map())); buttonsSignalMapper->setMapping(ui->pushButton_8, ui->pushButton_8->objectName()); connect(ui->pushButton_9, SIGNAL(clicked()), buttonsSignalMapper, SLOT(map())); buttonsSignalMapper->setMapping(ui->pushButton_9, ui->pushButton_9->objectName()); connect(ui->pushButton_10, SIGNAL(clicked()), buttonsSignalMapper, SLOT(map())); buttonsSignalMapper->setMapping(ui->pushButton_10, ui->pushButton_10->objectName()); connect(ui->pushButton_11, SIGNAL(clicked()), buttonsSignalMapper, SLOT(map())); buttonsSignalMapper->setMapping(ui->pushButton_11, ui->pushButton_11->objectName()); connect(ui->pushButton_12, SIGNAL(clicked()), buttonsSignalMapper, SLOT(map())); buttonsSignalMapper->setMapping(ui->pushButton_12, ui->pushButton_12->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 &))); }
// ---------------------------------------------------------------------------- // CReporterSendSelectedDialog::createcontent // ---------------------------------------------------------------------------- void CReporterSendSelectedDialog::createcontent() { Q_D(CReporterSendSelectedDialog); setObjectName("CrashReporterSendSelectedDialog"); int nbrOfFiles = d_ptr->files.count(); QString message; if (nbrOfFiles == 1) { //% "<p>This system has 1 stored crash report. Select reports to send to %1 for analysis or to delete.</p>" message = qtTrId("qtn_system_has_1_crash_report_send_to_%s").arg(d->server); } else { //% "<p>This system has %1 stored crash reports. Select reports to send to %2 for analysis or to delete.</p>" message = qtTrId("qtn_system_has_%1_crash_reports_send_to_%2").arg(nbrOfFiles).arg(d->server); } // Create content to be placed on central widget. QGraphicsWidget *panel = centralWidget(); // Create layout and policy. MLayout *layout = new MLayout(panel); layout->setContentsMargins(0,0,0,0); panel->setLayout(layout); MLinearLayoutPolicy *policy = new MLinearLayoutPolicy(layout, Qt::Vertical); policy->setObjectName("DialogMainLayout"); // Create message label and hack it to support wordwrapping MLabel *messagelabel = new MLabel(message, panel); messagelabel->setWordWrap(true); messagelabel->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred); messagelabel->setObjectName("DialogMessageLabel"); messagelabel->setStyleName("CommonFieldLabelInverted"); d->list = new MList(panel); d->cellCreator = new MContentItemCreator; d->list->setCellCreator(d->cellCreator); d->model = new CReporterSendFileListModel(d->files); d->list->setItemModel(d->model); d->list->setSelectionMode(MList::MultiSelection); // Add widgets to the layout policy->addItem(messagelabel, Qt::AlignLeft | Qt::AlignTop); policy->addItem(d->list, Qt::AlignLeft | Qt::AlignTop); // Add buttons to button area. QSignalMapper *mapper = new QSignalMapper(this); //% "Send Selected" MButton* dialogButton = new MButton(qtTrId("qtn_send_selected_button")); dialogButton->setStyleName("CommonSingleButtonInverted"); policy->addItem(dialogButton, Qt::AlignCenter); // MButtonModel *dialogButton = addButton(qtTrId("qtn_send_selected_button"), M::ActionRole); connect(dialogButton, SIGNAL(clicked()), mapper, SLOT(map())); mapper->setMapping(dialogButton, static_cast<int>(CReporter::SendSelectedButton)); //% "Send All" dialogButton = new MButton(qtTrId("qtn_send_all_button")); dialogButton->setStyleName("CommonSingleButtonInverted"); policy->addItem(dialogButton, Qt::AlignCenter); // dialogButton = addButton(qtTrId("qtn_send_all_button"), M::ActionRole); connect(dialogButton, SIGNAL(clicked()), mapper, SLOT(map())); mapper->setMapping(dialogButton, static_cast<int>(CReporter::SendAllButton)); //% "Delete Selected" dialogButton = new MButton(qtTrId("qtn_delete_selected_button")); dialogButton->setStyleName("CommonSingleButtonInverted"); policy->addItem(dialogButton, Qt::AlignCenter); // dialogButton = addButton(qtTrId("qtn_delete_selected_button"), M::DestructiveRole); connect(dialogButton, SIGNAL(clicked()), mapper, SLOT(map())); mapper->setMapping(dialogButton, static_cast<int>(CReporter::DeleteSelectedButton)); connect(mapper, SIGNAL(mapped(int)), SIGNAL(actionPerformed(int))); connect(mapper, SIGNAL(mapped(int)), SLOT(accept())); }
WaveEdit::WaveEdit(MusECore::PartList* pl, QWidget* parent, const char* name) : MidiEditor(TopWin::WAVE, 1, pl, parent, name) { setFocusPolicy(Qt::NoFocus); colorMode = colorModeInit; QSignalMapper* mapper = new QSignalMapper(this); QSignalMapper* colorMapper = new QSignalMapper(this); QAction* act; //---------Pulldown Menu---------------------------- // We probably don't need an empty menu - Orcan //QMenu* menuFile = menuBar()->addMenu(tr("&File")); QMenu* menuEdit = menuBar()->addMenu(tr("&Edit")); menuFunctions = menuBar()->addMenu(tr("Func&tions")); menuGain = menuFunctions->addMenu(tr("&Gain")); act = menuGain->addAction("200%"); mapper->setMapping(act, WaveCanvas::CMD_GAIN_200); connect(act, SIGNAL(triggered()), mapper, SLOT(map())); act = menuGain->addAction("150%"); mapper->setMapping(act, WaveCanvas::CMD_GAIN_150); connect(act, SIGNAL(triggered()), mapper, SLOT(map())); act = menuGain->addAction("75%"); mapper->setMapping(act, WaveCanvas::CMD_GAIN_75); connect(act, SIGNAL(triggered()), mapper, SLOT(map())); act = menuGain->addAction("50%"); mapper->setMapping(act, WaveCanvas::CMD_GAIN_50); connect(act, SIGNAL(triggered()), mapper, SLOT(map())); act = menuGain->addAction("25%"); mapper->setMapping(act, WaveCanvas::CMD_GAIN_25); connect(act, SIGNAL(triggered()), mapper, SLOT(map())); act = menuGain->addAction(tr("Other")); mapper->setMapping(act, WaveCanvas::CMD_GAIN_FREE); connect(act, SIGNAL(triggered()), mapper, SLOT(map())); connect(mapper, SIGNAL(mapped(int)), this, SLOT(cmd(int))); menuFunctions->addSeparator(); copyAction = menuEdit->addAction(tr("&Copy")); mapper->setMapping(copyAction, WaveCanvas::CMD_EDIT_COPY); connect(copyAction, SIGNAL(triggered()), mapper, SLOT(map())); copyPartRegionAction = menuEdit->addAction(tr("&Create Part from Region")); mapper->setMapping(copyPartRegionAction, WaveCanvas::CMD_CREATE_PART_REGION); connect(copyPartRegionAction, SIGNAL(triggered()), mapper, SLOT(map())); cutAction = menuEdit->addAction(tr("C&ut")); mapper->setMapping(cutAction, WaveCanvas::CMD_EDIT_CUT); connect(cutAction, SIGNAL(triggered()), mapper, SLOT(map())); pasteAction = menuEdit->addAction(tr("&Paste")); mapper->setMapping(pasteAction, WaveCanvas::CMD_EDIT_PASTE); connect(pasteAction, SIGNAL(triggered()), mapper, SLOT(map())); act = menuEdit->addAction(tr("Edit in E&xternal Editor")); mapper->setMapping(act, WaveCanvas::CMD_EDIT_EXTERNAL); connect(act, SIGNAL(triggered()), mapper, SLOT(map())); menuEdit->addSeparator(); // REMOVE Tim. Also remove CMD_ADJUST_WAVE_OFFSET and so on... // adjustWaveOffsetAction = menuEdit->addAction(tr("Adjust wave offset...")); // mapper->setMapping(adjustWaveOffsetAction, WaveCanvas::CMD_ADJUST_WAVE_OFFSET); // connect(adjustWaveOffsetAction, SIGNAL(triggered()), mapper, SLOT(map())); act = menuFunctions->addAction(tr("Mute Selection")); mapper->setMapping(act, WaveCanvas::CMD_MUTE); connect(act, SIGNAL(triggered()), mapper, SLOT(map())); act = menuFunctions->addAction(tr("Normalize Selection")); mapper->setMapping(act, WaveCanvas::CMD_NORMALIZE); connect(act, SIGNAL(triggered()), mapper, SLOT(map())); act = menuFunctions->addAction(tr("Fade In Selection")); mapper->setMapping(act, WaveCanvas::CMD_FADE_IN); connect(act, SIGNAL(triggered()), mapper, SLOT(map())); act = menuFunctions->addAction(tr("Fade Out Selection")); mapper->setMapping(act, WaveCanvas::CMD_FADE_OUT); connect(act, SIGNAL(triggered()), mapper, SLOT(map())); act = menuFunctions->addAction(tr("Reverse Selection")); mapper->setMapping(act, WaveCanvas::CMD_REVERSE); connect(act, SIGNAL(triggered()), mapper, SLOT(map())); select = menuEdit->addMenu(QIcon(*selectIcon), tr("Select")); selectAllAction = select->addAction(QIcon(*select_allIcon), tr("Select &All")); mapper->setMapping(selectAllAction, WaveCanvas::CMD_SELECT_ALL); connect(selectAllAction, SIGNAL(triggered()), mapper, SLOT(map())); selectNoneAction = select->addAction(QIcon(*select_allIcon), tr("&Deselect All")); mapper->setMapping(selectNoneAction, WaveCanvas::CMD_SELECT_NONE); connect(selectNoneAction, SIGNAL(triggered()), mapper, SLOT(map())); select->addSeparator(); selectPrevPartAction = select->addAction(QIcon(*select_all_parts_on_trackIcon), tr("&Previous Part")); mapper->setMapping(selectPrevPartAction, WaveCanvas::CMD_SELECT_PREV_PART); connect(selectPrevPartAction, SIGNAL(triggered()), mapper, SLOT(map())); selectNextPartAction = select->addAction(QIcon(*select_all_parts_on_trackIcon), tr("&Next Part")); mapper->setMapping(selectNextPartAction, WaveCanvas::CMD_SELECT_NEXT_PART); connect(selectNextPartAction, SIGNAL(triggered()), mapper, SLOT(map())); QMenu* settingsMenu = menuBar()->addMenu(tr("Window &Config")); eventColor = settingsMenu->addMenu(tr("&Event Color")); QActionGroup* actgrp = new QActionGroup(this); actgrp->setExclusive(true); evColorNormalAction = actgrp->addAction(tr("&Part colors")); evColorNormalAction->setCheckable(true); colorMapper->setMapping(evColorNormalAction, 0); evColorPartsAction = actgrp->addAction(tr("&Gray")); evColorPartsAction->setCheckable(true); colorMapper->setMapping(evColorPartsAction, 1); connect(evColorNormalAction, SIGNAL(triggered()), colorMapper, SLOT(map())); connect(evColorPartsAction, SIGNAL(triggered()), colorMapper, SLOT(map())); eventColor->addActions(actgrp->actions()); connect(colorMapper, SIGNAL(mapped(int)), this, SLOT(eventColorModeChanged(int))); settingsMenu->addSeparator(); settingsMenu->addAction(subwinAction); settingsMenu->addAction(shareAction); settingsMenu->addAction(fullscreenAction); connect(MusEGlobal::muse, SIGNAL(configChanged()), SLOT(configChanged())); //-------------------------------------------------- // ToolBar: Solo Cursor1 Cursor2 tools2 = new MusEGui::EditToolBar(this, waveEditTools); addToolBar(tools2); addToolBarBreak(); tb1 = addToolBar(tr("WaveEdit tools")); tb1->setObjectName("WaveEdit tools"); //tb1->setLabel(tr("weTools")); solo = new QToolButton(); solo->setText(tr("Solo")); solo->setCheckable(true); solo->setFocusPolicy(Qt::NoFocus); tb1->addWidget(solo); connect(solo, SIGNAL(toggled(bool)), SLOT(soloChanged(bool))); QLabel* label = new QLabel(tr("Cursor")); tb1->addWidget(label); label->setAlignment(Qt::AlignRight|Qt::AlignVCenter); label->setIndent(3); pos1 = new PosLabel(0); pos1->setFixedHeight(22); tb1->addWidget(pos1); pos2 = new PosLabel(0); pos2->setFixedHeight(22); pos2->setSmpte(true); tb1->addWidget(pos2); //--------------------------------------------------- // Rest //--------------------------------------------------- int yscale = 256; int xscale; if (!parts()->empty()) { // Roughly match total size of part MusECore::Part* firstPart = parts()->begin()->second; xscale = 0 - firstPart->lenFrame()/_widthInit[_type]; } else { xscale = -8000; } hscroll = new ScrollScale(-32768, 1, xscale, 10000, Qt::Horizontal, mainw, 0, false, 10000.0); //view = new WaveView(this, mainw, xscale, yscale); canvas = new WaveCanvas(this, mainw, xscale, yscale); //wview = canvas; // HACK! QSizeGrip* corner = new QSizeGrip(mainw); ymag = new QSlider(Qt::Vertical, mainw); ymag->setMinimum(1); ymag->setMaximum(256); ymag->setPageStep(256); ymag->setValue(yscale); ymag->setFocusPolicy(Qt::NoFocus); time = new MTScale(&_raster, mainw, xscale, true); ymag->setFixedWidth(16); connect(canvas, SIGNAL(mouseWheelMoved(int)), this, SLOT(moveVerticalSlider(int))); connect(ymag, SIGNAL(valueChanged(int)), canvas, SLOT(setYScale(int))); connect(canvas, SIGNAL(horizontalZoom(bool, const QPoint&)), SLOT(horizontalZoom(bool, const QPoint&))); connect(canvas, SIGNAL(horizontalZoom(int, const QPoint&)), SLOT(horizontalZoom(int, const QPoint&))); time->setOrigin(0, 0); mainGrid->setRowStretch(0, 100); mainGrid->setColumnStretch(0, 100); mainGrid->addWidget(time, 0, 0, 1, 2); mainGrid->addWidget(MusECore::hLine(mainw), 1, 0, 1, 2); mainGrid->addWidget(canvas, 2, 0); mainGrid->addWidget(ymag, 2, 1); mainGrid->addWidget(hscroll, 3, 0); mainGrid->addWidget(corner, 3, 1, Qt::AlignBottom | Qt::AlignRight); canvas->setFocus(); connect(canvas, SIGNAL(toolChanged(int)), tools2, SLOT(set(int))); connect(tools2, SIGNAL(toolChanged(int)), canvas, SLOT(setTool(int))); connect(hscroll, SIGNAL(scrollChanged(int)), canvas, SLOT(setXPos(int))); connect(hscroll, SIGNAL(scaleChanged(int)), canvas, SLOT(setXMag(int))); setWindowTitle(canvas->getCaption()); connect(canvas, SIGNAL(followEvent(int)), hscroll, SLOT(setOffset(int))); connect(hscroll, SIGNAL(scrollChanged(int)), time, SLOT(setXPos(int))); connect(hscroll, SIGNAL(scaleChanged(int)), time, SLOT(setXMag(int))); connect(time, SIGNAL(timeChanged(unsigned)), SLOT(timeChanged(unsigned))); connect(canvas, SIGNAL(timeChanged(unsigned)), SLOT(setTime(unsigned))); connect(canvas, SIGNAL(horizontalScroll(unsigned)),hscroll, SLOT(setPos(unsigned))); connect(canvas, SIGNAL(horizontalScrollNoLimit(unsigned)),hscroll, SLOT(setPosNoLimit(unsigned))); connect(hscroll, SIGNAL(scaleChanged(int)), SLOT(updateHScrollRange())); connect(MusEGlobal::song, SIGNAL(songChanged(MusECore::SongChangedFlags_t)), SLOT(songChanged1(MusECore::SongChangedFlags_t))); // For the wave editor, let's start with the operation range selection tool. canvas->setTool(MusEGui::RangeTool); tools2->set(MusEGui::RangeTool); setEventColorMode(colorMode); initShortcuts(); updateHScrollRange(); configChanged(); if(!parts()->empty()) { MusECore::WavePart* part = (MusECore::WavePart*)(parts()->begin()->second); solo->setChecked(part->track()->solo()); } initTopwinState(); finalizeInit(); }
PointViewerMainWindow::PointViewerMainWindow(const QGLFormat& format) : m_progressBar(0), m_pointView(0), m_shaderEditor(0), m_helpDialog(0), m_logTextView(0), m_maxPointCount(200*1000*1000), // 200 million m_geometries(0), m_ipcServer(0), m_hookManager(0) { #ifndef _WIN32 setWindowIcon(QIcon(":resource/icons/hicolor/256x256/apps/displaz.png")); #else // On windows, application icon is set via windows resource file #endif setWindowTitle("Displaz"); setAcceptDrops(true); m_helpDialog = new HelpDialog(this); m_geometries = new GeometryCollection(this); connect(m_geometries, SIGNAL(layoutChanged()), this, SLOT(updateTitle())); connect(m_geometries, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(updateTitle())); connect(m_geometries, SIGNAL(rowsInserted(QModelIndex,int,int)), this, SLOT(updateTitle())); connect(m_geometries, SIGNAL(rowsRemoved(QModelIndex,int,int)), this, SLOT(updateTitle())); //-------------------------------------------------- // Set up file loader in a separate thread // // Some subtleties regarding qt thread usage are discussed here: // http://mayaposch.wordpress.com/2011/11/01/how-to-really-truly-use-qthreads-the-full-explanation // // Main point: each QObject has a thread affinity which determines which // thread its slots will execute on, when called via a connected signal. QThread* loaderThread = new QThread(); m_fileLoader = new FileLoader(m_maxPointCount); m_fileLoader->moveToThread(loaderThread); connect(loaderThread, SIGNAL(finished()), m_fileLoader, SLOT(deleteLater())); connect(loaderThread, SIGNAL(finished()), loaderThread, SLOT(deleteLater())); //connect(m_fileLoader, SIGNAL(finished()), this, SIGNAL(fileLoadFinished())); connect(m_fileLoader, SIGNAL(geometryLoaded(std::shared_ptr<Geometry>, bool, bool)), m_geometries, SLOT(addGeometry(std::shared_ptr<Geometry>, bool, bool))); connect(m_fileLoader, SIGNAL(geometryMutatorLoaded(std::shared_ptr<GeometryMutator>)), m_geometries, SLOT(mutateGeometry(std::shared_ptr<GeometryMutator>))); loaderThread->start(); //-------------------------------------------------- // Menus menuBar()->setNativeMenuBar(false); // OS X doesn't activate the native menu bar under Qt5 // File menu QMenu* fileMenu = menuBar()->addMenu(tr("&File")); QAction* openAct = fileMenu->addAction(tr("&Open")); openAct->setToolTip(tr("Open a data set")); openAct->setShortcuts(QKeySequence::Open); connect(openAct, SIGNAL(triggered()), this, SLOT(openFiles())); QAction* addAct = fileMenu->addAction(tr("&Add")); addAct->setToolTip(tr("Add a data set")); connect(addAct, SIGNAL(triggered()), this, SLOT(addFiles())); QAction* reloadAct = fileMenu->addAction(tr("&Reload")); reloadAct->setStatusTip(tr("Reload point files from disk")); reloadAct->setShortcut(Qt::Key_F5); connect(reloadAct, SIGNAL(triggered()), this, SLOT(reloadFiles())); fileMenu->addSeparator(); QAction* screenShotAct = fileMenu->addAction(tr("Scree&nshot")); screenShotAct->setStatusTip(tr("Save screen shot of 3D window")); screenShotAct->setShortcut(Qt::Key_F9); connect(screenShotAct, SIGNAL(triggered()), this, SLOT(screenShot())); fileMenu->addSeparator(); QAction* quitAct = fileMenu->addAction(tr("&Quit")); quitAct->setStatusTip(tr("Exit the application")); quitAct->setShortcuts(QKeySequence::Quit); connect(quitAct, SIGNAL(triggered()), this, SLOT(close())); // View menu QMenu* viewMenu = menuBar()->addMenu(tr("&View")); QAction* trackballMode = viewMenu->addAction(tr("Use &Trackball camera")); trackballMode->setCheckable(true); trackballMode->setChecked(false); // Background sub-menu QMenu* backMenu = viewMenu->addMenu(tr("Set &Background")); QSignalMapper* mapper = new QSignalMapper(this); // Selectable backgrounds (svg_names from SVG standard - see QColor docs) const char* backgroundNames[] = {/* "Display Name", "svg_name", */ "Default", "#3C3232", "Black", "black", "Dark Grey", "dimgrey", "Slate Grey", "#858C93", "Light Grey", "lightgrey", "White", "white" }; for(size_t i = 0; i < sizeof(backgroundNames)/sizeof(const char*); i+=2) { QAction* backgroundAct = backMenu->addAction(tr(backgroundNames[i])); QPixmap pixmap(50,50); QString colName = backgroundNames[i+1]; pixmap.fill(QColor(colName)); QIcon icon(pixmap); backgroundAct->setIcon(icon); mapper->setMapping(backgroundAct, colName); connect(backgroundAct, SIGNAL(triggered()), mapper, SLOT(map())); } connect(mapper, SIGNAL(mapped(QString)), this, SLOT(setBackground(QString))); backMenu->addSeparator(); QAction* backgroundCustom = backMenu->addAction(tr("&Custom")); connect(backgroundCustom, SIGNAL(triggered()), this, SLOT(chooseBackground())); // Check boxes for drawing various scene elements by category viewMenu->addSeparator(); QAction* drawBoundingBoxes = viewMenu->addAction(tr("Draw Bounding bo&xes")); drawBoundingBoxes->setCheckable(true); drawBoundingBoxes->setChecked(false); QAction* drawCursor = viewMenu->addAction(tr("Draw 3D &Cursor")); drawCursor->setCheckable(true); drawCursor->setChecked(true); QAction* drawAxes = viewMenu->addAction(tr("Draw &Axes")); drawAxes->setCheckable(true); drawAxes->setChecked(true); QAction* drawGrid = viewMenu->addAction(tr("Draw &Grid")); drawGrid->setCheckable(true); drawGrid->setChecked(false); QAction* drawAnnotations = viewMenu->addAction(tr("Draw A&nnotations")); drawAnnotations->setCheckable(true); drawAnnotations->setChecked(true); // Shader menu QMenu* shaderMenu = menuBar()->addMenu(tr("&Shader")); QAction* openShaderAct = shaderMenu->addAction(tr("&Open")); openShaderAct->setToolTip(tr("Open a shader file")); connect(openShaderAct, SIGNAL(triggered()), this, SLOT(openShaderFile())); QAction* editShaderAct = shaderMenu->addAction(tr("&Edit")); editShaderAct->setToolTip(tr("Open shader editor window")); QAction* saveShaderAct = shaderMenu->addAction(tr("&Save")); saveShaderAct->setToolTip(tr("Save current shader file")); connect(saveShaderAct, SIGNAL(triggered()), this, SLOT(saveShaderFile())); shaderMenu->addSeparator(); // Help menu QMenu* helpMenu = menuBar()->addMenu(tr("&Help")); QAction* helpAct = helpMenu->addAction(tr("User &Guide")); connect(helpAct, SIGNAL(triggered()), this, SLOT(helpDialog())); helpMenu->addSeparator(); QAction* aboutAct = helpMenu->addAction(tr("&About")); connect(aboutAct, SIGNAL(triggered()), this, SLOT(aboutDialog())); //-------------------------------------------------- // Point viewer m_pointView = new View3D(m_geometries, format, this); setCentralWidget(m_pointView); connect(drawBoundingBoxes, SIGNAL(triggered()), m_pointView, SLOT(toggleDrawBoundingBoxes())); connect(drawCursor, SIGNAL(triggered()), m_pointView, SLOT(toggleDrawCursor())); connect(drawAxes, SIGNAL(triggered()), m_pointView, SLOT(toggleDrawAxes())); connect(drawGrid, SIGNAL(triggered()), m_pointView, SLOT(toggleDrawGrid())); connect(drawAnnotations, SIGNAL(triggered()), m_pointView, SLOT(toggleDrawAnnotations())); connect(trackballMode, SIGNAL(triggered()), m_pointView, SLOT(toggleCameraMode())); connect(m_geometries, SIGNAL(rowsInserted(QModelIndex,int,int)), this, SLOT(geometryRowsInserted(QModelIndex,int,int))); //-------------------------------------------------- // Docked widgets // Shader parameters UI QDockWidget* shaderParamsDock = new QDockWidget(tr("Shader Parameters"), this); shaderParamsDock->setFeatures(QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetClosable); QWidget* shaderParamsUI = new QWidget(shaderParamsDock); shaderParamsDock->setWidget(shaderParamsUI); m_pointView->setShaderParamsUIWidget(shaderParamsUI); // Shader editor UI QDockWidget* shaderEditorDock = new QDockWidget(tr("Shader Editor"), this); shaderEditorDock->setFeatures(QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetClosable | QDockWidget::DockWidgetFloatable); QWidget* shaderEditorUI = new QWidget(shaderEditorDock); m_shaderEditor = new ShaderEditor(shaderEditorUI); QGridLayout* shaderEditorLayout = new QGridLayout(shaderEditorUI); shaderEditorLayout->setContentsMargins(2,2,2,2); shaderEditorLayout->addWidget(m_shaderEditor, 0, 0, 1, 1); connect(editShaderAct, SIGNAL(triggered()), shaderEditorDock, SLOT(show())); shaderEditorDock->setWidget(shaderEditorUI); shaderMenu->addAction(m_shaderEditor->compileAction()); connect(m_shaderEditor->compileAction(), SIGNAL(triggered()), this, SLOT(compileShaderFile())); // TODO: check if this is needed - test shader update functionality //connect(m_shaderEditor, SIGNAL(sendShader(QString)), // &m_pointView->shaderProgram(), SLOT(setShader(QString))); // Log viewer UI QDockWidget* logDock = new QDockWidget(tr("Log"), this); logDock->setFeatures(QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetClosable); QWidget* logUI = new QWidget(logDock); m_logTextView = new LogViewer(logUI); m_logTextView->setReadOnly(true); m_logTextView->setTextInteractionFlags(Qt::TextSelectableByKeyboard | Qt::TextSelectableByMouse); m_logTextView->connectLogger(&g_logger); // connect to global logger m_progressBar = new QProgressBar(logUI); m_progressBar->setRange(0,100); m_progressBar->setValue(0); m_progressBar->hide(); connect(m_fileLoader, SIGNAL(loadStepStarted(QString)), this, SLOT(setProgressBarText(QString))); connect(m_fileLoader, SIGNAL(loadProgress(int)), m_progressBar, SLOT(setValue(int))); connect(m_fileLoader, SIGNAL(resetProgress()), m_progressBar, SLOT(hide())); QVBoxLayout* logUILayout = new QVBoxLayout(logUI); //logUILayout->setContentsMargins(2,2,2,2); logUILayout->addWidget(m_logTextView); logUILayout->addWidget(m_progressBar); //m_logTextView->setLineWrapMode(QPlainTextEdit::NoWrap); logDock->setWidget(logUI); // Data set list UI QDockWidget* dataSetDock = new QDockWidget(tr("Data Sets"), this); dataSetDock->setFeatures(QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetClosable | QDockWidget::DockWidgetFloatable); DataSetUI* dataSetUI = new DataSetUI(this); dataSetDock->setWidget(dataSetUI); QAbstractItemView* dataSetOverview = dataSetUI->view(); dataSetOverview->setModel(m_geometries); connect(dataSetOverview, SIGNAL(doubleClicked(const QModelIndex&)), m_pointView, SLOT(centerOnGeometry(const QModelIndex&))); m_pointView->setSelectionModel(dataSetOverview->selectionModel()); // Set up docked widgets addDockWidget(Qt::RightDockWidgetArea, shaderParamsDock); addDockWidget(Qt::LeftDockWidgetArea, shaderEditorDock); addDockWidget(Qt::RightDockWidgetArea, logDock); addDockWidget(Qt::RightDockWidgetArea, dataSetDock); tabifyDockWidget(logDock, dataSetDock); logDock->raise(); shaderEditorDock->setVisible(false); // Add dock widget toggles to view menu viewMenu->addSeparator(); viewMenu->addAction(shaderParamsDock->toggleViewAction()); viewMenu->addAction(logDock->toggleViewAction()); viewMenu->addAction(dataSetDock->toggleViewAction()); // Create custom hook events from CLI at runtime m_hookManager = new HookManager(this); }
// --- 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(); }
LiveViewWindow::LiveViewWindow(DVRServerRepository *serverRepository, QWidget *parent, bool openfs, Qt::WindowFlags f) : QWidget(parent, f), m_liveView(0), m_serverRepository(serverRepository), m_savedLayouts(new QComboBox), m_lastLayoutIndex(-1), m_autoSized(false), m_isLayoutChanging(false), m_wasOpenedFs(openfs) { QBoxLayout *layout = new QVBoxLayout(this); layout->setMargin(0); layout->setSpacing(0); m_toolBar = new QToolBar(tr("Live View")); m_toolBar->setIconSize(QSize(16, 16)); m_toolBar->setMovable(false); #ifndef Q_OS_MAC //toolBar->setStyleSheet(QLatin1String("QToolBar { border: none; }")); #endif m_liveView = new LiveViewArea(m_serverRepository); LiveViewLayout *viewLayout = m_liveView->layout(); /* Saved layouts box */ m_savedLayouts->setModel(SavedLayoutsModel::instance()); m_savedLayouts->setSizeAdjustPolicy(QComboBox::AdjustToContents); m_savedLayouts->setInsertPolicy(QComboBox::NoInsert); m_savedLayouts->setMinimumWidth(100); m_savedLayouts->setContextMenuPolicy(Qt::CustomContextMenu); m_savedLayouts->setCurrentIndex(-1); m_savedLayouts->setMaxVisibleItems(22); m_toolBar->addWidget(m_savedLayouts); QWidget *spacer = new QWidget; spacer->setFixedWidth(20); m_toolBar->addWidget(spacer); aNewLayout = m_toolBar->addAction(QIcon(QLatin1String(":/icons/plus.png")), tr("New Layout"), this, SLOT(createNewLayout())); aRenameLayout = m_toolBar->addAction(QIcon(QLatin1String(":/icons/pencil.png")), tr("Rename Layout"), this, SLOT(renameLayout())); aDelLayout = m_toolBar->addAction(QIcon(QLatin1String(":/icons/cross.png")), tr("Delete Layout"), this, SLOT(deleteCurrentLayout())); aRenameLayout->setEnabled(false); aDelLayout->setEnabled(false); spacer = new QWidget; spacer->setFixedWidth(16); m_toolBar->addWidget(spacer); connect(m_savedLayouts, SIGNAL(currentIndexChanged(int)), SLOT(savedLayoutChanged(int))); connect(m_savedLayouts, SIGNAL(customContextMenuRequested(QPoint)), SLOT(showLayoutMenu(QPoint))); m_addRowAction = m_toolBar->addAction(QIcon(QLatin1String(":/icons/layout-split-vertical.png")), tr("Add Row"), viewLayout, SLOT(appendRow())); m_removeRowAction = m_toolBar->addAction(QIcon(QLatin1String(":/icons/layout-join-vertical.png")), tr("Remove Row"), viewLayout, SLOT(removeRow())); spacer = new QWidget; spacer->setFixedWidth(16); m_toolBar->addWidget(spacer); m_addColumnAction = m_toolBar->addAction(QIcon(QLatin1String(":/icons/layout-split.png")), tr("Add Column"), viewLayout, SLOT(appendColumn())); m_removeColumnAction = m_toolBar->addAction(QIcon(QLatin1String(":/icons/layout-join.png")), tr("Remove Column"), viewLayout, SLOT(removeColumn())); spacer = new QWidget; spacer->setFixedWidth(16); m_toolBar->addWidget(spacer); QSignalMapper *mapper = new QSignalMapper(this); connect(mapper, SIGNAL(mapped(int)), viewLayout, SLOT(setGridSize(int))); m_singleAction = m_toolBar->addAction(QIcon(QLatin1String(":/icons/layout.png")), tr("Single"), mapper, SLOT(map())); mapper->setMapping(m_singleAction, 1); QAction *a = m_toolBar->addAction(QIcon(QLatin1String(":/icons/layout-4.png")), tr("2x2"), mapper, SLOT(map())); mapper->setMapping(a, 2); a = m_toolBar->addAction(QIcon(QLatin1String(":/icons/layout-9.png")), tr("3x3"), mapper, SLOT(map())); mapper->setMapping(a, 3); a = m_toolBar->addAction(QIcon(QLatin1String(":/icons/layout-16.png")), tr("4x4"), mapper, SLOT(map())); mapper->setMapping(a, 4); spacer = new QWidget; spacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); m_toolBar->addWidget(spacer); m_fullscreenAction = m_toolBar->addAction(QIcon(QLatin1String(":/icons/application-resize-full.png")), tr("Fullscreen"), this, SLOT(toggleFullScreen())); m_fullscreenAction->setShortcut(Qt::Key_F11); if (m_wasOpenedFs) { m_closeAction = m_toolBar->addAction(QIcon(QLatin1String(":/icons/cross.png")), tr("Exit"), this, SLOT(close())); new QShortcut(Qt::Key_Escape, this, SLOT(close()), 0, Qt::WindowShortcut); } else new QShortcut(Qt::Key_Escape, this, SLOT(exitFullScreen()), 0, Qt::WindowShortcut); connect(m_liveView->layout(), SIGNAL(layoutChanged()), SLOT(updateLayoutActionStates())); connect(m_liveView->layout(), SIGNAL(layoutChanged()), SLOT(saveLayout())); QMainWindow *wnd = qobject_cast<QMainWindow*>(window()); if (wnd) wnd->addToolBar(Qt::TopToolBarArea, m_toolBar); else layout->addWidget(m_toolBar); layout->addWidget(m_liveView); updateLayoutActionStates(); }
DisplayRessources::DisplayRessources( int nb, QWidget * parent, const char * name ) : QWidget( parent, name ) { _nbRessources = nb; QVBoxLayout * layout = new QVBoxLayout( this ); _title = new Sentence( this ); layout->addWidget( _title ); layout->addStretch( 1 ); _ressources = new RessourceIcon * [ nb ]; QSignalMapper * sigmap = new QSignalMapper( this ); for( int i = 0; i < nb; i+=3 ) { if( nb-i == 1 ) { _ressources[i] = new RessourceIcon( this ); _ressources[i]->setRessource( i ); layout->addWidget( _ressources[i] ); sigmap->setMapping( _ressources[i], i ); connect( _ressources[i], SIGNAL( sig_clicked() ), sigmap, SLOT( map() ) ); } else if( nb-i == 2 ) { QHBoxLayout * layH = new QHBoxLayout(); _ressources[i] = new RessourceIcon( this ); _ressources[i]->setRessource( i ); layH->addStretch( 1 ); layH->addWidget( _ressources[i] ); layH->addStretch( 1 ); sigmap->setMapping( _ressources[i], i ); connect( _ressources[i], SIGNAL( sig_clicked() ), sigmap, SLOT( map() ) ); _ressources[i+1] = new RessourceIcon( this ); _ressources[i+1]->setRessource( i+1 ); layH->addWidget( _ressources[i+1] ); layH->addStretch( 1 ); sigmap->setMapping( _ressources[i+1], i+1 ); connect( _ressources[i+1], SIGNAL( sig_clicked() ), sigmap, SLOT( map() ) ); layout->addLayout( layH ); } else { QHBoxLayout * layH = new QHBoxLayout(); _ressources[i] = new RessourceIcon( this ); _ressources[i]->setRessource( i ); layH->addWidget( _ressources[i] ); sigmap->setMapping( _ressources[i], i ); connect( _ressources[i], SIGNAL( sig_clicked() ), sigmap, SLOT( map() ) ); _ressources[i+1] = new RessourceIcon( this ); _ressources[i+1]->setRessource( i+1 ); layH->addWidget( _ressources[i+1] ); sigmap->setMapping( _ressources[i+1], i+1 ); connect( _ressources[i+1], SIGNAL( sig_clicked() ), sigmap, SLOT( map() ) ); _ressources[i+2] = new RessourceIcon( this ); _ressources[i+2]->setRessource( i+2 ); layH->addWidget( _ressources[i+2] ); sigmap->setMapping( _ressources[i+2], i+2 ); connect( _ressources[i+2], SIGNAL( sig_clicked() ), sigmap, SLOT( map() ) ); layout->addLayout( layH ); } } layout->activate(); connect( sigmap, SIGNAL( mapped( int ) ), SIGNAL( sig_ressource( int ) ) ); }
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( 128 ); /* 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& ) ); 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 ); #ifndef NDEBUG # define MAX_VIEW StandardPLPanel::VIEW_COUNT #else # define MAX_VIEW StandardPLPanel::VIEW_COUNT - 1 #endif 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[0]->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() ); }
EditorDialog::EditorDialog(QWidget * parent, osm::EditableMapObject & emo) : QDialog(parent), m_feature(emo) { QGridLayout * grid = new QGridLayout(); int row = 0; { // Coordinates. ms::LatLon const ll = emo.GetLatLon(); grid->addWidget(new QLabel("Latitude/Longitude:"), row, 0); QHBoxLayout * coords = new QHBoxLayout(); coords->addWidget(new QLabel(QString::fromStdString(strings::to_string_dac(ll.lat, 7) + " " + strings::to_string_dac(ll.lon, 7)))); grid->addLayout(coords, row++, 1); } { // Feature types. grid->addWidget(new QLabel("Type:"), row, 0); string localized = m_feature.GetLocalizedType(); string const raw = DebugPrint(m_feature.GetTypes()); if (!strings::EqualNoCase(localized, raw)) localized += " (" + raw + ")"; QLabel * label = new QLabel(QString::fromStdString(localized)); label->setTextInteractionFlags(Qt::TextSelectableByMouse); grid->addWidget(label, row++, 1); } if (emo.IsNameEditable()) { // Names. char const * defaultLangStr = StringUtf8Multilang::GetLangByCode(StringUtf8Multilang::kDefaultCode); // Default name editor is always displayed, even if feature name is empty. grid->addWidget(new QLabel(QString("Name:")), row, 0); QLineEdit * defaultName = new QLineEdit(); defaultName->setObjectName(defaultLangStr); QGridLayout * namesGrid = new QGridLayout(); int namesRow = 0; namesGrid->addWidget(defaultName, namesRow++, 0, 1, 0); auto const namesDataSource = emo.GetNamesDataSource(); for (auto const & ln : namesDataSource.names) { if (ln.m_code == StringUtf8Multilang::kDefaultCode) { defaultName->setText(QString::fromStdString(ln.m_name)); } else { char const * langStr = StringUtf8Multilang::GetLangByCode(ln.m_code); namesGrid->addWidget(new QLabel(ln.m_lang), namesRow, 0); QLineEdit * lineEditName = new QLineEdit(QString::fromStdString(ln.m_name)); lineEditName->setReadOnly(!emo.IsNameEditable()); lineEditName->setObjectName(langStr); namesGrid->addWidget(lineEditName, namesRow++, 1); } } grid->addLayout(namesGrid, row++, 1); } if (emo.IsAddressEditable()) { // Address rows. auto nearbyStreets = emo.GetNearbyStreets(); grid->addWidget(new QLabel(kStreetObjectName), row, 0); QComboBox * cmb = new QComboBox(); cmb->setEditable(true); if (emo.GetStreet().m_defaultName.empty()) cmb->addItem(""); for (int i = 0; i < nearbyStreets.size(); ++i) { string street = nearbyStreets[i].m_defaultName; if (!nearbyStreets[i].m_localizedName.empty()) street += " / " + nearbyStreets[i].m_localizedName; cmb->addItem(street.c_str()); if (emo.GetStreet() == nearbyStreets[i]) cmb->setCurrentIndex(i); } cmb->setObjectName(kStreetObjectName); grid->addWidget(cmb, row++, 1); grid->addWidget(new QLabel(kHouseNumberObjectName), row, 0); QLineEdit * houseLineEdit = new QLineEdit(emo.GetHouseNumber().c_str()); houseLineEdit->setObjectName(kHouseNumberObjectName); grid->addWidget(houseLineEdit, row++, 1); grid->addWidget(new QLabel(kPostcodeObjectName), row, 0); QLineEdit * postcodeEdit = new QLineEdit(QString::fromStdString(emo.GetPostcode())); postcodeEdit->setObjectName(kPostcodeObjectName); grid->addWidget(postcodeEdit, row++, 1); } // Editable metadata rows. for (osm::Props const prop : emo.GetEditableProperties()) { string v; switch (prop) { case osm::Props::Phone: v = emo.GetPhone(); break; case osm::Props::Fax: v = emo.GetFax(); break; case osm::Props::Email: v = emo.GetEmail(); break; case osm::Props::Website: v = emo.GetWebsite(); break; case osm::Props::Internet: { grid->addWidget(new QLabel(kInternetObjectName), row, 0); QComboBox * cmb = new QComboBox(); string const values[] = {DebugPrint(osm::Internet::Unknown), DebugPrint(osm::Internet::Wlan), DebugPrint(osm::Internet::Wired), DebugPrint(osm::Internet::Yes), DebugPrint(osm::Internet::No)}; for (auto const & v : values) cmb->addItem(v.c_str()); cmb->setCurrentText(DebugPrint(emo.GetInternet()).c_str()); cmb->setObjectName(kInternetObjectName); grid->addWidget(cmb, row++, 1); } continue; case osm::Props::Cuisine: v = strings::JoinStrings(emo.GetLocalizedCuisines(), ", "); break; case osm::Props::OpeningHours: v = emo.GetOpeningHours(); break; case osm::Props::Stars: v = strings::to_string(emo.GetStars()); break; case osm::Props::Operator: v = emo.GetOperator(); break; case osm::Props::Elevation: { double ele; if (emo.GetElevation(ele)) v = strings::to_string_dac(ele, 2); } break; case osm::Props::Wikipedia: v = emo.GetWikipedia(); break; case osm::Props::Flats: v = emo.GetFlats(); break; case osm::Props::BuildingLevels: v = emo.GetBuildingLevels(); break; } QString const fieldName = QString::fromStdString(DebugPrint(prop)); grid->addWidget(new QLabel(fieldName), row, 0); QLineEdit * lineEdit = new QLineEdit(QString::fromStdString(v)); // Mark line editor to query it's text value when editing is finished. lineEdit->setObjectName(fieldName); grid->addWidget(lineEdit, row++, 1); } { // Dialog buttons. QDialogButtonBox * buttonBox = new QDialogButtonBox(QDialogButtonBox::Cancel | QDialogButtonBox::Save); connect(buttonBox, SIGNAL(accepted()), this, SLOT(OnSave())); connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject())); // Delete button should send custom int return value from dialog. QPushButton * deletePOIButton = new QPushButton("Delete POI"); QSignalMapper * signalMapper = new QSignalMapper(); connect(deletePOIButton, SIGNAL(clicked()), signalMapper, SLOT(map())); signalMapper->setMapping(deletePOIButton, QDialogButtonBox::DestructiveRole); connect(signalMapper, SIGNAL(mapped(int)), this, SLOT(done(int))); buttonBox->addButton(deletePOIButton, QDialogButtonBox::DestructiveRole); grid->addWidget(buttonBox, row++, 1); } setLayout(grid); setWindowTitle("OSM Editor"); }
//FIXME: keep loaded plugins in own plugin manager and //unload plugins to let load new version without //the need to restart the application void RackWindow::loadPlugin(QWidget *pluginHost) { QDir pluginsDir(qApp->applicationDirPath()); #if defined(Q_OS_WIN) if (pluginsDir.dirName().toLower() == "debug" || pluginsDir.dirName().toLower() == "release") pluginsDir.cdUp(); #elif defined(Q_OS_MAC) if (pluginsDir.dirName() == "MacOS") { pluginsDir.cdUp(); pluginsDir.cdUp(); pluginsDir.cdUp(); } #endif if (!pluginsDir.cd("plugins")) { QMessageBox::information(this, "Error", "No plugin folder found"); return; } QStringList pluginList = pluginsDir.entryList(QDir::Files); RSelectPluginDialog pluginDialog(this); pluginDialog.pluginListWidget->addItems(pluginList); pluginDialog.pluginListWidget->setCurrentRow(0); if (pluginDialog.exec()) { // bool ok; // int newPluginIndex = RSelectPluginDialog::getIndex(this, pluginList, &ok); // if (ok) { //QString fileName = pluginsDir.entryList(QDir::Files).at(newPluginIndex); QString fileName = pluginsDir.entryList(QDir::Files).at(pluginDialog.pluginListWidget->currentRow()); QPluginLoader pluginLoader(pluginsDir.absoluteFilePath(fileName)); QObject *plugin = pluginLoader.instance(); ///test // QList<QPluginLoader *> loadedPlugins = findChildren<QPluginLoader *>(); // QObject *plugin = 0; // for (int i = 0; i < loadedPlugins.size(); ++i) { // if (loadedPlugins.at(i)->fileName() == pluginsDir.absoluteFilePath(fileName)) { // plugin = loadedPlugins.at(i)->instance(); // break; // } // } // if (!plugin) { // QPluginLoader *pluginLoader = new QPluginLoader(pluginsDir.absoluteFilePath(fileName), this); // plugin = pluginLoader->instance(); // } //debug code qDebug() << "we have the following plugins loaded:"; QList<QPluginLoader *> debugPlugins = findChildren<QPluginLoader *>(); for (int i = 0; i < debugPlugins.size(); ++i) { qDebug() << debugPlugins.at(i)->fileName(); } ////////// // m_pluginLoader = new QPluginLoader(pluginsDir.absoluteFilePath(fileName), this); // QObject *plugin = m_pluginLoader->instance(); ///////////////// if (plugin) { IWidgetPlugin *widgetPlugin = qobject_cast<IWidgetPlugin *>(plugin); if (widgetPlugin) { QWidget *newWidget = widgetPlugin->createRWidget(m_coreImpl, this); //get pointers from pluginhost: QStackedWidget *pluginStack = pluginHost->findChild<QStackedWidget *>("rackPluginStack"); QToolBar *pluginHostToolBar = pluginHost->findChild<QToolBar *>("rackPluginHostToolBar"); QToolBar *pluginToolBar = pluginHost->property("pluginToolBar").value<QToolBar *>(); QSignalMapper *sm = pluginHost->findChild<QSignalMapper *>("rackPluginSwitchMapper"); QActionGroup *ag = pluginHostToolBar->findChild<QActionGroup *>(); //add plugin widget to the widget stack: pluginStack->setCurrentIndex(pluginStack->addWidget(newWidget)); //create action for the toolbars: QAction *act = new QAction(widgetPlugin->name(), ag); act->setCheckable(true); act->setChecked(true); //qt bugfix: set transparent dummy icon to move button text down or right act->setIcon(QIcon(":/images/transparent-icon.png")); //create button for pluginhost toolbar: QToolButton *tb = new QToolButton; tb->setObjectName(QLatin1String(newWidget->metaObject()->className()) + "ToolButton"); tb->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); tb->setFocusPolicy(Qt::NoFocus); tb->setDefaultAction(act); RPushButton *settingsButton = new RPushButton; settingsButton->setObjectName("rackPluginHostToolBarSettingsButton"); RPushButton *deleteButton = new RPushButton; deleteButton->setObjectName("rackPluginHostToolBarDeleteButton"); QHBoxLayout *hl = new QHBoxLayout(tb); hl->setSpacing(0); hl->setContentsMargins(0,0,1,0); hl->addStretch(); hl->addWidget(settingsButton); hl->addWidget(deleteButton); pluginHostToolBar->addWidget(tb); //create button for plugin toolbar: QToolButton *tb1 = new QToolButton; tb1->setObjectName(QLatin1String(newWidget->metaObject()->className()) + "ToolButton"); tb1->setToolButtonStyle(Qt::ToolButtonTextUnderIcon); tb1->setFocusPolicy(Qt::NoFocus); tb1->setDefaultAction(act); pluginToolBar->addWidget(tb1); //connect action trigger to PluginSwitchMapper; QObject::connect(act, SIGNAL(triggered()), sm, SLOT(map())); sm->setMapping(act, newWidget); //connect delete signal //remove act from actiongroup and delete it: QObject::connect(deleteButton, SIGNAL(clicked()), m_mapperClosePlugin, SLOT(map())); m_mapperClosePlugin->setMapping(deleteButton, act); QObject::connect(deleteButton, SIGNAL(clicked()), newWidget, SLOT(deleteLater())); QObject::connect(deleteButton, SIGNAL(clicked()), tb1, SLOT(deleteLater())); QObject::connect(deleteButton, SIGNAL(clicked()), tb, SLOT(deleteLater())); //connect settings signal //if (plugin has settings) ... //QObject::connect(settingsButton, SIGNAL(clicked()), } } else { QMessageBox::information(this, "Error", "Could not load the plugin"); qDebug() << pluginLoader.errorString(); } } }