hydrogen
1.2.6
SoundLibraryRepositoryDialog.cpp
Go to the documentation of this file.
1
/*
2
* Hydrogen
3
* Copyright(c) 2002-2008 by Alex >Comix< Cominu [comix@users.sourceforge.net]
4
* Copyright(c) 2008-2025 The hydrogen development team [hydrogen-devel@lists.sourceforge.net]
5
*
6
* http://www.hydrogen-music.org
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
16
* GNU 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. If not, see https://www.gnu.org/licenses
20
*
21
*/
22
23
#include "
SoundLibraryRepositoryDialog.h
"
24
25
#include <
core/Preferences/Preferences.h
>
26
27
#include <QList>
28
#include <QInputDialog>
29
#include <QListWidgetItem>
30
31
SoundLibraryRepositoryDialog::SoundLibraryRepositoryDialog
( QWidget* pParent )
32
: QDialog( pParent )
33
{
34
setupUi(
this
);
35
36
setWindowTitle( tr(
"Edit repository settings"
) );
37
adjustSize();
38
setMinimumSize( width(), height() );
39
40
updateDialog
();
41
42
}
43
44
45
//update all values
46
void
SoundLibraryRepositoryDialog::updateDialog
(){
47
48
H2Core::Preferences
*pPref =
H2Core::Preferences::get_instance
();
49
50
/*
51
Read serverList from config and put servers into the serverList
52
*/
53
54
std::list<QString>::const_iterator cur_Server;
55
56
ServerListWidget->clear();
57
58
for
( cur_Server = pPref->
sServerList
.begin(); cur_Server != pPref->
sServerList
.end(); ++cur_Server )
59
{
60
ServerListWidget->addItem( *cur_Server );
61
}
62
}
63
64
65
68
69
void
SoundLibraryRepositoryDialog::on_AddBtn_clicked
()
70
{
71
H2Core::Preferences
*pPref =
H2Core::Preferences::get_instance
();
72
bool
ok;
73
74
QString text = QInputDialog::getText(
this
, tr(
"Edit server list"
), tr(
"URL"
), QLineEdit::Normal,QString(
""
), &ok);
75
76
if
( ok && !text.isEmpty() ){
77
pPref->
sServerList
.push_back( text );
78
}
79
80
updateDialog
();
81
}
82
86
void
SoundLibraryRepositoryDialog::on_DeleteBtn_clicked
()
87
{
88
QList<QListWidgetItem *> selectedItems;
89
selectedItems = ServerListWidget->selectedItems();
90
91
//std::list<std::string>::const_iterator cur_Server;
92
H2Core::Preferences
*pPref =
H2Core::Preferences::get_instance
();
93
94
while
( ! selectedItems.isEmpty() ){
95
96
QString selText;
97
98
selText = selectedItems.takeFirst()->text();
99
100
pPref->
sServerList
.remove(selText);
101
102
}
103
updateDialog
();
104
}
105
106
void
SoundLibraryRepositoryDialog::on_CloseBtn_clicked
()
107
{
108
accept();
109
}
110
111
SoundLibraryRepositoryDialog::~SoundLibraryRepositoryDialog
()
112
{
113
INFOLOG
(
"DESTROY"
);
114
115
}
INFOLOG
#define INFOLOG(x)
Definition
Object.h:240
Preferences.h
SoundLibraryRepositoryDialog.h
H2Core::Preferences
Manager for User Preferences File (singleton)
Definition
Preferences.h:79
H2Core::Preferences::get_instance
static Preferences * get_instance()
Returns a pointer to the current Preferences singleton stored in __instance.
Definition
Preferences.h:406
H2Core::Preferences::sServerList
std::list< QString > sServerList
Definition
Preferences.h:170
SoundLibraryRepositoryDialog::on_CloseBtn_clicked
void on_CloseBtn_clicked()
Definition
SoundLibraryRepositoryDialog.cpp:106
SoundLibraryRepositoryDialog::~SoundLibraryRepositoryDialog
~SoundLibraryRepositoryDialog()
Definition
SoundLibraryRepositoryDialog.cpp:111
SoundLibraryRepositoryDialog::on_AddBtn_clicked
void on_AddBtn_clicked()
Add new server url.
Definition
SoundLibraryRepositoryDialog.cpp:69
SoundLibraryRepositoryDialog::SoundLibraryRepositoryDialog
SoundLibraryRepositoryDialog(QWidget *pParent)
Definition
SoundLibraryRepositoryDialog.cpp:31
SoundLibraryRepositoryDialog::on_DeleteBtn_clicked
void on_DeleteBtn_clicked()
Delete serverList entry.
Definition
SoundLibraryRepositoryDialog.cpp:86
SoundLibraryRepositoryDialog::updateDialog
void updateDialog()
Definition
SoundLibraryRepositoryDialog.cpp:46
src
gui
src
SoundLibrary
SoundLibraryRepositoryDialog.cpp
Generated by
1.13.2