54 m_remoteListAdded(false) {
55 setWindowTitle(tr(
"New Installation Source"));
57 QVBoxLayout* mainLayout =
new QVBoxLayout(
this );
58 mainLayout->setContentsMargins(10, 10, 10, 10);
59 mainLayout->setSpacing( 5 );
61 QHBoxLayout *captionLayout =
new QHBoxLayout;
62 mainLayout->addLayout(captionLayout);
63 QLabel *label =
new QLabel( tr(
"Caption"),
this );
64 captionLayout->addWidget( label );
67 m_captionEdit->setText(QStringLiteral(
"CrossWire Bible Society"));
70 mainLayout->addSpacing( 10 );
72 QGridLayout* layout =
new QGridLayout;
73 layout->setSpacing(3);
74 layout->setContentsMargins(3, 3, 3, 3);
75 mainLayout->addLayout(layout);
76 layout->setSpacing( 5 );
78 label =
new QLabel(tr(
"Type"),
this);
79 layout->addWidget( label, 0, 0);
84 label =
new QLabel(tr(
"Path"),
this);
85 layout->addWidget( label, 0, 2 );
97 m_serverEdit->setText(QStringLiteral(
"ftp.crosswire.org"));
101 m_pathEdit->setText(QStringLiteral(
"/pub/sword/raw"));
103 mainLayout->addSpacing( 10 );
105 QDialogButtonBox* buttonBox =
new QDialogButtonBox(QDialogButtonBox::Cancel | QDialogButtonBox::Save, Qt::Horizontal,
this);
107 QPushButton* getListButton =
new QPushButton(tr(
"Get list..."),
this);
108 getListButton->setToolTip(tr(
"Download a list of sources from CrossWire server and add sources"));
109 buttonBox->addButton(getListButton, QDialogButtonBox::ActionRole);
110 BT_CONNECT(getListButton, &QPushButton::clicked,
114 tr(
"Get source list from remote server?"),
115 tr(
"List of sources will be downloaded from a "
116 "remote server. Sources will be added to the "
117 "current list. New source will replace an "
118 "old one if it has the same label. You can "
119 "later remove the sources you don't want to "
120 "keep.\n\nDo you want to continue?"),
121 QMessageBox::Yes | QMessageBox::No,
122 QMessageBox::Yes) == QMessageBox::No)
132 progressDialog.setValue(0);
133 progressDialog.setWindowTitle(tr(
"Downloading List"));
134 progressDialog.setMinimumDuration(0);
135 BT_CONNECT(&progressDialog, &QProgressDialog::canceled,
138 qApp->processEvents();
143 [&progressDialog](
const int,
const int current) {
144 progressDialog.setLabelText(
145 tr(
"Refreshing..."));
146 progressDialog.setValue(current);
147 qApp->processEvents();
150 progressDialog.show();
151 qApp->processEvents();
153 if (!iMgr.refreshRemoteSourceConfiguration()) {
155 progressDialog.setValue(100);
159 qWarning(
"InstallMgr: getting remote list returned an "
163 mainLayout->addWidget(buttonBox);
164 BT_CONNECT(buttonBox, &QDialogButtonBox::accepted,
166 struct Error { QString msg; };
169 throw Error{tr(
"Please provide a caption.")};
173 throw Error{tr(
"A source with this caption already "
174 "exists. Please provide a different "
180 throw Error{tr(
"Please provide a server name.")};
186 throw Error{tr(
"Please provide a path.")};
189 if (!fi.exists() || !fi.isReadable())
190 throw Error{tr(
"Please provide a valid, "
193 }
catch (Error
const & e) {
199 BT_CONNECT(buttonBox, &QDialogButtonBox::rejected,
200 this, &CSwordSetupInstallSourcesDialog::reject);
206 m_serverLabel->setEnabled(true);
207 m_serverEdit->setEnabled(true);
209 m_serverLabel->setEnabled(false);
210 m_serverEdit->setEnabled(false);
212 QString dirname = QFileDialog::getExistingDirectory(this);
213 if (dirname.isEmpty()) {
218 m_pathEdit->setText( dir.canonicalPath() );