Commit db4a489b authored by Matthias Messmer's avatar Matthias Messmer

replaced the View menu with pages of the settings dialog

svn path=/trunk/kdeedu/kmplot/; revision=301265
parent 60a29058
......@@ -27,6 +27,7 @@
#include <qdom.h>
#include <qfile.h>
#include <qtooltip.h>
#include <qtabwidget.h>
// KDE includes
#include <kactionclasses.h>
......@@ -68,6 +69,22 @@ MainDlg::MainDlg( const QString sessionId, KCmdLineArgs* args, const char* name
}
m_config = kapp->config();
m_recentFiles->loadEntries( m_config );
// Let's create a Configure Diloag
m_settingsDialog = new KConfigDialog( this, "settings", Settings::self() );
color_settings = new SettingsPageColor( 0, "colorSettings" );
coords_settings = new SettingsPageCoords( 0, "coordsSettings" );
scaling_settings = new SettingsPageScaling( 0, "scalingSettings" );
fonts_settings = new SettingsPageFonts( 0, "fontsSettings" );
m_settingsDialog->addPage( color_settings, i18n( "Colors" ), "colorize" );
m_settingsDialog->addPage( coords_settings, i18n( "Coords" ), "coords" );
m_settingsDialog->addPage( scaling_settings, i18n( "Scaling" ), "scaling" );
m_settingsDialog->addPage( fonts_settings, i18n( "Fonts" ), "fonts" );
// User edited the configuration - update your local copies of the
// configuration data
connect( m_settingsDialog, SIGNAL( settingsChanged() ), this, SLOT(updateSettings() ) );
}
MainDlg::~MainDlg()
......@@ -80,44 +97,52 @@ void MainDlg::setupActions()
// standard actions
KStdAction::openNew( this, SLOT( neu() ), actionCollection() );
KStdAction::open( this, SLOT( load() ), actionCollection() );
m_recentFiles = KStdAction::openRecent( this, SLOT( openRecent( const KURL& ) ),
actionCollection());
m_recentFiles = KStdAction::openRecent( this, SLOT( openRecent( const KURL& ) ), actionCollection());
KStdAction::print( this, SLOT( print() ), actionCollection() );
KStdAction::save( this, SLOT( save() ), actionCollection() );
KStdAction::saveAs( this, SLOT( saveas() ), actionCollection() );
KStdAction::quit( kapp, SLOT( closeAllWindows() ), actionCollection() );
connect( kapp, SIGNAL( lastWindowClosed() ), kapp, SLOT( quit() ) );
KStdAction::helpContents( this, SLOT( hilfe() ), actionCollection(), "helpcontents" );
KStdAction::keyBindings(this, SLOT(optionsConfigureKeys()), actionCollection());
KStdAction::configureToolbars(this, SLOT(optionsConfigureToolbars()), actionCollection());
KStdAction::preferences( this, SLOT( slotSettings() ), actionCollection());
createStandardStatusBarAction();
setStandardToolBarMenuEnabled(true);
// KmPLot specific actions
( void ) new KAction( i18n( "&Axes..." ), 0, this, SLOT( achsen() ), actionCollection(), "axes" );
( void ) new KAction( i18n( "&Scale..." ), 0, this, SLOT( skalierung() ), actionCollection(), "scale" );
( void ) new KAction( i18n( "&Grid..." ), 0, this, SLOT( raster() ), actionCollection(), "grid" );
// file menu
( void ) new KAction( i18n( "E&xport..." ), 0, this, SLOT( doexport() ), actionCollection(), "export");
// edit menu
( void ) new KAction( i18n( "&Colors..." ), "colorize.png", 0, this, SLOT( editColors() ), actionCollection(), "editcolors" );
( void ) new KAction( i18n( "&Axes..." ), "coords.png", 0, this, SLOT( editAxes() ), actionCollection(), "editaxes" );
( void ) new KAction( i18n( "&Grid..." ), "coords.png", 0, this, SLOT( editGrid() ), actionCollection(), "editgrid" );
( void ) new KAction( i18n( "&Scaling..." ), "scaling", 0, this, SLOT( editScaling() ), actionCollection(), "editscaling" );
( void ) new KAction( i18n( "&Fonts..." ), "fonts", 0, this, SLOT( editFonts() ), actionCollection(), "editfonts" );
( void ) new KAction( i18n( "Coordinate System I" ), "ksys1.png", 0, this, SLOT( onachsen1() ), actionCollection(), "coord_i" );
( void ) new KAction( i18n( "Coordinate System II" ), "ksys2.png", 0, this, SLOT( onachsen2() ), actionCollection(), "coord_ii" );
( void ) new KAction( i18n( "Coordinate System III" ), "ksys3.png", 0, this, SLOT( onachsen3() ), actionCollection(), "coord_iii" );
( void ) new KAction( i18n( "&Step..." ), 0, this, SLOT( schrittw() ), actionCollection(), "step" );
view_bezeichnungen = new KToggleAction( i18n( "&Names" ), 0, this, SLOT( bezeichnungen() ), actionCollection(), "names" );
// functions menu
( void ) new KAction( i18n( "&New Function Plot..." ), 0, this, SLOT( onNewFunction() ), actionCollection(), "newfunction" );
( void ) new KAction( i18n( "New Parametric Plot..." ), 0, this, SLOT( onNewParametric() ), actionCollection(), "newparametric" );
( void ) new KAction( i18n( "New Polar Plot..." ), 0, this, SLOT( onNewPolar() ), actionCollection(), "newpolar" );
( void ) new KAction( i18n( "Edit Functions..." ), "kfkt.png", 0, this, SLOT( funktionen() ), actionCollection(), "functions" );
( void ) new KAction( i18n( "Coordinate System I" ), "ksys1.png", 0, this, SLOT( onachsen1() ), actionCollection(), "coord_i" );
( void ) new KAction( i18n( "Coordinate System II" ), "ksys2.png", 0, this, SLOT( onachsen2() ), actionCollection(), "coord_ii" );
( void ) new KAction( i18n( "Coordinate System III" ), "ksys3.png", 0, this, SLOT( onachsen3() ), actionCollection(), "coord_iii" );
( void ) new KAction( i18n( "E&xport..." ), 0, this, SLOT( doexport() ), actionCollection(), "export");
// help menu
view_bezeichnungen = new KToggleAction( i18n( "&Names" ), 0, this, SLOT( bezeichnungen() ), actionCollection(), "names" );
connect( m_quickEdit, SIGNAL( returnPressed( const QString& ) ), this, SLOT( onQuickEdit( const QString& ) ) );
KWidgetAction* quickEditAction = new KWidgetAction( m_quickEdit, i18n( "Quick Edit" ), 0, this, 0, actionCollection(), "quickedit" );
quickEditAction->setWhatsThis( i18n( "Enter a simple function equation here.\n"
"For instance: f(x)=x^2\nFor more options use Functions->Edit Functions... menu." ) );
KStdAction::keyBindings(this, SLOT(optionsConfigureKeys()), actionCollection());
KStdAction::configureToolbars(this, SLOT(optionsConfigureToolbars()), actionCollection());
KStdAction::preferences( this, SLOT( slotSettings() ), actionCollection());
createGUI( locate( "data", "kmplot/kmplotui.rc" ) );
}
......@@ -460,6 +485,38 @@ void MainDlg::print()
}
}
void MainDlg::editColors()
{
m_settingsDialog->showPage( 0 );
m_settingsDialog->show();
}
void MainDlg::editAxes()
{
m_settingsDialog->showPage( 1 );
coords_settings->tabs->setCurrentPage( 0 );
m_settingsDialog->show();
}
void MainDlg::editGrid()
{
m_settingsDialog->showPage( 1 );
coords_settings->tabs->setCurrentPage( 1 );
m_settingsDialog->show();
}
void MainDlg::editScaling()
{
m_settingsDialog->showPage( 2 );
m_settingsDialog->show();
}
void MainDlg::editFonts()
{
m_settingsDialog->showPage( 3 );
m_settingsDialog->show();
}
void MainDlg::bezeichnungen()
{
if ( !bez )
......@@ -525,10 +582,13 @@ void MainDlg::onQuickEdit( const QString& f_str )
void MainDlg::skalierung()
{
SkalDlg skdlg;
/* SkalDlg skdlg;
skdlg.exec();
view->update();
view->update();*/
m_settingsDialog->showPage( 1 );
coords_settings->tabs->setCurrentPage( 1 );
KConfigDialog::showDialog( "settings" );
}
void MainDlg::schrittw()
......@@ -589,30 +649,16 @@ void MainDlg::hilfe()
void MainDlg::slotSettings()
{
// An instance of your dialog could be already created and could be cached,
// in which case you want to display the cached dialog instead of creating
// An instance of your dialog has already been created and has been cached,
// so we want to display the cached dialog instead of creating
// another one
if ( KConfigDialog::showDialog( "settings" ) ) return;
// KConfigDialog didn't find an instance of this dialog, so lets create it :
KConfigDialog* dialog = new KConfigDialog( this, "settings", Settings::self() );
SettingsPageColor* color_settings = new SettingsPageColor( 0, "colorSettings" );
SettingsPageCoords* coords_settings = new SettingsPageCoords( 0, "coordsSettings" );
SettingsPageScaling* scaling_settings = new SettingsPageScaling( 0, "scalingSettings" );
SettingsPageFonts* fonts_settings = new SettingsPageFonts( 0, "fontsSettings" );
dialog->addPage( color_settings, i18n( "Colors" ), "colorize" );
dialog->addPage( coords_settings, i18n( "Coords" ), "coords" );
dialog->addPage( scaling_settings, i18n( "Scaling" ), "scaling" );
dialog->addPage( fonts_settings, i18n( "Fonts" ), "fonts" );
// User edited the configuration - update your local copies of the
// configuration data
// connect( dialog, SIGNAL(settingsChanged()), this, SLOT(updateConfiguration()) );
// These Settings are not meant for the current plot but as default for next new plot.
// So we dont need to update local member variables...
dialog->show();
KConfigDialog::showDialog( "settings" );
}
void MainDlg::updateSettings()
{
getSettings();
view->update();
}
void MainDlg::newToolbarConfig()
......
......@@ -67,8 +67,13 @@
#include "View.h"
class KRecentFilesAction;
class KConfigDialog;
class KLineEdit;
class KRecentFilesAction;
class SettingsPageCoords;
class SettingsPageColor;
class SettingsPageFonts;
class SettingsPageScaling;
class MainDlg : public KMainWindow
{
......@@ -87,6 +92,11 @@ public slots:
void doexport();
void load();
void print();
void editColors();
void editAxes();
void editGrid();
void editScaling();
void editFonts();
void bezeichnungen();
void onNewFunction();
void onNewParametric();
......@@ -130,10 +140,16 @@ private:
KConfig* m_config;
KLineEdit* m_quickEdit;
KConfigDialog* m_settingsDialog;
SettingsPageColor* color_settings;
SettingsPageCoords* coords_settings;
SettingsPageScaling* scaling_settings;
SettingsPageFonts* fonts_settings;
private slots:
void newToolbarConfig();
void optionsConfigureKeys();
void optionsConfigureToolbars();
void updateSettings();
};
#endif // MainDlg_included
......@@ -58,6 +58,10 @@ void KEditFunction::initDialog( const FunctionType t, int index, int y_index )
else setWidgets();
}
/**
* Only show Widgets related to the function type.
* Some WhatsThis texts have to be adjusted, too.
*/
void KEditFunction::setVisibleWidgets()
{
switch( m_type )
......@@ -107,6 +111,9 @@ void KEditFunction::setVisibleWidgets()
updateGeometry();
}
/**
* Clear alls widgets values
*/
void KEditFunction::clearWidgets()
{
kLineEditName->clear();
......@@ -122,6 +129,9 @@ void KEditFunction::clearWidgets()
kColorButtonColor->setColor( "#000000" );
}
/**
* Fill the dialog's widgets with values from the parser
*/
void KEditFunction::setWidgets()
{
QString name, expression;
......@@ -150,6 +160,9 @@ void KEditFunction::setWidgets()
kColorButtonColor->setColor( m_parser->fktext[ m_index ].farbe );
}
/**
* Overwrites the dialog's accept() method to make sure, that the user's input is valid.
*/
void KEditFunction::accept()
{
// if we are editing an existing function, first delete the old one
......@@ -214,9 +227,11 @@ void KEditFunction::accept()
m_parser->fktext[ index ].dicke = kIntNumInputLineWidth->value();
m_parser->fktext[ index ].farbe = kColorButtonColor->color().rgb();
// call inherited method
QEditFunction::accept();
}
QString KEditFunction::newName()
{
int i = 0;
......@@ -238,17 +253,23 @@ QString KEditFunction::newName()
i++;
} while( m_parser->getfix( name.arg( i ) ) != -1 );
// cut of prefix again, will be added later again
// cut off prefix again, will be added later
if( m_type == Parametric || m_type == Polar )
name = name.right( name.length()-1 );
return name.arg( i );
}
/**
* return the well formed function equation
*/
QString KEditFunction::xFunction()
{
return "x" + kLineEditName->text() + "(t)=" + kLineEditXFunction->text();
}
/**
* extract function name and expression from a given expression
*/
void KEditFunction::splitEquation( const QString equation, QString &name, QString &expression )
{
int start = 0;
......@@ -259,6 +280,9 @@ void KEditFunction::splitEquation( const QString equation, QString &name, QStrin
expression = equation.section( '=', 1, 1 );
}
/**
* return the well formed function equation
*/
QString KEditFunction::yFunction()
{
switch( m_type )
......
......@@ -10,11 +10,12 @@
<Action name="newpolar"/>
<Action name="functions"/>
</Menu>
<Menu name="view">
<Action name="axes"/>
<Action name="scale"/>
<Action name="grid"/>
<Action name="step"/>
<Menu name="edit">
<Action name="editcolors"/>
<Action name="editaxes"/>
<Action name="editgrid"/>
<Action name="editscaling"/>
<Action name="editfonts"/>
<Separator />
<Action name="coord_i"/>
<Action name="coord_ii"/>
......
......@@ -50,10 +50,8 @@ GitterFarbe;
bool printtable; // header table printing option
void init()
void getSettings()
{
int ix;
mode = ACHSEN | PFEILE | EXTRAHMEN;
rsw = 1.;
......@@ -131,10 +129,15 @@ void init()
ps.fktext[ 7 ].farbe0 = Settings::color7().rgb();
ps.fktext[ 8 ].farbe0 = Settings::color8().rgb();
ps.fktext[ 9 ].farbe0 = Settings::color9().rgb();
printtable = true;
}
for ( ix = 0; ix < ps.ufanz; ++ix )
void init()
{
getSettings();
for ( int ix = 0; ix < ps.ufanz; ++ix )
ps.delfkt( ix );
printtable = true;
}
/*
......@@ -151,7 +154,7 @@ bool coordToMinMax( const int koord, double &min, double &max, const QString min
break;
case 1:
min = -5.0;
max = 5.5;
max = 5.0;
break;
case 2:
min = 0.0;
......
......@@ -161,12 +161,18 @@ extern QRgb AchsenFarbe,
/** Color of the grid. */
GitterFarbe;
extern bool printtable;
/**< Header table printing option
/** Header table printing option
* @see KPinterDlg
*/
extern bool printtable;
/** Inits all global variables with respect to the global config file @p kc.
*/
void getSettings();
/** Inits all global variables with respect to the global config file @p kc. */
/** Inits all global variables with respect to the global config file @p kc.
* Resetes the parser @p ps.
*/
void init();
/**
......
......@@ -9,7 +9,7 @@
<x>0</x>
<y>0</y>
<width>413</width>
<height>254</height>
<height>256</height>
</rect>
</property>
<property name="caption">
......@@ -21,7 +21,7 @@
</property>
<widget class="QTabWidget">
<property name="name">
<cstring>tabsColor9</cstring>
<cstring>tabs</cstring>
</property>
<widget class="QWidget">
<property name="name">
......@@ -372,7 +372,7 @@
</vbox>
</widget>
<tabstops>
<tabstop>tabsColor9</tabstop>
<tabstop>tabs</tabstop>
<tabstop>kcfg_AxesColor</tabstop>
<tabstop>kcfg_GridColor</tabstop>
<tabstop>kcfg_Color0</tabstop>
......
......@@ -9,7 +9,7 @@
<x>0</x>
<y>0</y>
<width>420</width>
<height>545</height>
<height>547</height>
</rect>
</property>
<property name="caption">
......@@ -21,7 +21,7 @@
</property>
<widget class="QTabWidget">
<property name="name">
<cstring>tabWidget4</cstring>
<cstring>tabs</cstring>
</property>
<widget class="QWidget">
<property name="name">
......@@ -665,7 +665,7 @@
</connection>
</connections>
<tabstops>
<tabstop>tabWidget4</tabstop>
<tabstop>tabs</tabstop>
<tabstop>radioButton1</tabstop>
<tabstop>kcfg_XMin</tabstop>
<tabstop>kcfg_XMax</tabstop>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment