Пример #1
0
void TabBar::setupHistoryActions()
{
    MainWindow *w = Application::instance()->mainWindow();
    MainView *mv = qobject_cast<MainView *>(parent());

    QAction *openLastClosedTabAction = w->actionByName( QL1S("open_last_closed_tab") );
    openLastClosedTabAction->setEnabled( mv->recentlyClosedTabs().size() > 0 );

    // update closed tabs menu
    KActionMenu *am = qobject_cast<KActionMenu *>( w->actionByName( QL1S("closed_tab_menu") ));
    if (!am)
        return;

    bool isEnabled = ( mv->recentlyClosedTabs().size() > 0 );
    am->setEnabled(isEnabled);

    if (am->menu())
        am->menu()->clear();

    if(!isEnabled)
        return;

    Q_FOREACH(const HistoryItem &item, mv->recentlyClosedTabs())
    {
        KAction *a = new KAction(Application::iconManager()->iconForUrl(item.url), item.title, this);
        a->setData(item.url);
        connect(a, SIGNAL(triggered()), mv, SLOT(openClosedTab()));
        am->addAction(a);
    }
}
Пример #2
0
void TabBar::mouseReleaseEvent(QMouseEvent *event)
{
    MainView *mv = qobject_cast<MainView *>(parent());
    QTimer::singleShot(200, mv->addTabButton(), SLOT(show()));

    KTabBar::mouseReleaseEvent(event);
}
Пример #3
0
Application::Application(int argc, char** argv) :
    QApplication(argc, argv)
{
    QCoreApplication::setOrganizationName("ZeroC");
    QCoreApplication::setOrganizationDomain("zeroc.com");
    QCoreApplication::setApplicationName("Chat Demo");

    LoginView* loginView = new LoginView(0);
    UserListModel* userListModel = new UserListModel();
    ChatView* chatView = new ChatView(0, userListModel);

    MainView* mainView = new MainView(loginView, chatView);

    _coordinator = new CoordinatorI(mainView, loginView, chatView, userListModel, argc, argv);

    setQuitOnLastWindowClosed(true);

    connect(this, SIGNAL(aboutToQuit()), this, SLOT(shutdown()));

    connect(mainView, SIGNAL(logout()), _coordinator.get(), SLOT(logout()));
    connect(mainView, SIGNAL(login()), _coordinator.get(), SLOT(login()));

    connect(loginView, SIGNAL(login(const LoginInfoPtr&)),
            _coordinator.get(), SLOT(login(const LoginInfoPtr&)));

    connect(chatView, SIGNAL(sendMessage(const std::string&)),
            _coordinator.get(), SLOT(sendMessage(const std::string&)));

    mainView->show();
}
Пример #4
0
void SessionManager::saveSession()
{
    if (!m_safe || QWebSettings::globalSettings()->testAttribute(QWebSettings::PrivateBrowsingEnabled))
        return;
    m_safe = false;


    QFile sessionFile(m_sessionFilePath);
    if (!sessionFile.open(QFile::WriteOnly | QFile::Truncate))
    {
        kDebug() << "Unable to open session file" << sessionFile.fileName();
        return;
    }
    QTextStream out(&sessionFile);
    MainWindowList wl = rApp->mainWindowList();
    Q_FOREACH(const QWeakPointer<MainWindow> &w, wl)
    {
        out << "window\n";
        MainView *mv = w.data()->mainView();
        for (int i = 0 ; i < mv->count() ; i++)
        {
            out << mv->webTab(i)->url().toEncoded() << "\n";
        }

        // Current Tab for window
        out << "currenttab\n";
        out << mv->tabBar()->currentIndex() << "\n";
    }
Пример #5
0
QSize TabBar::tabSizeHint(int index) const
{
    MainView *view = qobject_cast<MainView *>(parent());

    int buttonSize = view->addTabButton()->size().width();
    int tabBarWidth = view->size().width() - buttonSize;
    int baseWidth =  view->sizeHint().width() / BASE_WIDTH_DIVISOR;
    int minWidth =  view->sizeHint().width() / MIN_WIDTH_DIVISOR;

    int w;
    if (baseWidth*count() < tabBarWidth)
    {
        w = baseWidth;
    }
    else
    {
        if (count() > 0 && tabBarWidth / count() > minWidth)
        {
            w = tabBarWidth / count();
        }
        else
        {
            w = minWidth;
        }
    }

    int h = KTabBar::tabSizeHint(index).height();

    QSize ts = QSize(w, h);
    return ts;
}
Пример #6
0
KActionMenu *TabBar::setupHistoryActions()
{
    MainWindow *w = rApp->mainWindow();
    MainView *mv = qobject_cast<MainView *>(parent());

    QAction *openLastClosedTabAction = w->actionByName(QL1S("open_last_closed_tab"));

    bool closedTabsAvailable = (mv->recentlyClosedTabs().size() > 0);
    openLastClosedTabAction->setEnabled(closedTabsAvailable);

    KActionMenu *am = new KActionMenu(KIcon("tab-new"), i18n("Closed Tabs"), this);
    am->setDelayed(false);
    am->setEnabled(closedTabsAvailable);

    if (am->menu())
        am->menu()->clear();

    if (!closedTabsAvailable)
        return am;

    for (int i = 0; i < mv->recentlyClosedTabs().count(); ++i)
    {
        TabHistory item = mv->recentlyClosedTabs().at(i);
        KAction *a = new KAction(rApp->iconManager()->iconForUrl(item.url), item.title, this);
        a->setData(i);
        connect(a, SIGNAL(triggered()), mv, SLOT(openClosedTab()));
        am->addAction(a);
    }

    return am;
}
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    MainView w;
    w.show();

    return a.exec();
}
int	main( int argc, char** argv )
{
    QApplication app(argc, argv);
    MainView mainView;
    mainView.setResizeMode( QQuickView::SizeRootObjectToView );
    mainView.resize( 1124, 650 );
    mainView.show( );
    return app.exec( );
}
Пример #9
0
int main(int argc, char *argv[]){
    QApplication app(argc, argv);

    MainView window;

    window.resize(600, 400);
    window.setWindowTitle("TaskManager");
    window.show();

    return app.exec();
}
Пример #10
0
void TabBar::showTabPreview()
{
    if (m_isFirstTimeOnTab)
        m_isFirstTimeOnTab = false;

    //delete previous tab preview
    delete m_previewPopup.data();
    m_previewPopup.clear();

    MainView *mv = qobject_cast<MainView *>(parent());

    WebTab *indexedTab = mv->webTab(m_currentTabPreviewIndex);
    WebTab *currentTab = mv->webTab(currentIndex());

    // check if view && currentView exist before using them :)
    if (!currentTab || !indexedTab)
        return;

    // no previews during load
    if (indexedTab->isPageLoading())
        return;

    // Make sure the hovered webtab match the current size
    // Only the active one is updated by window resize events
    indexedTab->resize(currentTab->size());

    m_previewPopup = new TabPreviewPopup(indexedTab , this);

    int tabWidth = tabSizeHint(m_currentTabPreviewIndex).width();
    int tabBarWidth = mv->size().width();
    int leftIndex = tabRect(m_currentTabPreviewIndex).x() + (tabRect(m_currentTabPreviewIndex).width() - tabWidth) / 2;
    int popupWidth = m_previewPopup.data()->thumbnailSize().width();

    // Center the popup if the tab width is bigger or smaller
    leftIndex += (tabWidth - popupWidth) / 2;

    if (leftIndex < 0)
    {
        leftIndex = 0;
    }
    else if (leftIndex + tabWidth > tabBarWidth)
    {
        leftIndex = tabBarWidth - tabWidth;
    }

    QPoint pos(leftIndex, tabRect(m_currentTabPreviewIndex).y() + tabRect(m_currentTabPreviewIndex).height());
    m_previewPopup.data()->show(mapToGlobal(pos));
}
Пример #11
0
int main(int argc, char** argv) {
   // Register a new Message Handler for qDebug/qWarning/qCritical/qFatal
#ifdef INSTALL_MESSAGE_HANDLER
   qInstallMsgHandler(messageHandler);
#endif

   // Create the Application
   QApplication app(argc, argv);
   app.setApplicationName(APP_NAME);
   app.setApplicationVersion(APP_VERSION);
   app.setOrganizationName(ORG_NAME);
   app.setOrganizationDomain(ORG_DOMAIN);

   // Init Resource Files
   Q_INIT_RESOURCE(qmls);

   // MainView, that will hold the QML UI
   MainView mainView;

#if defined(Q_OS_SYMBIAN)
   qt_SetDefaultIap(); // This will avoid the browser to keep asking for an IAP
#elif defined(Q_WS_MAEMO_5)
   mainView.setAttribute(Qt::WA_Maemo5NonComposited, true); //< This will avoid the use of Composite on this Parentless-Widget
   mainView.setAttribute(Qt::WA_Maemo5AutoOrientation, true); //< "Qt::WA_Maemo5PortraitOrientation" or "Qt::WA_Maemo5LandscapeOrientation" or "Qt::WA_Maemo5AutoOrientation"
#endif

#if defined(Q_OS_MAC) || defined(Q_OS_WIN32)
   //desktop build, just open a window
//   mainView.setWindowFlags(Qt::FramelessWindowHint);
   mainView.show();
#else
	//TODO recognise whether Q_OS_LINUX is defined and understand whether is meego or desktop linux
   //mobile builds, we want the whole screen!
   mainView.showFullScreen();
#endif


   // The Core of the Application
   Core core(&mainView);
   core.start();

   return app.exec();
}
Пример #12
0
void TabBar::mouseMoveEvent(QMouseEvent *event)
{
    if (count() == 1)
    {
        return;
    }

    if (event->buttons() & Qt::LeftButton)
    {
        // hide addNewTabButton when moving tabs
        MainView *view = qobject_cast<MainView *>(parent());
        QTimer::singleShot(200, view->addTabButton(), SLOT(hide()));
    }

    KTabBar::mouseMoveEvent(event);

    if (ReKonfig::hoveringTabOption() == 0)
    {
        //Find the tab under the mouse
        const int tabIndex = tabAt(event->pos());

        // if found and not the current tab then show tab preview
        if (tabIndex != -1
                && tabIndex != currentIndex()
                && m_currentTabPreviewIndex != tabIndex
                && event->buttons() == Qt::NoButton
           )
        {
            m_currentTabPreviewIndex = tabIndex;
            QTimer::singleShot(200, this, SLOT( showTabPreview() ) );
        }

        // if current tab or not found then hide previous tab preview
        if (tabIndex == currentIndex() || tabIndex == -1)
        {
            if (!m_previewPopup.isNull())
            {
                m_previewPopup.data()->hide();
            }
            m_currentTabPreviewIndex = -1;
        }
    }
}
Пример #13
0
int main(int argc, char *argv[])
{
    qputenv("QMLSCENE_DEVICE", "epaper");
    qputenv("QT_QPA_PLATFORM", "epaper:enable_fonts");
    qputenv("QT_QPA_EVDEV_TOUCHSCREEN_PARAMETERS", "rotate=180");

    system("/usr/bin/button-capture &");

    QGuiApplication app(argc, argv);
    MainView view;

    srand(time(NULL));

    view.rootContext()->setContextProperty("screenGeometry", app.primaryScreen()->geometry());
    view.engine()->addImportPath(QStringLiteral(DEPLOYMENT_PATH));
    view.setSource(QDir(DEPLOYMENT_PATH).filePath("qml/Main.qml"));
    view.show();

    Options options(&view, &app);

    return app.exec();
}
Пример #14
0
void TabBar::showTabPreview()
{
    //delete previous tab preview
    delete m_previewPopup.data();
    m_previewPopup.clear();

    MainView *mv = qobject_cast<MainView *>(parent());

    WebTab *indexedTab = mv->webTab(m_currentTabPreviewIndex);
    WebTab *currentTab = mv->webTab(currentIndex());

    // check if view && currentView exist before using them :)
    if (!currentTab || !indexedTab)
        return;

    // no previews during load
    if (indexedTab->isPageLoading())
        return;

    int w = tabSizeHint(m_currentTabPreviewIndex).width();
    int h = w * ((0.0 + currentTab->height()) / currentTab->width());

    m_previewPopup = new KPassivePopup(this);
    m_previewPopup.data()->setFrameShape(QFrame::StyledPanel);
    m_previewPopup.data()->setFrameShadow(QFrame::Plain);
    m_previewPopup.data()->setFixedSize(w, h);

    QLabel *l = new QLabel();
    l->setPixmap( WebSnap::renderTabPreview(*indexedTab->page(), w, h) );

    m_previewPopup.data()->setView(l);
    m_previewPopup.data()->layout()->setAlignment(Qt::AlignTop);
    m_previewPopup.data()->layout()->setMargin(0);

    QPoint pos(tabRect(m_currentTabPreviewIndex).x() , tabRect(m_currentTabPreviewIndex).y() + tabRect(m_currentTabPreviewIndex).height());
    m_previewPopup.data()->show(mapToGlobal(pos));
}
Пример #15
0
bool AppDelegate::applicationDidFinishLaunching() {
    // initialize director
    CCDirector* pDirector = CCDirector::sharedDirector();
    CCEGLView* pEGLView = CCEGLView::sharedOpenGLView();

    pDirector->setOpenGLView(pEGLView);
	
    // turn on display FPS
    pDirector->setDisplayStats(true);

    CCSize screenSize = CCEGLView::sharedOpenGLView()->getFrameSize();
    CCSize designSize = CCSizeMake(640.0f, 960.0f);
    
    // create a scene. it's an autorelease object
	MainView* mainViewScene = new MainView();
	mainViewScene->init();
	
    CCEGLView::sharedOpenGLView()->setDesignResolutionSize(designSize.width, designSize.height, kResolutionExactFit);

    // run
    pDirector->runWithScene(mainViewScene);

    return true;
}
Пример #16
0
	bool OnCreate()
	{
		return m_view.Create(this, NULL, GetClientArea());
	}
int main(int argc, char *argv[])
{
    QGuiApplication app(argc, argv);
    QGuiApplication::setOrganizationName("Reach Technology");
    QGuiApplication::setOrganizationDomain("reachtech.com");
    QGuiApplication::setApplicationName("Qml-Viewer");
    QGuiApplication::setApplicationVersion(APP_VERSION);
    MainView view;

    QFileInfo settingsFile;

    QStringList args = app.arguments();
    foreach (QString item, args) {
        if(item == "--version" || item == "-v") {
            qDebug() << "QML Viewer " << APP_VERSION;
            return 0;
        }
    }

    QString sb(QGuiApplication::applicationDirPath());
    sb.append(QDir::separator());
    sb.append("settings.conf");
    // check to see if we have a settings file where we started from
    // if not fall back to system hard coded path
    QFileInfo file(sb);
    if (file.exists()) {
        qDebug() << "[QML] using local settings file:" << file.filePath();
        settingsFile.setFile(file.filePath());
    } else {
        qDebug() << "[QML] using system defined settings file:" << SYSTEM_SETTINGS_FILE;
        settingsFile.setFile(SYSTEM_SETTINGS_FILE);
    }

    #ifdef Q_OS_WIN
        QSettings settings(settingsFile.filePath(),QSettings::IniFormat);
    #else
        QSettings settings(settingsFile.filePath(),QSettings::NativeFormat);
    #endif

    settings.beginGroup(SYSTEM_SETTINGS_SECTION);
    int port = settings.value("port",4000).toInt();
    bool parseJSON = settings.value("parse_json", true).toBool();

    MainController controller(&view, port, parseJSON);

    QString test = settings.value("main_view").toString();

    view.setSource(QUrl::fromLocalFile(settings.value("main_view").toString()));
    view.setResizeMode(QQuickView::SizeRootObjectToView);

    if (settings.value("full_screen",false).toBool()) {
        view.showFullScreen();
    }

    if (settings.value("hide_curosr",false).toBool()) {
        view.setCursor(QCursor( Qt::BlankCursor ));
    }

    settings.endGroup();
    return app.exec();
}
Пример #18
0
int main(int argc, char *argv[])
{

    
	QApplication a(argc, argv);
    
	try
	{
		MainScene scene(&a);

		QRect rec = QApplication::desktop()->screenGeometry();
		float screenHeight = rec.height();
		float screenWidth = rec.width();

#if TARGET_OS_IPHONE
		if( screenHeight/screenWidth == 0.75 )
			//c'est un iPad
			scene.setSceneRect(100, 0, 1440, 900);
		else
			//c'est un iPhone
			scene.setSceneRect(0, 0, 1440, 900);
#else
		scene.setSceneRect(0, 0, screenWidth, screenHeight);
#endif

		QFont font("Helvetica Neue", 30, -1, false);
		QFont sansFont("Helvetica", 30);

		a.setStyleSheet("background-color: black;");
		scene.setBackgroundBrush(QBrush(QColor(0, 0, 0)));
		
        MainView *view = new MainView(&scene);
        
        view->setViewport(new QGLWidget(QGLFormat(QGL::SampleBuffers)));

        //view->setScene(&scene);
        
        
		//qDebug() << screenHeight / screenWidth;

#if TARGET_OS_IPHONE
		if( screenHeight/screenWidth == 0.75 )
			//c'est un iPad
			view->fitInView(QRect(0, 0, rec.height()/1.9, rec.width()/1.57), Qt::KeepAspectRatio);
		else
			//c'est un iPhone
			view->fitInView(QRect(0, 0, rec.height()*2.1, rec.width()*2.1), Qt::KeepAspectRatio);
#endif


#ifdef __APPLE__
#if TARGET_OS_IPHONE
		view->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint);
		view->setFrameShape(QFrame::NoFrame);
#else
		//rien. le défaut est parfait sur Mac
#endif
        
#else
		view->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint);
		view->setFrameShape(QFrame::NoFrame);
#endif

		//view.setTransform(m);
		view->showFullScreen();

        
		//view.show();
		return a.exec();
	}
	catch (std::exception& e){
		QMessageBox::critical(0, "Genius Couleur", e.what());
		return 0;
	}

}