Beispiel #1
0
void WizPreferenceWindow::on_comboLang_currentIndexChanged(int index)
{
    QString strLocaleName = m_locales[index];
    if (strLocaleName.compare(userSettings().locale())) {
        userSettings().setLocale(strLocaleName);

        WizMessageBox::information(this, tr("Info"), tr("Language will be changed after restart WizNote."));
    }
}
void CWizPreferenceWindow::on_comboLang_activated(int index)
{
    QString strLocaleName = m_locales[index];
    if (strLocaleName.compare(userSettings().locale())) {
        userSettings().setLocale(strLocaleName);
    }

    QMessageBox msgBox;
    msgBox.setIcon(QMessageBox::Information);
    msgBox.addButton(QMessageBox::Ok);
    msgBox.setText(tr("Language will be changed after restart WizNote."));
    msgBox.exec();
}
	void LynxUserInterfaceModel::SaveUserSettings()
	{
		// TODO: Can we save to a temporary and re-name on success?

		// If "--games" was on the command line, NEVER overwrite the user settings file, since
		// games mode uses pre-configured settings files ("--settings") that are not appropriate for overwrite.
		// This supports Hyperspin.

		if( _gamesMode ) return;

		auto fileOpener = _hostView->GetUserSettingsFileOpener();
		if( fileOpener != nullptr )
		{
			UserSettings  userSettings(
				_lynxEmulator->GetMachineType(),
				_renderStyle,
				_lynxEmulator->IsSoundEnabled(),
				_showFullScreen,
				_lynxEmulator->GetSpeedPercentage(),
				_lynxEmulator->GetTapeSounds(),
				_lynxEmulator->GetLynxRemCommandExtensionsEnabled(),
				_lynxEmulator->GetEnableSpeedMaxModeWhenUsingCassette(),
				_lynxEmulator->GetEnableSpeedMaxModeWhenInBetweenConsoleCommands(),
				_lynxEmulator->GetEnableSpeedMaxModeBecauseUserWantsItPermanently(),
				_lynxEmulator->GetLynxColourSet() );

			userSettings.SaveToFile( &*fileOpener, _platformEndOfLineSequenceUTF8 );
		}
	}
	void LynxUserInterfaceModel::LoadUserSettings()
	{
		auto fileOpener = _hostView->GetUserSettingsFileOpener();
		if( fileOpener != nullptr )
		{
            UserSettings  userSettings( &*fileOpener );

            // Now that the file has loaded successfully, we know we can use the information in it!
            // (Or, of course, the defaults that the UserSettings object applies, if it's down-level version).

			_renderStyle = userSettings.GetRenderStyle();
            _lynxEmulator->SetSoundEnable( userSettings.GetSoundEnable() );

			_showFullScreen = userSettings.GetFullScreenEnable();
            _lynxEmulator->SetSpeedPercentage( userSettings.GetSpeedPercentage() );
            _lynxEmulator->SetTapeSounds( userSettings.GetTapeSounds() );
            _lynxEmulator->SetLynxRemCommandExtensionsEnabled( userSettings.GetRemExtensions() );
            _lynxEmulator->SetEnableSpeedMaxModeWhenUsingCassette( userSettings.GetMaxSpeedCassette() );
            _lynxEmulator->SetEnableSpeedMaxModeWhenInBetweenConsoleCommands( userSettings.GetMaxSpeedConsole() );
            _lynxEmulator->SetEnableSpeedMaxModeBecauseUserWantsItPermanently( userSettings.GetMaxSpeedAlways() );
            _lynxEmulator->SetLynxColourSet( userSettings.GetColourSet() );

			_lynxEmulator->ResetGuest( userSettings.GetMachineType() );

			// Update UI:
			_hostView->InvalidateAreaOfHostScreen( _hostView->GetClientRectangle() );
			UpdateUserInterfaceElementsOnView();
		}
	}
Beispiel #5
0
    void ThemeConfig::setTo(const QString &path) {
        clear();

        QSettings settings(path, QSettings::IniFormat);
        QSettings userSettings(path + QStringLiteral(".user"), QSettings::IniFormat);

        // Support non-latin strings in background picture path
        // Warning: The codec must be set immediately after creating the QSettings object,
        // before accessing any data.
        settings.setIniCodec("UTF-8");
        userSettings.setIniCodec("UTF-8");

        // read default keys
        for (const QString &key: settings.allKeys()) {
            insert(key, settings.value(key));
        }
        // read user set themes overwriting defaults if they exist
        for (const QString &key: userSettings.allKeys()) {
            if (!userSettings.value(key).toString().isEmpty()) {
                insert(key, userSettings.value(key));
            }
        }

        //if the main config contains a background, save this to a new config value
        //to themes can use it if the user set config background cannot be loaded
        if (settings.contains(QStringLiteral("background"))) {
            insert(QStringLiteral("defaultBackground"), settings.value(QStringLiteral("background")));
        }
    }
void CWizPreferenceWindow::on_radioAuto_clicked(bool chcked)
{
    if (!chcked)
        return;

    userSettings().setNoteViewMode(viewmodeKeep);
    Q_EMIT settingsChanged(wizoptionsNoteView);
}
void CWizPreferenceWindow::on_radioAlwaysReading_clicked(bool chcked)
{
    if (!chcked)
        return;

    userSettings().setNoteViewMode(viewmodeAlwaysReading);
    emit settingsChanged(wizoptionsNoteView);
}
void CWizPreferenceWindow::accept()
{
    if (m_strSelectedSkin.compare(userSettings().skin())) {
        userSettings().setSkin(m_strSelectedSkin);
        m_bRestart = true;
    }

    QString strLocaleName = m_locales[m_iSelectedLocale];
    if (strLocaleName.compare(userSettings().locale())) {
        userSettings().setLocale(strLocaleName);
        m_bRestart = true;
    }

    if (m_bRestart) {
        emit restartForSettings();
    }

    QDialog::accept();
}
Beispiel #9
0
// ************ INVOICES START *****************
void XmlDataLayer::invoiceSellerDataToElem(InvoiceData &i_invData, QDomElement &o_element) {
    qDebug() << __FILE__ << __LINE__ << __FUNCTION__;

    QSettings userSettings("elinux", "user");
    o_element.setAttribute("name", userSettings.value("name").toString());
    o_element.setAttribute("zip", userSettings.value("zip").toString());
    o_element.setAttribute("city", userSettings.value("city").toString());
    o_element.setAttribute("street", userSettings.value("street").toString());
    // NIP = Taxing Identification Code
    o_element.setAttribute("tic", userSettings.value("tic").toString());
    o_element.setAttribute("account",
                    userSettings.value("account").toString(). replace(" ", "-"));
}
void CWizPreferenceWindow::on_comboSyncMethod_activated(int index)
{
    switch (index) {
        case 0:
            userSettings().setSyncMethod(-1);
            break;
        case 1:
            userSettings().setSyncMethod(1);
            break;
        case 2:
            userSettings().setSyncMethod(7);
            break;
        case 3:
            userSettings().setSyncMethod(30);
            break;
        case 4:
            userSettings().setSyncMethod(99999);
            break;
        default:
            Q_ASSERT(0);
    }

    Q_EMIT settingsChanged(wizoptionsSync);
}
void CWizPreferenceWindow::on_comboSyncInterval_activated(int index)
{
    switch (index) {
        case 0:
            userSettings().setSyncInterval(5);
            break;
        case 1:
            userSettings().setSyncInterval(15);
            break;
        case 2:
            userSettings().setSyncInterval(30);
            break;
        case 3:
            userSettings().setSyncInterval(60);
            break;
        case 4:
            userSettings().setSyncInterval(-1);
            break;
        default:
            Q_ASSERT(0);
    }

    Q_EMIT settingsChanged(wizoptionsSync);
}
Beispiel #12
0
int main(int argc, char *argv[])
{
#ifdef QT_NO_DEBUG
    qInstallMessageHandler(customMessageHandler);
#endif

    QApplication app(argc, argv);
    QApplication::setOrganizationName("MonkeySoft");
    QApplication::setOrganizationDomain("MonkeySoft.com");
    QApplication::setApplicationName("MonkeySoft");
    QQmlApplicationEngine engine;

    registrationTypes();

    QSettings userSettings("MonkeySoft", "User");

    engine.load(QUrl(QStringLiteral("qrc:/main.qml")));

    return app.exec();
}
void WelcomeDialog::getUserPasswordPairs()
{
    CWizStdStringArray usersFolder;
    ::WizEnumFolders(::WizGetDataStorePath(), usersFolder, 0);

    for(CWizStdStringArray::const_iterator iter = usersFolder.begin();
        iter != usersFolder.end();
        iter++)
    {
        QString strPath = *iter;
        QString strUserId = ::WizFolderNameByPath(strPath);

        if (strUserId.indexOf("@") == -1) {
            continue;
        }

        CWizUserSettings userSettings(strUserId);
        m_users.insert(strUserId, userSettings.password());
    }
}
void WelcomeDialog::updateUserSettings()
{
    CWizSettings settings(::WizGetDataStorePath() + "wiznote.ini");

    // set current login user as default user.
    settings.SetString("Users", "DefaultUser", userId());

    CWizUserSettings userSettings(userId());

    if(ui->checkAutoLogin->checkState() == Qt::Checked) {
        userSettings.setAutoLogin(true);
    } else {
        userSettings.setAutoLogin(false);
    }

    if(ui->checkRememberMe->checkState() == Qt::Checked) {
        userSettings.setPassword(::WizEncryptPassword(password()));
    } else {
        userSettings.setPassword();
    }
}
Beispiel #15
0
    ThemeConfig::ThemeConfig(const QString &path) {
        QSettings settings(path, QSettings::IniFormat);
        QSettings userSettings(path + ".user", QSettings::IniFormat);

        // read default keys
        for (const QString &key: settings.allKeys()) {
            insert(key, settings.value(key));
        }
        // read user set themes overwriting defaults if they exist
        for (const QString &key: userSettings.allKeys()) {
            if (!userSettings.value(key).toString().isEmpty()) {
                insert(key, userSettings.value(key));
            }
        }

        //if the main config contains a background, save this to a new config value
        //to themes can use it if the user set config background cannot be loaded
        if (settings.contains("background")) {
            insert("defaultBackground", settings.value("background"));
        }
    }
Beispiel #16
0
int _tmain(int argc, TCHAR* argv[])
{
	int nRetCode = 0;

  glutInit( &argc, (char**)argv );

  glutInitDisplayMode( GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH );
  glutInitWindowSize( 500, 500 );
  glutCreateWindow( "colorcube" );
  glutReshapeFunc( myReshape );
  glutDisplayFunc( display );
  glutIdleFunc( spinCube );
  glutMouseFunc( mouseButton );
  glutMotionFunc( mouseMotion );
  glutKeyboardFunc( keyboard );

  initSettings();
  userSettings();
  glutMainLoop();

	return nRetCode;
}
CWizPreferenceWindow::CWizPreferenceWindow(CWizExplorerApp& app, QWidget* parent)
    : QDialog(parent)
    , ui(new Ui::CWizPreferenceWindow)
    , m_app(app)
    , m_bRestart(false)
{
    ui->setupUi(this);

    connect(ui->buttonOK, SIGNAL(clicked()), SLOT(accept()));

    // general tab
    ::WizGetTranslatedLocales(m_locales);
    for (int i = 0; i < m_locales.count(); i++) {
        ui->comboLang->addItem(::WizGetTranslatedLocaleDisplayName(i));
    }

    for (int i = 0; i < ui->comboLang->count(); i++) {
        if (!m_locales[i].compare(userSettings().locale())) {
            ui->comboLang->setCurrentIndex(i);
        }
    }

    // just hide skin setup and upgrade notfiy on mac for convience.
#ifdef Q_WS_MAC
    ui->groupBoxSkin->hide();
    ui->checkBox->hide();
#endif // Q_WS_MAC

    ::WizGetSkins(m_skins);
    for (int i = 0; i < m_skins.count(); i++) {
        ui->comboSkin->addItem(::WizGetSkinDisplayName(m_skins[i], userSettings().locale()));
    }

    QString strCurSkinName = userSettings().skin();
    for (int i = 0; i < ui->comboSkin->count(); i++) {
        if (!strCurSkinName.compare(m_skins[i])) {
            ui->comboSkin->setCurrentIndex(i);
        }
    }

    connect(ui->comboLang, SIGNAL(currentIndexChanged(int)), SLOT(on_comboLang_currentIndexChanged(int)));
    connect(ui->comboSkin, SIGNAL(currentIndexChanged(int)), SLOT(on_comboSkin_currentIndexChanged(int)));

    // reading tab
    switch (userSettings().noteViewMode())
    {
        case viewmodeAlwaysEditing:
            ui->radioAlwaysEditing->setChecked(true);
            break;
        case viewmodeAlwaysReading:
            ui->radioAlwaysReading->setChecked(true);
            break;
        default:
            ui->radioAuto->setChecked(true);
            break;
    }

    connect(ui->radioAuto, SIGNAL(clicked(bool)), SLOT(on_radioAuto_clicked(bool)));
    connect(ui->radioAlwaysReading, SIGNAL(clicked(bool)), SLOT(on_radioAlwaysReading_clicked(bool)));
    connect(ui->radioAlwaysEditing, SIGNAL(clicked(bool)), SLOT(on_radioAlwaysEditing_clicked(bool)));

    // syncing tab
    ui->checkAutoSync->setChecked(userSettings().autoSync());
    ui->checkDownloadAllNotesData->setChecked(userSettings().downloadAllNotesData());

    QString proxySettings = WizFormatString1("<a href=\"proxy_settings\">%1</a>", tr("Proxy settings"));
    ui->labelProxySettings->setText(proxySettings);

    connect(ui->checkAutoSync, SIGNAL(clicked(bool)), SLOT(on_checkAutoSync_clicked(bool)));
    connect(ui->checkDownloadAllNotesData, SIGNAL(clicked(bool)), SLOT(on_checkDownloadAllNotesData_clicked(bool)));
    connect(ui->labelProxySettings, SIGNAL(linkActivated(const QString&)), SLOT(labelProxy_linkActivated(const QString&)));
}
CWizPreferenceWindow::CWizPreferenceWindow(CWizExplorerApp& app, QWidget* parent)
    : QDialog(parent)
    , ui(new Ui::CWizPreferenceWindow)
    , m_app(app)
    , m_bRestart(false)
{
    ui->setupUi(this);
    setWindowIcon(QIcon());

    connect(ui->buttonOK, SIGNAL(clicked()), SLOT(accept()));

    // general tab
    ::WizGetTranslatedLocales(m_locales);
    for (int i = 0; i < m_locales.count(); i++) {
        ui->comboLang->addItem(::WizGetTranslatedLocaleDisplayName(i));
    }

    for (int i = 0; i < ui->comboLang->count(); i++) {
        if (!m_locales[i].compare(userSettings().locale())) {
            ui->comboLang->setCurrentIndex(i);
        }
    }

    // just hide skin setup and upgrade notfiy on mac for convenience.
//#ifdef Q_WS_MAC
    //ui->groupBoxSkin->hide();
    //ui->checkBox->hide();
//#endif // Q_WS_MAC

//    ::WizGetSkins(m_skins);
//    for (int i = 0; i < m_skins.count(); i++) {
//        ui->comboSkin->addItem(::WizGetSkinDisplayName(m_skins[i], userSettings().locale()));
//    }

//    QString strCurSkinName = userSettings().skin();
//    for (int i = 0; i < ui->comboSkin->count(); i++) {
//        if (!strCurSkinName.compare(m_skins[i])) {
//            ui->comboSkin->setCurrentIndex(i);
//        }
//    }

    connect(ui->comboLang, SIGNAL(currentIndexChanged(int)), SLOT(on_comboLang_currentIndexChanged(int)));
    //connect(ui->comboSkin, SIGNAL(currentIndexChanged(int)), SLOT(on_comboSkin_currentIndexChanged(int)));

    // reading tab
    switch (userSettings().noteViewMode())
    {
        case viewmodeAlwaysEditing:
            ui->radioAlwaysEditing->setChecked(true);
            break;
        case viewmodeAlwaysReading:
            ui->radioAlwaysReading->setChecked(true);
            break;
        default:
            ui->radioAuto->setChecked(true);
            break;
    }

    connect(ui->radioAuto, SIGNAL(clicked(bool)), SLOT(on_radioAuto_clicked(bool)));
    connect(ui->radioAlwaysReading, SIGNAL(clicked(bool)), SLOT(on_radioAlwaysReading_clicked(bool)));
    connect(ui->radioAlwaysEditing, SIGNAL(clicked(bool)), SLOT(on_radioAlwaysEditing_clicked(bool)));

    // syncing tab
    int nInterval = userSettings().syncInterval();
    switch (nInterval) {
        case 5:
            ui->comboSyncInterval->setCurrentIndex(0);
            break;
        case 15:
            ui->comboSyncInterval->setCurrentIndex(1);
            break;
        case 30:
            ui->comboSyncInterval->setCurrentIndex(2);
            break;
        case 60:
            ui->comboSyncInterval->setCurrentIndex(3);
            break;
        case -1:
            ui->comboSyncInterval->setCurrentIndex(4);
            break;
        default:
            ui->comboSyncInterval->setCurrentIndex(1);
    }

    int nMethod = userSettings().syncMethod();
    switch (nMethod) {
        case -1:
            ui->comboSyncMethod->setCurrentIndex(0);
            break;
        case 1:
            ui->comboSyncMethod->setCurrentIndex(1);
            break;
        case 7:
            ui->comboSyncMethod->setCurrentIndex(2);
            break;
        case 30:
            ui->comboSyncMethod->setCurrentIndex(3);
            break;
        case 99999:
            ui->comboSyncMethod->setCurrentIndex(4);
            break;
        default:
            ui->comboSyncMethod->setCurrentIndex(2);
    }

    connect(ui->comboSyncInterval, SIGNAL(activated(int)), SLOT(on_comboSyncInterval_activated(int)));
    connect(ui->comboSyncMethod, SIGNAL(activated(int)), SLOT(on_comboSyncMethod_activated(int)));

    QString proxySettings = WizFormatString1("<a href=\"proxy_settings\">%1</a>", tr("Proxy settings"));
    ui->labelProxySettings->setText(proxySettings);
    connect(ui->labelProxySettings, SIGNAL(linkActivated(const QString&)), SLOT(labelProxy_linkActivated(const QString&)));

    // format tab
    QString strFont = QString("%1  %2").
            arg(m_app.userSettings().defaultFontFamily())
            .arg(m_app.userSettings().defaultFontSize());
    ui->editFont->setText(strFont);

    connect(ui->buttonFontSelect, SIGNAL(clicked()), SLOT(onButtonFontSelect_clicked()));
}
void CWizPreferenceWindow::on_checkDownloadAllNotesData_clicked(bool checked)
{
    userSettings().setDownloadAllNotesData(checked);
    emit settingsChanged(wizoptionsSync);
}
void CWizPreferenceWindow::on_checkAutoSync_clicked(bool checked)
{
    userSettings().setAutoSync(checked);
    emit settingsChanged(wizoptionsSync);
}
CWizPreferenceWindow::CWizPreferenceWindow(CWizExplorerApp& app, QWidget* parent)
    : QDialog(parent)
    , ui(new Ui::CWizPreferenceWindow)
    , m_app(app)
    , m_dbMgr(app.databaseManager())
{
    ui->setupUi(this);
    setWindowIcon(QIcon());
    setWindowTitle(tr("Preference"));

    connect(ui->btnClose, SIGNAL(clicked()), SLOT(accept()));

    // FIXME: proxy settings will back soon!!!
    ui->labelProxySettings->hide();

    // general tab
    ::WizGetTranslatedLocales(m_locales);
    for (int i = 0; i < m_locales.count(); i++) {
        ui->comboLang->addItem(::WizGetTranslatedLocaleDisplayName(i));
    }

    for (int i = 0; i < ui->comboLang->count(); i++) {
        if (m_locales[i] == userSettings().locale()) {
            ui->comboLang->setCurrentIndex(i);
        }
    }

    connect(ui->comboLang, SIGNAL(activated(int)), SLOT(on_comboLang_activated(int)));

    // reading tab
    switch (userSettings().noteViewMode())
    {
        case viewmodeAlwaysEditing:
            ui->radioAlwaysEditing->setChecked(true);
            break;
        case viewmodeAlwaysReading:
            ui->radioAlwaysReading->setChecked(true);
            break;
        default:
            ui->radioAuto->setChecked(true);
            break;
    }

    connect(ui->radioAuto, SIGNAL(clicked(bool)), SLOT(on_radioAuto_clicked(bool)));
    connect(ui->radioAlwaysReading, SIGNAL(clicked(bool)), SLOT(on_radioAlwaysReading_clicked(bool)));
    connect(ui->radioAlwaysEditing, SIGNAL(clicked(bool)), SLOT(on_radioAlwaysEditing_clicked(bool)));

    // syncing tab
    int nInterval = userSettings().syncInterval();
    switch (nInterval) {
        case 5:
            ui->comboSyncInterval->setCurrentIndex(0);
            break;
        case 15:
            ui->comboSyncInterval->setCurrentIndex(1);
            break;
        case 30:
            ui->comboSyncInterval->setCurrentIndex(2);
            break;
        case 60:
            ui->comboSyncInterval->setCurrentIndex(3);
            break;
        case -1:
            ui->comboSyncInterval->setCurrentIndex(4);
            break;
        default:
            ui->comboSyncInterval->setCurrentIndex(1);
    }

    switch (m_dbMgr.db().GetObjectSyncTimeline()) {
        case -1:
            ui->comboSyncMethod->setCurrentIndex(0);
            break;
        case 1:
            ui->comboSyncMethod->setCurrentIndex(1);
            break;
        case 7:
            ui->comboSyncMethod->setCurrentIndex(2);
            break;
        case 30:
            ui->comboSyncMethod->setCurrentIndex(3);
            break;
        case 99999:
            ui->comboSyncMethod->setCurrentIndex(4);
            break;
        default:
            ui->comboSyncMethod->setCurrentIndex(4);
    }

    int nDays = 1;
    if (m_dbMgr.count()) {
        nDays = m_dbMgr.at(0).GetObjectSyncTimeline();
    }

    switch (nDays) {
        case -1:
            ui->comboSyncGroupMethod->setCurrentIndex(0);
            break;
        case 1:
            ui->comboSyncGroupMethod->setCurrentIndex(1);
            break;
        case 7:
            ui->comboSyncGroupMethod->setCurrentIndex(2);
            break;
        case 30:
            ui->comboSyncGroupMethod->setCurrentIndex(3);
            break;
        case 99999:
            ui->comboSyncGroupMethod->setCurrentIndex(4);
            break;
        default:
            ui->comboSyncGroupMethod->setCurrentIndex(1);
    }

    connect(ui->comboSyncInterval, SIGNAL(activated(int)), SLOT(on_comboSyncInterval_activated(int)));
    connect(ui->comboSyncMethod, SIGNAL(activated(int)), SLOT(on_comboSyncMethod_activated(int)));
    connect(ui->comboSyncGroupMethod, SIGNAL(activated(int)), SLOT(on_comboSyncGroupMethod_activated(int)));

    QString proxySettings = WizFormatString1("<a href=\"proxy_settings\">%1</a>", tr("Proxy settings"));
    ui->labelProxySettings->setText(proxySettings);
    connect(ui->labelProxySettings, SIGNAL(linkActivated(const QString&)),
            SLOT(labelProxy_linkActivated(const QString&)));

    // format tab
    QString strFont = QString("%1  %2").
            arg(m_app.userSettings().defaultFontFamily())
            .arg(m_app.userSettings().defaultFontSize());
    ui->editFont->setText(strFont);

    connect(ui->buttonFontSelect, SIGNAL(clicked()), SLOT(onButtonFontSelect_clicked()));
}
Beispiel #22
0
void userEventAction( int key )
{
  switch(key)
  {
  case '0': /* ワイヤーフレームポリゴン */
    drawLines = !drawLines;
    break;

  case '1':
    smoothEnabled = !smoothEnabled;
    break;

  case '2': /* 照明 */
    lightingEnabled = !lightingEnabled;
    break;

  case '3': /* テクスチャ */
    texEnabled = !texEnabled;
    break;

  case '4': /* 霧 */
    fogEnabled = !fogEnabled;
    break;

  case '5': /* 隠面消去 */
    depthEnabled = !depthEnabled;
    break;

  case '6': /* 直線アンチエリアシング */
    lineAAEnabled = !lineAAEnabled;
    break;

  case '7': /* 透視投影テクスチャ */
    fastTexture = !fastTexture;
    break;

  case 'b':
    currentMaterials = &brassMaterials;
    break;

  case 'c':
    currentMaterials = &colorCubeMaterials;
    break;

  case 'C':
    currentLighting = &colorCubeLighting;
    break;

  case 'i':
    idleSpin = !idleSpin;
    break;

  case 'm': /* ミップマップしたテクスチャ */
    mipmapEnabled = !mipmapEnabled;
    break;

  case 'p':
    perspectiveXform = !perspectiveXform;
    break;

  case 'r':
    currentMaterials = &redPlasticMaterials;
    break;

  case 'w':
    currentLighting = &whiteLighting;
    break;

  case 27:
    exit(0);
  default:
    break;
  }

  userSettings();
  glutPostRedisplay();
}
Beispiel #23
0
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    QApplication::setApplicationName(QObject::tr("WizNote"));
    //IWizGlobal::instance()->setVersion("1.3.0");

#if defined Q_OS_MAC
    QDir dir(QApplication::applicationDirPath());
    dir.cdUp();
    dir.cd("PlugIns");
    QApplication::addLibraryPath(dir.absolutePath());
#elif defined Q_OS_LINUX
    QDir dir(QApplication::applicationDirPath());
    dir.cdUp();
    dir.cd("plugins");
    QApplication::addLibraryPath(dir.absolutePath());
#endif

    CWizSettings settings(QDir::homePath() + "/.wiznote/wiznote.ini");

#ifdef Q_OS_WIN
    QString strDefaultFontName = settings.GetString("Common", "DefaultFont", "");
    QFont f = WizCreateWindowsUIFont(a, strDefaultFontName);
    a.setFont(f);
#endif

    // set icon
    QIcon iconApp;
    iconApp.addFile(WizGetResourcesPath() + "skins/wiznote16.png");
    iconApp.addFile(WizGetResourcesPath() + "skins/wiznote24.png");
    iconApp.addFile(WizGetResourcesPath() + "skins/wiznote32.png");
    iconApp.addFile(WizGetResourcesPath() + "skins/wiznote48.png");
    iconApp.addFile(WizGetResourcesPath() + "skins/wiznote64.png");
    iconApp.addFile(WizGetResourcesPath() + "skins/wiznote128.png");
    iconApp.addFile(WizGetResourcesPath() + "skins/wiznote256.png");
    QApplication::setWindowIcon(iconApp);

    QString strUserId = settings.GetString("Users", "DefaultUser", "");
    QString strPassword;

    CWizUserSettings userSettings(strUserId);

    // setup locale for welcome dialog
    QString strLocale = userSettings.locale();

    QTranslator translatorWizNote;
    QString strLocaleFile = WizGetLocaleFileName(strLocale);
    translatorWizNote.load(strLocaleFile);
    a.installTranslator(&translatorWizNote);

    QTranslator translatorQt;
    strLocaleFile = WizGetQtLocaleFileName(strLocale);
    translatorQt.load(strLocaleFile);
    a.installTranslator(&translatorQt);

    // check update if needed
    CWizUpdaterDialog updater;
    if (updater.checkNeedUpdate()) {
        updater.show();
        updater.doUpdate();
        int ret = a.exec();
        QProcess::startDetached(argv[0], QStringList());
        return ret;
    }

    // figure out auto login or manually login
    bool bFallback = true;

    bool bAutoLogin = userSettings.autoLogin();
    strPassword = ::WizDecryptPassword(userSettings.password());

    if (bAutoLogin && !strPassword.isEmpty()) {
        bFallback = false;
    }

    // manually login
    if (bFallback) {

        WelcomeDialog dlgWelcome(strUserId, strLocale);
        if (QDialog::Accepted != dlgWelcome.exec())
            return 0;

        strUserId = dlgWelcome.userId();
        strPassword = dlgWelcome.password();
    }

    // reset password for restart event, will not touch welcome dialog
    QStringList args = QApplication::arguments();
    if (args.count() >= 3) {
        for (int i = 0; i < args.count(); i++) {
            if (!args.at(i).compare("--autologin=0")) {
                userSettings.setAutoLogin(false);
            } else if(!args.at(i).compare("--autologin=1")) {
                userSettings.setAutoLogin(true);
            } else if(!args.at(i).compare("--cleanpassword=1")) {
                userSettings.setPassword();
            }
        }
    }

    // reset locale for current user.
    userSettings.setUser(strUserId);
    strLocale = userSettings.locale();

    a.removeTranslator(&translatorWizNote);
    strLocaleFile = WizGetLocaleFileName(strLocale);
    translatorWizNote.load(strLocaleFile);
    a.installTranslator(&translatorWizNote);

    a.removeTranslator(&translatorQt);
    strLocaleFile = WizGetQtLocaleFileName(strLocale);
    translatorQt.load(strLocaleFile);
    a.installTranslator(&translatorQt);

    // ready
    //CWizDatabase db;
    //if (!db.openPrivate(strUserId, strPassword))
    //{
    //    QMessageBox::critical(NULL, "", QObject::tr("Can not open account"));
    //    return 0;
    //}
    CWizDatabaseManager dbMgr(strUserId);
    dbMgr.setPasswd(strPassword);
    if (!dbMgr.openAll()) {
        QMessageBox::critical(NULL, "", QObject::tr("Can not open database"));
        return 0;
    }

    MainWindow w(dbMgr);
    w.show();
    w.init();

    int ret = a.exec();

    // clean up
    QString strTempPath = ::WizGlobal()->GetTempPath();
    ::WizDeleteAllFilesInFolder(strTempPath);

    // restart
    if (w.isRestart())
    {
        userSettings.setUser(strUserId);

        // reset auto login
        bAutoLogin = userSettings.autoLogin();
        userSettings.setAutoLogin(true);

        // reset password
        // if user did not choose remember password, stored password already cleaned from database
        // we need store it back.
        bool bCleanPassword = false;
        if (userSettings.password().isEmpty()) {
            userSettings.setPassword(::WizEncryptPassword(strPassword));
            bCleanPassword = true;
        }

        // generate arguments
        QStringList argsRestart;
        if (bAutoLogin) {
            argsRestart.append(QString("--autologin=1"));
        } else {
            argsRestart.append(QString("--autologin=0"));
        }

        if (bCleanPassword) {
            argsRestart.append(QString("--cleanpassword=1"));
        } else {
            argsRestart.append(QString("--cleanpassword=0"));
        }

        QProcess::startDetached(argv[0], argsRestart);
    } else if (w.isLogout()) {
        QProcess::startDetached(argv[0], QStringList());
    }

    return ret;
}
CWizPreferenceWindow::CWizPreferenceWindow(CWizExplorerApp& app, QWidget* parent)
    : QDialog(parent)
    , ui(new Ui::CWizPreferenceWindow)
    , m_app(app)
    , m_dbMgr(app.databaseManager())
{
    ui->setupUi(this);
    setWindowIcon(QIcon());
    setWindowTitle(tr("Preference"));

    connect(ui->btnClose, SIGNAL(clicked()), SLOT(accept()));

    // general tab
    ::WizGetTranslatedLocales(m_locales);
    ui->comboLang->blockSignals(true);
    for (int i = 0; i < m_locales.count(); i++) {
        ui->comboLang->addItem(::WizGetTranslatedLocaleDisplayName(i));
    }

    for (int i = 0; i < ui->comboLang->count(); i++) {
        if (m_locales[i] == userSettings().locale()) {
            ui->comboLang->setCurrentIndex(i);
        }
    }
    ui->comboLang->blockSignals(false);

    ui->checkBox->blockSignals(true);
    Qt::CheckState checkState = userSettings().autoCheckUpdate() ? Qt::Checked : Qt::Unchecked;
    ui->checkBox->setCheckState(checkState);
    ui->checkBox->blockSignals(false);

    ui->checkBoxTrayIcon->blockSignals(true);
    checkState = userSettings().showSystemTrayIcon() ? Qt::Checked : Qt::Unchecked;
    ui->checkBoxTrayIcon->setCheckState(checkState);
    ui->checkBoxTrayIcon->blockSignals(false);

#ifdef BUILD4APPSTORE
    // hide language choice and upgrade for appstore
    ui->comboLang->setEnabled(false);
    ui->checkBox->setVisible(false);
#endif

#ifndef Q_OS_LINUX
  ui->checkBoxSystemStyle->setVisible(false);
#endif
  checkState = userSettings().useSystemBasedStyle() ? Qt::Checked : Qt::Unchecked;
  ui->checkBoxSystemStyle->blockSignals(true);
  ui->checkBoxSystemStyle->setCheckState(checkState);
  ui->checkBoxSystemStyle->blockSignals(false);

    // reading tab
    switch (userSettings().noteViewMode())
    {
        case viewmodeAlwaysEditing:
            ui->radioAlwaysEditing->setChecked(true);
            break;
        case viewmodeAlwaysReading:
            ui->radioAlwaysReading->setChecked(true);
            break;
        default:
            ui->radioAuto->setChecked(true);
            break;
    }

    // syncing tab
    int nInterval = userSettings().syncInterval();
    switch (nInterval) {
        case 5:
            ui->comboSyncInterval->setCurrentIndex(0);
            break;
        case 15:
            ui->comboSyncInterval->setCurrentIndex(1);
            break;
        case 30:
            ui->comboSyncInterval->setCurrentIndex(2);
            break;
        case 60:
            ui->comboSyncInterval->setCurrentIndex(3);
            break;
        case -1:
            ui->comboSyncInterval->setCurrentIndex(4);
            break;
        default:
            ui->comboSyncInterval->setCurrentIndex(1);
    }

    switch (m_dbMgr.db().GetObjectSyncTimeline()) {
        case -1:
            ui->comboSyncMethod->setCurrentIndex(0);
            break;
        case 1:
            ui->comboSyncMethod->setCurrentIndex(1);
            break;
        case 7:
            ui->comboSyncMethod->setCurrentIndex(2);
            break;
        case 30:
            ui->comboSyncMethod->setCurrentIndex(3);
            break;
        case 99999:
            ui->comboSyncMethod->setCurrentIndex(4);
            break;
        default:
            ui->comboSyncMethod->setCurrentIndex(4);
    }

    int nDays = 1;
    if (m_dbMgr.count()) {
        nDays = m_dbMgr.at(0).GetObjectSyncTimeline();
    }

    switch (nDays) {
        case -1:
            ui->comboSyncGroupMethod->setCurrentIndex(0);
            break;
        case 1:
            ui->comboSyncGroupMethod->setCurrentIndex(1);
            break;
        case 7:
            ui->comboSyncGroupMethod->setCurrentIndex(2);
            break;
        case 30:
            ui->comboSyncGroupMethod->setCurrentIndex(3);
            break;
        case 99999:
            ui->comboSyncGroupMethod->setCurrentIndex(4);
            break;
        default:
            ui->comboSyncGroupMethod->setCurrentIndex(1);
    }

    bool downloadAttachments = m_dbMgr.db().getDownloadAttachmentsAtSync();
    ui->comboDownloadAttachments->setCurrentIndex(downloadAttachments ? 1 : 0);

    connect(ui->comboSyncInterval, SIGNAL(activated(int)), SLOT(on_comboSyncInterval_activated(int)));
    connect(ui->comboSyncMethod, SIGNAL(activated(int)), SLOT(on_comboSyncMethod_activated(int)));
    connect(ui->comboSyncGroupMethod, SIGNAL(activated(int)), SLOT(on_comboSyncGroupMethod_activated(int)));
    connect(ui->comboDownloadAttachments, SIGNAL(activated(int)), SLOT(on_comboDownloadAttachments_activated(int)));

    QString proxySettings = WizFormatString1("<a href=\"proxy_settings\" style=\"color:#3CA2E0;\">%1</a>", tr("Proxy settings"));
    ui->labelProxySettings->setText(proxySettings);
    connect(ui->labelProxySettings, SIGNAL(linkActivated(const QString&)),
            SLOT(labelProxy_linkActivated(const QString&)));

    // format tab
    QString strFont = QString("%1  %2").
            arg(m_app.userSettings().defaultFontFamily())
            .arg(m_app.userSettings().defaultFontSize());
    ui->editFont->setText(strFont);

    connect(ui->buttonFontSelect, SIGNAL(clicked()), SLOT(onButtonFontSelect_clicked()));

    //
    ui->comboBox_unit->setCurrentIndex(m_app.userSettings().printMarginUnit());
    ui->spinBox_bottom->setValue(m_app.userSettings().printMarginValue(wizPositionBottom));
    ui->spinBox_left->setValue(m_app.userSettings().printMarginValue(wizPositionLeft));
    ui->spinBox_right->setValue(m_app.userSettings().printMarginValue(wizPositionRight));
    ui->spinBox_top->setValue(m_app.userSettings().printMarginValue(wizPositionTop));

    bool searchEncryptedNote = m_app.userSettings().searchEncryptedNote();
    ui->checkBoxSearchEncryNote->setChecked(searchEncryptedNote);
    ui->lineEditNotePassword->setEnabled(searchEncryptedNote);
    ui->lineEditNotePassword->setText(m_app.userSettings().encryptedNotePassword());

    QString strColor = m_app.userSettings().editorBackgroundColor();
    ui->pushButtonBackgroundColor->setStyleSheet(QString("QPushButton "
                                                         "{ border: 1px; background: %1; height:20px;  border-radius:5px } ").arg(strColor));
    ui->pushButtonClearBackground->setStyleSheet(QString("QPushButton:pressed{background-color: #000000;"));

    bool manuallySortFolders = m_app.userSettings().isManualSortingEnabled();
    ui->checkBoxManuallySort->setChecked(manuallySortFolders);
}