Пример #1
0
rc_t CC KMain(int argc, char* argv[]) {
    rc_t rc = 0;

    Params prm;
    KConfig* cfg = NULL;

    if (rc == 0)
    {   rc = ParamsConstruct(argc, argv, &prm); }

    if (rc == 0) {
        rc = KConfigMake(&cfg, NULL);
        DISP_RC(rc, "while calling KConfigMake");
    }

    if (rc == 0) {
        if (prm.modeSetNode)
        {   rc = SetNode(cfg, &prm); }
        if (prm.modeShowCfg)
        {   rc = ShowConfig(cfg, &prm); }
        if (prm.modeShowFiles) {
            rc_t rc3 = ShowFiles(cfg, &prm);
            if (rc3 != 0 && rc == 0)
            {   rc = rc3; }
        }
        if (prm.modeShowModules) {
            rc_t rc3 = ShowModules(cfg, &prm);
            if (rc3 != 0 && rc == 0)
            {   rc = rc3; }
        }
        if (prm.modeShowLoadPath) {
            const char* path = NULL;
            rc_t rc3 = KConfigGetLoadPath(cfg, &path);
            if (rc3 == 0) {
                if (path != NULL && path[0])
                {   OUTMSG(("%s\n", path)); }
            }
            else if (rc == 0)
            {   rc = rc3; }
        }
    }

    if (prm.modeShowEnv)
    {   ShowEnv(&prm); }

    RELEASE(KConfig, cfg);

    if (rc == 0 && prm.modeCreate)
    {   rc = CreateConfig(argv[0]); }

    ParamsDestruct(&prm);
    return rc;
}
Пример #2
0
QmitkAboutDialog::QmitkAboutDialog(QWidget* parent, Qt::WindowFlags f)
    : QDialog(parent, f)
{
    m_GUI.setupUi(this);

    QString mitkRevision(MITK_REVISION);
    QString mitkRevisionDescription(MITK_REVISION_DESC);
    QString itkVersion = QString("%1.%2.%3").arg(ITK_VERSION_MAJOR).arg(ITK_VERSION_MINOR).arg(ITK_VERSION_PATCH);
    QString vtkVersion = QString("%1.%2.%3").arg(VTK_MAJOR_VERSION).arg(VTK_MINOR_VERSION).arg(VTK_BUILD_VERSION);

    QString revisionText = QString("Revision: %1").arg(MITK_REVISION);

    if (!QString(MITK_REVISION_DESC).isEmpty())
        revisionText += QString("\nDescription: %1").arg(MITK_REVISION_DESC);

    m_GUI.m_RevisionLabel->setText(revisionText);
    m_GUI.m_ToolkitVersionsLabel->setText(QString("ITK %1, VTK %2, Qt %3").arg(itkVersion, vtkVersion, QT_VERSION_STR));

    QPushButton* btnModules = new QPushButton(QIcon(":/qmitk/ModuleView.png"), "Modules");
    m_GUI.m_ButtonBox->addButton(btnModules, QDialogButtonBox::ActionRole);

    connect(btnModules, SIGNAL(clicked()), this, SLOT(ShowModules()));
    connect(m_GUI.m_ButtonBox, SIGNAL(rejected()), this, SLOT(reject()));
}
//
// ThreadProc
//
void FullscreenMonitor::ThreadProc()
{
    
#if defined(_DEBUG)
    DbgSetCurrentThreadName("LS FullscreenMonitor Service");
#endif

    //
    struct FSWindow {
        FSWindow(HWND hWnd, HMONITOR hMonitor) {
            this->hWnd = hWnd;
            this->hMonitor = hMonitor;
        }
        HWND hWnd;
        HMONITOR hMonitor;
    };

    // List of all currently living known fullscreen windows
    std::list<FSWindow> fullscreenWindows;

    // The monitors which currently have modules hidden
    std::unordered_multiset<HMONITOR> hiddenMonitors;

    DWORD dwLiteStepProcID;
    GetWindowThreadProcessId(GetLitestepWnd(), &dwLiteStepProcID);

    // On startup, find any existing fullscreen windows.
    EnumDesktopWindows(nullptr, [] (HWND hWnd, LPARAM lParam) -> BOOL
    {
        HMONITOR hMonitor = IsFullscreenWindow(hWnd);
        std::list<FSWindow> *fullscreenWindows = (std::list<FSWindow>*)lParam;
        if (hMonitor)
        {
            // And add it to the list of fullscreen windows.
            fullscreenWindows->push_back(FSWindow(hWnd, hMonitor));
        }
        return TRUE;
    }, (LPARAM)&fullscreenWindows);

    // Hide modules on any monitor we found
    for (FSWindow window : fullscreenWindows)
    {
        hiddenMonitors.insert(window.hMonitor);
        if (hiddenMonitors.count(window.hMonitor) == 1)
        {
            HideModules(window.hMonitor, window.hWnd);
        }
    }

    // Main Loop
    while (m_bRun.load())
    {
        HWND hwndForeGround = GetForegroundWindow();
        bool bCheckedForeGround = false;

        // Re-Hide modules on all monitors
        if (m_bReHide.load())
        {
            hiddenMonitors.clear();
            for (FSWindow window : fullscreenWindows)
            {
                hiddenMonitors.insert(window.hMonitor);
                if (hiddenMonitors.count(window.hMonitor) == 1)
                {
                    HideModules(window.hMonitor, window.hWnd);
                }
            }
        }

        // Verify that all currently known fullscreen windows are still fullscreen.
        std::list<FSWindow>::iterator iter = fullscreenWindows.begin();
        while (iter != fullscreenWindows.end())
        {
            HMONITOR hNewMonitor = IsFullscreenWindow(iter->hWnd);

            // If we already checked the foreground window, don't bother doing it again.
            if (iter->hWnd == hwndForeGround)
            {
                bCheckedForeGround = true;
            }

            // 
            if (hNewMonitor != iter->hMonitor)
            {
                hiddenMonitors.erase(iter->hMonitor);

                // If there are no fullscreen windows left on the monitor, show the modules
                if (hiddenMonitors.count(iter->hMonitor) == 0)
                {
                    ShowModules(iter->hMonitor);
                }

                // Check if the window moved to another monitor (and stayed fullscreen)
                if (hNewMonitor)
                {
                    iter->hMonitor = hNewMonitor;
                    hiddenMonitors.insert(hNewMonitor);
                    if (hiddenMonitors.count(hNewMonitor) == 1)
                    {
                        HideModules(hNewMonitor, iter->hWnd);
                    }
                }
                else
                {
                    iter = fullscreenWindows.erase(iter);
                    continue;
                }
            }

            ++iter;
        }

        // Check if the currently active window is a fullscreen window.
        if (!bCheckedForeGround)
        {
            // If the currently active window belongs to litestep, show all modules.
            DWORD dwProcID;
            GetWindowThreadProcessId(hwndForeGround, &dwProcID);
            if (dwProcID == dwLiteStepProcID)
            {
                if (!hiddenMonitors.empty())
                {
                    for (HMONITOR hMonitor : hiddenMonitors)
                    {
                        ShowModules(hMonitor);
                    }
                    hiddenMonitors.clear();
                    fullscreenWindows.clear();
                }
            }
            else
            {
                HMONITOR hMonitor = IsFullscreenWindow(hwndForeGround);
                if (hMonitor)
                {
                    // Add the window to the list of known foreground windows.
                    fullscreenWindows.push_back(FSWindow(hwndForeGround, hMonitor));
                    hiddenMonitors.insert(hMonitor);

                    // If we didn't know about any fullscreen windows on this monitor before, hide the modules on it.
                    if (hiddenMonitors.count(hMonitor) == 1)
                    {
                        HideModules(hMonitor, hwndForeGround);
                    }
                }
            }
        }

        // Avoid using excesive amounts of CPU time
        std::this_thread::sleep_for(m_workerSleepDuration);
    }
}