Changeset 22d01e for src/UIElements


Ignore:
Timestamp:
Aug 9, 2012, 12:51:34 PM (12 years ago)
Author:
Michael Ankele <ankele@…>
Branches:
Action_Thermostats, Add_AtomRandomPerturbation, Add_FitFragmentPartialChargesAction, Add_RotateAroundBondAction, Add_SelectAtomByNameAction, Added_ParseSaveFragmentResults, AddingActions_SaveParseParticleParameters, Adding_Graph_to_ChangeBondActions, Adding_MD_integration_tests, Adding_ParticleName_to_Atom, Adding_StructOpt_integration_tests, AtomFragments, Automaking_mpqc_open, AutomationFragmentation_failures, Candidate_v1.5.4, Candidate_v1.6.0, Candidate_v1.6.1, ChangeBugEmailaddress, ChangingTestPorts, ChemicalSpaceEvaluator, CombiningParticlePotentialParsing, Combining_Subpackages, Debian_Package_split, Debian_package_split_molecuildergui_only, Disabling_MemDebug, Docu_Python_wait, EmpiricalPotential_contain_HomologyGraph, EmpiricalPotential_contain_HomologyGraph_documentation, Enable_parallel_make_install, Enhance_userguide, Enhanced_StructuralOptimization, Enhanced_StructuralOptimization_continued, Example_ManyWaysToTranslateAtom, Exclude_Hydrogens_annealWithBondGraph, FitPartialCharges_GlobalError, Fix_BoundInBox_CenterInBox_MoleculeActions, Fix_ChargeSampling_PBC, Fix_ChronosMutex, Fix_FitPartialCharges, Fix_FitPotential_needs_atomicnumbers, Fix_ForceAnnealing, Fix_IndependentFragmentGrids, Fix_ParseParticles, Fix_ParseParticles_split_forward_backward_Actions, Fix_PopActions, Fix_QtFragmentList_sorted_selection, Fix_Restrictedkeyset_FragmentMolecule, Fix_StatusMsg, Fix_StepWorldTime_single_argument, Fix_Verbose_Codepatterns, Fix_fitting_potentials, Fixes, ForceAnnealing_goodresults, ForceAnnealing_oldresults, ForceAnnealing_tocheck, ForceAnnealing_with_BondGraph, ForceAnnealing_with_BondGraph_continued, ForceAnnealing_with_BondGraph_continued_betteresults, ForceAnnealing_with_BondGraph_contraction-expansion, FragmentAction_writes_AtomFragments, FragmentMolecule_checks_bonddegrees, GeometryObjects, Gui_Fixes, Gui_displays_atomic_force_velocity, ImplicitCharges, IndependentFragmentGrids, IndependentFragmentGrids_IndividualZeroInstances, IndependentFragmentGrids_IntegrationTest, IndependentFragmentGrids_Sole_NN_Calculation, JobMarket_RobustOnKillsSegFaults, JobMarket_StableWorkerPool, JobMarket_unresolvable_hostname_fix, MoreRobust_FragmentAutomation, ODR_violation_mpqc_open, PartialCharges_OrthogonalSummation, PdbParser_setsAtomName, PythonUI_with_named_parameters, QtGui_reactivate_TimeChanged_changes, Recreated_GuiChecks, Rewrite_FitPartialCharges, RotateToPrincipalAxisSystem_UndoRedo, SaturateAtoms_findBestMatching, SaturateAtoms_singleDegree, StoppableMakroAction, Subpackage_CodePatterns, Subpackage_JobMarket, Subpackage_LinearAlgebra, Subpackage_levmar, Subpackage_mpqc_open, Subpackage_vmg, Switchable_LogView, ThirdParty_MPQC_rebuilt_buildsystem, TrajectoryDependenant_MaxOrder, TremoloParser_IncreasedPrecision, TremoloParser_MultipleTimesteps, TremoloParser_setsAtomName, Ubuntu_1604_changes, stable
Children:
59739e
Parents:
5bcbc7
git-author:
Michael Ankele <ankele@…> (08/08/12 13:14:50)
git-committer:
Michael Ankele <ankele@…> (08/09/12 12:51:34)
Message:

Qt: ask whether to save on quit

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/UIElements/Qt4/QtMainWindow.cpp

    r5bcbc7 r22d01e  
    2727#include<Qt/qtoolbar.h>
    2828#include<Qt/qsettings.h>
     29#include<Qt/qmessagebox.h>
     30#include<Qt/qevent.h>
    2931
    3032#include<iostream>
     
    4951#include "Actions/ActionRegistry.hpp"
    5052#include "Actions/ValueStorage.hpp"
     53#include "Parser/ChangeTracker.hpp"
     54#include "Parser/FormatParserStorage.hpp"
     55#include "Actions/WorldAction/OutputAction.hpp"
     56#include "Actions/WorldAction/OutputAsAction.hpp"
     57
     58using namespace MoleCuilder;
    5159
    5260QtMainWindow::QtMainWindow(QApplication *_theApp) :
     
    119127void QtMainWindow::closeEvent(QCloseEvent *event)
    120128{
     129  if (ChangeTracker::getInstance().hasChanged()){
     130    int ret = QMessageBox::question(this, tr("MoleCuilder"),
     131                                    tr("The world has been modified.\n"
     132                                       "Do you want to save your changes?"),
     133                                    QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel,
     134                                    QMessageBox::Save);
     135    switch(ret){
     136      case QMessageBox::Cancel:
     137        event->ignore();
     138        return;
     139      case QMessageBox::Save:
     140        if (FormatParserStorage::getInstance().isAbleToSave())
     141          MoleCuilder::WorldOutput();
     142        else{
     143          Action* action = ActionRegistry::getInstance().getActionByName("output-as");
     144          try{
     145            action->call();
     146          }catch(...){
     147            ELOG(1, "Action failed or cancelled");
     148          }
     149        }
     150        break;
     151    }
     152  }
    121153  QMainWindow::closeEvent(event);
    122154}
Note: See TracChangeset for help on using the changeset viewer.