コード例 #1
0
ファイル: qqmenuhelper.cpp プロジェクト: jmbowman/portabase
/**
 * <p>Adjust the "File" menu and toolbar contents as appropriate for the
 * document screen.  Sets the "File" menu to have the following content:</p>
 * <ul>
 * <li>Save</li>
 * <li>(items added using addToFileMenu() go here)</li>
 * <li><i>(separator)</i></li>
 * <li>Close</li>
 * <li>Preferences</li>
 * <li><i>(separator)</i></li>
 * <li>Quit</li>
 * </ul>
 * <p>Also shows the "Save" button on the toolbar.  If creating
 * a new file which isn't automatically saved, follow this with a call
 * to setEdited(true).  On the Mac, also shows a document icon in the
 * titlebar.  This method should be called after the visibility of any
 * application-specific actions has been updated (due to a Maemo
 * implementation detail).</p>
 */
void QQMenuHelper::updateDocumentFileMenu()
{
    // update action visibility
    fileSaveAction->setVisible(true);
    fileSeparatorAction->setVisible(true);
    closeAction->setVisible(true);
    fileNewAction->setVisible(false);
    fileOpenAction->setVisible(false);
    recent->menuAction()->setVisible(false);

    // enable and disable actions as appropriate for the current state
    fileNewAction->setEnabled(false);
    fileOpenAction->setEnabled(false);
    fileSaveAction->setEnabled(false);
    closeAction->setEnabled(true);

#if defined(Q_WS_HILDON) || defined(Q_WS_MAEMO_5)
    QMenuBar *mb = mainWindow->menuBar();
    mb->clear();
    int count = extraFileActions.count();
    for (int i = 0; i < count; i++) {
        if (extraFileActions[i]->isVisible()) {
            mb->addAction(extraFileActions[i]);
        }
    }
    mb->addAction(prefsAction);
    mb->addAction(helpAction);
#endif

#if defined(Q_WS_MAC)
    mainWindow->setWindowIcon(docIcon);
#endif
}
コード例 #2
0
void MainWindow::createMenuBar()
{
    QMenuBar* menubar = new QMenuBar(this);
    QMenu* pMenuFile = new QMenu(tr("&File"), menubar);
    QMenu* pMenuEdit = new QMenu(tr("&Edit"), menubar);
    QMenu* pMenuView = new QMenu(tr("&View"), menubar);
    QMenu* pMenuWindow = new QMenu(tr("&Window"), menubar);
    QMenu* pMenuHelp = new QMenu(tr("&Help"), menubar);

    menubar->addAction(pMenuFile->menuAction());
    menubar->addAction(pMenuEdit->menuAction());
    menubar->addAction(pMenuView->menuAction());
#if !defined(Q_OS_MAC)
    menubar->addAction(pMenuWindow->menuAction());
#endif
    menubar->addAction(pMenuHelp->menuAction());

    pMenuFile->addAction(m_pActionStartSynergy);
    pMenuFile->addAction(m_pActionStopSynergy);
    pMenuFile->addSeparator();
    pMenuFile->addAction(m_pActionSave);
    pMenuFile->addSeparator();
    pMenuFile->addAction(m_pActionQuit);
    pMenuEdit->addAction(m_pActionSettings);
    pMenuView->addAction(m_pActionLogOutput);
    pMenuWindow->addAction(m_pActionMinimize);
    pMenuWindow->addAction(m_pActionRestore);
    pMenuHelp->addAction(m_pActionAbout);

    setMenuBar(menubar);
}
コード例 #3
0
ファイル: SCNXViewerWidget.cpp プロジェクト: tomkek/projects
            SCNXViewerWidget::SCNXViewerWidget(const PlugIn &plugIn, QWidget *prnt) :
                    QWidget(prnt),
                    m_viewerWidget(NULL),
                    m_scnxViewerWidget(NULL) {

                // Set size.
                setMinimumSize(640, 480);

                // Layout manager.
                QGridLayout* mainBox = new QGridLayout(this);

                QMenuBar* menubar = new QMenuBar(this);
                QAction* open = new QAction(tr("op&en .scnx.."), this);
                open->setShortcut(tr("Ctrl+O"));
                open->setToolTip("Close the application.");
                connect(open, SIGNAL(triggered()), SLOT(openSCNX()));
                menubar->addAction(open);
                mainBox->addWidget(menubar, 0, 0);

                // OpenGL scene viewer.
                m_scnxViewerWidget = new SCNXGLWidget(plugIn, this);
                m_scnxViewerWidget->setMinimumWidth(540);
                m_scnxViewerWidget->setMinimumHeight(300);

                // Controllable frame.
                m_viewerWidget = new GLControlFrame(m_scnxViewerWidget);
                mainBox->addWidget(m_viewerWidget, 1, 0);

                // Set layout manager.
                setLayout(mainBox);
            }
コード例 #4
0
ファイル: mainwindow.cpp プロジェクト: divan/wgames
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
#ifdef Q_WS_MAEMO_5
    this->setAttribute(Qt::WA_Maemo5StackedWindow);
    this->setWindowFlags(Qt::Window);
#endif

    _games = new GamesData();

    QAction * settingsAction = new QAction(tr("Settings"), this);
    connect(settingsAction, SIGNAL(triggered()), this, SLOT(Settings()));

    QMenuBar * menuBar = new QMenuBar(this);
    menuBar->addAction(settingsAction);

    UpdateLabels();

#ifdef Q_WS_MAEMO_5
    ui->installButton->setIcon(QIcon("/etc/hildon/theme/backgrounds/app_install_games.png"));
    ui->savesButton->setIcon(QIcon("/etc/hildon/theme/backgrounds/app_install_multimedia.png"));
#else
    ui->installButton->setText(tr("Install"));
    ui->savesButton->setText(tr("Saves"));
#endif

    UpdateTracker();
}
コード例 #5
0
/*public*/ void AddEntryExitPairFrame::initComponents(LayoutEditor* panel) //throws Exception
{
 // the following code sets the frame's initial state

 nxPanel = new AddEntryExitPairPanel(panel);

 setTitle("Add Entry Exit Points");
 //getContentPane().setLayout(new BoxLayout(getContentPane(), BoxLayout.Y_AXIS));
 QWidget* centralWidget = new QWidget;
 QVBoxLayout* centralWidgetLayout = new QVBoxLayout(centralWidget);
 setCentralWidget(centralWidget);

centralWidgetLayout->addWidget(nxPanel);

 QMenuBar* menuBar = new QMenuBar();//getJMenuBar();
 QAction* options = new QAction(tr("Options"), this);
 menuBar->addAction(options);
// options.addActionListener(new ActionListener() {
//     /*public*/ void actionPerformed(ActionEvent event) {
//         nxPanel.optionWindow(event);
//     }
// });
 connect(options, SIGNAL(triggered()), this, SLOT(on_options()));

 setMenuBar(menuBar);
 addHelpMenu("package.jmri.jmrit.signalling.EntryExitFrame", true);
 // pack for display
 adjustSize();
}
コード例 #6
0
VisualizerContainer::VisualizerContainer(QMdiArea *container, voxie::visualization::Visualizer *visualizer) :
    QWidget(nullptr),
    //icon(":/icons/application-blue.png"),
    icon(visualizer->icon()),
    visualizer(visualizer),
    container(container),
    window(nullptr)
{
    visualizer->setParent(this);
    this->setWindowTitle(this->visualizer->mainView()->windowTitle());
    this->setWindowIcon(icon);
    {
        QVBoxLayout *layout = new QVBoxLayout();
        layout->setMargin(0);
        layout->setSpacing(0);
        {
            QMenuBar *bar = new QMenuBar();
            bar->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Maximum);

            QAction *popOutAction = bar->addAction("&Pop Out");
            connect(popOutAction, &QAction::triggered, this, &VisualizerContainer::switchPopState);

            layout->addWidget(bar);
            layout->addWidget(visualizer->mainView());
        }
        this->setLayout(layout);
    }

    this->moveToNewMdiChild();
}
コード例 #7
0
ファイル: MenuManager.cpp プロジェクト: lainegates/FreeCAD
void MenuManager::setup(MenuItem* menuItems) const
{
    if (!menuItems)
        return; // empty menu bar

    QMenuBar* menuBar = getMainWindow()->menuBar();
    //menuBar->setUpdatesEnabled(false);

    QList<MenuItem*> items = menuItems->getItems();
    QList<QAction*> actions = menuBar->actions();
    for (QList<MenuItem*>::ConstIterator it = items.begin(); it != items.end(); ++it)
    {
        // search for the menu action
        QAction* action = findAction(actions, QString::fromAscii((*it)->command().c_str()));
        if (!action) {
            // There must be not more than one separator in the menu bar, so
            // we can safely remove it if available and append it at the end
            if ((*it)->command() == "Separator") {
                action = menuBar->addSeparator();
                action->setObjectName(QLatin1String("Separator"));
            }
            else {
                // create a new menu
                std::string menuName = (*it)->command();
                QMenu* menu = menuBar->addMenu(
                    QApplication::translate("Workbench", menuName.c_str(),
                                            0, QApplication::UnicodeUTF8));
                action = menu->menuAction();
                menu->setObjectName(QString::fromAscii(menuName.c_str()));
                action->setObjectName(QString::fromAscii(menuName.c_str()));
            }

            // set the menu user data
            action->setData(QString::fromAscii((*it)->command().c_str()));
        }
        else {
            // put the menu at the end
            menuBar->removeAction(action);
            menuBar->addAction(action);
            action->setVisible(true);
            int index = actions.indexOf(action);
            actions.removeAt(index);
        }

        // flll up the menu
        if (!action->isSeparator())
            setup(*it, action->menu());
    }

    // hide all menus which we don't need for the moment
    for (QList<QAction*>::Iterator it = actions.begin(); it != actions.end(); ++it) {
        (*it)->setVisible(false);
    }

    // enable update again
    //menuBar->setUpdatesEnabled(true);
}
コード例 #8
0
ファイル: control_window.cpp プロジェクト: PetrosW/pDub
void Window_Control_t::createToolBar() {

    QMenuBar *MenuBar = new QMenuBar(this);
    this->setMenuBar(MenuBar);


//    newAct = new QAction(tr("&New"), this);
//    newAct->setShortcuts(QKeySequence::New);
//    newAct->setStatusTip(tr("Create a new file"));
//    connect(newAct, SIGNAL(triggered()), this, SLOT(newFile()));


    A_newProject = new QAction(tr("&New"), this);
    A_newProject->setShortcuts(QKeySequence::New);
    A_newProject->setToolTip(tr("Create a new project"));
    connect(A_newProject, SIGNAL(triggered()), this, SLOT(newProjectDialog()));

    A_loadProject = new QAction(tr("&Open"), this);
    A_loadProject->setShortcuts(QKeySequence::Open);
    A_loadProject->setToolTip(tr("O a old Project"));
    connect(A_loadProject, SIGNAL(triggered()), this, SLOT(loadProject()));

    A_saveProject = new QAction(tr("&Save"), this);
    A_saveProject->setShortcuts(QKeySequence::Save);
    A_saveProject->setToolTip(tr("Save a project"));
    connect(A_saveProject, SIGNAL(triggered()), this, SLOT(saveProject()));

    A_exportProject = new QAction(tr("&Export"), this);
    A_exportProject->setShortcut(tr("Ctrl+E"));
    A_exportProject->setToolTip(tr("Export a project"));
    connect(A_exportProject, SIGNAL(triggered()), this, SLOT(exportProject()));

    MenuBar->addAction(A_newProject);
    MenuBar->addAction(A_loadProject);
    MenuBar->addAction(A_saveProject);
    MenuBar->addAction(A_exportProject);

    //toolbar: dá se všemožně posouvat atd
    /*QToolBar *ToolBar = new QToolBar(this);
    this->addToolBar(ToolBar);
    ToolBar->addAction("New project");*/
}
コード例 #9
0
ファイル: actionmanager.cpp プロジェクト: nmapsi4/nmapsi4
void ActionManager::setupMenuBar()
{
    QMenuBar *menubar = new QMenuBar(m_ui);
    // File menu
    m_menuFile = new QMenu(menubar);
    m_menuFile->setTitle(tr("&File"));
    m_menuFile->addAction(m_collectionsScanSection.value("quit-action"));

    // Settings menu
    m_menuSettings = new QMenu(menubar);
    m_menuSettings->setTitle(tr("S&ettings"));
    m_menuSettings->addAction(m_collectionsScanSection.value("fullscreen-action"));
    m_menuSettings->addAction(m_collectionsScanSection.value("showmenubar-action"));
    m_menuSettings->addSeparator();
    m_menuSettings->addAction(m_collectionsScanSection.value("preferences-action"));

    // Tools menu
    m_menuTools = new QMenu(menubar);
    m_menuTools->setTitle(tr("&Tools"));
    m_menuTools->addAction(m_collectionsScanSection.value("sectionScan-action"));
    m_menuTools->addAction(m_collectionsScanSection.value("sectionVuln-action"));
    m_menuTools->addAction(m_collectionsScanSection.value("sectionDiscover-action"));

    // Help menu
    m_menuHelp = new QMenu(menubar);
    m_menuHelp->setTitle(tr("&Help"));
    m_menuHelp->addAction(m_collectionsScanSection.value("bug-action"));
    m_menuHelp->addAction(m_collectionsScanSection.value("home-action"));
    m_menuHelp->addAction(m_collectionsScanSection.value("documentation-action"));
    m_menuHelp->addAction(m_collectionsScanSection.value("donate-action"));
    m_menuHelp->addSeparator();
    m_menuHelp->addAction(m_collectionsScanSection.value("aboutui-action"));
    m_menuHelp->addAction(m_collectionsScanSection.value("aboutqt-action"));

    menubar->addAction(m_menuFile->menuAction());
    menubar->addAction(m_menuTools->menuAction());
    menubar->addAction(m_menuSettings->menuAction());
    menubar->addAction(m_menuHelp->menuAction());

    m_ui->setMenuBar(menubar);
}
コード例 #10
0
ファイル: cgraphicmonth.cpp プロジェクト: KulerOvZuo/grafik
CGraphicMonth::CGraphicMonth(CMonth* _miesiac, QWidget *parent) :
    QWidget(parent)
{    
    miesiacComboBOx = new QComboBox;
    kalendarzWidget = NULL;
    miesiac=_miesiac;

    pomoc = new QAction(QString("Pomoc"),this);
    connect(pomoc,SIGNAL(triggered()),this,SLOT(pokazPomoc()));
    QMenuBar* menu = new QMenuBar;
    menu->addAction(pomoc);
    menu->setFixedHeight(30);

    QFont font;
    font.setPointSize(mainFontSize);
    QLabel* miesiacLabel = new QLabel(QString("Miesiąc: "));
    miesiacLabel->setFont(font);
    for(int i=0; i<12;i++)
    {   miesiacComboBOx->addItem(QDate::longMonthName(i+1));
        miesiacComboBOx->setFont(font);
    }

    QLabel* rokLabel = new QLabel(QString("Rok: "));
    rokLabel->setFont(font);
    yearEdit = new QDateTimeEdit;
    yearEdit->setDisplayFormat("yyyy");
    yearEdit->setDateRange(QDate(1900,1,1),QDate(2200,1,1));
    yearEdit->setFont(font);

    miesiacComboBOx->setCurrentIndex(miesiac->getWybranaData().month()-1);
    yearEdit->setDate(miesiac->getWybranaData());

    connect(miesiacComboBOx,SIGNAL(activated(int)),this,SLOT(setMiesiac(int)));
    connect(yearEdit,SIGNAL(dateChanged(QDate)),this,SLOT(setRok(QDate)));

    QHBoxLayout *controlLayout = new QHBoxLayout;
    controlLayout->addWidget(miesiacLabel);
    controlLayout->addWidget(miesiacComboBOx);
    controlLayout->addSpacing(15);
    controlLayout->addWidget(rokLabel);
    controlLayout->addWidget(yearEdit);

    mainLayout = new QVBoxLayout;
    mainLayout->addWidget(menu);
    mainLayout->addLayout(controlLayout);
    wstawKalendarz();
    this->setLayout(mainLayout);
    this->setWindowFlags(Qt::MSWindowsFixedSizeDialogHint | Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint | Qt::Dialog);
    this->setWindowTitle(QString("Kalendarz."));
}
コード例 #11
0
MainWindow::MainWindow() :
    serviceProvider(0),
    markerManager(0),
    positionSource(0),
    lastNavigator(0),
    tracking(true),
    firstUpdate(true)
{
    // our actual maps widget is the centre of the mainwindow
    mapsWidget = new MapsWidget;
    setCentralWidget(mapsWidget);

    // set up the menus
    QMenuBar *mbar = new QMenuBar(this);
    mbar->addAction("Quit", qApp, SLOT(quit()));
    mbar->addAction("My Location", this, SLOT(goToMyLocation()));

    QMenu *searchMenu = new QMenu("Search");
    mbar->addMenu(searchMenu);

    searchMenu->addAction("For address or name", this, SLOT(showSearchDialog()));

    QMenu *navigateMenu = new QMenu("Directions");
    mbar->addMenu(navigateMenu);

    navigateMenu->addAction("From here to address", this, SLOT(showNavigateDialog()));

    setMenuBar(mbar);
    setWindowTitle("Maps Demo");

    // now begin the process of opening the network link
    netConfigManager = new QNetworkConfigurationManager;
    connect(netConfigManager, SIGNAL(updateCompleted()),
            this, SLOT(openNetworkSession()));
    netConfigManager->updateConfigurations();
}
コード例 #12
0
ファイル: calendardemo.cpp プロジェクト: tmcguire/qt-mobility
void CalendarDemo::buildMenu()
{
    // Build Options menu
#if defined(Q_WS_MAEMO_5) || defined(Q_WS_MAEMO_6) || defined(Q_OS_WINCE)
    // These platforms need their menu items added directly to the menu bar.
    QMenuBar *optionsMenu = menuBar();
#else
    QMenu *optionsMenu = new QMenu("&Options", this);
    #if !(defined(Q_OS_SYMBIAN) || defined(Q_WS_SIMULATOR))
    // We add the options menu to the softkey manually later
    menuBar()->addMenu(optionsMenu);
    #endif
#endif
    // Add editing options in the menu for Symbian (other platforms get buttons)
    QOrganizerManager defaultManager;
    QStringList supportedItemTypes = defaultManager.supportedItemTypes();
    if (supportedItemTypes.contains(QOrganizerItemType::TypeEvent)) {
        QAction* addEventAction = optionsMenu->addAction("Add E&vent");
        connect(addEventAction, SIGNAL(triggered(bool)), this, SLOT(addNewEvent()));
    }
コード例 #13
0
ファイル: qt_tm_widget.cpp プロジェクト: KarlHegbloom/texmacs
void
qt_tm_widget_rep::install_main_menu () {
  if (main_menu_widget == waiting_main_menu_widget) return;
  main_menu_widget = waiting_main_menu_widget;
  QList<QAction*>* src = main_menu_widget->get_qactionlist();
  if (!src) return;
  QMenuBar* dest = mainwindow()->menuBar();
  dest->clear();
  for (int i = 0; i < src->count(); i++) {
    QAction* a = (*src)[i];
    if (a->menu()) {
      //TRICK: Mac native QMenuBar accepts only menus which are already populated
      // this will cause a problem for us, since menus are lazy and populated only after triggering
      // this is the reason we add a dummy action before inserting the menu
      a->menu()->addAction("native menubar trick");
      dest->addAction(a->menu()->menuAction());
      QObject::connect (a->menu(),         SIGNAL (aboutToShow()),
                        the_gui->gui_helper, SLOT (aboutToShowMainMenu()));
      QObject::connect (a->menu(),         SIGNAL (aboutToHide()),
                        the_gui->gui_helper, SLOT (aboutToHideMainMenu()));
    }
  }
}
コード例 #14
0
ファイル: gui_window_main.cpp プロジェクト: kbsx32/raftcomp
/* main window constructor */
rfc::gui::WindowMain::WindowMain(Dispatcher *dispatcher, QWidget *parent) :
	dispatcher(dispatcher), QMainWindow(parent),
    tabWidget(new QTabWidget(this)),
	splitter(new QSplitter(this))
{
    this->setWindowTitle(
      QString("raftcomp - ") + dispatcher->getSavingFile());

    /* add splitter to widget */
	setCentralWidget(splitter);

	/* add menu */
	QMenuBar *qMenuBar = new QMenuBar(this);

	/* create 'save' button */
	QAction *act = new QAction(lang::save, qMenuBar);
	connect(act, SIGNAL(triggered(bool)),
			this, SLOT(slotSavePushed()));
	qMenuBar->addAction(act);

	setMenuBar(qMenuBar);

	/* all rules tabs */
    // QTabWidget *tabWidget = new QTabWidget(this);
	splitter->addWidget(tabWidget);

	tabWidget->addTab(new gui::mandat::Mandat(dispatcher, this), lang::mandat);

    addDisciplineToTab(new gui::Qualify(dispatcher,  this),	lang::qualify);
    addDisciplineToTab(new gui::Sprint(dispatcher,   this),	lang::sprint);
    addDisciplineToTab(new gui::Slalom(dispatcher,	this),	lang::slalom);
    addDisciplineToTab(new gui::LongRace(dispatcher, this),	lang::longRace);

    protocol = new gui::Protocol(dispatcher, this);
    tabWidget->addTab(protocol,	lang::protocol);
} /* end of 'WindowMain' constructor */
コード例 #15
0
ファイル: ui_main_window.hpp プロジェクト: sauver/sauver_sys
    void setupUi(QMainWindow *Detection)
    {
        if (Detection->objectName().isEmpty())
            Detection->setObjectName(QString::fromUtf8("Detection"));
        Detection->resize(729, 480);
        actionE_xit = new QAction(Detection);
        actionE_xit->setObjectName(QString::fromUtf8("actionE_xit"));
        action_Load_Map = new QAction(Detection);
        action_Load_Map->setObjectName(QString::fromUtf8("action_Load_Map"));
        action_Connect = new QAction(Detection);
        action_Connect->setObjectName(QString::fromUtf8("action_Connect"));
        action_Disconnect = new QAction(Detection);
        action_Disconnect->setObjectName(QString::fromUtf8("action_Disconnect"));
        centralWidget = new QWidget(Detection);
        centralWidget->setObjectName(QString::fromUtf8("centralWidget"));
        gridLayoutWidget = new QWidget(centralWidget);
        gridLayoutWidget->setObjectName(QString::fromUtf8("gridLayoutWidget"));
        gridLayoutWidget->setGeometry(QRect(0, 0, 721, 421));
        gridLayout = new QGridLayout(gridLayoutWidget);
        gridLayout->setSpacing(6);
        gridLayout->setContentsMargins(11, 11, 11, 11);
        gridLayout->setObjectName(QString::fromUtf8("gridLayout"));
        gridLayout->setSizeConstraint(QLayout::SetNoConstraint);
        gridLayout->setVerticalSpacing(5);
        gridLayout->setContentsMargins(0, 0, 0, 0);
        ugvFeedLabel = new QLabel(gridLayoutWidget);
        ugvFeedLabel->setObjectName(QString::fromUtf8("ugvFeedLabel"));
        QSizePolicy sizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
        sizePolicy.setHorizontalStretch(0);
        sizePolicy.setVerticalStretch(0);
        sizePolicy.setHeightForWidth(ugvFeedLabel->sizePolicy().hasHeightForWidth());
        ugvFeedLabel->setSizePolicy(sizePolicy);

        gridLayout->addWidget(ugvFeedLabel, 1, 2, 1, 1);

        connectionButton = new QCommandLinkButton(gridLayoutWidget);
        connectionButton->setObjectName(QString::fromUtf8("connectionButton"));

        gridLayout->addWidget(connectionButton, 0, 2, 1, 1);

        uavFeedLabel = new QLabel(gridLayoutWidget);
        uavFeedLabel->setObjectName(QString::fromUtf8("uavFeedLabel"));
        sizePolicy.setHeightForWidth(uavFeedLabel->sizePolicy().hasHeightForWidth());
        uavFeedLabel->setSizePolicy(sizePolicy);
        uavFeedLabel->setMaximumSize(QSize(16777215, 16777215));

        gridLayout->addWidget(uavFeedLabel, 1, 0, 1, 1);

        ugvMapLabel = new QLabel(gridLayoutWidget);
        ugvMapLabel->setObjectName(QString::fromUtf8("ugvMapLabel"));
        QSizePolicy sizePolicy1(QSizePolicy::MinimumExpanding, QSizePolicy::Expanding);
        sizePolicy1.setHorizontalStretch(0);
        sizePolicy1.setVerticalStretch(0);
        sizePolicy1.setHeightForWidth(ugvMapLabel->sizePolicy().hasHeightForWidth());
        ugvMapLabel->setSizePolicy(sizePolicy1);

        gridLayout->addWidget(ugvMapLabel, 1, 3, 1, 1);

        horizontalLayout_4 = new QHBoxLayout();
        horizontalLayout_4->setSpacing(6);
        horizontalLayout_4->setObjectName(QString::fromUtf8("horizontalLayout_4"));
        label_2 = new QLabel(gridLayoutWidget);
        label_2->setObjectName(QString::fromUtf8("label_2"));

        horizontalLayout_4->addWidget(label_2);

        uavTakeoffLandButton = new QPushButton(gridLayoutWidget);
        uavTakeoffLandButton->setObjectName(QString::fromUtf8("uavTakeoffLandButton"));

        horizontalLayout_4->addWidget(uavTakeoffLandButton);


        gridLayout->addLayout(horizontalLayout_4, 2, 0, 1, 1);

        horizontalLayout_2 = new QHBoxLayout();
        horizontalLayout_2->setSpacing(6);
        horizontalLayout_2->setObjectName(QString::fromUtf8("horizontalLayout_2"));
        label = new QLabel(gridLayoutWidget);
        label->setObjectName(QString::fromUtf8("label"));

        horizontalLayout_2->addWidget(label);

        ugvSpeedLCD = new QLCDNumber(gridLayoutWidget);
        ugvSpeedLCD->setObjectName(QString::fromUtf8("ugvSpeedLCD"));
        ugvSpeedLCD->setFrameShape(QFrame::Box);

        horizontalLayout_2->addWidget(ugvSpeedLCD);


        gridLayout->addLayout(horizontalLayout_2, 4, 2, 1, 1);

        horizontalLayout_6 = new QHBoxLayout();
        horizontalLayout_6->setSpacing(6);
        horizontalLayout_6->setObjectName(QString::fromUtf8("horizontalLayout_6"));
        label_3 = new QLabel(gridLayoutWidget);
        label_3->setObjectName(QString::fromUtf8("label_3"));

        horizontalLayout_6->addWidget(label_3);

        ugvSpeakerButton = new QPushButton(gridLayoutWidget);
        ugvSpeakerButton->setObjectName(QString::fromUtf8("ugvSpeakerButton"));

        horizontalLayout_6->addWidget(ugvSpeakerButton);


        gridLayout->addLayout(horizontalLayout_6, 2, 2, 1, 1);

        verticalLayout = new QVBoxLayout();
        verticalLayout->setSpacing(6);
        verticalLayout->setObjectName(QString::fromUtf8("verticalLayout"));
        label_4 = new QLabel(gridLayoutWidget);
        label_4->setObjectName(QString::fromUtf8("label_4"));
        label_4->setAlignment(Qt::AlignCenter);

        verticalLayout->addWidget(label_4);

        sauverStatus = new QTextBrowser(gridLayoutWidget);
        sauverStatus->setObjectName(QString::fromUtf8("sauverStatus"));
        sauverStatus->setEnabled(true);
        QSizePolicy sizePolicy2(QSizePolicy::Minimum, QSizePolicy::Minimum);
        sizePolicy2.setHorizontalStretch(0);
        sizePolicy2.setVerticalStretch(0);
        sizePolicy2.setHeightForWidth(sauverStatus->sizePolicy().hasHeightForWidth());
        sauverStatus->setSizePolicy(sizePolicy2);
        sauverStatus->setMaximumSize(QSize(777215, 215));

        verticalLayout->addWidget(sauverStatus);


        gridLayout->addLayout(verticalLayout, 4, 3, 1, 1);

        label_5 = new QLabel(gridLayoutWidget);
        label_5->setObjectName(QString::fromUtf8("label_5"));

        gridLayout->addWidget(label_5, 0, 0, 1, 1);

        Detection->setCentralWidget(centralWidget);
        menuBar = new QMenuBar(Detection);
        menuBar->setObjectName(QString::fromUtf8("menuBar"));
        menuBar->setGeometry(QRect(0, 0, 729, 23));
        menuFile = new QMenu(menuBar);
        menuFile->setObjectName(QString::fromUtf8("menuFile"));
        menu_Tools = new QMenu(menuBar);
        menu_Tools->setObjectName(QString::fromUtf8("menu_Tools"));
        menu_Help = new QMenu(menuBar);
        menu_Help->setObjectName(QString::fromUtf8("menu_Help"));
        Detection->setMenuBar(menuBar);
        mainToolBar = new QToolBar(Detection);
        mainToolBar->setObjectName(QString::fromUtf8("mainToolBar"));
        Detection->addToolBar(Qt::TopToolBarArea, mainToolBar);
        statusBar = new QStatusBar(Detection);
        statusBar->setObjectName(QString::fromUtf8("statusBar"));
        Detection->setStatusBar(statusBar);

        menuBar->addAction(menuFile->menuAction());
        menuBar->addAction(menu_Tools->menuAction());
        menuBar->addAction(menu_Help->menuAction());
        menuFile->addAction(action_Load_Map);
        menuFile->addAction(action_Disconnect);
        menuFile->addAction(actionE_xit);
        menu_Tools->addAction(action_Connect);

        retranslateUi(Detection);
        QObject::connect(actionE_xit, SIGNAL(activated()), Detection, SLOT(close()));
        QObject::connect(action_Connect, SIGNAL(activated()), connectionButton, SLOT(click()));

        QMetaObject::connectSlotsByName(Detection);
    } // setupUi
コード例 #16
0
//==============================================================================
// Create MainWindow
//==============================================================================
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow),
    bgColor (QColor(255,255,255)),
    logoPath(logoDefaultPath),
    usbPath (usbDefaultPath),
    rdPath  (rdDefaultPath)
{
    ui->setupUi(this);
    setAttribute(Qt::WA_DeleteOnClose);
    setWindowTitle("BootLogo Changer for Maemo 5");

    shell = 0;

    rdShow = false;

    QMenuBar *menu = menuBar();
    enableAnySizes = new QAction("Allow any image sizes", this);
    enableAnySizes->setCheckable(true);
    connect(enableAnySizes, SIGNAL(triggered(bool)),
            this, SLOT(changeImageLimit(bool)));
    menu->addAction(enableAnySizes);
    menu->addAction("About", this, SLOT(showAbout()));
    menu->addAction("About Qt", qApp, SLOT(aboutQt()));

    ui->stack->setCurrentWidget(ui->centralPage);

    // Central/Left/Right layouts
    ui->rightTopLayout->setContentsMargins(sizeInc, 0, 0, 0);

    // Right buttons
    // Background button
    ui->bgButton->setFixedWidth(ui->bgButton->sizeHint().width() + sizeStep);
    connect(ui->bgButton, SIGNAL(clicked()), this, SLOT(bgBtnClicked()));
    ui->bgButton->installEventFilter(this);
    ui->rightTopLayout->setAlignment(ui->bgButton, Qt::AlignVCenter | Qt::AlignRight);
    // Logo button
    ui->logoButton->setFixedWidth(ui->bgButton->sizeHint().width() + sizeStep);
    connect(ui->logoButton, SIGNAL(clicked()), this, SLOT(logoBtnClicked()));
    ui->logoButton->installEventFilter(this);
    ui->rightTopLayout->setAlignment(ui->logoButton, Qt::AlignVCenter | Qt::AlignRight);
    // USB button
    ui->usbButton->setFixedWidth(ui->bgButton->sizeHint().width() + sizeStep);
    connect(ui->usbButton, SIGNAL(clicked()), this, SLOT(usbBtnClicked()));
    ui->usbButton->installEventFilter(this);
    ui->rightTopLayout->setAlignment(ui->usbButton, Qt::AlignVCenter | Qt::AlignRight);
    // RD button
    ui->rdButton->setFixedWidth(ui->bgButton->sizeHint().width() + sizeStep);
    connect(ui->rdButton, SIGNAL(clicked()), this, SLOT(rdBtnClicked()));
    ui->rdButton->installEventFilter(this);
    ui->rightTopLayout->setAlignment(ui->rdButton, Qt::AlignVCenter | Qt::AlignRight);
    // Preview button
    connect(ui->previewButton, SIGNAL(clicked()), this, SLOT(showPreview()));
    // Apply button
    connect(ui->applyButton, SIGNAL(clicked()), this, SLOT(applyBtnClicked()));

    // Create info widgets for buttons
    // Create Background info widget
    createBgInfo();
    // Create Logo info widget
    createLogoInfo();
    // Create USB info widget
    createUsbInfo();
    // Create RD info widget
    createRdInfo();
    // Create Preview widget
    createPreview();
    // Create Apply widget
    createApply();
}
コード例 #17
0
    void setupUi(QMainWindow *MainWindow)
    {
        if (MainWindow->objectName().isEmpty())
            MainWindow->setObjectName(QString::fromUtf8("MainWindow"));
        MainWindow->resize(999, 913);
        actionAbout = new QAction(MainWindow);
        actionAbout->setObjectName(QString::fromUtf8("actionAbout"));
        actionAtlas = new QAction(MainWindow);
        actionAtlas->setObjectName(QString::fromUtf8("actionAtlas"));
        actionMapping = new QAction(MainWindow);
        actionMapping->setObjectName(QString::fromUtf8("actionMapping"));
        actionLibrary = new QAction(MainWindow);
        actionLibrary->setObjectName(QString::fromUtf8("actionLibrary"));
        actionToolbox = new QAction(MainWindow);
        actionToolbox->setObjectName(QString::fromUtf8("actionToolbox"));
        centralwidget = new QWidget(MainWindow);
        centralwidget->setObjectName(QString::fromUtf8("centralwidget"));
        gridLayout = new QGridLayout(centralwidget);
        gridLayout->setObjectName(QString::fromUtf8("gridLayout"));
        mainSizer = new QGridLayout();
        mainSizer->setObjectName(QString::fromUtf8("mainSizer"));
        mainSizer->setVerticalSpacing(14);
        mainSizer->setContentsMargins(0, -1, -1, -1);
        renderFrame = new QFrame(centralwidget);
        renderFrame->setObjectName(QString::fromUtf8("renderFrame"));
        renderFrame->setMinimumSize(QSize(800, 600));
        renderFrame->setFrameShape(QFrame::Box);
        renderFrame->setFrameShadow(QFrame::Raised);

        mainSizer->addWidget(renderFrame, 0, 0, 1, 1);


        gridLayout->addLayout(mainSizer, 0, 0, 1, 1);

        MainWindow->setCentralWidget(centralwidget);
        menubar = new QMenuBar(MainWindow);
        menubar->setObjectName(QString::fromUtf8("menubar"));
        menubar->setGeometry(QRect(0, 0, 999, 21));
        menuFile = new QMenu(menubar);
        menuFile->setObjectName(QString::fromUtf8("menuFile"));
        menuTools = new QMenu(menubar);
        menuTools->setObjectName(QString::fromUtf8("menuTools"));
        menuAbout = new QMenu(menubar);
        menuAbout->setObjectName(QString::fromUtf8("menuAbout"));
        menuWindows = new QMenu(menubar);
        menuWindows->setObjectName(QString::fromUtf8("menuWindows"));
        MainWindow->setMenuBar(menubar);
        statusbar = new QStatusBar(MainWindow);
        statusbar->setObjectName(QString::fromUtf8("statusbar"));
        MainWindow->setStatusBar(statusbar);

        menubar->addAction(menuFile->menuAction());
        menubar->addAction(menuTools->menuAction());
        menubar->addAction(menuWindows->menuAction());
        menubar->addAction(menuAbout->menuAction());
        menuTools->addAction(actionAtlas);
        menuTools->addAction(actionMapping);
        menuAbout->addAction(actionAbout);
        menuWindows->addAction(actionLibrary);
        menuWindows->addAction(actionToolbox);

        retranslateUi(MainWindow);

        QMetaObject::connectSlotsByName(MainWindow);
    } // setupUi
コード例 #18
0
void EditorMainWindow::SetupUI(QMainWindow *MainWindow) {

	setWindowIcon(*QtConfig::GetIcon("colorwheel.png"));

	MainWindow->setWindowTitle("Sound Engine v0.2.3");

	MainWindow->resize(1280, 720);

	MainWindow->setDockOptions(QMainWindow::AnimatedDocks |
								QMainWindow::AllowNestedDocks |
								QMainWindow::AllowTabbedDocks);

	MainWindow->setTabPosition(Qt::AllDockWidgetAreas, QTabWidget::TabPosition::North);

	// ************************************************************************
	// Load styling

	ReloadStyleSheets();

	// ************************************************************************
	// File Picker

	auto *picker = new FilePicker();
	picker->setNameFilter("*.xml");
	GUI::Set(QT_INSTACE::FILE_PICKER, (void*) picker);

	// ************************************************************************
	// Menu Bar

	QMenuBar *menuBar = new QMenuBar(MainWindow);
	menuBar->setObjectName(QStringLiteral("menuBar"));
	menuBar->setGeometry(QRect(0, 0, 1051, 21));
	MainWindow->setMenuBar(menuBar);

	// Menu Entry
	{
		QMenu *menuEngine = new QMenu(menuBar);
		menuEngine->setObjectName(QStringLiteral("menuEngine"));
		menuEngine->setTitle("File");

		menuBar->addAction(menuEngine->menuAction());

		{
			QAction *action = new QAction(MainWindow);
			action->setText("Exit");
			action->setIcon(*QtConfig::GetIcon("power.png"));
			menuEngine->addAction(action);
			QObject::connect(action, &QAction::triggered, this, &EditorMainWindow::close);
		}

		{
			QAction *action = new QAction(MainWindow);
			action->setText("Save As...");
			action->setIcon(*QtConfig::GetIcon("memorycard.png"));
			menuEngine->addAction(action);

			QObject::connect(action, &QAction::triggered, this, [picker]() {
				picker->OpenForSave();
			});

			QObject::connect(picker, &QFileDialog::fileSelected, this, [picker] (const QString & file) {
				if (picker->IsSaving()) {
					CSoundEditor::GetScene()->SaveSceneAs(file.toStdString().c_str());
				}
			});
		}
	}

	// Menu Entry
	{
		QMenu *menu = new QMenu(menuBar);
		menu->setTitle("Scene");
		menuBar->addAction(menu->menuAction());

		// Submenu buttons
		QAction *action = new QAction(MainWindow);
		action->setText("Clear Scene");
		action->setIcon(*QtConfig::GetIcon("denied.png"));
		menu->addAction(action);

		QObject::connect(action, &QAction::triggered, this, []() {
			CSoundEditor::GetScene()->Clear();
			GUI::Get<SceneWindow>(QT_INSTACE::SCENE_EDITOR)->Clear();
		});
	}

	// Menu Entry
	{
		QMenu *menu = new QMenu(menuBar);
		menu->setTitle("Tools");
		menuBar->addAction(menu->menuAction());

		// Submenu buttons
		{
			QAction *action = new QAction(MainWindow);
			action->setText("Reload StyleSheets");
			action->setIcon(*QtConfig::GetIcon("cmyk.png"));
			menu->addAction(action);
			QObject::connect(action, &QAction::triggered, this, &EditorMainWindow::ReloadStyleSheets);
		}

		// Submenu buttons
		{
			QAction *action = new QAction(MainWindow);
			action->setText("Reload CSound Config");
			action->setIcon(*QtConfig::GetIcon("loading.png"));
			menu->addAction(action);
			QObject::connect(action, &QAction::triggered, this, []() {
				SoundManager::Init();
			});
		}
	}

	// Menu Entry
	{
		QMenu *menu = new QMenu(menuBar);
		menu->setTitle("CSound");
		menuBar->addAction(menu->menuAction());

		// Submenu buttons
		QAction *action = new QAction(MainWindow);
		action->setText("Options");
		action->setIcon(*QtConfig::GetIcon("gear.png"));
		menu->addAction(action);

		appWindows["CSoundOptions"] = new CSoundOptionsWindow();

		QObject::connect(action, &QAction::triggered, this, [&]() {
			appWindows["CSoundOptions"]->Toggle();
		});
	}
	// Menu Entry
	{
		QMenu *menu = new QMenu(menuBar);
		menu->setTitle("Help");
		menuBar->addAction(menu->menuAction());

		// Submenu buttons
		QAction *action = new QAction(MainWindow);
		action->setText("About");
		action->setIcon(*QtConfig::GetIcon("chat.png"));
		menu->addAction(action);

		appWindows["About"] = new AboutWindow();

		QObject::connect(action, &QAction::triggered, this, [&]() {
			appWindows["About"]->Toggle();
		});
	}

	// ************************************************************************
	// Toolbar

	QToolBar *toolbar = new QToolBar();
	toolbar->setWindowTitle("Toolbar");

	// Play Audio
	{
		QToolButton *button = new QToolButton();
		button->setText("Play");
		button->setMaximumWidth(80);
		button->setIcon(*QtConfig::GetIcon("play.png"));
		button->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
		QObject::connect(button, &QToolButton::clicked, this, []() {
			CSoundEditor::GetScene()->Play();
		});
		toolbar->addWidget(button);
	}

	// Stop Audio
	{
		QToolButton *button = new QToolButton();
		button->setText("Stop");
		button->setMaximumWidth(80);
		button->setIcon(*QtConfig::GetIcon("volume_disabled.png"));
		button->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
		QObject::connect(button, &QToolButton::clicked, this, []() {
			CSoundEditor::GetScene()->Stop();
		});
		toolbar->addWidget(button);
	}

	// Save Scene
	{
		QToolButton *button = new QToolButton();
		button->setText("Save Scene");
		button->setIcon(*QtConfig::GetIcon("download.png"));
		button->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
		QObject::connect(button, &QToolButton::clicked, this, []() {
			auto result = CSoundEditor::GetScene()->SaveScene();
			if (!result) {
				auto picker = GUI::Get<FilePicker>(QT_INSTACE::FILE_PICKER);
				if (picker) {
					picker->OpenForSave();
				}
			}
		});
		toolbar->addWidget(button);
	}

	// Load Scene
	{
		QToolButton *button = new QToolButton();
		button->setText("Load Scene");
		button->setIcon(*QtConfig::GetIcon("upload.png"));
		button->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);

		QObject::connect(picker, &QFileDialog::fileSelected, this, [picker] (const QString & file) {
			if (!picker->IsSaving())
			{
				CSoundEditor::GetScene()->LoadScene(file.toStdString().c_str());
				GUI::Get<SceneWindow>(QT_INSTACE::SCENE_EDITOR)->Init();
			}
		});

		QObject::connect(button, &QToolButton::clicked, this, [picker]() {
			picker->OpenForLoad();
		});
		toolbar->addWidget(button);
	}

	// Headphone Test
	{
		QToolButton *button = new QToolButton();
		button->setText("Headphone Test");
		button->setIcon(*QtConfig::GetIcon("speaker.png"));
		button->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);

		appWindows["HeadphoneTest"] = new HeadphoneTestWindow();
		QObject::connect(button, &QToolButton::clicked, this, [this]() {
			appWindows["HeadphoneTest"]->Toggle();
		});

		toolbar->addWidget(button);
	}

	// Moving Plane
	{
		QToolButton *button = new QToolButton();
		button->setText("Moving Plane");
		button->setIcon(*QtConfig::GetIcon("frames.png"));
		button->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
		toolbar->addWidget(button);

		appWindows["MovingPlane"] = new MovingPlaneWindow();
		QObject::connect(button, &QToolButton::clicked, this, [this]() {
			appWindows["MovingPlane"]->Toggle();
		});
	}

	// Sweeping Plane
	{
		QToolButton *button = new QToolButton();
		button->setText("Horizontal Sweep");
		button->setIcon(*QtConfig::GetIcon("half-loading.png"));
		button->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
		toolbar->addWidget(button);

		appWindows["SweepingPlane"] = new SweepingPlaneWindow();
		QObject::connect(button, &QToolButton::clicked, this, [this]() {
			appWindows["SweepingPlane"]->Toggle();
		});
	}

	// Expanding Sphere
	{
		QToolButton *button = new QToolButton();
		button->setText("Expanding Sphere");
		button->setIcon(*QtConfig::GetIcon("target.png"));
		button->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);

		appWindows["ExpandingPlane"] = new ExpandingSphereWindow();
		QObject::connect(button, &QToolButton::clicked, this, [this]() {
			appWindows["ExpandingPlane"]->Toggle();
		});

		toolbar->addWidget(button);
	}

	// Padding Scene
	{
		QWidget *empty = new QWidget();
		empty->setObjectName("ToolWiteSpace");
		toolbar->addWidget(empty);
	}

	// Sound Output Mode
	{
		dropdown = new QComboBox();
		dropdown->setMinimumWidth(60);

		QStyledItemDelegate* itemDelegate = new QStyledItemDelegate();
		dropdown->setItemDelegate(itemDelegate);

		dropdown->addItem("None", QVariant(-1));
		dropdown->addItem("Mono", QVariant(0));
		dropdown->addItem("HRTF2", QVariant(1));
		dropdown->addItem("Stereo", QVariant(2));
		dropdown->addItem("ind-HRTF", QVariant(4));
		dropdown->addItem("PAN2", QVariant(8));
		dropdown->addItem("Quad-HRTF", QVariant(16));
		dropdown->addItem("Multi-8", QVariant(32));
		dropdown->addItem("Quad-Stereo", QVariant(64));

		// Default is HRTF
		dropdown->setCurrentIndex(2);
		SoundManager::SetGlobalOutputModelIndex(1);

		// Add widget
		auto widget = new CustomWidget(QBoxLayout::LeftToRight);
		widget->setObjectName("GlobalOutputDropdown");
		auto label = new QLabel("Global output");
		widget->AddWidget(label);
		widget->AddWidget(dropdown);
		toolbar->addWidget(widget);

		void (QComboBox::* indexChangedSignal)(int index) = &QComboBox::currentIndexChanged;
		QObject::connect(dropdown, indexChangedSignal, this, [&](int index) {
			if (index == 0) {
				SoundManager::SetGlobalOutputModelIndex(1024);
				CSoundEditor::GetScene()->SetOutputModel("none");
				return;
			} else if (SoundManager::GetGlobalOutputModelIndex() == 1024) {
				CSoundEditor::GetScene()->SetOutputModel("global-output");
			}
			auto data = dropdown->currentData().toUInt();
			SoundManager::SetGlobalOutputModelIndex(data);
		});
	}

	// Attach toobar to the main window
	MainWindow->addToolBar(toolbar);

	// ************************************************************************
	// Status Bar

	QStatusBar *statusBar = new QStatusBar(MainWindow);
	statusBar->setObjectName(QStringLiteral("statusBar"));
	MainWindow->setStatusBar(statusBar);

	//QMetaObject::connectSlotsByName(MainWindow);

	// ************************************************************************
	// Central Area

	QWidget *centeralWidget = new QWidget();
	centeralWidget->setFixedWidth(0);
	MainWindow->setCentralWidget(centeralWidget);

	// ************************************************************************
	// Attach windows
	dockWindows["TextPreview"] = new TextPreviewWindow();
	dockWindows["CodeEditor"] = new CodeEditorWindow();
	dockWindows["ComponentList"] = new ComponentList();
	dockWindows["InstrumentList"] = new InstrumentList();
	dockWindows["ScoreList"] = new ScoreList();

	dockWindows["ScoreEditor"] = new ScoreEditor();
	dockWindows["InstrumentEditor"] = new InstrumentEditor();
	dockWindows["ComponentEditor"] = new ComponentEditor();
	
	dockWindows["SceneWindow"] = new SceneWindow();
	dockWindows["GameWindow"] = new GameWindow();

	dockWindows["ObjectProperty"] = new SceneObjectProperties();
	dockWindows["CameraProperty"] = new CameraPropertyEditor();
	dockWindows["CSoundControl"] = new CSoundControlWindow();

	//// Left Dock
	MainWindow->addDockWidget(Qt::DockWidgetArea::LeftDockWidgetArea, dockWindows["SceneWindow"], Qt::Orientation::Vertical);
	MainWindow->addDockWidget(Qt::DockWidgetArea::LeftDockWidgetArea, dockWindows["ScoreEditor"], Qt::Orientation::Horizontal);
	MainWindow->addDockWidget(Qt::DockWidgetArea::LeftDockWidgetArea, dockWindows["InstrumentEditor"], Qt::Orientation::Horizontal);
	MainWindow->addDockWidget(Qt::DockWidgetArea::LeftDockWidgetArea, dockWindows["ComponentEditor"], Qt::Orientation::Vertical);
	MainWindow->tabifyDockWidget(dockWindows["ComponentEditor"], dockWindows["ObjectProperty"]);
	MainWindow->tabifyDockWidget(dockWindows["ComponentEditor"], dockWindows["CameraProperty"]);
	MainWindow->tabifyDockWidget(dockWindows["ComponentEditor"], dockWindows["CSoundControl"]);

	MainWindow->addDockWidget(Qt::DockWidgetArea::LeftDockWidgetArea, dockWindows["TextPreview"], Qt::Orientation::Horizontal);
	MainWindow->tabifyDockWidget(dockWindows["TextPreview"], dockWindows["CodeEditor"]);
	MainWindow->tabifyDockWidget(dockWindows["TextPreview"], dockWindows["GameWindow"]);

	dockWindows["GameWindow"]->setFloating(true);
	dockWindows["GameWindow"]->setFloating(false);
	dockWindows["GameWindow"]->raise();

	// Right Dock
	MainWindow->addDockWidget(Qt::DockWidgetArea::RightDockWidgetArea, dockWindows["ComponentList"], Qt::Orientation::Vertical);
	MainWindow->addDockWidget(Qt::DockWidgetArea::RightDockWidgetArea, dockWindows["InstrumentList"], Qt::Orientation::Vertical);
	MainWindow->addDockWidget(Qt::DockWidgetArea::RightDockWidgetArea, dockWindows["ScoreList"], Qt::Orientation::Vertical);

	// Activate Windows
	dockWindows["ObjectProperty"]->raise();
}
コード例 #19
0
ファイル: MadeupWindow.cpp プロジェクト: twodee/madeup
MadeupWindow::MadeupWindow(QWidget *parent) :
  QMainWindow(parent),
  autopathify_timer(new QTimer(this)),
  editor(nullptr),
  canvas(nullptr),
  last_directory(QDir::homePath()) {

  autopathify_timer->setSingleShot(true);
  config_path = (QStandardPaths::writableLocation(QStandardPaths::ConfigLocation) + QDir::separator() + "org.twodee.madeup.json").toStdString();
  std::cout << "config_path: " << config_path << std::endl;

  horizontal_splitter = new QSplitter(this);
  horizontal_splitter->setOrientation(Qt::Horizontal);

  // Left pane
  vertical_splitter = new QSplitter(horizontal_splitter);
  vertical_splitter->setOrientation(Qt::Vertical);

  // - Editor
  editor = new MadeupEditor(vertical_splitter);
  QFont font;
  font.setFamily(QStringLiteral("Courier New"));
  font.setPointSize(18);
  editor->setFont(font);
  editor->setLineWrapMode(QPlainTextEdit::NoWrap);

  // - Console
  console = new QTextBrowser(vertical_splitter);
  console->setFont(font);
  /* console->setText("<a href=\"jump?start=3&end=7\">click here</a>"); */
  console->setOpenLinks(false);

  {
    QPalette palette;
    palette.setColor(QPalette::Base, Qt::black);
    palette.setColor(QPalette::Text, Qt::white);
    editor->setPalette(palette);
    console->setPalette(palette);
  }

  QSizePolicy p1(QSizePolicy::Preferred, QSizePolicy::Preferred);
  p1.setHorizontalStretch(0);
  p1.setVerticalStretch(2);
  QSizePolicy p2(QSizePolicy::Preferred, QSizePolicy::Preferred);
  p2.setHorizontalStretch(0);
  p2.setVerticalStretch(0);

  editor->setSizePolicy(p1);
  console->setSizePolicy(p2);

  vertical_splitter->addWidget(editor);
  vertical_splitter->addWidget(console);

  // Middle pane
  canvas = new MadeupCanvas(horizontal_splitter);
  renderer = &canvas->getRenderer();

  // Right pane
  QWidget *settings_panel;
  settings_panel = new QWidget(horizontal_splitter);
  settings_panel->setVisible(false);

  settings_picker = new QComboBox();
  settings_picker->addItem("Display");
  settings_picker->addItem("Editor");
  settings_picker->addItem("Camera");
  settings_picker->addItem("Lighting");

  QStackedWidget *settings_pager = new QStackedWidget();

  // Display page
  QWidget *display_page = new QWidget();

  // Display page widgets
  QGroupBox *cartesian_group = new QGroupBox("Cartesian");

  QLabel *axis_label = new QLabel("Axis");
  QLabel *grid_label = new QLabel("Grid");
  QLabel *size_label = new QLabel("Extent");
  QLabel *spacing_label = new QLabel("Spacing");

  QLabel *x_label = new QLabel("X");
  QLabel *y_label = new QLabel("Y");
  QLabel *z_label = new QLabel("Z");

  for (int d = 0; d < 3; ++d) {
    show_axis_checkboxes[d] = new QCheckBox();
    show_grid_checkboxes[d] = new QCheckBox();
    grid_extent_spinners[d] = new QDoubleSpinBox();
    grid_extent_spinners[d]->setMinimum(0.01);
    grid_spacing_spinners[d] = new QDoubleSpinBox();
    grid_spacing_spinners[d]->setMinimum(0.01);
  }

  axis_stroke_width_spinner = new QDoubleSpinBox();  
  axis_stroke_width_spinner->setMinimum(1.0);

  grid_stroke_width_spinner = new QDoubleSpinBox();  
  grid_stroke_width_spinner->setMinimum(1.0);

  QGroupBox *path_group = new QGroupBox("Path");
  show_heading_checkbox = new QCheckBox("Show heading");
  show_path_checkbox = new QCheckBox("Show path");
  show_stops_checkbox = new QCheckBox("Show stops");

  QLabel *path_stroke_width_label = new QLabel("Thickness");
  path_stroke_width_spinner = new QDoubleSpinBox();
  path_stroke_width_spinner->setMinimum(1.0);

  QLabel *vertex_size_label = new QLabel("Vertex size");
  vertex_size_spinner = new QDoubleSpinBox();
  vertex_size_spinner->setMinimum(1.0);

  QLabel *path_color_label = new QLabel("Path color");
  path_color_button = new QPushButton();
  path_color_button->setFlat(true);
  path_color_button->setAutoFillBackground(true);

  QLabel *vertex_color_label = new QLabel("Vertex color");
  vertex_color_button = new QPushButton();
  vertex_color_button->setFlat(true);
  vertex_color_button->setAutoFillBackground(true);

  QLabel *style_label = new QLabel("Render style");
  face_style_picker = new QComboBox();
  face_style_picker->addItem("Filled");
  face_style_picker->addItem("Wireframe");
  face_style_picker->addItem("Vertices");

  QLabel *background_color_label = new QLabel("Background color");
  background_color_button = new QPushButton();
  background_color_button->setFlat(true);
  background_color_button->setAutoFillBackground(true);

  QSpacerItem *vertical_spacer = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding);

  // Display page layout
  QGridLayout *cartesian_layout = new QGridLayout(cartesian_group);
  cartesian_layout->setHorizontalSpacing(4);
  cartesian_layout->setVerticalSpacing(0);
  cartesian_layout->setContentsMargins(0, 0, 0, 0);

  int row = 0;
  cartesian_layout->addWidget(axis_label, row, 1, Qt::AlignHCenter | Qt::AlignBottom);
  cartesian_layout->addWidget(grid_label, row, 2, Qt::AlignHCenter | Qt::AlignBottom);
  cartesian_layout->addWidget(size_label, row, 3, Qt::AlignBottom);
  cartesian_layout->addWidget(spacing_label, row, 4, Qt::AlignBottom);
  ++row;

  cartesian_layout->addWidget(x_label, row, 0);
  cartesian_layout->addWidget(show_axis_checkboxes[0], row, 1, Qt::AlignCenter);
  cartesian_layout->addWidget(show_grid_checkboxes[0], row, 2, Qt::AlignCenter);
  cartesian_layout->addWidget(grid_extent_spinners[0], row, 3);
  cartesian_layout->addWidget(grid_spacing_spinners[0], row, 4);
  ++row;

  cartesian_layout->addWidget(y_label, row, 0);
  cartesian_layout->addWidget(show_axis_checkboxes[1], row, 1, Qt::AlignCenter);
  cartesian_layout->addWidget(show_grid_checkboxes[1], row, 2, Qt::AlignCenter);
  cartesian_layout->addWidget(grid_extent_spinners[1], row, 3);
  cartesian_layout->addWidget(grid_spacing_spinners[1], row, 4);
  ++row;

  cartesian_layout->addWidget(z_label, row, 0);
  cartesian_layout->addWidget(show_axis_checkboxes[2], row, 1, Qt::AlignCenter);
  cartesian_layout->addWidget(show_grid_checkboxes[2], row, 2, Qt::AlignCenter);
  cartesian_layout->addWidget(grid_extent_spinners[2], row, 3);
  cartesian_layout->addWidget(grid_spacing_spinners[2], row, 4);
  ++row;

  cartesian_layout->addWidget(new QLabel("Axis thickness"), row, 0, 1, 3);
  cartesian_layout->addWidget(axis_stroke_width_spinner, row, 3, 1, 2);
  ++row;

  cartesian_layout->addWidget(new QLabel("Grid thickness"), row, 0, 1, 3);
  cartesian_layout->addWidget(grid_stroke_width_spinner, row, 3, 1, 2);
  ++row;

  cartesian_layout->setColumnStretch(0, 0);
  cartesian_layout->setColumnStretch(1, 0);
  cartesian_layout->setColumnStretch(2, 0);
  cartesian_layout->setColumnStretch(3, 1);
  cartesian_layout->setColumnStretch(4, 1);

  QGridLayout *path_group_layout = new QGridLayout(path_group);
  path_group_layout->setHorizontalSpacing(3);
  path_group_layout->setVerticalSpacing(5);
  path_group_layout->setContentsMargins(0, 0, 0, 0);
  path_group_layout->addWidget(show_heading_checkbox, 0, 0, 1, 2);
  path_group_layout->addWidget(show_path_checkbox, 1, 0, 1, 2);
  path_group_layout->addWidget(show_stops_checkbox, 2, 0, 1, 2);
  path_group_layout->addWidget(path_stroke_width_label, 3, 0, 1, 1);
  path_group_layout->addWidget(path_stroke_width_spinner, 3, 1, 1, 1);
  path_group_layout->addWidget(vertex_size_label, 4, 0, 1, 1);
  path_group_layout->addWidget(vertex_size_spinner, 4, 1, 1, 1);
  path_group_layout->addWidget(path_color_label, 5, 0, 1, 1);
  path_group_layout->addWidget(path_color_button, 5, 1, 1, 1);
  path_group_layout->addWidget(vertex_color_label, 6, 0, 1, 1);
  path_group_layout->addWidget(vertex_color_button, 6, 1, 1, 1);
  path_group_layout->setColumnStretch(0, 0);
  path_group_layout->setColumnStretch(1, 1);

  QGridLayout *display_page_layout = new QGridLayout(display_page);
  display_page_layout->setSpacing(-1);
  display_page_layout->setContentsMargins(0, 0, 0, 0);
  display_page_layout->addWidget(cartesian_group, 0, 0, 1, 2);
  display_page_layout->addWidget(path_group, 1, 0, 1, 2);
  display_page_layout->addWidget(style_label, 2, 0, 1, 1);
  display_page_layout->addWidget(face_style_picker, 2, 1, 1, 1);
  display_page_layout->addWidget(background_color_label, 3, 0, 1, 1);
  display_page_layout->addWidget(background_color_button, 3, 1, 1, 1);
  display_page_layout->addItem(vertical_spacer, 4, 0, 1, 2);

  // Editor page
  QWidget *editor_page = new QWidget();

  autopathify_checkbox = new QCheckBox("Autopathify");
  show_console_checkbox = new QCheckBox("Show console");

  autopathify_delay_spinner = new QDoubleSpinBox();
  autopathify_delay_spinner->setMinimum(0.0);
  autopathify_delay_spinner->setMaximum(10.0);
  autopathify_delay_spinner->setSingleStep(0.25);

  QPushButton *select_font_button = new QPushButton("Select Font");

  QSpacerItem *vertical_spacer3 = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding);

  QGridLayout *editor_page_layout = new QGridLayout(editor_page);
  editor_page_layout->setSpacing(-1);
  editor_page_layout->setContentsMargins(0, 0, 0, 0);
  editor_page_layout->addWidget(autopathify_checkbox, 0, 0, 1, 2);

  editor_page_layout->addWidget(new QLabel("Autopathify delay"), 1, 0);
  editor_page_layout->addWidget(autopathify_delay_spinner, 1, 1);

  editor_page_layout->addWidget(show_console_checkbox, 2, 0, 1, 2);
  
  editor_page_layout->addWidget(select_font_button, 3, 0, 1, 2);

  editor_page_layout->addItem(vertical_spacer3, 4, 0, 1, 2);

  editor_page_layout->setColumnStretch(0, 0);
  editor_page_layout->setColumnStretch(1, 1);
 
  // Camera page
  QWidget *camera_page = new QWidget();

  QGroupBox *view_from_group = new QGroupBox("View From");
  QPushButton *negative_x_button = new QPushButton("-X");
  QPushButton *positive_x_button = new QPushButton("+X");
  QPushButton *negative_y_button = new QPushButton("-Y");
  QPushButton *positive_y_button = new QPushButton("+Y");
  QPushButton *negative_z_button = new QPushButton("-Z");
  QPushButton *positive_z_button = new QPushButton("+Z");

  QGridLayout *view_from_group_layout = new QGridLayout(view_from_group);
  view_from_group_layout->setSpacing(-1);
  view_from_group_layout->setContentsMargins(0, 0, 0, 0);
  view_from_group_layout->addWidget(negative_x_button, 0, 0);
  view_from_group_layout->addWidget(positive_x_button, 0, 1);
  view_from_group_layout->addWidget(negative_y_button, 1, 0);
  view_from_group_layout->addWidget(positive_y_button, 1, 1);
  view_from_group_layout->addWidget(negative_z_button, 2, 0);
  view_from_group_layout->addWidget(positive_z_button, 2, 1);

  has_autorotate_checkbox = new QCheckBox("Autorotate");

  QVBoxLayout *camera_page_layout = new QVBoxLayout(camera_page);
  camera_page_layout->setSpacing(-1);
  camera_page_layout->setContentsMargins(0, 0, 0, 0);
  camera_page_layout->addWidget(view_from_group);
  camera_page_layout->addWidget(has_autorotate_checkbox);
  QSpacerItem *vertical_spacer2 = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding);
  camera_page_layout->addItem(vertical_spacer2);

  // Lighting page
  QWidget *lighting_page = new QWidget();

  azimuth_angle_spinner = new QDoubleSpinBox();
  azimuth_angle_spinner->setMinimum(0.0);
  azimuth_angle_spinner->setMaximum(360.0);
  azimuth_angle_spinner->setSingleStep(5.0);

  elevation_angle_spinner = new QDoubleSpinBox();
  elevation_angle_spinner->setMinimum(-90.0);
  elevation_angle_spinner->setMaximum(90.0);
  elevation_angle_spinner->setSingleStep(5.0);

  shininess_spinner = new QDoubleSpinBox();
  shininess_spinner->setMinimum(0.1);
  shininess_spinner->setMaximum(1000.0);
  shininess_spinner->setSingleStep(10.0);

  light_distance_factor_spinner = new QDoubleSpinBox();
  light_distance_factor_spinner->setMinimum(0.0);
  light_distance_factor_spinner->setMaximum(100.0);
  light_distance_factor_spinner->setSingleStep(0.1);

  has_specular_checkbox = new QCheckBox("Show specular highlights");
  has_specular_checkbox->setChecked(true);
  faceted_checkbox = new QCheckBox("Faceted");
  is_two_sided_checkbox = new QCheckBox("Two-sided");

  QGridLayout *lighting_page_layout = new QGridLayout(lighting_page);
  lighting_page_layout->setSpacing(-1);
  lighting_page_layout->setContentsMargins(0, 0, 0, 0);

  lighting_page_layout->addWidget(new QLabel("Azimuth angle"), 0, 0);
  lighting_page_layout->addWidget(azimuth_angle_spinner, 0, 1);

  lighting_page_layout->addWidget(new QLabel("Elevation angle"), 1, 0);
  lighting_page_layout->addWidget(elevation_angle_spinner, 1, 1);

  lighting_page_layout->addWidget(new QLabel("Shininess"), 2, 0);
  lighting_page_layout->addWidget(shininess_spinner, 2, 1);

  lighting_page_layout->addWidget(new QLabel("Distance factor"), 3, 0);
  lighting_page_layout->addWidget(light_distance_factor_spinner, 3, 1);

  lighting_page_layout->addWidget(has_specular_checkbox, 4, 0, 1, 2);

  lighting_page_layout->addWidget(faceted_checkbox, 5, 0, 1, 2);

  lighting_page_layout->addWidget(is_two_sided_checkbox, 6, 0, 1, 2);

  QSpacerItem *vertical_spacer4 = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding);
  lighting_page_layout->addItem(vertical_spacer4, 7, 0, 1, 2);

  lighting_page_layout->setColumnStretch(0, 0);
  lighting_page_layout->setColumnStretch(1, 1);

  // Add pages
  settings_pager->addWidget(display_page);
  settings_pager->addWidget(editor_page);
  settings_pager->addWidget(camera_page);
  settings_pager->addWidget(lighting_page);

  // Layout
  QSizePolicy horizontal_stretch(QSizePolicy::Preferred, QSizePolicy::Preferred);
  horizontal_stretch.setHorizontalStretch(1);
  horizontal_stretch.setVerticalStretch(0);
  canvas->setSizePolicy(horizontal_stretch);

  QVBoxLayout *settings_panel_layout = new QVBoxLayout(settings_panel);
  settings_panel_layout->setSpacing(6);
  settings_panel_layout->setContentsMargins(0, 6, 0, 0);
  settings_panel_layout->addWidget(settings_picker);
  settings_panel_layout->addWidget(settings_pager);

  horizontal_splitter->addWidget(vertical_splitter);
  horizontal_splitter->addWidget(canvas);
  horizontal_splitter->addWidget(settings_panel);

  // Overall

  this->setCentralWidget(horizontal_splitter);

  // Actions
  QAction *action_solidify = new QAction(this);
  action_solidify->setText("Solidify");
  action_solidify->setShortcut(Qt::CTRL + Qt::Key_R);

  QAction *action_pathify = new QAction(this);
  action_pathify->setText("Pathify");
  action_pathify->setShortcut(Qt::CTRL + Qt::Key_E);

  QAction *action_text_bigger = new QAction(this);
  action_text_bigger->setText("Increase font size");
  action_text_bigger->setShortcut(Qt::CTRL + Qt::Key_Plus);

  QAction *action_text_smaller = new QAction(this);
  action_text_smaller->setText("Decrease font size");
  action_text_smaller->setShortcut(Qt::CTRL + Qt::Key_Minus);

  action_settings = new QAction(this);
  action_settings->setText("Show settings");
  action_settings->setShortcut(Qt::CTRL + Qt::Key_P);
  action_settings->setCheckable(true);

  QAction *action_documentation = new QAction(this);
  action_documentation->setText("Documentation");

  QAction *action_fit = new QAction(this);
  action_fit->setText("Fit");
  action_fit->setShortcut(Qt::CTRL + Qt::Key_F);

  QAction *action_screenshot = new QAction(this);
  action_screenshot->setText("Take screenshot");
  action_screenshot->setShortcut(Qt::CTRL + Qt::Key_T);

  QAction *action_new = new QAction(this);
  action_new->setText("New window");
  action_new->setShortcut(Qt::CTRL + Qt::Key_N);

  QAction *action_open = new QAction(this);
  action_open->setText("Open");
  action_open->setShortcut(Qt::CTRL + Qt::Key_O);

  QAction *action_save = new QAction(this);
  action_save->setText("Save");
  action_save->setShortcut(Qt::CTRL + Qt::Key_S);

  QAction *action_save_as = new QAction(this);
  action_save_as->setText("Save as");
  action_save_as->setShortcut(Qt::SHIFT + Qt::CTRL + Qt::Key_S);

  QAction *action_close = new QAction(this);
  action_close->setText("Close");
  action_close->setShortcut(Qt::CTRL + Qt::Key_W);

  QAction *action_export = new QAction(this);
  action_export->setText("Export OBJ");

  QAction *action_undo = editor->getUndoStack()->createUndoAction(this, "Undo");
  action_undo->setShortcut(QKeySequence::Undo);

  QAction *action_redo = editor->getUndoStack()->createRedoAction(this, "Redo");
  action_redo->setShortcut(QKeySequence::Redo);

  QAction *action_indent = new QAction(this);
  action_indent->setText("Indent");
  action_indent->setShortcut(Qt::CTRL + Qt::Key_BracketRight);

  QAction *action_unindent = new QAction(this);
  action_unindent->setText("Unindent");
  action_unindent->setShortcut(Qt::CTRL + Qt::Key_BracketLeft);

  QAction *action_comment = new QAction(this);
  action_comment->setText("Toggle comment");
  action_comment->setShortcut(Qt::CTRL + Qt::Key_Slash);

  // Toolbar
  QToolBar *toolbar = new QToolBar(this);
  toolbar->setMovable(false);
  addToolBar(Qt::TopToolBarArea, toolbar);
  toolbar->addAction(action_solidify);
  toolbar->addAction(action_pathify);
  toolbar->addAction(action_fit);

  // Status bar
  QStatusBar *statusBar = new QStatusBar(this);
  setStatusBar(statusBar);

  // Menubar
  QMenuBar *menuBar = new QMenuBar();
  setMenuBar(menuBar);

  QMenu *menuFile = new QMenu(menuBar);
  menuFile->setTitle("File");
  menuFile->addAction(action_open);
  menuFile->addAction(action_save);
  menuFile->addAction(action_save_as);
  menuFile->addAction(action_close);
  menuFile->addAction(action_new);
  menuFile->addSeparator();
  menuFile->addAction(action_export);

  QMenu *menuEdit = new QMenu(menuBar);
  menuEdit->setTitle("Edit");
  menuEdit->addAction(action_undo);
  menuEdit->addAction(action_redo);
  menuEdit->addAction(action_indent);
  menuEdit->addAction(action_unindent);
  menuEdit->addAction(action_comment);

  QMenu *menuView = new QMenu(menuBar);
  menuView->setTitle("View");
  menuView->addAction(action_settings);
  menuView->addAction(action_screenshot);
  menuView->addAction(action_text_bigger);
  menuView->addAction(action_text_smaller);

  QMenu *menuHelp = new QMenu(menuBar);
  menuHelp->setTitle("Help");
  menuHelp->addAction(action_documentation);

  setWindowTitle("Madeup");
  menuBar->addAction(menuFile->menuAction());
  menuBar->addAction(menuEdit->menuAction());
  menuBar->addAction(menuView->menuAction());
  menuBar->addAction(menuHelp->menuAction());

  // Events
  connect(settings_picker, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged), settings_pager, &QStackedWidget::setCurrentIndex);
  connect(action_solidify, &QAction::triggered, this, &MadeupWindow::onSolidify);
  connect(action_pathify, &QAction::triggered, this, &MadeupWindow::onPathify);
  connect(action_fit, &QAction::triggered, this, &MadeupWindow::onFit);
  connect(select_font_button, &QPushButton::clicked, this, &MadeupWindow::selectFont);
  connect(editor, &QPlainTextEdit::textChanged, this, &MadeupWindow::onTextChanged);

  connect(action_undo, &QAction::triggered, editor, &MadeupEditor::undo);
  connect(action_redo, &QAction::triggered, editor, &MadeupEditor::redo);
  connect(action_indent, &QAction::triggered, editor, &MadeupEditor::indent);
  connect(action_unindent, &QAction::triggered, editor, &MadeupEditor::unindent);
  connect(action_comment, &QAction::triggered, editor, &MadeupEditor::comment);

  connect(console, &QTextBrowser::anchorClicked, [=](const QUrl &link) {
    string command = link.toString().toStdString();

    std::smatch groups;
    if (std::regex_match(command, groups, std::regex("jump\\?start=(\\d+)&end=(\\d+)"))) {
      auto group = groups.begin();
      ++group;

      int a = td::Utilities::ToInt(*group);
      ++group;

      int b = td::Utilities::ToInt(*group);
      ++group;

      QTextCursor cursor(editor->document());
      cursor.setPosition(a, QTextCursor::MoveAnchor);
      cursor.setPosition(b + 1, QTextCursor::KeepAnchor);
      editor->setTextCursor(cursor);
    }
  });

  connect(negative_x_button, &QPushButton::clicked, [=]() {
    canvas->makeCurrent();
    renderer->viewFromAxis(0, -1);
    canvas->update();
  });

  connect(positive_x_button, &QPushButton::clicked, [=]() {
    canvas->makeCurrent();
    renderer->viewFromAxis(0, 1);
    canvas->update();
  });

  connect(negative_y_button, &QPushButton::clicked, [=]() {
    canvas->makeCurrent();
    renderer->viewFromAxis(1, -1);
    canvas->update();
  });

  connect(positive_y_button, &QPushButton::clicked, [=]() {
    canvas->makeCurrent();
    renderer->viewFromAxis(1, 1);
    canvas->update();
  });

  connect(negative_z_button, &QPushButton::clicked, [=]() {
    canvas->makeCurrent();
    renderer->viewFromAxis(2, -1);
    canvas->update();
  });

  connect(positive_z_button, &QPushButton::clicked, [=]() {
    canvas->makeCurrent();
    renderer->viewFromAxis(2, 1);
    canvas->update();
  });

  connect(action_text_bigger, &QAction::triggered, [=]() {
    QFont font = editor->font();
    font.setPointSize(font.pointSize() + 2);
    editor->setFont(font);
  });

  connect(action_text_smaller, &QAction::triggered, [=]() {
    QFont font = editor->font();
    font.setPointSize(font.pointSize() - 2);
    editor->setFont(font);
  });

  connect(autopathify_timer, &QTimer::timeout, [=]() {
    onPathify();
  });

  connect(face_style_picker, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged), [=](int i) {
    canvas->makeCurrent(); // no effect without this
    renderer->setRenderStyle(i);
    canvas->update();
  });

  connect(action_documentation, &QAction::triggered, [=]() {
    QDesktopServices::openUrl(QUrl("http://madeup.xyz/docs/introduction.html"));
  });

  connect(action_screenshot, &QAction::triggered, this, [=]() {
    canvas->makeCurrent();
    QString path = QFileDialog::getSaveFileName(this, "Save Screenshot", last_directory, "Images (*.png *.jpg *.gif)");
    if (path.length() != 0) {
      last_directory = QFileInfo(path).absolutePath();
      canvas->makeCurrent();
      renderer->takeScreenshot(path.toStdString());
    }
  });

  connect(action_open, &QAction::triggered, [=]() {
    QString path = QFileDialog::getOpenFileName(this, "Open File", last_directory, "Madeup Programs (*.mup)");
    if (path.length() != 0) {
      last_directory = QFileInfo(path).absolutePath();
      std::cout << "last_directory: " << last_directory.toStdString() << std::endl;
      open(path.toStdString());
    }
  });

  connect(action_close, &QAction::triggered, [=]() {
    close();
  });

  connect(action_save, &QAction::triggered, [=]() {
    if (mup_path.length() != 0) {
      saveAs(mup_path); 
    } else {
      QString path = QFileDialog::getSaveFileName(this, "Save File", last_directory, "Madeup Programs (*.mup)");
      if (path.length() != 0) {
        last_directory = QFileInfo(path).absolutePath();
        saveAs(path.toStdString()); 
      }
    }
  });

  connect(action_save_as, &QAction::triggered, [=]() {
    QString path = QFileDialog::getSaveFileName(this, "Save File", last_directory, "Madeup Programs (*.mup)");
    if (path.length() != 0) {
      last_directory = QFileInfo(path).absolutePath();
      saveAs(path.toStdString());
    }
  });

  connect(action_new, &QAction::triggered, [=]() {
    MadeupWindow *new_window = new MadeupWindow();
    // This window has no parent, so who's gonna delete it? Itself.
    new_window->setAttribute(Qt::WA_DeleteOnClose);
    new_window->show();
  });

  connect(action_export, &QAction::triggered, [=]() {
    QString path = QFileDialog::getSaveFileName(this, "Export File", last_directory, "Wavefront OBJ Files (*.obj)");
    if (path.length() != 0) {
      last_directory = QFileInfo(path).absolutePath();
      renderer->exportTrimesh(path.toStdString());
    }
  });

  connect(background_color_button, &QPushButton::clicked, [=](){
    selectColor(renderer->getBackgroundColor(), [=](const QColor &color) {
      canvas->makeCurrent(); // no effect without this
      renderer->setBackgroundColor(td::QVector4<float>(color.red() / 255.0f, color.green() / 255.0f, color.blue() / 255.0f, color.alpha() / 255.0f));
      canvas->update();
      QPalette palette;
      palette.setColor(QPalette::Button, color);
      background_color_button->setPalette(palette);
    });
  });

  connect(path_color_button, &QPushButton::clicked, [=](){
    selectColor(renderer->getPathColor(), [=](const QColor &color) {
      this->canvas->makeCurrent(); // no effect without this
      this->renderer->setPathColor(td::QVector4<float>(color.red() / 255.0f, color.green() / 255.0f, color.blue() / 255.0f, color.alpha() / 255.0f));
      this->canvas->update();
      QPalette palette;
      palette.setColor(QPalette::Button, color);
      path_color_button->setPalette(palette);
    });
  });

  connect(vertex_color_button, &QPushButton::clicked, [=](){
    selectColor(renderer->getVertexColor(), [=](const QColor &color) {
      this->canvas->makeCurrent(); // no effect without this
      this->renderer->setVertexColor(td::QVector4<float>(color.red() / 255.0f, color.green() / 255.0f, color.blue() / 255.0f, color.alpha() / 255.0f));
      this->canvas->update();
      QPalette palette;
      palette.setColor(QPalette::Button, color);
      vertex_color_button->setPalette(palette);
    });
  });

  connect(action_settings, &QAction::toggled, [=](bool is_checked) {
    settings_panel->setVisible(is_checked);
      
    // If a collapsed settings panel is being made visible again, we'll have to
    // make it bigger. Otherwise only the handle will appear.
    if (is_checked && settings_panel->width() == 0) {
      // Let's resize the views. The editor and canvas can retain their current
      // sizes. The panel can be made its minimum size. We guess 1; Qt will take
      // max(1, minimum size).
      QList<int> sizes = horizontal_splitter->sizes();
      sizes[2] = 1;
      horizontal_splitter->setSizes(sizes);
    }
  });

  connect(show_console_checkbox, &QCheckBox::toggled, [=](bool is_checked) {
    console->setVisible(is_checked);
  });

  connect(faceted_checkbox, &QCheckBox::toggled, [=](bool is_checked) {
    onRun(GeometryMode::SURFACE);
  });

  connect(is_two_sided_checkbox, &QCheckBox::toggled, [=](bool is_checked) {
    canvas->makeCurrent();
    renderer->isTwoSided(is_checked);
    canvas->update();
  });

  connect(has_autorotate_checkbox, &QCheckBox::toggled, [=](bool is_checked) {
    canvas->makeCurrent();
    renderer->hasAutorotate(is_checked);
    canvas->update();
  });

  connect(has_specular_checkbox, &QCheckBox::clicked, [=](bool is_checked) {
    canvas->makeCurrent();
    renderer->hasSpecular(is_checked);
    canvas->update();
  });

  connect(show_heading_checkbox, &QCheckBox::toggled, [=](bool is_checked) {
    canvas->makeCurrent();
    renderer->showHeading(is_checked);
    canvas->update();
  });

  connect(show_path_checkbox, &QCheckBox::toggled, [=](bool is_checked) {
    canvas->makeCurrent();
    renderer->showPath(is_checked);
    canvas->update();
  });

  connect(show_stops_checkbox, &QCheckBox::toggled, [=](bool is_checked) {
    canvas->makeCurrent();
    renderer->showStops(is_checked);
    canvas->update();
  });

  for (int d = 0; d < 3; ++d) {
    // TODO need local?
    int dd = d;

    connect(show_axis_checkboxes[d], &QCheckBox::toggled, [=](bool is_checked) {
      canvas->makeCurrent();
      renderer->showAxis(dd, is_checked);
      canvas->update();
    });

    connect(show_grid_checkboxes[d], &QCheckBox::toggled, [=](bool is_checked) {
      canvas->makeCurrent();
      renderer->showGrid(dd, is_checked);
      canvas->update();
    });

    connect(grid_extent_spinners[d], static_cast<void(QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged), [=](double value) {
      canvas->makeCurrent();
      renderer->setGridExtent(dd, (float) value);
      canvas->update();
    });

    connect(grid_spacing_spinners[d], static_cast<void(QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged), [=](double value) {
      canvas->makeCurrent();
      renderer->setGridSpacing(dd, (float) value);
      canvas->update();
    });
  }

  connect(azimuth_angle_spinner, static_cast<void(QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged), [=](double value) {
    canvas->makeCurrent();
    renderer->setAzimuthAngle(value);
    canvas->update();
  });

  connect(elevation_angle_spinner, static_cast<void(QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged), [=](double value) {
    canvas->makeCurrent();
    renderer->setElevationAngle(value);
    canvas->update();
  });

  connect(shininess_spinner, static_cast<void(QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged), [=](double value) {
    canvas->makeCurrent();
    renderer->setShininess(value);
    canvas->update();
  });

  connect(light_distance_factor_spinner, static_cast<void(QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged), [=](double value) {
    canvas->makeCurrent();
    renderer->setLightDistanceFactor(value);
    canvas->update();
  });

  connect(axis_stroke_width_spinner, static_cast<void(QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged), [=](double value) {
    canvas->makeCurrent();
    renderer->setAxisStrokeWidth(value);
    canvas->update();
  });

  connect(grid_stroke_width_spinner, static_cast<void(QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged), [=](double value) {
    canvas->makeCurrent();
    renderer->setGridStrokeWidth(value);
    canvas->update();
  });

  connect(autopathify_checkbox, &QCheckBox::toggled, [=](bool is_checked) {
    // We don't need to do much here. If a previous timer was started, cancel it.
    if (!is_checked) {
      autopathify_timer->stop(); 
    }
  });

  connect(path_stroke_width_spinner, static_cast<void(QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged), [=](double d) {
    canvas->makeCurrent();
    renderer->setPathStrokeWidth((float) d);
    canvas->update();
  });

  connect(vertex_size_spinner, static_cast<void(QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged), [=](double d) {
    renderer->setVertexSize((float) d);
    canvas->update();
  });

  // Tweaks
  editor->blockSignals(true);
  editor->setPlainText("moveto 0, 0, 0\n");
                  /* "repeat 4\n" */
                  /* "  move 10\n" */
                  /* "  yaw 90\n" */
                  /* "end\n" */
                  /* "dowel\n"); */
  onTextChanged();
  setWindowTitle("Madeup");
  editor->blockSignals(false);
}
コード例 #20
0
///
/// Public Funcitons
///
//!
//! Fills the given tool bars with actions for the TableViewPanel view.
//!
//! \param mainToolBar The main tool bar to fill with actions.
//! \param panelToolBar The panel tool bar to fill with actions.
//!
void TableViewPanel::fillToolBars ( QToolBar *mainToolBar, QToolBar *panelToolBar )
{
	// Temp
	QAction *ui_descriptionAction;
	ui_descriptionAction = new QAction(this);
    ui_descriptionAction->setObjectName(QString::fromUtf8("ui_descriptionAction"));
    ui_descriptionAction->setCheckable(true);
    QIcon icon1;
    icon1.addFile(QString::fromUtf8(":/infoIcon"), QSize(), QIcon::Normal, QIcon::Off);
    ui_descriptionAction->setIcon(icon1);
	ui_descriptionAction->setToolTip("Show Description");

	connect(ui_descriptionAction, SIGNAL(toggled(bool)), this, SLOT(showDiscription(bool)));

	// Column visibility select control
	// Place holder for drop down to select which columns of table are visible
	// This should be populated with column names
	QAction *visibilityAct = new QAction(tr("&Select Columns..."), this);
	visibilityAct->setStatusTip(tr("Select columns for visibility..."));
    connect(visibilityAct, SIGNAL(triggered()), this, SLOT());

	QMenu *visibilityMenu = new QMenu();
	visibilityMenu->addAction(visibilityAct);
    visibilityMenu->addSeparator();

	QString menuStyleSheet (
        "QMenuBar {"
        "    border: none;"
        "    margin: 0px;"
        "    padding: 0px;"
		"    background: none;"
        "}"
        "QMenuBar::item {"
        "    background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #a5a5a5, stop:0.2 #999999, stop:0.8 #b0b0b0, stop:1 #555555);"
        "    color: #000000;"
		"    border: 1px solid #323232"
        "    border-radius: 5px;"
        "}"
        "QMenuBar::item:selected {"
        "    background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #a6a6a6, stop:1 #8a8a8a);"
        "    color: #000000;"
		"    border: 1px solid #222222"
        "    border-radius: 5px;"
        "}"
        "QMenuBar::item:pressed {"
        "    background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #a6a6a6, stop:1 #8a8a8a);"
        "    color: #000000;"
		"    border: 1px solid #222222"
        "    border-radius: 5px;"
        "}"
    );

	QMenuBar *visibilityMenuBar = new QMenuBar();
	visibilityMenuBar->setMinimumWidth(50);
	visibilityMenuBar->setStyleSheet(menuStyleSheet);
	visibilityMenuBar->addMenu(visibilityMenu);
	visibilityMenuBar->addAction(visibilityAct);

	// Search control
	// Keyword search highlights rows

	QLineEdit *searchField = new QLineEdit();
	searchField->setMaximumWidth(200);

	mainToolBar->addAction(ui_descriptionAction);
	mainToolBar->addSeparator();
	mainToolBar->addWidget(visibilityMenuBar);
	mainToolBar->addSeparator();
	mainToolBar->addWidget(searchField);
}