Mercurial > hg > octave-lyh
changeset 13531:bb3676025b36
User can set a custom file editor instead of the built-in one.
author | Jacob Dawid <jacob.dawid@googlemail.com> |
---|---|
date | Sun, 24 Jul 2011 20:52:48 +0200 |
parents | 8c7390b78911 |
children | fd87d6f7e185 |
files | gui/src/FilesDockWidget.cpp gui/src/MainWindow.cpp gui/src/SettingsDialog.cpp gui/src/SettingsDialog.ui |
diffstat | 4 files changed, 156 insertions(+), 22 deletions(-) [+] |
line wrap: on
line diff
--- a/gui/src/FilesDockWidget.cpp +++ b/gui/src/FilesDockWidget.cpp @@ -21,6 +21,9 @@ #include <QApplication> #include <QFileInfo> #include <QCompleter> +#include <QSettings> +#include <QProcess> +#include <QDesktopServices> 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 ()); + } } }
--- a/gui/src/MainWindow.cpp +++ b/gui/src/MainWindow.cpp @@ -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";
--- a/gui/src/SettingsDialog.cpp +++ b/gui/src/SettingsDialog.cpp @@ -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; }
--- a/gui/src/SettingsDialog.ui +++ b/gui/src/SettingsDialog.ui @@ -10,26 +10,26 @@ <x>0</x> <y>0</y> <width>500</width> - <height>270</height> + <height>300</height> </rect> </property> <property name="minimumSize"> <size> <width>500</width> - <height>270</height> + <height>300</height> </size> </property> <property name="maximumSize"> <size> <width>500</width> - <height>270</height> + <height>300</height> </size> </property> <property name="windowTitle"> <string>Settings</string> </property> - <layout class="QGridLayout" name="gridLayout"> - <item row="1" column="0"> + <layout class="QVBoxLayout" name="verticalLayout_2"> + <item> <widget class="QTabWidget" name="tabWidget"> <property name="currentIndex"> <number>0</number> @@ -106,6 +106,9 @@ </item> <item> <widget class="QLineEdit" name="nickServPassword"> + <property name="enabled"> + <bool>false</bool> + </property> <property name="echoMode"> <enum>QLineEdit::Password</enum> </property> @@ -117,10 +120,122 @@ </item> </layout> </widget> + <widget class="QWidget" name="tab"> + <attribute name="title"> + <string>Editor</string> + </attribute> + <layout class="QGridLayout" name="gridLayout"> + <item row="0" column="0"> + <layout class="QHBoxLayout" name="horizontalLayout_3"> + <item> + <widget class="QCheckBox" name="useCustomFileEditor"> + <property name="text"> + <string>Use custom file editor:</string> + </property> + </widget> + </item> + <item> + <widget class="QLineEdit" name="customFileEditor"> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="text"> + <string>emacs</string> + </property> + </widget> + </item> + </layout> + </item> + <item row="1" column="0"> + <spacer name="verticalSpacer"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>158</height> + </size> + </property> + </spacer> + </item> + </layout> + </widget> </widget> </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout_2"> + <item> + <widget class="QPushButton" name="resetButton"> + <property name="text"> + <string>Reset to defaults</string> + </property> + </widget> + </item> + <item> + <spacer name="horizontalSpacer_2"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QPushButton" name="exportButton"> + <property name="text"> + <string>Export</string> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="importButton"> + <property name="text"> + <string>Import</string> + </property> + </widget> + </item> + </layout> + </item> </layout> </widget> <resources/> - <connections/> + <connections> + <connection> + <sender>useCustomFileEditor</sender> + <signal>toggled(bool)</signal> + <receiver>customFileEditor</receiver> + <slot>setEnabled(bool)</slot> + <hints> + <hint type="sourcelabel"> + <x>111</x> + <y>62</y> + </hint> + <hint type="destinationlabel"> + <x>343</x> + <y>63</y> + </hint> + </hints> + </connection> + <connection> + <sender>autoIdentification</sender> + <signal>toggled(bool)</signal> + <receiver>nickServPassword</receiver> + <slot>setEnabled(bool)</slot> + <hints> + <hint type="sourcelabel"> + <x>249</x> + <y>144</y> + </hint> + <hint type="destinationlabel"> + <x>384</x> + <y>229</y> + </hint> + </hints> + </connection> + </connections> </ui>