mirror of
https://github.com/clangen/musikcube.git
synced 2025-01-01 17:58:29 +00:00
Added win32cpp::SysTray to musikServer.
This commit is contained in:
parent
9ae09ba267
commit
14ae9b8a8f
@ -51,10 +51,12 @@
|
||||
#include <win32cpp/LinearLayout.hpp>
|
||||
#include <win32cpp/Label.hpp>
|
||||
#include <win32cpp/Frame.hpp>
|
||||
|
||||
#include <win32cpp/SysTray.hpp>
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
using namespace musik::server;
|
||||
using namespace win32cpp;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@ -88,6 +90,22 @@ void MainWindowController::OnMainWindowCreated(Window* window)
|
||||
}
|
||||
|
||||
|
||||
// Init Tray Icon
|
||||
MenuRef myMenu = Menu::CreatePopup();
|
||||
|
||||
// Create Tray Menu
|
||||
MenuItemRef trayExit = myMenu->Items().Append(MenuItem::Create(_T("E&xit")));
|
||||
|
||||
// Bind Exit to handler
|
||||
trayExit->Activated.connect(this, &MainWindowController::OnFileExit);
|
||||
|
||||
UINT uidTrayIcon = Application::Instance().SysTrayManager()->AddIcon(Application::Instance().MainWindow(), icon);
|
||||
Application::Instance().SysTrayManager()->SetTooltip(uidTrayIcon, _T("musikServer"));
|
||||
Application::Instance().SysTrayManager()->SetPopupMenu(uidTrayIcon, myMenu);
|
||||
Application::Instance().SysTrayManager()->EnableMinimizeToTray(uidTrayIcon);
|
||||
|
||||
|
||||
|
||||
{
|
||||
// Set window size and position
|
||||
musik::core::Preferences windowPrefs("ServerWindow");
|
||||
@ -122,7 +140,12 @@ void MainWindowController::OnMainWindowCreated(Window* window)
|
||||
// Syncpath tab
|
||||
SyncpathView *synpathView = tabs->AddTab(uistring(_T("Sync paths")), new SyncpathView());
|
||||
this->syncpathController = new SyncpathController(*synpathView,&this->server->indexer);
|
||||
|
||||
|
||||
// Users tab
|
||||
Frame *usersView = tabs->AddTab(uistring(_T("Users")), new Frame());
|
||||
|
||||
// Settings tab
|
||||
Frame *settingsView = tabs->AddTab(uistring(_T("Settings")), new Frame());
|
||||
|
||||
|
||||
this->mainFrame->AddChild(mainRowLayout);
|
||||
@ -136,6 +159,11 @@ void MainWindowController::OnMainWindowCreated(Window* window)
|
||||
this->timer.OnTimeout.connect(this,&MainWindowController::UpdateStatus);
|
||||
this->timer.ConnectToWindow(&this->mainWindow);
|
||||
this->timer.Start();
|
||||
|
||||
|
||||
|
||||
this->mainWindow.Show(SW_MINIMIZE);
|
||||
this->mainWindow.Show(SW_HIDE);
|
||||
}
|
||||
|
||||
void MainWindowController::OnResize(Window* window, Size size)
|
||||
@ -160,3 +188,8 @@ void MainWindowController::UpdateStatus(){
|
||||
this->statusLabel->SetCaption( this->server->indexer.GetStatus() );
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindowController::OnFileExit(MenuItemRef menuItem)
|
||||
{
|
||||
Application::Instance().Terminate();
|
||||
}
|
||||
|
@ -71,6 +71,7 @@ class MainWindowController : public EventHandler
|
||||
void OnResize(Window* window, Size size);
|
||||
void OnDestroyed(Window* window);
|
||||
void UpdateStatus();
|
||||
void OnFileExit(MenuItemRef menuItem);
|
||||
|
||||
protected:
|
||||
TopLevelWindow& mainWindow;
|
||||
|
Loading…
Reference in New Issue
Block a user