Skip to content

Commit

Permalink
#1192, implemented git warning dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
pbek committed Apr 23, 2019
1 parent cb03a2b commit 8601aac
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 6 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# QOwnNotes Changelog

## 19.4.5
- you now will get a warning dialog if your git client couldn't be executed when
a git command is issued (for [#1192](https://github.com/pbek/QOwnNotes/issues/1192))
- you will be able to turn off that dialog
- more checksum generation improvements for the AUR and added checksum support
to the build processes of Launchpad Snap, Slackware and Gentoo
(for [#1175](https://github.com/pbek/QOwnNotes/issues/1175))
Expand Down
18 changes: 15 additions & 3 deletions src/utils/git.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include <QtCore/QSettings>
#include "git.h"
#include "misc.h"
#include "gui.h"


/**
Expand Down Expand Up @@ -56,7 +57,8 @@ void Utils::Git::commitCurrentNoteFolder() {
* @param process
* @return
*/
bool Utils::Git::executeCommand(QString command, QProcess *process) {
bool Utils::Git::executeCommand(QString command, QProcess *process,
bool withErrorDialog) {
if (process == Q_NULLPTR) {
process = new QProcess();
}
Expand All @@ -65,6 +67,14 @@ bool Utils::Git::executeCommand(QString command, QProcess *process) {

if (!process->waitForFinished()) {
qWarning() << "Command '" + command + "' failed";

if (withErrorDialog) {
Utils::Gui::warning(
Q_NULLPTR, QObject::tr("Command failed!"),
QObject::tr("The command <code>%1</code> failed!").arg(
command), "command-failed");
}

return false;
}

Expand All @@ -90,8 +100,10 @@ bool Utils::Git::executeCommand(QString command, QProcess *process) {
* @param process
* @return
*/
bool Utils::Git::executeGitCommand(QString arguments, QProcess *process) {
return executeCommand("\""+ gitCommand() + "\" " + arguments, process);
bool Utils::Git::executeGitCommand(QString arguments, QProcess *process,
bool withErrorDialog) {
return executeCommand("\"" + gitCommand() + "\" " + arguments, process,
withErrorDialog);
}

/**
Expand Down
6 changes: 4 additions & 2 deletions src/utils/git.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@
namespace Utils {
namespace Git {
void commitCurrentNoteFolder();
bool executeCommand(QString command, QProcess *process = Q_NULLPTR);
bool executeCommand(QString command, QProcess *process = Q_NULLPTR,
bool withErrorDialog = false);
bool executeGitCommand(QString arguments,
QProcess *process = Q_NULLPTR);
QProcess *process = Q_NULLPTR,
bool withErrorDialog = true);
QString gitCommand();
void showLog(QString filePath);
bool hasLogCommand();
Expand Down
21 changes: 21 additions & 0 deletions src/utils/gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,27 @@ QMessageBox::StandardButton Utils::Gui::question(
identifier, buttons, defaultButton);
}

/**
* Shows a warning message box with a checkbox to override the message box in
* the future
*
* @param parent
* @param title
* @param text
* @param identifier
* @param buttons
* @param defaultButton
* @return
*/
QMessageBox::StandardButton Utils::Gui::warning(
QWidget *parent, const QString &title, const QString &text,
const QString &identifier,
QMessageBox::StandardButtons buttons,
QMessageBox::StandardButton defaultButton) {
return showMessageBox(parent, QMessageBox::Icon::Warning, title, text,
identifier, buttons, defaultButton);
}

/**
* Shows a message box with a checkbox to override the message box in the future
*
Expand Down
9 changes: 8 additions & 1 deletion src/utils/gui.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ namespace Utils {
QWidget *parent, const QString &title, const QString &text,
const QString &identifier = "default",
QMessageBox::StandardButtons buttons = QMessageBox::Ok,
QMessageBox::StandardButton defaultButton = QMessageBox::NoButton);
QMessageBox::StandardButton defaultButton = QMessageBox::Ok);

QMessageBox::StandardButton question(
QWidget *parent, const QString &title, const QString &text,
Expand All @@ -71,6 +71,13 @@ namespace Utils {
QMessageBox::StandardButtons(QMessageBox::Yes | QMessageBox::No),
QMessageBox::StandardButton defaultButton = QMessageBox::NoButton);

QMessageBox::StandardButton warning(
QWidget *parent, const QString &title, const QString &text,
const QString &identifier = "default",
QMessageBox::StandardButtons buttons =
QMessageBox::StandardButtons(QMessageBox::Ok),
QMessageBox::StandardButton defaultButton = QMessageBox::Ok);

bool userDataInTreeWidgetExists(QTreeWidget *treeWidget,
QVariant userData,
int column = 0);
Expand Down

0 comments on commit 8601aac

Please sign in to comment.