[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdeedu/kiten
From:       Joseph Kerian <jkerian () gmail ! com>
Date:       2006-09-11 5:59:33
Message-ID: 1157954373.896880.13484.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 582946 by kerian:

* Added a real preference dialog to radselect in order to set the font on the buttons
* Made the buttons in the grid somewhat smaller so they don't take a rediculous amount of space
* Fixed some wierd repeats in some of the .ui files


 M  +0 -7      bin/configfont.ui  
 M  +2 -2      radselect/CMakeLists.txt  
 M  +12 -7     radselect/radselect.cpp  
 M  +21 -15    radselect/radselectbuttongrid.cpp  
 M  +2 -0      radselect/radselectbuttongrid.h  
 A             radselect/radselectconfig.kcfg  
 A             radselect/radselectconfig.kcfgc  
 D             radselect/radselectpref.cpp  
 D             radselect/radselectpref.h  
 A             radselect/radselectprefdialog.ui  
 M  +10 -14    radselect/radselectview.cpp  
 M  +3 -0      radselect/radselectview.h  


--- trunk/KDE/kdeedu/kiten/bin/configfont.ui #582945:582946
@@ -421,12 +421,5 @@
   <pixmapfunction>qPixmapFromMimeSource</pixmapfunction>
   <includes>
     <include location="local" >kfontrequester.h</include>
-    <include location="local" >kfontrequester.h</include>
-    <include location="local" >kfontrequester.h</include>
-    <include location="local" >kfontrequester.h</include>
-    <include location="local" >kfontrequester.h</include>
-    <include location="local" >kfontrequester.h</include>
-    <include location="local" >kfontrequester.h</include>
-    <include location="local" >kfontrequester.h</include>
   </includes>
 </ui>
--- trunk/KDE/kdeedu/kiten/radselect/CMakeLists.txt #582945:582946
@@ -4,10 +4,10 @@
 	radselectmain.cpp
 	radselect.cpp
 	radselectview.cpp
-	radselectpref.cpp
 	radselectbuttongrid.cpp
 	)
-kde4_add_ui_files(radselect_bin_SRCS radical_selector.ui)
+kde4_add_ui_files(radselect_bin_SRCS radical_selector.ui radselectprefdialog.ui)
+kde4_add_kcfg_files(radselect_bin_SRCS radselectconfig.kcfgc)
 kde4_automoc(${radselect_bin_SRCS})
 
 kde4_add_executable(radselect_bin ${radselect_bin_SRCS})
--- trunk/KDE/kdeedu/kiten/radselect/radselect.cpp #582945:582946
@@ -19,9 +19,10 @@
 
 
 #include "radselect.h"
-#include "radselectpref.h"
 #include "kromajiedit.h"
 #include "kitenEdit.h"
+#include "radselectconfig.h"
+#include "ui_radselectprefdialog.h"
 
 #include <qpainter.h>
 #include <QDragEnterEvent>
@@ -35,6 +36,7 @@
 #include <kio/netaccess.h>
 #include <kfiledialog.h>
 #include <kconfig.h>
+#include <kconfigdialog.h>
 
 #include <kstdaccel.h>
 #include <kaction.h>
@@ -136,12 +138,15 @@
 
 void radselect::optionsPreferences()
 {
-    // popup some sort of preference dialog, here
-    radselectPreferences dlg;
-    if (dlg.exec())
-    {
-        // redo your settings
-    }
+	if(KConfigDialog::showDialog("settings"))
+		return;
+	KConfigDialog *dialog = new KConfigDialog(this,"settings", radselectConfigSkeleton::self());
+	QWidget *preferences = new QWidget();
+	Ui::radselectprefdialog layout;
+	layout.setupUi(preferences);
+	dialog->addPage(preferences, i18n("Settings"),"contents");
+	connect(dialog,SIGNAL(settingsChanged(const QString&)), m_view, SLOT(loadSettings()));
+	dialog->show();
 }
 
 void radselect::changeStatusbar(const QString& text)
--- trunk/KDE/kdeedu/kiten/radselect/radselectbuttongrid.cpp #582945:582946
@@ -18,25 +18,11 @@
 */
 
 
-/*  TODO:
-*	Double check that I need to subclass the QPushButton
-*	Ditch some of this massive pile of includes, investigate KDE classes
-*	Add an alternate stroke setup (setable in preferences)
-*	Add preferences hooks
-		radical files
-		FONTS!!!
-*	Clean up alot of the layout code (both: radical list & main)
-
+/* 
     Future Plans:
 *	Design a custom QGridLayout to rearrange buttons dynamically to resize
 *	Make radical search list a two/three column field with delete button
 *	Design multiple radical file handling
-*	Build a proper exception handling framework
-*	Icon set for properly displayed radicals
-*	Radical Decomposition, and associated interface
-*	Rebuild most of this file as a ui file, handle any special code in
-		radselect.cpp, and move the smaller classes to their own file.
-
 */
 
 #include "radselectbuttongrid.h"
@@ -56,6 +42,8 @@
 #include <kmessagebox.h>
 #include <kstandarddirs.h>
 
+#include <kdebug.h>
+
 radselectButtonGrid::radselectButtonGrid(QWidget *parent)
     : QWidget(parent)
 {
@@ -134,15 +122,33 @@
 				continue; //Skip if this is the wrong column
 
 			radicalButton *button = new radicalButton(*it,box);
+			//Note that this is slightly naughty... since this does not consult
+			//QStyle before setting this. (see QPushButton's sizeHint() for what
+			//one should do, but that looks fugly in this case)
+			QFontMetrics fm = button->fontMetrics();
+			QSize sz = fm.size(Qt::TextShowMnemonic, *it);
+			button->setMinimumSize(sz);
+
 			grid->addWidget(button, row_index++, column_index);
 		
 			//Bind slots/signals for this button
     		connect( button, SIGNAL( leftReleased(const QString&) ), 
 					this, SIGNAL( addRadicalToList(const QString&) ) );
+			//Add this button to our list
+			buttons.insert(*it,button);
 		}
 	}
 }
 
+void radselectButtonGrid::setFont(const QFont &font) {
+	foreach(QPushButton *button, buttons.values()) {
+		button->setFont(font);
+		QFontMetrics fm = button->fontMetrics();
+		QSize sz = fm.size(Qt::TextShowMnemonic, button->text());
+		button->setMinimumSize(sz);
+	}
+}
+
 void radselectButtonGrid::clearSelections() {
 	//In the future, this will do something
 }
--- trunk/KDE/kdeedu/kiten/radselect/radselectbuttongrid.h #582945:582946
@@ -68,6 +68,7 @@
 public slots:
 	/** Reset all buttons to the up and uncolored state */
 	void clearSelections();
+	void setFont(const QFont&);
 
 private: //private functions we need
 	bool loadRadicalFile();  		// Reads the data from the radkfile
@@ -78,6 +79,7 @@
 	static const unsigned int number_of_radical_columns = 11;
 				//Higher stroke counts are bunched together
 	QHash<QString,Radical*> radicals; 
+	QHash<QString,radicalButton*> buttons;
 
 };
 
--- trunk/KDE/kdeedu/kiten/radselect/radselectview.cpp #582945:582946
@@ -17,13 +17,7 @@
    Boston, MA 02110-1301, USA.
 */
 
-/*  TODO:
-*	Double check that I need to subclass the QPushButton
-*	Add an alternate stroke setup (setable in preferences)
-*	Add preferences hooks
-		radical files
-		FONTS!!!
-
+/* 
     Future Plans:
 *	Design a custom QGridLayout to rearrange buttons dynamically to resize
 *	Make radical search list a two/three column field with delete button
@@ -31,13 +25,11 @@
 *	Build a proper exception handling framework
 *	Icon set for properly displayed radicals
 *	Radical Decomposition, and associated interface
-*	Rebuild most of this file as a ui file, handle any special code in
-		radselect.cpp, and move the smaller classes to their own file.
-
 */
 
 #include "radselectview.h"
 #include "radselectbuttongrid.h"
+#include "radselectconfig.h"
 
 #include <QtCore/QString>
 #include <QtCore/QList>
@@ -54,10 +46,8 @@
 {
 	setupUi(this);
 	//Configure the scrolling area
-	
-	radselectButtonGrid *buttons = new radselectButtonGrid(this);
-	radical_box->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
-//	buttons->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
+
+	buttons = new radselectButtonGrid(this);
 	radical_box->setWidget(buttons);
 	radical_box->setWidgetResizable(true);
 
@@ -74,13 +64,19 @@
 	//Connect our search button
    connect( search_button, SIGNAL( clicked() ), this, SLOT(startSearch()));
 
+	loadSettings();
 }
 
 radselectView::~radselectView()
 {
 }
 
+void
+radselectView::loadSettings() {
+	buttons->setFont(radselectConfigSkeleton::self()->font());
+}
 
+
 void radselectView::startSearch()
 {	//Something has triggered a search... usually a button-press
 	QString radicals_result,grade_result,stroke_result,result;
--- trunk/KDE/kdeedu/kiten/radselect/radselectview.h #582945:582946
@@ -28,6 +28,7 @@
 class QString;
 class QStringList;
 class QListWidgetItem;
+class radselectButtonGrid;
 
 class radselectView : public QWidget, public Ui::radical_selector
 {
@@ -46,6 +47,7 @@
 			//this will be emitted when the user pushes "Search"
 
 private slots:
+	void loadSettings();
 	void startSearch();		//Someone has clicked the search button! (uses getSearchInfo)
 	QString getSearchInfo(QString& radicals_result,QString& grade_result,QString& stroke_result);
 			// Grab all the info this widget provides (returns a formatted search string)
@@ -56,6 +58,7 @@
 
 private: //Private variables
 	QListWidgetItem *victim; //List item to be deleted from the radical search list
+	radselectButtonGrid *buttons;
 
 };
 
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic