Fuel

Diff
Login

Differences From Artifact [c3c91806c4]:

To Artifact [80d52a1f0b]:


14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include "CommitDialog.h"
#include "FileActionDialog.h"

#define SILENT_STATUS true
#define COUNTOF(array) (sizeof(array)/sizeof(array[0]))

#ifdef QT_WS_WIN
	#define EOL_MARK "\r\n"
#else
	#define EOL_MARK "\n"
#endif

enum
{
	COLUMN_STATUS,
	COLUMN_PATH,
	COLUMN_FILENAME,







|

|







14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include "CommitDialog.h"
#include "FileActionDialog.h"

#define SILENT_STATUS true
#define COUNTOF(array) (sizeof(array)/sizeof(array[0]))

#ifdef QT_WS_WIN
	QString EOL_MARK("\r\n");
#else
	QString EOL_MARK("\n");
#endif

enum
{
	COLUMN_STATUS,
	COLUMN_PATH,
	COLUMN_FILENAME,
83
84
85
86
87
88
89








90
91
92
93
94
95
96
		connect(recentWorkspaceActs[i], SIGNAL(triggered()), this, SLOT(onOpenRecent()));
		ui->menuFile->insertAction(recent_sep, recentWorkspaceActs[i]);
	}

	statusLabel = new QLabel();
	statusLabel->setMinimumSize( statusLabel->sizeHint() );
	ui->statusBar->addWidget( statusLabel, 1 );









	loadSettings();
	refresh();
	rebuildRecent();
	fossilAbort = false;
}








>
>
>
>
>
>
>
>







83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
		connect(recentWorkspaceActs[i], SIGNAL(triggered()), this, SLOT(onOpenRecent()));
		ui->menuFile->insertAction(recent_sep, recentWorkspaceActs[i]);
	}

	statusLabel = new QLabel();
	statusLabel->setMinimumSize( statusLabel->sizeHint() );
	ui->statusBar->addWidget( statusLabel, 1 );

// Native applications on OSX don't use menu icons
#ifdef Q_WS_MACX
	foreach(QAction *a, ui->menuBar->actions())
		a->setIconVisibleInMenu(false);
	foreach(QAction *a, ui->menuFile->actions())
		a->setIconVisibleInMenu(false);
#endif

	loadSettings();
	refresh();
	rebuildRecent();
	fossilAbort = false;
}

482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
	process.start(fossil, args);
	if(!process.waitForStarted())
	{
		log("Could not start fossil executable '" + fossil + "''\n");
		return false;
	}

	const char *ans_yes = "y" EOL_MARK;
	const char *ans_no = "n" EOL_MARK;
	const char *ans_always = "a" EOL_MARK;

	fossilAbort = false;
	QString buffer;

	while(process.state()==QProcess::Running)
	{
		if(fossilAbort)







|
|
|







490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
	process.start(fossil, args);
	if(!process.waitForStarted())
	{
		log("Could not start fossil executable '" + fossil + "''\n");
		return false;
	}

	QString ans_yes = 'y' + EOL_MARK;
	QString ans_no = 'n' + EOL_MARK;
	QString ans_always = 'a' + EOL_MARK;

	fossilAbort = false;
	QString buffer;

	while(process.state()==QProcess::Running)
	{
		if(fossilAbort)
509
510
511
512
513
514
515
516
517
518


519
520
521
522
523
524
525
			continue;

		// Extract the last line
		int last_line_start = buffer.lastIndexOf(EOL_MARK);

		QString last_line;
		if(last_line_start != -1)
			last_line = buffer.mid(last_line_start+COUNTOF(EOL_MARK));
		else
			last_line = buffer;



		last_line = last_line.trimmed();

		// Check if we have a query
		bool ends_qmark = !last_line.isEmpty() && last_line[last_line.length()-1]=='?';
		bool have_yn_query = last_line.toLower().indexOf("y/n")!=-1;
		int have_yna_query = last_line.toLower().indexOf("a=always/y/n")!=-1;







|


>
>







517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
			continue;

		// Extract the last line
		int last_line_start = buffer.lastIndexOf(EOL_MARK);

		QString last_line;
		if(last_line_start != -1)
			last_line = buffer.mid(last_line_start+EOL_MARK.length());
		else
			last_line = buffer;

		QChar cc = buffer[last_line_start];

		last_line = last_line.trimmed();

		// Check if we have a query
		bool ends_qmark = !last_line.isEmpty() && last_line[last_line.length()-1]=='?';
		bool have_yn_query = last_line.toLower().indexOf("y/n")!=-1;
		int have_yna_query = last_line.toLower().indexOf("a=always/y/n")!=-1;
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563

564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
























585
586
587
588
589
590
591
				log(line+"\n");
		}

		// Remove everything we processed
		buffer = buffer.mid(last_line_start);

		// Now process any query
		if(have_query && have_yn_query)
		{
			QString query = ParseFossilQuery(last_line);

			int res =  QMessageBox::question(this, "Fossil", query, QMessageBox::Yes|QMessageBox::No, QMessageBox::No);
			if(res==QMessageBox::Yes)
			{
				process.write(ans_yes, COUNTOF(ans_yes));
				log("Y\n");
			}
			else
			{
				process.write(ans_no, COUNTOF(ans_no));
				log("N\n");
			}

			buffer.clear();

		}
		else if(have_query && have_yna_query)
		{
			QString query = ParseFossilQuery(query);

			int res =  QMessageBox::question(this, "Fossil", query, QMessageBox::Yes|QMessageBox::No|QMessageBox::YesToAll, QMessageBox::No);
			if(res==QDialogButtonBox::Yes)
			{
				process.write(ans_yes, COUNTOF(ans_yes));
				log("Y\n");
			}
			else if(res==QDialogButtonBox::YesToAll)
			{
				process.write(ans_always, COUNTOF(ans_always));
				log("A\n");
			}
			else
			{
				process.write(ans_no, COUNTOF(ans_no));
				log("N\n");
			}
























			buffer.clear();
		}
	}

	// Must be finished by now
	Q_ASSERT(process.state()==QProcess::NotRunning);








|



|
|
<
<
<
<
|
<
<
<
<
|
|
>
|
<
<
<
<
<


|




|




|


>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







550
551
552
553
554
555
556
557
558
559
560
561
562




563




564
565
566
567





568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
				log(line+"\n");
		}

		// Remove everything we processed
		buffer = buffer.mid(last_line_start);

		// Now process any query
		if(have_query && have_yna_query)
		{
			QString query = ParseFossilQuery(last_line);

			QMessageBox mb(QMessageBox::Question, "Fossil", query, QMessageBox::Yes|QMessageBox::No|QMessageBox::YesToAll, this, Qt::Dialog | Qt::MSWindowsFixedSizeDialogHint | Qt::Sheet );
			mb.setDefaultButton(QMessageBox::No);




			mb.setWindowModality(Qt::WindowModal);




			mb.setModal(true);
			mb.exec();
			int res = mb.standardButton(mb.clickedButton());






			if(res==QDialogButtonBox::Yes)
			{
				process.write(ans_yes.toAscii());
				log("Y\n");
			}
			else if(res==QDialogButtonBox::YesToAll)
			{
				process.write(ans_always.toAscii());
				log("A\n");
			}
			else
			{
				process.write(ans_no.toAscii());
				log("N\n");
			}
			buffer.clear();
		}
		else if(have_query && have_yn_query)
		{
			QString query = ParseFossilQuery(last_line);

			QMessageBox mb(QMessageBox::Question, "Fossil", query, QMessageBox::Yes|QMessageBox::No|QMessageBox::YesToAll, this, Qt::Dialog | Qt::MSWindowsFixedSizeDialogHint | Qt::Sheet );
			mb.setDefaultButton(QMessageBox::No);
			mb.setWindowModality(Qt::WindowModal);
			mb.setModal(true);
			mb.exec();
			int res = mb.standardButton(mb.clickedButton());

			if(res==QMessageBox::Yes)
			{
				process.write(ans_yes.toAscii());
				log("Y\n");
			}
			else
			{
				process.write(ans_no.toAscii());
				log("N\n");
			}

			buffer.clear();
		}
	}

	// Must be finished by now
	Q_ASSERT(process.state()==QProcess::NotRunning);

963
964
965
966
967
968
969
970
971
972
973
974
975
976
977

	if(repo_files.length()!=1)
		return;

	QFileInfo fi_before(repo_files[0]);

	bool ok = false;
	QString new_name = QInputDialog::getText(this, tr("Rename"), tr("Enter new name"), QLineEdit::Normal, fi_before.filePath(), &ok );
	if(!ok)
		return;

	QFileInfo fi_after(new_name);

	if(fi_after.exists())
	{







|







985
986
987
988
989
990
991
992
993
994
995
996
997
998
999

	if(repo_files.length()!=1)
		return;

	QFileInfo fi_before(repo_files[0]);

	bool ok = false;
	QString new_name = QInputDialog::getText(this, tr("Rename"), tr("Enter new name"), QLineEdit::Normal, fi_before.filePath(), &ok, Qt::Sheet );
	if(!ok)
		return;

	QFileInfo fi_after(new_name);

	if(fi_after.exists())
	{
1080
1081
1082
1083
1084
1085
1086










1087
1088
1089
1090
1091

1092
1093
1094
1095
1096
1097
1098
1099
1100

	refresh();
}

//------------------------------------------------------------------------------
void MainWindow::on_actionAbout_triggered()
{










	QMessageBox::about(this, "About... Fuel ",
					   QCoreApplication::applicationName() + " "+ QCoreApplication::applicationVersion() + " " +
					   tr("a GUI frontend to Fossil SCM\n"
						   "by Kostas Karanikolas\n"
						   "Released under the GNU GPL\n\n"

						   "Icon-set by Deleket - Jojo Mendoza\n"
						   "Available under the CC Attribution-Noncommercial-No Derivate 3.0 License"));
}

//------------------------------------------------------------------------------
void MainWindow::on_actionUpdate_triggered()
{
	QStringList res;








>
>
>
>
>
>
>
>
>
>
|

|
|
|
>
|
|







1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133

	refresh();
}

//------------------------------------------------------------------------------
void MainWindow::on_actionAbout_triggered()
{
	QString fossil_ver;
	QStringList res;

	if(runFossil(QStringList() << "version", &res, true) && res.length()==1)
	{
		int off = res[0].indexOf("version ");
		if(off!=-1)
			fossil_ver = tr("Fossil version ")+res[0].mid(off) + "\n\n";
	}

	QMessageBox::about(this, "About Fuel...",
					   QCoreApplication::applicationName() + " "+ QCoreApplication::applicationVersion() + " " +
						tr("a GUI frontend to the Fossil SCM\n"
							"by Kostas Karanikolas\n"
							"Released under the GNU GPL\n\n")
					   + fossil_ver +
						tr("Icon-set by Deleket - Jojo Mendoza\n"
							"Available under the CC Attribution-Noncommercial-No Derivate 3.0 License"));
}

//------------------------------------------------------------------------------
void MainWindow::on_actionUpdate_triggered()
{
	QStringList res;

1124
1125
1126
1127
1128
1129
1130




1131
1132

1133
1134
1135


1136
1137
1138
1139
1140
1141
1142
1143

1144
1145
{
	QString current;
	// Retrieve existing url
	QStringList out;
	if(runFossil(QStringList() << "remote-url", &out, true) && out.length()==1)
		current = out[0].trimmed();





	bool ok = false;
	current = QInputDialog::getText(this, tr("Remote URL"), tr("Enter new remote url"), QLineEdit::Normal, current, &ok );


	if(!ok)
		return;



	QUrl url(current);
	if(!url.isValid())
	{
		QMessageBox::critical(this, tr("Remote URL"), tr("This URL is not valid"), QMessageBox::Ok );
		return;
	}


	runFossil(QStringList() << "remote-url" << QuotePath(url.toString()));
}







>
>
>
>
|
|
>

|

>
>








>
|

1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
{
	QString current;
	// Retrieve existing url
	QStringList out;
	if(runFossil(QStringList() << "remote-url", &out, true) && out.length()==1)
		current = out[0].trimmed();

	QInputDialog dlg(this, Qt::Sheet);
	dlg.setWindowTitle(tr("Remote URL"));
	dlg.setInputMode(QInputDialog::TextInput);
	dlg.setWindowModality(Qt::WindowModal);
	dlg.setModal(true);
	dlg.setLabelText(tr("Enter new remote URL:"));
	dlg.setTextValue(current);

	if(dlg.exec() == QDialog::Rejected)
		return;

	current = dlg.textValue();

	QUrl url(current);
	if(!url.isValid())
	{
		QMessageBox::critical(this, tr("Remote URL"), tr("This URL is not valid"), QMessageBox::Ok );
		return;
	}

	// Run as silent to avoid displaying credentials in the log
	runFossil(QStringList() << "remote-url" << QuotePath(url.toString()), 0, true);
}