[rkward-cvs] rkward/rkward/dialogs startupdialog.cpp,1.3,1.4 startupdialog.h,1.2,1.3

Thomas Friedrichsmeier tfry at users.sourceforge.net
Thu Oct 20 20:58:43 UTC 2005


Update of /cvsroot/rkward/rkward/rkward/dialogs
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16707/rkward/dialogs

Modified Files:
	startupdialog.cpp startupdialog.h 
Log Message:
Added option to bypass startup dialog

Index: startupdialog.cpp
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/dialogs/startupdialog.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** startupdialog.cpp	29 Sep 2005 16:02:51 -0000	1.3
--- startupdialog.cpp	20 Oct 2005 20:58:40 -0000	1.4
***************
*** 19,22 ****
--- 19,23 ----
  #include <qpushbutton.h>
  #include <qradiobutton.h>
+ #include <qcheckbox.h>
  #include <qbuttongroup.h>
  #include <qlayout.h>
***************
*** 36,39 ****
--- 37,41 ----
  #include <kstandarddirs.h>
  
+ #include "../settings/rksettingsmodulegeneral.h"
  #include "../debug.h"
  
***************
*** 42,45 ****
--- 44,49 ----
  	StartupDialog::result = result;
  
+ 	setCaption (i18n ("What would you like to do?"));
+ 
  	QVBoxLayout *vbox = new QVBoxLayout (this);
  	
***************
*** 54,64 ****
  	choser->layout()->setMargin (11);
  	QVBoxLayout *choser_layout = new QVBoxLayout(choser->layout());
! 	choser_layout->addWidget (new QRadioButton (i18n ("Start with an empty workspace"), choser));
! 	choser_layout->addWidget (new QRadioButton (i18n ("Start with an empty table"), choser));
! 	choser_layout->addWidget (new QRadioButton (i18n ("Load an existing workspace:"), choser));
! 	choser->setButton (static_cast<int> (EmptyTable));
  
  	file_list = new QListView (choser);
  	file_list->addColumn (i18n ("Filename"));
  	chose_file_item = new QListViewItem (file_list, i18n ("<<Open another file>>"));
  	if (recent_files) {
--- 58,71 ----
  	choser->layout()->setMargin (11);
  	QVBoxLayout *choser_layout = new QVBoxLayout(choser->layout());
! 	choser_layout->addWidget (empty_workspace_button = new QRadioButton (i18n ("Start with an empty workspace"), choser));
! 	choser_layout->addWidget (empty_table_button = new QRadioButton (i18n ("Start with an empty table"), choser));
! 	open_button = new QRadioButton (i18n ("Load an existing workspace:"), choser);
! 	connect (open_button, SIGNAL (stateChanged (int)), this, SLOT (openButtonSelected (int)));
! 	empty_table_button->setChecked (true);
! 	choser_layout->addWidget (open_button);
  
  	file_list = new QListView (choser);
  	file_list->addColumn (i18n ("Filename"));
+ 	file_list->setSorting (-1);
  	chose_file_item = new QListViewItem (file_list, i18n ("<<Open another file>>"));
  	if (recent_files) {
***************
*** 68,74 ****
  		}
  	}
! 	connect (file_list, SIGNAL (clicked (QListViewItem *)), this, SLOT (listClicked (QListViewItem*)));
  	connect (file_list, SIGNAL (doubleClicked (QListViewItem *, const QPoint &, int)), this, SLOT (listDoubleClicked (QListViewItem*, const QPoint &, int)));
  	choser_layout->addWidget (file_list);
  	
  	vbox->addWidget (choser);
--- 75,82 ----
  		}
  	}
! 	connect (file_list, SIGNAL (selectionChanged (QListViewItem *)), this, SLOT (listClicked (QListViewItem*)));
  	connect (file_list, SIGNAL (doubleClicked (QListViewItem *, const QPoint &, int)), this, SLOT (listDoubleClicked (QListViewItem*, const QPoint &, int)));
  	choser_layout->addWidget (file_list);
+ 	choser_layout->addWidget (remember_box = new QCheckBox (i18n ("Always do this on startup"), choser));
  	
  	vbox->addWidget (choser);
***************
*** 84,89 ****
  	button_hbox->addWidget (cancel_button);
  
- 	setCaption (i18n ("What would you like to do?"));
- 	
  	setFixedWidth (minimumWidth ());
  }
--- 92,95 ----
***************
*** 96,110 ****
  void StartupDialog::accept () {
  	RK_TRACE (DIALOGS);
- #if QT_VERSION < 0x030200
- 	int selected = choser->id (choser->selected ());
- #else
- 	int selected = choser->selectedId ();
- #endif
  
! 	if (selected == (int) EmptyWorkspace) {
  		result->result = EmptyWorkspace;
! 	} else if (selected == (int) EmptyTable) {
  		result->result = EmptyTable;
! 	} else if (selected == (int) OpenFile) {
  		QListViewItem *item = file_list->selectedItem ();
  		if (item == chose_file_item) {
--- 102,111 ----
  void StartupDialog::accept () {
  	RK_TRACE (DIALOGS);
  
! 	if (empty_workspace_button->isChecked ()) {
  		result->result = EmptyWorkspace;
! 	} else if (empty_table_button->isChecked ()) {
  		result->result = EmptyTable;
! 	} else if (open_button->isChecked ()) {
  		QListViewItem *item = file_list->selectedItem ();
  		if (item == chose_file_item) {
***************
*** 117,120 ****
--- 118,122 ----
  		RK_ASSERT (false);
  	}
+ 	if (remember_box->isChecked ()) RKSettingsModuleGeneral::setStartupAction (result->result);
  	QDialog::accept ();
  }
***************
*** 132,136 ****
  	
  	if (item) {
! 		choser->setButton ((int) OpenFile);
  		item->setSelected (true);
  		accept ();
--- 134,138 ----
  	
  	if (item) {
! 		open_button->setChecked (true);
  		item->setSelected (true);
  		accept ();
***************
*** 141,145 ****
  	RK_TRACE (DIALOGS);
  	
! 	if (item) choser->setButton ((int) OpenFile);
  }
  
--- 143,168 ----
  	RK_TRACE (DIALOGS);
  	
! 	if (item) {
! 		open_button->setChecked (true);
! 		openButtonSelected (QButton::On);		// always do processing
! 	}
! }
! 
! void StartupDialog::openButtonSelected (int state) {
! 	RK_TRACE (DIALOGS);
! 
! 	if (state == QButton::On) {
! 		if (!file_list->selectedItem ()) {
! 			file_list->setSelected (file_list->firstChild (), true);
! 		}
! 		if (file_list->selectedItem () != chose_file_item) {
! 			remember_box->setChecked (false);
! 			remember_box->setEnabled (false);
! 		} else {
! 			remember_box->setEnabled (true);
! 		}
! 	} else if (state == QButton::Off) {
! 		remember_box->setEnabled (true);
! 	}
  }
  
***************
*** 147,152 ****
  StartupDialog::StartupDialogResult *StartupDialog::getStartupAction (QWidget *parent, KRecentFilesAction *recent_files) {
  	RK_TRACE (DIALOGS);
  	StartupDialogResult *result = new StartupDialogResult;
! 	result->result = EmptyWorkspace;
  
  	StartupDialog *dialog = new StartupDialog (parent, result, recent_files);
--- 170,180 ----
  StartupDialog::StartupDialogResult *StartupDialog::getStartupAction (QWidget *parent, KRecentFilesAction *recent_files) {
  	RK_TRACE (DIALOGS);
+ 
  	StartupDialogResult *result = new StartupDialogResult;
! 	result->result = RKSettingsModuleGeneral::startupAction ();
! 
! 	if (result->result != NoSavedSetting) {
! 		return result;
! 	}
  
  	StartupDialog *dialog = new StartupDialog (parent, result, recent_files);

Index: startupdialog.h
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/dialogs/startupdialog.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** startupdialog.h	20 Oct 2005 19:45:54 -0000	1.2
--- startupdialog.h	20 Oct 2005 20:58:41 -0000	1.3
***************
*** 23,27 ****
--- 23,29 ----
  
  class QPushButton;
+ class QCheckBox;
  class QButtonGroup;
+ class QRadioButton;
  class QListView;
  class QListViewItem;
***************
*** 38,48 ****
  Q_OBJECT
  public:
! 	/** enum to hold result of StartupDialog */
  	enum Result {
  		EmptyWorkspace=0,	/**< start with an empty workspace */
  		EmptyTable=1,				/**< start with an empty table */
! 		OpenFile=2,					/**< open a recent file (already specified) */
! 		ChoseFile=3,				/**< chose file to open */
! 		NoSavedSetting=4		/**< not acutally returned as a result. Used in RKSettingsModuleGeneral. This is saved, if user wants to be asked on every startup */
  	};
  	struct StartupDialogResult {
--- 40,50 ----
  Q_OBJECT
  public:
! 	/** enum to hold result of StartupDialog. WARNING: do not change the numeric values! They are saved as user settings in the config (@see RKSettingsModuleGeneral). */
  	enum Result {
  		EmptyWorkspace=0,	/**< start with an empty workspace */
  		EmptyTable=1,				/**< start with an empty table */
! 		ChoseFile=2,				/**< chose file to open */
! 		NoSavedSetting=3,		/**< not acutally returned as a result. Used in RKSettingsModuleGeneral. This is saved, if user wants to be asked on every startup */
! 		OpenFile=4					/**< open a recent file (already specified) */
  	};
  	struct StartupDialogResult {
***************
*** 61,67 ****
--- 63,74 ----
  	void listDoubleClicked (QListViewItem *item, const QPoint &, int);
  	void listClicked (QListViewItem *item);
+ 	void openButtonSelected (int state);
  private:
  	QPushButton *ok_button;
  	QPushButton *cancel_button;
+ 	QRadioButton *empty_workspace_button;
+ 	QRadioButton *empty_table_button;
+ 	QRadioButton *open_button;
+ 	QCheckBox *remember_box;
  	
  	QButtonGroup *choser;





More information about the rkward-tracker mailing list