Mercurial > hg > forks > UniversalIndentGUI
changeset 430:12072a5e2887
[add] Feature Request ID 1885911 : Added the possibility to open a file on applications start, that is handed over as parameter on the command line. http://universalindent.sf.net/issue/1885911
git-svn-id: svn://svn.code.sf.net/p/universalindent/code/trunk@665 59b1889a-e5ac-428c-b0c7-476e01d41282
author | thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282> |
---|---|
date | Sat, 03 May 2008 13:22:50 +0000 |
parents | 67a6289e07cf |
children | 3db734329229 |
files | README.txt doc/universalindentgui.man src/main.cpp src/mainwindow.cpp src/mainwindow.h |
diffstat | 5 files changed, 24 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/README.txt Sat May 03 12:19:30 2008 +0000 +++ b/README.txt Sat May 03 13:22:50 2008 +0000 @@ -33,11 +33,14 @@ Right now the windows version of GreatCode is shipped along with the Linux version of UniversalIndentGUI, because I was unable to compile GreatCode under Linux. UniversalIndentGUI tries to start GreatCode via wine. So wine has to be installed in order to use GreatCode. This applies to any new indenter, where only a windows executable exists, too. -3.1 Portable mode +3.1 Parameters +UniversalIndentGUI can be started with a file as parameter, which is loaded on startup. + +3.2 Portable mode UniversalIndentGUI can be run in a portable mode, so it won't make any modifications on the system, except for the media it is started from. The things UniversalIndentGUI writes to the for example USB drive are the user settings of the application and the set parameters of the indenters. Further a temporary dir is used, to feed the indenters with input files and grab their output. The portable mode is being used, if the sub dir "indenters" is found in the same dir as the executable. Thats the case for the before named binary archives. -3.2 Multiuser mode +3.3 Multiuser mode Especially Unix based systems strictly make use of user restrictments, but also Windows can be used that way, even if many dislike that due to lack of comfort. To be able to run UniversalIndentGUI on multiuser systems the needed files are spread over different directories. On Unix based these are: /usr/bin for the binary. /etc/UniversalIndentGUI for global configuration and the essential indenter ini files.
--- a/doc/universalindentgui.man Sat May 03 12:19:30 2008 +0000 +++ b/doc/universalindentgui.man Sat May 03 13:22:50 2008 +0000 @@ -5,7 +5,10 @@ .SH SYNOPSIS .B universalindentgui -(takes no commandline parameters) +.RI [ FILE ] +Optional the as parameter given +.IR FILE +can be opened at start. .SH DESCRIPTION \fBUniversalIndentGUI\fP is a cross platform compatible GUI for several code formatters, beautifiers and indenters, e.g. GreatCode, AStyle (Artistic Style), GNU Indent, BCPP and others. Its main feature is a live preview to directly see how the selected formatting options affect the source code.
--- a/src/main.cpp Sat May 03 12:19:30 2008 +0000 +++ b/src/main.cpp Sat May 03 13:22:50 2008 +0000 @@ -27,8 +27,12 @@ int main(int argc, char *argv[]) { QApplication app(argc, argv); + QString file2OpenOnStart = ""; - MainWindow mainWindow; + if ( argc > 1 ) { + file2OpenOnStart = argv[1]; + } + MainWindow mainWindow(file2OpenOnStart); mainWindow.show();
--- a/src/mainwindow.cpp Sat May 03 12:19:30 2008 +0000 +++ b/src/mainwindow.cpp Sat May 03 13:22:50 2008 +0000 @@ -34,7 +34,7 @@ /*! \brief Constructs the main window. */ -MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) { +MainWindow::MainWindow(QString file2OpenOnStart, QWidget *parent) : QMainWindow(parent) { // set the program version, revision and date, which is shown in the main window title and in the about dialog. version = "0.8.1"; revision = "650"; @@ -151,8 +151,14 @@ settingsDialog = new UiGuiSettingsDialog(this, settings); connect( actionShowSettings, SIGNAL(activated()), settingsDialog, SLOT(showDialog()) ); - // Loads the last opened file, if this is enabled in the settings. - loadLastOpenedFile(); + // If a file that should be opened on start has been handed over to the constructor exists, load it + if ( QFile::exists(file2OpenOnStart) ) { + openSourceFileDialog(file2OpenOnStart); + } + // Otherwise load the last opened file, if this is enabled in the settings. + else { + loadLastOpenedFile(); + } updateSourceView();