Reorganized context menu
Added Clear log action Improved settings serialization. Added Saving and loading of window position and size Added Quit action Added Timeline action Added File history action FossilOrigin-Name: 836ed88f08a4d0133120fa5735627bbd24cd30a0
This commit is contained in:
		
							
								
								
									
										165
									
								
								MainWindow.cpp
									
									
									
									
									
								
							
							
						
						
									
										165
									
								
								MainWindow.cpp
									
									
									
									
									
								
							| @@ -4,7 +4,7 @@ | ||||
| #include <QStandardItem> | ||||
| #include <QProcess> | ||||
| #include <QSettings> | ||||
|  | ||||
| #include <QDesktopServices> | ||||
|  | ||||
| MainWindow::MainWindow(QWidget *parent) : | ||||
|     QMainWindow(parent), | ||||
| @@ -12,28 +12,26 @@ MainWindow::MainWindow(QWidget *parent) : | ||||
| { | ||||
|     ui->setupUi(this); | ||||
| 	ui->tableView->setModel(&itemModel); | ||||
| 	ui->tableView->addAction(ui->actionDiff); | ||||
| 	ui->tableView->addAction(ui->actionHistory); | ||||
| 	ui->tableView->addAction(ui->actionAdd); | ||||
| 	ui->tableView->addAction(ui->actionDelete); | ||||
| 	ui->tableView->addAction(ui->actionRename); | ||||
| 	ui->tableView->addAction(ui->actionHistory); | ||||
| 	ui->tableView->addAction(ui->actionDiff); | ||||
|  | ||||
| 	settingsFile = QApplication::applicationDirPath().left(1) + ":/qfossil.ini"; | ||||
| 	settingsFile = QDir::homePath() + QDir::separator() + ".fuelrc"; | ||||
| 	currentWorkspace = 0; | ||||
| 	loadSettings(); | ||||
|  | ||||
| 	if(workspaces.empty()) | ||||
| 		workspaces.append("/home/kostas/tmp/cheesy-fos"); | ||||
|  | ||||
| 	if(fossilPath.isEmpty()) | ||||
| 		fossilPath = "fossil"; | ||||
|  | ||||
| 	refresh(); | ||||
| } | ||||
|  | ||||
| //------------------------------------------------------------------------------ | ||||
| MainWindow::~MainWindow() | ||||
| { | ||||
| 	stopUI(); | ||||
| 	saveSettings(); | ||||
| 	delete ui; | ||||
| } | ||||
| @@ -54,7 +52,6 @@ void MainWindow::on_actionOpen_triggered() | ||||
| 		currentWorkspace = workspaces.size()-1; | ||||
| 		refresh(); | ||||
| 	} | ||||
|  | ||||
| } | ||||
|  | ||||
| //------------------------------------------------------------------------------ | ||||
| @@ -174,6 +171,11 @@ void MainWindow::Log(const QString &text) | ||||
| { | ||||
| 	ui->textBrowser->append(text); | ||||
| } | ||||
| //------------------------------------------------------------------------------ | ||||
| void MainWindow::on_actionClearLog_triggered() | ||||
| { | ||||
| 	ui->textBrowser->clear(); | ||||
| } | ||||
|  | ||||
| //------------------------------------------------------------------------------ | ||||
| bool MainWindow::runFossil(QStringList &result, const QStringList &args) | ||||
| @@ -233,27 +235,44 @@ void MainWindow::loadSettings() | ||||
| { | ||||
| 	QSettings settings(settingsFile, QSettings::NativeFormat); | ||||
|  | ||||
| 	bool ok=false; | ||||
|  | ||||
| 	fossilPath = settings.value("FossilPath").toString(); | ||||
| 	if(fossilPath.isEmpty()) | ||||
| 	if(settings.contains("FossilPath")) | ||||
| 		fossilPath = settings.value("FossilPath").toString(); | ||||
| 	else | ||||
| 		fossilPath = "fossil"; | ||||
|  | ||||
| 	int num_repos =	settings.value("NumWorkspaces").toInt(&ok); | ||||
| 	if(!ok) | ||||
| 		num_repos=0; | ||||
| 	int num_wks = 0; | ||||
|  | ||||
| 	for(int i=0; i<num_repos; ++i) | ||||
| 	if(settings.contains("NumWorkspaces")) | ||||
| 		num_wks = settings.value("NumWorkspaces").toInt(); | ||||
|  | ||||
| 	for(int i=0; i<num_wks; ++i) | ||||
| 	{ | ||||
| 	  QString wk = settings.value("Workspace_"+i).toString(); | ||||
| 	  if(!wk.isEmpty()) | ||||
| 		QString key = "Workspace_" + QString::number(i); | ||||
| 		QString wk = settings.value(key).toString(); | ||||
| 		if(!wk.isEmpty()) | ||||
| 			workspaces.append(wk); | ||||
| 	} | ||||
|  | ||||
| 	currentWorkspace = settings.value("LastWorkspace").toInt(&ok); | ||||
| 	if(!ok) | ||||
| 		num_repos=0; | ||||
| 	if(settings.contains("LastWorkspace")) | ||||
| 		currentWorkspace = settings.value("LastWorkspace").toInt(); | ||||
| 	else | ||||
| 		currentWorkspace = 0; | ||||
|  | ||||
| 	if(settings.contains("WindowX") && settings.contains("WindowY")) | ||||
| 	{ | ||||
| 		QPoint _pos; | ||||
| 		_pos.setX(settings.value("WindowX").toInt()); | ||||
| 		_pos.setY(settings.value("WindowY").toInt()); | ||||
| 		move(_pos); | ||||
| 	} | ||||
|  | ||||
| 	if(settings.contains("WindowWidth") && settings.contains("WindowHeight")) | ||||
| 	{ | ||||
| 		QSize _size; | ||||
| 		_size.setWidth(settings.value("WindowWidth").toInt()); | ||||
| 		_size.setHeight(settings.value("WindowHeight").toInt()); | ||||
| 		resize(_size); | ||||
| 	} | ||||
| } | ||||
|  | ||||
| //------------------------------------------------------------------------------ | ||||
| @@ -264,13 +283,21 @@ void MainWindow::saveSettings() | ||||
| 	settings.setValue("NumWorkspaces", workspaces.size()); | ||||
|  | ||||
| 	for(int i=0; i<workspaces.size(); ++i) | ||||
| 		settings.setValue("Workspace_"+i, workspaces[i]); | ||||
| 	{ | ||||
| 		QString key = "Workspace_" + QString::number(i); | ||||
| 		settings.setValue(key, workspaces[i]); | ||||
| 	} | ||||
|  | ||||
| 	settings.setValue("LastWorkspace", currentWorkspace); | ||||
| 	settings.setValue("WindowX", x()); | ||||
| 	settings.setValue("WindowY", y()); | ||||
| 	settings.setValue("WindowWidth", width()); | ||||
| 	settings.setValue("WindowHeight", height()); | ||||
|  | ||||
| } | ||||
|  | ||||
| //------------------------------------------------------------------------------ | ||||
| void MainWindow::on_actionDiff_triggered() | ||||
| void MainWindow::getSelectionFilenames(QStringList &filenames) | ||||
| { | ||||
| 	QModelIndexList selection = ui->tableView->selectionModel()->selectedIndexes(); | ||||
| 	for(QModelIndexList::iterator mi_it = selection.begin(); mi_it!=selection.end(); ++mi_it) | ||||
| @@ -283,32 +310,92 @@ void MainWindow::on_actionDiff_triggered() | ||||
| 			continue; | ||||
|  | ||||
| 		QVariant data = itemModel.data(mi); | ||||
| 		QString fname = data.toString(); | ||||
| 		filenames.append(data.toString()); | ||||
| 	} | ||||
| } | ||||
| //------------------------------------------------------------------------------ | ||||
| void MainWindow::on_actionDiff_triggered() | ||||
| { | ||||
| 	QStringList selection; | ||||
| 	getSelectionFilenames(selection); | ||||
|  | ||||
| 	for(QStringList::iterator it = selection.begin(); it!=selection.end(); ++it) | ||||
| 	{ | ||||
| 		QStringList res; | ||||
| 		if(!runFossil(res, QStringList() << "gdiff" << fname)) | ||||
| 		if(!runFossil(res, QStringList() << "gdiff" << *it)) | ||||
| 			return; | ||||
| 	} | ||||
| } | ||||
|  | ||||
| //------------------------------------------------------------------------------ | ||||
| bool MainWindow::startUI() | ||||
| { | ||||
| 	if(uiRunning()) | ||||
| 		return true; | ||||
|  | ||||
| 	fossilUI.setProcessChannelMode(QProcess::MergedChannels); | ||||
| 	fossilUI.setWorkingDirectory(getCurrentWorkspace()); | ||||
|  | ||||
| 	Log("> fossil ui"); | ||||
|  | ||||
| 	fossilUI.start(fossilPath, QStringList() << "ui"); | ||||
| 	if(!fossilUI.waitForStarted()) | ||||
| 	{ | ||||
| 		Log(fossilPath + " does not exist\n"); | ||||
| 		return false; | ||||
| 	} | ||||
|  | ||||
| 	return true; | ||||
| } | ||||
|  | ||||
| //------------------------------------------------------------------------------ | ||||
| void MainWindow::stopUI() | ||||
| { | ||||
| 	if(uiRunning()) | ||||
| 		fossilUI.terminate(); | ||||
| } | ||||
|  | ||||
|  | ||||
| //------------------------------------------------------------------------------ | ||||
| void MainWindow::on_actionFossilUI_toggled(bool arg1) | ||||
| { | ||||
| 	if(arg1 && fossilUI.state()==QProcess::NotRunning) | ||||
| 	{ | ||||
| 		fossilUI.setProcessChannelMode(QProcess::MergedChannels); | ||||
| 		fossilUI.setWorkingDirectory(getCurrentWorkspace()); | ||||
| 	if(arg1) | ||||
| 		startUI(); | ||||
| 	else | ||||
| 		stopUI(); | ||||
| } | ||||
|  | ||||
| 		Log("> fossil ui"); | ||||
| //------------------------------------------------------------------------------ | ||||
| void MainWindow::on_actionQuit_triggered() | ||||
| { | ||||
| 	close(); | ||||
| } | ||||
|  | ||||
| 		fossilUI.start(fossilPath, QStringList() << "ui"); | ||||
| 		if(!fossilUI.waitForStarted()) | ||||
| 		{ | ||||
| 			Log(fossilPath + " does not exist\n"); | ||||
| 			return; | ||||
| 		} | ||||
| 	} | ||||
| 	else if(!arg1 && fossilUI.state()==QProcess::Running) | ||||
| //------------------------------------------------------------------------------ | ||||
| void MainWindow::on_actionTimeline_triggered() | ||||
| { | ||||
| 	if(!uiRunning()) | ||||
| 		ui->actionFossilUI->activate(QAction::Trigger); | ||||
|  | ||||
| 	Q_ASSERT(uiRunning()); | ||||
|  | ||||
| 	QDesktopServices::openUrl(QUrl("http://localhost:8080/timeline")); | ||||
| } | ||||
|  | ||||
| //------------------------------------------------------------------------------ | ||||
| void MainWindow::on_actionHistory_triggered() | ||||
| { | ||||
| 	if(!uiRunning()) | ||||
| 		ui->actionFossilUI->activate(QAction::Trigger); | ||||
|  | ||||
| 	Q_ASSERT(uiRunning()); | ||||
|  | ||||
| 	QStringList selection; | ||||
| 	getSelectionFilenames(selection); | ||||
|  | ||||
| 	for(QStringList::iterator it = selection.begin(); it!=selection.end(); ++it) | ||||
| 	{ | ||||
| 		fossilUI.terminate(); | ||||
| 		QDesktopServices::openUrl(QUrl("http://localhost:8080/finfo?name="+*it)); | ||||
| 	} | ||||
| } | ||||
|  | ||||
|   | ||||
							
								
								
									
										11
									
								
								MainWindow.h
									
									
									
									
									
								
							
							
						
						
									
										11
									
								
								MainWindow.h
									
									
									
									
									
								
							| @@ -57,14 +57,21 @@ private: | ||||
| 	void saveSettings(); | ||||
| 	const QString &getCurrentWorkspace() { Q_ASSERT(currentWorkspace<workspaces.size()); return workspaces[currentWorkspace]; } | ||||
| 	void Log(const QString &text); | ||||
| 	bool uiRunning() const { return fossilUI.state() == QProcess::Running; } | ||||
| 	void getSelectionFilenames(QStringList &filenames); | ||||
| 	bool startUI(); | ||||
| 	void stopUI(); | ||||
|  | ||||
| private slots: | ||||
| 	void on_actionRefresh_triggered(); | ||||
| 	void on_actionOpen_triggered(); | ||||
|  | ||||
| 	void on_actionDiff_triggered(); | ||||
|  | ||||
| 	void on_actionFossilUI_toggled(bool arg1); | ||||
| 	void on_actionQuit_triggered(); | ||||
| 	void on_actionTimeline_triggered(); | ||||
| 	void on_actionHistory_triggered(); | ||||
|  | ||||
| 	void on_actionClearLog_triggered(); | ||||
|  | ||||
| public slots: | ||||
| 	void on_tableView_customContextMenuRequested(const QPoint &pos); | ||||
|   | ||||
| @@ -11,7 +11,7 @@ | ||||
|    </rect> | ||||
|   </property> | ||||
|   <property name="windowTitle"> | ||||
|    <string>QFossil</string> | ||||
|    <string>Fuel</string> | ||||
|   </property> | ||||
|   <widget class="QWidget" name="centralWidget"> | ||||
|    <layout class="QVBoxLayout" name="verticalLayout"> | ||||
| @@ -130,6 +130,10 @@ | ||||
|    <addaction name="actionDiff"/> | ||||
|    <addaction name="actionHistory"/> | ||||
|    <addaction name="separator"/> | ||||
|    <addaction name="actionClearLog"/> | ||||
|    <addaction name="separator"/> | ||||
|    <addaction name="actionTimeline"/> | ||||
|    <addaction name="separator"/> | ||||
|    <addaction name="actionFossilUI"/> | ||||
|   </widget> | ||||
|   <widget class="QStatusBar" name="statusBar"/> | ||||
| @@ -145,7 +149,7 @@ | ||||
|   <action name="actionCommit"> | ||||
|    <property name="icon"> | ||||
|     <iconset resource="resources.qrc"> | ||||
|      <normaloff>:/icons/icons/Save-01.png</normaloff>:/icons/icons/Save-01.png</iconset> | ||||
|      <normaloff>:/icons/icons/Button Add-01.png</normaloff>:/icons/icons/Button Add-01.png</iconset> | ||||
|    </property> | ||||
|    <property name="text"> | ||||
|     <string>Commit</string> | ||||
| @@ -184,7 +188,13 @@ | ||||
|      <normaloff>:/icons/icons/My Documents-01.png</normaloff>:/icons/icons/My Documents-01.png</iconset> | ||||
|    </property> | ||||
|    <property name="text"> | ||||
|     <string>Open workspace...</string> | ||||
|     <string>Open Workspace...</string> | ||||
|    </property> | ||||
|    <property name="toolTip"> | ||||
|     <string>Open a fossil checkout folder</string> | ||||
|    </property> | ||||
|    <property name="iconVisibleInMenu"> | ||||
|     <bool>true</bool> | ||||
|    </property> | ||||
|   </action> | ||||
|   <action name="actionPush"> | ||||
| @@ -225,6 +235,9 @@ | ||||
|    <property name="text"> | ||||
|     <string>Quit</string> | ||||
|    </property> | ||||
|    <property name="iconVisibleInMenu"> | ||||
|     <bool>true</bool> | ||||
|    </property> | ||||
|   </action> | ||||
|   <action name="actionHistory"> | ||||
|    <property name="icon"> | ||||
| @@ -232,7 +245,10 @@ | ||||
|      <normaloff>:/icons/icons/File History-01.png</normaloff>:/icons/icons/File History-01.png</iconset> | ||||
|    </property> | ||||
|    <property name="text"> | ||||
|     <string>history</string> | ||||
|     <string>History</string> | ||||
|    </property> | ||||
|    <property name="toolTip"> | ||||
|     <string>History</string> | ||||
|    </property> | ||||
|   </action> | ||||
|   <action name="actionFossilUI"> | ||||
| @@ -256,16 +272,31 @@ | ||||
|      <normaloff>:/icons/icons/Document-Revert-icon.png</normaloff>:/icons/icons/Document-Revert-icon.png</iconset> | ||||
|    </property> | ||||
|    <property name="text"> | ||||
|     <string>revert</string> | ||||
|     <string>Revert</string> | ||||
|    </property> | ||||
|    <property name="toolTip"> | ||||
|     <string>Revert</string> | ||||
|    </property> | ||||
|   </action> | ||||
|   <action name="actionClearLog"> | ||||
|    <property name="icon"> | ||||
|     <iconset resource="resources.qrc"> | ||||
|      <normaloff>:/icons/icons/Book-01.png</normaloff>:/icons/icons/Book-01.png</iconset> | ||||
|      <normaloff>:/icons/icons/Text Edit.png</normaloff>:/icons/icons/Text Edit.png</iconset> | ||||
|    </property> | ||||
|    <property name="text"> | ||||
|     <string>clearLog</string> | ||||
|     <string>Clear Log</string> | ||||
|    </property> | ||||
|    <property name="toolTip"> | ||||
|     <string>Clear Log</string> | ||||
|    </property> | ||||
|   </action> | ||||
|   <action name="actionTimeline"> | ||||
|    <property name="icon"> | ||||
|     <iconset resource="resources.qrc"> | ||||
|      <normaloff>:/icons/icons/Clock-01.png</normaloff>:/icons/icons/Clock-01.png</iconset> | ||||
|    </property> | ||||
|    <property name="text"> | ||||
|     <string>Timeline</string> | ||||
|    </property> | ||||
|   </action> | ||||
|  </widget> | ||||
|   | ||||
							
								
								
									
										18
									
								
								manifest
									
									
									
									
									
								
							
							
						
						
									
										18
									
								
								manifest
									
									
									
									
									
								
							| @@ -1,8 +1,8 @@ | ||||
| C Implemented\sdiff\scommand\nImplemented\sui\scommand\nAdded\sfull\sset\sof\sicons | ||||
| D 2011-08-02T13:16:35.211 | ||||
| F MainWindow.cpp e1ab75af0cac9bb128c2c113823dd2986ba04920 | ||||
| F MainWindow.h 502a65528683310c9b8c3d661705faaed90a02a2 | ||||
| F MainWindow.ui aeb073a5e930adcfd63bc83e3647644a12d9d4f9 | ||||
| C Reorganized\scontext\smenu\nAdded\sClear\slog\saction\nImproved\ssettings\sserialization.\nAdded\sSaving\sand\sloading\sof\swindow\sposition\sand\ssize\nAdded\sQuit\saction\nAdded\sTimeline\saction\nAdded\sFile\shistory\saction | ||||
| D 2011-08-02T14:37:32.392 | ||||
| F MainWindow.cpp 40b52cc20d0bdd312eda97dabfe061d0b811c4ca | ||||
| F MainWindow.h d9dd1137ff2af5a3a10d0f63f6bfe85d25b466c4 | ||||
| F MainWindow.ui ecde2d039645f4ff31d56416985fa372b534dade | ||||
| F icons/Address\sBook-01.png ef2cec80ea5a559b72e8be4a344a1869fe69cbd8 | ||||
| F icons/Adobe\sIllustrator\sCS3\sDocument-01.png 2e44e933d58eefee7ccfa1650fed4ceadcf3c2be | ||||
| F icons/Adobe\sPDF\sDocument-01.png 8a0bc3ba633d08debde748d64b5a9675e30447a3 | ||||
| @@ -157,9 +157,9 @@ F icons/Zoom\sOut-01.png 8eda092100d9e00c9097f43a80d1e26695947448 | ||||
| F icons/Zoom-01.png 67ca532922e9166325c5c75fce1ca3fbb0d2b6a6 | ||||
| F main.cpp f53e9e1e34f65565f06b2d37d7be5c38e2113a03 | ||||
| F qtfossil.pro 80268b3b1ec8f73cbc24896a0f2ae3fbcca286cb | ||||
| F qtfossil.pro.user 0a24670f4ebfd9af897655ca0e5d4eafbb71df9e | ||||
| F qtfossil.pro.user 22fafa96fdc37a358378024e78fab11e7796b61d | ||||
| F resources.qrc e98383ed205f4e37100c60057e0129c3b86dea53 | ||||
| P ef1ad7e20ba3aa605446197cecbba38c8b0e60da | ||||
| R b848f9cf5a2c81fe399e52d22d9c4dc8 | ||||
| P b900691237413a91803d830d1e9e6702ed76d749 | ||||
| R 73ae2bf1796d58dab2d89012f1383da3 | ||||
| U kostas | ||||
| Z 125f8c422d72643bb1465048f8f4c3de | ||||
| Z 7d44a0e71f9d084bae91ca71484d39c3 | ||||
|   | ||||
| @@ -1 +1 @@ | ||||
| b900691237413a91803d830d1e9e6702ed76d749 | ||||
| 836ed88f08a4d0133120fa5735627bbd24cd30a0 | ||||
| @@ -1,6 +1,6 @@ | ||||
| <?xml version="1.0" encoding="UTF-8"?> | ||||
| <!DOCTYPE QtCreatorProject> | ||||
| <!-- Written by Qt Creator 2.2.82, 2011-08-02T22:14:22. --> | ||||
| <!-- Written by Qt Creator 2.2.82, 2011-08-02T23:35:20. --> | ||||
| <qtcreator> | ||||
|  <data> | ||||
|   <variable>ProjectExplorer.Project.ActiveTarget</variable> | ||||
|   | ||||
		Reference in New Issue
	
	Block a user