Пример #1
0
void LogsProcessor::threadProc()
{
    while (!needStop())
    {
        {
            CSectionLock _lock(m_cs);
            if (!m_msgs.empty())
            {
                int last = m_msgs.size() - 1;
                msg m = m_msgs[last];
                m_msgs.pop_back();
                m_msgs.swap(m_towrite);
                m_msgs.push_back(m);
            }
        }
        if (m_towrite.empty())
        {
            closeReqLogs();
            Sleep(250);
            continue;
        }
        saveAll();
        closeReqLogs();
    }
    
    {
        CSectionLock _lock(m_cs);
        if (!m_msgs.empty())    
            m_msgs.swap(m_towrite);
    }
    saveAll();    
    closeReqLogs();
}
Пример #2
0
bool DBBrowserDB::close()
{
    if(_db)
    {
        if (getDirty())
        {
            QMessageBox::StandardButton reply = QMessageBox::question(0,
                                                                      QApplication::applicationName(),
                                                                      QObject::tr("Do you want to save the changes "
                                                                                  "made to the database file %1?").arg(curDBFilename),
                                                                      QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel);

            // If the user clicked the cancel button stop here and return false
            if(reply == QMessageBox::Cancel)
                return false;

            // If he didn't it was either yes or no
            if(reply == QMessageBox::Yes)
                saveAll();
            else
                revertAll(); //not really necessary, I think... but will not hurt.
        }
        sqlite3_close(_db);
    }
    _db = 0;
    objMap.clear();
    savepointList.clear();
    emit dbChanged(getDirty());

    // Return true to tell the calling function that the closing wasn't cancelled by the user
    return true;
}
Пример #3
0
void EditMetadataCommon::showSaveMenu()
{
    updateMetadata();

    if (!hasMetadataChanged())
    {
        Close();
        return;
    }

    QString label = tr("Save Changes?");

    MythScreenStack *popupStack = GetMythMainWindow()->GetStack("popup stack");

    MythDialogBox *menu = new MythDialogBox(label, popupStack, "savechangesmenu");

    if (!menu->Create())
    {
        delete menu;
        return;
    }

    menu->SetReturnEvent(this, "savechangesmenu");

    if (metadataOnly)
        menu->AddButton(tr("Save Changes"), SLOT(saveToMetadata()));
    else
        menu->AddButton(tr("Save Changes"), SLOT(saveAll()));

    menu->AddButton(tr("Exit/Do Not Save"), SLOT(cleanupAndClose()));
    menu->AddButton(tr("Cancel"));

    popupStack->AddScreen(menu);
}
int ONScripterLabel::saveSaveFile( int no, const char *savestr, bool no_error )
{
    // make save data structure on memory
    if ((no < 0) || (saveon_flag && internal_saveon_flag)){
        file_io_buf_ptr = 0;
        saveMagicNumber( false );
        saveSaveFile2( false );
        allocFileIOBuf();
        saveMagicNumber( true );
        saveSaveFile2( true );
        save_data_len = file_io_buf_ptr;
        memcpy(save_data_buf, file_io_buf, save_data_len);
    }

    if ( no >= 0 ){
        saveAll(no_error);

        char filename[16];
        sprintf( filename, "save%d.dat", no );

        memcpy(file_io_buf, save_data_buf, save_data_len);
        file_io_buf_ptr = save_data_len;
        if (saveFileIOBuf( filename, 0, savestr )){
            return -1;
        }

        size_t magic_len = strlen(SAVEFILE_MAGIC_NUMBER)+2;
        sprintf( filename, "sav%csave%d.dat", DELIMITER, no );
        if (saveFileIOBuf( filename, magic_len, savestr ))
            fprintf( stderr, "can't open save file %s for writing (not an error)\n", filename );
    }

    return 0;
}
Пример #5
0
void FlashData::saveGlyphs() {
  if (_ram.magic == FLASH_MAGIC && _ram.version == FLASH_VERSION) {
    EEPROM.put(FLASH_GLYPHS_ADDRESS, _ram.glyphs);
  } else {
    saveAll();
  }
}
Пример #6
0
int MaterialWidget::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QWidget::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: refresh((*reinterpret_cast< string(*)>(_a[1]))); break;
        case 1: currentMatChanged((*reinterpret_cast< QString(*)>(_a[1]))); break;
        case 2: saveAll(); break;
        case 3: addNewMaterial(); break;
        case 4: nameChanged((*reinterpret_cast< QString(*)>(_a[1]))); break;
        case 5: specChanged((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 6: shineChanged((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 7: colorChanged(); break;
        case 8: glowChanged(); break;
        case 9: currentTexChanged((*reinterpret_cast< QString(*)>(_a[1]))); break;
        case 10: currentNormChanged((*reinterpret_cast< QString(*)>(_a[1]))); break;
        case 11: uTexOffChanged((*reinterpret_cast< QString(*)>(_a[1]))); break;
        case 12: vTexOffChanged((*reinterpret_cast< QString(*)>(_a[1]))); break;
        case 13: uTexScaleChanged((*reinterpret_cast< QString(*)>(_a[1]))); break;
        case 14: vTexScaleChanged((*reinterpret_cast< QString(*)>(_a[1]))); break;
        case 15: texRotateChanged((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 16: normalChanged(); break;
        default: ;
        }
        _id -= 17;
    }
    return _id;
}
Пример #7
0
void FlashData::saveDisplay() {
  if (_ram.magic == FLASH_MAGIC && _ram.version == FLASH_VERSION) {
    EEPROM.put(FLASH_DISPLAY_ADDRESS, _ram.disp);
  } else {
    saveAll();
  }
}
Пример #8
0
void FlashData::save() {
  if (_ram.magic == FLASH_MAGIC && _ram.version == FLASH_VERSION) {
    EEPROM.put(FLASH_LEDS_ADDRESS, _ram.leds);
  } else {
    saveAll();
  }
}
Пример #9
0
void EditMetadataDialog::showSaveMenu()
{
    popup = new MythPopupBox(GetMythMainWindow(), "Menu");

    QLabel *label = popup->addLabel(tr("Save Changes?"), MythPopupBox::Large, false);
    label->setAlignment(Qt::AlignCenter | Qt::WordBreak);
    QAbstractButton *topButton;

    if (metadataOnly)
    {
        topButton = popup->addButton(tr("Save Changes"), this,
                                        SLOT(saveToMetadata()));
    }
    else
    {
        topButton = popup->addButton(tr("Save Changes"), this,
                                     SLOT(saveAll()));
    }

    popup->addButton(tr("Exit/Do Not Save"), this,
                            SLOT(closeDialog()));

    popup->addButton(tr("Cancel"), this, SLOT(cancelPopup()));

    popup->ShowPopup(this, SLOT(cancelPopup()));

    topButton->setFocus();
}
Пример #10
0
/**
void Port::savePortData (uint8_t portAddress, uint32_t currentPeriod)
  Formats and saves sensor data to EEPROM
@param uint8_t portAddress
  portAddress must be a valid port address between 0 and PORT_MAX.Since port addresses start at 1
  there is an offset of 1 between array position and port address.
@param uint32_t currentPeriod
  The current period of the experiemnt.
@return void
**/
void Port::savePortData (uint8_t portAddress, uint32_t currentPeriod){
    //checking boundry conditions
    if (portAddress < 0 || portAddress > PORT_MAX){
        respond(SDI_ABORT);
    }
    //if portAddress is 0 save data from all ports
    else if (portAddress == 0){
        saveAll(currentPeriod);
    }
    else {
        //create a data block to formate and store data in EEPROM
        DataBlock newData;
        newData.port = portAddress;
        newData.periodNumber = currentPeriod;
        //need to switch on sensor type to take the correct measurment.
        if ((*ports[portAddress -1]).getType() == SENSOR_TYPE_A){
            SENSOR_RETURN_TYPE_A temp = (*ports[portAddress -1]).measureTemp();
            newData.data = *(reinterpret_cast <uint32_t*> (&temp));
        }
        else if ((*ports[portAddress -1]).getType() == SENSOR_TYPE_B){
            SENSOR_RETURN_TYPE_B temp = (*ports[portAddress -1]).measureLight();
            newData.data = *(reinterpret_cast <uint32_t*> (&temp));
        }
        //save block to memory
        (*memory).saveDataBlock(newData);
    }
}
Пример #11
0
    Manager::~Manager() {
        // Cleanup timer
        stopTimer();
        delete _saveTimer;

        // Save all settings before exit
        saveAll();

        // sync will be called in the QSettings destructor
    }
Пример #12
0
 void Manager::startTimer() {
     if (!_saveTimer) {
         _saveTimer = new QTimer(this);
         Q_CHECK_PTR(_saveTimer);
         _saveTimer->setSingleShot(true); // We will restart it once settings are saved.
         _saveTimer->setInterval(SAVE_INTERVAL_MSEC);
         connect(_saveTimer, SIGNAL(timeout()), this, SLOT(saveAll()));
     }
     _saveTimer->start();
 }
Пример #13
0
void MainWindow::exportToXml() {
    QString fileName = QFileDialog::getSaveFileName();
    try {
        saveAll(fileName);
    }
    catch (CalendarException e){
        QMessageBox* error = new QMessageBox(this);
        error->setText(e.getInfo());
        error->show();
    }
}
Пример #14
0
void QuickTaskCreator::saveAll(){
    QuickTaskTask *task;
    //task = static_cast<QuickTaskTask>(this->taskWidgets.at(x));
    if(this->taskWidgets.count())
        task=this->taskWidgets.takeFirst();
    else return;
    if(task){
        connect(task,SIGNAL(saveCompleted()),this,SLOT(saveAll()));
        task->save();
    }

}
Пример #15
0
/******************************************************************************
  * version:    1.0
  * author:     link
  * date:       2016.01.28
  * brief:      按钮功能
******************************************************************************/
void w_Hide::buttonJudge(int id)
{
    switch(id){
    case W_SYST_EXIT:
        emit switchWindow(W_SYST);
        break;
    case W_SYST_SAVE:
        emit saveAll();
        break;
    default:
        break;
    }
}
Пример #16
0
/******************************************************************************
  * version:    1.0
  * author:     link
  * date:       2015.12.10
  * brief:      按钮功能
******************************************************************************/
void w_Conf::buttonJudge(int id)
{
    int index;
    switch (id){
    case W_CONF_EXIT:
        emit switchWindow(W_TEST);
        break;
    case W_CONF_SAVE:
        if (wAll != NULL){
            CONF = wAll->output();
            wAll->setHardware();
        }
        if (wRes != NULL){
            RES = wRes->output();
            wRes->setHardware();
        }
        if (wOpp != NULL){
            OPP = wOpp->output();
            wOpp->setHardware();
        }
        if (wIns != NULL){
            INS = wIns->output();
            wIns->setHardware();
        }
        if (wAcv != NULL){
            ACV = wAcv->output();
            wAcv->setHardware();
        }
        if (wDcv != NULL){
            DCV = wDcv->output();
            wDcv->setHardware();
        }
        if (wItt != NULL){
            ITT = wItt->output();
            wItt->setHardware();
        }
        emit saveAll();
        break;
    case W_CONF_EASY:
        break;
    case W_CONF_CULL:
        index = tabWidget->currentIndex();
        if (tabWidget->tabText(index) == tr("反嵌"))
            wOpp->startDebug();
        if (tabWidget->tabText(index) == tr("匝间"))
            wItt->startDebug();
        break;
    default:
        break;
    }
}
Пример #17
0
QMenuBar *TeamBuilder::createMenuBar(MainEngine *w)
{
    QMenuBar *menuBar = new QMenuBar();
    menuBar->setObjectName("TeamBuilder");
    QMenu *fileMenu = menuBar->addMenu(tr("&File"));
    fileMenu->addAction(tr("&New"),this,SLOT(newTeam()),tr("Ctrl+N", "New"));
    fileMenu->addAction(tr("&Save all"),this,SLOT(saveAll()),tr("Ctrl+S", "Save all"));
    fileMenu->addAction(tr("&Load all"),this,SLOT(openLoadWindow()),tr("Ctrl+L", "Load all"));
    fileMenu->addSeparator();
    fileMenu->addAction(tr("&Quit"),qApp,SLOT(quit()),tr("Ctrl+Q", "Quit"));
    QMenu *teamMenu = menuBar->addMenu(tr("&Team"));
    if (currentWidget() && currentWidget() == this->teamMenu) {
        teamMenu->addAction(tr("Choose pokemon"), this->teamMenu, SLOT(choosePokemon()), tr("Alt+E", "Choose Pokemon"));
    }
    teamMenu->addAction(tr("Trainer Menu"), this, SLOT(switchToTrainer()), tr("Ctrl+B", "Trainer Menu"));
    teamMenu->addSeparator();
    teamMenu->addAction(tr("&Add team"), this, SLOT(addTeam()), tr("Ctrl+A", "Add team"));
    teamMenu->addAction(tr("&Load team"), this, SLOT(openTeam()), tr("Ctrl+Shift+L", "Load team"));
    teamMenu->addAction(tr("&Save team"), this, SLOT(saveTeam()), tr("Ctrl+Shift+S", "Save team"));
    teamMenu->addAction(tr("&Import team"), this, SLOT(importTeam()), tr("Ctrl+I", "Import team"));
    teamMenu->addAction(tr("&Export team"), this, SLOT(exportTeam()), tr("Ctrl+E", "Export team"));
    teamMenu->addSeparator();
    teamMenu->addAction(tr("Import from Android"), this, SLOT(importAndroid()), tr("Ctrl+Shift+I", "Import from Android"));
    teamMenu->addAction(tr("Export to Android"), this, SLOT(exportAndroid()), tr("Ctrl+Shift+E", "Export to Android"));

    currentWidget()->addMenus(menuBar);

    /* Loading mod menu */
    QMenu *menuMods = menuBar->addMenu(tr("&Mods"));
    QActionGroup *group = new QActionGroup(menuMods);

    QString currentMod = PokemonInfoConfig::currentMod();
    // No mod option.
    QAction *noMod = menuMods->addAction(tr("&No mod"), this, SLOT(setNoMod()));
    noMod->setCheckable(true);
    noMod->setChecked(currentMod.length()==0);
    group->addAction(noMod);

    menuMods->addSeparator();

    QStringList mods = PokemonInfoConfig::availableMods();

    foreach(QString smod, mods) {
        QAction *mod = menuMods->addAction(smod, this, SLOT(changeMod()));
        mod->setProperty("name", smod);
        mod->setCheckable(true);
        mod->setChecked(currentMod == smod);
        group->addAction(mod);
    }
Пример #18
0
int SetWidget::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QWidget::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: saveAll(); break;
        case 1: chooseColor(); break;
        case 2: changeBackground(); break;
        default: ;
        }
        _id -= 3;
    }
    return _id;
}
Пример #19
0
QuickTaskCreator::QuickTaskCreator(QWidget *parent) :
    QMainWindow(parent),
    m_ui(new Ui::QuickTaskCreator)
{
    m_ui->setupUi(this);
    taskifyAction = new QAction(tr("&Taskify..."), this);
    connect(taskifyAction,SIGNAL(activated()),this,SLOT(taskify()));
    taskLayout = new QVBoxLayout();
    this->m_ui->toolBar->addAction(taskifyAction);
    taskLayout->setMargin(2);
    this->m_ui->taskListWidget->setLayout(taskLayout);
    this->defaultsWidget=new QuickTaskCreatorDefaults;
    this->m_ui->defaultsArea->setWidget(this->defaultsWidget);
//    this->connect(this->m_ui->editor,SIGNAL(textChanged()),this,SLOT(taskify()));

    this->connect(this->m_ui->saveAllButton,SIGNAL(clicked()),this,SLOT(saveAll()));
}
Пример #20
0
void PEditor::closeEvent(QCloseEvent *event) {
    int ret = QMessageBox::warning(this, tr("PEditor"),
                                   tr("Are you sure you want to quit?"),
                                   QMessageBox::Yes | QMessageBox::Default,
                                   QMessageBox::No | QMessageBox::Escape);

    if (ret == QMessageBox::No) {
        event->ignore();
        return;
    }

    saveAll();

    while (tabWidget->count())
        closeTab(0, true);

    writeSettings();
    event->accept();
}
Пример #21
0
/** Binds events (signals) to actions (slots). */
void
MessageLog::createActions()
{
  connect(ui.actionSave_Selected, SIGNAL(triggered()),
          this, SLOT(saveSelected()));

  connect(ui.actionSave_All, SIGNAL(triggered()),
          this, SLOT(saveAll()));

  connect(ui.actionSelect_All, SIGNAL(triggered()),
          this, SLOT(selectAll()));

  connect(ui.actionCopy, SIGNAL(triggered()),
          this, SLOT(copy()));

  connect(ui.actionFind, SIGNAL(triggered()),
          this, SLOT(find()));

  connect(ui.actionClear, SIGNAL(triggered()),
          this, SLOT(clear()));

  connect(ui.actionHelp, SIGNAL(triggered()),
          this, SLOT(help()));

  connect(ui.btnSaveSettings, SIGNAL(clicked()),
          this, SLOT(saveSettings()));

  connect(ui.btnCancelSettings, SIGNAL(clicked()),
          this, SLOT(cancelChanges()));

  connect(ui.btnBrowse, SIGNAL(clicked()),
          this, SLOT(browse()));

#if defined(Q_WS_MAC)
  ui.actionHelp->setShortcut(QString("Ctrl+?"));
#endif
  ui.actionClose->setShortcut(QString("Esc"));
  Vidalia::createShortcut("Ctrl+W", this, ui.actionClose, SLOT(trigger()));
}
//应用程式的主菜单:显示
int menuShow()
{
	//变量定义表
	uint MenuItem=1;

    scrcls();
	
	puts("<=-------------------------------------=>");
	puts("         小 学 数 学 考 试 系 统");
	puts("        Designed by www.fcsys.us.");
	puts("<=-------------------------------------=>");
	puts("       [1]随机生成10数学试题");
	puts("       [2]开始进行本次数学考试");
	puts("       [3]保存本次数学考试记录");
	puts("       [4]查询历史数学考试记录");
	puts("       [5]当次前次考试成绩对比");
	puts("       [6]保存考试成绩到文件中");
	puts("       [7]退出小学数学考试系统");
	puts("<=-------------------------------------=>");
	printf("\n请输入当前的选择项目[1-7限定]:");

	//处理用户输入选项
	scanf("%d",&MenuItem);
	if(MenuItem>7||MenuItem<1)
		menuShow();				//0:控制重新显示菜单
	else
		switch(MenuItem)		//N:控制菜单执行
		{
			case 1:genItem();break;
			case 2:doWork();break;
			case 3:saveCurrent(0);break;
			case 4:viewHistory(0);break;
			case 5:viewAll();break;
			case 6:saveAll();break;
			case 7:exit(0);
		}
	return 0;
}
Пример #23
0
/*!
 \brief IDE main class constructor

 \param parent
*/
WindowIDE::WindowIDE(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::WindowIDE)
{
    ui->setupUi(this);

    tabifyDockWidget(ui->projectDockWidget,ui->filesDockWidget);
    this->setWindowTitle(tr("PockEmul Integrated Development Environment"));
    this->setAttribute(Qt::WA_DeleteOnClose,true);

    setupEditor();

    connect(ui->actionCompile, SIGNAL(triggered()), this, SLOT(compile()));
    connect(ui->actionSave,SIGNAL(triggered()),this,SLOT(save()));
    connect(ui->actionSave_All,SIGNAL(triggered()),this,SLOT(saveAll()));
    //connect(ui->listWidget,SIGNAL(itemDoubleClicked(QListWidgetItem*)),this,SLOT(load(QListWidgetItem*)));
    connect(ui->treeView,SIGNAL(doubleClicked(QModelIndex)),this,SLOT(load(QModelIndex)));
    connect(ui->tabWidget,SIGNAL(tabCloseRequested(int)),this,SLOT(closeEditorTab(int)));
    connect(ui->outputtabWidget,SIGNAL(tabCloseRequested(int)),this,SLOT(closeOutputTab(int)));
    connect(ui->actionNew,SIGNAL(triggered()),this,SLOT(newFile()));

    connect(mainwindow,SIGNAL(DestroySignal(CPObject*)),this,SLOT(DestroySlot(CPObject*)));
}
Пример #24
0
void IScriptEditor::closeEvent(QCloseEvent *e)
{
    // See if we got any modified files...
    QHashIterator<QString,file_t> i(files);
    bool modified = false;
    while (i.hasNext()) {
        i.next();
        if (i.value().modified)
            modified = true;
        if (modified)
            break;
    }

    if (modified) {
        int b = QMessageBox::question(this, tr("Unsaved changes"),
                                      tr("Do you want to save the changes?"),
                                      QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel, QMessageBox::Cancel);

        if (b == QMessageBox::Yes)
            saveAll();
        if (b == QMessageBox::Cancel)
            e->ignore();
    }
}
Пример #25
0
void MainWindow::initMenuFile() {
	//connect menu "File" Action
	connect(actionNew, SIGNAL(triggered()), _documentManager, SLOT(newDocument()));
	connect(actionOpen, SIGNAL(triggered()), _documentManager, SLOT(open()));
	connect(actionSave, SIGNAL(triggered()), _documentManager, SLOT(save()));
	connect(actionSaveAs, SIGNAL(triggered()), _documentManager, SLOT(saveAs()));
	connect(actionSaveACopyAs, SIGNAL(triggered()), _documentManager, SLOT(saveACopyAs()));
	connect(actionSaveAll, SIGNAL(triggered()), _documentManager, SLOT(saveAll()));
	connect(actionClose, SIGNAL(triggered()), _documentManager, SLOT(close()));
	connect(actionCloseAll, SIGNAL(triggered()), _documentManager, SLOT(closeAll()));
	connect(actionCloseAllExceptCurrentDocument, SIGNAL(triggered()), _documentManager, SLOT(closeAllExceptCurrentDocument()));
	connect(actionReload, SIGNAL(triggered()), _documentManager, SLOT(reload()));
	connect(actionPrint, SIGNAL(triggered()), _documentManager, SLOT(print()));
	connect(actionExit, SIGNAL(triggered()), qApp, SLOT(closeAllWindows()));

	connect(actionExportAsHTML, SIGNAL(triggered()), this, SLOT(exportDocument()));

	connect(actionNewSession, SIGNAL(triggered()), _sessionManager, SLOT(newSession()));
	connect(actionOpenSession, SIGNAL(triggered()), _sessionManager, SLOT(openSession()));
	connect(actionSwitchSession, SIGNAL(triggered()), _sessionManager, SLOT(switchSession()));
	connect(actionSaveSession, SIGNAL(triggered()), _sessionManager, SLOT(saveSession()));
	connect(actionSaveSessionAs, SIGNAL(triggered()), _sessionManager, SLOT(saveSessionAs()));
	connect(actionManageSessions, SIGNAL(triggered()), _sessionManager, SLOT(manageSessions()));

	//recent file actions
	connect(actionEmptyRecentFilesList, SIGNAL(triggered()), this, SLOT(clearRecentFile()));
	connect(actionOpenAllRecentFiles, SIGNAL(triggered()), this, SLOT(openAllRecentFile()));
	_recentFileSeparator = menuRecentFiles->addSeparator();
	for (int i = 0; i < MaxRecentFiles; ++i) {
		_recentFileActions[i] = new QAction(this);
		_recentFileActions[i]->setVisible(false);
		connect(_recentFileActions[i], SIGNAL(triggered()),this, SLOT(openRecentFile()));
		menuRecentFiles->addAction(_recentFileActions[i]);
	}
	updateRecentFileActions();
}
Пример #26
0
void MainWindow::on_actionSave_triggered()
{
    saveAll();
    configuratorWidget->saveOtherSettings();
    this->setWindowModified(false);
}
Пример #27
0
About::About(QWidget *parent) : QDialog(parent)
{
  setFixedSize(900, 470);
  setWindowIcon(QIcon(":icon.png"));
  setWindowTitle("Boris v" VERSION);

  move(QApplication::desktop()->width() / 2 - 225, QApplication::desktop()->height() / 2 - 250);
  // About tab
  QWidget *aboutWidget = new QWidget;
  QLabel *aboutText = new QLabel(tr("Boris bids you welcome! He is here to keep you company during all seasons of the year. He is a bit of a prankster, so keep an eye out for him!\n\n"
                                    "Functions:\n- You can throw Boris around your desktop by left-clicking him. Don't throw him too much though, or you'll bruise him...\n- Right-clicking Boris brings up a menu where you can select what you want Boris to do. Each activity is added to a queue and performed in the order you select them.\n- Right-click the tray icon to either quit, cause an earthquake, teleport or open this config/about box.\n\nVitality description:\n- The 'Zz' icon signifies Boris' energy level. Tell him to relax to give him more energy.\n- The 'knife and fork' icon shows how hungry Boris is. Tell him to eat to remove his hunger.\n- The 'toilet' icon is an indicator of Boris' need to go to the toilet. Tell him to weewee to make him feel better.\n- The 'speech bubble' icon shows Boris' need for social interaction. Move you mouse over him to interact with him. Boris will also socialize with other Boris clones when he meets them.\n- The 'smiley' icon indicates if Boris is in a good mood. If he's sad, tell him to do something fun.\n- If Boris is getting dirty, tell him to take a shower.\n\nIf your friends / colleagues become envious and would like a Boris of their own, simply ask them to visit http://www.muldjord.com/boris and download it. You can also download the full source code in there if you like. This software is COMPLETELY FREE and OPEN SOURCE (GPLv3)."));
  aboutText->setWordWrap(true);
  aboutText->setMaximumWidth(400);

  QVBoxLayout *aboutLayout = new QVBoxLayout();
  aboutLayout->addWidget(aboutText);
  aboutWidget->setLayout(aboutLayout);

  QScrollArea *aboutScroll = new QScrollArea();
  aboutScroll->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  aboutScroll->setWidget(aboutWidget);

  // Author tab
  QWidget *authorWidget = new QWidget;
  QLabel *authorText = new QLabel(tr("Programming: Lars Muldjord\nGraphics: Lars Muldjord\nSound: Lars Muldjord\n\nBoris was programmed using the Qt framework (http://www.qt.io) and C++.\n\nBug reports, suggestions and / or comments can be emailed to me at:\[email protected].\n\nIf your friends / colleagues would like to get their own Boris, tell them to visit:\n\nhttp://www.muldjord.com/boris\n\nIt's FREE and OPEN SOURCE (GPLv3), so there's absolutely no strings attached, just download away. You can also download the full source code in there if you like.\n\nCopyright 2016 Lars Muldjord. This software is distributed under the terms of the GNU General Public License. Be sure to read the license in the 'License' tab or check out the web page http://www.gnu.org/licenses/gpl-3.0.html."));
  authorText->setWordWrap(true);
  authorText->setMaximumWidth(400);

  QVBoxLayout *authorLayout = new QVBoxLayout();
  authorLayout->addWidget(authorText);
  authorWidget->setLayout(authorLayout);

  QScrollArea *authorScroll = new QScrollArea();
  authorScroll->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  authorScroll->setWidget(authorWidget);

  // License tab
  // Read COPYING data from file
  QFile file("COPYING.TXT");
  QByteArray gplText;
  if(file.open(QIODevice::ReadOnly)) {
    gplText = file.readAll();
    file.close();
  } else {
    printf("ERROR: Couldn't find COPYING file at the designated location.\n");
    gplText = "ERROR: File not found... This means that someone has been fiddling with the files of this software, and someone might be violating the terms of the GPL. Go to the following location to read the license: http://www.gnu.org/licenses/gpl-3.0.html";
  }

  QWidget *licenseWidget = new QWidget;
  QLabel *licenseText = new QLabel(gplText);
  licenseText->setWordWrap(true);
  licenseText->setMaximumWidth(400);

  QVBoxLayout *licenseLayout = new QVBoxLayout();
  licenseLayout->addWidget(licenseText);
  licenseWidget->setLayout(licenseLayout);

  QScrollArea *licenseScroll = new QScrollArea();
  licenseScroll->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  licenseScroll->setWidget(licenseWidget);

  QTabWidget *tabWidget = new QTabWidget;
  tabWidget->addTab(aboutScroll, tr("About"));
  tabWidget->addTab(authorScroll, tr("Author"));
  tabWidget->addTab(licenseScroll, tr("License"));
  
  QPushButton *okButton = new QPushButton(tr("Close and save"));
  connect(okButton, SIGNAL(clicked()), this, SLOT(saveAll()));

  QLabel *sizeLabel = new QLabel(tr("Boris size in pixels (32-256 or 0 for random):"));
  sizeLineEdit = new QLineEdit();
  QIntValidator *sizeValidator = new QIntValidator(32,256);
  sizeLineEdit->setValidator(sizeValidator);
  if(settings->contains("size")) {
    sizeLineEdit->setText(settings->value("size").toString());
  }

  QLabel *clonesLabel = new QLabel(tr("Boris clones (1-100):"));
  clonesLineEdit = new QLineEdit();
  QIntValidator *clonesValidator = new QIntValidator(1,100);
  clonesLineEdit->setValidator(clonesValidator);
  if(settings->contains("clones")) {
    clonesLineEdit->setText(settings->value("clones").toString());
  }

  alwaysWeather = new QCheckBox(tr("Show weather all the time"));
  if(settings->value("weather") == "true") {
    alwaysWeather->setCheckState(Qt::Checked);
  }

  QLabel *weatherLabel = new QLabel(tr("Show weather for city (mouse over for help):"));
  weatherLineEdit = new QLineEdit();
  weatherLineEdit->setToolTip(tr("Try typing in a nearby city. If it doesn't work, go to openweathermap.org and search for a city until you find one that exists.<br/>Then type that in exactly as it is shown on their website."));
  if(settings->contains("weather_city")) {
    weatherLineEdit->setText(settings->value("weather_city").toString());
  }

  QLabel *weatherKeyLabel = new QLabel(tr("OpenWeatherMap key (mouse over for help):"));
  weatherKeyLineEdit = new QLineEdit();
  weatherKeyLineEdit->setToolTip(tr("The weather functionality needs an API key to function. The default one should work.<br/>In case it doesn't, get a new one for free at openweathermap.org/appid"));
  if(settings->contains("weather_key")) {
    weatherKeyLineEdit->setText(settings->value("weather_key").toString());
  }

  showStats = new QCheckBox(tr("Always show vitality stats"));
  if(settings->value("stats") == "true") {
    showStats->setCheckState(Qt::Checked);
  }

  QLabel *independenceLabel = new QLabel(tr("Independence:"));
  independenceSlider = new QSlider(Qt::Horizontal);
  independenceSlider->setMinimum(0);
  independenceSlider->setMaximum(100);
  if(settings->contains("independence")) {
    independenceSlider->setValue(settings->value("independence").toInt());
  }

  enableChatter = new QCheckBox(tr("Enable Boris speech bubbles"));
  if(settings->value("chatter") == "true") {
    enableChatter->setCheckState(Qt::Checked);
  }

  enableSound = new QCheckBox(tr("Enable sound"));
  if(settings->value("sound") == "true") {
    enableSound->setCheckState(Qt::Checked);
  }

  QLabel *volumeLabel = new QLabel(tr("Sound volume:"));
  volumeSlider = new QSlider(Qt::Horizontal);
  volumeSlider->setMinimum(0);
  volumeSlider->setMaximum(100);
  if(settings->contains("volume")) {
    volumeSlider->setValue(settings->value("volume").toInt());
  }
  
  showWelcome = new QCheckBox(tr("Always show this dialog on startup"));
  if(settings->value("show_welcome") == "true") {
    showWelcome->setCheckState(Qt::Checked);
  }

  QVBoxLayout *configLayout = new QVBoxLayout();
  configLayout->addWidget(showWelcome);
  configLayout->addWidget(sizeLabel);
  configLayout->addWidget(sizeLineEdit);
  configLayout->addWidget(clonesLabel);
  configLayout->addWidget(clonesLineEdit);
  configLayout->addWidget(enableChatter);
  configLayout->addWidget(showStats);
  configLayout->addWidget(independenceLabel);
  configLayout->addWidget(independenceSlider);
  configLayout->addWidget(enableSound);
  configLayout->addWidget(volumeLabel);
  configLayout->addWidget(volumeSlider);
  configLayout->addWidget(alwaysWeather);
  configLayout->addWidget(weatherLabel);
  configLayout->addWidget(weatherLineEdit);
  configLayout->addWidget(weatherKeyLabel);
  configLayout->addWidget(weatherKeyLineEdit);
  
  QVBoxLayout *infoLayout = new QVBoxLayout;
  infoLayout->addWidget(tabWidget);
  infoLayout->addWidget(okButton);

  QHBoxLayout *layout = new QHBoxLayout;
  layout->addLayout(configLayout);
  layout->addLayout(infoLayout);
  
  setLayout(layout);
}
void Sample_TempObstacles::handleSettings()
{
    Sample::handleCommonSettings();

    if (imguiCheck("Keep Itermediate Results", m_keepInterResults))
        m_keepInterResults = !m_keepInterResults;

    imguiLabel("Tiling");
    imguiSlider("TileSize", &m_tileSize, 16.0f, 128.0f, 8.0f);

    int gridSize = 1;
    if (m_geom)
    {
        const float* bmin = m_geom->getNavMeshBoundsMin();
        const float* bmax = m_geom->getNavMeshBoundsMax();
        char text[64];
        int gw = 0, gh = 0;
        rcCalcGridSize(bmin, bmax, m_cellSize, &gw, &gh);
        const int ts = (int)m_tileSize;
        const int tw = (gw + ts-1) / ts;
        const int th = (gh + ts-1) / ts;
        snprintf(text, 64, "Tiles  %d x %d", tw, th);
        imguiValue(text);

        // Max tiles and max polys affect how the tile IDs are caculated.
        // There are 22 bits available for identifying a tile and a polygon.
        int tileBits = rcMin((int)dtIlog2(dtNextPow2(tw*th*EXPECTED_LAYERS_PER_TILE)), 14);
        if (tileBits > 14) tileBits = 14;
        int polyBits = 22 - tileBits;
        m_maxTiles = 1 << tileBits;
        m_maxPolysPerTile = 1 << polyBits;
        snprintf(text, 64, "Max Tiles  %d", m_maxTiles);
        imguiValue(text);
        snprintf(text, 64, "Max Polys  %d", m_maxPolysPerTile);
        imguiValue(text);
        gridSize = tw*th;
    }
    else
    {
        m_maxTiles = 0;
        m_maxPolysPerTile = 0;
    }

    imguiSeparator();

    imguiLabel("Tile Cache");
    char msg[64];

    const float compressionRatio = (float)m_cacheCompressedSize / (float)(m_cacheRawSize+1);

    snprintf(msg, 64, "Layers  %d", m_cacheLayerCount);
    imguiValue(msg);
    snprintf(msg, 64, "Layers (per tile)  %.1f", (float)m_cacheLayerCount/(float)gridSize);
    imguiValue(msg);

    snprintf(msg, 64, "Memory  %.1f kB / %.1f kB (%.1f%%)", m_cacheCompressedSize/1024.0f, m_cacheRawSize/1024.0f, compressionRatio*100.0f);
    imguiValue(msg);
    snprintf(msg, 64, "Navmesh Build Time  %.1f ms", m_cacheBuildTimeMs);
    imguiValue(msg);
    snprintf(msg, 64, "Build Peak Mem Usage  %.1f kB", m_cacheBuildMemUsage/1024.0f);
    imguiValue(msg);

    imguiSeparator();

    imguiIndent();
    imguiIndent();

    if (imguiButton("Save"))
    {
        saveAll("all_tiles_tilecache.bin");
    }

    if (imguiButton("Load"))
    {
        dtFreeNavMesh(m_navMesh);
        dtFreeTileCache(m_tileCache);
        loadAll("all_tiles_tilecache.bin");
        m_navQuery->init(m_navMesh, 2048);
    }

    imguiUnindent();
    imguiUnindent();

    imguiSeparator();
}
Пример #29
0
void Sample_TileMesh::handleSettings()
{
	Sample::handleCommonSettings();

	if (imguiCheck("Keep Itermediate Results", m_keepInterResults))
		m_keepInterResults = !m_keepInterResults;

	if (imguiCheck("Build All Tiles", m_buildAll))
		m_buildAll = !m_buildAll;
	
	imguiLabel("Tiling");
	imguiSlider("TileSize", &m_tileSize, 16.0f, 1024.0f, 16.0f);
	
	if (m_geom)
	{
		const float* bmin = m_geom->getMeshBoundsMin();
		const float* bmax = m_geom->getMeshBoundsMax();
		char text[64];
		int gw = 0, gh = 0;
		rcCalcGridSize(bmin, bmax, m_cellSize, &gw, &gh);
		const int ts = (int)m_tileSize;
		const int tw = (gw + ts-1) / ts;
		const int th = (gh + ts-1) / ts;
		snprintf(text, 64, "Tiles  %d x %d", tw, th);
		imguiValue(text);

		// Max tiles and max polys affect how the tile IDs are caculated.
		// There are 22 bits available for identifying a tile and a polygon.
		int tileBits = rcMin((int)ilog2(nextPow2(tw*th)), 14);
		if (tileBits > 14) tileBits = 14;
		int polyBits = 22 - tileBits;
		m_maxTiles = 1 << tileBits;
		m_maxPolysPerTile = 1 << polyBits;
		snprintf(text, 64, "Max Tiles  %d", m_maxTiles);
		imguiValue(text);
		snprintf(text, 64, "Max Polys  %d", m_maxPolysPerTile);
		imguiValue(text);
	}
	else
	{
		m_maxTiles = 0;
		m_maxPolysPerTile = 0;
	}
	
	imguiSeparator();
	
	imguiIndent();
	imguiIndent();
	
	if (imguiButton("Save"))
	{
		saveAll("all_tiles_navmesh.bin", m_navMesh);
	}

	if (imguiButton("Load"))
	{
		dtFreeNavMesh(m_navMesh);
		m_navMesh = loadAll("all_tiles_navmesh.bin");
		m_navQuery->init(m_navMesh, 2048);
	}

	imguiUnindent();
	imguiUnindent();
	
	char msg[64];
	snprintf(msg, 64, "Build Time: %.1fms", m_totalBuildTimeMs);
	imguiLabel(msg);
	
	imguiSeparator();
	
	imguiSeparator();
	
}
Пример #30
0
void MainWindow::createMenus()
{
   QAction* action;
   QString  name;
   QMenu*   menu;
   QMenu*   subMenu;

   // ----- File Menu -----
   menu = menuBar()->addMenu("File");

      name = "About";
      action = menu->addAction(name);
      connect(action, SIGNAL(triggered()), this, SLOT(showAbout()));

      name = "New Molecule";
      action = menu->addAction(name);
      connect(action, SIGNAL(triggered()), &m_viewerModel, SLOT(newMoleculeMenu()));
      action->setShortcut(QKeySequence::New);

      name = "New Viewer";
      action = menu->addAction(name);
      connect(action, SIGNAL(triggered()), this, SLOT(newViewer()));

      name = "Open";
      action = menu->addAction(name);
      connect(action, SIGNAL(triggered()), this, SLOT(openFile()));
      action->setShortcut(QKeySequence::Open);

      name = "Open Recent";
      m_recentFilesMenu = menu->addMenu(name);
      updateRecentFilesMenu();

      menu->addSeparator();

/*
      name = "Parse Test File";
      action = menu->addAction(name);
      connect(action, SIGNAL(triggered()), this, SLOT(parseFile()));

      menu->addSeparator();
*/

      name = "Close Viewer";
      action = menu->addAction(name);
      connect(action, SIGNAL(triggered()), this, SLOT(close()));
      action->setShortcut(QKeySequence::Close);

      name = "Save";
      action = menu->addAction(name);
      connect(action, SIGNAL(triggered()), &m_viewerModel, SLOT(saveAll()));
      action->setShortcut(QKeySequence::Save);

      name = "Save As";
      action = menu->addAction(name);
      connect(action, SIGNAL(triggered()), &m_viewerModel, SLOT(saveAs()));
      action->setShortcut(Qt::SHIFT + Qt::CTRL + Qt::Key_S);

      menu->addSeparator();

      name = "Save Picture";
      action = menu->addAction(name);
      connect(action, SIGNAL(triggered()), &m_viewer, SLOT(saveSnapshot()));
      action->setShortcut(Qt::CTRL + Qt::Key_P);

      name = "Record Animation";
      action = menu->addAction(name);
      action->setCheckable(true);
      action->setChecked(false);
      connect(action, SIGNAL(triggered()), this, SLOT(toggleRecordingActive()));
      action->setShortcut(Qt::SHIFT + Qt::CTRL + Qt::Key_P);
      m_recordAnimationAction = action;

      name = "Show Message Log";
      action = menu->addAction(name);
      connect(action, SIGNAL(triggered()), this, SLOT(showLogMessages()));
      action->setShortcut(Qt::CTRL + Qt::Key_L);

      name = "Quit";
      action = menu->addAction(name);
      connect(action, SIGNAL(triggered()), this, SLOT(quit()));
      action->setShortcut(Qt::CTRL + Qt::Key_Q);


   // ----- Edit Menu -----
   menu = menuBar()->addMenu("Edit");
  
      name = "Undo";
      action = menu->addAction(name);
      connect(action, SIGNAL(triggered()), &m_undoStack, SLOT(undo()));
      action->setShortcut(QKeySequence::Undo);
      connect(&m_undoStack, SIGNAL(canUndoChanged(bool)), action, SLOT(setEnabled(bool)));

      name = "Redo";
      action = menu->addAction(name);
      connect(action, SIGNAL(triggered()), &m_undoStack, SLOT(redo()));
      action->setShortcut(QKeySequence::Redo);
      connect(&m_undoStack, SIGNAL(canRedoChanged(bool)), action, SLOT(setEnabled(bool)));

      menu->addSeparator();

      name = "Cut";
      action = menu->addAction(name);
      connect(action, SIGNAL(triggered()), &m_viewerModel, SLOT(cutSelection()));
      action->setShortcut(Qt::CTRL + Qt::Key_X);

      name = "Copy";
      action = menu->addAction(name);
      connect(action, SIGNAL(triggered()), &m_viewerModel, SLOT(copySelectionToClipboard()));
      action->setShortcut(Qt::CTRL + Qt::Key_C);

      name = "Paste";
      action = menu->addAction(name);
      connect(action, SIGNAL(triggered()), &m_viewerModel, SLOT(pasteSelectionFromClipboard()));
      action->setShortcut(Qt::CTRL + Qt::Key_V);

      menu->addSeparator();

      name = "Select All";
      action = menu->addAction(name);
      connect(action, SIGNAL(triggered()), &m_viewerModel, SLOT(selectAll()));
      action->setShortcut(Qt::CTRL + Qt::Key_A);

      name = "Select None";
      action = menu->addAction(name);
      connect(action, SIGNAL(triggered()), &m_viewerModel, SIGNAL(clearSelection()));
      action->setShortcut(Qt::SHIFT + Qt::CTRL + Qt::Key_A);

      name = "Invert Selection";
      action = menu->addAction(name);
      connect(action, SIGNAL(triggered()), &m_viewerModel, SLOT(invertSelection()));
      action->setShortcut(Qt::CTRL + Qt::Key_I);

      menu->addSeparator();

      name = "Reindex Atoms";
      action = menu->addAction(name);
      connect(action, SIGNAL(triggered()), this, SLOT(reindexAtoms()));


      menu->addSeparator();

      name = "Preferences";
      action = menu->addAction(name);
      connect(action, SIGNAL(triggered()), this, SLOT(showPreferences()));


   // ----- Display Menu -----
   menu = menuBar()->addMenu("Display");

      name = "Full Screen";
      action = menu->addAction(name);
      action->setCheckable(true);
      action->setChecked(false);
      connect(action, SIGNAL(triggered()), this, SLOT(fullScreen()));
      action->setShortcut(Qt::CTRL + Qt::Key_0);
      m_fullScreenAction = action;

      name = "Reset View";
      action = menu->addAction(name);
      connect(action, SIGNAL(triggered()), &m_viewer, SLOT(resetView()));
      action->setShortcut(Qt::CTRL + Qt::Key_R);

      name = "Show Axes";
      action = menu->addAction(name);
      action->setCheckable(true);
      action->setChecked(false);
      connect(action, SIGNAL(triggered()), &m_viewerModel, SLOT(toggleAxes()));
      connect(&m_viewerModel, SIGNAL(axesOn(bool)), action, SLOT(setChecked(bool)));
      action->setShortcut(Qt::Key_A);


      menu->addSeparator();

      name = "Atom Labels";
      subMenu = menu->addMenu(name);

         name = "Element";
         action = subMenu->addAction(name);
         connect(action, SIGNAL(triggered()), this, SLOT(setLabel()));
         action->setData(Layer::Atom::Element);
         action->setShortcut(Qt::Key_E);
         action->setCheckable(true);
         m_labelActions << action;

         name = "Index";
         action = subMenu->addAction(name);
         connect(action, SIGNAL(triggered()), this, SLOT(setLabel()));
         action->setData(Layer::Atom::Index);
         action->setShortcut(Qt::Key_I);
         action->setCheckable(true);
         m_labelActions << action;
   
         name = "Mass";
         action = subMenu->addAction(name);
         connect(action, SIGNAL(triggered()), this, SLOT(setLabel()));
         action->setData(Layer::Atom::Mass);
         action->setShortcut(Qt::Key_M);
         action->setCheckable(true);
         m_labelActions << action;

/*
         name = "NMR Shifts";
         action = subMenu->addAction(name);
         connect(action, SIGNAL(triggered()), this, SLOT(setLabel()));
         action->setData(Layer::Atom::NmrShifts);
         action->setShortcut(Qt::Key_N);
         action->setCheckable(true);
         m_labelActions << action;
*/

         name = "Partial Charge";
         action = subMenu->addAction(name);
         connect(action, SIGNAL(triggered()), this, SLOT(setLabel()));
         action->setData(Layer::Atom::Charge);
         action->setShortcut(Qt::Key_Q);
         action->setCheckable(true);
         m_labelActions << action;

         name = "Spin Densities";
         action = subMenu->addAction(name);
         connect(action, SIGNAL(triggered()), this, SLOT(setLabel()));
         action->setData(Layer::Atom::Spin);
         action->setShortcut(Qt::Key_S);
         action->setCheckable(true);
         m_labelActions << action;

   menu->addSeparator();

   name = "Configure Appearance";
      action = menu->addAction(name);
      connect(action, SIGNAL(triggered()), this, SLOT(configureAppearance()));


      // These are not working correctly at the moment.
/*
      name = "Partial Charge Type";
      QActionGroup* partialChargeGroup = new QActionGroup(this);
      subMenu = menu->addMenu(name);

         QString pc("Gasteiger");
         action = subMenu->addAction(pc);
         action->setCheckable(true);
         action->setChecked(true);
         action->setData(pc);
         partialChargeGroup->addAction(action);
         connect(action, SIGNAL(triggered()), this, SLOT(setPartialChargeType()));

         pc = "Sanderson";
         action = subMenu->addAction(pc);
         action->setCheckable(true);
         action->setData(pc);
         partialChargeGroup->addAction(action);
         connect(action, SIGNAL(triggered()), this, SLOT(setPartialChargeType()));

         pc = "Mulliken";
         action = subMenu->addAction(pc);
         action->setCheckable(true);
         action->setData(pc);
         partialChargeGroup->addAction(action);
         connect(action, SIGNAL(triggered()), this, SLOT(setPartialChargeType()));
*/



   // ----- Build Menu -----
   menu = menuBar()->addMenu("Build");

      name = "Fill Valencies With Hydrogens";
      action = menu->addAction(name);
      connect(action, SIGNAL(triggered()), &m_viewerModel, SLOT(addHydrogens()));
      action->setShortcut(Qt::CTRL + Qt::Key_F);

      name = "Reperceive Bonds";
      action = menu->addAction(name);
      connect(action, SIGNAL(triggered()), &m_viewerModel, SLOT(reperceiveBonds()));

      menu->addSeparator();

      name = "Set Constraint";
      action = menu->addAction(name);
      connect(action, SIGNAL(triggered()), &m_viewerModel, SLOT(setConstraint()));
      action->setShortcut(Qt::CTRL + Qt::Key_K);

      name = "Minimize Structure";
      action = menu->addAction(name);
      connect(action, SIGNAL(triggered()), &m_viewerModel, SLOT(minimizeEnergy()));
      action->setShortcut(Qt::CTRL + Qt::Key_M);

      name = "Select Force Field";

      QActionGroup* forceFieldGroup = new QActionGroup(this);
      subMenu = menu->addMenu(name);

         QString ff("MMFF94");
         action = subMenu->addAction(ff);
         action->setCheckable(true);
         action->setData(ff);
         forceFieldGroup->addAction(action);
         connect(action, SIGNAL(triggered()), this, SLOT(setForceField()));
         if (Preferences::DefaultForceField() == ff) action->setChecked(true);

         ff = "MMFF94s";
         action = subMenu->addAction(ff);
         action->setCheckable(true);
         action->setData(ff);
         forceFieldGroup->addAction(action);
         connect(action, SIGNAL(triggered()), this, SLOT(setForceField()));
         if (Preferences::DefaultForceField() == ff) action->setChecked(true);

         ff = "UFF";
         action = subMenu->addAction(ff);
         action->setCheckable(true);
         action->setData(ff);
         forceFieldGroup->addAction(action);
         connect(action, SIGNAL(triggered()), this, SLOT(setForceField()));
         if (Preferences::DefaultForceField() == ff) action->setChecked(true);

         ff = "Ghemical";
         action = subMenu->addAction(ff);
         action->setCheckable(true);
         action->setData(ff);
         forceFieldGroup->addAction(action);
         connect(action, SIGNAL(triggered()), this, SLOT(setForceField()));
         if (Preferences::DefaultForceField() == ff) action->setChecked(true);

         ff = "Gaff";
         action = subMenu->addAction(ff);
         action->setCheckable(true);
         action->setData(ff);
         forceFieldGroup->addAction(action);
         connect(action, SIGNAL(triggered()), this, SLOT(setForceField()));
         if (Preferences::DefaultForceField() == ff) action->setChecked(true);

      menu->addSeparator();

      name = "Translate To Center";
      action = menu->addAction(name);
      connect(action, SIGNAL(triggered()), &m_viewerModel, SLOT(translateToCenter()));
      action->setShortcut(Qt::CTRL + Qt::Key_T );

      name = "Symmetrize Molecule";
      action = menu->addAction(name);
      connect(action, SIGNAL(triggered()), &m_viewerModel, SLOT(symmetrize()));
      action->setShortcut(Qt::CTRL + Qt::Key_Y );

      name = "Set Symmetry Tolerance";
      action = menu->addAction(name);
      connect(action, SIGNAL(triggered()), &m_viewerModel, SLOT(adjustSymmetryTolerance()));

      name = "Auto-detect Symmetry";
      action = menu->addAction(name);
      action->setCheckable(true);
      action->setChecked(false);
      connect(action, SIGNAL(triggered()), &m_viewerModel, SLOT(toggleAutoDetectSymmetry()));



   // ----- Calculation Menu -----
   menu = menuBar()->addMenu("Calculation");

      name = "Q-Chem Setup";
      action = menu->addAction(name);
      connect(action, SIGNAL(triggered()), this, SLOT(openQChemUI()));
      action->setShortcut(Qt::CTRL + Qt::Key_U );
      m_qchemSetupAction = action;

      name = "Job Monitor";
      action = menu->addAction(name);
      connect(action, SIGNAL(triggered()), this, SLOT(showProcessMonitor()));
      action->setShortcut(Qt::CTRL + Qt::Key_J );

      menu->addSeparator();

      name = "Edit Servers";
      action = menu->addAction(name);
      connect(action, SIGNAL(triggered()), this, SLOT(editServers()));

      name = "Remove All Processes";
      action = menu->addAction(name);
      connect(action, SIGNAL(triggered()), 
         &(ProcessMonitor::instance()), SLOT(clearProcessList()));

      name = "Reset Password Vault Key";
      action = menu->addAction(name);
      connect(action, SIGNAL(triggered()), this, SLOT(setVaultPassword()));



   // ----- Help Menu -----
   menu = menuBar()->addMenu("Help");

      name = "Show Help";
      action = menu->addAction(name);
      connect(action, SIGNAL(triggered()), this, SLOT(showHelp()));
}