Changed: Open directory containing the profile

--HG--
branch : develop
This commit is contained in:
kervala 2016-06-11 17:00:09 +02:00
parent 32e3dfe54b
commit f5762eff59
2 changed files with 26 additions and 1 deletions

View file

@ -32,6 +32,7 @@ CProfilesDialog::CProfilesDialog(QWidget *parent):QDialog(parent), m_currentProf
connect(deleteButton, SIGNAL(clicked()), SLOT(onDeleteProfile())); connect(deleteButton, SIGNAL(clicked()), SLOT(onDeleteProfile()));
connect(profilesListView, SIGNAL(clicked(QModelIndex)), SLOT(onProfileClicked(QModelIndex))); connect(profilesListView, SIGNAL(clicked(QModelIndex)), SLOT(onProfileClicked(QModelIndex)));
connect(executableBrowseButton, SIGNAL(clicked()), SLOT(onExecutableBrowseClicked())); connect(executableBrowseButton, SIGNAL(clicked()), SLOT(onExecutableBrowseClicked()));
connect(directoryButton, SIGNAL(clicked()), SLOT(onProfileDirectoryClicked()));
m_model = new CProfilesModel(this); m_model = new CProfilesModel(this);
m_serversModel = new CServersModel(this); m_serversModel = new CServersModel(this);
@ -97,6 +98,15 @@ void CProfilesDialog::displayProfile(int index)
const CProfile &profile = m_model->getProfiles()[index]; const CProfile &profile = m_model->getProfiles()[index];
QString executable = profile.executable;
if (executable.isEmpty())
{
executable = CConfigFile::getInstance()->getServerClientFullPath(profile.server);
}
QString profileDirectory = CConfigFile::getInstance()->getProfileDirectory() + "/" + profile.id;
// update all widgets with content of profile // update all widgets with content of profile
profileIdLabel->setText(profile.id); profileIdLabel->setText(profile.id);
nameEdit->setText(profile.name); nameEdit->setText(profile.name);
@ -104,10 +114,13 @@ void CProfilesDialog::displayProfile(int index)
executablePathLabel->setText(QFileInfo(profile.executable).fileName()); executablePathLabel->setText(QFileInfo(profile.executable).fileName());
argumentsEdit->setText(profile.arguments); argumentsEdit->setText(profile.arguments);
commentsEdit->setPlainText(profile.comments); commentsEdit->setPlainText(profile.comments);
directoryPathLabel->setText(CConfigFile::getInstance()->getProfileDirectory()); directoryPathLabel->setText(profileDirectory);
desktopShortcutCheckBox->setChecked(profile.desktopShortcut); desktopShortcutCheckBox->setChecked(profile.desktopShortcut);
menuShortcutCheckBox->setChecked(profile.menuShortcut); menuShortcutCheckBox->setChecked(profile.menuShortcut);
// disable click on button if directory doesn't exist
directoryButton->setEnabled(QFile::exists(profileDirectory));
updateExecutableVersion(index); updateExecutableVersion(index);
m_currentProfileIndex = index; m_currentProfileIndex = index;
@ -249,3 +262,14 @@ void CProfilesDialog::onExecutableBrowseClicked()
updateExecutableVersion(m_currentProfileIndex); updateExecutableVersion(m_currentProfileIndex);
} }
void CProfilesDialog::onProfileDirectoryClicked()
{
if (m_currentProfileIndex < 0) return;
const CProfile &profile = m_model->getProfiles()[m_currentProfileIndex];
QString profileDirectory = CConfigFile::getInstance()->getProfileDirectory() + "/" + profile.id;
QDesktopServices::openUrl(QUrl::fromLocalFile(profileDirectory));
}

View file

@ -42,6 +42,7 @@ private slots:
void onAddProfile(); void onAddProfile();
void onDeleteProfile(); void onDeleteProfile();
void onProfileClicked(const QModelIndex &index); void onProfileClicked(const QModelIndex &index);
void onProfileDirectoryClicked();
void displayProfile(int index); void displayProfile(int index);
void saveProfile(int index); void saveProfile(int index);