void NMainMenuBar::createThemeMenu(QMenu *parentMenu) { QMenu *menu = parentMenu->addMenu(tr("Theme")); QStringList list = global.getThemeNames(); QFont f = global.getGuiFont(QFont()); global.settings->beginGroup(INI_GROUP_APPEARANCE); QString userTheme = global.settings->value("themeName", DEFAULT_THEME_NAME).toString(); global.settings->endGroup(); // Setup themes (we expect to find the DEFAULT_THEME_NAME theme as first one) for (int i = 0; i < list.size(); i++) { QString themeName(list[i]); if ((i == 0) && (QString::compare(themeName, DEFAULT_THEME_NAME, Qt::CaseInsensitive) != 0)) { QLOG_ERROR() << "First theme is expected to be " << DEFAULT_THEME_NAME; } QAction *themeAction = new QAction(themeName, this); themeAction->setData(themeName); themeAction->setCheckable(true); themeAction->setFont(f); connect(themeAction, SIGNAL(triggered()), parent, SLOT(reloadIcons())); if (themeName == userTheme) { themeAction->setChecked(true); } themeActions.append(themeAction); } menu->addActions(themeActions); menu->setFont(f); }
AppearancePreferences::AppearancePreferences(QWidget *parent) : QWidget(parent) { mainLayout = new QGridLayout(); mainLayout->setAlignment(Qt::AlignTop); setLayout(mainLayout); int middleClickIndex = global.getMiddleClickAction(); showTrayIcon = new QCheckBox(tr("Show tray icon"), this); showPDFs = new QCheckBox(tr("Display PDFs inline"), this); showSplashScreen = new QCheckBox(tr("Show splash screen on startup"), this); autoStart = new QCheckBox(tr("Start automatically at login"), this); showMissedReminders = new QCheckBox(tr("Show missed reminders on startup"), this); startMinimized = new QCheckBox(tr("Always Start minimized"), this); dynamicTotals = new QCheckBox(tr("Show notebook and tag totals"), this); autoHideEditorButtonbar = new QCheckBox(tr("Auto-Hide editor toolbar"), this); autoHideEditorButtonbar->setChecked(global.autoHideEditorToolbar); disableEditingOnStartup = new QCheckBox(tr("Disable note editing on statup"), this); traySingleClickAction = new QComboBox(); traySingleClickAction->addItem(tr("Show/Hide NixNote"), 0); traySingleClickAction->addItem(tr("New Text Note"), 1); traySingleClickAction->addItem(tr("New Quick Note"), 2); traySingleClickAction->addItem(tr("Screen Capture"), 3); trayMiddleClickAction = new QComboBox(); trayMiddleClickAction->addItem(tr("Show/Hide NixNote"), 0); trayMiddleClickAction->addItem(tr("New Text Note"), 1); trayMiddleClickAction->addItem(tr("New Quick Note"), 2); trayMiddleClickAction->addItem(tr("Screen Capture"), 3); mouseMiddleClickAction = new QComboBox(); mouseMiddleClickAction->addItem(tr("Open New Tab"), MOUSE_MIDDLE_CLICK_NEW_TAB); mouseMiddleClickAction->addItem(tr("Open New Window"), MOUSE_MIDDLE_CLICK_NEW_WINDOW); mouseMiddleClickAction->setCurrentIndex(middleClickIndex); defaultGuiFontSizeChooser = new QComboBox(); defaultFontChooser = new QComboBox(); defaultFontSizeChooser = new QComboBox(); connect(defaultFontChooser, SIGNAL(currentIndexChanged(QString)), this, SLOT(loadFontSizes(QString))); loadFontNames(defaultFontChooser, global.defaultFont); defaultGuiFontChooser = new QComboBox(); connect(defaultGuiFontChooser, SIGNAL(currentIndexChanged(QString)), this, SLOT(loadGuiFontSizes(QString))); loadFontNames(defaultGuiFontChooser, global.defaultGuiFont); windowThemeChooser = new QComboBox(); windowThemeChooser->addItem(tr("System Default")); windowThemeChooser->addItems(global.getThemeNames()); defaultNotebookOnStartupLabel = new QLabel(tr("Startup Behavior"),this); defaultNotebookOnStartup = new QComboBox(); defaultNotebookOnStartup->addItem(tr("Restore Selection Criteria"), UseLastViewedNotebook); defaultNotebookOnStartup->addItem(tr("Select Default Notebook"), UseDefaultNotebook); defaultNotebookOnStartup->addItem(tr("View All Notebooks"), UseAllNotebooks); int row=0; minimizeToTray = NULL; closeToTray = NULL; mainLayout->addWidget(showTrayIcon,row++,0); if (QSystemTrayIcon::isSystemTrayAvailable()) { minimizeToTray = new QCheckBox(tr("Minimize to tray")); closeToTray = new QCheckBox(tr("Close to tray")); mainLayout->addWidget(minimizeToTray, row++, 0); mainLayout->addWidget(closeToTray, row++, 0); } mainLayout->addWidget(showSplashScreen, row++,0); mainLayout->addWidget(autoHideEditorButtonbar, row++, 0); mainLayout->addWidget(showPDFs, row++,0); mainLayout->addWidget(showMissedReminders, row++, 0); mainLayout->addWidget(dynamicTotals, row++, 0); mainLayout->addWidget(startMinimized, row++, 0); mainLayout->addWidget(autoStart, row++, 0); mainLayout->addWidget(disableEditingOnStartup, row++, 0); mainLayout->addWidget(defaultNotebookOnStartupLabel,row,0); mainLayout->addWidget(defaultNotebookOnStartup, row++,1); mainLayout->addWidget(new QLabel(tr("Middle Click Open Behavior")), row,0); mainLayout->addWidget(mouseMiddleClickAction, row++, 1); mainLayout->addWidget(new QLabel(tr("Tray Icon Click Action")), row, 0); mainLayout->addWidget(traySingleClickAction, row++, 1); mainLayout->addWidget(new QLabel(tr("Tray Icon Middle Click Action")), row, 0); mainLayout->addWidget(trayMiddleClickAction, row++, 1); mainLayout->addWidget(new QLabel(tr("Default GUI Font*")), row, 0); mainLayout->addWidget(defaultGuiFontChooser, row++, 1); mainLayout->addWidget(new QLabel(tr("Default GUI Font Size*")), row, 0); mainLayout->addWidget(defaultGuiFontSizeChooser, row++, 1); mainLayout->addWidget(new QLabel(tr("Default Editor Font*")), row, 0); mainLayout->addWidget(defaultFontChooser, row++, 1); mainLayout->addWidget(new QLabel(tr("Default Editor Font Size*")), row, 0); mainLayout->addWidget(defaultFontSizeChooser, row++, 1); mainLayout->addWidget(new QLabel(""), row++, 0); mainLayout->addWidget(new QLabel(tr("* May require restart on some systems.")), row++, 0); global.settings->beginGroup("Appearance"); disableEditingOnStartup->setChecked(global.settings->value("disableEditingOnStartup",false).toBool()); int idx = global.settings->value("traySingleClickAction", 0).toInt(); idx = traySingleClickAction->findData(idx, Qt::UserRole); traySingleClickAction->setCurrentIndex(idx); idx = global.settings->value("trayMiddleClickAction", 0).toInt(); idx = traySingleClickAction->findData(idx, Qt::UserRole); trayMiddleClickAction->setCurrentIndex(idx); showTrayIcon->setChecked(global.settings->value("showTrayIcon", false).toBool()); showPDFs->setChecked(global.settings->value("showPDFs", true).toBool()); showSplashScreen->setChecked(global.settings->value("showSplashScreen", false).toBool()); showMissedReminders->setChecked(global.settings->value("showMissedReminders", false).toBool()); startMinimized->setChecked(global.settings->value("startMinimized", false).toBool()); if (global.countBehavior == Global::CountAll) dynamicTotals->setChecked(true); else dynamicTotals->setChecked(false); autoStart->setChecked(global.settings->value("autoStart", false).toBool()); int defaultNotebook = global.settings->value("startupNotebook", UseLastViewedNotebook).toInt(); defaultNotebookOnStartup->setCurrentIndex(defaultNotebook); global.settings->endGroup(); connect(showTrayIcon, SIGNAL(clicked(bool)), this, SLOT(showTrayIconChanged(bool))); if (minimizeToTray != NULL) { minimizeToTray->setChecked(global.minimizeToTray()); if (!showTrayIcon->isChecked()) minimizeToTray->setEnabled(false); } if (closeToTray != NULL) { closeToTray->setChecked(global.closeToTray()); if (!showTrayIcon->isChecked()) closeToTray->setEnabled(false); } this->setFont(global.getGuiFont(font())); }