# HG changeset patch # User Chris Cannam # Date 1292537498 0 # Node ID 1a3af8617ea4e317404f0fe9263535043b22cdd9 # Parent bb89bcd8986bbcd4e0cab260821914f64bbaeaea * basic external editor selection (for hgignore) diff -r bb89bcd8986b -r 1a3af8617ea4 common.cpp --- a/common.cpp Thu Dec 16 20:23:43 2010 +0000 +++ b/common.cpp Thu Dec 16 22:11:38 2010 +0000 @@ -48,9 +48,9 @@ if (name != "") { if (name[0] != '/' #ifdef Q_OS_WIN32 - && (QRegExp("^[a-zA-Z]:").indexIn(name) != 0) + && (QRegExp("^\\w:").indexIn(name) != 0) #endif - ) { + ) { #ifdef Q_OS_WIN32 QChar pathSep = ';'; #else @@ -68,7 +68,7 @@ path = installPath + pathSep + path; } #ifndef Q_OS_WIN32 - //!!! + //!!! path = path + ":/usr/local/bin"; DEBUG << "... adding /usr/local/bin just in case (fix and add settings dlg please)" << endl; diff -r bb89bcd8986b -r 1a3af8617ea4 mainwindow.cpp --- a/mainwindow.cpp Thu Dec 16 20:23:43 2010 +0000 +++ b/mainwindow.cpp Thu Dec 16 22:11:38 2010 +0000 @@ -376,26 +376,51 @@ { QString hgIgnorePath; QStringList params; - QString editorName; - + hgIgnorePath = workFolderPath; - hgIgnorePath += ".hgignore"; + hgIgnorePath += "/.hgignore"; params << hgIgnorePath; -//!!! -#ifdef Q_OS_LINUX + QSettings settings; + settings.beginGroup("Locations"); + QString editor = settings.value("editorbinary", "").toString(); + if (editor == "") { + QStringList bases; + bases +#if defined Q_OS_WIN32 + << "wordpad.exe" + << "C:\\Program Files\\Windows NT\\Accessories\\wordpad.exe" + << "notepad.exe" +#elif defined Q_OS_MAC + << "textedit" +#else + << "gedit" << "kate" +#endif + ; + bool found = false; + foreach (QString base, bases) { + editor = findInPath(base, m_myDirPath, true); + if (editor != base && editor != base + ".exe") { + found = true; + break; + } + } + if (found) { + settings.setValue("editorbinary", editor); + } else { + editor = ""; + } + } - editorName = "gedit"; - -#else - - editorName = """C:\\Program Files\\Windows NT\\Accessories\\wordpad.exe"""; - -#endif + if (editor == "") { + DEBUG << "Failed to find a text editor" << endl; + //!!! visible error! + return; + } HgAction action(ACT_HG_IGNORE, workFolderPath, params); - action.executable = editorName; + action.executable = editor; runner->requestAction(action); } @@ -1829,7 +1854,7 @@ //Repository actions hgRefreshAct = new QAction(QIcon(":/images/status.png"), tr("Refresh"), this); - hgRefreshAct->setStatusTip(tr("Update the window to show the current state of the working folder")); + hgRefreshAct->setStatusTip(tr("Refresh the window to show the current state of the working folder")); hgIncomingAct = new QAction(QIcon(":/images/incoming.png"), tr("Preview"), this); hgIncomingAct -> setStatusTip(tr("See what changes are available in the remote repository waiting to be pulled")); diff -r bb89bcd8986b -r 1a3af8617ea4 settingsdialog.cpp --- a/settingsdialog.cpp Thu Dec 16 20:23:43 2010 +0000 +++ b/settingsdialog.cpp Thu Dec 16 22:11:38 2010 +0000 @@ -94,7 +94,7 @@ browse = new QPushButton(tr("Browse...")); pathsLayout->addWidget(browse, row++, 2); connect(browse, SIGNAL(clicked()), this, SLOT(diffPathBrowse())); - + pathsLayout->addWidget(new QLabel(tr("External file-merge program:")), row, 0); m_mergePathEdit = new QLineEdit(); @@ -107,6 +107,18 @@ pathsLayout->addWidget(browse, row++, 2); connect(browse, SIGNAL(clicked()), this, SLOT(mergePathBrowse())); + pathsLayout->addWidget(new QLabel(tr("External text editor:")), row, 0); + + m_editPathEdit = new QLineEdit(); + m_editPathEdit->setText(settings.value("editorbinary").toString()); + connect(m_editPathEdit, SIGNAL(textChanged(const QString &)), + this, SLOT(editPathChanged(const QString &))); + pathsLayout->addWidget(m_editPathEdit, row, 1); + + browse = new QPushButton(tr("Browse...")); + pathsLayout->addWidget(browse, row++, 2); + connect(browse, SIGNAL(clicked()), this, SLOT(editPathBrowse())); + settings.endGroup(); settings.beginGroup("Locations"); @@ -186,12 +198,12 @@ } void -SettingsDialog::editorPathChanged(const QString &s) +SettingsDialog::editPathChanged(const QString &s) { } void -SettingsDialog::editorPathBrowse() +SettingsDialog::editPathBrowse() { } diff -r bb89bcd8986b -r 1a3af8617ea4 settingsdialog.h --- a/settingsdialog.h Thu Dec 16 20:23:43 2010 +0000 +++ b/settingsdialog.h Thu Dec 16 22:11:38 2010 +0000 @@ -40,8 +40,8 @@ void diffPathBrowse(); void mergePathChanged(const QString &); void mergePathBrowse(); - void editorPathChanged(const QString &); - void editorPathBrowse(); + void editPathChanged(const QString &); + void editPathBrowse(); void extensionPathChanged(const QString &); void extensionPathBrowse(); @@ -53,7 +53,7 @@ QLineEdit *m_hgPathEdit; QLineEdit *m_diffPathEdit; QLineEdit *m_mergePathEdit; - QLineEdit *m_editorPathEdit; + QLineEdit *m_editPathEdit; QCheckBox *m_useExtension; QLineEdit *m_extensionPathEdit;