1 /* 2 * Cantata 3 * 4 * Copyright (c) 2011-2020 Craig Drummond <craig.p.drummond@gmail.com> 5 * 6 * ---- 7 * 8 * This program is free software; you can redistribute it and/or modify 9 * it under the terms of the GNU General Public License as published by 10 * the Free Software Foundation; either version 2 of the License, or 11 * (at your option) any later version. 12 * 13 * This program is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 * General Public License for more details. 17 * 18 * You should have received a copy of the GNU General Public License 19 * along with this program; see the file COPYING. If not, write to 20 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 21 * Boston, MA 02110-1301, USA. 22 */ 23 24 #ifndef SERVERSETTINGS_H 25 #define SERVERSETTINGS_H 26 27 #include "ui_serversettings.h" 28 #include "mpd-interface/mpdconnection.h" 29 #include "devices/deviceoptions.h" 30 31 #include <QPushButton> 32 33 class ServerSettings : public QWidget, private Ui::ServerSettings 34 { 35 Q_OBJECT 36 37 struct Collection { 38 Collection(const MPDConnectionDetails &d=MPDConnectionDetails(), const DeviceOptions &n=DeviceOptions()) detailsCollection39 : details(d), namingOpts(n) { } 40 MPDConnectionDetails details; 41 DeviceOptions namingOpts; 42 }; 43 44 public: 45 ServerSettings(QWidget *p); ~ServerSettings()46 ~ServerSettings() override { } 47 48 void load(); 49 void save(); 50 void cancel(); 51 52 private Q_SLOTS: 53 void showDetails(int index); 54 void add(); 55 void remove(); 56 void nameChanged(); 57 void basicDirChanged(); 58 #ifdef AVAHI_FOUND 59 void detectMPDs(); 60 void adoptServerSettings(QString ip, QString port); 61 #endif 62 63 private: 64 void setDetails(const MPDConnectionDetails &details); 65 MPDConnectionDetails getDetails() const; 66 QString generateName(int ignore=-1) const; 67 68 private: 69 QList<Collection> collections; 70 Collection prevBasic; 71 bool haveBasicCollection; 72 bool isCurrentConnection; 73 bool allOptions; 74 int prevIndex; 75 #ifdef AVAHI_FOUND 76 QPushButton *discoveryButton; 77 #endif 78 }; 79 80 #endif 81