예제 #1
0
void MainWindow::onDoubleClicked(const QModelIndex &index)
{
    int row = index.row();
    if (configHelper->connectionAt(row)->isRunning()) {
        onStatus();
    } else {
        editRow(row);
    }
}
 DownloadsDataModel::DownloadsDataModel( QObject *parent ): bb::cascades::DataModel( parent ),
         m_downloadManager( new DownloadManager( this ) )
 {
     QObject::connect( m_downloadManager, SIGNAL(status( QString, QString, QString, QString )),
             this, SLOT(onStatus( QString, QString, QString, QString )) );
     QObject::connect( m_downloadManager, SIGNAL( newDownloadAdded() ), this, SLOT( onNewDownloadAdded() ) );
     QObject::connect( m_downloadManager, SIGNAL( finished(QString, QString) ), this, SLOT( onFinished(QString, QString) ) ) ;
     QObject::connect( m_downloadManager, SIGNAL( progress(QString, qint64, qint64, int, double, QString )),
             this, SLOT( onNewDownloadAdded() ) );
 }
예제 #3
0
MainWindow::MainWindow(QWidget *parent, Qt::WindowFlags flags)
    : QMainWindow(parent, flags), loginWindow_(NULL), connectWindow_(NULL), serverListWindow_(0),
      timer_(NULL), settingsMenu_(0), connected_(0), getServers_(NULL)
{
	QCoreApplication::setOrganizationName("CPPP");
    QCoreApplication::setApplicationName("VPNht");

	ui.setupUi(this);
    setWindowTitle("VPN.ht " + QString(VERSION));

    g_openVPNConnection = new OpenVPNConnectorQt(this);
    if (!g_openVPNConnection->installHelper(SERVICE_NAME))
    {
        QMessageBox::information(this,
                                 "VPNht", "Failed to install helper for program. Please contact support.");
        QTimer::singleShot(1, this, SLOT(close()));
        return;
    }

#if defined Q_OS_MAC
    //setAttribute(Qt::WA_QuitOnClose, false);
#endif

    trayIcon_ = new QSystemTrayIcon(this);       

    trayMenu_ = new QMenu(this);
    actConnect_ = new QAction("Connect", this);
    actDisconnect_ = new QAction("Disconnect", this);
    actHelp_ = new QAction("Help", this);
    actLiveChat_ = new QAction("Live chat", this);
    actExit_ = new QAction("Quit", this);
    trayMenu_->addAction(actConnect_);
    trayMenu_->addAction(actDisconnect_);
    trayMenu_->addSeparator();
    trayMenu_->addAction(actHelp_);
    trayMenu_->addAction(actLiveChat_);
    trayMenu_->addAction(actExit_);
    trayIcon_->setContextMenu(trayMenu_);
    trayIcon_->hide();    

    setTrayStatusDisconnected(false);

    settingsMenu_ = new QMenu(this);
    settingsMenu_->addAction("Settings", this, SLOT(onSettings()));
    settingsMenu_->addAction("Status", this, SLOT(onStatus()));
    settingsMenu_->addAction("Help", this, SLOT(onHelp()));
    settingsMenu_->addAction("Proxy", this, SLOT(onProxy()));
    settingsMenu_->addAction("Show logs", this, SLOT(onShowLogs()));
    settingsMenu_->addAction("Logout", this, SLOT(onReturnToSignUp()));
    settingsMenu_->setStyleSheet(ctxMenuStyle);    

    loginWindow_ = new LoginWindow(this);
	ui.verticalLayout->addWidget(loginWindow_);
	loginWindow_->loadSettings();
    loginWindow_->hide();
	connect(loginWindow_, SIGNAL(signedIn(QString, QString)), SLOT(onSignIn(QString, QString)));

    waitWindow_ = new WaitWindow(this);
    ui.verticalLayout->addWidget(waitWindow_);

    settingsWindow_ = new SettingsWindow(settingsMenu_, this);
    connect(settingsWindow_, SIGNAL(back()), SLOT(onBack()));
	ui.verticalLayout->addWidget(settingsWindow_);
    settingsWindow_->hide();

    connectWindow_ = new ConnectWindow(settingsMenu_, this);
    connect(connectWindow_, SIGNAL(serverList()), SLOT(onServerList()));
    connect(connectWindow_, SIGNAL(connected()), SLOT(onConnected()));
        ui.verticalLayout->addWidget(connectWindow_);

    ui.verticalLayout->addWidget(connectWindow_);
	connectWindow_->hide();

    serverListWindow_ = new ServerListWindow(this);
    connect(serverListWindow_, SIGNAL(serverSelected(const QString &)),
            this, SLOT( onChangeServer(const QString &) ));
    ui.verticalLayout->addWidget(serverListWindow_);
    serverListWindow_->hide();

    proxySettingsWindow_ = new ProxySettingsWindow(settingsMenu_, this);
    connect(proxySettingsWindow_, SIGNAL(back()), SLOT(onBack()));
    ui.verticalLayout->addWidget(proxySettingsWindow_);
    proxySettingsWindow_->hide();


    // tray action
    connect(actConnect_, SIGNAL(triggered()), connectWindow_, SLOT(onClickConnect()));
    connect(actDisconnect_, SIGNAL(triggered()), connectWindow_, SLOT(onClickConnect()));
    connect(actHelp_, SIGNAL(triggered()), SLOT(onActHelp()));
    connect(actLiveChat_, SIGNAL(triggered()), SLOT(onLiveChat()));
    connect(actExit_, SIGNAL(triggered()), SLOT(onExit()));


#if defined Q_OS_WIN
    connect(trayIcon_, SIGNAL(activated(QSystemTrayIcon::ActivationReason)),
            SLOT( onTrayActivated(QSystemTrayIcon::ActivationReason) ));
#endif

    QSettings settings;
    if (settings.value("savePass", "true").toString() == "true")
    {
		QString username = settings.value("login", "").toString();
		QString password = settings.value("password", "").toString();
		if (!username.isEmpty() && !password.isEmpty())
        {
            adjustSize();
            setFixedSize(size());
            skipLoginScreen(username, password);
		}
		else
		{
            waitWindow_->hide();
            loginWindow_->show();
            adjustSize();
            setFixedSize(size());
		}
    }
    else
    {
        waitWindow_->hide();
        loginWindow_->show();
        adjustSize();
        setFixedSize(size());
    }
}