1 /* 2 For general Scribus (>=1.3.2) copyright and licensing information please refer 3 to the COPYING file provided with the program. Following this notice may exist 4 a copyright and/or license notice that predates the release of Scribus 1.3.2 5 for which a new license (GPL+exception) is in place. 6 */ 7 /*************************************************************************** 8 scribuswin.cpp - description 9 ------------------- 10 begin : Mit Nov 6 2002 11 copyright : (C) 2002 by Franz Schmid 12 email : Franz.Schmid@altmuehlnet.de 13 ***************************************************************************/ 14 15 /*************************************************************************** 16 * * 17 * This program is free software; you can redistribute it and/or modify * 18 * it under the terms of the GNU General Public License as published by * 19 * the Free Software Foundation; either version 2 of the License, or * 20 * (at your option) any later version. * 21 * * 22 ***************************************************************************/ 23 24 #include "scribuswin.h" 25 26 #include <QApplication> 27 #include <QDir> 28 #include <QMessageBox> 29 30 #include "commonstrings.h" 31 #include "iconmanager.h" 32 #include "scribus.h" 33 #include "scribusdoc.h" 34 #include "scribusview.h" 35 36 ScribusWin(QWidget * parent,ScribusDoc * doc)37ScribusWin::ScribusWin(QWidget* parent, ScribusDoc* doc) : 38 QMainWindow(parent) 39 { 40 setWindowIcon(IconManager::instance().loadIcon("AppIcon2.png")); 41 setAttribute(Qt::WA_DeleteOnClose); 42 m_Doc = doc; 43 } 44 setMainWindow(ScribusMainWindow * mw)45void ScribusWin::setMainWindow(ScribusMainWindow *mw) 46 { 47 m_ScMW = mw; 48 } 49 setView(ScribusView * newView)50void ScribusWin::setView(ScribusView* newView) 51 { 52 m_View = newView; 53 ++m_Doc->viewCount; 54 m_winIndex = ++m_Doc->viewID; 55 setCentralWidget(newView); 56 setStatusBar(nullptr); 57 } 58 closeEvent(QCloseEvent * ce)59void ScribusWin::closeEvent(QCloseEvent *ce) 60 { 61 activateWindow(); 62 m_ScMW->newActWin(getSubWin()); 63 if (m_Doc->isModified() && (m_Doc->viewCount == 1)) 64 { 65 int i = ScMessageBox::information(m_ScMW, CommonStrings::trWarning, tr("Document:")+" "+ 66 QDir::toNativeSeparators(m_Doc->documentFileName())+"\n"+ 67 tr("has been changed since the last save."), 68 QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, 69 QMessageBox::Cancel, // GUI default 70 QMessageBox::Discard); // batch default 71 if (i == QMessageBox::Cancel) 72 { 73 ce->ignore(); 74 return; 75 } 76 if (i == QMessageBox::Save) 77 { 78 if (!m_ScMW->slotFileSave()) 79 { 80 ce->ignore(); 81 return; 82 } 83 } 84 } 85 m_ScMW->DoFileClose(); 86 ce->accept(); 87 } 88