Пример #1
0
BOOL COXCustomizeTrayIconPage::OnCloseManager(BOOL bIsOk) 
{	
	CWinApp* pApp=AfxGetApp();
	ASSERT(pApp!=NULL);

	if(bIsOk)
	{
		if(!ApplyChanges())
			return FALSE;
		if(!m_sProfileName.IsEmpty())
		{
			pApp->WriteProfileString(m_sProfileName,
				_T("TrayIconTooltip"),m_sIconTooltip);
			pApp->WriteProfileInt(m_sProfileName,
				_T("ShowTrayIcon"),m_bShowTrayIcon);
			pApp->WriteProfileInt(m_sProfileName,
				_T("UseRightClick"),m_bUseRightClick);
			pApp->WriteProfileInt(m_sProfileName,
				_T("UseDefaultIcon"),m_bUseDefaultIcon);
			pApp->WriteProfileString(m_sProfileName,
				_T("TrayIconSourceFileName"),m_sIconSourceFileName);
			pApp->WriteProfileInt(m_sProfileName,
				_T("IconIndexFromSourceFile"),m_nIconIndex);
		}
	}
	else
	{
		if(!m_sProfileName.IsEmpty())
		{
			m_sIconTooltip=pApp->GetProfileString(m_sProfileName,
				_T("TrayIconTooltip"),m_sIconTooltip);
			m_bShowTrayIcon=pApp->GetProfileInt(m_sProfileName,
				_T("ShowTrayIcon"),m_bShowTrayIcon);
			m_bUseRightClick=pApp->GetProfileInt(m_sProfileName,
				_T("UseRightClick"),m_bUseRightClick);
			m_bUseDefaultIcon=pApp->GetProfileInt(m_sProfileName,
				_T("UseDefaultIcon"),m_bUseDefaultIcon);
			m_sIconSourceFileName=pApp->GetProfileString(m_sProfileName,
				_T("TrayIconSourceFileName"),m_sIconSourceFileName);
			m_nIconIndex=pApp->GetProfileInt(m_sProfileName,
				_T("IconIndexFromSourceFile"),m_nIconIndex);

			if(m_sIconSourceFileName.IsEmpty())
			{
				//get the application path
				::GetModuleFileName(NULL,
					m_sIconSourceFileName.GetBuffer(MAX_PATH),MAX_PATH);
				m_sIconSourceFileName.ReleaseBuffer();
			}

			SetupTrayIcon();
		}
	}

	return TRUE;
}
Пример #2
0
BOOL COXCustomizeTrayIconPage::ApplyChanges()
{
	if(!UpdateData(TRUE))
		return FALSE;

	m_nIconIndex=m_listIcons.GetCurSel();

	m_bUseRightClick=(m_nDisplayMenuEvent==1);
	m_bUseDefaultIcon=(m_nIconSourceType==0);

	SetupTrayIcon();

	return TRUE;
}
Пример #3
0
TopBar::TopBar(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::TopBar)
{
    ui->setupUi(this);

    gLayout = new Layout();
    gSettings = new Settings();

    /* Dialogs */
    aboutDialog = new AboutDialog(this);
    layoutViewer = new LayoutViewer(this);
    settingsDialog = new SettingsDialog(this);

    ui->buttonIcon->installEventFilter(this);

    SetupTopBar();
    SetupPopupMenus();
    SetupTrayIcon();
}
Пример #4
0
Ouroboros::Ouroboros(QWidget *parent) :
    QMainWindow(parent),
    PlayStatus(PLAYSTATUS_STOPPED),
    AnimeProgressStyle(this), //assign this as parent so that stylesheet get inherited
    ui(new Ui::Ouroboros)
{
    ui->setupUi(this);\
    setMouseTracking(true);

    //setup main window
    QString Title = QString(APP_NAME) + " " + QString::number(APP_MAJOR_VERSION) + "." + QString::number(APP_MINOR_VERSION);
    if(APP_DEBUG) Title.append(" Debug");
    this->setWindowTitle(Title);

    //Generate a random seed for other classes
    QTime CurrentTime = QTime::currentTime();
    qsrand((uint)CurrentTime.msec());

    //setup views
    SetViewLayouts();

    //setup tray icon
    SetupTrayIcon();

    //Load settings
    Settings.Load();

    //Load the style
    Theme_Manager.LoadThemeList();
    Theme_Manager.LoadTheme(Settings.Application.Stylesheet);
    this->setStyleSheet(QString(Theme_Manager.GetTheme()));

    //Set the ui for the manager
    GUI_Manager.SetMainWindow(this);

    //Setup Detection
    //Only detects on windows currently
#ifdef WIN32
    File_Manager.SaveMedia();
    //Load Media
    File_Manager.LoadMedia();
    if(Media_Manager.MediaListLoaded)
    {
        DetectionTimer.setInterval(RECOGNITION_TIMEDELAY);
        connect(&DetectionTimer,SIGNAL(timeout()),&Media_Manager,SLOT(DetectAnime()));
        connect(this,SIGNAL(StopDetectionTimer()),&DetectionTimer,SLOT(stop()));
        DetectionTimer.start();
    }
#endif

    //Setup a timer to run the queue every 5 minutes
    QTimer *RunTimer = new QTimer(this);
    connect(RunTimer,SIGNAL(timeout()),&Queue_Manager,SLOT(Run()));
    connect(RunTimer,SIGNAL(timeout()),&Theme_Manager,SLOT(LoadThemeList()));
    RunTimer->start(30000);

    //Connect signals and slots
    connect(RunTimer,SIGNAL(timeout()),&Queue_Manager,SLOT(StartRunning()));
    connect(&Api_Manager,SIGNAL(ChangeStatus(QString,int)),this,SLOT(ChangeStatus(QString,int)));
    connect(&GUI_Manager,SIGNAL(ShowTrayMessage(QString,QString,int)),this,SLOT(ShowTrayMessage(QString,QString,int)));
    connect(&Media_Manager,SIGNAL(ShowTrayMessage(QString,QString,int)),this,SLOT(ShowTrayMessage(QString,QString,int)));
    connect(&Theme_Manager,SIGNAL(ThemeChanged(QString)),this,SLOT(setStyleSheet(QString)));

    //Load user info
    File_Manager.LoadUserInformation();

    //Load history
    File_Manager.LoadHistory();

    //Load local database
    File_Manager.LoadAnimeDatabase();
    GUI_Manager.PopulateModel();

    //Sync anime
    if(CurrentUser.isValid())
    {
        emit ChangeStatus("Syncing ...", 3000);
        Queue_Manager.Sync(true);
    }
}
Пример #5
0
BOOL COXCustomizeTrayIconPage::
InitializeTrayIcon(HICON hIcon, UINT nContextMenuResourceID,
				   LPCTSTR lpszIconTooltip/*=NULL*/, 
				   BOOL bShowTrayIcon/*=TRUE*/, 
				   BOOL bUseRightClick/*=TRUE*/, 
				   LPCTSTR lpszIconSourceFileName/*=NULL*/,
				   LPCTSTR lpszProfileName/*=_T("CustomizeTrayIcon")*/)
{
	ASSERT(hIcon!=NULL);
	m_hOrigIcon=hIcon;

	HINSTANCE hMenuResourceInstance=
		AfxFindResourceHandle(MAKEINTRESOURCE(nContextMenuResourceID),RT_MENU);
	ASSERT(hMenuResourceInstance!=NULL);
	VERIFY(m_contextMenu.LoadMenu(nContextMenuResourceID));

	m_sIconTooltip=lpszIconTooltip;

	m_bShowTrayIcon=bShowTrayIcon;

	m_bUseRightClick=bUseRightClick;

	m_bUseDefaultIcon=TRUE;

	m_sIconSourceFileName=lpszIconSourceFileName;
	m_nIconIndex=-1;

	CWinApp* pApp=AfxGetApp();
	ASSERT(pApp!=NULL);

	if(lpszProfileName!=NULL)
	{
		m_sProfileName=lpszProfileName;
	
		m_sIconTooltip=pApp->GetProfileString(m_sProfileName,
			_T("TrayIconTooltip"),m_sIconTooltip);
		m_bShowTrayIcon=pApp->GetProfileInt(m_sProfileName,
			_T("ShowTrayIcon"),m_bShowTrayIcon);
		m_bUseRightClick=pApp->GetProfileInt(m_sProfileName,
			_T("UseRightClick"),m_bUseRightClick);
		m_bUseDefaultIcon=pApp->GetProfileInt(m_sProfileName,
			_T("UseDefaultIcon"),m_bUseDefaultIcon);
		m_sIconSourceFileName=pApp->GetProfileString(m_sProfileName,
			_T("TrayIconSourceFileName"),m_sIconSourceFileName);
		m_nIconIndex=pApp->GetProfileInt(m_sProfileName,
			_T("IconIndexFromSourceFile"),m_nIconIndex);
	}

	if(m_sIconSourceFileName.IsEmpty())
	{
		//get the application path
		::GetModuleFileName(NULL,m_sIconSourceFileName.GetBuffer(MAX_PATH),MAX_PATH);
		m_sIconSourceFileName.ReleaseBuffer();
	}

	// initialize tray icon
	//
	SetupTrayIcon();
	//
	//////////////////////////////
	
	return TRUE;
}