comparison src/mainwindow.cpp @ 498:21aa41b62c3a

Add back/forward/home to Help window, and some Help edits
author Chris Cannam
date Mon, 22 Aug 2011 18:46:06 +0100
parents 41a156d439d0
children 1c05e7576ea5
comparison
equal deleted inserted replaced
497:a9032181c37d 498:21aa41b62c3a
54 #include "versiontester.h" 54 #include "versiontester.h"
55 55
56 56
57 MainWindow::MainWindow(QString myDirPath) : 57 MainWindow::MainWindow(QString myDirPath) :
58 m_myDirPath(myDirPath), 58 m_myDirPath(myDirPath),
59 m_helpDialog(0),
59 m_fsWatcherGeneralTimer(0), 60 m_fsWatcherGeneralTimer(0),
60 m_fsWatcherRestoreTimer(0), 61 m_fsWatcherRestoreTimer(0),
61 m_fsWatcherSuspended(false), 62 m_fsWatcherSuspended(false)
62 m_helpDialog(0)
63 { 63 {
64 setWindowIcon(QIcon(":images/easyhg-icon.png")); 64 setWindowIcon(QIcon(":images/easyhg-icon.png"));
65 65
66 QString wndTitle; 66 QString wndTitle;
67 67
2656 //!!! should also do things like set the status texts for the 2656 //!!! should also do things like set the status texts for the
2657 //!!! actions appropriately by context 2657 //!!! actions appropriately by context
2658 2658
2659 QDir localRepoDir; 2659 QDir localRepoDir;
2660 QDir workFolderDir; 2660 QDir workFolderDir;
2661 bool workFolderExist = true;
2662 bool localRepoExist = true;
2663 2661
2664 m_remoteRepoActionsEnabled = true; 2662 m_remoteRepoActionsEnabled = true;
2665 if (m_remoteRepoPath.isEmpty()) { 2663 if (m_remoteRepoPath.isEmpty()) {
2666 m_remoteRepoActionsEnabled = false; 2664 m_remoteRepoActionsEnabled = false;
2667 } 2665 }
2668 2666
2669 m_localRepoActionsEnabled = true; 2667 m_localRepoActionsEnabled = true;
2670 if (m_workFolderPath.isEmpty()) { 2668 if (m_workFolderPath.isEmpty()) {
2671 m_localRepoActionsEnabled = false; 2669 m_localRepoActionsEnabled = false;
2672 workFolderExist = false;
2673 } 2670 }
2674 2671
2675 if (m_workFolderPath == "" || !workFolderDir.exists(m_workFolderPath)) { 2672 if (m_workFolderPath == "" || !workFolderDir.exists(m_workFolderPath)) {
2676 m_localRepoActionsEnabled = false; 2673 m_localRepoActionsEnabled = false;
2677 workFolderExist = false;
2678 } else {
2679 workFolderExist = true;
2680 } 2674 }
2681 2675
2682 if (!localRepoDir.exists(m_workFolderPath + "/.hg")) { 2676 if (!localRepoDir.exists(m_workFolderPath + "/.hg")) {
2683 m_localRepoActionsEnabled = false; 2677 m_localRepoActionsEnabled = false;
2684 localRepoExist = false;
2685 } 2678 }
2686 2679
2687 bool haveDiff = false; 2680 bool haveDiff = false;
2688 QSettings settings; 2681 QSettings settings;
2689 settings.beginGroup("Locations"); 2682 settings.beginGroup("Locations");
3096 { 3089 {
3097 if (!m_helpDialog) { 3090 if (!m_helpDialog) {
3098 m_helpDialog = new QDialog; 3091 m_helpDialog = new QDialog;
3099 QGridLayout *layout = new QGridLayout; 3092 QGridLayout *layout = new QGridLayout;
3100 m_helpDialog->setLayout(layout); 3093 m_helpDialog->setLayout(layout);
3094 QPushButton *home = new QPushButton;
3095 home->setIcon(QIcon(":images/home.png"));
3096 layout->addWidget(home, 0, 0);
3097 QPushButton *back = new QPushButton;
3098 back->setIcon(QIcon(":images/back.png"));
3099 layout->addWidget(back, 0, 1);
3100 QPushButton *fwd = new QPushButton;
3101 fwd->setIcon(QIcon(":images/forward.png"));
3102 layout->addWidget(fwd, 0, 2);
3101 QTextBrowser *text = new QTextBrowser; 3103 QTextBrowser *text = new QTextBrowser;
3102 text->setOpenExternalLinks(true); 3104 text->setOpenExternalLinks(true);
3103 layout->addWidget(text, 0, 0); 3105 layout->addWidget(text, 1, 0, 1, 4);
3104 text->setSource(QUrl("qrc:help/topics.html")); 3106 text->setSource(QUrl("qrc:help/topics.html"));
3105 QDialogButtonBox *bb = new QDialogButtonBox(QDialogButtonBox::Close); 3107 QDialogButtonBox *bb = new QDialogButtonBox(QDialogButtonBox::Close);
3106 connect(bb, SIGNAL(rejected()), m_helpDialog, SLOT(hide())); 3108 connect(bb, SIGNAL(rejected()), m_helpDialog, SLOT(hide()));
3107 layout->addWidget(bb, 1, 0); 3109 connect(text, SIGNAL(backwardAvailable(bool)),
3110 back, SLOT(setEnabled(bool)));
3111 connect(text, SIGNAL(forwardAvailable(bool)),
3112 fwd, SLOT(setEnabled(bool)));
3113 connect(home, SIGNAL(clicked()), text, SLOT(home()));
3114 connect(back, SIGNAL(clicked()), text, SLOT(backward()));
3115 connect(fwd, SIGNAL(clicked()), text, SLOT(forward()));
3116 back->setEnabled(false);
3117 fwd->setEnabled(false);
3118 layout->addWidget(bb, 2, 0, 1, 4);
3119 layout->setColumnStretch(3, 20);
3108 m_helpDialog->resize(450, 500); 3120 m_helpDialog->resize(450, 500);
3109 } 3121 }
3110 QTextBrowser *tb = m_helpDialog->findChild<QTextBrowser *>(); 3122 QTextBrowser *tb = m_helpDialog->findChild<QTextBrowser *>();
3111 if (tb) tb->home(); 3123 if (tb) tb->home();
3112 m_helpDialog->show(); 3124 m_helpDialog->show();