"Fossies" - the Fresh Open Source Software Archive

Member "cutter-1.10.3/src/common/IOModesController.cpp" (8 May 2020, 1513 Bytes) of package /linux/privat/cutter-1.10.3.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "IOModesController.cpp" see the Fossies "Dox" file reference documentation.

    1 #include "IOModesController.h"
    2 #include "Cutter.h"
    3 
    4 #include <QPushButton>
    5 #include <QObject>
    6 
    7 bool IOModesController::canWrite()
    8 {
    9     return Core()->isIOCacheEnabled() || Core()->isWriteModeEnabled();
   10 }
   11 
   12 bool IOModesController::prepareForWriting()
   13 {
   14     if (canWrite()) {
   15         return true;
   16     }
   17 
   18     QMessageBox msgBox;
   19     msgBox.setIcon(QMessageBox::Icon::Critical);
   20     msgBox.setWindowTitle(QObject::tr("Write error"));
   21     msgBox.setText(
   22         QObject::tr("Your file is opened in read-only mode. "
   23            "Editing is only available when the file is opened in either Write or Cache modes.\n\n"
   24            "WARNING: In Write mode, any changes will be committed to the file on disk. "
   25            "For safety, please consider using Cache mode and then commit the changes manually "
   26            "via File -> Commit modifications to disk."));
   27     msgBox.addButton(QObject::tr("Cancel"), QMessageBox::RejectRole);
   28     QAbstractButton *reopenButton = msgBox.addButton(QObject::tr("Reopen in Write mode"),
   29                                                      QMessageBox::YesRole);
   30     QAbstractButton *iocacheButton = msgBox.addButton(QObject::tr("Enable Cache mode"),
   31                                                      QMessageBox::YesRole);
   32 
   33     msgBox.exec();
   34 
   35     if (msgBox.clickedButton() == reopenButton) {
   36         Core()->setWriteMode(true);
   37     } else if (msgBox.clickedButton() == iocacheButton) {
   38         Core()->setIOCache(true);
   39     } else {
   40         return false;
   41     }
   42     return true;
   43 }