1 /*
2    Drawpile - a collaborative drawing program.
3 
4    Copyright (C) 2006-2019 Calle Laakkonen
5 
6    Drawpile is free software: you can redistribute it and/or modify
7    it under the terms of the GNU General Public License as published by
8    the Free Software Foundation, either version 3 of the License, or
9    (at your option) any later version.
10 
11    Drawpile is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14    GNU General Public License for more details.
15 
16    You should have received a copy of the GNU General Public License
17    along with Drawpile.  If not, see <http://www.gnu.org/licenses/>.
18 */
19 #ifndef JOINDIALOG_H
20 #define JOINDIALOG_H
21 
22 #include <QDialog>
23 
24 class Ui_JoinDialog;
25 
26 class SessionListingModel;
27 class SessionFilterProxyModel;
28 
29 namespace dialogs {
30 
31 class JoinDialog : public QDialog
32 {
33 	Q_OBJECT
34 public:
35 	explicit JoinDialog(const QUrl &defaultUrl, QWidget *parent=nullptr);
36 	~JoinDialog();
37 
38 	//! Get the host address
39 	QString getAddress() const;
40 
41 	//! Get the join parameters encoded as an URL
42 	QUrl getUrl() const;
43 
44 	//! Get the selected recording filename (empty if not selected)
45 	QString autoRecordFilename() const;
46 
47 	//! Restore settings from configuration file
48 	void restoreSettings();
49 
50 	//! Store settings in configuration file
51 	void rememberSettings() const;
52 
53 protected:
54 	void resizeEvent(QResizeEvent *event) override;
55 
56 private slots:
57 	void addressChanged(const QString &addr);
58 	void refreshListing();
59 	void recordingToggled(bool checked);
60 
61 	void addListServer();
62 
63 private:
64 	void resolveRoomcode(const QString &roomcode, const QStringList &servers);
65 	void setListingVisible(bool show);
66 
67 	void addListServerUrl(const QUrl &url);
68 
69 	Ui_JoinDialog *m_ui;
70 	QPushButton *m_addServerButton;
71 	SessionFilterProxyModel *m_filteredSessions;
72 	SessionListingModel *m_sessions;
73 
74 	qint64 m_lastRefresh;
75 
76 	QString m_recordingFilename;
77 };
78 
79 }
80 
81 #endif
82 
83