Commit 58ec83be authored by Joris Guisson's avatar Joris Guisson
Browse files

Backport scroll area config dialog stuff from trunk

svn path=/branches/stable/extragear-kde4/network/ktorrent/; revision=963671
parent 012afcd0
......@@ -10,6 +10,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
......
......@@ -152,7 +152,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);
}
......@@ -695,6 +698,9 @@ namespace kt
group_view->saveState(cfg);
qm->saveState(cfg);
ideal::MainWindow::saveState(cfg);
if (pref_dlg)
pref_dlg->saveState(cfg);
cfg->sync();
}
void GUI::currentTorrentChanged(bt::TorrentInterface* tc)
......
......@@ -18,6 +18,7 @@
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
***************************************************************************/
#include <klocale.h>
#include <kconfigdialogmanager.h>
......@@ -43,7 +44,6 @@ namespace kt
{
setupUi(this);
}
virtual ~QMPref() {}
void loadSettings()
......@@ -135,19 +135,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;
}
}
}
......@@ -159,20 +166,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()
......@@ -189,6 +196,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