Mercurial > hg > easyhg
changeset 32:4f307720272f
Version 0.5.0: Added "Copy comment" context menu to "parents" list.
author | Jari Korhonen <jtkorhonen@gmail.com> |
---|---|
date | Tue, 15 Jun 2010 03:16:40 +0300 |
parents | 552a49635124 |
children | ff8d64625aa3 |
files | common.h hgexpwidget.cpp hgexpwidget.h mainwindow.cpp |
diffstat | 4 files changed, 77 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/common.h Mon Jun 14 22:04:52 2010 +0300 +++ b/common.h Tue Jun 15 03:16:40 2010 +0300 @@ -8,7 +8,7 @@ #include <QtCore> #define APPNAME "HgExplorer" -#define APPVERSION "0.4.7" +#define APPVERSION "0.5.0" #define MY_ICON_SIZE 32 #define REPOMENU_TITLE "Repository actions" #define WORKFOLDERMENU_TITLE "Workfolder actions"
--- a/hgexpwidget.cpp Mon Jun 14 22:04:52 2010 +0300 +++ b/hgexpwidget.cpp Tue Jun 15 03:16:40 2010 +0300 @@ -3,6 +3,8 @@ ****************************************************************************/ #include <QtGui> +#include <QtCore> +#include <QClipboard> #include "hgexpwidget.h" #include "common.h" @@ -42,6 +44,10 @@ parentsLayout -> addWidget(parentsLabel); parentsLayout -> addWidget(localRepoHgParentsList); grpLocalRepo -> setLayout(parentsLayout); + copyCommentAct = new QAction("Copy comment", localRepoHgParentsList); + userListMenu = new QMenu(localRepoHgParentsList); + userListMenu -> addAction(copyCommentAct); + connect(copyCommentAct, SIGNAL(triggered()), this, SLOT(copyComment())); //Workfolder grpWorkFolder = new QGroupBox(tr(WORKFOLDER_STR) + workFolderPath); @@ -106,6 +112,49 @@ setTabEnabled(HISTORYTAB, false); } +void HgExpWidget::contextMenuEvent(QContextMenuEvent * event) +{ + if (copyCommentAct -> isEnabled()) + { + QPoint topL; + QPoint bottomR; + + topL = localRepoHgParentsList-> + mapToGlobal(QPoint(0, 0)); + bottomR = localRepoHgParentsList-> + mapToGlobal(QPoint(localRepoHgParentsList -> width(), localRepoHgParentsList -> height())); + + if ((event -> globalPos().x() > topL.x()) && (event -> globalPos().x() < bottomR.x())) + { + if ((event -> globalPos().y() > topL.y()) && (event -> globalPos().y() < bottomR.y())) + { + userListMenu->exec(event -> globalPos()); + } + } + } +} + +void HgExpWidget::copyComment() +{ + if (localRepoHgParentsList -> count() >= 1) + { + QListWidgetItem *it = localRepoHgParentsList -> item(0); + QString tmp = it -> text(); + int ind = tmp.indexOf("summary:"); + if (ind != -1) + { + QString comment; + ind += 11; //jump over word "summary:" + + comment = tmp.mid(ind); + + QClipboard *clipboard = QApplication::clipboard(); + clipboard->setText(comment); + } + } +} + + QString HgExpWidget::getStatFlags() { @@ -353,9 +402,23 @@ } +void HgExpWidget::enableDisableOtherTabs(int tabPage) +{ + static int oldTabPage = -1; -void HgExpWidget::enableDisableOtherTabs() -{ + if (tabPage != oldTabPage) + { + oldTabPage = tabPage; + if (tabPage == WORKTAB) + { + copyCommentAct -> setEnabled(true); + } + else + { + copyCommentAct -> setEnabled(false); + } + } + //history list is only interesting when we have something in it ;-) if (localRepoHgLogList -> count() < 2) {
--- a/hgexpwidget.h Mon Jun 14 22:04:52 2010 +0300 +++ b/hgexpwidget.h Tue Jun 15 03:16:40 2010 +0300 @@ -7,6 +7,8 @@ #include <QtGui> #include <QtCore> +#include <QMenu> + #include "common.h" #define NUM_STAT_FILE_TYPES 7 @@ -28,7 +30,7 @@ void getHistoryDiffRevisions(QString& revA, QString& revB); void getUpdateToRevRevision(QString& rev); void clearLists(); - void enableDisableOtherTabs(); + void enableDisableOtherTabs(int tabPage); QString getStatFlags(void); unsigned char getFileTypesBits(); @@ -40,6 +42,9 @@ signals: void workFolderViewTypesChanged(); +private slots: + void copyComment(); + private: QGroupBox *grpRemoteRepo; QWidget *workPageWidget; @@ -52,6 +57,8 @@ QVBoxLayout *parentsLayout; QListWidget *localRepoHgParentsList; QLabel *parentsLabel; + QMenu *userListMenu; + QAction *copyCommentAct; QGroupBox *grpWorkFolder; QHBoxLayout *workFolderLayout; @@ -66,6 +73,7 @@ QString findRev(QString itemText, QString& smallRev); QStringList splitChangeSets(QString chgSetsStr); int findLineStart(int nowIndex, QString chgSetsStr); + void contextMenuEvent (QContextMenuEvent * event); }; #endif // HGEXPWIDGET_H
--- a/mainwindow.cpp Mon Jun 14 22:04:52 2010 +0300 +++ b/mainwindow.cpp Tue Jun 15 03:16:40 2010 +0300 @@ -963,6 +963,7 @@ void MainWindow::tabChanged(int currTab) { tabPage = currTab; + } void MainWindow::enableDisableActions() @@ -1026,7 +1027,7 @@ hgAnnotateAct -> setEnabled(localRepoActionsEnabled); hgServeAct -> setEnabled(localRepoActionsEnabled); - hgExp -> enableDisableOtherTabs(); + hgExp -> enableDisableOtherTabs(tabPage); int added, modified, removed, notTracked, selected, selectedAdded, selectedModified, selectedRemoved, selectedNotTracked;