# HG changeset patch # User Chris Cannam # Date 1330362506 0 # Node ID d932ce55c364b49393997bda1ffd1df7ad7518da # Parent 57a7f95ef4001e66c496597d299412cc7e828ac2 Remove the single find widget from top, add one to each tab at the bottom instead. (Turns out you don't usually want to search for the same text in both types of widget.) Also provide sensible no-results text. diff -r 57a7f95ef400 -r d932ce55c364 src/filestatuswidget.cpp --- a/src/filestatuswidget.cpp Thu Feb 23 15:28:29 2012 +0000 +++ b/src/filestatuswidget.cpp Mon Feb 27 17:08:26 2012 +0000 @@ -18,6 +18,7 @@ #include "filestatuswidget.h" #include "debug.h" #include "multichoicedialog.h" +#include "findwidget.h" #include #include @@ -154,9 +155,19 @@ layout->addItem(new QSpacerItem(8, 8), ++row, 0); - m_showAllFiles = new QCheckBox(tr("Show all files"), this); + QWidget *opts = new QWidget; + QGridLayout *optLayout = new QGridLayout(opts); + optLayout->setMargin(0); + layout->addWidget(opts, ++row, 0); + + m_findWidget = new FindWidget(this); + optLayout->addWidget(m_findWidget, 0, 0, Qt::AlignLeft); + connect(m_findWidget, SIGNAL(findTextChanged(QString)), + this, SLOT(setSearchText(QString))); + + m_showAllFiles = new QCheckBox(tr("Show all file states"), this); m_showAllFiles->setEnabled(false); - layout->addWidget(m_showAllFiles, ++row, 0, Qt::AlignLeft); + optLayout->addWidget(m_showAllFiles, 0, 1, Qt::AlignRight); QSettings settings; m_showAllFiles->setChecked(settings.value("showall", false).toBool()); @@ -209,7 +220,16 @@ { QSettings settings; settings.beginGroup("Presentation"); - if (settings.value("showhelpfultext", true).toBool()) { + + if (m_searchText != "") { + if (!m_showAllFiles->isChecked()) { + m_noModificationsLabel->setText + (tr("Nothing found
None of the modified files have matching filenames.
Select Show all file states to find matches among unmodified and untracked files as well.
")); + } else { + m_noModificationsLabel->setText + (tr("Nothing found
No files have matching filenames.
")); + } + } else if (settings.value("showhelpfultext", true).toBool()) { m_noModificationsLabel->setText (tr("This area will list files in your working folder that you have changed.

At the moment you have no uncommitted changes.

To see changes previously made to the repository,
switch to the History tab.

%1
") #if defined Q_OS_MAC diff -r 57a7f95ef400 -r d932ce55c364 src/filestatuswidget.h --- a/src/filestatuswidget.h Thu Feb 23 15:28:29 2012 +0000 +++ b/src/filestatuswidget.h Mon Feb 27 17:08:26 2012 +0000 @@ -29,6 +29,7 @@ class QPushButton; class QFileInfo; class QCheckBox; +class FindWidget; class FileStatusWidget : public QWidget { @@ -89,6 +90,7 @@ QString m_localPath; QLabel *m_noModificationsLabel; + FindWidget *m_findWidget; QCheckBox *m_showAllFiles; FileStates m_fileStates; diff -r 57a7f95ef400 -r d932ce55c364 src/findwidget.cpp --- a/src/findwidget.cpp Thu Feb 23 15:28:29 2012 +0000 +++ b/src/findwidget.cpp Mon Feb 27 17:08:26 2012 +0000 @@ -26,25 +26,26 @@ QWidget(parent) { QGridLayout *layout = new QGridLayout; + layout->setMargin(0); setLayout(layout); QToolButton *button = new QToolButton(); layout->addWidget(button, 0, 0); button->setText(tr("Find...")); button->setToolButtonStyle(Qt::ToolButtonTextOnly); - button->setAutoRaise(true); +// button->setAutoRaise(true); connect(button, SIGNAL(clicked()), this, SLOT(buttonPressed())); -/* - QLabel *label = new QLabel(tr("Find:")); - layout->addWidget(label, 0, 0); -*/ m_lineEdit = new QLineEdit(); layout->addWidget(m_lineEdit, 0, 1); m_lineEdit->setFixedWidth(100); m_lineEdit->hide(); + int h = m_lineEdit->sizeHint().height(); + int h0 = button->sizeHint().height(); + if (h > h0) button->setFixedHeight(h); + connect(m_lineEdit, SIGNAL(textChanged(const QString &)), this, SIGNAL(findTextChanged(QString))); } @@ -66,6 +67,7 @@ } } else { m_lineEdit->show(); + m_lineEdit->setFocus(Qt::OtherFocusReason); button->setText(tr("Find:")); if (m_lineEdit->text() != "") { emit findTextChanged(m_lineEdit->text()); diff -r 57a7f95ef400 -r d932ce55c364 src/historywidget.cpp --- a/src/historywidget.cpp Thu Feb 23 15:28:29 2012 +0000 +++ b/src/historywidget.cpp Mon Feb 27 17:08:26 2012 +0000 @@ -23,6 +23,7 @@ #include "grapher.h" #include "debug.h" #include "uncommitteditem.h" +#include "findwidget.h" #include @@ -55,11 +56,21 @@ settings.beginGroup("Presentation"); bool showClosed = (settings.value("showclosedbranches", false).toBool()); + QWidget *opts = new QWidget; + QGridLayout *optLayout = new QGridLayout(opts); + optLayout->setMargin(0); + layout->addWidget(opts, ++row, 0, 1, 2); + + m_findWidget = new FindWidget(this); + optLayout->addWidget(m_findWidget, 0, 0, Qt::AlignLeft); + connect(m_findWidget, SIGNAL(findTextChanged(QString)), + this, SLOT(setSearchText(QString))); + m_showClosedBranches = new QCheckBox(tr("Show closed branches"), this); m_showClosedBranches->setChecked(showClosed); connect(m_showClosedBranches, SIGNAL(toggled(bool)), this, SLOT(showClosedChanged(bool))); - layout->addWidget(m_showClosedBranches, ++row, 0, Qt::AlignLeft); + optLayout->addWidget(m_showClosedBranches, 0, 1, Qt::AlignRight); m_showClosedBranches->hide(); setLayout(layout); diff -r 57a7f95ef400 -r d932ce55c364 src/historywidget.h --- a/src/historywidget.h Thu Feb 23 15:28:29 2012 +0000 +++ b/src/historywidget.h Mon Feb 27 17:08:26 2012 +0000 @@ -28,6 +28,7 @@ class Panner; class UncommittedItem; class QGraphicsScene; +class FindWidget; class HistoryWidget : public QWidget { @@ -81,6 +82,7 @@ bool m_showUncommitted; bool m_refreshNeeded; + FindWidget *m_findWidget; Panned *m_panned; Panner *m_panner; QCheckBox *m_showClosedBranches; diff -r 57a7f95ef400 -r d932ce55c364 src/mainwindow.cpp --- a/src/mainwindow.cpp Thu Feb 23 15:28:29 2012 +0000 +++ b/src/mainwindow.cpp Mon Feb 27 17:08:26 2012 +0000 @@ -53,7 +53,6 @@ #include "hgignoredialog.h" #include "versiontester.h" #include "fswatcher.h" -#include "findwidget.h" MainWindow::MainWindow(QString myDirPath) : @@ -108,12 +107,7 @@ #endif m_workStatus = new WorkStatusWidget(this); - cl->addWidget(m_workStatus, row, 0); - - m_findWidget = new FindWidget(this); - cl->addWidget(m_findWidget, row++, 1, Qt::AlignRight | Qt::AlignTop); - connect(m_findWidget, SIGNAL(findTextChanged(QString)), - this, SLOT(findTextChanged(QString))); + cl->addWidget(m_workStatus, row++, 0); m_hgTabs = new HgTabWidget(central, m_workFolderPath); connectTabsSignals(); @@ -232,12 +226,6 @@ hgQueryPaths(); } -void MainWindow::findTextChanged(QString text) -{ - std::cerr << "find: " << text << std::endl; - m_hgTabs->setSearchText(text); -} - void MainWindow::hgRefresh() { clearState(); diff -r 57a7f95ef400 -r d932ce55c364 src/mainwindow.h --- a/src/mainwindow.h Thu Feb 23 15:28:29 2012 +0000 +++ b/src/mainwindow.h Mon Feb 27 17:08:26 2012 +0000 @@ -36,7 +36,6 @@ class WorkStatusWidget; class FsWatcher; -class FindWidget; class MainWindow : public QMainWindow { @@ -69,7 +68,6 @@ void startupDialog(); void clearSelections(); void showAllChanged(); - void findTextChanged(QString); void hgTest(); void hgTestExtension(); @@ -183,7 +181,6 @@ WorkStatusWidget *m_workStatus; HgTabWidget *m_hgTabs; - FindWidget *m_findWidget; QString m_remoteRepoPath; QString m_workFolderPath;