# HG changeset patch # User Jacob Dawid # Date 1311533568 -7200 # Node ID bb3676025b36c9890a86ea9aa52cac6082dbfc4d # Parent 8c7390b78911770465e0a535e8b5a52d58ac19cc User can set a custom file editor instead of the built-in one. diff -r 8c7390b78911 -r bb3676025b36 gui/src/FilesDockWidget.cpp --- a/gui/src/FilesDockWidget.cpp Fri Jul 22 22:01:37 2011 +0200 +++ b/gui/src/FilesDockWidget.cpp Sun Jul 24 20:52:48 2011 +0200 @@ -21,6 +21,9 @@ #include #include #include +#include +#include +#include FilesDockWidget::FilesDockWidget (QWidget * parent):QDockWidget (parent) { @@ -90,7 +93,10 @@ void FilesDockWidget::itemDoubleClicked (const QModelIndex & index) { + // Retrieve the file info associated with the model index. QFileInfo fileInfo = m_fileSystemModel->fileInfo (index); + + // If it is a directory, cd into it. if (fileInfo.isDir ()) { m_fileSystemModel->setRootPath (fileInfo.absolutePath ()); @@ -98,10 +104,26 @@ setCurrentDirectory (m_fileSystemModel->fileInfo (index). absoluteFilePath ()); } + // Otherwise attempt to open it. else { - QFileInfo fileInfo = m_fileSystemModel->fileInfo (index); - emit openFile (fileInfo.filePath ()); + // Check if the user wants to use a custom file editor. + QDesktopServices desktopServices; + QString settingsFile = + desktopServices.storageLocation (QDesktopServices::HomeLocation) + + "/.quint/settings.ini"; + QSettings settings (settingsFile, QSettings::IniFormat); + if (settings.value ("useCustomFileEditor").toBool ()) + { + QString editor = settings.value ("customFileEditor").toString (); + QStringList arguments; + arguments << fileInfo.filePath (); + QProcess::execute (editor, arguments); + } + else + { + emit openFile (fileInfo.filePath ()); + } } } diff -r 8c7390b78911 -r bb3676025b36 gui/src/MainWindow.cpp --- a/gui/src/MainWindow.cpp Fri Jul 22 22:01:37 2011 +0200 +++ b/gui/src/MainWindow.cpp Sun Jul 24 20:52:48 2011 +0200 @@ -31,8 +31,7 @@ MainWindow::MainWindow (QWidget * parent):QMainWindow (parent), m_isRunning (true) { - QDesktopServices - desktopServices; + QDesktopServices desktopServices; m_settingsFile = desktopServices.storageLocation (QDesktopServices::HomeLocation) + "/.quint/settings.ini"; diff -r 8c7390b78911 -r bb3676025b36 gui/src/SettingsDialog.cpp --- a/gui/src/SettingsDialog.cpp Fri Jul 22 22:01:37 2011 +0200 +++ b/gui/src/SettingsDialog.cpp Sun Jul 24 20:52:48 2011 +0200 @@ -9,26 +9,24 @@ ui->setupUi (this); QSettings settings (m_settingsFile, QSettings::IniFormat); - ui->connectOnStartup->setChecked (settings.value ("connectOnStartup"). - toBool ()); - ui->showMessageOfTheDay->setChecked (settings.value ("showMessageOfTheDay"). - toBool ()); + ui->connectOnStartup->setChecked (settings.value ("connectOnStartup").toBool ()); + ui->showMessageOfTheDay->setChecked (settings.value ("showMessageOfTheDay").toBool ()); ui->showTopic->setChecked (settings.value ("showTopic").toBool ()); - ui->autoIdentification->setChecked (settings.value ("autoIdentification"). - toBool ()); - ui->nickServPassword->setText (settings.value ("nickServPassword"). - toString ()); + ui->autoIdentification->setChecked (settings.value ("autoIdentification").toBool ()); + ui->nickServPassword->setText (settings.value ("nickServPassword").toString ()); + ui->useCustomFileEditor->setChecked (settings.value ("useCustomFileEditor").toBool ()); + ui->customFileEditor->setText (settings.value ("customFileEditor").toString ()); } SettingsDialog::~SettingsDialog () { QSettings settings (m_settingsFile, QSettings::IniFormat); settings.setValue ("connectOnStartup", ui->connectOnStartup->isChecked ()); - settings.setValue ("showMessageOfTheDay", - ui->showMessageOfTheDay->isChecked ()); + settings.setValue ("showMessageOfTheDay", ui->showMessageOfTheDay->isChecked ()); settings.setValue ("showTopic", ui->showTopic->isChecked ()); - settings.setValue ("autoIdentification", - ui->autoIdentification->isChecked ()); + settings.setValue ("autoIdentification", ui->autoIdentification->isChecked ()); settings.setValue ("nickServPassword", ui->nickServPassword->text ()); + settings.setValue ("useCustomFileEditor", ui->useCustomFileEditor->isChecked ()); + settings.setValue ("customFileEditor", ui->customFileEditor->text ()); delete ui; } diff -r 8c7390b78911 -r bb3676025b36 gui/src/SettingsDialog.ui --- a/gui/src/SettingsDialog.ui Fri Jul 22 22:01:37 2011 +0200 +++ b/gui/src/SettingsDialog.ui Sun Jul 24 20:52:48 2011 +0200 @@ -10,26 +10,26 @@ 0 0 500 - 270 + 300 500 - 270 + 300 500 - 270 + 300 Settings - - + + 0 @@ -106,6 +106,9 @@ + + false + QLineEdit::Password @@ -117,10 +120,122 @@ + + + Editor + + + + + + + + Use custom file editor: + + + + + + + false + + + emacs + + + + + + + + + Qt::Vertical + + + + 20 + 158 + + + + + + + + + + + + Reset to defaults + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Export + + + + + + + Import + + + + + - + + + useCustomFileEditor + toggled(bool) + customFileEditor + setEnabled(bool) + + + 111 + 62 + + + 343 + 63 + + + + + autoIdentification + toggled(bool) + nickServPassword + setEnabled(bool) + + + 249 + 144 + + + 384 + 229 + + + +