changeset 0:a9098eba2ee5

Initial commit.
author Jari Korhonen <jtkorhonen@gmail.com>
date Thu, 22 Apr 2010 03:15:35 +0300
parents
children e275d0b5d6ca c19a4f858aab
files .hgignore common.cpp common.h hgexplorer.ico hgexplorer.pro hgexplorer.qrc hgexplorer.rc hgexpwidget.cpp hgexpwidget.h hgrunner.cpp hgrunner.h images/add.png images/chgsetdiff.png images/commit.png images/diff.png images/exit.png images/folderdiff.png images/incoming.png images/merge.png images/pull.png images/push.png images/remove.png images/settings.png images/status.png images/undo.png images/update.png main.cpp mainwindow.cpp mainwindow.h object_script.hgexplorer.Release settingsdialog.cpp settingsdialog.h
diffstat 32 files changed, 2412 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.hgignore	Thu Apr 22 03:15:35 2010 +0300
@@ -0,0 +1,24 @@
+syntax: glob
+*.core
+*.o
+*~
+*.exe
+*.dll
+moc_*.cpp
+qrc_hgexplorer.cpp
+core
+hgexplorer
+debug/hgexplorer.exe
+Makefile
+Makefile.Debug
+Makefile.Release
+hgexplorer.pro.user
+object_script.hgexplorer.Debug
+object_script.hgexplorer.exe.Release
+object_script.hgexplorer.exe.Debug
+
+
+
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common.cpp	Thu Apr 22 03:15:35 2010 +0300
@@ -0,0 +1,56 @@
+//** Copyright (C) Jari Korhonen, 2010 (under lgpl)
+
+
+#include "common.h"
+
+QString getSystem()
+{
+    #ifdef Q_WS_X11
+    return QString("Linux");
+    #endif
+
+    #ifdef Q_WS_MAC
+    return QString("Mac");
+    #endif
+
+    #ifdef Q_WS_WIN
+    return QString("Windows");
+    #endif
+
+    return QString("");
+}
+
+QString getHgBinaryName()
+{
+    if (getSystem() == "Windows")
+        return QString("hg.exe");
+    else
+        return QString("hg");
+}
+
+QString getDiffMergeDefaultPath()
+{
+    if (getSystem() == "Windows")
+        return QString("c:\\program files\\sourcegear\\diffmerge\\diffmerge.exe");
+    else
+        return QString("/usr/bin/diffmerge");
+}
+
+
+QString getHgDirName()
+{
+    if (getSystem() == "Windows")
+    {
+        return QString(".hg\\");
+    }
+    else
+    {
+        return QString(".hg/");
+    }
+}
+
+
+
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common.h	Thu Apr 22 03:15:35 2010 +0300
@@ -0,0 +1,40 @@
+#ifndef COMMON_H
+#define COMMON_H
+
+//** Copyright (C) Jari Korhonen, 2010 (under lgpl)
+
+#include <QtCore>
+
+#define APPNAME                         "HgExplorer"
+#define APPVERSION                      "0.3.6"
+#define MY_ICON_SIZE                    32
+#define REPOMENU_TITLE                  "Repository actions"
+#define WORKFOLDERMENU_TITLE            "Workfolder actions"
+#define EXITOK(x)                       ((x)==0)
+#define CHGSET                          "changeset: "
+#define REQUIRED_CHGSET_DIFF_COUNT      2
+
+#define WORKTAB                         0
+#define HISTORYTAB                      1
+#define HEADSTAB                        2
+
+#define HGSTAT_M_BIT    1U
+#define HGSTAT_A_BIT    2U
+#define HGSTAT_R_BIT    4U
+#define HGSTAT_D_BIT    8U
+#define HGSTAT_U_BIT    16U
+#define HGSTAT_C_BIT    32U
+#define HGSTAT_I_BIT    64U
+
+#define DEFAULT_HG_STAT_BITS (HGSTAT_M_BIT | HGSTAT_A_BIT | HGSTAT_R_BIT | HGSTAT_D_BIT | HGSTAT_U_BIT)
+
+
+
+extern QString getSystem();
+extern QString getHgBinaryName();
+extern QString getDiffMergeDefaultPath();
+extern QString getHgDirName();
+
+#endif 	//COMMON_H
+
+
Binary file hgexplorer.ico has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hgexplorer.pro	Thu Apr 22 03:15:35 2010 +0300
@@ -0,0 +1,23 @@
+TEMPLATE = app
+TARGET = hgexplorer
+unix {
+    DESTDIR = .
+}
+
+HEADERS = mainwindow.h \
+    hgexpwidget.h \
+    common.h \
+    hgrunner.h \
+    settingsdialog.h
+SOURCES = main.cpp \
+    mainwindow.cpp \
+    hgexpwidget.cpp \
+    hgrunner.cpp \
+    settingsdialog.cpp \
+    common.cpp
+
+# ! [0]
+RESOURCES = hgexplorer.qrc
+win32 {
+    RC_FILE = hgexplorer.rc
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hgexplorer.qrc	Thu Apr 22 03:15:35 2010 +0300
@@ -0,0 +1,19 @@
+<RCC>
+    <qresource prefix="/">
+        <file>images/add.png</file>
+        <file>images/commit.png</file>
+        <file>images/diff.png</file>
+        <file>images/folderdiff.png</file>
+        <file>images/exit.png</file>
+        <file>images/merge.png</file>
+        <file>images/pull.png</file>
+        <file>images/push.png</file>
+        <file>images/remove.png</file>
+        <file>images/settings.png</file>
+        <file>images/status.png</file>
+        <file>images/undo.png</file>
+        <file>images/update.png</file>
+        <file>images/incoming.png</file>
+        <file>images/chgsetdiff.png</file>
+    </qresource>
+</RCC>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hgexplorer.rc	Thu Apr 22 03:15:35 2010 +0300
@@ -0,0 +1,1 @@
+IDI_ICON1 ICON DISCARDABLE "hgexplorer.ico"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hgexpwidget.cpp	Thu Apr 22 03:15:35 2010 +0300
@@ -0,0 +1,380 @@
+//** Copyright (C) Jari Korhonen, 2010 (under lgpl)
+
+#include <QtGui>
+
+#include "hgexpwidget.h"
+#include "common.h"
+
+#define REMOTE_REPO_STR  "Remote repository: "
+#define LOCAL_REPO_STR   "Local repository: "
+#define WORKFOLDER_STR   "Working folder: "
+
+
+const char hgStatViewOptions[NUM_STAT_FILE_TYPES] = {'m','a','r','d','u','c','i'};
+
+const char *statFilesStr[NUM_STAT_FILE_TYPES] =  {  "M: Modified",
+                                                    "A: To be added on next commit",
+                                                    "R: To be removed on next commit",
+                                                    "!: Tracked, locally deleted",
+                                                    "?: Unknown, not yet tracked",
+                                                    "C: Clean (not changed)",
+                                                    "I: Ignored (via .hgignore file)"};
+
+
+HgExpWidget::HgExpWidget(QWidget *parent, QString remoteRepo, QString workFolderPath, unsigned char viewFileTypesBits): QTabWidget(parent)
+{
+    //Work page
+    //Work page
+    //Work page
+
+    //Remote repo
+    grpRemoteRepo = new QGroupBox(tr(REMOTE_REPO_STR) + remoteRepo);
+    grpRemoteRepo -> setMinimumHeight(24);
+
+    //Local Repo
+    grpLocalRepo = new QGroupBox(tr(LOCAL_REPO_STR) + workFolderPath + getHgDirName());
+    parentsLabel = new QLabel(tr("Working folder parent(s):"));
+    localRepoHgParentsList = new QListWidget;
+    localRepoHgParentsList -> setSelectionMode(QAbstractItemView::NoSelection);
+    parentsLayout = new QVBoxLayout;
+    parentsLayout -> addWidget(parentsLabel);
+    parentsLayout -> addWidget(localRepoHgParentsList);
+    grpLocalRepo -> setLayout(parentsLayout);
+
+    //Workfolder
+    grpWorkFolder = new QGroupBox(tr(WORKFOLDER_STR) + workFolderPath);
+    workFolderLayout = new QHBoxLayout;
+    workFolderFileList = new QListWidget;
+    workFolderFileList -> setSelectionMode(QAbstractItemView::SingleSelection);
+    grpViewFileTypes = new QGroupBox;
+    fileTypesLayout = new QVBoxLayout;
+
+    for(int i = 0; i < NUM_STAT_FILE_TYPES; i++)
+    {
+        chkViewFileTypes[i] = new QCheckBox(statFilesStr[i]);
+        if ((1U << i) & viewFileTypesBits)
+        {
+            chkViewFileTypes[i]->setChecked(true);
+        }
+        else
+        {
+            chkViewFileTypes[i]->setChecked(false);
+        }
+        connect(chkViewFileTypes[i], SIGNAL(stateChanged(int)), this, SIGNAL(workFolderViewTypesChanged()));
+        fileTypesLayout -> addWidget(chkViewFileTypes[i]);
+    }
+
+    grpViewFileTypes -> setLayout(fileTypesLayout);
+    workFolderLayout->addWidget(workFolderFileList, 3);
+    workFolderLayout->addWidget(grpViewFileTypes, 1);
+    grpWorkFolder -> setLayout(workFolderLayout);
+
+    workPageWidget = new QWidget;
+    mainLayout = new QVBoxLayout(workPageWidget);
+    mainLayout -> addWidget(grpRemoteRepo, 1);
+    mainLayout -> addWidget(grpLocalRepo, 8);
+    mainLayout -> addWidget(grpWorkFolder, 12);
+    addTab(workPageWidget, tr("Work"));
+
+    //History page
+    //History page
+    //History page
+    historyPageWidget = new QWidget;
+    localRepoHgLogList = new QListWidget;
+    localRepoHgLogList->setFont(QFont("Courier New"));
+    localRepoHgLogList -> setSelectionMode(QAbstractItemView::ExtendedSelection);
+
+    historyLayout = new QVBoxLayout(historyPageWidget);
+    historyLayout->addWidget(localRepoHgLogList);
+    addTab(historyPageWidget, tr("History (log)"));
+
+    //Heads page
+    //Heads page
+    //Heads page
+    headsPageWidget = new QWidget;
+    localRepoHeadsList = new QListWidget;
+    localRepoHeadsList -> setSelectionMode(QAbstractItemView::ExtendedSelection);
+
+    headsLayout = new QVBoxLayout(headsPageWidget);
+    headsLayout->addWidget(localRepoHeadsList);
+    addTab(headsPageWidget, tr("Heads"));
+
+    //Initially, only work page is active
+    setTabEnabled(HEADSTAB, false);
+    setTabEnabled(HISTORYTAB, false);
+}
+
+
+QString HgExpWidget::getStatFlags()
+{
+    QString ret;
+
+    for(int i = 0; i < NUM_STAT_FILE_TYPES; i++)
+    {
+        if (Qt::Checked == chkViewFileTypes[i]->checkState())
+        {
+            ret += hgStatViewOptions[i];
+        }
+    }
+
+    return ret;
+}
+
+
+unsigned char HgExpWidget::getFileTypesBits()
+{
+    unsigned char ret;
+
+    ret = 0;
+
+    for(int i = 0; i < NUM_STAT_FILE_TYPES; i++)
+    {
+        if (Qt::Checked == chkViewFileTypes[i]->checkState())
+        {
+            ret |= (1U << i);
+        }
+    }
+
+    return ret;
+}
+
+
+void HgExpWidget::updateWorkFolderFileList(QString fileList)
+{
+    workFolderFileList-> clear();
+    workFolderFileList -> addItems(fileList.split("\n"));
+}
+
+void HgExpWidget::updateLocalRepoHeadsList(QString headList)
+{
+    localRepoHeadsList-> clear();
+    localRepoHeadsList -> addItems(splitChangeSets(headList));
+
+    //heads list is interesting only when we have 2 or more
+    if (localRepoHeadsList-> count() < 2)
+    {
+        setTabEnabled(HEADSTAB, false);
+    }
+    else
+    {
+        setTabEnabled(HEADSTAB, true);
+    }
+}
+
+
+void HgExpWidget::clearLists()
+{
+    localRepoHeadsList-> clear();
+    localRepoHgParentsList-> clear();
+    workFolderFileList-> clear();
+    localRepoHgLogList -> clear();
+}
+
+void HgExpWidget::updateLocalRepoParentsList(QString parentsList)
+{
+    localRepoHgParentsList-> clear();
+    localRepoHgParentsList -> addItems(splitChangeSets(parentsList));
+}
+
+void HgExpWidget::updateLocalRepoHgLogList(QString hgLogList)
+{
+    localRepoHgLogList -> clear();
+    localRepoHgLogList -> addItems(splitChangeSets(hgLogList));
+
+}
+
+
+int HgExpWidget::findLineStart(int nowIndex, QString str)
+{
+    if (nowIndex < 0)
+    {
+        return -1;
+    }
+
+    while(str.at(nowIndex) != '\n')
+    {
+        if (nowIndex == 0)
+        {
+            return nowIndex;
+        }
+        nowIndex--;
+    }
+    return nowIndex + 1;
+}
+
+
+QStringList HgExpWidget::splitChangeSets(QString chgSetsStr)
+{
+    int currChgSet;
+    int currChgSetLineStart;
+
+    int prevChgSet;
+    QStringList tmp;
+
+    currChgSet = chgSetsStr.indexOf(CHGSET);
+    currChgSetLineStart = findLineStart(currChgSet, chgSetsStr);
+    prevChgSet = -1;
+    while (currChgSet != -1)
+    {
+        if (prevChgSet != -1)
+        {
+            tmp.append(chgSetsStr.mid(prevChgSet, (currChgSetLineStart - prevChgSet - 1)));
+        }
+
+        prevChgSet = currChgSetLineStart;
+
+        currChgSet = chgSetsStr.indexOf(CHGSET, currChgSet + 1);
+        currChgSetLineStart = findLineStart(currChgSet, chgSetsStr);
+    }
+
+    if (prevChgSet != -1)
+    {
+        //Last changeset
+        tmp.append(chgSetsStr.mid(prevChgSet));
+    }
+    else
+    {
+        //Only changeset (if any)
+        if (!chgSetsStr.isEmpty())
+        {
+            tmp.append(chgSetsStr.mid(0));
+        }
+    }
+
+    return tmp;
+}
+
+QString HgExpWidget::getCurrentFileListLine()
+{
+    if (workFolderFileList -> currentItem() != NULL)
+    {
+        return workFolderFileList -> currentItem()->text();
+    }
+    return "";
+}
+
+void HgExpWidget::setWorkFolderAndRepoNames(QString workFolderPath, QString remoteRepoPath)
+{
+    grpRemoteRepo -> setTitle(tr(REMOTE_REPO_STR) + remoteRepoPath);
+    grpLocalRepo -> setTitle(tr(LOCAL_REPO_STR) + workFolderPath + getHgDirName());
+    grpWorkFolder -> setTitle(tr(WORKFOLDER_STR) + workFolderPath);
+}
+
+#define MERC_SHA1_MARKER_LEN 12
+QString HgExpWidget::findRev(QString itemText, QString & smallRev)
+{
+    QString tmp(itemText);
+    int i;
+    int j;
+
+    smallRev ="0";
+
+    i = tmp.indexOf(CHGSET);
+    if (i != -1)
+    {
+        j = i + 10;
+        i = tmp.indexOf(":", j);  //xx:yyyyyy after changeset:
+
+        if (i != -1)
+        {
+            smallRev = tmp.mid(j, (i-j));
+            return tmp.mid(i+1, MERC_SHA1_MARKER_LEN);
+        }
+    }
+
+    return "";
+}
+
+void HgExpWidget::getHistoryDiffRevisions(QString& revA, QString& revB)
+{
+    QList <QListWidgetItem *> histList = localRepoHgLogList->selectedItems();
+    QList <QListWidgetItem *> headList = localRepoHeadsList->selectedItems();
+
+    QString revATmp;
+    QString revBTmp;
+    QString smallRevA;
+    QString smallRevB;
+    QString txtA;
+    QString txtB;
+
+    if (histList.count() == REQUIRED_CHGSET_DIFF_COUNT)
+    {
+        txtA = histList.last()->text();
+        txtB = histList.first()->text();
+
+    }
+    else if (headList.count() == REQUIRED_CHGSET_DIFF_COUNT)
+    {
+        txtA = headList.last()->text();
+        txtB = headList.first()->text();
+    }
+    else
+    {
+        revA = "";
+        revB = "";
+        return;
+    }
+
+    revATmp = findRev(txtA, smallRevA);
+    revBTmp = findRev(txtB, smallRevB);
+
+    //Switch order according to repo small revision number (user can select items from list in "wrong" order)
+    if (smallRevB.toULongLong() > smallRevA.toULongLong())
+    {
+        revA = revATmp;
+        revB = revBTmp;
+    }
+    else
+    {
+        revA = revBTmp;
+        revB = revATmp;
+    }
+}
+
+
+void HgExpWidget::getUpdateToRevRevision(QString& rev)
+{
+    QList <QListWidgetItem *> histList = localRepoHgLogList->selectedItems();
+    QString txt;
+    QString smallRev;
+
+
+    if (histList.count() == 1)
+    {
+        txt = histList.first()->text();
+        rev = findRev(txt, smallRev);
+    }
+    else
+    {
+        rev = "";
+    }
+}
+
+
+
+void HgExpWidget::enableDisableOtherTabs()
+{
+    //history list is only interesting when we have something in it ;-)
+    if (localRepoHgLogList -> count() < 2)
+    {
+        setTabEnabled(HISTORYTAB, false);
+    }
+    else
+    {
+        setTabEnabled(HISTORYTAB, true);
+    }
+
+    //history list is only interesting when we have something in it ;-)
+    if (localRepoHgLogList -> count() < 2)
+    {
+        setTabEnabled(HISTORYTAB, false);
+    }
+    else
+    {
+        setTabEnabled(HISTORYTAB, true);
+    }
+}
+
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hgexpwidget.h	Thu Apr 22 03:15:35 2010 +0300
@@ -0,0 +1,69 @@
+#ifndef HGEXPWIDGET_H
+#define HGEXPWIDGET_H
+
+//** Copyright (C) Jari Korhonen, 2010 (under lgpl)
+
+#include <QtGui>
+#include <QtCore>
+#include "common.h"
+
+#define NUM_STAT_FILE_TYPES 7
+
+
+class HgExpWidget: public QTabWidget
+{
+    Q_OBJECT
+
+public:
+    HgExpWidget(QWidget *parent, QString remoteRepo, QString workFolderPath,
+                unsigned char viewFileTypesBits = DEFAULT_HG_STAT_BITS);
+    void updateWorkFolderFileList(QString fileList);
+    void updateLocalRepoHeadsList(QString headList);
+    void updateLocalRepoHgLogList(QString hgLogList);
+    void updateLocalRepoParentsList(QString parentsList);
+    void setWorkFolderAndRepoNames(QString workFolderPath, QString remoteRepoPath);
+    QString getCurrentFileListLine();
+    void getHistoryDiffRevisions(QString& revA, QString& revB);
+    void getUpdateToRevRevision(QString& rev);
+    void clearLists();
+    void enableDisableOtherTabs();
+    QString getStatFlags(void);
+    unsigned char getFileTypesBits();
+
+
+    QListWidget *workFolderFileList;
+    QListWidget *localRepoHeadsList;
+    QListWidget *localRepoHgLogList;
+
+signals:
+    void workFolderViewTypesChanged();
+
+private:
+    QGroupBox   *grpRemoteRepo;
+    QWidget     *workPageWidget;
+    QWidget     *historyPageWidget;
+    QWidget     *headsPageWidget;
+
+    QGroupBox   *grpLocalRepo;
+    QVBoxLayout *mainLayout;
+    QVBoxLayout *localRepoLayout;
+    QVBoxLayout *parentsLayout;
+    QListWidget *localRepoHgParentsList;
+    QLabel      *parentsLabel;
+
+    QGroupBox   *grpWorkFolder;
+    QHBoxLayout *workFolderLayout;
+    QGroupBox   *grpViewFileTypes;
+    QVBoxLayout *fileTypesLayout;
+    QCheckBox   *chkViewFileTypes[NUM_STAT_FILE_TYPES];
+
+    QVBoxLayout *historyLayout;
+
+    QVBoxLayout *headsLayout;
+
+    QString     findRev(QString itemText, QString& smallRev);
+    QStringList splitChangeSets(QString chgSetsStr);
+    int findLineStart(int nowIndex, QString chgSetsStr);
+};
+
+#endif // HGEXPWIDGET_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hgrunner.cpp	Thu Apr 22 03:15:35 2010 +0300
@@ -0,0 +1,166 @@
+//** Copyright (C) Jari Korhonen, 2010 (under lgpl)
+
+#include "hgrunner.h"
+#include <QtCore>
+#include <QtGui>
+
+#include <unistd.h>
+
+HgRunner::HgRunner(QWidget * parent): QProgressBar(parent)
+{
+    proc = new QProcess(this);
+
+    setTextVisible(false);
+    setVisible(false);
+    isRunning = false;
+
+    stdOut.clear();
+    stdErr.clear();
+
+    connect(proc, SIGNAL(started()), this, SLOT(started()));
+    connect(proc, SIGNAL(error(QProcess::ProcessError)), this, SLOT(error(QProcess::ProcessError)));
+    connect(proc, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(finished(int, QProcess::ExitStatus)));
+}
+
+HgRunner::~HgRunner()
+{
+    delete proc;
+}
+
+void HgRunner::started()
+{
+    proc -> closeWriteChannel();
+}
+
+void HgRunner::setProcExitInfo(int procExitCode, QProcess::ExitStatus procExitStatus)
+{
+    exitCode = procExitCode;
+    exitStatus = procExitStatus;
+    stdOut = proc -> readAllStandardOutput();
+    stdErr = proc -> readAllStandardError();
+}
+
+void HgRunner::presentErrorToUser()
+{
+    QPushButton *okButton;
+    QListWidget *stdoL;
+    QListWidget *stdeL;
+    QString tmp;
+
+    QDialog *dlg = new QDialog(this);
+    dlg -> setMinimumWidth(800);
+    QVBoxLayout layout;
+
+    dlg -> setWindowTitle(tr("Mercurial error / warning"));
+
+    tmp.sprintf("%s: %d, %s: %d", "Exitcode", exitCode, "Exit status", exitStatus);
+    layout.addWidget(new QLabel(getLastCommandLine()));
+    layout.addWidget(new QLabel(tmp));
+    layout.addWidget(new QLabel(tr("Standard out:")));
+    stdoL = new QListWidget();
+    stdoL -> addItems(stdOut.split("\n"));
+    layout.addWidget(stdoL);
+
+    layout.addWidget(new QLabel(tr("Standard error:")));
+    stdeL = new QListWidget();
+    stdeL -> addItems(stdErr.split("\n"));
+    layout.addWidget(stdeL);
+
+    okButton = new QPushButton("Ok");
+    layout.addWidget(okButton);
+
+    connect(okButton, SIGNAL(clicked()), dlg, SLOT(accept()));
+    dlg -> setLayout(&layout);
+
+    dlg -> setModal(true);
+    dlg -> exec();
+}
+
+
+
+void HgRunner::error(QProcess::ProcessError)
+{
+    setProcExitInfo(proc -> exitCode(), proc -> exitStatus());
+
+    presentErrorToUser();
+
+    isRunning = false;
+}
+
+QString HgRunner::getLastCommandLine()
+{
+    return QString("Command line: " + lastHgCommand + " " + lastParams);
+}
+
+void HgRunner::finished(int procExitCode, QProcess::ExitStatus procExitStatus)
+{
+    setProcExitInfo(procExitCode, procExitStatus);
+
+    if (reportErrors)
+    {
+        if ((exitCode == 0) && (exitStatus == QProcess::NormalExit))
+        {
+            //All ok
+        }
+        else
+        {
+            presentErrorToUser();
+        }
+    }
+
+    isRunning = false;
+}
+
+bool HgRunner::isProcRunning()
+{
+    return isRunning;
+}
+
+void HgRunner::killProc()
+{
+    if (isProcRunning())
+    {
+        proc -> kill();
+    }
+}
+
+
+void HgRunner::startProc(QString hgExePathAndName, QString workingDir, QStringList params, bool reportErrors)
+{
+    this -> reportErrors = reportErrors;
+    isRunning = true;
+    setRange(0, 0);
+    setVisible(true);
+    stdOut.clear();
+    stdErr.clear();
+    exitCode = 0;
+    exitStatus = QProcess::NormalExit;
+
+    if (!workingDir.isEmpty())
+    {
+        proc -> setWorkingDirectory(workingDir);
+    }
+
+    lastHgCommand = hgExePathAndName;
+    lastParams = params.join(" ");
+
+    proc -> start(hgExePathAndName, params);
+
+}
+
+int HgRunner::getExitCode()
+{
+    return exitCode;
+}
+
+QString HgRunner::getStdOut()
+{
+    return stdOut;
+}
+
+void HgRunner::hideProgBar()
+{
+    setVisible(false);
+}
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hgrunner.h	Thu Apr 22 03:15:35 2010 +0300
@@ -0,0 +1,48 @@
+#ifndef HGRUNNER_H
+#define HGRUNNER_H
+
+//** Copyright (C) Jari Korhonen, 2010 (under lgpl)
+
+#include <QProgressBar>
+#include <QProcess>
+#include <QByteArray>
+#include <QRect>
+
+class HgRunner : public QProgressBar
+{
+    Q_OBJECT
+
+    public:
+        HgRunner(QWidget * parent = 0);
+        ~HgRunner();
+
+        void startProc(QString hgExePathAndName, QString workingDir, QStringList params, bool reportErrors = true);
+        bool isProcRunning();
+        void killProc();
+        int  getExitCode();
+        void hideProgBar();
+        QString getStdOut();
+
+    private:
+        void setProcExitInfo(int procExitCode, QProcess::ExitStatus procExitStatus);
+        QString getLastCommandLine();
+        void presentErrorToUser();
+
+        bool                    reportErrors;
+        bool                    isRunning;
+        QProcess                *proc;
+        QString                 stdOut;
+        QString                 stdErr;
+        int                     exitCode;
+        QProcess::ExitStatus    exitStatus;
+        QString                 lastHgCommand;
+        QString                 lastParams;
+
+
+    private slots:
+        void started();
+        void error(QProcess::ProcessError error);
+        void finished(int procExitCode, QProcess::ExitStatus procExitStatus);
+};
+
+#endif // HGRUNNER_H
Binary file images/add.png has changed
Binary file images/chgsetdiff.png has changed
Binary file images/commit.png has changed
Binary file images/diff.png has changed
Binary file images/exit.png has changed
Binary file images/folderdiff.png has changed
Binary file images/incoming.png has changed
Binary file images/merge.png has changed
Binary file images/pull.png has changed
Binary file images/push.png has changed
Binary file images/remove.png has changed
Binary file images/settings.png has changed
Binary file images/status.png has changed
Binary file images/undo.png has changed
Binary file images/update.png has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu Apr 22 03:15:35 2010 +0300
@@ -0,0 +1,74 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file.  Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights.  These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.  Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+** $QT_END_LICENSE$
+**
+** Copyright (C) Jari Korhonen, 2010 (HgExplorer specific parts, under lgpl)
+****************************************************************************/
+
+#include <QApplication>
+
+#ifdef Q_WS_X11
+#include <QCleanlooksStyle>
+#endif
+
+#ifdef Q_WS_WIN
+#include <QWindowsXPStyle>
+#endif
+
+#include "mainwindow.h"
+
+int main(int argc, char *argv[])
+{
+    Q_INIT_RESOURCE(hgexplorer);
+
+    QApplication app(argc, argv);
+
+    app.setApplicationName(APPNAME);
+
+    #ifdef Q_WS_X11
+    app.setStyle(new QCleanlooksStyle);
+    #endif
+
+    #ifdef Q_WS_WIN
+    app.setStyle(new QWindowsXPStyle);
+    #endif
+
+    MainWindow mainWin;
+    mainWin.show();
+    return app.exec();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mainwindow.cpp	Thu Apr 22 03:15:35 2010 +0300
@@ -0,0 +1,1106 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file.  Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights.  These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.  Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+** $QT_END_LICENSE$
+**
+** Copyright (C) Jari Korhonen, 2010 (HgExplorer specific parts, under lgpl)
+*************************************************************************************/
+
+#include <QtGui>
+#include <QStringList>
+#include <QDir>
+
+#include "mainwindow.h"
+#include "settingsdialog.h"
+
+
+MainWindow::MainWindow()
+{
+    QString wndTitle;
+
+    createActions();
+    createMenus();
+    createToolBars();
+    createStatusBar();
+
+    timerId = startTimer(200);
+    runner = new HgRunner(this);
+    runningAction = ACT_NONE;
+    statusBar()->addPermanentWidget(runner);
+
+    wndTitle.sprintf("%s %s", APPNAME, APPVERSION);
+    setWindowTitle(wndTitle);
+
+    remoteRepoPath = "";
+    workFolderPath = "";
+
+    readSettings();
+
+    tabPage = 0;
+    hgExp = new HgExpWidget((QWidget *) this, remoteRepoPath, workFolderPath, initialFileTypesBits);
+    setCentralWidget(hgExp);
+
+    setUnifiedTitleAndToolBarOnMac(true);
+    connectActions();
+    enableDisableActions();
+
+    if (firstStart)
+    {
+        QMessageBox::information(this, tr("First start todo"), tr("Going to \"Settings\" first."));
+        settings();
+    }
+
+    hgStat();
+}
+
+
+void MainWindow::closeEvent(QCloseEvent *)
+{
+    writeSettings();
+}
+
+
+void MainWindow::about()
+{
+   QMessageBox::about(this, tr("About HgExplorer"),
+                      tr("<b>HgExplorer</b> tries to be Mercurial's <b>VSS Explorer:</b> ;-)<br><br>"
+                        "-Hides command line in normal use<br>"
+                        "-Makes common operations easier<br><br>"
+                        "(c) 2010 (lgpl), Jari Korhonen (jtkorhonen@gmail.com)<br><br>"
+                        "-Needs Mercurial ;-) (thanks Matt Mackall, Bryan O'Sullivan and others !)<br>"
+                        "-Uses excellent Nuvola icons (c) David Vignoni (Thanks, David !)<br>"
+                        "-Needs Qt4, mingw (in windows), python, kdiff3 (Thanks to all of you !)<br>"));
+}
+
+
+void MainWindow::hgStat()
+{
+    if (hgStatAct -> isEnabled())
+    {
+        if (runningAction == ACT_NONE)
+        {
+            QStringList params;
+
+            QString statFlags = hgExp -> getStatFlags();
+            if (statFlags.isEmpty())
+            {
+                params << "stat";
+            }
+            else
+            {
+                params << "stat" << "-" + statFlags;
+            }
+
+
+            runner -> startProc(getHgBinaryName(), workFolderPath, params);
+            runningAction = ACT_STAT;
+        }
+    }
+}
+
+void MainWindow::hgHeads()
+{
+    if (runningAction == ACT_NONE)
+    {
+        QStringList params;
+        params << "heads";
+
+        //on empty repos, "hg heads" will fail, don't care of that.
+        runner -> startProc(getHgBinaryName(), workFolderPath, params, false);
+        runningAction = ACT_HEADS;
+    }
+}
+
+void MainWindow::hgLog()
+{
+    if (runningAction == ACT_NONE)
+    {
+        QStringList params;
+        params << "glog" << "--verbose";
+
+        runner -> startProc(getHgBinaryName(), workFolderPath, params);
+        runningAction = ACT_LOG;
+    }
+}
+
+
+void MainWindow::hgParents()
+{
+    if (runningAction == ACT_NONE)
+    {
+        QStringList params;
+        params << "parents";
+
+        runner -> startProc(getHgBinaryName(), workFolderPath, params);
+        runningAction = ACT_PARENTS;
+    }
+}
+
+
+
+void MainWindow::hgRemove()
+{
+    if (runningAction == ACT_NONE)
+    {
+        QStringList params;
+        QString currentFile = hgExp -> getCurrentFileListLine();
+
+        if (!currentFile.isEmpty())
+        {
+            params << "remove" << currentFile.mid(2);   //Jump over status marker characters (e.g "M ")
+
+            runner -> startProc(getHgBinaryName(), workFolderPath, params);
+            runningAction = ACT_REMOVE;
+        }
+    }
+}
+
+void MainWindow::hgAnnotate()
+{
+    if (runningAction == ACT_NONE)
+    {
+        QStringList params;
+        QString currentFile = hgExp -> getCurrentFileListLine();
+
+        if (!currentFile.isEmpty())
+        {
+            params << "annotate" << currentFile.mid(2);   //Jump over status marker characters (e.g "M ")
+
+            runner -> startProc(getHgBinaryName(), workFolderPath, params);
+            runningAction = ACT_ANNOTATE;
+        }
+    }
+}
+
+
+void MainWindow::hgResolveMark()
+{
+    if (runningAction == ACT_NONE)
+    {
+        QStringList params;
+        QString currentFile = hgExp -> getCurrentFileListLine();
+
+        if (!currentFile.isEmpty())
+        {
+            params << "resolve" << "--mark" << currentFile.mid(2);   //Jump over status marker characters (e.g "M ")
+
+            runner -> startProc(getHgBinaryName(), workFolderPath, params);
+            runningAction = ACT_RESOLVE_MARK;
+        }
+    }
+}
+
+
+
+void MainWindow::hgResolveList()
+{
+    if (runningAction == ACT_NONE)
+    {
+        QStringList params;
+
+        params << "resolve" << "--list";
+        runner -> startProc(getHgBinaryName(), workFolderPath, params);
+        runningAction = ACT_RESOLVE_LIST;
+    }
+}
+
+
+
+void MainWindow::hgAdd()
+{
+    if (runningAction == ACT_NONE)
+    {
+        QStringList params;
+
+        params << "add";
+
+        runner -> startProc(getHgBinaryName(), workFolderPath, params);
+        runningAction = ACT_ADD;
+    }
+}
+
+int MainWindow::getCommitComment(QString& comment)
+{
+    int ret;
+
+    QDialog dlg(this);
+
+    QLabel *commentLabel = new QLabel(tr("Comment:"));
+    QLineEdit *commentEdit = new QLineEdit;
+    commentEdit -> setFixedWidth(400);
+    QHBoxLayout *commentLayout = new QHBoxLayout;
+    commentLayout -> addWidget(commentLabel);
+    commentLayout -> addWidget(commentEdit);
+
+    QPushButton *btnOk = new QPushButton(tr("Ok"));
+    QPushButton *btnCancel = new QPushButton(tr("Cancel"));
+    QHBoxLayout *btnLayout = new QHBoxLayout;
+    btnLayout -> addWidget(btnOk);
+    btnLayout -> addWidget(btnCancel);
+
+    QVBoxLayout *mainLayout = new QVBoxLayout;
+    mainLayout -> addLayout(commentLayout);
+    mainLayout -> addLayout(btnLayout);
+
+    dlg.setLayout(mainLayout);
+
+    dlg.setWindowTitle(tr("Save (commit)"));
+
+    connect(btnOk, SIGNAL(clicked()), &dlg, SLOT(accept()));
+    connect(btnCancel, SIGNAL(clicked()), &dlg, SLOT(reject()));
+
+    ret = dlg.exec();
+    comment = commentEdit -> text();
+    return ret;
+}
+
+void MainWindow::hgCommit()
+{
+    if (runningAction == ACT_NONE)
+    {
+        QStringList params;
+        QString comment;
+        
+        if (QDialog::Accepted == getCommitComment(comment))
+        {
+            if (!comment.isEmpty())
+            {
+                params << "commit" << "--message" << comment << "--user" << userInfo;
+
+                runner -> startProc(getHgBinaryName(), workFolderPath, params);
+                runningAction = ACT_COMMIT;
+            }
+        }
+    }
+}
+
+void MainWindow::hgFileDiff()
+{
+    if (runningAction == ACT_NONE)
+    {
+        QStringList params;
+
+        QString currentFile = hgExp -> getCurrentFileListLine();
+
+        if (!currentFile.isEmpty())
+        {
+            //Diff parent file against working folder file
+            params << "kdiff3" << currentFile.mid(2);
+            runner -> startProc(getHgBinaryName(), workFolderPath, params, false);
+            runningAction = ACT_FILEDIFF;
+        }
+    }
+}
+
+
+void MainWindow::hgFolderDiff()
+{
+    if (runningAction == ACT_NONE)
+    {
+        QStringList params;
+
+        //Diff parent against working folder (folder diff)
+        params << "kdiff3";
+        runner -> startProc(getHgBinaryName(), workFolderPath, params, false);
+        runningAction = ACT_FOLDERDIFF;
+    }
+}
+
+
+void MainWindow::hgChgSetDiff()
+{
+    if (runningAction == ACT_NONE)
+    {
+        QStringList params;
+
+        //Diff 2 history log versions against each other
+        QString revA;
+        QString revB;
+
+        hgExp -> getHistoryDiffRevisions(revA, revB);
+
+        if ((!revA.isEmpty()) && (!revB.isEmpty()))
+        {
+            params << "kdiff3" << "--rev" << revA << "--rev" << revB;
+            runner -> startProc(getHgBinaryName(), workFolderPath, params, false);
+            runningAction = ACT_CHGSETDIFF;
+        }
+        else
+        {
+            QMessageBox::information(this, tr("Changeset diff"), tr("Please select two changesets from history list or heads list first."));
+        }
+    }
+}
+
+
+
+void MainWindow::hgUpdate()
+{
+    if (runningAction == ACT_NONE)
+    {
+        QStringList params;
+
+
+        params << "update";
+
+
+        runner -> startProc(getHgBinaryName(), workFolderPath, params);
+        runningAction = ACT_UPDATE;
+    }
+}
+
+
+void MainWindow::hgUpdateToRev()
+{
+    if (runningAction == ACT_NONE)
+    {
+        QStringList params;
+        QString rev;
+
+        hgExp -> getUpdateToRevRevision(rev);
+
+        hgExp -> setCurrentIndex(WORKTAB);
+        enableDisableActions();
+
+        params << "update" << "--rev" << rev << "--clean";
+
+        runner -> startProc(getHgBinaryName(), workFolderPath, params);
+
+        runningAction = ACT_UPDATE;
+    }
+}
+
+
+void MainWindow::hgRevert()
+{
+    if (runningAction == ACT_NONE)
+    {
+        QStringList params;
+        QString currentFile = hgExp -> getCurrentFileListLine();
+
+        params << "revert" << currentFile.mid(2);
+
+        runner -> startProc(getHgBinaryName(), workFolderPath, params);
+        runningAction = ACT_REVERT;
+    }
+}
+
+void MainWindow::hgMerge()
+{
+    if (runningAction == ACT_NONE)
+    {
+        QStringList params;
+
+        params << "merge";
+
+        runner -> startProc(getHgBinaryName(), workFolderPath, params);
+        runningAction = ACT_MERGE;
+    }
+}
+
+
+void MainWindow::hgCloneFromRemote()
+{
+    if (runningAction == ACT_NONE)
+    {
+        QStringList params;
+
+        params << "clone" << remoteRepoPath << workFolderPath;
+
+        runner -> startProc(getHgBinaryName(), workFolderPath, params);
+        runningAction = ACT_CLONEFROMREMOTE;
+    }
+}
+
+
+void MainWindow::hgInit()
+{
+    if (runningAction == ACT_NONE)
+    {
+        QStringList params;
+
+        params << "init";
+
+        runner -> startProc(getHgBinaryName(), workFolderPath, params);
+        runningAction = ACT_INIT;
+    }
+}
+
+
+void MainWindow::hgIncoming()
+{
+    if (runningAction == ACT_NONE)
+    {
+        QStringList params;
+
+        params << "incoming" << "--newest-first" << remoteRepoPath;
+
+        runner -> startProc(getHgBinaryName(), workFolderPath, params, false);
+        runningAction = ACT_INCOMING;
+    }
+}
+
+
+void MainWindow::hgPull()
+{
+    if (runningAction == ACT_NONE)
+    {
+        QStringList params;
+
+        params << "pull" << remoteRepoPath;
+
+        runner -> startProc(getHgBinaryName(), workFolderPath, params);
+        runningAction = ACT_PULL;
+    }
+}
+
+
+void MainWindow::hgPush()
+{
+    if (runningAction == ACT_NONE)
+    {
+        QStringList params;
+
+        params << "push" << remoteRepoPath;
+
+        runner -> startProc(getHgBinaryName(), workFolderPath, params);
+        runningAction = ACT_PUSH;
+    }
+}
+
+
+void MainWindow::settings()
+{
+    SettingsDialog *settingsDlg = new SettingsDialog(this);
+    settingsDlg->setModal(true);
+    settingsDlg->exec();
+    hgExp -> clearLists();
+    enableDisableActions();
+    hgStat();
+}
+
+void MainWindow::presentLongStdoutToUser(QString stdo, int w, int h)
+{
+    QDialog dlg;
+    dlg.setMinimumWidth(w);
+    dlg.setMinimumHeight(h);
+
+    QVBoxLayout *box = new QVBoxLayout;
+    QListWidget *list = new QListWidget;
+    list-> addItems(stdo.split("\n"));
+    QPushButton *btn = new QPushButton(tr("Ok"));
+    connect(btn, SIGNAL(clicked()), &dlg, SLOT(accept()));
+
+    box -> addWidget(list);
+    box -> addWidget(btn);
+    dlg.setLayout(box);
+
+    dlg.exec();
+}
+
+
+bool MainWindow::isSelectedLocallyDeleted(QListWidget *workList)
+{
+    QList<QListWidgetItem *> selList = workList -> selectedItems();
+    if (selList.count() == 1)
+    {
+        if (selList.at(0)->text().mid(0, 1) == "!")
+        {
+            return true;
+        }
+    }
+    return false;
+}
+
+
+bool MainWindow::isSelectedUntracked(QListWidget *workList)
+{
+    QList<QListWidgetItem *> selList = workList -> selectedItems();
+    if (selList.count() == 1)
+    {
+        if (selList.at(0)->text().mid(0, 1) == "?")
+        {
+            return true;
+        }
+    }
+    return false;
+}
+
+
+bool MainWindow::isSelectedModified(QListWidget *workList)
+{
+    QList<QListWidgetItem *> selList = workList -> selectedItems();
+    if (selList.count() == 1)
+    {
+        if (selList.at(0)->text().mid(0, 1) == "M")
+        {
+            return true;
+        }
+    }
+    return false;
+}
+
+void MainWindow::countAMRModifications(QListWidget *workList, int& a, int& m, int& r)
+{
+    int itemCount = workList -> count();
+    if (itemCount > 0)
+    {
+        int A= 0;
+        int M=0;
+        int R=0;
+        for (int i = 0; i < workList -> count(); i++)
+        {
+            QListWidgetItem *currItem = workList -> item(i);
+
+            QString tmp = currItem->text().mid(0, 1);
+            if (tmp == "M")
+            {
+                M++;
+            }
+            else if (tmp == "R")
+            {
+                R++;
+            }
+            else if (tmp == "A")
+            {
+                A++;
+            }
+        }
+
+        a = A;
+        m = M;
+        r = R;
+    }
+    else
+    {
+        a = 0;
+        m = 0;
+        r = 0;
+    }
+}
+
+
+void MainWindow::timerEvent(QTimerEvent *)
+{
+    bool shouldHgStat = false;
+
+    if (runningAction != ACT_NONE)
+    {
+        //We are running some hg command...
+        if (runner -> isProcRunning() == false)
+        {
+            //Running has just ended.
+            int exitCode = runner -> getExitCode();
+
+            runner -> hideProgBar();
+
+            //Clumsy...
+            if ((EXITOK(exitCode)) || ((exitCode == 1) && (runningAction == ACT_INCOMING)))
+            {
+                //Successful running.
+                switch(runningAction)
+                {
+                    case ACT_STAT:
+                        {
+                            hgExp -> updateWorkFolderFileList(runner -> getStdOut());
+                        }
+                        break;
+
+                    case ACT_INCOMING:
+                    case ACT_ANNOTATE:
+                    case ACT_RESOLVE_LIST:
+                    case ACT_RESOLVE_MARK:
+                        presentLongStdoutToUser(runner -> getStdOut(), 1024, 768);
+                        shouldHgStat = true;
+                        break;
+
+                    case ACT_PULL:
+                        QMessageBox::information(this, "pull", runner -> getStdOut());
+                        shouldHgStat = true;
+                        break;
+
+                    case ACT_PUSH:
+                        QMessageBox::information(this, "push", runner -> getStdOut());
+                        shouldHgStat = true;
+                        break;
+
+                    case ACT_INIT:
+                        enableDisableActions();
+                        shouldHgStat = true;
+                        break;
+
+                    case ACT_CLONEFROMREMOTE:
+                        QMessageBox::information(this, "clone", runner -> getStdOut());
+                        enableDisableActions();
+                        shouldHgStat = true;
+                        break;
+
+                    case ACT_LOG:
+                        {
+                            hgExp -> updateLocalRepoHgLogList(runner -> getStdOut());
+                        }
+                        break;
+
+                    case ACT_PARENTS:
+                        {
+                            hgExp -> updateLocalRepoParentsList(runner -> getStdOut());
+                        }
+                        break;
+
+                    case ACT_HEADS:
+                        {
+                            QString stdOut = runner -> getStdOut();
+                            hgExp -> updateLocalRepoHeadsList(stdOut);
+                        }
+                        break;
+
+                    case ACT_REMOVE:
+                    case ACT_ADD:
+                    case ACT_COMMIT:
+                    case ACT_FILEDIFF:
+                    case ACT_FOLDERDIFF:
+                    case ACT_CHGSETDIFF:
+                    case ACT_REVERT:
+                        shouldHgStat = true;
+                        break;
+
+                    case ACT_UPDATE:
+                        QMessageBox::information(this, "update", runner -> getStdOut());
+                        shouldHgStat = true;
+                        break;
+
+                    case ACT_MERGE:
+                        QMessageBox::information(this, "merge", runner -> getStdOut());
+                        shouldHgStat = true;
+                        break;
+
+                    default:
+                        break;
+                }
+            }
+
+            //Typical sequence goes stat -> heads -> parents -> log
+            if (runningAction == ACT_STAT)
+            {
+                runningAction = ACT_NONE;
+                hgHeads();
+            }
+            else if (runningAction == ACT_HEADS)
+            {
+                runningAction = ACT_NONE;
+                hgParents();
+            }
+            else if (runningAction == ACT_PARENTS)
+            {
+                runningAction = ACT_NONE;
+                hgLog();
+            }
+            else
+            {
+                runningAction = ACT_NONE;
+                if (shouldHgStat)
+                {
+                    hgStat();
+                }
+            }
+        }
+    }
+    else
+    {
+        enableDisableActions();
+    }
+}
+
+void MainWindow::connectActions()
+{
+    connect(exitAct, SIGNAL(triggered()), this, SLOT(close()));
+    connect(aboutAct, SIGNAL(triggered()), this, SLOT(about()));
+    connect(aboutQtAct, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
+
+    connect(hgStatAct, SIGNAL(triggered()), this, SLOT(hgStat()));
+    connect(hgExp, SIGNAL(workFolderViewTypesChanged()), this, SLOT(hgStat()));
+    connect(hgRemoveAct, SIGNAL(triggered()), this, SLOT(hgRemove()));
+    connect(hgAddAct, SIGNAL(triggered()), this, SLOT(hgAdd()));
+    connect(hgCommitAct, SIGNAL(triggered()), this, SLOT(hgCommit()));
+    connect(hgFileDiffAct, SIGNAL(triggered()), this, SLOT(hgFileDiff()));
+    connect(hgFolderDiffAct, SIGNAL(triggered()), this, SLOT(hgFolderDiff()));
+    connect(hgChgSetDiffAct, SIGNAL(triggered()), this, SLOT(hgChgSetDiff()));
+    connect(hgUpdateAct, SIGNAL(triggered()), this, SLOT(hgUpdate()));
+    connect(hgRevertAct, SIGNAL(triggered()), this, SLOT(hgRevert()));
+    connect(hgMergeAct, SIGNAL(triggered()), this, SLOT(hgMerge()));
+
+    connect(settingsAct, SIGNAL(triggered()), this, SLOT(settings()));
+
+    connect(hgInitAct, SIGNAL(triggered()), this, SLOT(hgInit()));
+    connect(hgCloneFromRemoteAct, SIGNAL(triggered()), this, SLOT(hgCloneFromRemote()));
+    connect(hgIncomingAct, SIGNAL(triggered()), this, SLOT(hgIncoming()));
+    connect(hgPullAct, SIGNAL(triggered()), this, SLOT(hgPull()));
+    connect(hgPushAct, SIGNAL(triggered()), this, SLOT(hgPush()));
+
+    connect(hgExp, SIGNAL(currentChanged(int)), this, SLOT(tabChanged(int)));
+
+    connect(hgUpdateToRevAct, SIGNAL(triggered()), this, SLOT(hgUpdateToRev()));
+    connect(hgAnnotateAct, SIGNAL(triggered()), this, SLOT(hgAnnotate()));
+    connect(hgResolveListAct, SIGNAL(triggered()), this, SLOT(hgResolveList()));
+    connect(hgResolveMarkAct, SIGNAL(triggered()), this, SLOT(hgResolveMark()));
+}
+
+void MainWindow::tabChanged(int currTab)
+{
+    tabPage = currTab;
+}
+
+void MainWindow::enableDisableActions()
+{
+    QDir localRepoDir;
+    QDir workFolderDir;
+    bool workFolderExist;
+    bool localRepoExist;
+
+    remoteRepoActionsEnabled = true;
+    if (remoteRepoPath.isEmpty())
+    {
+        remoteRepoActionsEnabled = false;
+    }
+
+    localRepoActionsEnabled = true;
+    if (workFolderPath.isEmpty())
+    {
+        localRepoActionsEnabled = false;
+        workFolderExist = false;
+    }
+
+    if (!workFolderDir.exists(workFolderPath))
+    {
+        localRepoActionsEnabled = false;
+        workFolderExist = false;
+    }
+    else
+    {
+        workFolderExist = true;
+    }
+
+    if (!localRepoDir.exists(workFolderPath + getHgDirName()))
+    {
+        localRepoActionsEnabled = false;
+        localRepoExist = false;
+    }
+
+    hgCloneFromRemoteAct -> setEnabled(remoteRepoActionsEnabled);
+    hgIncomingAct -> setEnabled(remoteRepoActionsEnabled && remoteRepoActionsEnabled);
+    hgPullAct -> setEnabled(remoteRepoActionsEnabled && remoteRepoActionsEnabled);
+    hgPushAct -> setEnabled(remoteRepoActionsEnabled && remoteRepoActionsEnabled);
+
+    if (tabPage != WORKTAB)
+    {
+        localRepoActionsEnabled = false;
+    }
+
+    hgInitAct -> setEnabled((localRepoExist == false) && (workFolderExist==true));
+    hgStatAct -> setEnabled(localRepoActionsEnabled);
+    hgFileDiffAct -> setEnabled(localRepoActionsEnabled);
+    hgFolderDiffAct -> setEnabled(localRepoActionsEnabled);
+    hgRevertAct -> setEnabled(localRepoActionsEnabled);
+    hgAddAct -> setEnabled(localRepoActionsEnabled);
+    hgRemoveAct -> setEnabled(localRepoActionsEnabled);
+    hgUpdateAct -> setEnabled(localRepoActionsEnabled);
+    hgCommitAct -> setEnabled(localRepoActionsEnabled);
+    hgMergeAct -> setEnabled(localRepoActionsEnabled);
+
+    hgExp -> enableDisableOtherTabs();
+
+    int a, m, r;
+    countAMRModifications(hgExp -> workFolderFileList, a, m, r);
+
+    if (tabPage == WORKTAB)
+    {
+        //Enable / disable actions according to workFolderFileList selections / currentSelection / count
+        hgChgSetDiffAct -> setEnabled(false);
+        hgUpdateToRevAct -> setEnabled(false);
+
+        if (localRepoActionsEnabled)
+        {
+            if ((a == 0) && (m == 0) && (r == 0))
+            {
+                hgCommitAct -> setEnabled(false);
+                hgRevertAct -> setEnabled(false);
+            }
+
+            if (m == 0)
+            {
+                hgFolderDiffAct -> setEnabled(false);
+            }
+
+            if (!isSelectedModified(hgExp -> workFolderFileList))
+            {
+                hgFileDiffAct -> setEnabled(false);
+                hgRevertAct -> setEnabled(false);
+            }
+
+            if (!isSelectedUntracked(hgExp -> workFolderFileList))
+            {
+                hgAddAct -> setEnabled(false);
+            }
+
+            if (!isSelectedLocallyDeleted(hgExp -> workFolderFileList))
+            {
+                hgRemoveAct -> setEnabled(false);
+            }
+
+            if (hgExp -> localRepoHeadsList->count() == 1)
+            {
+                hgMergeAct -> setEnabled(false);
+            }
+
+        }
+    }
+    else
+    {
+        QList <QListWidgetItem *> headSelList = hgExp -> localRepoHeadsList->selectedItems();
+        QList <QListWidgetItem *> historySelList = hgExp -> localRepoHgLogList->selectedItems();
+
+        if ((historySelList.count() == 2) || (headSelList.count() == 2))
+        {
+            hgChgSetDiffAct -> setEnabled(true);
+        }
+        else
+        {
+            hgChgSetDiffAct -> setEnabled(false);
+        }
+
+        if ((a == 0) && (m == 0) && (r == 0))
+        {
+            if (historySelList.count() == 1)
+            {
+                hgUpdateToRevAct -> setEnabled(true);
+            }
+            else
+            {
+                hgUpdateToRevAct -> setEnabled(false);
+            }
+        }
+        else
+        {
+            hgUpdateToRevAct -> setEnabled(false);
+        }
+    }
+}
+
+void MainWindow::createActions()
+{
+    //File actions
+    hgInitAct = new QAction(tr("Init local repository"), this);
+    hgInitAct->setStatusTip(tr("Create an empty local repository in selected folder"));
+
+    hgCloneFromRemoteAct = new QAction(tr("Clone from remote"), this);
+    hgCloneFromRemoteAct->setStatusTip(tr("Clone from remote repository into local repository in selected folder"));
+
+    settingsAct = new QAction(QIcon(":/images/settings.png"), tr("Settings..."), this);
+    settingsAct -> setStatusTip(tr("View and change application settings"));
+    settingsAct -> setIconVisibleInMenu(true);
+
+    exitAct = new QAction(QIcon(":/images/exit.png"), tr("Exit"), this);
+    exitAct->setShortcuts(QKeySequence::Quit);
+    exitAct->setStatusTip(tr("Exit application"));
+    exitAct -> setIconVisibleInMenu(true);
+
+    //Repository actions
+    hgIncomingAct = new QAction(QIcon(":/images/incoming.png"), tr("View incoming changesets"), this);
+    hgIncomingAct -> setStatusTip(tr("View info of changesets incoming to us from remote repository (on pull operation)"));
+
+    hgPullAct = new QAction(QIcon(":/images/pull.png"), tr("Pull from remote"), this);
+    hgPullAct -> setStatusTip(tr("Pull changesets from remote repository to local repository"));
+
+    hgPushAct = new QAction(QIcon(":/images/push.png"), tr("Push to remote"), this);
+    hgPushAct->setStatusTip(tr("Push local changesets to remote repository"));
+
+    //Workfolder actions
+    hgStatAct = new QAction(QIcon(":/images/status.png"), tr("Refresh status"), this);
+    hgStatAct->setStatusTip(tr("Refresh (info of) status of workfolder files (A=Added, M=Mofified, R=Removed, C=Clean, !=Locally deleted, ?=Not tracked, I=Ignored)"));
+
+    hgFileDiffAct   = new QAction(QIcon(":/images/diff.png"), tr("View filediff"), this);
+    hgFileDiffAct->setStatusTip(tr("Filediff: View differences between selected working folder file and local repository file"));
+
+    hgFolderDiffAct   = new QAction(QIcon(":/images/folderdiff.png"), tr("View folderdiff"), this);
+    hgFolderDiffAct->setStatusTip(tr("Folderdiff: View all differences between working folder files and local repository files"));
+
+    hgChgSetDiffAct   = new QAction(QIcon(":/images/chgsetdiff.png"), tr("View changesetdiff"), this);
+    hgChgSetDiffAct->setStatusTip(tr("Change set diff: View differences between all files of 2 repository changesets"));
+
+    hgRevertAct = new QAction(QIcon(":/images/undo.png"), tr("Undo changes"), this);
+    hgRevertAct->setStatusTip(tr("Undo selected working folder file changes (return to local repository version)"));
+
+    hgAddAct = new QAction(QIcon(":/images/add.png"), tr("Add files"), this);
+    hgAddAct -> setStatusTip(tr("Add working folder files to local repository (on next commit)"));
+
+    hgRemoveAct = new QAction(QIcon(":/images/remove.png"), tr("Remove file"), this);
+    hgRemoveAct -> setStatusTip(tr("Remove selected working folder file from local repository (on next commit)"));
+
+    hgUpdateAct = new QAction(QIcon(":/images/update.png"), tr("Update working folder"), this);
+    hgUpdateAct->setStatusTip(tr("Update working folder from local repository"));
+
+    hgCommitAct = new QAction(QIcon(":/images/commit.png"), tr("Commit / Save changes"), this);
+    hgCommitAct->setStatusTip(tr("Save all changes in working folder (and all subfolders) to local repository"));
+
+    hgMergeAct = new QAction(QIcon(":/images/merge.png"), tr("Merge"), this);
+    hgMergeAct->setStatusTip(tr("Merge two local repository changesets to working folder"));
+
+    //Advanced actions
+    hgUpdateToRevAct = new QAction(tr("Update to revision"), this);
+    hgUpdateToRevAct -> setStatusTip(tr("Update working folder to version selected from history list"));
+
+    hgAnnotateAct = new QAction(tr("Annotate"), this);
+    hgAnnotateAct -> setStatusTip(tr("Show line-by-line version information for selected file"));
+
+    hgResolveListAct = new QAction(tr("Resolve (list)"), this);
+    hgResolveListAct -> setStatusTip(tr("Resolve (list): Show list of files needing merge"));
+
+    hgResolveMarkAct = new QAction(tr("Resolve (mark)"), this);
+    hgResolveMarkAct -> setStatusTip(tr("Resolve (mark): Mark selected file status as resolved"));
+
+    //Help actions
+    aboutAct = new QAction(tr("About"), this);
+    aboutAct->setStatusTip(tr("Show the application's About box"));
+
+    aboutQtAct = new QAction(tr("About Qt"), this);
+    aboutQtAct->setStatusTip(tr("Show the Qt library's About box"));
+}
+
+void MainWindow::createMenus()
+{
+    fileMenu = menuBar()->addMenu(tr("File"));
+    fileMenu -> addAction(hgInitAct);
+    fileMenu -> addAction(hgCloneFromRemoteAct);
+    fileMenu -> addSeparator();
+    fileMenu -> addAction(settingsAct);
+    fileMenu -> addSeparator();
+    fileMenu -> addAction(exitAct);
+
+    advancedMenu = menuBar()->addMenu(tr("Advanced"));
+    advancedMenu -> addAction(hgUpdateToRevAct);
+    advancedMenu -> addSeparator();
+    advancedMenu -> addAction(hgAnnotateAct);
+    advancedMenu -> addSeparator();
+    advancedMenu -> addAction(hgResolveListAct);
+    advancedMenu -> addAction(hgResolveMarkAct);
+
+    helpMenu = menuBar()->addMenu(tr("Help"));
+    helpMenu->addAction(aboutAct);
+    helpMenu->addAction(aboutQtAct);
+}
+
+void MainWindow::createToolBars()
+{
+    fileToolBar = addToolBar(tr("File"));
+    fileToolBar -> setIconSize(QSize(MY_ICON_SIZE, MY_ICON_SIZE));
+    fileToolBar -> addAction(settingsAct);
+    fileToolBar -> addAction(exitAct);
+    fileToolBar -> addSeparator();
+    fileToolBar -> addAction(hgChgSetDiffAct);
+    fileToolBar -> setMovable(false);
+
+    repoToolBar = addToolBar(tr(REPOMENU_TITLE));
+    repoToolBar -> setIconSize(QSize(MY_ICON_SIZE, MY_ICON_SIZE));
+    repoToolBar->addAction(hgIncomingAct);
+    repoToolBar->addAction(hgPullAct);
+    repoToolBar->addAction(hgPushAct);
+    repoToolBar -> setMovable(false);
+
+    workFolderToolBar = addToolBar(tr(WORKFOLDERMENU_TITLE));
+    addToolBar(Qt::LeftToolBarArea, workFolderToolBar);
+    workFolderToolBar -> setIconSize(QSize(MY_ICON_SIZE, MY_ICON_SIZE));
+    workFolderToolBar->addAction(hgStatAct);
+    workFolderToolBar->addSeparator();
+    workFolderToolBar->addAction(hgFileDiffAct);
+    workFolderToolBar->addAction(hgFolderDiffAct);
+    workFolderToolBar->addSeparator();
+    workFolderToolBar->addAction(hgRevertAct);
+    workFolderToolBar->addAction(hgUpdateAct);
+    workFolderToolBar->addAction(hgCommitAct);
+    workFolderToolBar->addAction(hgMergeAct);
+    workFolderToolBar->addSeparator();
+    workFolderToolBar->addAction(hgAddAct);
+    workFolderToolBar->addAction(hgRemoveAct);
+    workFolderToolBar -> setMovable(false);
+
+}
+
+
+void MainWindow::createStatusBar()
+{
+    statusBar()->showMessage(tr("Ready"));
+}
+
+void MainWindow::readSettings()
+{
+    QDir workFolder;
+
+    QSettings settings("hgexplorer", "hgexplorer");
+
+    remoteRepoPath = settings.value("remoterepopath", "").toString() ;
+    workFolderPath = settings.value("workfolderpath", "").toString();
+    if (!workFolder.exists(workFolderPath))
+    {
+        workFolderPath = "";
+    }
+
+    userInfo = settings.value("userinfo", "").toString();
+
+    QPoint pos = settings.value("pos", QPoint(200, 200)).toPoint();
+    QSize size = settings.value("size", QSize(400, 400)).toSize();
+    firstStart = settings.value("firststart", QVariant(true)).toBool();
+
+    initialFileTypesBits = (unsigned char) settings.value("viewFileTypes", QVariant(DEFAULT_HG_STAT_BITS)).toInt();
+    resize(size);
+    move(pos);
+}
+
+void MainWindow::writeSettings()
+{
+    QSettings settings("hgexplorer", "hgexplorer");
+    settings.setValue("pos", pos());
+    settings.setValue("size", size());
+    settings.setValue("remoterepopath", remoteRepoPath);
+    settings.setValue("workfolderpath", workFolderPath);
+    settings.setValue("userinfo", userInfo);
+    settings.setValue("firststart", firstStart);
+    settings.setValue("viewFileTypes", hgExp -> getFileTypesBits());
+}
+
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mainwindow.h	Thu Apr 22 03:15:35 2010 +0300
@@ -0,0 +1,201 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file.  Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights.  These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.  Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+** $QT_END_LICENSE$
+**
+** Copyright (C) Jari Korhonen, 2010 (HgExplorer specific parts, under lgpl)
+****************************************************************************/
+
+#ifndef MAINWINDOW_H
+#define MAINWINDOW_H
+
+#include <QMainWindow>
+
+#include "hgexpwidget.h"
+#include "hgrunner.h"
+#include "common.h"
+
+QT_BEGIN_NAMESPACE
+class QAction;
+class QMenu;
+QT_END_NAMESPACE
+
+enum HGACTIONS
+{
+    ACT_NONE,
+    ACT_STAT,
+    ACT_HEADS,
+    ACT_PARENTS,
+    ACT_LOG,
+    ACT_REMOVE,
+    ACT_ADD,
+    ACT_INCOMING,
+    ACT_PUSH,
+    ACT_PULL,
+    ACT_CLONEFROMREMOTE,
+    ACT_INIT,
+    ACT_COMMIT,
+    ACT_ANNOTATE,
+    ACT_FILEDIFF,
+    ACT_FOLDERDIFF,
+    ACT_CHGSETDIFF,
+    ACT_UPDATE,
+    ACT_REVERT,
+    ACT_MERGE,
+    ACT_RESOLVE_LIST,
+    ACT_RESOLVE_MARK
+};
+
+
+class MainWindow : public QMainWindow
+{
+    Q_OBJECT
+
+public:
+    MainWindow();
+    HgExpWidget *hgExp;
+    void writeSettings();
+    void enableDisableActions();
+
+    //Paths to remote repo & workfolder
+    //Local repo is directory "./hg/" under work folder
+    QString remoteRepoPath;
+    QString workFolderPath;
+
+    //User info for commits
+    QString userInfo;
+    bool        firstStart;
+
+protected:
+    void closeEvent(QCloseEvent *event);
+    void timerEvent(QTimerEvent *event);
+
+public slots:
+    void hgStat();
+    void tabChanged(int currTab);
+
+private slots:
+    void about();
+    void hgRemove();
+    void hgAdd();
+    void hgCommit();
+    void hgFileDiff();
+    void hgFolderDiff();
+    void hgChgSetDiff();
+    void hgUpdate();
+    void hgRevert();
+    void hgMerge();
+    void settings();
+    void hgCloneFromRemote();
+    void hgInit();
+    void hgIncoming();
+    void hgPush();
+    void hgPull();
+    void hgUpdateToRev();
+    void hgAnnotate();
+    void hgResolveList();
+    void hgResolveMark();
+
+private:
+    void hgHeads();
+    void hgParents();
+    void hgLog();
+    void createActions();
+    void connectActions();
+    void createMenus();
+    void createToolBars();
+    void createStatusBar();
+    void readSettings();
+    void splitChangeSets(QStringList *list, QString hgLogOutput);
+    int getCommitComment(QString& comment);
+    void presentLongStdoutToUser(QString stdo, int w, int h);
+    void countAMRModifications(QListWidget *workList, int& a, int& m, int& r);
+    bool isSelectedModified(QListWidget *workList);
+    bool isSelectedUntracked(QListWidget *workList);
+    bool isSelectedLocallyDeleted(QListWidget *workList);
+
+
+    //Actions enabled flags
+    bool remoteRepoActionsEnabled;
+    bool localRepoActionsEnabled;
+
+    //File menu actions
+    QAction *hgInitAct;
+    QAction *hgCloneFromRemoteAct;
+    QAction *settingsAct;
+    QAction *exitAct;
+
+    QAction *hgIncomingAct;
+    QAction *hgPushAct;
+    QAction *hgPullAct;
+    QAction *hgStatAct;
+    QAction *hgFileDiffAct;
+    QAction *hgFolderDiffAct;
+    QAction *hgChgSetDiffAct;
+    QAction *hgRevertAct;
+    QAction *hgAddAct;
+    QAction *hgRemoveAct;
+    QAction *hgUpdateAct;
+    QAction *hgCommitAct;
+    QAction *hgMergeAct;
+    QAction *hgUpdateToRevAct;
+    QAction *hgAnnotateAct;
+    QAction *hgResolveListAct;
+    QAction *hgResolveMarkAct;
+
+    //Menus
+    QMenu   *fileMenu;
+    QMenu   *advancedMenu;
+    QMenu   *helpMenu;
+
+    //Help menu actions
+    QAction *aboutAct;
+    QAction *aboutQtAct;
+
+    QToolBar *fileToolBar;
+    QToolBar *repoToolBar;
+    QToolBar *workFolderToolBar;
+
+    int         timerId;
+    HGACTIONS   runningAction;
+    HgRunner    *runner;
+
+    int         tabPage;
+    unsigned char   initialFileTypesBits;
+};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/object_script.hgexplorer.Release	Thu Apr 22 03:15:35 2010 +0300
@@ -0,0 +1,13 @@
+INPUT(
+./release\main.o
+./release\mainwindow.o
+./release\hgexpwidget.o
+./release\hgrunner.o
+./release\settingsdialog.o
+./release\common.o
+./release\moc_mainwindow.o
+./release\moc_hgexpwidget.o
+./release\moc_hgrunner.o
+./release\moc_settingsdialog.o
+./release\qrc_hgexplorer.o
+);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/settingsdialog.cpp	Thu Apr 22 03:15:35 2010 +0300
@@ -0,0 +1,143 @@
+//** Copyright (C) Jari Korhonen, 2010 (under lgpl)
+
+#include "settingsdialog.h"
+
+#include <QHBoxLayout>
+#include <QVBoxLayout>
+
+
+SettingsDialog::SettingsDialog(QWidget *parent): QDialog(parent)
+{
+    QPushButton *okButton;
+    QPushButton *cancelButton;
+
+    mainWnd = (MainWindow *) parent;
+
+    userInfoLabel = new QLabel(tr("User info for commits, e.g. John Smith <john.smith@mail.com>"));
+    userInfoLineEdit = new QLineEdit(mainWnd->userInfo);
+    userInfoLabel -> setBuddy(userInfoLineEdit);
+
+    remoteRepoLabel = new QLabel(tr("Remote repository path, e.g. http://192.168.1.10:8000/ or /home/mike/anotherrepo/ or c:\\anotherrepo\\"));
+    remoteRepoLineEdit = new QLineEdit(mainWnd->remoteRepoPath);
+    remoteRepoLabel -> setBuddy(remoteRepoLineEdit);
+    remoteRepoBrowseButton = new QPushButton(tr("Browse..."));
+
+    workFolderLabel = new QLabel(tr("Local work folder path, e.g. /home/mike/work/ or c:\\mike\\work\\"));
+    workFolderLineEdit = new QLineEdit(mainWnd -> workFolderPath);
+    workFolderLabel -> setBuddy(workFolderLineEdit);
+    workFolderBrowseButton = new QPushButton(tr("Browse..."));
+
+    okButton = new QPushButton(tr("Ok"));
+    cancelButton = new QPushButton(tr("Cancel"));
+
+    QHBoxLayout *btnLayout = new QHBoxLayout;
+    btnLayout -> addWidget(okButton);
+    btnLayout -> addWidget(cancelButton);
+    btnLayout -> addStretch();
+
+    QHBoxLayout *workFolderLayout = new QHBoxLayout;
+    workFolderLayout -> addWidget(workFolderLineEdit);
+    workFolderLayout -> addWidget(workFolderBrowseButton);
+
+    QHBoxLayout *remoteRepoLayout = new QHBoxLayout;
+    remoteRepoLayout -> addWidget(remoteRepoLineEdit);
+    remoteRepoLayout -> addWidget(remoteRepoBrowseButton);
+
+    QVBoxLayout *mainLayout = new QVBoxLayout;
+
+    mainLayout -> addWidget(userInfoLabel);
+    mainLayout -> addWidget(userInfoLineEdit);
+
+    mainLayout -> addWidget(remoteRepoLabel);
+    mainLayout -> addLayout(remoteRepoLayout);
+
+    mainLayout -> addWidget(workFolderLabel);
+    mainLayout -> addLayout(workFolderLayout);
+
+    mainLayout -> addLayout(btnLayout);
+
+    setLayout(mainLayout);
+
+    connect(okButton, SIGNAL(clicked()), this, SLOT(okClicked()));
+    connect(cancelButton, SIGNAL(clicked()), this, SLOT(cancelClicked()));
+    connect(workFolderBrowseButton, SIGNAL(clicked()), this, SLOT(browseWorkFolder()));
+    connect(remoteRepoBrowseButton, SIGNAL(clicked()), this, SLOT(browseRemoteRepo()));
+}
+
+#define EMPTY_DIR 2
+
+void SettingsDialog::okClicked()
+{
+    mainWnd -> firstStart = false;
+    mainWnd -> userInfo = userInfoLineEdit->text();
+    mainWnd -> remoteRepoPath = remoteRepoLineEdit->text();
+    mainWnd -> workFolderPath = workFolderLineEdit -> text();
+    mainWnd -> writeSettings();
+    mainWnd -> enableDisableActions();
+    mainWnd -> hgStat();
+    mainWnd -> hgExp -> setWorkFolderAndRepoNames(mainWnd -> workFolderPath, mainWnd -> remoteRepoPath);
+
+    QDir dir(mainWnd -> workFolderPath);
+    if (dir.exists(mainWnd -> workFolderPath))
+    {
+        uint cnt = dir.count();
+        if (cnt == EMPTY_DIR)
+        {
+            QMessageBox::information(this, tr("Todo"), tr("Your chosen workfolder is empty.\nChoose \"File/Clone from remote\"\nto download a remote repository.\nYou can also choose \"File/Init local repository\"\nto initialize repository and add files later."));
+        }
+        else
+        {
+            QString repoPath = mainWnd -> workFolderPath + getHgDirName();
+            QDir repoDir(repoPath);
+            if (!repoDir.exists())
+            {
+                QMessageBox::information(this, tr("Todo"), tr("Your chosen workfolder is not empty,\nbut does not yet contain a repository.\nChoose \"File/Init local repository\" \nto initialize repository."));
+            }
+        }
+    }
+
+
+    close();
+}
+
+
+void SettingsDialog::cancelClicked()
+{
+    close();
+}
+
+
+void SettingsDialog::browseDirAndSetLineEdit(QLineEdit *lineEdit)
+{
+    QString dir;
+    QString startDir;
+    QString system;
+
+    system = getSystem();
+    if ((system == "Linux") || (system == "Mac"))
+    {
+        startDir = QDir::homePath();
+    }
+    else
+    {
+        startDir = "c:\\";
+    }
+
+    dir =  QFileDialog::getExistingDirectory(this, tr("Open Directory"),
+        startDir,
+        QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
+
+    lineEdit->setText(dir + QDir::separator());
+}
+
+void SettingsDialog::browseWorkFolder()
+{
+    browseDirAndSetLineEdit(workFolderLineEdit);
+}
+
+void SettingsDialog::browseRemoteRepo()
+{
+    browseDirAndSetLineEdit(remoteRepoLineEdit);
+}
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/settingsdialog.h	Thu Apr 22 03:15:35 2010 +0300
@@ -0,0 +1,49 @@
+#ifndef SETTINGSDIALOG_H
+#define SETTINGSDIALOG_H
+
+#include "mainwindow.h"
+
+//** Copyright (C) Jari Korhonen, 2010 (under lgpl)
+
+#include <QDialog>
+#include <QLabel>
+#include <QLineEdit>
+#include <QPushButton>
+
+class SettingsDialog : public QDialog
+{
+    Q_OBJECT
+
+public:
+    SettingsDialog(QWidget *parent = 0);
+
+private slots:
+    void okClicked();
+    void cancelClicked();
+    void browseWorkFolder();
+    void browseRemoteRepo();
+
+private:
+    QLabel      *userInfoLabel;
+    QLineEdit   *userInfoLineEdit;
+
+    QLabel      *remoteRepoLabel;
+    QLineEdit   *remoteRepoLineEdit;
+    QPushButton *remoteRepoBrowseButton;
+    QHBoxLayout *remoteRepoLayout;
+
+    QLabel      *workFolderLabel;
+    QLineEdit   *workFolderLineEdit;
+    QPushButton *workFolderBrowseButton;
+    QHBoxLayout *workFolderLayout;
+
+    QPushButton *okButton;
+    QPushButton *cancelButton;
+
+    MainWindow  *mainWnd;
+
+    void browseDirAndSetLineEdit(QLineEdit *lineEdit);
+};
+
+
+#endif // SETTINGSDIALOG_H