← Back to team overview

linuxdcpp-team team mailing list archive

[Branch ~dcplusplus-team/dcplusplus/trunk] Rev 2485: Remember the last settings page

 

------------------------------------------------------------
revno: 2485
committer: poy <poy@xxxxxxxxxx>
branch nick: trunk
timestamp: Mon 2011-04-11 23:26:22 +0200
message:
  Remember the last settings page
modified:
  changelog.txt
  dcpp/SettingsManager.cpp
  dcpp/SettingsManager.h
  win32/PropPage.cpp
  win32/SettingsDialog.cpp
  win32/SettingsDialog.h


--
lp:dcplusplus
https://code.launchpad.net/~dcplusplus-team/dcplusplus/trunk

Your team Dcplusplus-team is subscribed to branch lp:dcplusplus.
To unsubscribe from this branch go to https://code.launchpad.net/~dcplusplus-team/dcplusplus/trunk/+edit-subscription
=== modified file 'changelog.txt'
--- changelog.txt	2011-04-11 20:39:22 +0000
+++ changelog.txt	2011-04-11 21:26:22 +0000
@@ -17,6 +17,7 @@
 * [L#748623] Port mappers respect the bind address (poy)
 * Make more parts of the interface DPI-aware (poy)
 * Resizable and scrollable settings dialog
+* Remember the last settings page (poy)
 
 -- 0.782 2011-03-05 --
 * Prevent a remote crash triggered via malformed user commands (poy)

=== modified file 'dcpp/SettingsManager.cpp'
--- dcpp/SettingsManager.cpp	2011-04-11 20:39:22 +0000
+++ dcpp/SettingsManager.cpp	2011-04-11 21:26:22 +0000
@@ -52,7 +52,7 @@
 	"LogFormatSystem", "LogFormatStatus", "DirectoryListingFrameOrder", "DirectoryListingFrameWidths",
 	"TLSPrivateKeyFile", "TLSCertificateFile", "TLSTrustedCertificatesPath",
 	"Language", "DownloadsOrder", "DownloadsWidth", "Toolbar", "LastSearchType",
-	"SoundMainChat", "SoundPM", "SoundPMWindow", "Mapper",
+	"SoundMainChat", "SoundPM", "SoundPMWindow", "Mapper", "SettingsPage",
 	"SENTRY",
 	// Ints
 	"IncomingConnections", "InPort", "Slots", "AutoFollow", "ClearSearch",

=== modified file 'dcpp/SettingsManager.h'
--- dcpp/SettingsManager.h	2011-04-11 20:39:22 +0000
+++ dcpp/SettingsManager.h	2011-04-11 21:26:22 +0000
@@ -70,7 +70,7 @@
 		LOG_FILE_SYSTEM, LOG_FORMAT_SYSTEM, LOG_FORMAT_STATUS, DIRECTORYLISTINGFRAME_ORDER, DIRECTORYLISTINGFRAME_WIDTHS,
 		TLS_PRIVATE_KEY_FILE, TLS_CERTIFICATE_FILE, TLS_TRUSTED_CERTIFICATES_PATH,
 		LANGUAGE, DOWNLOADS_ORDER, DOWNLOADS_WIDTHS, TOOLBAR, LAST_SEARCH_TYPE,
-		SOUND_MAIN_CHAT, SOUND_PM, SOUND_PM_WINDOW, MAPPER,
+		SOUND_MAIN_CHAT, SOUND_PM, SOUND_PM_WINDOW, MAPPER, SETTINGS_PAGE,
 		STR_LAST };
 
 	enum IntSetting { INT_FIRST = STR_LAST + 1,

=== modified file 'win32/PropPage.cpp'
--- win32/PropPage.cpp	2011-04-11 20:39:22 +0000
+++ win32/PropPage.cpp	2011-04-11 21:26:22 +0000
@@ -28,6 +28,8 @@
 #include <dcpp/SettingsManager.h>
 #include "WinUtil.h"
 
+const dwt::Rectangle padding(7, 4, 14, 21);
+
 PropPage::PropPage(dwt::Widget* parent, int rows, int cols) : dwt::ModelessDialog(parent), grid(0) {
 	create();
 
@@ -42,7 +44,7 @@
 
 void PropPage::layout() {
 	auto clientSize = getClientSize();
-	grid->resize(dwt::Rectangle(7, 4, clientSize.x - 14, clientSize.y - 21));
+	grid->resize(dwt::Rectangle(padding.left(), padding.top(), clientSize.x - padding.width(), clientSize.y - padding.height()));
 }
 
 void PropPage::read(const ItemList& items) {
@@ -135,7 +137,7 @@
 }
 
 dwt::Point PropPage::getPreferredSize() {
-	return grid->getPreferredSize();
+	return grid->getPreferredSize() + dwt::Point(padding.right(), padding.bottom());
 }
 
 void PropPage::handleListHelp(TablePtr list, unsigned id) {

=== modified file 'win32/SettingsDialog.cpp'
--- win32/SettingsDialog.cpp	2011-04-11 20:39:22 +0000
+++ win32/SettingsDialog.cpp	2011-04-11 21:26:22 +0000
@@ -121,38 +121,46 @@
 		}
 
 		auto container = cur->addChild(dwt::ScrolledContainer::Seed(WS_BORDER));
+		const auto setting = Text::toT(SETTING(SETTINGS_PAGE));
+		auto addPage = [this, container, &setting](const tstring& title, PropPage* page, HTREEITEM parent) -> HTREEITEM {
+			pages.push_back(page);
+			auto ret = tree->insert(title, parent, reinterpret_cast<LPARAM>(page), true);
+			if(title == setting)
+				callAsync([=] { tree->setSelected(ret); });
+			return ret;
+		};
 
-		addPage(T_("Personal information"), new GeneralPage(container));
+		addPage(T_("Personal information"), new GeneralPage(container), TVI_ROOT);
 
 		{
-			HTREEITEM item = addPage(T_("Connectivity"), new ConnectivityPage(container));
+			HTREEITEM item = addPage(T_("Connectivity"), new ConnectivityPage(container), TVI_ROOT);
 			addPage(T_("Manual configuration"), new ConnectivityManualPage(container), item);
 			addPage(T_("Bandwidth limiting"), new BandwidthLimitPage(container), item);
 			addPage(T_("Proxy"), new ProxyPage(container), item);
 		}
 
 		{
-			HTREEITEM item = addPage(T_("Downloads"), new DownloadPage(container));
+			HTREEITEM item = addPage(T_("Downloads"), new DownloadPage(container), TVI_ROOT);
 			addPage(T_("Favorites"), new FavoriteDirsPage(container), item);
 			addPage(T_("Queue"), new QueuePage(container), item);
 		}
 
-		addPage(T_("Sharing"), new UploadPage(container));
+		addPage(T_("Sharing"), new UploadPage(container), TVI_ROOT);
 
 		{
-			HTREEITEM item = addPage(T_("Appearance"), new AppearancePage(container));
+			HTREEITEM item = addPage(T_("Appearance"), new AppearancePage(container), TVI_ROOT);
 			addPage(T_("Colors and sounds"), new Appearance2Page(container), item);
 			addPage(T_("Tabs"), new TabsPage(container), item);
 			addPage(T_("Windows"), new WindowsPage(container), item);
 		}
 
 		{
-			HTREEITEM item = addPage(T_("History"), new HistoryPage(container));
+			HTREEITEM item = addPage(T_("History"), new HistoryPage(container), TVI_ROOT);
 			addPage(T_("Logs"), new LogPage(container), item);
 		}
 
 		{
-			HTREEITEM item = addPage(T_("Advanced"), new AdvancedPage(container));
+			HTREEITEM item = addPage(T_("Advanced"), new AdvancedPage(container), TVI_ROOT);
 			addPage(T_("Experts only"), new ExpertsPage(container), item);
 			addPage(T_("User commands"), new UCPage(container), item);
 			addPage(T_("Security certificates"), new CertificatesPage(container), item);
@@ -227,11 +235,6 @@
 	help->setText(Text::toT(WinUtil::getHelpText(widget->getHelpId())));
 }
 
-HTREEITEM SettingsDialog::addPage(const tstring& title, PropPage* page, HTREEITEM parent) {
-	pages.push_back(page);
-	return tree->insert(title, parent, reinterpret_cast<LPARAM>(page), true);
-}
-
 void SettingsDialog::handleHelp(dwt::Control* widget, unsigned id) {
 	if(id == IDH_INDEX && currentPage)
 		id = currentPage->getHelpId();
@@ -245,6 +248,8 @@
 	SettingsManager::getInstance()->set(SettingsManager::SETTINGS_HEIGHT,
 		static_cast<int>(static_cast<float>(pt.y) / dwt::util::dpiFactor()));
 
+	SettingsManager::getInstance()->set(SettingsManager::SETTINGS_PAGE, Text::fromT(tree->getSelectedText()));
+
 	return true;
 }
 

=== modified file 'win32/SettingsDialog.h'
--- win32/SettingsDialog.h	2011-04-11 20:39:22 +0000
+++ win32/SettingsDialog.h	2011-04-11 21:26:22 +0000
@@ -41,7 +41,6 @@
 	TreePtr tree;
 	RichTextBoxPtr help;
 
-	HTREEITEM addPage(const tstring& title, PropPage* page, HTREEITEM parent = TVI_ROOT);
 	void updateTitle();
 	void write();