void MainWindow::Toolbar() { QPixmap openIcon((const char**) open_xpm); QPixmap redoIcon((const char**) redo_xpm); QPixmap simulateIcon((const char**) simulate_xpm); QPixmap stopIcon((const char**) stop_xpm); QPixmap cameraIcon((const char**) camera_xpm); QPixmap filmIcon((const char**) film_xpm); QPixmap frontViewIcon((const char**) frontView_xpm); QPixmap topViewIcon((const char**) topView_xpm); QPixmap rightSideViewIcon((const char**) rightSideView_xpm); toolbar = addToolBar("main toolbar"); QAction *open = toolbar->addAction(QIcon(openIcon), "Open Scene (Ctrl + O)"); QAction *redo = toolbar->addAction(QIcon(redoIcon), "Load last viewed scene (Ctrl + Shift + Q)"); toolbar->addSeparator(); QAction *simulate = toolbar->addAction(QIcon(simulateIcon), "Start Simulation (Ctrl + R"); QAction *stop = toolbar->addAction(QIcon(stopIcon), "Stop Simulation (Ctrl + C"); stop->setVisible(false); toolbar->addSeparator(); QAction *camera = toolbar->addAction(QIcon(cameraIcon), "Export screenshot"); QAction *film = toolbar->addAction(QIcon(filmIcon), "Export film sequence"); toolbar->addSeparator(); QAction *front = toolbar->addAction(QIcon(frontViewIcon), "View scene from front"); QAction *top = toolbar->addAction(QIcon(topViewIcon), "View scene from top"); QAction *rightSide = toolbar->addAction(QIcon(rightSideViewIcon), "View scene from right"); connect(open, SIGNAL(triggered()), this, SLOT(loadScene())); connect(redo, SIGNAL(triggered()), this, SLOT(quickLoad())); connect(simulate, SIGNAL(triggered()), this, SLOT(startSimulation())); connect(stop, SIGNAL(triggered()), this, SLOT(stopSimulation())); connect(camera, SIGNAL(triggered()), this, SLOT(camera())); connect(film, SIGNAL(triggered()), this, SLOT(film())); connect(front, SIGNAL(triggered()), this, SLOT(front())); connect(top, SIGNAL(triggered()), this, SLOT(top())); connect(rightSide, SIGNAL(triggered()), this, SLOT(side())); }
StartupView::StartupView( QWidget * parent ) : QWidget( parent ) { m_templateListModel = std::shared_ptr<TemplateListModel>( new TemplateListModel() ); setStyleSheet("openstudio--StartupView { background: #E6E6E6; }"); #ifdef Q_OS_MAC setWindowFlags(Qt::FramelessWindowHint); #else setWindowFlags(Qt::CustomizeWindowHint); #endif auto recentProjectsView = new QWidget(); recentProjectsView->setStyleSheet("QWidget { background: #F2F2F2; }"); auto recentProjectsLayout = new QVBoxLayout(); recentProjectsLayout->setContentsMargins(10,10,10,10); QLabel * recentProjectsLabel = new QLabel("Recent Projects"); recentProjectsLabel->setStyleSheet("QLabel { font: bold }"); recentProjectsLayout->addWidget(recentProjectsLabel,0,Qt::AlignTop); recentProjectsView->setLayout(recentProjectsLayout); auto openButton = new QToolButton(); openButton->setText("Open File"); openButton->setStyleSheet("QToolButton { font: bold; }"); openButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); QIcon openIcon(":/images/open_file.png"); openButton->setIcon(openIcon); openButton->setIconSize(QSize(40,40)); connect(openButton, &QToolButton::clicked, this, &StartupView::openClicked); auto importButton = new QToolButton(); importButton->setText("Import Idf"); importButton->setStyleSheet("QToolButton { font: bold; }"); importButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); QIcon importIcon(":/images/import_file.png"); importButton->setIcon(importIcon); importButton->setIconSize(QSize(40,40)); connect(importButton, &QToolButton::clicked, this, &StartupView::importClicked); /* QToolButton * importSDDButton = new QToolButton(); importSDDButton->setText("Import SDD"); importSDDButton->setStyleSheet("QToolButton { font: bold; }"); importSDDButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); QIcon importSDDIcon(":/images/import_file.png"); importSDDButton->setIcon(importSDDIcon); importSDDButton->setIconSize(QSize(40,40)); connect(importSDDButton, &QToolButton::clicked, this, &StartupView::importSDDClicked); */ auto projectChooserView = new QWidget(); projectChooserView->setFixedWidth(238); projectChooserView->setStyleSheet("QWidget { background: #F2F2F2; }"); auto projectChooserLayout = new QVBoxLayout(); projectChooserLayout->setContentsMargins(10,10,10,10); QLabel * projectChooserLabel = new QLabel("Create New From Template"); projectChooserLabel->setStyleSheet("QLabel { font: bold }"); projectChooserLayout->addWidget(projectChooserLabel,0,Qt::AlignTop); m_listView = new QListView(); m_listView->setViewMode(QListView::IconMode); m_listView->setModel(m_templateListModel.get()); m_listView->setFocusPolicy(Qt::NoFocus); m_listView->setFlow(QListView::LeftToRight); m_listView->setUniformItemSizes(true); m_listView->setSelectionMode(QAbstractItemView::SingleSelection); projectChooserLayout->addWidget(m_listView); projectChooserView->setLayout(projectChooserLayout); m_projectDetailView = new QWidget(); m_projectDetailView->setStyleSheet("QWidget { background: #F2F2F2; }"); auto projectDetailLayout = new QVBoxLayout(); projectDetailLayout->setContentsMargins(10,10,10,10); m_projectDetailView->setLayout(projectDetailLayout); auto footerView = new QWidget(); footerView->setObjectName("FooterView"); footerView->setStyleSheet("QWidget#FooterView { background: #E6E6E6; }"); footerView->setMaximumHeight(50); footerView->setMinimumHeight(50); auto cancelButton = new QPushButton(); cancelButton->setObjectName("StandardGrayButton"); cancelButton->setMinimumSize(QSize(99,28)); #ifdef OPENSTUDIO_PLUGIN cancelButton->setText("Cancel"); connect(cancelButton, &QPushButton::clicked, this, &StartupView::hide); #else #ifdef Q_OS_MAC cancelButton->setText("Quit"); #else cancelButton->setText("Exit"); #endif connect(cancelButton, &QPushButton::clicked, OpenStudioApp::instance(), &OpenStudioApp::quit); #endif cancelButton->setStyleSheet("QPushButton { font: bold; }"); auto chooseButton = new QPushButton(); chooseButton->setObjectName("StandardBlueButton"); chooseButton->setText("Choose"); chooseButton->setMinimumSize(QSize(99,28)); connect(chooseButton, &QPushButton::clicked, this, &StartupView::newFromTemplateSlot); chooseButton->setStyleSheet("QPushButton { font: bold; }"); auto hFooterLayout = new QHBoxLayout(); hFooterLayout->setSpacing(25); hFooterLayout->setContentsMargins(0,0,0,0); hFooterLayout->addStretch(); hFooterLayout->addWidget(cancelButton); hFooterLayout->addWidget(chooseButton); footerView->setLayout(hFooterLayout); auto hLayout = new QHBoxLayout(); auto vLayout = new QVBoxLayout(); auto vOpenLayout = new QVBoxLayout(); vOpenLayout->addWidget(recentProjectsView); vOpenLayout->addWidget(openButton); vOpenLayout->addWidget(importButton); //vOpenLayout->addWidget(importSDDButton); hLayout->addLayout(vOpenLayout); hLayout->addWidget(projectChooserView); hLayout->addWidget(m_projectDetailView,1); vLayout->addSpacing(50); vLayout->addLayout(hLayout); vLayout->addWidget(footerView); setLayout(vLayout); connect(m_listView, &QListView::clicked, this, &StartupView::showDetailsForItem); m_listView->setCurrentIndex(m_templateListModel->index(0,0)); showDetailsForItem(m_templateListModel->index(0,0)); }
MainToolBar::MainToolBar(QWidget *parent) : QToolBar(parent) , mCommandButton(new CommandButton(this)) { setObjectName(QLatin1String("MainToolBar")); setWindowTitle(tr("Main Toolbar")); setToolButtonStyle(Qt::ToolButtonFollowStyle); QIcon newIcon(QLatin1String(":images/24x24/document-new.png")); QIcon openIcon(QLatin1String(":images/24x24/document-open.png")); QIcon saveIcon(QLatin1String(":images/24x24/document-save.png")); QIcon undoIcon(QLatin1String(":images/24x24/edit-undo.png")); QIcon redoIcon(QLatin1String(":images/24x24/edit-redo.png")); newIcon.addFile(QLatin1String(":images/16x16/document-new.png")); openIcon.addFile(QLatin1String(":images/16x16/document-open.png")); saveIcon.addFile(QLatin1String(":images/16x16/document-save.png")); redoIcon.addFile(QLatin1String(":images/16x16/edit-redo.png")); undoIcon.addFile(QLatin1String(":images/16x16/edit-undo.png")); mNewButton = new QToolButton(this); mOpenAction = new QAction(this); mSaveAction = new QAction(this); QMenu *newMenu = new QMenu(this); newMenu->addAction(ActionManager::action("NewMap")); newMenu->addAction(ActionManager::action("NewTileset")); mNewButton->setMenu(newMenu); mNewButton->setPopupMode(QToolButton::InstantPopup); QUndoGroup *undoGroup = DocumentManager::instance()->undoGroup(); mUndoAction = undoGroup->createUndoAction(this, tr("Undo")); mRedoAction = undoGroup->createRedoAction(this, tr("Redo")); mNewButton->setIcon(newIcon); mOpenAction->setIcon(openIcon); mSaveAction->setIcon(saveIcon); mUndoAction->setIcon(undoIcon); mRedoAction->setIcon(redoIcon); Utils::setThemeIcon(mNewButton, "document-new"); Utils::setThemeIcon(mOpenAction, "document-open"); Utils::setThemeIcon(mSaveAction, "document-save"); Utils::setThemeIcon(mRedoAction, "edit-redo"); Utils::setThemeIcon(mUndoAction, "edit-undo"); mRedoAction->setPriority(QAction::LowPriority); addWidget(mNewButton); addAction(mOpenAction); addAction(mSaveAction); addSeparator(); addAction(mUndoAction); addAction(mRedoAction); addSeparator(); addWidget(mCommandButton); DocumentManager *documentManager = DocumentManager::instance(); connect(mOpenAction, &QAction::triggered, documentManager, &DocumentManager::openFileDialog); connect(mSaveAction, &QAction::triggered, documentManager, &DocumentManager::saveFile); connect(documentManager, &DocumentManager::currentDocumentChanged, this, &MainToolBar::currentDocumentChanged); connect(this, &MainToolBar::orientationChanged, this, &MainToolBar::onOrientationChanged); retranslateUi(); }
int main(int argc, char **argv) { QApplication app(argc, argv); // Initializing the graph and its container Q3DScatter *graph = new Q3DScatter(); QWidget *container = QWidget::createWindowContainer(graph); //! [0] QSize screenSize = graph->screen()->size(); container->setMinimumSize(QSize(screenSize.width() / 2.25, screenSize.height() / 4)); container->setMaximumSize(screenSize); container->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); container->setFocusPolicy(Qt::StrongFocus); //! [1] QWidget *widget = new QWidget; QGroupBox *menuLayout = new QGroupBox; QGroupBox *optionLayout = new QGroupBox; QVBoxLayout *vLayout = new QVBoxLayout(widget); vLayout->addWidget(menuLayout); vLayout->addWidget(container, 1); vLayout->addWidget(optionLayout); //! [1] widget->setWindowTitle(QStringLiteral("CRN Dava Visualization")); //! [4] /* QComboBox *themeList = new QComboBox(widget); themeList->addItem(QStringLiteral("Qt")); themeList->addItem(QStringLiteral("Primary Colors")); themeList->addItem(QStringLiteral("Digia")); themeList->addItem(QStringLiteral("Stone Moss")); themeList->addItem(QStringLiteral("Army Blue")); themeList->addItem(QStringLiteral("Retro")); themeList->addItem(QStringLiteral("Ebony")); themeList->addItem(QStringLiteral("Isabelle")); themeList->setCurrentIndex(6); QPushButton *labelButton = new QPushButton(widget); labelButton->setText(QStringLiteral("Change label style")); */ int logoHeight = 100, logoWidth = 300; int buttonSize = 100; QGridLayout *gridMenu = new QGridLayout(); QPushButton *taLogoLabel = new QPushButton(); QPushButton *configLabel = new QPushButton(); QPushButton *saveLabel = new QPushButton(); QPushButton *openLabel = new QPushButton(); QPushButton *globeLabel = new QPushButton(); QPixmap taLogoPix("/home/adityarputra/Pictures/placeholder.png"); QIcon taLogoIcon(taLogoPix); QPixmap configPix("/home/adityarputra/Pictures/placeholder.png"); QIcon configIcon(configPix); QPixmap savePix("/home/adityarputra/Pictures/placeholder.png"); QIcon saveIcon(savePix); QPixmap openPix("/home/adityarputra/Pictures/placeholder.png"); QIcon openIcon(openPix); QPixmap globePix("/home/adityarputra/Pictures/placeholder.png"); QIcon globeIcon(globePix); taLogoLabel->setIcon(taLogoIcon); taLogoLabel->setMaximumSize(logoWidth,logoHeight); //taLogoLabel->setText("TA logo label"); configLabel->setIcon(configIcon); configLabel->setMaximumSize(buttonSize,buttonSize); //configLabel->setText("Config Icon"); saveLabel->setIcon(saveIcon); saveLabel->setMaximumSize(buttonSize,buttonSize); //saveLabel->setText("Save Icon"); openLabel->setIcon(openIcon); openLabel->setMaximumSize(buttonSize,buttonSize); //openLabel->setText("Open Icon"); globeLabel->setIcon(globeIcon); globeLabel->setMaximumSize(buttonSize,buttonSize); //globeLabel->setText("Globe Icon"); gridMenu->addWidget(taLogoLabel,0,0); gridMenu->addWidget(configLabel,0,2); gridMenu->addWidget(saveLabel,0,3); gridMenu->addWidget(openLabel,0,4); gridMenu->addWidget(globeLabel,0,5); gridMenu->setColumnStretch(0,300); gridMenu->setRowMinimumHeight(0,100); gridMenu->setColumnStretch(1,100); gridMenu->setColumnStretch(2,100); gridMenu->setColumnStretch(3,100); gridMenu->setColumnStretch(4,100); gridMenu->setColumnStretch(5,100); menuLayout->setLayout(gridMenu); //-----------------------------------// QGridLayout *gridOption = new QGridLayout(); QComboBox *gasTypeCombo = new QComboBox(); QPushButton *rewindButton = new QPushButton(); QPushButton *prevButton = new QPushButton(); QPushButton *startButton = new QPushButton(); QPushButton *nextButton = new QPushButton(); QPushButton *forwardButton = new QPushButton(); QTableWidget *sensorDataTable = new QTableWidget(); QPlainTextEdit *console = new QPlainTextEdit(); sensorDataTable->setRowCount(60); sensorDataTable->setColumnCount(9); QPixmap buttonPix("/home/adityarputra/Pictures/placeholder.png"); QIcon buttonIcon(buttonPix); rewindButton->setIcon(buttonIcon); rewindButton->setMaximumWidth(50); prevButton->setIcon(buttonIcon); prevButton->setMaximumWidth(50); startButton->setIcon(buttonIcon); startButton->setMaximumWidth(50); nextButton->setIcon(buttonIcon); nextButton->setMaximumWidth(50); forwardButton->setIcon(buttonIcon); forwardButton->setMaximumWidth(50); gridOption->addWidget(sensorDataTable,0,6,3,1); gridOption->addWidget(gasTypeCombo,0,0,1,5); gridOption->addWidget(rewindButton,1,0); gridOption->addWidget(prevButton,1,1); gridOption->addWidget(startButton,1,2); gridOption->addWidget(nextButton,1,3); gridOption->addWidget(forwardButton,1,4); gridOption->addWidget(console,2,0,1,5); gridOption->setColumnStretch(0,50); gridOption->setColumnStretch(1,50); gridOption->setColumnStretch(2,50); gridOption->setColumnStretch(3,50); gridOption->setColumnStretch(4,50); gridOption->setColumnStretch(5,50); gridOption->setColumnStretch(6,400); optionLayout->setLayout(gridOption); //----------------------------------To be deleted--------------------------------- /*QCheckBox *smoothCheckBox = new QCheckBox(widget); smoothCheckBox->setText(QStringLiteral("Smooth dots")); smoothCheckBox->setChecked(true); QComboBox *itemStyleList = new QComboBox(widget); itemStyleList->addItem(QStringLiteral("Sphere"), int(QAbstract3DSeries::MeshSphere)); itemStyleList->addItem(QStringLiteral("Cube"), int(QAbstract3DSeries::MeshCube)); itemStyleList->addItem(QStringLiteral("Minimal"), int(QAbstract3DSeries::MeshMinimal)); itemStyleList->addItem(QStringLiteral("Point"), int(QAbstract3DSeries::MeshPoint)); itemStyleList->setCurrentIndex(0); QPushButton *cameraButton = new QPushButton(widget); cameraButton->setText(QStringLiteral("Change camera preset")); QPushButton *itemCountButton = new QPushButton(widget); itemCountButton->setText(QStringLiteral("Toggle item count")); QCheckBox *backgroundCheckBox = new QCheckBox(widget); backgroundCheckBox->setText(QStringLiteral("Show background")); backgroundCheckBox->setChecked(true); QCheckBox *gridCheckBox = new QCheckBox(widget); gridCheckBox->setText(QStringLiteral("Show grid")); gridCheckBox->setChecked(true); QComboBox *shadowQuality = new QComboBox(widget); shadowQuality->addItem(QStringLiteral("None")); shadowQuality->addItem(QStringLiteral("Low")); shadowQuality->addItem(QStringLiteral("Medium")); shadowQuality->addItem(QStringLiteral("High")); shadowQuality->addItem(QStringLiteral("Low Soft")); shadowQuality->addItem(QStringLiteral("Medium Soft")); shadowQuality->addItem(QStringLiteral("High Soft")); shadowQuality->setCurrentIndex(4); QFontComboBox *fontList = new QFontComboBox(widget); fontList->setCurrentFont(QFont("Arial"));*/ //---------------------------------------------------------------- // Adding widget to respective layout /* vLayout->addWidget(labelButton, 0, Qt::AlignTop); vLayout->addWidget(cameraButton, 0, Qt::AlignTop); vLayout->addWidget(itemCountButton, 0, Qt::AlignTop); vLayout->addWidget(backgroundCheckBox); vLayout->addWidget(gridCheckBox); vLayout->addWidget(smoothCheckBox, 0, Qt::AlignTop); vLayout->addWidget(new QLabel(QStringLiteral("Change dot style"))); vLayout->addWidget(itemStyleList); vLayout->addWidget(new QLabel(QStringLiteral("Change theme"))); vLayout->addWidget(themeList); vLayout->addWidget(new QLabel(QStringLiteral("Adjust shadow quality"))); vLayout->addWidget(shadowQuality); vLayout->addWidget(new QLabel(QStringLiteral("Change font"))); vLayout->addWidget(fontList, 1, Qt::AlignTop); */ //! [5] //! [2] ScatterDataModifier *modifier = new ScatterDataModifier(graph); //! [2] connect(configLabel,SIGNAL(clicked(bool)),this, /* QObject::connect(cameraButton, &QPushButton::clicked, modifier, &ScatterDataModifier::changePresetCamera); QObject::connect(labelButton, &QPushButton::clicked, modifier, &ScatterDataModifier::changeLabelStyle); QObject::connect(itemCountButton, &QPushButton::clicked, modifier, &ScatterDataModifier::toggleItemCount); QObject::connect(backgroundCheckBox, &QCheckBox::stateChanged, modifier, &ScatterDataModifier::setBackgroundEnabled); QObject::connect(gridCheckBox, &QCheckBox::stateChanged, modifier, &ScatterDataModifier::setGridEnabled); QObject::connect(smoothCheckBox, &QCheckBox::stateChanged, modifier, &ScatterDataModifier::setSmoothDots); QObject::connect(modifier, &ScatterDataModifier::backgroundEnabledChanged, backgroundCheckBox, &QCheckBox::setChecked); QObject::connect(modifier, &ScatterDataModifier::gridEnabledChanged, gridCheckBox, &QCheckBox::setChecked); QObject::connect(itemStyleList, SIGNAL(currentIndexChanged(int)), modifier, SLOT(changeStyle(int))); QObject::connect(themeList, SIGNAL(currentIndexChanged(int)), modifier, SLOT(changeTheme(int))); QObject::connect(shadowQuality, SIGNAL(currentIndexChanged(int)), modifier, SLOT(changeShadowQuality(int))); QObject::connect(modifier, &ScatterDataModifier::shadowQualityChanged, shadowQuality, &QComboBox::setCurrentIndex); QObject::connect(graph, &Q3DScatter::shadowQualityChanged, modifier, &ScatterDataModifier::shadowQualityUpdatedByVisual); QObject::connect(fontList, &QFontComboBox::currentFontChanged, modifier, &ScatterDataModifier::changeFont); QObject::connect(modifier, &ScatterDataModifier::fontChanged, fontList, &QFontComboBox::setCurrentFont); */ //! [6] //! [3] widget->show(); return app.exec(); //! [3] }