diff --git a/hg/mergedialog.cpp b/hg/mergedialog.cpp index d46dfd3..576c734 100644 --- a/hg/mergedialog.cpp +++ b/hg/mergedialog.cpp @@ -1,154 +1,153 @@ /*************************************************************************** * Copyright (C) 2011 by Vishesh Yadav * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * ***************************************************************************/ #include "mergedialog.h" #include "hgwrapper.h" #include "commititemdelegate.h" #include "commitinfowidget.h" #include "fileviewhgpluginsettings.h" #include #include #include #include #include #include #include #include -#include HgMergeDialog::HgMergeDialog(QWidget *parent): DialogBase(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, parent) { // dialog properties this->setWindowTitle(xi18nc("@title:window", "Hg Merge")); okButton()->setText(xi18nc("@label:button", "Merge")); // UI m_currentChangeset = new QLabel; m_commitInfoWidget = new HgCommitInfoWidget; QVBoxLayout *vbox = new QVBoxLayout; vbox->addWidget(m_currentChangeset); vbox->addWidget(m_commitInfoWidget); layout()->insertLayout(0, vbox); updateInitialDialog(); // load saved geometry FileViewHgPluginSettings *settings = FileViewHgPluginSettings::self(); this->resize(QSize(settings->mergeDialogWidth(), settings->mergeDialogHeight())); // connections connect(this, SIGNAL(finished(int)), this, SLOT(saveGeometry())); } void HgMergeDialog::updateInitialDialog() { HgWrapper *hgWrapper = HgWrapper::instance(); // update label - current branch QString line("parents: "); line += hgWrapper->getParentsOfHead(); m_currentChangeset->setText(line); // update heads list QProcess process; process.setWorkingDirectory(hgWrapper->getBaseDir()); QStringList args; args << QLatin1String("heads"); args << QLatin1String("--template"); args << QLatin1String("{rev}\n{node|short}\n{branch}\n" "{author}\n{desc|firstline}\n"); process.start(QLatin1String("hg"), args); m_commitInfoWidget->clear(); const int FINAL = 5; char buffer[FINAL][1024]; int count = 0; while (process.waitForReadyRead()) { while (process.readLine(buffer[count], sizeof(buffer[count])) > 0) { if (count == FINAL - 1) { QString rev = QTextCodec::codecForLocale()->toUnicode(buffer[0]).trimmed(); QString changeset = QTextCodec::codecForLocale()->toUnicode(buffer[1]).trimmed(); QString branch = QTextCodec::codecForLocale()->toUnicode(buffer[2]).trimmed(); QString author = QTextCodec::codecForLocale()->toUnicode(buffer[3]).trimmed(); QString log = QTextCodec::codecForLocale()->toUnicode(buffer[4]).trimmed(); QListWidgetItem *item = new QListWidgetItem; item->setData(Qt::DisplayRole, changeset); item->setData(Qt::UserRole + 1, rev); item->setData(Qt::UserRole + 2, branch); item->setData(Qt::UserRole + 3, author); item->setData(Qt::UserRole + 4, log); m_commitInfoWidget->addItem(item); } count = (count + 1)%FINAL; } } } void HgMergeDialog::done(int r) { if (r == QDialog::Accepted) { HgWrapper *hgw = HgWrapper::instance(); QListWidgetItem *currentItem = m_commitInfoWidget->currentItem(); if (currentItem == 0) { KMessageBox::error(this, xi18nc("@message", "No head selected for merge!")); return; } QString changeset = m_commitInfoWidget->selectedChangeset(); QStringList args; args << QLatin1String("-r"); args << changeset; if (hgw->executeCommandTillFinished(QLatin1String("merge"), args)) { KMessageBox::information(this, hgw->readAllStandardOutput()); QDialog::done(r); } else { KMessageBox::error(this, hgw->readAllStandardError()); return; } } else { QDialog::done(r); } } void HgMergeDialog::saveGeometry() { FileViewHgPluginSettings *settings = FileViewHgPluginSettings::self(); settings->setMergeDialogHeight(this->height()); settings->setMergeDialogWidth(this->width()); settings->save(); } diff --git a/hg/mergedialog.h b/hg/mergedialog.h index 1ff4231..00c3913 100644 --- a/hg/mergedialog.h +++ b/hg/mergedialog.h @@ -1,53 +1,52 @@ /*************************************************************************** * Copyright (C) 2011 by Vishesh Yadav * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * ***************************************************************************/ #ifndef HGMERGE_H #define HGMERGE_H #include #include "dialogbase.h" -class KComboBox; class QLabel; class HgCommitInfoWidget; /** * Implements dialog to perform merge operations */ class HgMergeDialog : public DialogBase { Q_OBJECT public: HgMergeDialog(QWidget *parent = 0); void done(int r); private slots: void saveGeometry(); private: void updateInitialDialog(); private: QLabel *m_currentChangeset; HgCommitInfoWidget *m_commitInfoWidget; }; #endif // HGMERGE_H diff --git a/hg/pulldialog.cpp b/hg/pulldialog.cpp index ebd1ae1..f106f06 100644 --- a/hg/pulldialog.cpp +++ b/hg/pulldialog.cpp @@ -1,166 +1,165 @@ /*************************************************************************** * Copyright (C) 2011 by Vishesh Yadav * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * ***************************************************************************/ #include "pulldialog.h" #include "hgwrapper.h" #include "hgconfig.h" #include "pathselector.h" #include "fileviewhgpluginsettings.h" #include #include #include #include #include #include #include #include -#include #include #include HgPullDialog::HgPullDialog(QWidget *parent): HgSyncBaseDialog(HgSyncBaseDialog::PullDialog, parent) { // dialog properties this->setWindowTitle(xi18nc("@title:window", "Hg Pull Repository")); setup(); } void HgPullDialog::setOptions() { m_optUpdate = new QCheckBox(xi18nc("@label:checkbox", "Update to new branch head if changesets were pulled")); m_optInsecure = new QCheckBox(xi18nc("@label:checkbox", "Do not verify server certificate")); m_optForce = new QCheckBox(xi18nc("@label:checkbox", "Force Pull")); m_optionGroup = new QGroupBox(xi18nc("@label:group", "Options")); m_options << m_optForce; m_options << m_optUpdate; m_options << m_optInsecure; } void HgPullDialog::createChangesGroup() { m_changesGroup = new QGroupBox(xi18nc("@label:group", "Incoming Changes")); QHBoxLayout *hbox = new QHBoxLayout; m_changesList = new QTableWidget; m_changesList->setColumnCount(4); m_changesList->verticalHeader()->hide(); m_changesList->horizontalHeader()->hide(); m_changesList->setSelectionBehavior(QAbstractItemView::SelectRows); m_changesList->setEditTriggers(QAbstractItemView::NoEditTriggers); hbox->addWidget(m_changesList); m_changesGroup->setLayout(hbox); m_changesGroup->setVisible(false); connect(this, SIGNAL(changeListAvailable()), this, SLOT(slotUpdateChangesGeometry())); } void HgPullDialog::getHgChangesArguments(QStringList &args) { args << QLatin1String("incoming"); args << m_pathSelector->remote(); args << QLatin1String("--config"); args << QLatin1String("ui.verbose=False"); args << QLatin1String("--template"); args << QLatin1String("Commit: {rev}:{node|short} " "{author} " "{date|isodate} {desc|firstline}\n"); } void HgPullDialog::parseUpdateChanges(const QString &input) { QStringList list = input.split(" ", QString::SkipEmptyParts); QTableWidgetItem *author = new QTableWidgetItem; QTableWidgetItem *changeset = new QTableWidgetItem; QTableWidgetItem *date = new QTableWidgetItem; QTableWidgetItem *summary = new QTableWidgetItem; author->setForeground(Qt::darkRed); changeset->setForeground(Qt::red); date->setForeground(Qt::blue); author->setText(list.takeFirst()); changeset->setText(list.takeFirst()); date->setText(list.takeFirst()); summary->setText(list.takeFirst()); int rowCount = m_changesList->rowCount(); m_changesList->insertRow(rowCount); m_changesList->setItem(rowCount, 0, author); m_changesList->setItem(rowCount, 1, changeset); m_changesList->setItem(rowCount, 2, date); m_changesList->setItem(rowCount, 3, summary); } void HgPullDialog::appendOptionArguments(QStringList &args) { if (m_optForce->isChecked()) { args << QLatin1String("--force"); } if (m_optUpdate->isChecked()) { args << QLatin1String("--update"); } if (m_optInsecure->isChecked()) { args << QLatin1String("--insecure"); } } void HgPullDialog::slotUpdateChangesGeometry() { m_changesList->resizeColumnsToContents(); m_changesList->resizeRowsToContents(); m_changesList->horizontalHeader()->setStretchLastSection(true); } void HgPullDialog::readBigSize() { FileViewHgPluginSettings *settings = FileViewHgPluginSettings::self(); m_bigSize = QSize(settings->pullDialogBigWidth(), settings->pushDialogBigHeight()); } void HgPullDialog::writeBigSize() { qDebug() << "Saving geometry"; FileViewHgPluginSettings *settings = FileViewHgPluginSettings::self(); settings->setPullDialogBigWidth(m_bigSize.width()); settings->setPullDialogBigHeight(m_bigSize.height()); settings->save(); } void HgPullDialog::noChangesMessage() { KMessageBox::information(this, xi18nc("@message:info", "No incoming changes!")); } diff --git a/hg/pulldialog.h b/hg/pulldialog.h index b37bd06..8e7869e 100644 --- a/hg/pulldialog.h +++ b/hg/pulldialog.h @@ -1,67 +1,66 @@ /*************************************************************************** * Copyright (C) 2011 by Vishesh Yadav * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * ***************************************************************************/ #ifndef HGPULLDILAOG_H #define HGPULLDILAOG_H #include "syncdialogbase.h" class QCheckBox; class QTableWidget; class KTextEdit; -class KComboBox; class QString; /** * Dialog to implement pull operation */ class HgPullDialog : public HgSyncBaseDialog { Q_OBJECT public: HgPullDialog(QWidget *parent = 0); private: void setOptions(); void parseUpdateChanges(const QString &input); void appendOptionArguments(QStringList &args); void createChangesGroup(); void getHgChangesArguments(QStringList &args); void noChangesMessage(); private slots: void slotUpdateChangesGeometry(); void readBigSize(); void writeBigSize(); private: // Options QCheckBox *m_optUpdate; QCheckBox *m_optInsecure; QCheckBox *m_optForce; QGroupBox *m_optionGroup; // incoming Changes QTableWidget *m_changesList; }; #endif // HGPULLDILAOG_H diff --git a/hg/pushdialog.cpp b/hg/pushdialog.cpp index 732648a..519b058 100644 --- a/hg/pushdialog.cpp +++ b/hg/pushdialog.cpp @@ -1,186 +1,185 @@ /*************************************************************************** * Copyright (C) 2011 by Vishesh Yadav * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * ***************************************************************************/ #include "pushdialog.h" #include "hgconfig.h" #include "pathselector.h" #include "fileviewhgpluginsettings.h" #include #include #include #include #include #include #include #include #include -#include #include #include HgPushDialog::HgPushDialog(QWidget *parent): HgSyncBaseDialog(HgSyncBaseDialog::PushDialog, parent) { // dialog properties this->setWindowTitle(xi18nc("@title:window", "Hg Push Repository")); setup(); } void HgPushDialog::setOptions() { m_optAllowNewBranch = new QCheckBox(xi18nc("@label:checkbox", "Allow pushing a new branch")); m_optInsecure = new QCheckBox(xi18nc("@label:checkbox", "Do not verify server certificate")); m_optForce = new QCheckBox(xi18nc("@label:checkbox", "Force Push")); m_optionGroup = new QGroupBox(xi18nc("@label:group", "Options")); m_options << m_optForce; m_options << m_optAllowNewBranch; m_options << m_optInsecure; } void HgPushDialog::createChangesGroup() { m_changesGroup = new QGroupBox(xi18nc("@label:group", "Outgoing Changes")); QHBoxLayout *hbox = new QHBoxLayout; m_outChangesList = new QTableWidget; m_changesetInfo = new KTextEdit; m_outChangesList->setColumnCount(3); m_outChangesList->verticalHeader()->hide(); m_outChangesList->horizontalHeader()->hide(); m_outChangesList->setSelectionBehavior(QAbstractItemView::SelectRows); m_outChangesList->setEditTriggers(QAbstractItemView::NoEditTriggers); m_changesetInfo->setFontFamily(QLatin1String("Monospace")); hbox->addWidget(m_outChangesList); hbox->addWidget(m_changesetInfo); m_changesGroup->setLayout(hbox); m_changesGroup->setVisible(false); connect(m_outChangesList, SIGNAL(itemSelectionChanged()), this, SLOT(slotOutSelChanged())); connect(this, SIGNAL(changeListAvailable()), this, SLOT(slotUpdateChangesGeometry())); } void HgPushDialog::slotOutSelChanged() { if (m_hgw->isBusy()) { return; } QString changeset = m_outChangesList->item(m_outChangesList->currentRow(), 0)->text().split(' ', QString::SkipEmptyParts).takeLast(); QStringList args; args << QLatin1String("-r"); args << changeset; args << QLatin1String("-v"); args << QLatin1String("-p"); QString output; m_hgw->executeCommand(QLatin1String("log"), args, output); m_changesetInfo->clear(); m_changesetInfo->setText(output); } void HgPushDialog::getHgChangesArguments(QStringList &args) { args << QLatin1String("outgoing"); args << m_pathSelector->remote(); args << QLatin1String("--config"); args << QLatin1String("ui.verbose=False"); args << QLatin1String("--template"); args << QLatin1String("Commit: {rev}:{node|short} " "{date|isodate} {desc|firstline}\n"); } void HgPushDialog::parseUpdateChanges(const QString &input) { QStringList list = input.split(" ", QString::SkipEmptyParts); QTableWidgetItem *changeset = new QTableWidgetItem; QTableWidgetItem *date = new QTableWidgetItem; QTableWidgetItem *summary = new QTableWidgetItem; changeset->setForeground(Qt::red); date->setForeground(Qt::blue); changeset->setText(list.takeFirst()); date->setText(list.takeFirst()); summary->setText(list.takeFirst()); int rowCount = m_outChangesList->rowCount(); m_outChangesList->insertRow(rowCount); m_outChangesList->setItem(rowCount, 0, changeset); m_outChangesList->setItem(rowCount, 1, date); m_outChangesList->setItem(rowCount, 2, summary); } void HgPushDialog::appendOptionArguments(QStringList &args) { if (m_optForce->isChecked()) { args << QLatin1String("--force"); } if (m_optAllowNewBranch->isChecked()) { args << QLatin1String("--new-branch"); } if (m_optInsecure->isChecked()) { args << QLatin1String("--insecure"); } } void HgPushDialog::slotUpdateChangesGeometry() { m_outChangesList->resizeColumnsToContents(); m_outChangesList->resizeRowsToContents(); m_outChangesList->horizontalHeader()->setStretchLastSection(true); } void HgPushDialog::readBigSize() { FileViewHgPluginSettings *settings = FileViewHgPluginSettings::self(); m_bigSize = QSize(settings->pushDialogBigWidth(), settings->pushDialogBigHeight()); } void HgPushDialog::writeBigSize() { qDebug() << "Saving geometry"; FileViewHgPluginSettings *settings = FileViewHgPluginSettings::self(); settings->setPushDialogBigWidth(m_bigSize.width()); settings->setPushDialogBigHeight(m_bigSize.height()); settings->save(); } void HgPushDialog::noChangesMessage() { KMessageBox::information(this, xi18nc("@message:info", "No outgoing changes!")); } diff --git a/hg/syncdialogbase.cpp b/hg/syncdialogbase.cpp index 51fa950..3d228e7 100644 --- a/hg/syncdialogbase.cpp +++ b/hg/syncdialogbase.cpp @@ -1,350 +1,349 @@ /*************************************************************************** * Copyright (C) 2011 by Vishesh Yadav * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * ***************************************************************************/ #include "syncdialogbase.h" #include "hgconfig.h" #include "pathselector.h" #include "fileviewhgpluginsettings.h" #include #include #include #include #include #include #include #include #include #include #include #include #include -#include #include #include HgSyncBaseDialog::HgSyncBaseDialog(DialogType dialogType, QWidget *parent): DialogBase(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, parent), m_haveChanges(false), m_terminated(false), m_dialogType(dialogType) { m_hgw = HgWrapper::instance(); } void HgSyncBaseDialog::setup() { createChangesGroup(); readBigSize(); setupUI(); connect(m_changesButton, SIGNAL(clicked()), this, SLOT(slotGetChanges())); connect(&m_process, SIGNAL(stateChanged(QProcess::ProcessState)), this, SLOT(slotUpdateBusy(QProcess::ProcessState))); connect(&m_main_process, SIGNAL(stateChanged(QProcess::ProcessState)), this, SLOT(slotUpdateBusy(QProcess::ProcessState))); connect(&m_main_process, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(slotOperationComplete(int, QProcess::ExitStatus))); connect(&m_main_process, SIGNAL(error(QProcess::ProcessError)), this, SLOT(slotOperationError())); connect(&m_process, SIGNAL(error(QProcess::ProcessError)), this, SLOT(slotChangesProcessError())); connect(&m_process, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(slotChangesProcessComplete(int, QProcess::ExitStatus))); connect(this, SIGNAL(finished(int)), this, SLOT(slotWriteBigSize())); } void HgSyncBaseDialog::createOptionGroup() { setOptions(); QVBoxLayout *layout = new QVBoxLayout; foreach (QCheckBox *cb, m_options) { layout->addWidget(cb); } m_optionGroup = new QGroupBox(this); m_optionGroup->setLayout(layout); m_optionGroup->setVisible(false); } void HgSyncBaseDialog::setupUI() { // top url bar m_pathSelector = new HgPathSelector; // changes button //FIXME not very good idea. Bad HACK if (m_dialogType == PullDialog) { m_changesButton = new QPushButton(i18nc("@label:button", "Show Incoming Changes")); } else { m_changesButton = new QPushButton(i18nc("@label:button", "Show Outgoing Changes")); } m_changesButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); m_changesButton->setCheckable(true); // dialog's main widget QWidget *widget = new QWidget(this); QVBoxLayout *lay = new QVBoxLayout; lay->addWidget(m_pathSelector); // changes m_changesGroup->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); lay->addWidget(m_changesGroup); // bottom bar QHBoxLayout *bottomLayout = new QHBoxLayout; m_statusProg = new QProgressBar; m_statusProg->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); bottomLayout->addWidget(m_changesButton, Qt::AlignLeft); bottomLayout->addStretch(); bottomLayout->addWidget(m_statusProg); // lay->addLayout(bottomLayout); widget->setLayout(lay); createOptionGroup(); QVBoxLayout *mainLayout = new QVBoxLayout; mainLayout->addWidget(widget); mainLayout->addWidget(m_optionGroup); // bottom button box with OK/Cancel and Options buttons okButton()->setText(xi18nc("@action:button", m_dialogType == PullDialog ? "Pull" : "Push")); okButton()->setIcon(QIcon::fromTheme( m_dialogType == PullDialog ? "git-pull" : "git-push")); m_optionsButton = new QPushButton(buttonBox()); m_optionsButton->setIcon(QIcon::fromTheme("help-about")); switchOptionsButton(true); buttonBox()->addButton(m_optionsButton, QDialogButtonBox::ResetRole); layout()->insertLayout(0, mainLayout); connect(m_optionsButton, SIGNAL(clicked()), this, SLOT(slotOptionsButtonClick())); } void HgSyncBaseDialog::slotGetChanges() { if (m_haveChanges) { m_changesGroup->setVisible(!m_changesGroup->isVisible()); m_changesButton->setChecked(m_changesGroup->isVisible()); if (m_changesGroup->isVisible()) { loadBigSize(); } else { loadSmallSize(); } return; } if (m_process.state() == QProcess::Running) { return; } QStringList args; getHgChangesArguments(args); m_process.setWorkingDirectory(m_hgw->getBaseDir()); m_process.start(QLatin1String("hg"), args); } void HgSyncBaseDialog::slotChangesProcessComplete(int exitCode, QProcess::ExitStatus status) { if (exitCode != 0 || status != QProcess::NormalExit) { QString message = QTextCodec::codecForLocale()->toUnicode(m_process.readAllStandardError()); if (message.isEmpty()) { message = i18nc("@message", "No changes found!"); } KMessageBox::error(this, message); return; } char buffer[512]; /** * unwantedRead boolean to ensure that unwanted information messages * by mercurial are filtered out. * eg. Comparing with /path/to/repository * Searching for changes */ bool unwantedRead = false; /** * hasChanges boolean checks whether there are any changes to be sent * or received and invoke noChangesMessage() if its false */ bool hasChanges = false; while (m_process.readLine(buffer, sizeof(buffer)) > 0) { QString line(QTextCodec::codecForLocale()->toUnicode(buffer)); if (unwantedRead ) { line.remove(QLatin1String("Commit: ")); parseUpdateChanges(line.trimmed()); hasChanges = true;; } else if (line.startsWith(QLatin1String("Commit: "))) { unwantedRead = true; line.remove(QLatin1String("Commit: ")); parseUpdateChanges(line.trimmed()); hasChanges = true; } } if (!hasChanges) { noChangesMessage(); } m_changesGroup->setVisible(true); m_changesButton->setChecked(true); loadBigSize(); m_haveChanges = true; emit changeListAvailable(); } void HgSyncBaseDialog::slotChangesProcessError() { qDebug() << "Cant get changes"; KMessageBox::error(this, i18n("Error!")); } void HgSyncBaseDialog::loadSmallSize() { m_bigSize = size(); resize(m_smallSize); adjustSize(); updateGeometry(); } void HgSyncBaseDialog::loadBigSize() { m_smallSize = size(); resize(m_bigSize); } void HgSyncBaseDialog::slotWriteBigSize() { if (m_changesGroup->isVisible()) { m_bigSize = size(); } writeBigSize(); } void HgSyncBaseDialog::done(int r) { if (r == QDialog::Accepted) { if (m_main_process.state() == QProcess::Running || m_main_process.state() == QProcess::Starting) { qDebug() << "HgWrapper already busy"; return; } QStringList args; QString command = (m_dialogType==PullDialog)?"pull":"push"; args << command; args << m_pathSelector->remote(); appendOptionArguments(args); m_terminated = false; m_main_process.setWorkingDirectory(m_hgw->getBaseDir()); m_main_process.start(QLatin1String("hg"), args); } else { if (m_process.state() == QProcess::Running || m_process.state() == QProcess::Starting || m_main_process.state() == QProcess::Running || m_main_process.state() == QProcess::Starting) { if (m_process.state() == QProcess::Running || m_process.state() == QProcess::Starting) { m_process.terminate(); } if (m_main_process.state() == QProcess::Running || m_main_process.state() == QProcess::Starting) { qDebug() << "terminating pull/push process"; m_terminated = true; m_main_process.terminate(); } } else { QDialog::done(r); } } } void HgSyncBaseDialog::slotOperationComplete(int exitCode, QProcess::ExitStatus status) { if (exitCode == 0 && status == QProcess::NormalExit) { QDialog::done(QDialog::Accepted); } else { if (!m_terminated) { KMessageBox::error(this, i18n("Error!")); } } } void HgSyncBaseDialog::slotOperationError() { KMessageBox::error(this, i18n("Error!")); } void HgSyncBaseDialog::slotUpdateBusy(QProcess::ProcessState state) { if (state == QProcess::Running || state == QProcess::Starting) { m_statusProg->setRange(0, 0); m_changesButton->setEnabled(false); m_changesButton->setChecked(true); okButton()->setDisabled(true); } else { m_statusProg->setRange(0, 100); m_changesButton->setEnabled(true); okButton()->setDisabled(false); } m_statusProg->repaint(); QApplication::processEvents(); } void HgSyncBaseDialog::slotOptionsButtonClick() { if (m_optionsButton->text().contains(">>")) { switchOptionsButton(false); m_optionGroup->setVisible(true); } else { switchOptionsButton(true); m_optionGroup->setVisible(false); } } void HgSyncBaseDialog::switchOptionsButton(bool switchOn) { m_optionsButton->setText(xi18nc("@action:button", "Options") + (switchOn ? " >>" : " <<")); }