void TermMainWindow::setup_ViewMenu_Actions()
{
    toggleBorder = new QAction(tr("Hide Window Borders"), this);
    //toggleBorder->setObjectName("toggle_Borderless");
    toggleBorder->setCheckable(true);
// TODO/FIXME: it's broken somehow. When I call toggleBorderless() here the non-responsive window appear
//    toggleBorder->setChecked(Properties::Instance()->borderless);
//    if (Properties::Instance()->borderless)
//        toggleBorderless();
    connect(toggleBorder, SIGNAL(triggered()), this, SLOT(toggleBorderless()));
    menu_Window->addAction(toggleBorder);
    toggleBorder->setVisible(true);

    QSettings settings;
    settings.beginGroup("Shortcuts");
    Properties::Instance()->actions[TOGGLE_BOOKMARKS] = m_bookmarksDock->toggleViewAction();
    QKeySequence seq = QKeySequence::fromString( settings.value(TOGGLE_BOOKMARKS, TOGGLE_BOOKMARKS_SHORTCUT).toString() );
    Properties::Instance()->actions[TOGGLE_BOOKMARKS]->setShortcut(seq);
    menu_Window->addAction(Properties::Instance()->actions[TOGGLE_BOOKMARKS]);
    settings.endGroup();

    menu_Window->addSeparator();

    /* Scrollbar */
    scrollBarPosition = new QActionGroup(this);
    QAction *scrollNone = new QAction(tr("None"), this);
    QAction *scrollRight = new QAction(tr("Right"), this);
    QAction *scrollLeft = new QAction(tr("Left"), this);

    /* order of insertion is dep. on QTermWidget::ScrollBarPosition enum */
    scrollBarPosition->addAction(scrollNone);
    scrollBarPosition->addAction(scrollLeft);
    scrollBarPosition->addAction(scrollRight);

    for(int i = 0; i < scrollBarPosition->actions().size(); ++i)
        scrollBarPosition->actions().at(i)->setCheckable(true);

    if( Properties::Instance()->scrollBarPos < scrollBarPosition->actions().size() )
        scrollBarPosition->actions().at(Properties::Instance()->scrollBarPos)->setChecked(true);

    connect(scrollBarPosition, SIGNAL(triggered(QAction *)),
             consoleTabulator, SLOT(changeScrollPosition(QAction *)) );

    scrollPosMenu = new QMenu(tr("Scrollbar Layout"), menu_Window);
    scrollPosMenu->setObjectName("scrollPosMenu");

    for(int i=0; i < scrollBarPosition->actions().size(); ++i) {
        scrollPosMenu->addAction(scrollBarPosition->actions().at(i));
    }

    menu_Window->addMenu(scrollPosMenu);
}
Exemplo n.º 2
0
BorderlessWindow::BorderlessWindow(QApplication* app, HBRUSH windowBackground, const int width, const int height) : hWnd(0),
    hInstance(GetModuleHandle(NULL)),
    closed(false),
    visible(false),
    borderless(false),
    borderlessResizeable(true),
    aeroShadow(false)
{
    WNDCLASSEX wcx = {0};
    wcx.cbSize = sizeof(WNDCLASSEX);
    wcx.style = CS_HREDRAW | CS_VREDRAW;
    wcx.hInstance = hInstance;
    wcx.lpfnWndProc = WndProc;
    wcx.cbClsExtra	= 0;
    wcx.cbWndExtra	= 0;
    wcx.lpszClassName = L"WindowClass";
    wcx.hbrBackground = windowBackground;
    wcx.hCursor = LoadCursor( hInstance, IDC_ARROW );
    RegisterClassEx(&wcx);
    if (FAILED(RegisterClassEx(&wcx))) throw std::runtime_error("Couldn't register window class");

    // Center window at runtime
    QRect rec = QApplication::desktop()->screenGeometry();
    int x = rec.width();
    int y = rec.height();
    int offsetX = (x - width) / 2;
    int offsetY = (y - (y * 0.05) - height) / 2;    // Compensate for taskbar

    hWnd = CreateWindow(L"WindowClass", L"Project Ascension", static_cast<DWORD>( Style::windowed ), offsetX, offsetY, width, height, 0, 0, hInstance, nullptr);

    if (!hWnd) throw std::runtime_error("Encountered an unknown error while constructing the launcher window.");

    SetWindowLongPtr(hWnd, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(this));


    mainPanel = new WinWindow(hWnd);
    g_winId = (HWND)mainPanel->winId();

    show();
    toggleBorderless();

    a = app;
}