diff --git a/git/checkoutdialog.cpp b/git/checkoutdialog.cpp index 6079fdf..9d741c9 100644 --- a/git/checkoutdialog.cpp +++ b/git/checkoutdialog.cpp @@ -1,274 +1,274 @@ /****************************************************************************** * Copyright (C) 2010 by Sebastian Doerner * * * * 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 "checkoutdialog.h" #include "gitwrapper.h" -#include #include #include #include #include +#include #include #include #include #include #include #include #include CheckoutDialog::CheckoutDialog(QWidget* parent): QDialog(parent, Qt::Dialog), m_userEditedNewBranchName(false) { //branch/tag selection this->setWindowTitle(xi18nc("@title:window", "Git Checkout")); m_buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok|QDialogButtonBox::Cancel); QWidget *mainWidget = new QWidget(this); QVBoxLayout *mainLayout = new QVBoxLayout; this->setLayout(mainLayout); mainLayout->addWidget(mainWidget); QPushButton *okButton = m_buttonBox->button(QDialogButtonBox::Ok); okButton->setDefault(true); okButton->setShortcut(Qt::CTRL | Qt::Key_Return); this->connect(m_buttonBox, SIGNAL(accepted()), this, SLOT(accept())); this->connect(m_buttonBox, SIGNAL(rejected()), this, SLOT(reject())); okButton->setText(i18nc("@action:button", "Checkout")); QWidget *boxWidget = new QWidget(this); QVBoxLayout *boxLayout = new QVBoxLayout(boxWidget); mainLayout->addWidget(boxWidget); m_branchSelectGroupBox = new QGroupBox(boxWidget); mainLayout->addWidget(m_branchSelectGroupBox); boxLayout->addWidget(m_branchSelectGroupBox); QGridLayout * gridLayout = new QGridLayout(m_branchSelectGroupBox); m_branchSelectGroupBox->setLayout(gridLayout); m_branchRadioButton = new QRadioButton(i18nc("@option:radio Git Checkout","Branch:"), m_branchSelectGroupBox); m_branchRadioButton->setChecked(true); gridLayout->addWidget(m_branchRadioButton,0,0); m_branchRadioButton->setFocus(); - m_branchComboBox = new KComboBox(false, m_branchSelectGroupBox); + m_branchComboBox = new QComboBox(m_branchSelectGroupBox); gridLayout->addWidget(m_branchComboBox,0,1); QRadioButton * tagRadioButton = new QRadioButton(i18nc("@option:radio Git Checkout", "Tag:"), m_branchSelectGroupBox); gridLayout->addWidget(tagRadioButton,1,0); - m_tagComboBox = new KComboBox(false, m_branchSelectGroupBox); + m_tagComboBox = new QComboBox(m_branchSelectGroupBox); m_tagComboBox->setEnabled(false); gridLayout->addWidget(m_tagComboBox,1,1); //options QGroupBox * optionsGroupBox = new QGroupBox(boxWidget); mainLayout->addWidget(optionsGroupBox); boxLayout->addWidget(optionsGroupBox); optionsGroupBox->setTitle(i18nc("@title:group", "Options")); QGridLayout * optionsGridLayout = new QGridLayout(optionsGroupBox); optionsGroupBox->setLayout(optionsGridLayout); m_newBranchCheckBox = new QCheckBox(i18nc("@option:check", "Create New Branch: "), optionsGroupBox); m_newBranchCheckBox->setToolTip(i18nc("@info:tooltip", "Create a new branch based on a selected branch or tag.")); optionsGridLayout->addWidget(m_newBranchCheckBox, 0,0); mainLayout->addWidget(m_buttonBox); m_newBranchName = new KLineEdit(optionsGroupBox); m_newBranchName->setMinimumWidth(150); m_newBranchName->setClearButtonShown(true); optionsGridLayout->addWidget(m_newBranchName, 0, 1); //initialize alternate color scheme for errors m_errorColors = m_newBranchName->palette(); m_errorColors.setColor(QPalette::Normal, QPalette::Base, Qt::red); m_errorColors.setColor(QPalette::Inactive, QPalette::Base, Qt::red); m_forceCheckBox = new QCheckBox(i18nc("@option:check", "Force"), optionsGroupBox); m_forceCheckBox->setToolTip(i18nc("@info:tooltip", "Discard local changes.")); optionsGridLayout->addWidget(m_forceCheckBox, 1,0); //get branch names GitWrapper * gitWrapper = GitWrapper::instance(); int currentBranchIndex; const QStringList branches = gitWrapper->branches(¤tBranchIndex); m_branchComboBox->addItems(branches); if (currentBranchIndex == -1) { m_branchComboBox->insertItem(0, "(no branch)"); m_branchComboBox->setCurrentIndex(0); } else { m_branchComboBox->setCurrentIndex(currentBranchIndex); } setDefaultNewBranchName(m_branchComboBox->currentText()); //keep local branches to prevent creating an equally named new branch foreach (const QString& b, branches) { if (!b.startsWith(QLatin1String("remotes/"))) { //you CAN create local branches called "remotes/...", but since no sane person //would do that, we save the effort of another call to "git branch" m_branchNames.insert(b); } } //get tag names const QStringList tags = gitWrapper->tags(); m_tagComboBox->addItems(tags); m_tagComboBox->setCurrentIndex(m_tagComboBox->count()-1); if (m_tagComboBox->count() == 0){ tagRadioButton->setEnabled(false); const QString tooltip = i18nc("@info:tooltip", "There are no tags in this repository."); tagRadioButton->setToolTip(tooltip); m_tagComboBox->setToolTip(tooltip); } //signals connect(m_branchRadioButton, SIGNAL(toggled(bool)), this, SLOT(branchRadioButtonToggled(bool))); connect(m_branchComboBox, SIGNAL(currentIndexChanged(QString)), this, SLOT(setDefaultNewBranchName(QString))); connect(m_branchComboBox, SIGNAL(currentIndexChanged(QString)), this, SLOT(setOkButtonState())); connect(m_tagComboBox, SIGNAL(currentIndexChanged(QString)), this, SLOT(setDefaultNewBranchName(QString))); connect(m_newBranchCheckBox, SIGNAL(stateChanged(int)), this, SLOT(newBranchCheckBoxStateToggled(int))); connect(m_newBranchName, SIGNAL(textChanged(QString)), this, SLOT(setOkButtonState())); connect(m_newBranchName, SIGNAL(textEdited(QString)), this, SLOT(noteUserEditedNewBranchName())); //set initial widget states newBranchCheckBoxStateToggled(Qt::Unchecked); } QString CheckoutDialog::checkoutIdentifier() const { QString identifier = m_branchComboBox->isEnabled() ? m_branchComboBox->currentText() : m_tagComboBox->currentText(); if (identifier.length()==0 || identifier.at(0)=='(') { identifier = ""; } return identifier; } bool CheckoutDialog::force() const { return m_forceCheckBox->isChecked(); } QString CheckoutDialog::newBranchName() const { if (m_newBranchCheckBox->isChecked()) { return m_newBranchName->text().trimmed(); } else { return QString(); } } void CheckoutDialog::branchRadioButtonToggled(bool checked) { m_branchComboBox->setEnabled(checked); m_tagComboBox->setEnabled(!checked); setDefaultNewBranchName(checked ? m_branchComboBox->currentText() : m_tagComboBox->currentText()); setOkButtonState(); } void CheckoutDialog::newBranchCheckBoxStateToggled(int state) { m_newBranchName->setEnabled(state == Qt::Checked); m_branchSelectGroupBox->setTitle( state == Qt::Checked ? i18nc("@title:group", "Branch Base") : i18nc("@title:group", "Checkout")); if (state == Qt::Checked) { m_newBranchName->setFocus(Qt::TabFocusReason); } setOkButtonState(); } void CheckoutDialog::setOkButtonState() { //default to enabled bool enableButton = true; bool newNameError = false; QPushButton *okButton = m_buttonBox->button(QDialogButtonBox::Ok); //------------disable on these conditions---------------// if (m_newBranchCheckBox->isChecked()) { const QString newBranchName = m_newBranchName->text().trimmed(); if (newBranchName.isEmpty()){ enableButton = false; newNameError = true; const QString tt = i18nc("@info:tooltip", "You must enter a valid name for the new branch first."); m_newBranchName->setToolTip(tt); okButton->setToolTip(tt)); } if (m_branchNames.contains(newBranchName)) { enableButton = false; newNameError = true; const QString tt = i18nc("@info:tooltip", "A branch with the name '%1' already exists.", newBranchName); m_newBranchName->setToolTip(tt); okButton->setToolTip(tt)); } if (newBranchName.contains(QRegExp("\\s"))) { enableButton = false; newNameError = true; const QString tt = i18nc("@info:tooltip", "Branch names may not contain any whitespace."); m_newBranchName->setToolTip(tt); okButton->setToolTip(tt)); } } //if we create a new branch and no valid branch is selected we create one based on the currently checked out version else if (m_branchRadioButton->isChecked() && m_branchComboBox->currentText().at(0) == '('){ enableButton = false; okButton->setToolTip(i18nc("@info:tooltip", "You must select a valid branch first.")); } //------------------------------------------------------// setLineEditErrorModeActive(newNameError); okButton->setEnabled(enableButton); if (!newNameError) { m_newBranchName->setToolTip(QString()); } if (enableButton) { okButton->setToolTip(QString()); } } void CheckoutDialog::setDefaultNewBranchName(const QString& baseBranchName) { if (!m_userEditedNewBranchName) { if (baseBranchName.startsWith('(')) { m_newBranchName->setText(""); } else { m_newBranchName->setText(i18nc("@item:intext Prepended to the current branch name " "to get the default name for a newly created branch", "branch") + '_' + baseBranchName); } } } void CheckoutDialog::noteUserEditedNewBranchName() { m_userEditedNewBranchName = true; } void CheckoutDialog::setLineEditErrorModeActive(bool active) { m_newBranchName->setPalette(active ? m_errorColors : QPalette()); } diff --git a/git/checkoutdialog.h b/git/checkoutdialog.h index dcf45b5..fe7ceb5 100644 --- a/git/checkoutdialog.h +++ b/git/checkoutdialog.h @@ -1,90 +1,90 @@ /****************************************************************************** * Copyright (C) 2010 by Sebastian Doerner * * * * 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 CHECKOUTDIALOG_H #define CHECKOUTDIALOG_H #include #include #include -class KComboBox; class KLineEdit; class QCheckBox; +class QComboBox; class QDialogButtonBox; class QGroupBox; class QRadioButton; /** * @brief The dialog for checking out Branches or Tags in Git. */ class CheckoutDialog : public QDialog { Q_OBJECT public: CheckoutDialog(QWidget* parent = 0); /** * Returns the name of the selected tag or branch to be checkout out * @returns The name of the selected tag or branch */ QString checkoutIdentifier() const; /** * @returns True if the user selected a forced checkout, false otherwise. */ bool force() const; /** * @returns The user selected name of the new branch, if a new branch is to be * created, empty String otherwise. */ QString newBranchName() const; private slots: void branchRadioButtonToggled(bool checked); void newBranchCheckBoxStateToggled(int state); /** * Checks whether the values of all relevant widgets are valid. * Enables or disables the OK button and sets tooltips accordingly. */ void setOkButtonState(); void noteUserEditedNewBranchName(); /** * Inserts a default name for the new branch into m_newBranchName unless the user * has already edited the content. * @param baseBranchName The base name to derive the new name of. */ void setDefaultNewBranchName(const QString & baseBranchName); private: inline void setLineEditErrorModeActive(bool active); private: ///@brief true if the user has manually edited the branchName, false otherwise bool m_userEditedNewBranchName; QSet m_branchNames; QPalette m_errorColors; QDialogButtonBox *m_buttonBox; QGroupBox * m_branchSelectGroupBox; QRadioButton * m_branchRadioButton; - KComboBox * m_branchComboBox; - KComboBox * m_tagComboBox; + QComboBox * m_branchComboBox; + QComboBox * m_tagComboBox; QCheckBox * m_newBranchCheckBox; KLineEdit * m_newBranchName; QCheckBox * m_forceCheckBox; }; #endif // CHECKOUTDIALOG_H diff --git a/git/pulldialog.cpp b/git/pulldialog.cpp index d6c28f0..48cf9d6 100644 --- a/git/pulldialog.cpp +++ b/git/pulldialog.cpp @@ -1,114 +1,114 @@ /****************************************************************************** * Copyright (C) 2010 by Sebastian Doerner * * * * 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 "gitwrapper.h" -#include #include #include +#include #include #include #include #include #include #include PullDialog::PullDialog(QWidget* parent): QDialog(parent, Qt::Dialog) { this->setWindowTitle(xi18nc("@title:window", "Git Pull")); QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok|QDialogButtonBox::Cancel); QWidget *mainWidget = new QWidget(this); QVBoxLayout *mainLayout = new QVBoxLayout; this->setLayout(mainLayout); mainLayout->addWidget(mainWidget); QPushButton *okButton = m_buttonBox->button(QDialogButtonBox::Ok); okButton->setDefault(true); okButton->setShortcut(Qt::CTRL | Qt::Key_Return); this->connect(m_buttonBox, SIGNAL(accepted()), this, SLOT(accept())); this->connect(m_buttonBox, SIGNAL(rejected()), this, SLOT(reject())); okButton->setText(i18nc("@action:button", "Pull")); QWidget * boxWidget = new QWidget(this); QVBoxLayout * boxLayout = new QVBoxLayout(boxWidget); mainLayout->addWidget(boxWidget); QGroupBox * sourceGroupBox = new QGroupBox(boxWidget); mainLayout->addWidget(sourceGroupBox); boxLayout->addWidget(sourceGroupBox); sourceGroupBox->setTitle(i18nc("@title:group The source to pull from", "Source")); QHBoxLayout * sourceHBox = new QHBoxLayout(sourceGroupBox); sourceGroupBox->setLayout(sourceHBox); mainLayout->addWidget(m_buttonBox); QLabel * remoteLabel = new QLabel(i18nc("@label:listbox a git remote", "Remote:"), sourceGroupBox); sourceHBox->addWidget(remoteLabel); - m_remoteComboBox = new KComboBox(false, sourceGroupBox); + m_remoteComboBox = new QComboBox(sourceGroupBox); sourceHBox->addWidget(m_remoteComboBox); QLabel * remoteBranchLabel = new QLabel(i18nc("@label:listbox", "Remote branch:"), sourceGroupBox); sourceHBox->addWidget(remoteBranchLabel); - m_remoteBranchComboBox = new KComboBox(false, sourceGroupBox); + m_remoteBranchComboBox = new QComboBox(sourceGroupBox); sourceHBox->addWidget(m_remoteBranchComboBox); //populate UI GitWrapper * gitWrapper = GitWrapper::instance(); //get sources m_remoteComboBox->addItems(gitWrapper->pullRemotes()); //get branch names int currentBranchIndex; QStringList branches = gitWrapper->branches(¤tBranchIndex); foreach (const QString& branch, branches) { if (branch.startsWith(QLatin1String("remotes/"))) { const QString remote = branch.section('/', 1, 1); const QString name = branch.section('/', 2); m_remoteBranches[remote] << name; } } remoteSelectionChanged(m_remoteComboBox->currentText()); //Signals connect(m_remoteComboBox, SIGNAL(currentIndexChanged(QString)), this, SLOT(remoteSelectionChanged(QString))); } QString PullDialog::source() const { return m_remoteComboBox->currentText(); } QString PullDialog::remoteBranch() const { return m_remoteBranchComboBox->currentText(); } void PullDialog::remoteSelectionChanged(const QString& newRemote) { m_remoteBranchComboBox->clear(); m_remoteBranchComboBox->addItems(m_remoteBranches.value(newRemote)); QPushButton *okButton = m_buttonBox->button(QDialogButtonBox::Ok); okButton->setEnabled(m_remoteBranchComboBox->count() > 0); } diff --git a/git/pulldialog.h b/git/pulldialog.h index e71ebe3..0c55dfc 100644 --- a/git/pulldialog.h +++ b/git/pulldialog.h @@ -1,45 +1,45 @@ /****************************************************************************** * Copyright (C) 2010 by Sebastian Doerner * * * * 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 PULLDIALOG_H #define PULLDIALOG_H #include -class KComboBox; +class QComboBox; class QDialogButtonBox; class PullDialog : public QDialog { Q_OBJECT public: PullDialog(QWidget* parent = 0); QString source() const; QString remoteBranch() const; private: QDialogButtonBox *m_buttonBox; - KComboBox * m_remoteComboBox; - KComboBox * m_remoteBranchComboBox; + QComboBox * m_remoteComboBox; + QComboBox * m_remoteBranchComboBox; QHash m_remoteBranches; private slots: void remoteSelectionChanged(const QString& newRemote); }; #endif // PULLDIALOG_H diff --git a/git/pushdialog.cpp b/git/pushdialog.cpp index 4339acc..210fc40 100644 --- a/git/pushdialog.cpp +++ b/git/pushdialog.cpp @@ -1,169 +1,169 @@ /****************************************************************************** * Copyright (C) 2010 by Sebastian Doerner * * * * 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 "gitwrapper.h" -#include #include #include #include +#include #include #include #include #include #include #include PushDialog::PushDialog (QWidget* parent ): QDialog (parent, Qt::Dialog) { this->setWindowTitle(xi18nc("@title:window", "Git Push")); QDialogButtonBox *m_buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok|QDialogButtonBox::Cancel); QWidget *mainWidget = new QWidget(this); QVBoxLayout *mainLayout = new QVBoxLayout; this->setLayout(mainLayout); mainLayout->addWidget(mainWidget); QPushButton *okButton = m_buttonBox->button(QDialogButtonBox::Ok); okButton->setDefault(true); okButton->setShortcut(Qt::CTRL | Qt::Key_Return); this->connect(m_buttonBox, SIGNAL(accepted()), this, SLOT(accept())); this->connect(m_buttonBox, SIGNAL(rejected()), this, SLOT(reject())); m_buttonBox->button(QDialogButtonBox::Ok)->setDefault(true); okButton->setText(i18nc("@action:button", "Push")); QWidget * boxWidget = new QWidget(this); QVBoxLayout * boxLayout = new QVBoxLayout(boxWidget); mainLayout->addWidget(boxWidget); //Destination QGroupBox * destinationGroupBox = new QGroupBox(boxWidget); mainLayout->addWidget(destinationGroupBox); boxLayout->addWidget(destinationGroupBox); destinationGroupBox->setTitle(i18nc("@title:group The remote host", "Destination")); QHBoxLayout * destinationHBox = new QHBoxLayout(destinationGroupBox); destinationGroupBox->setLayout(destinationHBox); QLabel * remoteLabel = new QLabel(i18nc("@label:listbox a git remote", "Remote:"), destinationGroupBox); destinationHBox->addWidget(remoteLabel); - m_remoteComboBox = new KComboBox(false, destinationGroupBox); + m_remoteComboBox = new QComboBox(destinationGroupBox); destinationHBox->addWidget(m_remoteComboBox); destinationHBox->addStretch(); //Branches QGroupBox* branchesGroupBox = new QGroupBox(boxWidget); mainLayout->addWidget(branchesGroupBox); boxLayout->addWidget(branchesGroupBox); branchesGroupBox->setTitle(i18nc("@title:group", "Branches")); QHBoxLayout * branchesHBox = new QHBoxLayout(branchesGroupBox); branchesGroupBox->setLayout(branchesHBox); QLabel * localBranchLabel = new QLabel(i18nc("@label:listbox", "Local Branch:"), branchesGroupBox); branchesHBox->addWidget(localBranchLabel); - m_localBranchComboBox = new KComboBox(false, branchesGroupBox); + m_localBranchComboBox = new QComboBox(branchesGroupBox); branchesHBox->addWidget(m_localBranchComboBox); branchesHBox->addStretch(); QLabel * remoteBranchLabel = new QLabel(i18nc("@label:listbox", "Remote Branch:"), branchesGroupBox); branchesHBox->addWidget(remoteBranchLabel); - m_remoteBranchComboBox = new KComboBox(false, branchesGroupBox); + m_remoteBranchComboBox = new QComboBox(branchesGroupBox); branchesHBox->addWidget(m_remoteBranchComboBox); QGroupBox* optionsGroupBox = new QGroupBox(boxWidget); mainLayout->addWidget(optionsGroupBox); boxLayout->addWidget(optionsGroupBox); optionsGroupBox->setTitle(i18nc("@title:group", "Options")); QHBoxLayout * optionsHBox = new QHBoxLayout(optionsGroupBox); optionsGroupBox->setLayout(optionsHBox); m_forceCheckBox = new QCheckBox(i18nc("@option:check", "Force"), optionsGroupBox); m_forceCheckBox->setToolTip(i18nc("@info:tooltip", "Proceed even if the remote branch is not an ancestor of the local branch.")); optionsHBox->addWidget(m_forceCheckBox); mainLayout->addWidget(m_buttonBox); //populate UI GitWrapper * gitWrapper = GitWrapper::instance(); //get destinations QStringList remotes = gitWrapper->pushRemotes(); m_remoteComboBox->addItems(remotes); //get branch names int currentBranchIndex; QStringList branches = gitWrapper->branches(¤tBranchIndex); foreach (const QString& branch, branches) { if (branch.startsWith(QLatin1String("remotes/"))) { const QString remote = branch.section('/', 1, 1); const QString name = branch.section('/', 2); m_remoteBranches[remote] << name; } else { m_localBranchComboBox->addItem(branch); } } m_localBranchComboBox->setCurrentText(branches.at(currentBranchIndex)); remoteSelectionChanged(m_remoteComboBox->currentText()); //Signals connect(m_remoteComboBox, SIGNAL(currentIndexChanged(QString)), this, SLOT(remoteSelectionChanged(QString))); connect(m_localBranchComboBox, SIGNAL(currentIndexChanged(QString)), this, SLOT(localBranchSelectionChanged(QString))); } QString PushDialog::destination() const { return m_remoteComboBox->currentText(); } QString PushDialog::localBranch() const { return m_localBranchComboBox->currentText(); } QString PushDialog::remoteBranch() const { return m_remoteBranchComboBox->currentText(); } bool PushDialog::force() const { return m_forceCheckBox->isChecked(); } void PushDialog::remoteSelectionChanged(const QString& newRemote) { m_remoteBranchComboBox->clear(); m_remoteBranchComboBox->addItems(m_remoteBranches.value(newRemote)); localBranchSelectionChanged(m_localBranchComboBox->currentText()); } void PushDialog::localBranchSelectionChanged(const QString& newLocalBranch) { //select matching remote branch if possible const int index = m_remoteBranchComboBox->findText(newLocalBranch); if (index != -1) { m_remoteBranchComboBox->setCurrentIndex(index); } QPushButton *okButton = m_buttonBox->button(QDialogButtonBox::Ok); okButton->setEnabled(m_remoteBranchComboBox->count() > 0); } diff --git a/git/pushdialog.h b/git/pushdialog.h index 21e065c..01a7910 100644 --- a/git/pushdialog.h +++ b/git/pushdialog.h @@ -1,52 +1,52 @@ /****************************************************************************** * Copyright (C) 2010 by Sebastian Doerner * * * * 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 PUSHDIALOG_H #define PUSHDIALOG_H #include -class KComboBox; class QCheckBox; +class QComboBox; class QDialogButtonBox; class PushDialog : public QDialog { Q_OBJECT public: PushDialog(QWidget* parent = 0); QString destination() const; QString localBranch() const; QString remoteBranch() const; bool force() const; private slots: void remoteSelectionChanged(const QString& newRemote); void localBranchSelectionChanged(const QString& newLocalBranch); private: QHash m_remoteBranches; - KComboBox * m_remoteComboBox; - KComboBox * m_localBranchComboBox; - KComboBox * m_remoteBranchComboBox; + QComboBox * m_remoteComboBox; + QComboBox * m_localBranchComboBox; + QComboBox * m_remoteBranchComboBox; QCheckBox * m_forceCheckBox; QDialogButtonBox * m_buttonBox; }; #endif // PUSHDIALOG_H diff --git a/git/tagdialog.cpp b/git/tagdialog.cpp index 0eaa3b4..9354146 100644 --- a/git/tagdialog.cpp +++ b/git/tagdialog.cpp @@ -1,159 +1,159 @@ /****************************************************************************** * Copyright (C) 2010 by Johannes Steffen * * Copyright (C) 2010 by Sebastian Doerner * * * * 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 "tagdialog.h" #include "gitwrapper.h" -#include #include #include #include #include #include +#include #include #include #include #include #include #include #include TagDialog::TagDialog (QWidget* parent ): QDialog (parent, Qt::Dialog), m_localCodec(QTextCodec::codecForLocale()) { this->setWindowTitle(xi18nc("@title:window", "Git Create Tag")); QDialogButtonBox *m_buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok|QDialogButtonBox::Cancel); QWidget *mainWidget = new QWidget(this); QVBoxLayout *mainLayout = new QVBoxLayout; this->setLayout(mainLayout); mainLayout->addWidget(mainWidget); QPushButton *okButton = m_buttonBox->button(QDialogButtonBox::Ok); okButton->setDefault(true); okButton->setShortcut(Qt::CTRL | Qt::Key_Return); this->connect(m_buttonBox, SIGNAL(accepted()), this, SLOT(accept())); this->connect(m_buttonBox, SIGNAL(rejected()), this, SLOT(reject())); m_buttonBox->button(QDialogButtonBox::Ok)->setDefault(true); okButton->setText(i18nc("@action:button", "Create Tag")); QWidget* boxWidget = new QWidget(this); QVBoxLayout* boxLayout = new QVBoxLayout(boxWidget); mainLayout->addWidget(boxWidget); QGroupBox* tagInformationGroupBox = new QGroupBox(boxWidget); mainLayout->addWidget(tagInformationGroupBox); boxLayout->addWidget(tagInformationGroupBox); tagInformationGroupBox->setTitle(i18nc("@title:group", "Tag Information")); QVBoxLayout * tagInformationLayout = new QVBoxLayout(tagInformationGroupBox); tagInformationGroupBox->setLayout(tagInformationLayout); QLabel* nameLabel = new QLabel(i18nc("@label:textbox", "Tag Name:"), tagInformationGroupBox); tagInformationLayout->addWidget(nameLabel); m_tagNameTextEdit = new KLineEdit(tagInformationGroupBox); tagInformationLayout->addWidget(m_tagNameTextEdit); setOkButtonState(); connect(m_tagNameTextEdit, SIGNAL(textChanged(QString)), this, SLOT(setOkButtonState())); QLabel* messageLabel = new QLabel(i18nc("@label:textbox", "Tag Message:"), tagInformationGroupBox); tagInformationLayout->addWidget(messageLabel); m_tagMessageTextEdit = new KTextEdit(tagInformationGroupBox); m_tagMessageTextEdit->setLineWrapMode(QTextEdit::FixedColumnWidth); m_tagMessageTextEdit->setLineWrapColumnOrWidth(72); tagInformationLayout->addWidget(m_tagMessageTextEdit); QGroupBox* attachToGroupBox = new QGroupBox(boxWidget); mainLayout->addWidget(attachToGroupBox); boxLayout->addWidget(attachToGroupBox); attachToGroupBox->setTitle(i18nc("@title:group", "Attach to")); mainLayout->addWidget(m_buttonBox); QHBoxLayout* attachToLayout = new QHBoxLayout(); attachToGroupBox->setLayout(attachToLayout); QLabel* branchLabel = new QLabel(i18nc("@label:listbox", "Branch:"), attachToGroupBox); attachToLayout->addWidget(branchLabel); - m_branchComboBox = new KComboBox(false, attachToGroupBox); + m_branchComboBox = new QComboBox(attachToGroupBox); attachToLayout->addWidget(m_branchComboBox); attachToLayout->addStretch(); this->resize(QSize(300,200)); //initialize alternate color scheme for errors m_errorColors = m_tagNameTextEdit->palette(); m_errorColors.setColor(QPalette::Normal, QPalette::Base, Qt::red); m_errorColors.setColor(QPalette::Inactive, QPalette::Base, Qt::red); //get branch & tag names GitWrapper * gitWrapper = GitWrapper::instance(); int currentIndex; const QStringList branches = gitWrapper->branches(¤tIndex); m_branchComboBox->addItems(branches); m_branchComboBox->setCurrentIndex(currentIndex); gitWrapper->tagSet(m_tagNames); } QByteArray TagDialog::tagMessage() const { return m_localCodec->fromUnicode(m_tagMessageTextEdit->toPlainText()); } QString TagDialog::tagName() const { return m_tagNameTextEdit->text().trimmed(); } QString TagDialog::baseBranch() const { return m_branchComboBox->currentText(); } void TagDialog::setOkButtonState() { const QString tagName = m_tagNameTextEdit->text().trimmed(); QString toolTip; if (tagName.isEmpty()) { toolTip = i18nc("@info:tooltip", "You must enter a tag name first."); } else if (tagName.contains(QRegExp("\\s"))) { toolTip = i18nc("@info:tooltip", "Tag names may not contain any whitespace."); } else if (m_tagNames.contains(tagName)) { toolTip = i18nc("@info:tooltip", "A tag named '%1' already exists.", tagName); } QPushButton *okButton = m_buttonBox->button(QDialogButtonBox::Ok); okButton->setEnabled(toolTip.isEmpty()); setLineEditErrorModeActive(!toolTip.isEmpty()); m_tagNameTextEdit->setToolTip(toolTip); okButton->setToolTip(toolTip)); } void TagDialog::setLineEditErrorModeActive(bool active) { m_tagNameTextEdit->setPalette(active ? m_errorColors : QPalette()); } diff --git a/git/tagdialog.h b/git/tagdialog.h index e5895ff..0fa9f1e 100644 --- a/git/tagdialog.h +++ b/git/tagdialog.h @@ -1,70 +1,70 @@ /****************************************************************************** * Copyright (C) 2010 by Johannes Steffen * * * * 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 TAGDIALOG_H #define TAGDIALOG_H #include #include class KTextEdit; class KLineEdit; -class KComboBox; +class QComboBox; class QDialogButtonBox; class QTextCodec; class QRadioButton; class TagDialog : public QDialog { Q_OBJECT public: TagDialog(QWidget* parent = 0); /** * Returns the tag message given by the user. * @returns The tag message. */ QByteArray tagMessage() const; /** * Returns the tag name given by the user. * @return The tag name. */ QString tagName() const; /** * @returns The name of the branch the tag should point to or HEAD if the tag should point to the current HEAD. */ QString baseBranch() const; private slots: void setOkButtonState(); private: inline void setLineEditErrorModeActive(bool active); private: QSet m_tagNames; KTextEdit* m_tagMessageTextEdit; KLineEdit* m_tagNameTextEdit; - KComboBox* m_branchComboBox; + QComboBox* m_branchComboBox; QDialogButtonBox* m_buttonBox; QRadioButton* branchRadioButton; QTextCodec* m_localCodec; QPalette m_errorColors; }; #endif // TAGDIALOG_H