Saving window size using musik::core::Preferences

This commit is contained in:
Daniel Önnerby 2008-08-12 08:39:16 +00:00
parent 8845c38038
commit 89e29f62f3
5 changed files with 43 additions and 15 deletions

View File

@ -91,6 +91,23 @@ utfstring Preferences::GetString(const char* key,const utfchar* defaultValue){
return defaultValue;
}
void Preferences::SetBool(const char* key,bool value){
boost::mutex::scoped_lock lock(IO::Instance()->mutex);
this->IOPtr->SaveSetting(this->nameSpace.c_str(),key,Setting(value));
}
void Preferences::SetInt(const char* key,int value){
boost::mutex::scoped_lock lock(IO::Instance()->mutex);
this->IOPtr->SaveSetting(this->nameSpace.c_str(),key,Setting(value));
}
void Preferences::SetString(const char* key,const utfchar* value){
boost::mutex::scoped_lock lock(IO::Instance()->mutex);
this->IOPtr->SaveSetting(this->nameSpace.c_str(),key,Setting(utfstring(value)));
}
//////////////////////////////////////////////////////////////////////////////
Preferences::IO::Ptr Preferences::IO::Instance(){

View File

@ -58,8 +58,13 @@ class Preferences{
int GetInt(const char* key,int defaultValue);
utfstring GetString(const char* key,const utfchar* defaultValue);
void SetBool(const char* key,bool value);
void SetInt(const char* key,int value);
void SetString(const char* key,const utfchar* value);
std::string nameSpace;
private:
class Setting{
public:

View File

@ -111,7 +111,7 @@ int Connection::Open(const utfchar *database,unsigned int options,unsigned int c
///Error code returned by SQLite
//////////////////////////////////////////
int Connection::Open(const utfstring &database,unsigned int options,unsigned int cache){
sqlite3_enable_shared_cache(1);
// sqlite3_enable_shared_cache(1);
int error;
#ifdef UTF_WIDECHAR

View File

@ -43,8 +43,7 @@
#include <cube/LibraryWindowView.hpp>
#include <cube/TransportController.hpp>
#include <core/LibraryFactory.h>
#include <core/Pluginfactory.h>
#include <core/Preferences.h>
#include <cube/resources/resource.h>
@ -66,18 +65,10 @@ using namespace musik::cube;
, menuController(mainWindow)
, libraryController(NULL)
{
musik::core::PluginFactory::Instance();
this->mainWindow.Created.connect(
this, &MainWindowController::OnMainWindowCreated);
// Connect the local library to the
/*
this->LibraryCallbackTimer.ConnectToWindow(&mainWindow);
this->LibraryCallbackTimer.OnTimeout.connect(this,&MainWindowController::QueryQueueLoop);
musik::core::LibraryFactory::GetCurrentLibrary()->OnQueryQueueStart.connect(this,&MainWindowController::QueryQueueStart);
musik::core::LibraryFactory::GetCurrentLibrary()->OnQueryQueueEnd.connect(this,&MainWindowController::QueryQueueEnd);
*/
}
MainWindowController::~MainWindowController()
@ -101,9 +92,12 @@ void MainWindowController::OnMainWindowCreated(Window* window)
static const int TransportViewHeight = 54;
this->mainWindow.MoveTo(200, 200);
this->mainWindow.Resize(700, 480);
this->mainWindow.SetMinimumSize(Size(320, 240));
{
musik::core::Preferences windowPrefs("MainWindow");
this->mainWindow.MoveTo(windowPrefs.GetInt("x",200), windowPrefs.GetInt("y",200));
this->mainWindow.Resize(windowPrefs.GetInt("width",700), windowPrefs.GetInt("height",480));
this->mainWindow.SetMinimumSize(Size(320, 240));
}
Size clientSize = this->mainWindow.ClientSize();
@ -129,11 +123,22 @@ void MainWindowController::OnMainWindowCreated(Window* window)
this->clientView = transportSplitter;
this->mainWindow.Resized.connect(this, &MainWindowController::OnResize);
this->mainWindow.Destroyed.connect(this, &MainWindowController::OnDestroyed);
}
void MainWindowController::OnResize(Window* window, Size size)
void MainWindowController::OnResize(Window* window, Size size)
{
RedrawLock redrawLock(this->clientView);
this->clientView->Resize(this->mainWindow.ClientSize());
}
void MainWindowController::OnDestroyed(Window* window)
{
Point location( window->Location() );
Size size( window->WindowSize() );
musik::core::Preferences windowPrefs("MainWindow");
windowPrefs.SetInt("x",location.x);
windowPrefs.SetInt("y",location.y);
windowPrefs.SetInt("width",size.width);
windowPrefs.SetInt("height",size.height);
}

View File

@ -76,6 +76,7 @@ public: /*dtor*/ ~MainWindowController();
protected: void OnMainWindowCreated(Window* window);
protected: void OnResize(Window* window, Size size);
protected: void OnDestroyed(Window* window);
protected: TopLevelWindow& mainWindow;
protected: Splitter* clientView;