File indexing completed on 2023-09-24 05:01:38
0001 /* 0002 * kmixctrl - kmix volume save/restore utility 0003 * 0004 * Copyright (C) 2000 Stefan Schimanski <1Stein@gmx.de> 0005 * 0006 * This program is free software; you can redistribute it and/or 0007 * modify it under the terms of the GNU Library General Public 0008 * License as published by the Free Software Foundation; either 0009 * version 2 of the License, or (at your option) any later version. 0010 * 0011 * This program is distributed in the hope that it will be useful, 0012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0014 * Library General Public License for more details. 0015 * 0016 * You should have received a copy of the GNU Library General Public 0017 * License along with this program; if not, write to the Free 0018 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 0019 */ 0020 0021 #include <qcoreapplication.h> 0022 #include <qcommandlineparser.h> 0023 0024 #include <kaboutdata.h> 0025 #include <klocalizedstring.h> 0026 #include <kconfig.h> 0027 0028 #include "gui/kmixtoolbox.h" 0029 #include "core/mixer.h" 0030 #include "core/mixertoolbox.h" 0031 #include "settings.h" 0032 0033 0034 int main(int argc, char *argv[]) 0035 { 0036 QCoreApplication app(argc, argv); 0037 0038 KLocalizedString::setApplicationDomain("kmix"); 0039 0040 KAboutData aboutData("kmixctrl", i18n("KMixCtrl"), 0041 KMIX_VERSION, i18n("kmixctrl - kmix volume save/restore utility"), 0042 KAboutLicense::GPL, 0043 i18n("(c) 2000 by Stefan Schimanski")); 0044 0045 aboutData.addAuthor(i18n("Stefan Schimanski"), QString(), "1Stein@gmx.de"); 0046 KAboutData::setApplicationData(aboutData); 0047 0048 QCommandLineParser parser; 0049 aboutData.setupCommandLine(&parser); 0050 parser.addOption(QCommandLineOption((QStringList() << "s" << "save"), 0051 i18n("Save current volumes as default"))); 0052 parser.addOption(QCommandLineOption((QStringList() << "r" << "restore"), 0053 i18n("Restore default volumes"))); 0054 parser.process(app); 0055 0056 // create mixers 0057 MixerToolBox::initMixer(false); 0058 0059 // load volumes 0060 if ( parser.isSet("restore") ) 0061 { 0062 for (Mixer *mixer : qAsConst(MixerToolBox::mixers())) 0063 { 0064 mixer->volumeLoad(Settings::self()->config()); 0065 } 0066 } 0067 0068 // save volumes 0069 if (parser.isSet("save")) 0070 { 0071 for (const Mixer *mixer : qAsConst(MixerToolBox::mixers())) 0072 { 0073 mixer->volumeSave(Settings::self()->config()); 0074 } 0075 } 0076 0077 MixerToolBox::deinitMixer(); 0078 0079 return 0; 0080 }