1 /***************************************************************************
2 * KMK - KDE Music Cataloger - the tool for personal *
3 * audio collection management *
5 * Copyright (C) 2006,2007 by Plamen Petrov *
8 * This program is free software; you can redistribute it and/or modify *
9 * it under the terms of the GNU General Public License as published by *
10 * the Free Software Foundation; either version 2 of the License, or *
11 * (at your option) any later version. *
13 * This program is distributed in the hope that it will be useful, *
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16 * GNU General Public License for more details. *
18 * You should have received a copy of the GNU General Public License *
19 * along with this program; if not, write to the *
20 * Free Software Foundation, Inc., *
21 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
22 ***************************************************************************/
24 #include <kapplication.h>
26 #include <qcombobox.h>
27 #include <qcheckbox.h>
28 #include <qpushbutton.h>
30 #include "kmksettings_dialog.h"
31 #include "kmkexternalplayer.h"
32 #define SDLG "Settings Dialog: "
34 //TODO: make the dialog remember initial settings and activate "Save and Apply" only when
35 // there really are changes to save
37 kmkSettingsDialog::kmkSettingsDialog( uint
*rm_flag
)
38 :kmkSettingsBase( 0, "KMK Settings Dialog", FALSE
, Qt::WType_Dialog
| Qt::WDestructiveClose
)
42 s
= new KmkGlobalSettings
;
44 s
->readSettings( kapp
->config() );
46 if( s
->dbg() & KMK_DBG_CONFIG
) kdDebug() << SDLG
"constructor: read config, now will use it..." << endl
;
47 cb_last
->setChecked( s
->loadLast() );
48 cb_geometry
->setChecked( s
->saveGeo() );
49 cb_autoAdj
->setChecked( s
->autoColumnWidth() );
51 for( int er
=0; er
< KMK_NUMBER_OF_SUPPORTED_PLAYERS
; er
++)
52 cmb_Player
->insertItem( QString( kmkExtPlayersNames
[er
] ) );
53 cmb_Player
->setCurrentItem( s
->extPlayer() );
54 cmb_Player
->setEnabled( TRUE
);
55 if( s
->dbg() ) kdDebug() << SDLG
"constructor: currently " << cmb_Player
->count() <<
56 " items in cmb_Player comboBox..." << endl
;
58 if( s
->dbg() & KMK_DBG_SIGNALS
)
59 kdDebug() << SDLG
"constructor: connecting signals to slots... " << endl
;
61 connect( pbSave
, SIGNAL( clicked() ), this, SLOT( slotClicked_pbSave() ) );
62 connect( pbCancel
, SIGNAL( clicked() ), this, SLOT( slotClicked_pbCancel() ) );
64 if( s
->dbg() & KMK_DBG_SIGNALS
)
65 kdDebug() << SDLG
"constructor: done connecting signals!" << endl
;
67 if( s
->dbg() & KMK_DBG_CONFIG
) kdDebug() << SDLG
"constructor: done." << endl
;
72 kmkSettingsDialog::~kmkSettingsDialog()
74 if( s
->dbg() & KMK_DBG_CONFIG
) kdDebug() << SDLG
"destructor: deleting config object." << endl
;
78 void kmkSettingsDialog::slotClicked_pbSave()
80 if( s
->dbg() & KMK_DBG_SIGNALS
) kdDebug() << SDLG
"slotClicked_pbSave: processing request..." << endl
;
81 if( s
->dbg() & KMK_DBG_CONFIG
) kdDebug() << SDLG
"slotClicked_pbSave: saving config..." << endl
;
82 s
->setLoadLast( cb_last
->isChecked() );
83 s
->setSaveGeo( cb_geometry
->isChecked() );
84 s
->setAutoColumnWidth( cb_autoAdj
->isChecked() );
85 s
->setExtPlayer( cmb_Player
->currentItem() );
86 s
->saveSettings( kapp
->config() );
88 if( s
->dbg() ) kdDebug() << SDLG
"slotClicked_pbSave: cmb_Player current item: "
89 << cmb_Player
->currentItem() << endl
;
90 done( Accepted
); // we have WDestructiveClose, so this should delete the dialog
91 if( s
->dbg() & KMK_DBG_CONFIG
) kdDebug() << SDLG
"slotClicked_pbSave: done." << endl
;
92 if( s
->dbg() & KMK_DBG_SIGNALS
) kdDebug() << SDLG
"slotClicked_pbSave: done. " << endl
;
95 void kmkSettingsDialog::slotClicked_pbCancel()
97 if( s
->dbg() & KMK_DBG_SIGNALS
) kdDebug() << SDLG
"slotClicked_pbCancel: processing request..." << endl
;
98 if( s
->dbg() & KMK_DBG_CONFIG
) kdDebug() << SDLG
"slotClicked_pbCancel: NOT saving config..." << endl
;
99 done( Rejected
); // we have WDestructiveClose, so this should delete the dialog
100 if( s
->dbg() & KMK_DBG_SIGNALS
) kdDebug() << SDLG
"slotClicked_pbCancel: done. " << endl
;
103 void kmkSettingsDialog::slotHandle_tag_change( const QString
& m
)
108 #include "kmksettings_dialog.moc"