comparison src/mainwindow.cpp @ 494:41a156d439d0

Start adding Help
author Chris Cannam
date Thu, 18 Aug 2011 16:37:27 +0100
parents 1d90cd7a1c5f
children 21aa41b62c3a
comparison
equal deleted inserted replaced
493:75ebcacd3f75 494:41a156d439d0
33 #include <QRegExp> 33 #include <QRegExp>
34 #include <QShortcut> 34 #include <QShortcut>
35 #include <QUrl> 35 #include <QUrl>
36 #include <QDialogButtonBox> 36 #include <QDialogButtonBox>
37 #include <QTimer> 37 #include <QTimer>
38 #include <QTextBrowser>
38 39
39 #include "mainwindow.h" 40 #include "mainwindow.h"
40 #include "multichoicedialog.h" 41 #include "multichoicedialog.h"
41 #include "startupdialog.h" 42 #include "startupdialog.h"
42 #include "colourset.h" 43 #include "colourset.h"
55 56
56 MainWindow::MainWindow(QString myDirPath) : 57 MainWindow::MainWindow(QString myDirPath) :
57 m_myDirPath(myDirPath), 58 m_myDirPath(myDirPath),
58 m_fsWatcherGeneralTimer(0), 59 m_fsWatcherGeneralTimer(0),
59 m_fsWatcherRestoreTimer(0), 60 m_fsWatcherRestoreTimer(0),
60 m_fsWatcherSuspended(false) 61 m_fsWatcherSuspended(false),
62 m_helpDialog(0)
61 { 63 {
62 setWindowIcon(QIcon(":images/easyhg-icon.png")); 64 setWindowIcon(QIcon(":images/easyhg-icon.png"));
63 65
64 QString wndTitle; 66 QString wndTitle;
65 67
2532 2534
2533 void MainWindow::connectActions() 2535 void MainWindow::connectActions()
2534 { 2536 {
2535 connect(m_exitAct, SIGNAL(triggered()), this, SLOT(close())); 2537 connect(m_exitAct, SIGNAL(triggered()), this, SLOT(close()));
2536 connect(m_aboutAct, SIGNAL(triggered()), this, SLOT(about())); 2538 connect(m_aboutAct, SIGNAL(triggered()), this, SLOT(about()));
2539 connect(m_helpAct, SIGNAL(triggered()), this, SLOT(help()));
2537 2540
2538 connect(m_hgRefreshAct, SIGNAL(triggered()), this, SLOT(hgRefresh())); 2541 connect(m_hgRefreshAct, SIGNAL(triggered()), this, SLOT(hgRefresh()));
2539 connect(m_hgRemoveAct, SIGNAL(triggered()), this, SLOT(hgRemove())); 2542 connect(m_hgRemoveAct, SIGNAL(triggered()), this, SLOT(hgRemove()));
2540 connect(m_hgAddAct, SIGNAL(triggered()), this, SLOT(hgAdd())); 2543 connect(m_hgAddAct, SIGNAL(triggered()), this, SLOT(hgAdd()));
2541 connect(m_hgCommitAct, SIGNAL(triggered()), this, SLOT(hgCommit())); 2544 connect(m_hgCommitAct, SIGNAL(triggered()), this, SLOT(hgCommit()));
2923 2926
2924 m_hgServeAct = new QAction(tr("Share Repository"), this); 2927 m_hgServeAct = new QAction(tr("Share Repository"), this);
2925 m_hgServeAct->setStatusTip(tr("Serve local repository temporarily via HTTP for workgroup access")); 2928 m_hgServeAct->setStatusTip(tr("Serve local repository temporarily via HTTP for workgroup access"));
2926 2929
2927 //Help actions 2930 //Help actions
2931 #ifdef Q_OS_MAC
2932 m_helpAct = new QAction(tr("EasyMercurial Help"), this);
2933 #else
2934 m_helpAct = new QAction(tr("Help Topics"), this);
2935 #endif
2936 m_helpAct->setShortcuts(QKeySequence::HelpContents);
2928 m_aboutAct = new QAction(tr("About EasyMercurial"), this); 2937 m_aboutAct = new QAction(tr("About EasyMercurial"), this);
2929 2938
2930 // Miscellaneous 2939 // Miscellaneous
2931 QShortcut *clearSelectionsShortcut = new QShortcut(Qt::Key_Escape, this); 2940 QShortcut *clearSelectionsShortcut = new QShortcut(Qt::Key_Escape, this);
2932 connect(clearSelectionsShortcut, SIGNAL(activated()), 2941 connect(clearSelectionsShortcut, SIGNAL(activated()),
2971 remoteMenu->addSeparator(); 2980 remoteMenu->addSeparator();
2972 remoteMenu->addAction(m_hgPullAct); 2981 remoteMenu->addAction(m_hgPullAct);
2973 remoteMenu->addAction(m_hgPushAct); 2982 remoteMenu->addAction(m_hgPushAct);
2974 2983
2975 m_helpMenu = menuBar()->addMenu(tr("&Help")); 2984 m_helpMenu = menuBar()->addMenu(tr("&Help"));
2985 m_helpMenu->addAction(m_helpAct);
2976 m_helpMenu->addAction(m_aboutAct); 2986 m_helpMenu->addAction(m_aboutAct);
2977 } 2987 }
2978 2988
2979 void MainWindow::createToolBars() 2989 void MainWindow::createToolBars()
2980 { 2990 {
3080 settings.setValue(tag, false); 3090 settings.setValue(tag, false);
3081 } 3091 }
3082 settings.endGroup(); 3092 settings.endGroup();
3083 } 3093 }
3084 3094
3095 void MainWindow::help()
3096 {
3097 if (!m_helpDialog) {
3098 m_helpDialog = new QDialog;
3099 QGridLayout *layout = new QGridLayout;
3100 m_helpDialog->setLayout(layout);
3101 QTextBrowser *text = new QTextBrowser;
3102 text->setOpenExternalLinks(true);
3103 layout->addWidget(text, 0, 0);
3104 text->setSource(QUrl("qrc:help/topics.html"));
3105 QDialogButtonBox *bb = new QDialogButtonBox(QDialogButtonBox::Close);
3106 connect(bb, SIGNAL(rejected()), m_helpDialog, SLOT(hide()));
3107 layout->addWidget(bb, 1, 0);
3108 m_helpDialog->resize(450, 500);
3109 }
3110 QTextBrowser *tb = m_helpDialog->findChild<QTextBrowser *>();
3111 if (tb) tb->home();
3112 m_helpDialog->show();
3113 m_helpDialog->raise();
3114 }
3115