# HG changeset patch # User Chris Cannam # Date 1294326943 0 # Node ID 6c5a06da0ab920a83fc9a614bc77247a43d9f6e8 # Parent e67bd8abc3e331ab194892b536c62efc95d19b8b# Parent 1b2ee42fa004cdd8b4fbf5fbd04af66fc53cc8b9 Merge diff -r 1b2ee42fa004 -r 6c5a06da0ab9 filestatuswidget.cpp --- a/filestatuswidget.cpp Thu Jan 06 14:17:35 2011 +0000 +++ b/filestatuswidget.cpp Thu Jan 06 15:15:43 2011 +0000 @@ -31,6 +31,7 @@ #include #include #include +#include FileStatusWidget::FileStatusWidget(QWidget *parent) : QWidget(parent), @@ -72,17 +73,9 @@ layout->addWidget(new QLabel("
"), ++row, 0, 1, 3); ++row; - //!!! option to be less verbose -> shorten this - m_noModificationsLabel = new QLabel - (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 - .arg(tr("To open the working folder in Finder,
click on the “Local” folder path shown above.")) -#elif defined Q_OS_WIN32 - .arg(tr("To open the working folder in Windows Explorer,
click on the “Local” folder path shown above.")) -#else - .arg(tr("To open the working folder in your system file manager,
click the “Local” folder path shown above.")) -#endif - ); + + m_noModificationsLabel = new QLabel; + setNoModificationsLabelText(); layout->addWidget(m_noModificationsLabel, row, 1, 1, 2); m_noModificationsLabel->hide(); @@ -97,8 +90,8 @@ m_descriptions[FileStates::Clean] = tr("You have not changed these files."); m_descriptions[FileStates::Modified] = tr("You have changed these files since you last committed them."); - m_descriptions[FileStates::Added] = tr("These files will be added to version control next time you commit."); - m_descriptions[FileStates::Removed] = tr("These files will be removed from version control next time you commit.
" + m_descriptions[FileStates::Added] = tr("These files will be added to version control next time you commit them."); + m_descriptions[FileStates::Removed] = tr("These files will be removed from version control next time you commit them.
" "They will not be deleted from the local folder."); m_descriptions[FileStates::Missing] = tr("These files are recorded in the version control, but absent from your working folder.
" "If you intended to delete them, select them and use Remove to tell the version control system about it.
" @@ -113,19 +106,29 @@ m_highlightExplanation = tr("Files highlighted in red " "have appeared since your most recent commit or update."); + m_boxesParent = new QWidget(this); + layout->addWidget(m_boxesParent, ++row, 0, 1, 3); + + QGridLayout *boxesLayout = new QGridLayout; + boxesLayout->setMargin(0); + m_boxesParent->setLayout(boxesLayout); + int boxRow = 0; + for (int i = int(FileStates::FirstState); i <= int(FileStates::LastState); ++i) { FileStates::State s = FileStates::State(i); - QWidget *box = new QWidget; + QWidget *box = new QWidget(m_boxesParent); QGridLayout *boxlayout = new QGridLayout; boxlayout->setMargin(0); box->setLayout(boxlayout); boxlayout->addItem(new QSpacerItem(3, 3), 0, 0); - boxlayout->addWidget(new QLabel(labelFor(s)), 1, 0); + QLabel *label = new QLabel(labelFor(s)); + label->setWordWrap(true); + boxlayout->addWidget(label, 1, 0); QListWidget *w = new QListWidget; m_stateListMap[s] = w; @@ -137,10 +140,13 @@ boxlayout->addItem(new QSpacerItem(2, 2), 3, 0); - layout->addWidget(box, ++row, 0, 1, 3); + boxesLayout->addWidget(box, ++boxRow, 0); + m_boxes.push_back(box); box->hide(); } + m_gridlyLayout = false; + layout->setRowStretch(++row, 20); layout->addItem(new QSpacerItem(8, 8), ++row, 0); @@ -184,15 +190,44 @@ QString FileStatusWidget::labelFor(FileStates::State s, bool addHighlightExplanation) { - if (addHighlightExplanation) { - return QString("%1
%2
%3
") - .arg(m_simpleLabels[s]) - .arg(m_descriptions[s]) - .arg(m_highlightExplanation); + QSettings settings; + settings.beginGroup("Presentation"); + if (settings.value("showhelpfultext", true).toBool()) { + if (addHighlightExplanation) { + return QString("%1
%2
%3
") + .arg(m_simpleLabels[s]) + .arg(m_descriptions[s]) + .arg(m_highlightExplanation); + } else { + return QString("%1
%2
") + .arg(m_simpleLabels[s]) + .arg(m_descriptions[s]); + } } else { - return QString("%1
%2
") - .arg(m_simpleLabels[s]) - .arg(m_descriptions[s]); + return QString("%1") + .arg(m_simpleLabels[s]); + } + settings.endGroup(); +} + +void FileStatusWidget::setNoModificationsLabelText() +{ + QSettings settings; + settings.beginGroup("Presentation"); + 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 + .arg(tr("To open the working folder in Finder,
click on the “Local” folder path shown above.")) +#elif defined Q_OS_WIN32 + .arg(tr("To open the working folder in Windows Explorer,
click on the “Local” folder path shown above.")) +#else + .arg(tr("To open the working folder in your system file manager,
click the “Local” folder path shown above.")) +#endif + ); + } else { + m_noModificationsLabel->setText + (tr("You have no uncommitted changes.")); } } @@ -430,7 +465,7 @@ QSet selectedFiles; foreach (QString f, m_selectedFiles) selectedFiles.insert(f); - bool haveAnything = false; + int visibleCount = 0; foreach (FileStates::State s, m_stateListMap.keys()) { @@ -483,13 +518,72 @@ w->parentWidget()->hide(); } else { w->parentWidget()->show(); - haveAnything = true; + ++visibleCount; } } - m_noModificationsLabel->setVisible(!haveAnything); + m_noModificationsLabel->setVisible(visibleCount == 0); + + if (visibleCount > 3) { + layoutBoxesGridly(visibleCount); + } else { + layoutBoxesLinearly(); + } updateStateLabel(); + setNoModificationsLabelText(); +} + +void FileStatusWidget::layoutBoxesGridly(int visibleCount) +{ + if (m_gridlyLayout && m_lastGridlyCount == visibleCount) return; + + delete m_boxesParent->layout(); + + QGridLayout *layout = new QGridLayout; + layout->setMargin(0); + m_boxesParent->setLayout(layout); + + int row = 0; + int col = 0; + + DEBUG << "FileStatusWidget::layoutBoxesGridly: visibleCount = " + << visibleCount << endl; + + for (int i = 0; i < m_boxes.size(); ++i) { + + if (!m_boxes[i]->isVisible()) continue; + + if (col == 0 && row >= (visibleCount+1)/2) { + layout->addItem(new QSpacerItem(10, 5), 0, 1); + col = 2; + row = 0; + } + + layout->addWidget(m_boxes[i], row, col); + + ++row; + } + + m_gridlyLayout = true; + m_lastGridlyCount = visibleCount; +} + +void FileStatusWidget::layoutBoxesLinearly() +{ + if (!m_gridlyLayout) return; + + delete m_boxesParent->layout(); + + QGridLayout *layout = new QGridLayout; + layout->setMargin(0); + m_boxesParent->setLayout(layout); + + for (int i = 0; i < m_boxes.size(); ++i) { + layout->addWidget(m_boxes[i], i, 0); + } + + m_gridlyLayout = false; } void FileStatusWidget::setLabelFor(QWidget *w, FileStates::State s, bool addHighlight) diff -r 1b2ee42fa004 -r 6c5a06da0ab9 filestatuswidget.h --- a/filestatuswidget.h Thu Jan 06 14:17:35 2011 +0000 +++ b/filestatuswidget.h Thu Jan 06 15:15:43 2011 +0000 @@ -21,6 +21,7 @@ #include "filestates.h" #include +#include class QLabel; class QListWidget; @@ -75,6 +76,7 @@ public slots: void clearSelections(); + void updateWidgets(); private slots: void itemSelectionChanged(); @@ -103,8 +105,15 @@ QFileInfo *m_dateReference; QStringList m_selectedFiles; - void updateWidgets(); + bool m_gridlyLayout; + int m_lastGridlyCount; + QList m_boxes; + QWidget *m_boxesParent; + + void layoutBoxesGridly(int count); + void layoutBoxesLinearly(); void updateStateLabel(); + void setNoModificationsLabelText(); QString labelFor(FileStates::State, bool addHighlightExplanation = false); void setLabelFor(QWidget *w, FileStates::State, bool addHighlightExplanation); }; diff -r 1b2ee42fa004 -r 6c5a06da0ab9 hgtabwidget.cpp --- a/hgtabwidget.cpp Thu Jan 06 14:17:35 2011 +0000 +++ b/hgtabwidget.cpp Thu Jan 06 15:15:43 2011 +0000 @@ -87,6 +87,11 @@ m_historyWidget->setCurrent(ids, branch, showUncommitted); } +void HgTabWidget::updateFileStates() +{ + m_fileStatusWidget->updateWidgets(); +} + void HgTabWidget::updateHistory() { m_historyWidget->update(); diff -r 1b2ee42fa004 -r 6c5a06da0ab9 hgtabwidget.h --- a/hgtabwidget.h Thu Jan 06 14:17:35 2011 +0000 +++ b/hgtabwidget.h Thu Jan 06 15:15:43 2011 +0000 @@ -50,6 +50,7 @@ void setCurrent(QStringList ids, QString branch); + void updateFileStates(); void updateHistory(); FileStates getFileStates() { return m_fileStates; } diff -r 1b2ee42fa004 -r 6c5a06da0ab9 mainwindow.cpp --- a/mainwindow.cpp Thu Jan 06 14:17:35 2011 +0000 +++ b/mainwindow.cpp Thu Jan 06 15:15:43 2011 +0000 @@ -41,6 +41,7 @@ #include "confirmcommentdialog.h" #include "incomingdialog.h" #include "settingsdialog.h" +#include "version.h" MainWindow::MainWindow(QString myDirPath) : @@ -154,7 +155,7 @@ void MainWindow::about() { QMessageBox::about(this, tr("About EasyMercurial"), - tr("

About EasyMercurial

" + tr("

EasyMercurial v%1

" #ifdef Q_OS_MAC "" #endif @@ -188,7 +189,7 @@ #ifdef Q_OS_MAC "" #endif - )); + ).arg(EASYHG_VERSION)); } void MainWindow::clearSelections() @@ -1311,6 +1312,11 @@ { SettingsDialog *settingsDlg = new SettingsDialog(this); settingsDlg->exec(); + + if (settingsDlg->presentationChanged()) { + hgTabs->updateFileStates(); + updateToolBarStyle(); + } } #define STDOUT_NEEDS_BIG_WINDOW 512 @@ -2030,6 +2036,7 @@ bool canUpdate = false; bool haveMerge = false; bool emptyRepo = false; + bool noWorkingCopy = false; int currentBranchHeads = 0; if (currentParents.size() == 1) { @@ -2056,7 +2063,16 @@ } } } else if (currentParents.size() == 0) { - emptyRepo = true; + if (currentHeads.size() == 0) { + // No heads -> empty repo + emptyRepo = true; + } else { + // Heads, but no parents -> no working copy, e.g. we have + // just converted this repo but haven't updated in it yet. + // Uncommon but confusing; probably merits a special case + noWorkingCopy = true; + canUpdate = true; + } } else { haveMerge = true; justMerged = true; @@ -2080,6 +2096,8 @@ hgTabs->setState(tr("(Examining repository)")); } else if (emptyRepo) { hgTabs->setState(tr("Nothing committed to this repository yet")); + } else if (noWorkingCopy) { + hgTabs->setState(tr("No working copy yet: consider updating")); } else if (canMerge) { hgTabs->setState(tr("Awaiting merge on %1").arg(branchText)); } else if (!hgTabs->getAllUnresolvedFiles().empty()) { @@ -2227,11 +2245,22 @@ workFolderToolBar->addAction(hgRemoveAct); workFolderToolBar -> setMovable(false); - foreach (QToolButton *tb, findChildren()) { - tb->setToolButtonStyle(Qt::ToolButtonTextUnderIcon); - } + updateToolBarStyle(); } +void MainWindow::updateToolBarStyle() +{ + QSettings settings; + settings.beginGroup("Presentation"); + bool showText = settings.value("showiconlabels", true).toBool(); + settings.endGroup(); + + foreach (QToolButton *tb, findChildren()) { + tb->setToolButtonStyle(showText ? + Qt::ToolButtonTextUnderIcon : + Qt::ToolButtonIconOnly); + } +} void MainWindow::createStatusBar() { diff -r 1b2ee42fa004 -r 6c5a06da0ab9 mainwindow.h --- a/mainwindow.h Thu Jan 06 14:17:35 2011 +0000 +++ b/mainwindow.h Thu Jan 06 15:15:43 2011 +0000 @@ -116,6 +116,7 @@ void connectTabsSignals(); void createMenus(); void createToolBars(); + void updateToolBarStyle(); void createStatusBar(); void readSettings(); void splitChangeSets(QStringList *list, QString hgLogOutput); diff -r 1b2ee42fa004 -r 6c5a06da0ab9 settingsdialog.cpp --- a/settingsdialog.cpp Thu Jan 06 14:17:35 2011 +0000 +++ b/settingsdialog.cpp Thu Jan 06 15:15:43 2011 +0000 @@ -27,7 +27,8 @@ #include SettingsDialog::SettingsDialog(QWidget *parent) : - QDialog(parent) + QDialog(parent), + m_presentationChanged(false) { setModal(true); setWindowTitle(tr("Settings")); @@ -37,6 +38,8 @@ QGridLayout *mainLayout = new QGridLayout; setLayout(mainLayout); + + QGroupBox *meBox = new QGroupBox(tr("User details")); mainLayout->addWidget(meBox, 0, 0); QGridLayout *meLayout = new QGridLayout; @@ -60,8 +63,31 @@ settings.endGroup(); + + + QGroupBox *lookBox = new QGroupBox(tr("Presentation")); + mainLayout->addWidget(lookBox, 1, 0); + QGridLayout *lookLayout = new QGridLayout; + lookBox->setLayout(lookLayout); + + settings.beginGroup("Presentation"); + + row = 0; + + m_showIconLabels = new QCheckBox(tr("Show labels on toolbar icons")); + m_showIconLabels->setChecked(settings.value("showiconlabels", true).toBool()); + lookLayout->addWidget(m_showIconLabels, row++, 0); + + m_showExtraText = new QCheckBox(tr("Show long descriptions for file status headings")); + m_showExtraText->setChecked(settings.value("showhelpfultext", true).toBool()); + lookLayout->addWidget(m_showExtraText, row++, 0); + + settings.endGroup(); + + + QGroupBox *pathsBox = new QGroupBox(tr("System application locations")); - mainLayout->addWidget(pathsBox, 1, 0); + mainLayout->addWidget(pathsBox, 2, 0); QGridLayout *pathsLayout = new QGridLayout; pathsBox->setLayout(pathsLayout); @@ -135,9 +161,10 @@ settings.endGroup(); + QDialogButtonBox *bbox = new QDialogButtonBox(QDialogButtonBox::Ok); connect(bbox, SIGNAL(accepted()), this, SLOT(accept())); - mainLayout->addWidget(bbox, 2, 0); + mainLayout->addWidget(bbox, 3, 0); m_ok = bbox->button(QDialogButtonBox::Ok); } @@ -199,6 +226,19 @@ settings.setValue("name", m_nameEdit->text()); settings.setValue("email", m_emailEdit->text()); settings.endGroup(); + settings.beginGroup("Presentation"); + bool b; + b = m_showIconLabels->isChecked(); + if (b != settings.value("showiconlabels", true)) { + settings.setValue("showiconlabels", b); + m_presentationChanged = true; + } + b = m_showExtraText->isChecked(); + if (b != settings.value("showhelpfultext", true)) { + settings.setValue("showhelpfultext", b); + m_presentationChanged = true; + } + settings.endGroup(); settings.beginGroup("Locations"); settings.setValue("hgbinary", m_hgPathLabel->text()); settings.setValue("extdiffbinary", m_diffPathLabel->text()); diff -r 1b2ee42fa004 -r 6c5a06da0ab9 settingsdialog.h --- a/settingsdialog.h Thu Jan 06 14:17:35 2011 +0000 +++ b/settingsdialog.h Thu Jan 06 15:15:43 2011 +0000 @@ -30,6 +30,10 @@ public: SettingsDialog(QWidget *parent = 0); + + bool presentationChanged() { + return m_presentationChanged; + } private slots: void hgPathBrowse(); @@ -51,8 +55,13 @@ QCheckBox *m_useExtension; QLineEdit *m_extensionPathLabel; + QCheckBox *m_showIconLabels; + QCheckBox *m_showExtraText; + QPushButton *m_ok; + bool m_presentationChanged; + void browseFor(QString, QLineEdit *); }; diff -r 1b2ee42fa004 -r 6c5a06da0ab9 version.h --- a/version.h Thu Jan 06 14:17:35 2011 +0000 +++ b/version.h Thu Jan 06 15:15:43 2011 +0000 @@ -1,1 +1,1 @@ -#define EASYHG_VERSION "0.8" +#define EASYHG_VERSION "0.1"