Exemple #1
0
void MainWindow::onSettingsButtonClicked() {
  // Stop the timer while we're in the settings window.
  stopTimer();

  SettingsWindow settingsWindow(this);
  settingsWindow.setModal(true);
  settingsWindow.exec();

  // Do a refresh.  We don't have to start the timer ourselves here, because
  // after the update the timer will start up again with the new interval value.
  onUpdateButtonClicked();
}
Exemple #2
0
int main(int argc, char *argv[])
{
    QCoreApplication::setOrganizationName("SRFGames");
    QCoreApplication::setOrganizationDomain("sol-online.org"),
    QCoreApplication::setApplicationName("ShareYourClipboard");

#ifdef Q_OS_MAC
    QDir dir(argv[0]);
    dir.cdUp();
    QString currentDir = dir.absolutePath();
    dir.cdUp();
    dir.cd("PlugIns");
    QCoreApplication::setLibraryPaths(QStringList(dir.absolutePath()));
#endif

    QApplication a(argc, argv);
    QApplication::setQuitOnLastWindowClosed(false);

#ifdef Q_OS_MAC
    QDir::setCurrent(currentDir);
#endif

    qDebug() << "init manager\n";
    cClipboardManager manager(a.clipboard());

    qDebug() << "init tray icon\n";
    cTrayIcon trIcon(&manager);
    QObject::connect(&trIcon, SIGNAL(switchState()), &manager, SLOT(switchState()));
    QObject::connect(&trIcon, SIGNAL(pasteFiles()), &manager, SLOT(pasteFiles()));
    QObject::connect(&manager, SIGNAL(onStateChanged(cClipboardManager::eClipboardState)), &trIcon, SLOT(setState(cClipboardManager::eClipboardState)));

    qDebug() << "init settings window\n";
    SettingsWindow settingsWindow(&manager);
    QObject::connect(&trIcon, SIGNAL(showSettings()), &settingsWindow, SLOT(showNormal()));
    QObject::connect(&settingsWindow, SIGNAL(preferencesChange()), &manager, SLOT(onPreferencesChanged()));

    qDebug() << "init copy dialog\n";
    CopyProgressDialog copydialog;
    QObject::connect(&manager, SIGNAL(onStartCopyProcess(QString)), &copydialog, SLOT(start(QString)));
    QObject::connect(&manager, SIGNAL(onStopCopyProcess()), &copydialog, SLOT(stop()));
    QObject::connect(&manager, SIGNAL(showMessage(QString)), &copydialog, SLOT(showMessage(QString)));
    QObject::connect(&manager, SIGNAL(onSetProgressMain(QString,int,int)), &copydialog, SLOT(setProgressMain(QString,int,int)));
    QObject::connect(&manager, SIGNAL(onSetProgressSecond(QString,int,int)), &copydialog, SLOT(setProgressSecond(QString,int,int)));
    QObject::connect(&copydialog, SIGNAL(cancel()), &manager, SLOT(cancelDownloading()));

    qDebug() << "start app loop\n";
    int result = a.exec();
    qDebug() << "application close\n";
    return result;
}
Exemple #3
0
int main(int argc, char *argv[])
{
    QCoreApplication::setOrganizationName("SRFGames");
    QCoreApplication::setOrganizationDomain("sol-online.org"),
    QCoreApplication::setApplicationName("TrackYourTime");

#ifdef Q_OS_MAC
    QDir dir(argv[0]);
    dir.cdUp();
    QString currentDir = dir.absolutePath();
    dir.cdUp();
    dir.cd("PlugIns");
    QCoreApplication::setLibraryPaths(QStringList(dir.absolutePath()));
#endif

    QApplication a(argc, argv);
    QApplication::setQuitOnLastWindowClosed(false);

#ifdef Q_OS_MAC
    QDir::setCurrent(currentDir);
#endif



    QSettings settings;
    QString Language = QLocale::system().name();
    Language.truncate(Language.lastIndexOf('_'));
    Language = settings.value(cDataManager::CONF_LANGUAGE_ID,Language).toString();
    if (settings.value(cDataManager::CONF_FIRST_LAUNCH_ID,true).toBool()){
        settings.setValue(cDataManager::CONF_FIRST_LAUNCH_ID,false);
        settings.setValue(cDataManager::CONF_LANGUAGE_ID,Language);
        settings.setValue(cDataManager::CONF_AUTORUN_ID,true);
        setAutorun();
        settings.sync();
    }

    QTranslator translator;
    translator.load("lang_" + Language,QDir::currentPath()+"/data/languages");
    QApplication::installTranslator(&translator);

    cDataManager datamanager;

    cTrayIcon trIcon(&datamanager);
    QObject::connect(&datamanager, SIGNAL(trayActive()), &trIcon, SLOT(setActive()));
    QObject::connect(&datamanager, SIGNAL(traySleep()), &trIcon, SLOT(setInactive()));
    QObject::connect(&datamanager, SIGNAL(trayShowHint(QString)), &trIcon, SLOT(showHint(QString)));
    QObject::connect(&datamanager, SIGNAL(profilesChanged()), &trIcon, SLOT(onProfilesChange()));

    ApplicationsWindow applicationsWindow(&datamanager);
    QObject::connect(&trIcon, SIGNAL(showApplications()), &applicationsWindow, SLOT(show()));
    QObject::connect(&datamanager, SIGNAL(profilesChanged()), &applicationsWindow, SLOT(onProfilesChange()));
    QObject::connect(&datamanager, SIGNAL(applicationsChanged()), &applicationsWindow, SLOT(onApplicationsChange()));

    ProfilesWindow profilesWindow(&datamanager);
    QObject::connect(&applicationsWindow, SIGNAL(showProfiles()), &profilesWindow, SLOT(show()));

    App_SettingsWindow app_settingsWindow(&datamanager);
    QObject::connect(&applicationsWindow, SIGNAL(showAppSettings(int)), &app_settingsWindow, SLOT(showApp(int)));
    QObject::connect(&datamanager, SIGNAL(debugScriptResult(QString,sSysInfo)), &app_settingsWindow, SLOT(onScriptResult(QString,sSysInfo)));

    SettingsWindow settingsWindow(&datamanager);
    QObject::connect(&trIcon, SIGNAL(showSettings()), &settingsWindow, SLOT(show()));
    QObject::connect(&settingsWindow, SIGNAL(preferencesChange()), &datamanager, SLOT(onPreferencesChanged()));

    StatisticWindow statisticWindow(&datamanager);
    QObject::connect(&trIcon, SIGNAL(showStatistic()), &statisticWindow, SLOT(show()));

    AboutWindow aboutWindow;
    QObject::connect(&trIcon, SIGNAL(showAbout()), &aboutWindow, SLOT(show()));

    int result = a.exec();

    return result;
}
Exemple #4
0
int main(int argc, char *argv[])
{
    QCoreApplication::setOrganizationName("SRFGames");
    QCoreApplication::setOrganizationDomain("sol-online.org"),
    QCoreApplication::setApplicationName("TrackYourTime");

#ifdef Q_OS_MAC
    QDir dir(argv[0]);
    dir.cdUp();
    QString currentDir = dir.absolutePath();
    dir.cdUp();
    dir.cd("PlugIns");
    QCoreApplication::setLibraryPaths(QStringList(dir.absolutePath()));
#endif

    QApplication a(argc, argv);
    QApplication::setQuitOnLastWindowClosed(false);

#ifdef Q_OS_MAC
    QDir::setCurrent(currentDir);
#endif


    qDebug() << "application start\n";

    cSettings settings;
    QString Language = QLocale::system().name();
    Language.truncate(Language.lastIndexOf('_'));
    Language = settings.db()->value(cDataManager::CONF_LANGUAGE_ID,Language).toString();
    if (settings.db()->value(cDataManager::CONF_FIRST_LAUNCH_ID,true).toBool()){
        settings.db()->setValue(cDataManager::CONF_FIRST_LAUNCH_ID,false);
        settings.db()->setValue(cDataManager::CONF_LANGUAGE_ID,Language);
        settings.db()->setValue(cDataManager::CONF_AUTORUN_ID,true);
        setAutorun();
        settings.db()->sync();
    }

    qDebug() << "laod translation\n";
    QTranslator translator;
    translator.load("lang_" + Language,QDir::currentPath()+"/data/languages");
    QApplication::installTranslator(&translator);

    qDebug() << "init datamanager\n";
    cDataManager datamanager;
    qDebug() << "init schedule\n";
    cSchedule schedule(&datamanager);
    qDebug() << "init updater\n";
    cUpdater updater;
    QObject::connect(&schedule,SIGNAL(checkUpdates()),&updater,SLOT(checkUpdates()));

    qDebug() << "init tray icon\n";
    cTrayIcon trIcon(&datamanager);
    QObject::connect(&datamanager, SIGNAL(trayActive()), &trIcon, SLOT(setActive()));
    QObject::connect(&datamanager, SIGNAL(traySleep()), &trIcon, SLOT(setInactive()));
    QObject::connect(&datamanager, SIGNAL(trayShowHint(QString)), &trIcon, SLOT(showHint(QString)));
    QObject::connect(&datamanager, SIGNAL(profilesChanged()), &trIcon, SLOT(onProfilesChange()));

    qDebug() << "init applications window\n";
    ApplicationsWindow applicationsWindow(&datamanager);
    QObject::connect(&trIcon, SIGNAL(showApplications()), &applicationsWindow, SLOT(showNormal()));
    QObject::connect(&datamanager, SIGNAL(profilesChanged()), &applicationsWindow, SLOT(onProfilesChange()));
    QObject::connect(&datamanager, SIGNAL(applicationsChanged()), &applicationsWindow, SLOT(onApplicationsChange()));

    qDebug() << "init profiles window\n";
    ProfilesWindow profilesWindow(&datamanager);
    QObject::connect(&applicationsWindow, SIGNAL(showProfiles()), &profilesWindow, SLOT(showNormal()));

    qDebug() << "init app settings window\n";
    App_SettingsWindow app_settingsWindow(&datamanager);
    QObject::connect(&applicationsWindow, SIGNAL(showAppSettings(int)), &app_settingsWindow, SLOT(showApp(int)));
    QObject::connect(&datamanager, SIGNAL(debugScriptResult(QString,sSysInfo)), &app_settingsWindow, SLOT(onScriptResult(QString,sSysInfo)));

    qDebug() << "init settings window\n";
    SettingsWindow settingsWindow(&datamanager);
    QObject::connect(&trIcon, SIGNAL(showSettings()), &settingsWindow, SLOT(showNormal()));
    QObject::connect(&settingsWindow, SIGNAL(preferencesChange()), &datamanager, SLOT(onPreferencesChanged()));

    qDebug() << "init schedule window\n";
    ScheduleWindow scheduleWindow(&datamanager,&schedule);
    QObject::connect(&datamanager, SIGNAL(profilesChanged()), &scheduleWindow, SLOT(rebuild()));
    QObject::connect(&trIcon, SIGNAL(showSchedule()), &scheduleWindow, SLOT(showNormal()));

    qDebug() << "init statistic window\n";
    StatisticWindow statisticWindow(&datamanager);
    QObject::connect(&trIcon, SIGNAL(showStatistic()), &statisticWindow, SLOT(showNormal()));

    qDebug() << "init about window\n";
    AboutWindow aboutWindow;
    QObject::connect(&trIcon, SIGNAL(showAbout()), &aboutWindow, SLOT(showNormal()));

    qDebug() << "init update window\n";
    UpdateAvailableWindow updateAvailableWindow;
    QObject::connect(&updater, SIGNAL(newVersionAvailable(QString)), &updateAvailableWindow, SLOT(showUpdate(QString)));
    QObject::connect(&updateAvailableWindow, SIGNAL(ignoreUpdate()), &updater, SLOT(ignoreNewVersion()));

    qDebug() << "init notification window\n";
    NotificationWindow notificationWindow(&datamanager);
    QObject::connect(&settingsWindow, SIGNAL(preferencesChange()), &notificationWindow, SLOT(onPreferencesChanged()));
    QObject::connect(&datamanager, SIGNAL(showNotification()), &notificationWindow, SLOT(onShow()));

    qDebug() << "start schedule\n";
    schedule.start();

    qDebug() << "start app loop\n";
    int result = a.exec();
    qDebug() << "application close\n";
    return result;
}
Exemple #5
0
Widget::Widget()
{
    // This class is the host of the whole application. This is BAD. Needs to be rectified. Should split this up into either: More classes OR More Files

    firstComp = NULL; //Setup the linked list

    //Spawn a QMainWindow, and set its attributes
    mainWindow = new QMainWindow();
    mainWindow->resize(400, 400);
    mainWindow->setWindowTitle("Lan Party Manager " + releaseType + " " + releaseVer);

    setup = new QSettings(QSettings::IniFormat, QSettings::SystemScope, "Alldritt Coding", "LanParty Manager", this);
    QStringList keys = setup->allKeys();

    if(keys.length() != 8)
    {
        setup->clear();
        setup->setValue("udpBroadcast", 1000);
        setup->setValue("tcpBroadcast", 5000);
        setup->setValue("udpPort", 45454);
        setup->setValue("tcpPort", 1337);
        setup->setValue("debug", false);
        setup->setValue("releaseType", releaseType);
        setup->setValue("releaseVer", releaseVer);
        setup->setValue("networkUpdateRate", 1000);
    }
    else
    {
		udpBroadcastRate = setup->value("udpBroadcast", 1000).toInt();
		tcpCheckRate = setup->value("tcpBroadcast", 5000).toInt();
		standardUdpPort = setup->value("udpPort", 45454).toInt();
		standardTcpPort = setup->value("tcpPort", 1337).toInt();
		debugMode = setup->value("debug", false).toBool();
		//releaseType = setup->value("releaseType", "").toString();
		//releaseVer = setup->value("releaseVer", "").toString();
		networkUpdateRate = setup->value("networkUpdateRate", 1000).toInt();
    }

    settings = new QWidget(mainWindow, Qt::Dialog);
    settings->resize(300, 300);
    settings->setWindowTitle("Settings");
    settings->hide();
	
    QLabel * la = new QLabel(settings);
    la->move(15, 15);
    la->setText("UDP Broadcast Delay");
	
    QLabel * lb = new QLabel(settings);
    lb->move(15, 45);
    lb->setText("TCP Broadcast Delay");
	
    QLabel * lc = new QLabel(settings);
    lc->move(15, 75);
    lc->setText("Default UDP Port (Advanced)");
	
    QLabel * ld = new QLabel(settings);
    ld->move(15, 105);
    ld->setText("Default TCP Port (Advanced)");
	
    QLabel * le = new QLabel(settings);
    le->move(15, 165);
    le->setText("Debug Mode");
	
    QLabel * lf = new QLabel(settings);
    lf->move(15, 135);
    lf->setText("Total Bytes Refresh Rate");

    uPort = new QLineEdit(settings);
    uPort->setGeometry(200, 75, 50, 20);
    uPort->setText(QString().number(standardUdpPort));

    tPort = new QLineEdit(settings);
    tPort->setGeometry(200, 105, 50, 20);
    tPort->setText(QString().number(standardTcpPort));

    uDelay = new QLineEdit(settings);
    uDelay->setGeometry(200, 15, 50, 20);
    uDelay->setText(QString().number(udpBroadcastRate));

    tDelay = new QLineEdit(settings);
    tDelay->setGeometry(200, 45, 50, 20);
    tDelay->setText(QString().number(tcpCheckRate));

    nDelay = new QLineEdit(settings);
    nDelay->setGeometry(200, 135, 50, 20);
    nDelay->setText(QString().number(networkUpdateRate));

    debugOn = new QCheckBox(settings);
    debugOn->move(200, 165);
    debugOn->setChecked(debugMode);

    QPushButton * apply = new QPushButton(settings);
    apply->setGeometry(200, 200, 60, 30);
    apply->setText("Apply");
    QObject::connect(apply, SIGNAL(clicked()), this, SLOT(apply()));

    QWidget * passWindow = new QWidget(mainWindow, Qt::Tool);
    passWindow->resize(200, 80);
    passWindow->hide();

    QLabel * passLabel = new QLabel(passWindow);
    passLabel->move(50, 10);
    passLabel->setText("Enter Password");

    passBox = new QLineEdit(passWindow);
    passBox->setGeometry(40, 25, 130, 20);

    QPushButton * enter = new QPushButton(passWindow);
    enter->setGeometry(40, 50, 50, 25);
    enter->setText("Enter");

    QObject::connect(enter, SIGNAL(clicked()), this, SLOT(passEnter()));
    QObject::connect(enter, SIGNAL(clicked()), passWindow, SLOT(hide()));
    QObject::connect(passBox, SIGNAL(returnPressed()), this, SLOT(passEnter()));
    QObject::connect(passBox, SIGNAL(returnPressed()), passWindow, SLOT(hide()));

    icon = new QIcon(":/images/icon.png");
    sysIcon = new QSystemTrayIcon(*icon, this);
    sysIcon->show();
    sysMenu = new QMenu(mainWindow);
    QAction * exitAction = sysMenu->addAction("Exit");
    sysIcon->setContextMenu(sysMenu);
    connect(exitAction, SIGNAL(triggered(bool)), qApp, SLOT(quit()));
    connect(exitAction, SIGNAL(triggered(bool)), this, SLOT(close()));
    bool success = connect(sysIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(iconClicked(QSystemTrayIcon::ActivationReason)));
    if(success != true)
    {
		sysIcon->showMessage("System Tray Error", "Window Respawn Connection Failed", QSystemTrayIcon::Information, 10000 );
    }

	QMenu* file = mainWindow->menuBar()->addMenu(tr("&File"));
	QMenu* help = mainWindow->menuBar()->addMenu(tr("&Help"));

	QAction* exitAct = new QAction(tr("&Exit"), this);
	exitAct->setStatusTip(tr("Quit"));
	connect(exitAct, SIGNAL(triggered()), qApp, SLOT(quit()));
	connect(exitAct, SIGNAL(triggered()), this, SLOT(close()));

	QAction* settingAct = new QAction(tr("&Settings"), this);
	settingAct->setStatusTip(tr("Access the Settings page"));
	connect(settingAct, SIGNAL(triggered()), this, SLOT(settingsWindow()));

	QAction* aboutQtAct = new QAction(tr("About &Qt"), this);
	aboutQtAct->setStatusTip(tr("Show the Qt library's About box"));
	connect(aboutQtAct, SIGNAL(triggered()), qApp, SLOT(aboutQt()));

	QAction* aboutAct = new QAction(tr("&About"), this);
	aboutAct->setStatusTip(tr("Show the About box"));
	connect(aboutAct, SIGNAL(triggered()), this, SLOT(about()));

	help->addAction(aboutQtAct);
	help->addAction(aboutAct);
	file->addAction(settingAct);
	file->addAction(exitAct);
	mainWindow->show();

    server = new QPushButton(mainWindow);
    client = new QPushButton(mainWindow);

    log = new QFile("log.txt");
    currentTime = new QDateTime(); //create the log timestamp
    *currentTime = QDateTime::currentDateTime(); //get system time

    if(!log->open(QIODevice::ReadWrite|QIODevice::Append))
    {
        QMessageBox::information(0, "Error", "Can't open logfile. Reason: " + log->errorString());
    }

    if(debugMode)
    {
		writeLog("LanMan " + releaseType + " " + releaseVer + " Logfile Start");
		writeLog("Time Format is: DD/MM/YYYY - HOUR:MIN:SEC AM/PM");
    }

    server->setGeometry(10, 30, 100, 30);
    client->setGeometry(290, 30, 100, 30);
    server->setText("SERVER MODE");
    client->setText("CLIENT MODE");
    client->show();
    server->show();
    connect(client, SIGNAL(released()), this, SLOT(startClient()));
    connect(server, SIGNAL(released()), passWindow, SLOT(show()));
    mainLabel = new QLabel("", mainWindow);
    mainLabel->move(165, 40);
    mainLabel->show();
    udpSocket = new QUdpSocket(this);
}