File indexing completed on 2024-05-12 16:23:34
0001 /*************************************************************************** 0002 * Copyright (C) 2005-2017 by Linuxstopmotion contributors; * 0003 * see the AUTHORS file for details. * 0004 * * 0005 * This program is free software; you can redistribute it and/or modify * 0006 * it under the terms of the GNU General Public License as published by * 0007 * the Free Software Foundation; either version 2 of the License, or * 0008 * (at your option) any later version. * 0009 * * 0010 * This program is distributed in the hope that it will be useful, * 0011 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 0012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 0013 * GNU General Public License for more details. * 0014 * * 0015 * You should have received a copy of the GNU General Public License * 0016 * along with this program; if not, write to the * 0017 * Free Software Foundation, Inc., * 0018 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 0019 ***************************************************************************/ 0020 #include "preferencesmenu.h" 0021 0022 #include <QPushButton> 0023 #include <QTabWidget> 0024 #include <QVBoxLayout> 0025 #include <QWidget> 0026 0027 #include "devicetab.h" 0028 #include "exporttab.h" 0029 #include "importtab.h" 0030 #include "src/domain/domainfacade.h" 0031 #include "src/foundation/preferencestool.h" 0032 #include "src/foundation/uiexception.h" 0033 #include "src/presentation/frontends/frontend.h" 0034 0035 0036 PreferencesMenu::PreferencesMenu(QWidget *parent) 0037 : QDialog(parent, Qt::Dialog) 0038 { 0039 importVideoTab = 0; 0040 exportVideoTab = 0; 0041 videoDeviceTab = 0; 0042 tabWidget = new QTabWidget; 0043 0044 applyButton = new QPushButton(tr("Apply"), this); 0045 applyButton->setDefault(true); 0046 connect(applyButton, SIGNAL(clicked()), this, SLOT(apply())); 0047 0048 closeButton = new QPushButton(tr("Close"), this); 0049 closeButton->setDefault(true); 0050 connect(closeButton, SIGNAL(clicked()), this, SLOT(close())); 0051 0052 QHBoxLayout *buttonLayout = new QHBoxLayout; 0053 buttonLayout->addStretch(1); 0054 buttonLayout->addWidget(applyButton); 0055 buttonLayout->addWidget(closeButton); 0056 0057 QVBoxLayout *mainLayout = new QVBoxLayout; 0058 mainLayout->addWidget(tabWidget); 0059 mainLayout->addLayout(buttonLayout); 0060 0061 setLayout(mainLayout); 0062 setWindowTitle(tr("Preferences Menu")); 0063 setMaximumWidth(800); 0064 setMinimumWidth(620); 0065 setModal(false); 0066 0067 makeVideoDeviceTab(); 0068 makeVideoImportTab(); 0069 makeVideoExportTab(); 0070 } 0071 0072 0073 void PreferencesMenu::makeVideoImportTab() 0074 { 0075 importVideoTab = new ImportTab; 0076 importVideoTab->initializeImportValues(); 0077 importVideoTab->setMinimumHeight(400); 0078 tabWidget->addTab(importVideoTab, tr("Video &Import")); 0079 } 0080 0081 0082 void PreferencesMenu::makeVideoExportTab() 0083 { 0084 exportVideoTab = new ExportTab; 0085 exportVideoTab->initialize(); 0086 exportVideoTab->setMinimumHeight(460); 0087 tabWidget->addTab(exportVideoTab, tr("Video &Export")); 0088 } 0089 0090 0091 void PreferencesMenu::makeVideoDeviceTab() 0092 { 0093 videoDeviceTab = new DeviceTab; 0094 videoDeviceTab->initialize(); 0095 videoDeviceTab->setMinimumHeight(300); 0096 tabWidget->addTab(videoDeviceTab, tr("Video &Device")); 0097 } 0098 0099 0100 void PreferencesMenu::apply() 0101 { 0102 setFocus(); 0103 videoDeviceTab->apply(); 0104 importVideoTab->apply(); 0105 exportVideoTab->apply(); 0106 try { 0107 PreferencesTool::get()->flush(); 0108 } catch (UiException& ex) { 0109 DomainFacade::getFacade()->getFrontend()->handleException(ex); 0110 } 0111 } 0112 0113 0114 void PreferencesMenu::display() 0115 { 0116 videoDeviceTab->initialize(); 0117 this->show(); 0118 } 0119 0120 0121 void PreferencesMenu::retranslateStrings() 0122 { 0123 applyButton->setText(tr("Apply")); 0124 closeButton->setText(tr("Close")); 0125 setWindowTitle(tr("Preferences Menu")); 0126 0127 tabWidget->setTabText(0, tr("Video &Device")); 0128 tabWidget->setTabText(1, tr("Video &Import")); 0129 tabWidget->setTabText(2, tr("Video &Export")); 0130 0131 importVideoTab->retranslateStrings(); 0132 exportVideoTab->retranslateStrings(); 0133 videoDeviceTab->retranslateStrings(); 0134 } 0135