Commit 48837b3f authored by Joris Guisson's avatar Joris Guisson
Browse files

Config dialog now embeds pages in scroll areas, so that the dialog also is useable on small screens


svn path=/trunk/extragear/network/ktorrent/; revision=963670
parent e96439f2
......@@ -38,6 +38,7 @@ Changes in 3.2.2 :
- Fix bug causing drag and drop of torrent on to plasma desktop not to work
- Increase numwant to 200 and the maximum number of potential peers to 500
- Cancel all scan dialogs before exiting, this fixes a crash (191487)
- Config dialog now embeds pages in scroll areas, so that the dialog also is useable on small screens
Changes in 3.2.1 :
- Resort torrents if display name is changed
......
......@@ -139,7 +139,10 @@ namespace kt
void GUI::addPrefPage(PrefPageInterface* page)
{
if (!pref_dlg)
{
pref_dlg = new PrefDialog(this,core);
pref_dlg->loadState(KGlobal::config());
}
pref_dlg->addPrefPage(page);
}
......@@ -519,6 +522,8 @@ namespace kt
g.writeEntry("hidden_on_exit",isHidden());
torrent_activity->saveState(cfg);
central->saveState(cfg);
if (pref_dlg)
pref_dlg->saveState(cfg);
cfg->sync();
}
......
......@@ -18,6 +18,7 @@
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
***************************************************************************/
#include <klocale.h>
#include <kconfigdialogmanager.h>
#include "settings.h"
......@@ -34,7 +35,6 @@
namespace kt
{
PrefDialog::PrefDialog(QWidget* parent,Core* core) : KConfigDialog(parent,"settings",Settings::self())
......@@ -60,19 +60,26 @@ namespace kt
void PrefDialog::addPrefPage(PrefPageInterface* page)
{
KPageWidgetItem* p = addPage(page,page->config(),page->pageName(),page->pageIcon());
pages.insert(page,p);
PrefPageScrollArea* area = new PrefPageScrollArea(page,this);
KPageWidgetItem* p = addPage(area,page->config(),page->pageName(),page->pageIcon());
area->page_widget_item = p;
pages.append(area);
if (!isHidden())
page->loadSettings();
}
void PrefDialog::removePrefPage(PrefPageInterface* page)
{
KPageWidgetItem* p = pages.value(page);
if (p)
foreach (PrefPageScrollArea* area,pages)
{
removePage(p);
pages.remove(page);
if (area->page == page)
{
area->takeWidget();
pages.removeAll(area);
removePage(area->page_widget_item);
break;
}
}
}
......@@ -84,20 +91,20 @@ namespace kt
void PrefDialog::updateWidgets()
{
foreach (PrefPageInterface* p,pages.keys())
p->loadSettings();
foreach (PrefPageScrollArea* area,pages)
area->page->loadSettings();
}
void PrefDialog::updateWidgetsDefault()
{
foreach (PrefPageInterface* p,pages.keys())
p->loadDefaults();
foreach (PrefPageScrollArea* area,pages)
area->page->loadDefaults();
}
void PrefDialog::updateSettings()
{
foreach (PrefPageInterface* p,pages.keys())
p->updateSettings();
foreach (PrefPageScrollArea* area,pages)
area->page->updateSettings();
}
void PrefDialog::calculateRecommendedSettings()
......@@ -114,6 +121,34 @@ namespace kt
net_pref->kcfg_maxTotalConnections->setValue(dlg.max_conn_glob);
}
}
void PrefDialog::loadState(KSharedConfigPtr cfg)
{
KConfigGroup g = cfg->group("PrefDialog");
QSize s = g.readEntry("size",sizeHint());
resize(s);
}
void PrefDialog::saveState(KSharedConfigPtr cfg)
{
KConfigGroup g = cfg->group("PrefDialog");
g.writeEntry("size",size());
}
///////////////////////////////////////
PrefPageScrollArea::PrefPageScrollArea(kt::PrefPageInterface* page, QWidget* parent) : QScrollArea(parent),page(page),page_widget_item(0)
{
setWidget(page);
setWidgetResizable(true);
setFrameStyle(QFrame::NoFrame);
viewport()->setAutoFillBackground(false);
}
PrefPageScrollArea::~PrefPageScrollArea()
{
}
}
......
......@@ -21,7 +21,8 @@
#ifndef KT_PREFDIALOG_HH
#define KT_PREFDIALOG_HH
#include <QMap>
#include <QList>
#include <QScrollArea>
#include <kconfigdialog.h>
namespace kt
......@@ -30,6 +31,7 @@ namespace kt
class PrefPageInterface;
class NetworkPref;
class QMPref;
class PrefPageScrollArea;
/**
* KTorrent's preferences dialog, this uses the new KConfigDialog class which should make our live much easier.
......@@ -60,6 +62,16 @@ namespace kt
* Update the widgets and show
*/
void updateWidgetsAndShow();
/**
* Load the state of the dialog
*/
void loadState(KSharedConfigPtr cfg);
/**
* Save the state of the dialog
*/
void saveState(KSharedConfigPtr cfg);
protected:
virtual void updateWidgets();
......@@ -70,10 +82,20 @@ namespace kt
void calculateRecommendedSettings();
private:
QMap<PrefPageInterface*,KPageWidgetItem*> pages;
QList<PrefPageScrollArea*> pages;
NetworkPref* net_pref;
QMPref* qm_pref;
};
class PrefPageScrollArea : public QScrollArea
{
public:
PrefPageScrollArea(PrefPageInterface* page,QWidget* parent = 0);
virtual ~PrefPageScrollArea();
PrefPageInterface* page;
KPageWidgetItem* page_widget_item;
};
}
......
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