diff --git a/apps/launcher/datafilespage.cpp b/apps/launcher/datafilespage.cpp
index 1fa93962a..06e9ff3f8 100644
--- a/apps/launcher/datafilespage.cpp
+++ b/apps/launcher/datafilespage.cpp
@@ -83,12 +83,14 @@ DataFilesPage::DataFilesPage(QWidget *parent) : QWidget(parent)
mNewProfileButton = new QPushButton(this);
mNewProfileButton->setIcon(QIcon::fromTheme("document-new"));
+ mNewProfileButton->setShortcut(QKeySequence(tr("Ctrl+N")));
mCopyProfileButton = new QPushButton(this);
mCopyProfileButton->setIcon(QIcon::fromTheme("edit-copy"));
mDeleteProfileButton = new QPushButton(this);
mDeleteProfileButton->setIcon(QIcon::fromTheme("document-close"));
+ mDeleteProfileButton->setShortcut(QKeySequence(tr("Delete")));
QHBoxLayout *bottomLayout = new QHBoxLayout();
@@ -122,6 +124,8 @@ DataFilesPage::DataFilesPage(QWidget *parent) : QWidget(parent)
connect(mNewProfileButton, SIGNAL(pressed()), this, SLOT(newProfile()));
+ connect(mCopyProfileButton, SIGNAL(pressed()), this, SLOT(copyProfile()));
+ connect(mDeleteProfileButton, SIGNAL(pressed()), this, SLOT(deleteProfile()));
setupConfig();
}
@@ -149,15 +153,73 @@ void DataFilesPage::newProfile()
}
+void DataFilesPage::copyProfile()
+{
+ QString profile = mProfilesComboBox->currentText();
+ bool ok;
+
+ QString text = QInputDialog::getText(this, tr("Copy Profile"),
+ tr("Profile Name:"), QLineEdit::Normal,
+ tr("%0 Copy").arg(profile), &ok);
+ if (ok && !text.isEmpty()) {
+ if (mProfilesComboBox->findText(text) != -1)
+ {
+ QMessageBox::warning(this, tr("Profile already exists"),
+ tr("the profile %0 already exists.").arg(text),
+ QMessageBox::Ok);
+ } else {
+ // Add the new profile to the combobox
+ mProfilesComboBox->addItem(text);
+
+ // First write the current profile as the new profile
+ writeConfig(text);
+ mProfilesComboBox->setCurrentIndex(mProfilesComboBox->findText(text));
+
+ }
+
+ }
+
+}
+
void DataFilesPage::deleteProfile()
{
QString profile = mProfilesComboBox->currentText();
- if (!profile.isEmpty()) {
- QMessageBox::warning(this, tr("Delete profile"),
- tr("Are you sure you want to remove %0.").arg(profile),
- QMessageBox::Ok);
+ if (profile.isEmpty()) {
+ return;
+ }
+
+ QMessageBox deleteMessageBox(this);
+ deleteMessageBox.setWindowTitle(tr("Delete Profile"));
+ deleteMessageBox.setText(tr("Are you sure you want to delete %0?").arg(profile));
+ deleteMessageBox.setIcon(QMessageBox::Warning);
+ QAbstractButton *deleteButton =
+ deleteMessageBox.addButton(tr("Delete"), QMessageBox::ActionRole);
+
+ deleteMessageBox.addButton(QMessageBox::Cancel);
+
+ deleteMessageBox.exec();
+
+ if (deleteMessageBox.clickedButton() == deleteButton) {
+
+ qDebug() << "Delete profile " << profile;
+
+ // Make sure we have no groups open
+ while (!mLauncherConfig->group().isEmpty()) {
+ mLauncherConfig->endGroup();
+ }
+
+ mLauncherConfig->beginGroup("Profiles");
+
+ // Open the profile-name subgroup
+ mLauncherConfig->beginGroup(profile);
+ mLauncherConfig->remove(""); // Clear the subgroup
+ mLauncherConfig->endGroup();
+ mLauncherConfig->endGroup();
+
+ // Remove the profile from the combobox
+ mProfilesComboBox->removeItem(mProfilesComboBox->findText(profile));
}
}
diff --git a/apps/launcher/datafilespage.hpp b/apps/launcher/datafilespage.hpp
index 2d91cf329..2aebc0160 100644
--- a/apps/launcher/datafilespage.hpp
+++ b/apps/launcher/datafilespage.hpp
@@ -39,6 +39,7 @@ public slots:
void resizeRows();
void profileChanged(const QString &previous, const QString ¤t);
void newProfile();
+ void copyProfile();
void deleteProfile();
private: