3 Copyright (c) 2012 Jakob Leben & Tim Blechmann
4 http://www.audiosynth.com
6 This program 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 2 of the License, or
9 (at your option) any later version.
11 This program 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.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 #ifndef SCIDE_WIDGETS_SESSIONS_DIALOG_HPP_INCLUDED
22 #define SCIDE_WIDGETS_SESSIONS_DIALOG_HPP_INCLUDED
24 #include "../core/session_manager.hpp"
27 #include <QListWidget>
28 #include <QPushButton>
29 #include <QDialogButtonBox>
30 #include <QHBoxLayout>
31 #include <QVBoxLayout>
32 #include <QInputDialog>
33 #include <QMessageBox>
37 class SessionsDialog
: public QDialog
42 SessionsDialog ( SessionManager
*mng
, QWidget
*parent
= 0 ):
46 setWindowTitle("Sessions");
48 mList
= new QListWidget
;
50 QPushButton
*removeBtn
= new QPushButton(tr("Delete"));
51 QPushButton
*renameBtn
= new QPushButton(tr("Rename..."));
53 QDialogButtonBox
*dialogBtns
= new QDialogButtonBox(QDialogButtonBox::Ok
);
56 QHBoxLayout
*contentBox
= new QHBoxLayout
;
57 QVBoxLayout
*btnBox
= new QVBoxLayout
;
58 btnBox
->addWidget(renameBtn
);
59 btnBox
->addWidget(removeBtn
);
61 contentBox
->addWidget(mList
);
62 contentBox
->addLayout(btnBox
);
64 QVBoxLayout
*layout
= new QVBoxLayout
;
65 layout
->addLayout(contentBox
);
66 layout
->addWidget(dialogBtns
);
70 connect(removeBtn
, SIGNAL(clicked()), this, SLOT(removeCurrent()));
71 connect(renameBtn
, SIGNAL(clicked()), this, SLOT(renameCurrent()));
72 connect(dialogBtns
, SIGNAL(accepted()), this, SLOT(accept()));
80 QListWidgetItem
*item
= mList
->currentItem();
84 QString name
= item
->text();
86 if ( QMessageBox::warning (
89 tr("Are you sure you want to delete session '%1'?").arg(name
),
90 QMessageBox::Yes
| QMessageBox::No
,
92 ) == QMessageBox::Yes
)
94 mMng
->removeSession(name
);
101 QListWidgetItem
*item
= mList
->currentItem();
105 QString oldName
= item
->text();
106 QString newName
= QInputDialog::getText (
108 tr("Rename Session"),
109 tr("Enter a new name for the session:"),
113 if (newName
.isEmpty() || newName
== oldName
)
116 mMng
->renameSession(oldName
, newName
);
121 void updateSessions()
124 QStringList sessions
= mMng
->availableSessions();
125 mList
->addItems(sessions
);
129 SessionManager
*mMng
;