void MainWindow::mouseDoubleClickEvent(QMouseEvent *event) { if (Q_UNLIKELY(over->containsDrawing("blank_table"))) { QTableWidget *w = static_cast<QTableWidget *>( ui->listTabs->currentWidget()->layout()->itemAt(0)->widget()); QPoint location = w->mapTo(this, QPoint(0, 0)); QRect r(location.x() + 1, location.y() + 24, w->width() - 2, w->height() - 25); if (r.contains(event->x(), event->y())) { SearchPanel *sp = new SearchPanel(this); sp->show(); } } }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) { centralWidget = new QWidget(this); this->setCentralWidget(centralWidget); QHBoxLayout *mainLayout = new QHBoxLayout; QTableWidget* table = new QTableWidget(this); mainLayout->addWidget(table); table->setColumnCount(2); //table->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch); table->resize(20, table->height()); table->setBaseSize(20,20); canvas = new Canvas(this); // Main MenuBar menuBar = new QMenuBar(canvas); // File Menus QMenu* fileMenu = new QMenu("File"); QPixmap openPix("img/folder_picture.png"); QAction* open = new QAction(openPix, "&Open", this); fileMenu->addAction(open); fileMenu->addSeparator(); QPixmap savePix("img/disk.png"); QAction* save = new QAction(savePix, "&Save", this); fileMenu->addAction(save); QPixmap saveAsPix("img/disk_multiple.png"); QAction* saveAs = new QAction(saveAsPix, "&Save As", this); fileMenu->addAction(saveAs); fileMenu->addSeparator(); QPixmap quitPix("img/door_out.png"); QAction* quit = new QAction(quitPix, "&Quit", this); fileMenu->addAction(quit); // Edit Menu QMenu* editMenu = new QMenu("Edit"); QPixmap cutPix("img/cut.png"); QAction* cut = new QAction(cutPix, "&Cut", this); editMenu->addAction(cut); QPixmap copyPix("img/copy.png"); QAction* copy = new QAction(copyPix, "&Copy", this); editMenu->addAction(copy); QPixmap pastePix("img/paste.png"); QAction* paste = new QAction(pastePix, "&Paste", this); editMenu->addAction(paste); editMenu->addSeparator(); editMenu->addAction("Sprite"); editMenu->addAction("Animation"); // View Menus QMenu* viewMenu = new QMenu("View"); QPixmap gridPix("img/grid.png"); QAction* viewGrid = new QAction(gridPix, "&Grid", this); viewMenu->addAction(viewGrid); viewGrid->setCheckable(true); viewGrid->setChecked(true); QAction *viewSprite = viewMenu->addAction("Sprite"); viewSprite->setCheckable(true); viewSprite->setChecked(true); QAction *viewSymmetry = viewMenu->addAction("Symmetry Hints"); viewSymmetry->setCheckable(true); viewSymmetry->setChecked(true); viewMenu->addSeparator(); QPixmap zoomInPix("img/zoom_in.png"); QAction* zoomIn = new QAction(zoomInPix, "&Zoom In", this); viewMenu->addAction(zoomIn); QPixmap zoomOutPix("img/zoom_out.png"); QAction* zoomOut = new QAction(zoomOutPix, "&Zoom Out", this); viewMenu->addAction(zoomOut); QPixmap zoom100Pix("img/zoom.png"); QAction* zoom100 = new QAction(zoom100Pix, "&Actual Size", this); viewMenu->addAction(zoom100); // Help Menus QMenu* helpMenu = new QMenu("Help"); QPixmap aboutPix("img/star.png"); QAction* about = new QAction(aboutPix, "&About", this); helpMenu->addAction(about); menuBar->addMenu(fileMenu); menuBar->addMenu(editMenu); menuBar->addMenu(viewMenu); menuBar->addMenu(helpMenu); // ToolBar QToolBar* toolBar = new QToolBar(canvas); toolBar->addAction(open); toolBar->addSeparator(); toolBar->addAction(save); toolBar->addAction(saveAs); toolBar->addSeparator(); toolBar->addAction(cut); toolBar->addAction(copy); toolBar->addAction(paste); toolBar->addSeparator(); toolBar->addAction(viewGrid); toolBar->addSeparator(); QSpinBox* gridX = new QSpinBox(this); gridX->setPrefix("X: "); toolBar->addWidget(gridX); toolBar->addSeparator(); QSpinBox* gridY = new QSpinBox(this); gridY->setPrefix("Y: "); toolBar->addWidget(gridY); toolBar->addSeparator(); toolBar->addAction(zoomIn); toolBar->addAction(zoomOut); toolBar->addAction(zoom100); toolBar->addSeparator(); QDoubleSpinBox* speed = new QDoubleSpinBox(this); speed->setPrefix("Speed: "); speed->setDecimals(3); speed->setSingleStep(0.001); speed->setAccelerated(true); toolBar->addWidget(speed); mainLayout->addWidget(canvas); setMenuBar(menuBar); addToolBar(toolBar); toolBar->addSeparator(); QPixmap playPix("img/play.png"); QAction* play = new QAction(playPix, "&Play", this); toolBar->addAction(play); QPixmap pausePix("img/pause.png"); QAction* pause = new QAction(pausePix, "&Pause", this); toolBar->addAction(pause); QPixmap stopPix("img/stop.png"); QAction* stop = new QAction(stopPix, "&Stop", this); toolBar->addAction(stop); toolBar->addSeparator(); QSpinBox* frame = new QSpinBox(this); frame->setPrefix("Frame: "); toolBar->addWidget(frame); mainLayout->setMargin(0); centralWidget->setLayout(mainLayout); }
void PrintingController::printLegend(bool newPageForSection) { if (fwbdebug) qDebug("******** Legend"); if (newPageForSection) { pr->flushPage(); pr->beginPage(); // resets yPos } else pr->printText("\n"); pr->printText(QObject::tr("Legend")); pr->printText(" "); QTableWidget *legendTbl = new QTableWidget(1,2); configureQTableForPrint(legendTbl); string icon_path="/FWBuilderResources/Type/"; int row = 0; int col = 0; QPixmap pm; QPixmap bfr(32,32); QPainter bfrp(&bfr); for (int i=0; !legendList[i].isEmpty(); ++i,++i) { if (row >= legendTbl->rowCount()) legendTbl->insertRow(row); QString type_name = legendList[i]; QString objName = legendList[i+1]; if (type_name==CustomService::TYPENAME) { col++; row=0; } #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) if (fwbdebug) qDebug("Legend table: row=%d col=%d %s %s", row, col, type_name.toAscii().constData(), objName.toAscii().constData()); #else if (fwbdebug) qDebug("Legend table: row=%d col=%d %s %s", row, col, type_name.toLatin1().constData(), objName.toLatin1().constData()); #endif QString icn = ":/Icons/"+type_name+"/icon"; QPixmap pm; if ( ! QPixmapCache::find( icn, pm) ) { pm.load( icn ); QPixmapCache::insert( icn, pm); } bfrp.fillRect(0,0,32,32,QColor(Qt::white)); bfrp.drawPixmap(4,4,pm); QTableWidgetItem *itm = new QTableWidgetItem; itm->setIcon(QIcon(bfr)); itm->setText(objName); legendTbl->setItem(row, col, itm); row++; } legendTbl->resizeColumnToContents(0); legendTbl->resizeColumnToContents(1); for (int i=0; i<legendTbl->rowCount(); ++i) legendTbl->resizeRowToContents(i); QSize sh = legendTbl->sizeHint(); legendTbl->resize(sh.width(),sh.height()); if (fwbdebug) qDebug("legendTbl size: %dx%d", legendTbl->width(),legendTbl->height()); pr->printQTable(legendTbl, false, false); }