diff --git a/stuff/profiles/layouts/rooms/Default/menubar_template.xml b/stuff/profiles/layouts/rooms/Default/menubar_template.xml index 5df924e..c41c894 100644 --- a/stuff/profiles/layouts/rooms/Default/menubar_template.xml +++ b/stuff/profiles/layouts/rooms/Default/menubar_template.xml @@ -2,9 +2,9 @@ MI_NewScene MI_LoadScene + MI_SaveAll MI_SaveScene MI_SaveSceneAs - MI_SaveAll MI_OpenRecentScene MI_RevertScene @@ -13,6 +13,7 @@ MI_NewLevel MI_LoadLevel + MI_SaveAllLevels MI_SaveLevel MI_SaveLevelAs MI_ExportLevel diff --git a/stuff/profiles/layouts/rooms/StudioGhibli/menubar_template.xml b/stuff/profiles/layouts/rooms/StudioGhibli/menubar_template.xml index eee1faf..b78b58c 100644 --- a/stuff/profiles/layouts/rooms/StudioGhibli/menubar_template.xml +++ b/stuff/profiles/layouts/rooms/StudioGhibli/menubar_template.xml @@ -13,6 +13,7 @@ MI_NewLevel MI_LoadLevel + MI_SaveAllLevels MI_SaveLevel MI_SaveLevelAs MI_ExportLevel diff --git a/toonz/sources/include/toonz/preferences.h b/toonz/sources/include/toonz/preferences.h index 7b8c6e4..a3c5ca4 100644 --- a/toonz/sources/include/toonz/preferences.h +++ b/toonz/sources/include/toonz/preferences.h @@ -99,6 +99,14 @@ public: void setAutosavePeriod(int minutes); int getAutosavePeriod() const { return m_autosavePeriod; } // minutes + void enableAutosaveScene(bool on); + bool isAutosaveSceneEnabled() const { return m_autosaveSceneEnabled; } + + void enableAutosaveOtherFiles(bool on); + bool isAutosaveOtherFilesEnabled() const { + return m_autosaveOtherFilesEnabled; + } + void enableLevelsBackup(bool enabled); bool isLevelsBackupEnabled() const { return m_levelsBackupEnabled; } @@ -457,6 +465,7 @@ private: m_generatedMovieViewEnabled, m_xsheetAutopanEnabled, m_ignoreAlphaonColumn1Enabled, m_previewAlwaysOpenNewFlipEnabled, m_rewindAfterPlaybackEnabled, m_fitToFlipbookEnabled, m_autosaveEnabled, + m_autosaveSceneEnabled, m_autosaveOtherFilesEnabled, m_defaultViewerEnabled, m_pixelsOnly; bool m_rasterOptimizedMemory, m_saveUnpaintedInCleanup, m_askForOverrideRender, m_automaticSVNFolderRefreshEnabled, m_SVNEnabled, diff --git a/toonz/sources/include/toonzqt/dvdialog.h b/toonz/sources/include/toonzqt/dvdialog.h index b61e366..6184bf5 100644 --- a/toonz/sources/include/toonzqt/dvdialog.h +++ b/toonz/sources/include/toonzqt/dvdialog.h @@ -58,10 +58,11 @@ void DVAPI MsgBoxInPopup(MsgType type, const QString &text); // ATTENZIONE: Valore di ritorno // 0 = l'utente ha chiuso la finestra (dovrebbe corrispondere ad un cancel o ad -// un NO) -// 1 = primo bottone da sx premuto -// 2 = secondo bottone da sx premuto -// 3 = terzo bottone da sx premuto +// un NO) - closed window +// 1 = primo bottone da sx premuto - first button selected +// 2 = secondo bottone da sx premuto - second button +// 3 = terzo bottone da sx premuto - third button +// 4 = fourth button int DVAPI MsgBox(MsgType type, const QString &text, const std::vector &buttons, @@ -77,6 +78,12 @@ int DVAPI MsgBox(const QString &text, const QString &button1, const QString &button2, const QString &button3, int defaultButtonIndex = 0, QWidget *parent = 0); +// QUESTION: four botton user defined +int DVAPI MsgBox(const QString &text, const QString &button1, + const QString &button2, const QString &button3, + const QString &button4, int defaultButtonIndex = 0, + QWidget *parent = 0); + Dialog DVAPI *createMsgBox(MsgType type, const QString &text, const QStringList &buttons, int defaultButtonIndex, QWidget *parent = 0); @@ -229,6 +236,8 @@ public: void addButtonBarWidget(QWidget *widget); void addButtonBarWidget(QWidget *first, QWidget *second); void addButtonBarWidget(QWidget *first, QWidget *second, QWidget *third); + void addButtonBarWidget(QWidget *first, QWidget *second, QWidget *third, + QWidget *fourth); void hideEvent(QHideEvent *event) override; diff --git a/toonz/sources/toonz/iocommand.cpp b/toonz/sources/toonz/iocommand.cpp index 00b9df1..2cb728d 100644 --- a/toonz/sources/toonz/iocommand.cpp +++ b/toonz/sources/toonz/iocommand.cpp @@ -1176,17 +1176,21 @@ bool IoCmd::saveSceneIfNeeded(QString msg) { QString question; question = QObject::tr( "%1: the current scene has been modified.\n" - "Do you want to save your changes?") + "What would you like to do?") .arg(msg); - int ret = DVGui::MsgBox(question, QObject::tr("Save"), - QObject::tr("Discard"), QObject::tr("Cancel"), 0); - if (ret == 0 || ret == 3) { + int ret = DVGui::MsgBox( + question, QObject::tr("Save All"), QObject::tr("Save Scene Only"), + QObject::tr("Discard Changes"), QObject::tr("Cancel"), 0); + if (ret == 0 || ret == 4) { // cancel (or closed message box window) return false; } else if (ret == 1) { + // save all + if (!IoCmd::saveAll()) return false; + } else if (ret == 2) { // save if (!IoCmd::saveScene()) return false; - } else if (ret == 2) { + } else if (ret == 3) { } isLevelOrSceneIsDirty = true; @@ -1203,21 +1207,25 @@ bool IoCmd::saveSceneIfNeeded(QString msg) { if (!dirtyResources.empty()) { QString question; - question = - msg + ":" + QObject::tr(" Following file(s) are modified.\n\n"); + question = msg + ":" + + QObject::tr(" The following file(s) have been modified.\n\n"); for (int i = 0; i < dirtyResources.size(); i++) { question += " " + dirtyResources[i] + "\n"; } - question += - QObject::tr("\nAre you sure to ") + msg + QObject::tr(" anyway ?"); + question += QObject::tr("\nWhat would you like to do? "); int ret = - DVGui::MsgBox(question, QObject::tr("OK"), QObject::tr("Cancel"), 0); - if (ret == 0 || ret == 2) { + DVGui::MsgBox(question, QObject::tr("Save Changes"), + msg + QObject::tr(" Anyway"), QObject::tr("Cancel"), 0); + if (ret == 0 || ret == 3) { // cancel (or closed message box window) return false; } else if (ret == 1) { - // ok + // save non scene files + IoCmd::saveNonSceneFiles(); + return false; + } else if (ret == 2) { + // quit } isLevelOrSceneIsDirty = true; @@ -1604,7 +1612,7 @@ bool IoCmd::saveLevel(TXshSimpleLevel *sl) { } //=========================================================================== -// IoCmd::saveSound(soundPath, soundColumn, overwrite) +// IoCmd::saveAll() //--------------------------------------------------------------------------- bool IoCmd::saveAll() { @@ -1627,6 +1635,26 @@ bool IoCmd::saveAll() { } //=========================================================================== +// IoCmd::saveNonSceneFiles() +//--------------------------------------------------------------------------- + +void IoCmd::saveNonSceneFiles() { + // try to save non scene files + + TApp *app = TApp::instance(); + ToonzScene *scene = app->getCurrentScene()->getScene(); + bool untitled = scene->isUntitled(); + SceneResources resources(scene, 0); + resources.save(scene->getScenePath()); + if (untitled) scene->setUntitled(); + resources.updatePaths(); + + // for update title bar + app->getCurrentLevel()->notifyLevelTitleChange(); + app->getCurrentPalette()->notifyPaletteTitleChanged(); +} + +//=========================================================================== // IoCmd::saveSound(soundPath, soundColumn, overwrite) //--------------------------------------------------------------------------- @@ -2738,3 +2766,12 @@ public: SaveAllCommandHandler() : MenuItemHandler(MI_SaveAll) {} void execute() override { IoCmd::saveAll(); } } saveAllCommandHandler; + +//============================================================================= +// Save all levels +//----------------------------------------------------------------------------- +class SaveAllLevelsCommandHandler : public MenuItemHandler { +public: + SaveAllLevelsCommandHandler() : MenuItemHandler(MI_SaveAllLevels) {} + void execute() { IoCmd::saveNonSceneFiles(); } +} saveAllLevelsCommandHandler; diff --git a/toonz/sources/toonz/iocommand.h b/toonz/sources/toonz/iocommand.h index 17f6fdb..2415e85 100644 --- a/toonz/sources/toonz/iocommand.h +++ b/toonz/sources/toonz/iocommand.h @@ -197,6 +197,8 @@ bool saveLevel(TXshSimpleLevel *sl); bool saveAll(); +void saveNonSceneFiles(); + bool saveSound(const TFilePath &fp, TXshSoundLevel *sc, bool overwrite); bool saveSound(TXshSoundLevel *sc); diff --git a/toonz/sources/toonz/mainwindow.cpp b/toonz/sources/toonz/mainwindow.cpp index e0acfec..b2b2e24 100644 --- a/toonz/sources/toonz/mainwindow.cpp +++ b/toonz/sources/toonz/mainwindow.cpp @@ -1558,9 +1558,9 @@ QAction *MainWindow::createToolAction(const char *id, const char *iconName, void MainWindow::defineActions() { createMenuFileAction(MI_NewScene, tr("&New Scene"), "Ctrl+N"); createMenuFileAction(MI_LoadScene, tr("&Load Scene..."), "Ctrl+L"); - createMenuFileAction(MI_SaveScene, tr("&Save Scene"), "Ctrl+S"); + createMenuFileAction(MI_SaveScene, tr("&Save Scene"), ""); createMenuFileAction(MI_SaveSceneAs, tr("&Save Scene As..."), "Ctrl+Shift+S"); - createMenuFileAction(MI_SaveAll, tr("&Save All"), ""); + createMenuFileAction(MI_SaveAll, tr("&Save All"), "Ctrl+S"); createMenuFileAction(MI_RevertScene, tr("&Revert Scene"), ""); QAction *act = CommandManager::instance()->getAction(MI_RevertScene); @@ -1579,6 +1579,7 @@ void MainWindow::defineActions() { createMenuFileAction(MI_NewLevel, tr("&New Level..."), ""); createMenuFileAction(MI_LoadLevel, tr("&Load Level..."), ""); createMenuFileAction(MI_SaveLevel, tr("&Save Level"), ""); + createMenuFileAction(MI_SaveAllLevels, tr("&Save All Levels"), ""); createMenuFileAction(MI_SaveLevelAs, tr("&Save Level As..."), ""); createMenuFileAction(MI_ExportLevel, tr("&Export Level..."), ""); createMenuFileAction(MI_ConvertFileWithInput, tr("&Convert File..."), ""); diff --git a/toonz/sources/toonz/menubar.cpp b/toonz/sources/toonz/menubar.cpp index 512c136..83ecf2c 100644 --- a/toonz/sources/toonz/menubar.cpp +++ b/toonz/sources/toonz/menubar.cpp @@ -1077,6 +1077,7 @@ QMenuBar *StackedMenuBar::createFullMenuBar() { fileMenu->addSeparator(); addMenuItem(fileMenu, MI_NewLevel); addMenuItem(fileMenu, MI_LoadLevel); + addMenuItem(fileMenu, MI_SaveAllLevels); addMenuItem(fileMenu, MI_SaveLevel); addMenuItem(fileMenu, MI_SaveLevelAs); addMenuItem(fileMenu, MI_ExportLevel); diff --git a/toonz/sources/toonz/menubarcommandids.h b/toonz/sources/toonz/menubarcommandids.h index ac9a5bf..d0ec9f1 100644 --- a/toonz/sources/toonz/menubarcommandids.h +++ b/toonz/sources/toonz/menubarcommandids.h @@ -16,6 +16,7 @@ #define MI_SaveScene "MI_SaveScene" #define MI_SaveSceneAs "MI_SaveSceneAs" #define MI_SaveAll "MI_SaveAll" +#define MI_SaveAllLevels "MI_SaveAllLevels" #define MI_RevertScene "MI_RevertScene" #define MI_LoadSubSceneFile "MI_LoadSubSceneFile" diff --git a/toonz/sources/toonz/preferencespopup.cpp b/toonz/sources/toonz/preferencespopup.cpp index 09064aa..e310e51 100644 --- a/toonz/sources/toonz/preferencespopup.cpp +++ b/toonz/sources/toonz/preferencespopup.cpp @@ -554,9 +554,31 @@ void PreferencesPopup::onDefaultViewerChanged(int index) { //----------------------------------------------------------------------------- -void PreferencesPopup::onAutoSaveChanged(int index) { - m_minuteFld->setEnabled(index == Qt::Checked); - m_pref->enableAutosave(index == Qt::Checked); +void PreferencesPopup::onAutoSaveChanged(bool on) { + m_pref->enableAutosave(on); + if (on && !m_autoSaveSceneCB->isChecked() && + !m_autoSaveOtherFilesCB->isChecked()) { + m_autoSaveSceneCB->setChecked(true); + m_autoSaveOtherFilesCB->setChecked(true); + } +} + +//----------------------------------------------------------------------------- + +void PreferencesPopup::onAutoSaveSceneChanged(int index) { + m_pref->enableAutosaveScene(index == Qt::Checked); + if (!m_autoSaveOtherFilesCB->isChecked() && index == Qt::Unchecked) { + m_autoSaveGroup->setChecked(false); + } +} + +//----------------------------------------------------------------------------- + +void PreferencesPopup::onAutoSaveOtherFilesChanged(int index) { + m_pref->enableAutosaveOtherFiles(index == Qt::Checked); + if (!m_autoSaveSceneCB->isChecked() && index == Qt::Unchecked) { + m_autoSaveGroup->setChecked(false); + } } //----------------------------------------------------------------------------- @@ -926,8 +948,12 @@ PreferencesPopup::PreferencesPopup() new CheckBox(tr("Use Default Viewer for Movie Formats"), this); CheckBox *minimizeRasterMemoryCB = new CheckBox(tr("Minimize Raster Memory Fragmentation *"), this); - CheckBox *autoSaveCB = new CheckBox(tr("Save Automatically Every Minutes")); - m_minuteFld = new DVGui::IntLineEdit(this, 15, 1, 60); + m_autoSaveGroup = new QGroupBox(tr("Save Automatically"), this); + m_autoSaveGroup->setCheckable(true); + m_autoSaveSceneCB = new CheckBox(tr("Automatically Save the Scene File")); + m_autoSaveOtherFilesCB = + new CheckBox(tr("Automatically Save Non-Scene Files")); + m_minuteFld = new DVGui::IntLineEdit(this, 15, 1, 60); CheckBox *replaceAfterSaveLevelAsCB = new CheckBox(tr("Replace Toonz Level after SaveLevelAs command"), this); @@ -1137,9 +1163,10 @@ PreferencesPopup::PreferencesPopup() //--- General ------------------------------ useDefaultViewerCB->setChecked(m_pref->isDefaultViewerEnabled()); minimizeRasterMemoryCB->setChecked(m_pref->isRasterOptimizedMemory()); - autoSaveCB->setChecked(m_pref->isAutosaveEnabled()); + m_autoSaveGroup->setChecked(m_pref->isAutosaveEnabled()); + m_autoSaveSceneCB->setChecked(m_pref->isAutosaveSceneEnabled()); + m_autoSaveOtherFilesCB->setChecked(m_pref->isAutosaveOtherFilesEnabled()); m_minuteFld->setValue(m_pref->getAutosavePeriod()); - m_minuteFld->setEnabled(m_pref->isAutosaveEnabled()); replaceAfterSaveLevelAsCB->setChecked( m_pref->isReplaceAfterSaveLevelAsEnabled()); @@ -1384,16 +1411,27 @@ PreferencesPopup::PreferencesPopup() Qt::AlignLeft | Qt::AlignVCenter); generalFrameLay->addWidget(minimizeRasterMemoryCB, 0, Qt::AlignLeft | Qt::AlignVCenter); - QHBoxLayout *saveAutoLay = new QHBoxLayout(); - saveAutoLay->setMargin(0); - saveAutoLay->setSpacing(15); + + QVBoxLayout *autoSaveOptionsLay = new QVBoxLayout(); + autoSaveOptionsLay->setMargin(10); { - saveAutoLay->addWidget(autoSaveCB, 0); - saveAutoLay->addWidget(m_minuteFld, 0); - saveAutoLay->addStretch(1); - } - generalFrameLay->addLayout(saveAutoLay, 0); + QHBoxLayout *saveAutoLay = new QHBoxLayout(); + saveAutoLay->setMargin(0); + saveAutoLay->setSpacing(5); + { + saveAutoLay->addWidget(new QLabel(tr("Interval(Minutes): "), this)); + saveAutoLay->addWidget(m_minuteFld, 0); + saveAutoLay->addStretch(1); + } + autoSaveOptionsLay->addLayout(saveAutoLay, 0); + autoSaveOptionsLay->addWidget(m_autoSaveSceneCB, 0, + Qt::AlignLeft | Qt::AlignVCenter); + autoSaveOptionsLay->addWidget(m_autoSaveOtherFilesCB, 0, + Qt::AlignLeft | Qt::AlignVCenter); + } + m_autoSaveGroup->setLayout(autoSaveOptionsLay); + generalFrameLay->addWidget(m_autoSaveGroup); // Unit, CameraUnit QGridLayout *unitLay = new QGridLayout(); unitLay->setMargin(0); @@ -1903,8 +1941,12 @@ PreferencesPopup::PreferencesPopup() SLOT(onDefaultViewerChanged(int))); ret = ret && connect(minimizeRasterMemoryCB, SIGNAL(stateChanged(int)), this, SLOT(onRasterOptimizedMemoryChanged(int))); - ret = ret && connect(autoSaveCB, SIGNAL(stateChanged(int)), - SLOT(onAutoSaveChanged(int))); + ret = ret && connect(m_autoSaveGroup, SIGNAL(toggled(bool)), + SLOT(onAutoSaveChanged(bool))); + ret = ret && connect(m_autoSaveSceneCB, SIGNAL(stateChanged(int)), + SLOT(onAutoSaveSceneChanged(int))); + ret = ret && connect(m_autoSaveOtherFilesCB, SIGNAL(stateChanged(int)), + SLOT(onAutoSaveOtherFilesChanged(int))); ret = ret && connect(m_minuteFld, SIGNAL(editingFinished()), SLOT(onMinuteChanged())); ret = ret && connect(m_cellsDragBehaviour, SIGNAL(currentIndexChanged(int)), diff --git a/toonz/sources/toonz/preferencespopup.h b/toonz/sources/toonz/preferencespopup.h index 74290c8..134ce6e 100644 --- a/toonz/sources/toonz/preferencespopup.h +++ b/toonz/sources/toonz/preferencespopup.h @@ -24,6 +24,7 @@ class QLineEdit; class QPushButton; class QLabel; +class QGroupBox; //============================================================== @@ -70,12 +71,14 @@ private: DVGui::CheckBox *m_inksOnly, *m_enableVersionControl, *m_levelsBackup, *m_onionSkinVisibility, *m_pixelsOnlyCB, *m_projectRootDocuments, *m_projectRootDesktop, *m_projectRootCustom, *m_projectRootStuff, - *m_onionSkinDuringPlayback; + *m_onionSkinDuringPlayback, *m_autoSaveSceneCB, *m_autoSaveOtherFilesCB; DVGui::FileField *m_customProjectRootFileField; DVGui::FileField *m_ffmpegPathFileFld; + QGroupBox *m_autoSaveGroup; + private: // QWidget* create(const QString& lbl, bool def, const char* slot); void rebuildFormatsList(); @@ -104,7 +107,9 @@ private slots: void onRasterOptimizedMemoryChanged(int index); void onSaveUnpaintedInCleanupChanged(int index); void onMinimizeSaveboxAfterEditing(int index); - void onAutoSaveChanged(int index); + void onAutoSaveChanged(bool on); + void onAutoSaveSceneChanged(int index); + void onAutoSaveOtherFilesChanged(int index); void onDefaultViewerChanged(int index); void onBlankCountChanged(); void onBlankColorChanged(const TPixel32 &, bool isDragging); diff --git a/toonz/sources/toonz/tapp.cpp b/toonz/sources/toonz/tapp.cpp index a6ef8b2..698fe26 100644 --- a/toonz/sources/toonz/tapp.cpp +++ b/toonz/sources/toonz/tapp.cpp @@ -673,16 +673,25 @@ void TApp::autosave() { } else m_autosaveSuspended = false; - if (scene->isUntitled()) { + if (scene->isUntitled() && + Preferences::instance()->isAutosaveSceneEnabled()) { DVGui::warning( - tr("It is not possible to save automatically an untitled scene.")); + tr("It is not possible to automatically save an untitled scene.")); return; } DVGui::ProgressDialog pb( "Autosaving scene..." + toQString(scene->getScenePath()), 0, 0, 1); pb.show(); - IoCmd::saveScene(); + Preferences *pref = Preferences::instance(); + if (pref->isAutosaveSceneEnabled() && pref->isAutosaveOtherFilesEnabled()) { + IoCmd::saveAll(); + } else if (pref->isAutosaveSceneEnabled()) { + IoCmd::saveScene(); + } else if (pref->isAutosaveOtherFilesEnabled()) { + IoCmd::saveNonSceneFiles(); + } + pb.setValue(1); } @@ -705,7 +714,7 @@ void TApp::onStartAutoSave() { //----------------------------------------------------------------------------- void TApp::onStopAutoSave() { - assert(!Preferences::instance()->isAutosaveEnabled()); + // assert(!Preferences::instance()->isAutosaveEnabled()); m_autosaveTimer->stop(); } diff --git a/toonz/sources/toonzlib/preferences.cpp b/toonz/sources/toonzlib/preferences.cpp index e7da85d..6545e51 100644 --- a/toonz/sources/toonzlib/preferences.cpp +++ b/toonz/sources/toonzlib/preferences.cpp @@ -255,6 +255,8 @@ Preferences::Preferences() , m_fitToFlipbookEnabled(false) , m_previewAlwaysOpenNewFlipEnabled(false) , m_autosaveEnabled(false) + , m_autosaveSceneEnabled(true) + , m_autosaveOtherFilesEnabled(true) , m_defaultViewerEnabled(false) , m_saveUnpaintedInCleanup(true) , m_askForOverrideRender(true) @@ -324,6 +326,9 @@ Preferences::Preferences() getValue(*m_settings, "sceneNumberingEnabled", m_sceneNumberingEnabled); getValue(*m_settings, "animationSheetEnabled", m_animationSheetEnabled); getValue(*m_settings, "autosaveEnabled", m_autosaveEnabled); + getValue(*m_settings, "autosaveSceneEnabled", m_autosaveSceneEnabled); + getValue(*m_settings, "autosaveOtherFilesEnabled", + m_autosaveOtherFilesEnabled); getValue(*m_settings, "defaultViewerEnabled", m_defaultViewerEnabled); getValue(*m_settings, "rasterOptimizedMemory", m_rasterOptimizedMemory); getValue(*m_settings, "saveUnpaintedInCleanup", m_saveUnpaintedInCleanup); @@ -644,6 +649,20 @@ void Preferences::enableAutosave(bool on) { //----------------------------------------------------------------- +void Preferences::enableAutosaveScene(bool on) { + m_autosaveSceneEnabled = on; + m_settings->setValue("autosaveSceneEnabled", on ? "1" : "0"); +} + +//----------------------------------------------------------------- + +void Preferences::enableAutosaveOtherFiles(bool on) { + m_autosaveOtherFilesEnabled = on; + m_settings->setValue("autosaveOtherFilesEnabled", on ? "1" : "0"); +} + +//----------------------------------------------------------------- + void Preferences::setAskForOverrideRender(bool on) { m_autosaveEnabled = on; m_settings->setValue("askForOverrideRender", on ? "1" : "0"); diff --git a/toonz/sources/toonzqt/dvdialog.cpp b/toonz/sources/toonzqt/dvdialog.cpp index 281586e..59cfbd8 100644 --- a/toonz/sources/toonzqt/dvdialog.cpp +++ b/toonz/sources/toonzqt/dvdialog.cpp @@ -729,6 +729,23 @@ void Dialog::addButtonBarWidget(QWidget *first, QWidget *second, } } +//----------------------------------------------------------------------------- +/*! Add four widget to the button part of dialog. +*/ +void Dialog::addButtonBarWidget(QWidget *first, QWidget *second, QWidget *third, + QWidget *fourth) { + first->setMinimumSize(65, 25); + second->setMinimumSize(65, 25); + third->setMinimumSize(65, 25); + assert(m_hasButton); + if (m_hasButton) { + m_buttonLayout->addWidget(first); + m_buttonLayout->addWidget(second); + m_buttonLayout->addWidget(third); + m_buttonLayout->addWidget(fourth); + } +} + //============================================================================= RadioButtonDialog::RadioButtonDialog(const QString &labelText, @@ -1060,6 +1077,65 @@ int DVGui::MsgBox(const QString &text, const QString &button1Text, //----------------------------------------------------------------------------- +int DVGui::MsgBox(const QString &text, const QString &button1Text, + const QString &button2Text, const QString &button3Text, + const QString &button4Text, int defaultButtonIndex, + QWidget *parent) { + Dialog dialog(parent, true); + dialog.setWindowFlags(dialog.windowFlags() | Qt::WindowStaysOnTopHint); + dialog.setAlignment(Qt::AlignLeft); + QString msgBoxTitle = getMsgBoxTitle(QUESTION); + dialog.setWindowTitle(msgBoxTitle); + + QLabel *mainTextLabel = new QLabel(text, &dialog); + QPixmap iconPixmap = getMsgBoxPixmap(QUESTION); + if (!iconPixmap.isNull()) { + QLabel *iconLabel = new QLabel(&dialog); + iconLabel->setPixmap(iconPixmap); + + QHBoxLayout *mainLayout = new QHBoxLayout; + mainLayout->addWidget(iconLabel); + mainLayout->addSpacing(16); + mainLayout->addWidget(mainTextLabel); + dialog.addLayout(mainLayout); + } else + dialog.addWidget(mainTextLabel); + + // ButtonGroup: is used only to retrieve the clicked button + QButtonGroup *buttonGroup = new QButtonGroup(&dialog); + + QPushButton *button1 = new QPushButton(button1Text, &dialog); + button1->setDefault(false); + if (defaultButtonIndex == 0) button1->setDefault(true); + dialog.addButtonBarWidget(button1); + buttonGroup->addButton(button1, 1); + + QPushButton *button2 = new QPushButton(button2Text, &dialog); + button2->setDefault(false); + if (defaultButtonIndex == 1) button2->setDefault(true); + dialog.addButtonBarWidget(button2); + buttonGroup->addButton(button2, 2); + + QPushButton *button3 = new QPushButton(button3Text, &dialog); + button3->setDefault(false); + if (defaultButtonIndex == 2) button3->setDefault(true); + dialog.addButtonBarWidget(button3); + buttonGroup->addButton(button3, 3); + + QPushButton *button4 = new QPushButton(button4Text, &dialog); + button4->setDefault(false); + if (defaultButtonIndex == 3) button4->setDefault(true); + dialog.addButtonBarWidget(button4); + buttonGroup->addButton(button4, 4); + + QObject::connect(buttonGroup, SIGNAL(buttonPressed(int)), &dialog, + SLOT(done(int))); + dialog.raise(); + return dialog.exec(); +} + +//----------------------------------------------------------------------------- + int DVGui::MsgBox(const QString &text, const QString &button1, const QString &button2, int defaultButtonIndex, QWidget *parent) {