CreationDateFieldWizard::CreationDateFieldWizard(const QString &fieldName, QWidget *parent, AbstractFieldWizard::EditMode editMode) : AbstractFieldWizard(fieldName, parent, editMode), ui(new Ui::CreationDateFieldWizard) { ui->setupUi(this); //setup format combo QDateTime nowDateTime = QDateTime::currentDateTime(); QLocale locale; ui->dateFormatBox->addItem(nowDateTime.toString( locale.dateTimeFormat(QLocale::ShortFormat)), 1); ui->dateFormatBox->addItem(nowDateTime.toString( locale.dateFormat(QLocale::ShortFormat)), 2); ui->dateFormatBox->addItem(nowDateTime.toString("ddd MMM d hh:mm yyyy"), 3); ui->dateFormatBox->addItem(nowDateTime.toString("ddd MMM d yyyy"), 4); ui->dateFormatBox->addItem(nowDateTime.toString("yyyy-MM-dd hh:mm"), 5); ui->dateFormatBox->addItem(nowDateTime.toString("yyyy-MM-dd"), 6); connect(ui->backButton, SIGNAL(clicked()), this, SIGNAL(backSignal())); connect(ui->finishButton, SIGNAL(clicked()), this, SIGNAL(finishSignal())); ui->finishButton->setFocus(); }
void DateFormWidget::loadMetadataDisplayProperties(const QString &metadata) { MetadataPropertiesParser parser(metadata); if (metadata.size() == 0) return; QString v; QLocale locale; QString dateFormat = locale.dateTimeFormat(QLocale::ShortFormat); v = parser.getValue("dateFormat"); if (v == "1") dateFormat = locale.dateTimeFormat(QLocale::ShortFormat); else if (v == "2") dateFormat = locale.dateFormat(QLocale::ShortFormat); else if (v == "3") dateFormat = "ddd MMM d hh:mm yyyy"; else if (v == "4") dateFormat = "ddd MMM d yyyy"; else if (v == "5") dateFormat = "yyyy-MM-dd hh:mm"; else if (v == "6") dateFormat = "yyyy-MM-dd"; //setup date time edit m_dateTimeEdit->setCalendarPopup(true); m_dateTimeEdit->setDisplayFormat(dateFormat); }
/** customize date format for feeds etc. */ void Rshare::customizeDateFormat() { QLocale locale = QLocale(); // set to default locale /* get long date format without weekday */ _dateformat = locale.dateFormat(QLocale::LongFormat); _dateformat.replace(QRegExp("^dddd,*[^ ]* *('[^']+' )*"), ""); _dateformat.replace(QRegExp(",* *dddd"), ""); _dateformat = _dateformat.trimmed(); }
QString Ago(int seconds_since_epoch, const QLocale& locale) { const QDateTime now = QDateTime::currentDateTime(); const QDateTime then = QDateTime::fromTime_t(seconds_since_epoch); const int days_ago = then.date().daysTo(now.date()); const QString time = then.time().toString(locale.timeFormat(QLocale::ShortFormat)); if (days_ago == 0) return tr("Today") + " " + time; if (days_ago == 1) return tr("Yesterday") + " " + time; if (days_ago <= 7) return tr("%1 days ago").arg(days_ago); return then.date().toString(locale.dateFormat(QLocale::ShortFormat)); }
// Replacements of special license template keywords. static bool keyWordReplacement(const QString &keyWord, const QString &file, const QString &className, QString *value) { if (keyWord == QLatin1String("%YEAR%")) { *value = QString::number(QDate::currentDate().year()); return true; } if (keyWord == QLatin1String("%MONTH%")) { *value = QString::number(QDate::currentDate().month()); return true; } if (keyWord == QLatin1String("%DAY%")) { *value = QString::number(QDate::currentDate().day()); return true; } if (keyWord == QLatin1String("%CLASS%")) { *value = className; return true; } if (keyWord == QLatin1String("%FILENAME%")) { *value = Utils::FileName::fromString(file).fileName(); return true; } if (keyWord == QLatin1String("%DATE%")) { static QString format; // ensure a format with 4 year digits. Some have locales have 2. if (format.isEmpty()) { QLocale loc; format = loc.dateFormat(QLocale::ShortFormat); const QChar ypsilon = QLatin1Char('y'); if (format.count(ypsilon) == 2) format.insert(format.indexOf(ypsilon), QString(2, ypsilon)); } *value = QDate::currentDate().toString(format); return true; } if (keyWord == QLatin1String("%USER%")) { *value = Utils::Environment::systemEnvironment().userName(); return true; } // Environment variables (for example '%$EMAIL%'). if (keyWord.startsWith(QLatin1String("%$"))) { const QString varName = keyWord.mid(2, keyWord.size() - 3); *value = QString::fromLocal8Bit(qgetenv(varName.toLocal8Bit())); return true; } return false; }
QString uiLanguage(QLocale *callerLoc) { QSettings s; s.beginGroup("Language"); if (!s.value("UseSystemLanguage", true).toBool()) { loc = QLocale(s.value("UiLanguage", QLocale().uiLanguages().first()).toString()); } else { loc = QLocale(QLocale().uiLanguages().first()); } QString uiLang = loc.uiLanguages().first(); s.endGroup(); // there's a stupid Qt bug on MacOS where uiLanguages doesn't give us the country info if (!uiLang.contains('-') && uiLang != loc.bcp47Name()) { QLocale loc2(loc.bcp47Name()); loc = loc2; uiLang = loc2.uiLanguages().first(); } if (callerLoc) *callerLoc = loc; // the short format is fine // the long format uses long weekday and month names, so replace those with the short ones // for time we don't want the time zone designator and don't want leading zeroes on the hours shortDateFormat = loc.dateFormat(QLocale::ShortFormat); dateFormat = loc.dateFormat(QLocale::LongFormat); dateFormat.replace("dddd,", "ddd").replace("dddd", "ddd").replace("MMMM", "MMM"); // special hack for Swedish as our switching from long weekday names to short weekday names // messes things up there dateFormat.replace("'en' 'den' d:'e'", " d"); timeFormat = loc.timeFormat(); timeFormat.replace("(t)", "").replace(" t", "").replace("t", "").replace("hh", "h").replace("HH", "H").replace("'kl'.", ""); timeFormat.replace(".ss", "").replace(":ss", "").replace("ss", ""); return uiLang; }
// Replacements of special license template keywords. static bool keyWordReplacement(const QString &keyWord, QString *value) { if (keyWord == QLatin1String("%YEAR%")) { *value = QLatin1String("%{CurrentDate:yyyy}"); return true; } if (keyWord == QLatin1String("%MONTH%")) { *value = QLatin1String("%{CurrentDate:M}"); return true; } if (keyWord == QLatin1String("%DAY%")) { *value = QLatin1String("%{CurrentDate:d}"); return true; } if (keyWord == QLatin1String("%CLASS%")) { *value = QLatin1String("%{Cpp:License:ClassName}"); return true; } if (keyWord == QLatin1String("%FILENAME%")) { *value = QLatin1String("%{Cpp:License:FileName}"); return true; } if (keyWord == QLatin1String("%DATE%")) { static QString format; // ensure a format with 4 year digits. Some have locales have 2. if (format.isEmpty()) { QLocale loc; format = loc.dateFormat(QLocale::ShortFormat); const QChar ypsilon = QLatin1Char('y'); if (format.count(ypsilon) == 2) format.insert(format.indexOf(ypsilon), QString(2, ypsilon)); } *value = QString::fromLatin1("%{CurrentDate:") + format + QLatin1Char('}'); return true; } if (keyWord == QLatin1String("%USER%")) { *value = QLatin1String("%{Env:USER}"); return true; } // Environment variables (for example '%$EMAIL%'). if (keyWord.startsWith(QLatin1String("%$"))) { const QString varName = keyWord.mid(2, keyWord.size() - 3); *value = QString::fromLatin1("%{Env:") + varName + QLatin1Char('}'); return true; } return false; }
void BudgetEntityDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const { if (index.column() != 0 || !index.data().canConvert<BudgetEntity>()) { QStyledItemDelegate::paint(painter, option, index); return; } BudgetEntity entity = qvariant_cast<BudgetEntity>(index.data()); painter->save(); painter->setRenderHint(QPainter::Antialiasing); QLocale locale; QStyleOptionViewItemV4 opt = option; QStyledItemDelegate::initStyleOption(&opt, index); QRect rect = opt.rect; opt.text = ""; QStyle *style = opt.widget ? opt.widget->style() : QApplication::style(); style->drawControl(QStyle::CE_ItemViewItem, &opt, painter, opt.widget); QPalette::ColorGroup cg = opt.state & QStyle::State_Enabled ? QPalette::Normal : QPalette::Disabled; if (opt.state & QStyle::State_Selected) { painter->setPen(opt.palette.color(cg, QPalette::HighlightedText)); } else { painter->setPen(opt.palette.color(cg, QPalette::Text)); } if (dateWidth <= 0) { QDate _date = QDate(9999, 12, 29); //*((int*)(&dateWidth)) = painter->fontMetrics().width(_date.toString(locale.dateFormat(QLocale::ShortFormat))) + 10; dateWidth = painter->fontMetrics().width(_date.toString(locale.dateFormat(QLocale::ShortFormat))) + 10;; } QString amount = locale.toCurrencyString(entity.amount(), locale.currencySymbol(QLocale::CurrencySymbol)); int amountWidth = painter->fontMetrics().width(amount); QRect adj = rect.adjusted(3, rect.height()/3, -3, rect.height()/3); painter->drawText(adj.adjusted(0, 0, -amountWidth, 0), Qt::TextSingleLine, entity.date().toString(locale.dateFormat(QLocale::ShortFormat))); painter->drawText(adj.adjusted(adj.left() + dateWidth, 0, -amountWidth, 0), Qt::TextWordWrap, entity.description()); painter->drawText(adj.adjusted(adj.left() + dateWidth + amountWidth, 0, 0, 0), Qt::AlignRight | Qt::TextSingleLine, amount); painter->restore(); }
void LXQtWorldClock::settingsChanged() { PluginSettings *_settings = settings(); QString oldFormat = mFormat; mTimeZones.clear(); QList<QMap<QString, QVariant> > array = _settings->readArray(QLatin1String("timeZones")); for (const auto &map : array) { QString timeZoneName = map.value(QLatin1String("timeZone"), QString()).toString(); mTimeZones.append(timeZoneName); mTimeZoneCustomNames[timeZoneName] = map.value(QLatin1String("customName"), QString()).toString(); } if (mTimeZones.isEmpty()) mTimeZones.append(QLatin1String("local")); mDefaultTimeZone = _settings->value(QLatin1String("defaultTimeZone"), QString()).toString(); if (mDefaultTimeZone.isEmpty()) mDefaultTimeZone = mTimeZones[0]; mActiveTimeZone = mDefaultTimeZone; bool longTimeFormatSelected = false; QString formatType = _settings->value(QLatin1String("formatType"), QString()).toString(); QString dateFormatType = _settings->value(QLatin1String("dateFormatType"), QString()).toString(); bool advancedManual = _settings->value(QLatin1String("useAdvancedManualFormat"), false).toBool(); // backward compatibility if (formatType == QLatin1String("custom")) { formatType = QLatin1String("short-timeonly"); dateFormatType = QLatin1String("short"); advancedManual = true; } else if (formatType == QLatin1String("short")) { formatType = QLatin1String("short-timeonly"); dateFormatType = QLatin1String("short"); advancedManual = false; } else if ((formatType == QLatin1String("full")) || (formatType == QLatin1String("long")) || (formatType == QLatin1String("medium"))) { formatType = QLatin1String("long-timeonly"); dateFormatType = QLatin1String("long"); advancedManual = false; } if (formatType == QLatin1String("long-timeonly")) longTimeFormatSelected = true; bool timeShowSeconds = _settings->value(QLatin1String("timeShowSeconds"), false).toBool(); bool timePadHour = _settings->value(QLatin1String("timePadHour"), false).toBool(); bool timeAMPM = _settings->value(QLatin1String("timeAMPM"), false).toBool(); // timezone bool showTimezone = _settings->value(QLatin1String("showTimezone"), false).toBool() && !longTimeFormatSelected; QString timezonePosition = _settings->value(QLatin1String("timezonePosition"), QString()).toString(); QString timezoneFormatType = _settings->value(QLatin1String("timezoneFormatType"), QString()).toString(); // date bool showDate = _settings->value(QLatin1String("showDate"), false).toBool(); QString datePosition = _settings->value(QLatin1String("datePosition"), QString()).toString(); bool dateShowYear = _settings->value(QLatin1String("dateShowYear"), false).toBool(); bool dateShowDoW = _settings->value(QLatin1String("dateShowDoW"), false).toBool(); bool datePadDay = _settings->value(QLatin1String("datePadDay"), false).toBool(); bool dateLongNames = _settings->value(QLatin1String("dateLongNames"), false).toBool(); // advanced QString customFormat = _settings->value(QLatin1String("customFormat"), tr("'<b>'HH:mm:ss'</b><br/><font size=\"-2\">'ddd, d MMM yyyy'<br/>'TT'</font>'")).toString(); if (advancedManual) mFormat = customFormat; else { QLocale locale = QLocale(QLocale::AnyLanguage, QLocale().country()); if (formatType == QLatin1String("short-timeonly")) mFormat = locale.timeFormat(QLocale::ShortFormat); else if (formatType == QLatin1String("long-timeonly")) mFormat = locale.timeFormat(QLocale::LongFormat); else // if (formatType == QLatin1String("custom-timeonly")) mFormat = QString(QLatin1String("%1:mm%2%3")).arg(timePadHour ? QLatin1String("hh") : QLatin1String("h")).arg(timeShowSeconds ? QLatin1String(":ss") : QLatin1String("")).arg(timeAMPM ? QLatin1String(" A") : QLatin1String("")); if (showTimezone) { QString timezonePortion; if (timezoneFormatType == QLatin1String("short")) timezonePortion = QLatin1String("TTTT"); else if (timezoneFormatType == QLatin1String("long")) timezonePortion = QLatin1String("TTTTT"); else if (timezoneFormatType == QLatin1String("offset")) timezonePortion = QLatin1String("T"); else if (timezoneFormatType == QLatin1String("abbreviation")) timezonePortion = QLatin1String("TTT"); else if (timezoneFormatType == QLatin1String("iana")) timezonePortion = QLatin1String("TT"); else // if (timezoneFormatType == QLatin1String("custom")) timezonePortion = QLatin1String("TTTTTT"); if (timezonePosition == QLatin1String("below")) mFormat = mFormat + QLatin1String("'<br/>'") + timezonePortion; else if (timezonePosition == QLatin1String("above")) mFormat = timezonePortion + QLatin1String("'<br/>'") + mFormat; else if (timezonePosition == QLatin1String("before")) mFormat = timezonePortion + QLatin1String(" ") + mFormat; else // if (timezonePosition == QLatin1String("after")) mFormat = mFormat + QLatin1String(" ") + timezonePortion; } if (showDate) { QString datePortion; if (dateFormatType == QLatin1String("short")) datePortion = locale.dateFormat(QLocale::ShortFormat); else if (dateFormatType == QLatin1String("long")) datePortion = locale.dateFormat(QLocale::LongFormat); else if (dateFormatType == QLatin1String("iso")) datePortion = QLatin1String("yyyy-MM-dd"); else // if (dateFormatType == QLatin1String("custom")) { QString datePortionOrder; QString dateLocale = locale.dateFormat(QLocale::ShortFormat).toLower(); int yearIndex = dateLocale.indexOf("y"); int monthIndex = dateLocale.indexOf("m"); int dayIndex = dateLocale.indexOf("d"); if (yearIndex < dayIndex) // Big-endian (year, month, day) (yyyy MMMM dd, dddd) -> in some Asia countires like China or Japan datePortionOrder = QLatin1String("%1%2%3 %4%5%6"); else if (monthIndex < dayIndex) // Middle-endian (month, day, year) (dddd, MMMM dd yyyy) -> USA datePortionOrder = QLatin1String("%6%5%3 %4%2%1"); else // Little-endian (day, month, year) (dddd, dd MMMM yyyy) -> most of Europe datePortionOrder = QLatin1String("%6%5%4 %3%2%1"); datePortion = datePortionOrder.arg(dateShowYear ? QLatin1String("yyyy") : QLatin1String("")).arg(dateShowYear ? QLatin1String(" ") : QLatin1String("")).arg(dateLongNames ? QLatin1String("MMMM") : QLatin1String("MMM")).arg(datePadDay ? QLatin1String("dd") : QLatin1String("d")).arg(dateShowDoW ? QLatin1String(", ") : QLatin1String("")).arg(dateShowDoW ? (dateLongNames ? QLatin1String("dddd") : QLatin1String("ddd")) : QLatin1String("")); } if (datePosition == QLatin1String("below")) mFormat = mFormat + QLatin1String("'<br/>'") + datePortion; else if (datePosition == QLatin1String("above")) mFormat = datePortion + QLatin1String("'<br/>'") + mFormat; else if (datePosition == QLatin1String("before")) mFormat = datePortion + QLatin1String(" ") + mFormat; else // if (datePosition == QLatin1String("after")) mFormat = mFormat + QLatin1String(" ") + datePortion; } } if ((oldFormat != mFormat)) { int update_interval; QString format = mFormat; format.replace(QRegExp(QLatin1String("'[^']*'")), QString()); //don't support updating on milisecond basis -> big performance hit if (format.contains(QLatin1String("s"))) update_interval = 1000; else if (format.contains(QLatin1String("m"))) update_interval = 60000; else update_interval = 3600000; if (update_interval != mUpdateInterval) { mUpdateInterval = update_interval; restartTimer(); } } bool autoRotate = settings()->value(QLatin1String("autoRotate"), true).toBool(); if (autoRotate != mAutoRotate) { mAutoRotate = autoRotate; realign(); } if (mPopup) { updatePopupContent(); mPopup->adjustSize(); mPopup->setGeometry(calculatePopupWindowPos(mPopup->size())); } setTimeText(); }
/** * @brief Constructor of UserInterfaceForm. * @param myParent Setting widget which will contain this form as tab. * * Restores all controls from the settings. */ UserInterfaceForm::UserInterfaceForm(SettingsWidget* myParent) : GenericForm(QPixmap(":/img/settings/general.png")) { parent = myParent; bodyUI = new Ui::UserInterfaceSettings; bodyUI->setupUi(this); // block all child signals during initialization const RecursiveSignalBlocker signalBlocker(this); Settings& s = Settings::getInstance(); const QFont chatBaseFont = s.getChatMessageFont(); bodyUI->txtChatFontSize->setValue(QFontInfo(chatBaseFont).pixelSize()); bodyUI->txtChatFont->setCurrentFont(chatBaseFont); int index = static_cast<int>(s.getStylePreference()); bodyUI->textStyleComboBox->setCurrentIndex(index); bool showWindow = s.getShowWindow(); bodyUI->showWindow->setChecked(showWindow); bodyUI->showInFront->setChecked(s.getShowInFront()); bodyUI->showInFront->setEnabled(showWindow); bodyUI->groupAlwaysNotify->setChecked(s.getGroupAlwaysNotify()); bodyUI->cbGroupchatPosition->setChecked(s.getGroupchatPosition()); bodyUI->cbCompactLayout->setChecked(s.getCompactLayout()); bodyUI->cbSeparateWindow->setChecked(s.getSeparateWindow()); bodyUI->cbDontGroupWindows->setChecked(s.getDontGroupWindows()); bodyUI->cbDontGroupWindows->setEnabled(s.getSeparateWindow()); bodyUI->useEmoticons->setChecked(s.getUseEmoticons()); for (auto entry : SmileyPack::listSmileyPacks()) bodyUI->smileyPackBrowser->addItem(entry.first, entry.second); smileLabels = {bodyUI->smile1, bodyUI->smile2, bodyUI->smile3, bodyUI->smile4, bodyUI->smile5}; int currentPack = bodyUI->smileyPackBrowser->findData(s.getSmileyPack()); bodyUI->smileyPackBrowser->setCurrentIndex(currentPack); reloadSmileys(); bodyUI->smileyPackBrowser->setEnabled(bodyUI->useEmoticons->isChecked()); bodyUI->styleBrowser->addItem(tr("None")); bodyUI->styleBrowser->addItems(QStyleFactory::keys()); QString style; if (QStyleFactory::keys().contains(s.getStyle())) style = s.getStyle(); else style = tr("None"); bodyUI->styleBrowser->setCurrentText(style); for (QString color : Style::getThemeColorNames()) bodyUI->themeColorCBox->addItem(color); bodyUI->themeColorCBox->setCurrentIndex(s.getThemeColor()); bodyUI->emoticonSize->setValue(s.getEmojiFontPointSize()); QLocale ql; QStringList timeFormats; timeFormats << ql.timeFormat(QLocale::ShortFormat) << ql.timeFormat(QLocale::LongFormat) << "hh:mm AP" << "hh:mm:ss AP" << "hh:mm:ss"; timeFormats.removeDuplicates(); bodyUI->timestamp->addItems(timeFormats); QRegularExpression re(QString("^[^\\n]{0,%0}$").arg(MAX_FORMAT_LENGTH)); QRegularExpressionValidator* validator = new QRegularExpressionValidator(re, this); QString timeFormat = s.getTimestampFormat(); if (!re.match(timeFormat).hasMatch()) timeFormat = timeFormats[0]; bodyUI->timestamp->setCurrentText(timeFormat); bodyUI->timestamp->setValidator(validator); on_timestamp_editTextChanged(timeFormat); QStringList dateFormats; dateFormats << QStringLiteral("yyyy-MM-dd") // ISO 8601 // format strings from system locale << ql.dateFormat(QLocale::LongFormat) << ql.dateFormat(QLocale::ShortFormat) << ql.dateFormat(QLocale::NarrowFormat) << "dd-MM-yyyy" << "d-MM-yyyy" << "dddd dd-MM-yyyy" << "dddd d-MM"; dateFormats.removeDuplicates(); bodyUI->dateFormats->addItems(dateFormats); QString dateFormat = s.getDateFormat(); if (!re.match(dateFormat).hasMatch()) dateFormat = dateFormats[0]; bodyUI->dateFormats->setCurrentText(dateFormat); bodyUI->dateFormats->setValidator(validator); on_dateFormats_editTextChanged(dateFormat); eventsInit(); Translator::registerHandler(std::bind(&UserInterfaceForm::retranslateUi, this), this); }
QString QtPropertyBrowserUtils::dateFormat() { QLocale loc; return loc.dateFormat(QLocale::ShortFormat); }
Overview::Overview(QWidget *parent, gGraphView *shared) : QWidget(parent), ui(new Ui::Overview), m_shared(shared) { ui->setupUi(this); // Set Date controls locale to 4 digit years QLocale locale = QLocale::system(); QString shortformat = locale.dateFormat(QLocale::ShortFormat); if (!shortformat.toLower().contains("yyyy")) { shortformat.replace("yy", "yyyy"); } ui->dateStart->setDisplayFormat(shortformat); ui->dateEnd->setDisplayFormat(shortformat); Qt::DayOfWeek dow = firstDayOfWeekFromLocale(); ui->dateStart->calendarWidget()->setFirstDayOfWeek(dow); ui->dateEnd->calendarWidget()->setFirstDayOfWeek(dow); // Stop both calendar drop downs highlighting weekends in red QTextCharFormat format = ui->dateStart->calendarWidget()->weekdayTextFormat(Qt::Saturday); format.setForeground(QBrush(COLOR_Black, Qt::SolidPattern)); ui->dateStart->calendarWidget()->setWeekdayTextFormat(Qt::Saturday, format); ui->dateStart->calendarWidget()->setWeekdayTextFormat(Qt::Sunday, format); ui->dateEnd->calendarWidget()->setWeekdayTextFormat(Qt::Saturday, format); ui->dateEnd->calendarWidget()->setWeekdayTextFormat(Qt::Sunday, format); // Connect the signals to update which days have CPAP data when the month is changed connect(ui->dateStart->calendarWidget(), SIGNAL(currentPageChanged(int, int)), SLOT(dateStart_currentPageChanged(int, int))); connect(ui->dateEnd->calendarWidget(), SIGNAL(currentPageChanged(int, int)), SLOT(dateEnd_currentPageChanged(int, int))); QVBoxLayout *framelayout = new QVBoxLayout; ui->graphArea->setLayout(framelayout); QFrame *border = new QFrame(ui->graphArea); framelayout->setMargin(1); border->setFrameShape(QFrame::StyledPanel); framelayout->addWidget(border,1); // Create the horizontal layout to hold the GraphView object and it's scrollbar layout = new QHBoxLayout(border); layout->setSpacing(0); // remove the ugly margins/spacing layout->setMargin(0); layout->setContentsMargins(0, 0, 0, 0); border->setLayout(layout); border->setAutoFillBackground(false); // Create the GraphView Object GraphView = new gGraphView(ui->graphArea, m_shared); GraphView->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); GraphView->setEmptyText(STR_Empty_NoData); // Create the custom scrollbar and attach to GraphView scrollbar = new MyScrollBar(ui->graphArea); scrollbar->setOrientation(Qt::Vertical); scrollbar->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Expanding); scrollbar->setMaximumWidth(20); GraphView->setScrollBar(scrollbar); // Add the graphView and scrollbar to the layout. layout->addWidget(GraphView, 1); layout->addWidget(scrollbar, 0); layout->layout(); dateLabel = new MyLabel(this); dateLabel->setAlignment(Qt::AlignVCenter); dateLabel->setText("[Date Widget]"); QFont font = dateLabel->font(); font.setPointSizeF(font.pointSizeF()*1.3F); dateLabel->setFont(font); QPalette palette = dateLabel->palette(); palette.setColor(QPalette::Base, Qt::blue); dateLabel->setPalette(palette); ui->dateLayout->addWidget(dateLabel,1); // uc = new SummaryChart(STR_UNIT_Hours, GT_BAR); // uc->addSlice(NoChannel, COLOR_Green, ST_HOURS); // UC->AddLayer(uc); /* return; // TODO: Automate graph creation process float percentile = p_profile->general->prefCalcPercentile() / 100.0; int mididx = p_profile->general->prefCalcMiddle(); SummaryType ST_mid; if (mididx == 0) { ST_mid = ST_PERC; } if (mididx == 1) { ST_mid = ST_WAVG; } if (mididx == 2) { ST_mid = ST_AVG; } SummaryType ST_max = p_profile->general->prefCalcMax() ? ST_PERC : ST_MAX; const EventDataType maxperc = 0.995F; US = createGraph(STR_GRAPH_SessionTimes, tr("Session Times"), tr("Session Times\n(hours)"), YT_Time); SET = createGraph("Settings", STR_TR_Settings, STR_TR_Settings); TGMV = createGraph(schema::channel[CPAP_TgMV].code(), schema::channel[CPAP_TgMV].label(), tr("Target\nVentilation\n(L/min)")); PTB = createGraph(schema::channel[CPAP_PTB].code(), schema::channel[CPAP_PTB].label(), tr("Patient\nTriggered\nBreaths\n(%)")); SES = createGraph(STR_GRAPH_Sessions, STR_TR_Sessions, STR_TR_Sessions + tr("\n(count)")); ahihr = new SummaryChart(STR_UNIT_EventsPerHour, GT_POINTS); ahihr->addSlice(ahicode, COLOR_Blue, ST_MAX); ahihr->addSlice(ahicode, COLOR_Orange, ST_WAVG); AHIHR->AddLayer(ahihr); weight = new SummaryChart(STR_TR_Weight, GT_POINTS); weight->setMachineType(MT_JOURNAL); weight->addSlice(Journal_Weight, COLOR_Black, ST_SETAVG); WEIGHT->AddLayer(weight); bmi = new SummaryChart(STR_TR_BMI, GT_POINTS); bmi->setMachineType(MT_JOURNAL); bmi->addSlice(Journal_BMI, COLOR_DarkBlue, ST_SETAVG); BMI->AddLayer(bmi); zombie = new SummaryChart(tr("Zombie Meter"), GT_POINTS); zombie->setMachineType(MT_JOURNAL); zombie->addSlice(Journal_ZombieMeter, COLOR_DarkRed, ST_SETAVG); ZOMBIE->AddLayer(zombie); pulse = new SummaryChart(STR_TR_PulseRate, GT_POINTS); pulse->setMachineType(MT_OXIMETER); pulse->addSlice(OXI_Pulse, COLOR_Red, ST_mid, 0.5); pulse->addSlice(OXI_Pulse, COLOR_Pink, ST_MIN); pulse->addSlice(OXI_Pulse, COLOR_Orange, ST_MAX); PULSE->AddLayer(pulse); spo2 = new SummaryChart(STR_TR_SpO2, GT_POINTS); spo2->setMachineType(MT_OXIMETER); spo2->addSlice(OXI_SPO2, COLOR_Cyan, ST_mid, 0.5); spo2->addSlice(OXI_SPO2, COLOR_LightBlue, ST_PERC, percentile); spo2->addSlice(OXI_SPO2, COLOR_Blue, ST_MIN); SPO2->AddLayer(spo2); fl = new SummaryChart(STR_TR_FL, GT_POINTS); fl->addSlice(CPAP_FlowLimit, COLOR_Brown, ST_CPH); FL->AddLayer(fl); sa = new SummaryChart(STR_TR_SA, GT_POINTS); sa->addSlice(CPAP_SensAwake, COLOR_Brown, ST_CNT); SA->AddLayer(sa); us = new SummaryChart(STR_UNIT_Hours, GT_SESSIONS); us->addSlice(NoChannel, COLOR_DarkBlue, ST_HOURS); us->addSlice(NoChannel, COLOR_Blue, ST_SESSIONS); US->AddLayer(us); ses = new SummaryChart(STR_TR_Sessions, GT_POINTS); ses->addSlice(NoChannel, COLOR_Blue, ST_SESSIONS); SES->AddLayer(ses); if (ahicode == CPAP_RDI) { bc = new SummaryChart(STR_TR_RDI, GT_BAR); } else { bc = new SummaryChart(STR_TR_AHI, GT_BAR); } bc->addSlice(CPAP_ClearAirway, COLOR_ClearAirway, ST_CPH); bc->addSlice(CPAP_Obstructive, COLOR_Obstructive, ST_CPH); bc->addSlice(CPAP_Apnea, COLOR_Apnea, ST_CPH); bc->addSlice(CPAP_Hypopnea, COLOR_Hypopnea, ST_CPH); if (p_profile->general->calculateRDI()) { bc->addSlice(CPAP_RERA, COLOR_RERA, ST_CPH); } // bc->addSlice(CPAP_UserFlag1, COLOR_UserFlag1, ST_CPH); // bc->addSlice(CPAP_UserFlag2, COLOR_UserFlag2, ST_CPH); AHI->AddLayer(bc); set = new SummaryChart("", GT_POINTS); //set->addSlice(PRS1_SysOneResistSet,COLOR_Gray,ST_SETAVG); set->addSlice(CPAP_HumidSetting, COLOR_Blue, ST_SETWAVG); set->addSlice(CPAP_PresReliefLevel, COLOR_Red, ST_SETWAVG); set->addSlice(CPAP_PresReliefMode, COLOR_Red, ST_SETWAVG); // set->addSlice(RMS9_EPRLevel,COLOR_Green,ST_SETWAVG); //set->addSlice(INTP_SmartFlex,COLOR_Purple,ST_SETWAVG); SET->AddLayer(set); rr = new SummaryChart(tr("breaths/min"), GT_POINTS); rr->addSlice(CPAP_RespRate, COLOR_LightBlue, ST_MIN); rr->addSlice(CPAP_RespRate, COLOR_Blue, ST_mid, 0.5); rr->addSlice(CPAP_RespRate, COLOR_LightGreen, ST_PERC, percentile); rr->addSlice(CPAP_RespRate, COLOR_Green, ST_max, maxperc); // rr->addSlice(CPAP_RespRate,COLOR_Green,ST_MAX); RR->AddLayer(rr); tv = new SummaryChart(tr("L/b"), GT_POINTS); tv->addSlice(CPAP_TidalVolume, COLOR_LightBlue, ST_MIN); tv->addSlice(CPAP_TidalVolume, COLOR_Blue, ST_mid, 0.5); tv->addSlice(CPAP_TidalVolume, COLOR_LightGreen, ST_PERC, percentile); tv->addSlice(CPAP_TidalVolume, COLOR_Green, ST_max, maxperc); TV->AddLayer(tv); mv = new SummaryChart(STR_UNIT_LPM, GT_POINTS); mv->addSlice(CPAP_MinuteVent, COLOR_LightBlue, ST_MIN); mv->addSlice(CPAP_MinuteVent, COLOR_Blue, ST_mid, 0.5); mv->addSlice(CPAP_MinuteVent, COLOR_LightGreen, ST_PERC, percentile); mv->addSlice(CPAP_MinuteVent, COLOR_Green, ST_max, maxperc); MV->AddLayer(mv); // should merge... tgmv = new SummaryChart(STR_UNIT_LPM, GT_POINTS); tgmv->addSlice(CPAP_TgMV, COLOR_LightBlue, ST_MIN); tgmv->addSlice(CPAP_TgMV, COLOR_Blue, ST_mid, 0.5); tgmv->addSlice(CPAP_TgMV, COLOR_LightGreen, ST_PERC, percentile); tgmv->addSlice(CPAP_TgMV, COLOR_Green, ST_max, maxperc); TGMV->AddLayer(tgmv); ptb = new SummaryChart(tr("%PTB"), GT_POINTS); ptb->addSlice(CPAP_PTB, COLOR_Yellow, ST_MIN); ptb->addSlice(CPAP_PTB, COLOR_Blue, ST_mid, 0.5); ptb->addSlice(CPAP_PTB, COLOR_LightGray, ST_PERC, percentile); ptb->addSlice(CPAP_PTB, COLOR_Orange, ST_WAVG); PTB->AddLayer(ptb); pr = new SummaryChart(STR_TR_Pressure, GT_POINTS); // Added in summarychart.. Slightly annoying.. PR->AddLayer(pr); totlk = new SummaryChart(STR_TR_TotalLeaks, GT_POINTS); totlk->addSlice(CPAP_LeakTotal, COLOR_LightBlue, ST_mid, 0.5); totlk->addSlice(CPAP_LeakTotal, COLOR_DarkGray, ST_PERC, percentile); totlk->addSlice(CPAP_LeakTotal, COLOR_Gray, ST_max, maxperc); //tot->addSlice(CPAP_Leak, COLOR_DarkBlue, ST_WAVG); //tot->addSlice(CPAP_Leak, COLOR_DarkYellow); TOTLK->AddLayer(totlk); NLL->AddLayer(nll = new SummaryChart(tr("% %1").arg(schema::channel[CPAP_LargeLeak].fullname()), GT_POINTS)); nll->addSlice(CPAP_LargeLeak, schema::channel[CPAP_LargeLeak].defaultColor(), ST_SPH); // <--- The code to the previous marker is crap AHI->setPinned(false); SES->setRecMinY(1); SET->setRecMinY(0); //SET->setRecMaxY(5); */ RebuildGraphs(false); ui->rangeCombo->setCurrentIndex(p_profile->general->lastOverviewRange()); icon_on = new QIcon(":/icons/session-on.png"); icon_off = new QIcon(":/icons/session-off.png"); GraphView->resetLayout(); GraphView->LoadSettings("Overview"); //no trans GraphView->setEmptyImage(QPixmap(":/docs/sheep.png")); connect(GraphView, SIGNAL(updateCurrentTime(double)), this, SLOT(on_LineCursorUpdate(double))); connect(GraphView, SIGNAL(updateRange(double,double)), this, SLOT(on_RangeUpdate(double,double))); connect(GraphView, SIGNAL(GraphsChanged()), this, SLOT(updateGraphCombo())); }
/** * @brief Constructor of UserInterfaceForm. * @param myParent Setting widget which will contain this form as tab. * * Restores all controls from the settings. */ UserInterfaceForm::UserInterfaceForm(SettingsWidget* myParent) : GenericForm(QPixmap(":/img/settings/general.png")) { parent = myParent; bodyUI = new Ui::UserInterfaceSettings; bodyUI->setupUi(this); // block all child signals during initialization const RecursiveSignalBlocker signalBlocker(this); Settings &s = Settings::getInstance(); const QFont chatBaseFont = s.getChatMessageFont(); bodyUI->txtChatFontSize->setValue(QFontInfo(chatBaseFont).pixelSize()); bodyUI->txtChatFont->setCurrentFont(chatBaseFont); int index = static_cast<int>(s.getStylePreference()); bodyUI->textStyleComboBox->setCurrentIndex(index); bool showWindow = s.getShowWindow(); bodyUI->showWindow->setChecked(showWindow); bodyUI->showInFront->setChecked(s.getShowInFront()); bodyUI->showInFront->setEnabled(showWindow); bodyUI->groupAlwaysNotify->setChecked(s.getGroupAlwaysNotify()); bodyUI->cbGroupchatPosition->setChecked(s.getGroupchatPosition()); bodyUI->cbCompactLayout->setChecked(s.getCompactLayout()); bodyUI->cbSeparateWindow->setChecked(s.getSeparateWindow()); bodyUI->cbDontGroupWindows->setChecked(s.getDontGroupWindows()); bodyUI->cbDontGroupWindows->setEnabled(s.getSeparateWindow()); bodyUI->useEmoticons->setChecked(s.getUseEmoticons()); for (auto entry : SmileyPack::listSmileyPacks()) bodyUI->smileyPackBrowser->addItem(entry.first, entry.second); smileLabels = {bodyUI->smile1, bodyUI->smile2, bodyUI->smile3, bodyUI->smile4, bodyUI->smile5}; int currentPack = bodyUI->smileyPackBrowser->findData(s.getSmileyPack()); bodyUI->smileyPackBrowser->setCurrentIndex(currentPack); reloadSmileys(); bodyUI->smileyPackBrowser->setEnabled(bodyUI->useEmoticons->isChecked()); bodyUI->styleBrowser->addItem(tr("None")); bodyUI->styleBrowser->addItems(QStyleFactory::keys()); QString style; if (QStyleFactory::keys().contains(s.getStyle())) style = s.getStyle(); else style = tr("None"); bodyUI->styleBrowser->setCurrentText(style); for (QString color : Style::getThemeColorNames()) bodyUI->themeColorCBox->addItem(color); bodyUI->themeColorCBox->setCurrentIndex(s.getThemeColor()); bodyUI->emoticonSize->setValue(s.getEmojiFontPointSize()); QStringList timestamps; for (QString timestamp : timeFormats) timestamps << QString("%1 - %2").arg(timestamp, QTime::currentTime().toString(timestamp)); bodyUI->timestamp->addItems(timestamps); QLocale ql; QStringList datestamps; dateFormats.append(ql.dateFormat()); dateFormats.append(ql.dateFormat(QLocale::LongFormat)); dateFormats.removeDuplicates(); timeFormats.append(ql.timeFormat()); timeFormats.append(ql.timeFormat(QLocale::LongFormat)); timeFormats.removeDuplicates(); for (QString datestamp : dateFormats) datestamps << QString("%1 - %2").arg(datestamp, QDate::currentDate().toString(datestamp)); bodyUI->dateFormats->addItems(datestamps); bodyUI->timestamp->setCurrentText(QString("%1 - %2").arg(s.getTimestampFormat(), QTime::currentTime().toString(s.getTimestampFormat()))); bodyUI->dateFormats->setCurrentText(QString("%1 - %2").arg(s.getDateFormat(), QDate::currentDate().toString(s.getDateFormat()))); eventsInit(); Translator::registerHandler(std::bind(&UserInterfaceForm::retranslateUi, this), this); }
GeneralForm::GeneralForm(SettingsWidget *myParent) : GenericForm(QPixmap(":/img/settings/general.png")) { parent = myParent; bodyUI = new Ui::GeneralSettings; bodyUI->setupUi(this); bodyUI->checkUpdates->setVisible(AUTOUPDATE_ENABLED); bodyUI->checkUpdates->setChecked(Settings::getInstance().getCheckUpdates()); bodyUI->cbEnableIPv6->setChecked(Settings::getInstance().getEnableIPv6()); for (int i = 0; i < langs.size(); i++) bodyUI->transComboBox->insertItem(i, langs[i]); bodyUI->transComboBox->setCurrentIndex(locales.indexOf(Settings::getInstance().getTranslation())); bodyUI->cbAutorun->setChecked(Settings::getInstance().getAutorun()); #if defined(__APPLE__) && defined(__MACH__) bodyUI->cbAutorun->setEnabled(false); #endif bool showSystemTray = Settings::getInstance().getShowSystemTray(); bodyUI->showSystemTray->setChecked(showSystemTray); bodyUI->startInTray->setChecked(Settings::getInstance().getAutostartInTray()); bodyUI->startInTray->setEnabled(showSystemTray); bodyUI->closeToTray->setChecked(Settings::getInstance().getCloseToTray()); bodyUI->closeToTray->setEnabled(showSystemTray); bodyUI->minimizeToTray->setChecked(Settings::getInstance().getMinimizeToTray()); bodyUI->minimizeToTray->setEnabled(showSystemTray); bodyUI->lightTrayIcon->setChecked(Settings::getInstance().getLightTrayIcon()); bodyUI->lightTrayIcon->setEnabled(showSystemTray); bodyUI->statusChanges->setChecked(Settings::getInstance().getStatusChangeNotificationEnabled()); bodyUI->useEmoticons->setChecked(Settings::getInstance().getUseEmoticons()); bodyUI->autoacceptFiles->setChecked(Settings::getInstance().getAutoSaveEnabled()); bodyUI->autoSaveFilesDir->setText(Settings::getInstance().getGlobalAutoAcceptDir()); bodyUI->showWindow->setChecked(Settings::getInstance().getShowWindow()); bodyUI->showInFront->setChecked(Settings::getInstance().getShowInFront()); bodyUI->notifySound->setChecked(Settings::getInstance().getNotifySound()); bodyUI->groupAlwaysNotify->setChecked(Settings::getInstance().getGroupAlwaysNotify()); bodyUI->cbFauxOfflineMessaging->setChecked(Settings::getInstance().getFauxOfflineMessaging()); bodyUI->cbCompactLayout->setChecked(Settings::getInstance().getCompactLayout()); bodyUI->cbGroupchatPosition->setChecked(Settings::getInstance().getGroupchatPosition()); for (auto entry : SmileyPack::listSmileyPacks()) bodyUI->smileyPackBrowser->addItem(entry.first, entry.second); bodyUI->smileyPackBrowser->setCurrentIndex(bodyUI->smileyPackBrowser->findData(Settings::getInstance().getSmileyPack())); reloadSmiles(); bodyUI->smileyPackBrowser->setEnabled(bodyUI->useEmoticons->isChecked()); bodyUI->styleBrowser->addItem(tr("None")); bodyUI->styleBrowser->addItems(QStyleFactory::keys()); if (QStyleFactory::keys().contains(Settings::getInstance().getStyle())) bodyUI->styleBrowser->setCurrentText(Settings::getInstance().getStyle()); else bodyUI->styleBrowser->setCurrentText(tr("None")); for (QString color : Style::themeColorNames) bodyUI->themeColorCBox->addItem(color); bodyUI->themeColorCBox->setCurrentIndex(Settings::getInstance().getThemeColor()); bodyUI->emoticonSize->setValue(Settings::getInstance().getEmojiFontPointSize()); QStringList timestamps; for (QString timestamp : timeFormats) timestamps << QString("%1 - %2").arg(timestamp, QTime::currentTime().toString(timestamp)); bodyUI->timestamp->addItems(timestamps); QLocale ql; QStringList datestamps; dateFormats.append(ql.dateFormat()); dateFormats.append(ql.dateFormat(QLocale::LongFormat)); dateFormats.removeDuplicates(); timeFormats.append(ql.timeFormat()); timeFormats.append(ql.timeFormat(QLocale::LongFormat)); timeFormats.removeDuplicates(); for (QString datestamp : dateFormats) datestamps << QString("%1 - %2").arg(datestamp, QDate::currentDate().toString(datestamp)); bodyUI->dateFormats->addItems(datestamps); bodyUI->timestamp->setCurrentText(QString("%1 - %2").arg(Settings::getInstance().getTimestampFormat(), QTime::currentTime().toString(Settings::getInstance().getTimestampFormat()))); bodyUI->dateFormats->setCurrentText(QString("%1 - %2").arg(Settings::getInstance().getDateFormat(), QDate::currentDate().toString(Settings::getInstance().getDateFormat()))); bodyUI->autoAwaySpinBox->setValue(Settings::getInstance().getAutoAwayTime()); bodyUI->cbEnableUDP->setChecked(!Settings::getInstance().getForceTCP()); bodyUI->proxyAddr->setText(Settings::getInstance().getProxyAddr()); int port = Settings::getInstance().getProxyPort(); if (port != -1) bodyUI->proxyPort->setValue(port); bodyUI->proxyType->setCurrentIndex(static_cast<int>(Settings::getInstance().getProxyType())); onUseProxyUpdated(); //general connect(bodyUI->checkUpdates, &QCheckBox::stateChanged, this, &GeneralForm::onCheckUpdateChanged); connect(bodyUI->transComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(onTranslationUpdated())); connect(bodyUI->cbAutorun, &QCheckBox::stateChanged, this, &GeneralForm::onAutorunUpdated); connect(bodyUI->showSystemTray, &QCheckBox::stateChanged, this, &GeneralForm::onSetShowSystemTray); connect(bodyUI->startInTray, &QCheckBox::stateChanged, this, &GeneralForm::onSetAutostartInTray); connect(bodyUI->closeToTray, &QCheckBox::stateChanged, this, &GeneralForm::onSetCloseToTray); connect(bodyUI->minimizeToTray, &QCheckBox::stateChanged, this, &GeneralForm::onSetMinimizeToTray); connect(bodyUI->lightTrayIcon, &QCheckBox::stateChanged, this, &GeneralForm::onSetLightTrayIcon); connect(bodyUI->statusChanges, &QCheckBox::stateChanged, this, &GeneralForm::onSetStatusChange); connect(bodyUI->autoAwaySpinBox, SIGNAL(editingFinished()), this, SLOT(onAutoAwayChanged())); connect(bodyUI->showWindow, &QCheckBox::stateChanged, this, &GeneralForm::onShowWindowChanged); connect(bodyUI->showInFront, &QCheckBox::stateChanged, this, &GeneralForm::onSetShowInFront); connect(bodyUI->notifySound, &QCheckBox::stateChanged, this, &GeneralForm::onSetNotifySound); connect(bodyUI->groupAlwaysNotify, &QCheckBox::stateChanged, this, &GeneralForm::onSetGroupAlwaysNotify); connect(bodyUI->autoacceptFiles, &QCheckBox::stateChanged, this, &GeneralForm::onAutoAcceptFileChange); if (bodyUI->autoacceptFiles->isChecked()) connect(bodyUI->autoSaveFilesDir, SIGNAL(clicked()), this, SLOT(onAutoSaveDirChange())); //theme connect(bodyUI->useEmoticons, &QCheckBox::stateChanged, this, &GeneralForm::onUseEmoticonsChange); connect(bodyUI->smileyPackBrowser, SIGNAL(currentIndexChanged(int)), this, SLOT(onSmileyBrowserIndexChanged(int))); connect(bodyUI->styleBrowser, SIGNAL(currentTextChanged(QString)), this, SLOT(onStyleSelected(QString))); connect(bodyUI->themeColorCBox, SIGNAL(currentIndexChanged(int)), this, SLOT(onThemeColorChanged(int))); connect(bodyUI->emoticonSize, SIGNAL(editingFinished()), this, SLOT(onEmoticonSizeChanged())); connect(bodyUI->timestamp, SIGNAL(currentIndexChanged(int)), this, SLOT(onTimestampSelected(int))); connect(bodyUI->dateFormats, SIGNAL(currentIndexChanged(int)), this, SLOT(onDateFormatSelected(int))); //connection connect(bodyUI->cbEnableIPv6, &QCheckBox::stateChanged, this, &GeneralForm::onEnableIPv6Updated); connect(bodyUI->cbEnableUDP, &QCheckBox::stateChanged, this, &GeneralForm::onUDPUpdated); connect(bodyUI->proxyType, SIGNAL(currentIndexChanged(int)), this, SLOT(onUseProxyUpdated())); connect(bodyUI->proxyAddr, &QLineEdit::editingFinished, this, &GeneralForm::onProxyAddrEdited); connect(bodyUI->proxyPort, SIGNAL(valueChanged(int)), this, SLOT(onProxyPortEdited(int))); connect(bodyUI->reconnectButton, &QPushButton::clicked, this, &GeneralForm::onReconnectClicked); connect(bodyUI->cbFauxOfflineMessaging, &QCheckBox::stateChanged, this, &GeneralForm::onFauxOfflineMessaging); connect(bodyUI->cbCompactLayout, &QCheckBox::stateChanged, this, &GeneralForm::onCompactLayout); connect(bodyUI->cbGroupchatPosition, &QCheckBox::stateChanged, this, &GeneralForm::onGroupchatPositionChanged); // prevent stealing mouse whell scroll // scrolling event won't be transmitted to comboboxes or qspinboxes when scrolling // you can scroll through general settings without accidentially chaning theme/skin/icons etc. // @see GeneralForm::eventFilter(QObject *o, QEvent *e) at the bottom of this file for more for (QComboBox* cb : findChildren<QComboBox*>()) { cb->installEventFilter(this); cb->setFocusPolicy(Qt::StrongFocus); } for (QSpinBox* sp : findChildren<QSpinBox*>()) { sp->installEventFilter(this); sp->setFocusPolicy(Qt::WheelFocus); } #ifndef QTOX_PLATFORM_EXT bodyUI->autoAwayLabel->setEnabled(false); // these don't seem to change the appearance of the widgets, bodyUI->autoAwaySpinBox->setEnabled(false); // though they are unusable #endif Translator::registerHandler(std::bind(&GeneralForm::retranslateUi, this), this); }
QString Debug::text() { QMutexLocker ml(&_lock); QString body = i18n("Kst version %1\n\n\nKst log:\n").arg(KSTVERSION); QLocale locale; for (int i = 0; i < _messages.count(); i++ ) { body += i18nc("date leveltext: message", "%1 %2: %3\n", _messages[i].date.toString(locale.dateFormat()), label(_messages[i].level), _messages[i].msg); } body += i18n("\n\nData-source plugins:"); QStringList dsp = dataSourcePlugins(); for (QStringList::ConstIterator it = dsp.begin(); it != dsp.end(); ++it) { body += '\n'; body += *it; } body += "\n\n"; return body; }
PreferencesDialog::PreferencesDialog(QWidget *parent, Profile *_profile) : QDialog(parent), ui(new Ui::PreferencesDialog), profile(_profile) { ui->setupUi(this); channeltype.clear(); channeltype[schema::FLAG] = tr("Flag"); channeltype[schema::MINOR_FLAG] = tr("Minor Flag"); channeltype[schema::SPAN] = tr("Span"); channeltype[schema::UNKNOWN] = tr("Always Minor"); //#ifdef LOCK_RESMED_SESSIONS // QList<Machine *> machines = p_profile->GetMachines(MT_CPAP); // for (QList<Machine *>::iterator it = machines.begin(); it != machines.end(); ++it) { // const QString & mclass=(*it)->loaderName(); // if (mclass == STR_MACH_ResMed) { // ui->combineSlider->setEnabled(false); // ui->IgnoreSlider->setEnabled(false); // ui->timeEdit->setEnabled(false); // break; // } // } //#endif QLocale locale = QLocale::system(); QString shortformat = locale.dateFormat(QLocale::ShortFormat); if (!shortformat.toLower().contains("yyyy")) { shortformat.replace("yy", "yyyy"); } // Qt::DayOfWeek dow = firstDayOfWeekFromLocale(); // QTextCharFormat format = ui->startedUsingMask->calendarWidget()->weekdayTextFormat(Qt::Saturday); // format.setForeground(QBrush(Qt::black, Qt::SolidPattern)); Q_ASSERT(profile != nullptr); ui->tabWidget->setCurrentIndex(0); //i=ui->timeZoneCombo->findText((*profile)["TimeZone"].toString()); //ui->timeZoneCombo->setCurrentIndex(i); ui->showLeakRedline->setChecked(profile->cpap->showLeakRedline()); ui->leakRedlineSpinbox->setValue(profile->cpap->leakRedline()); ui->oxiDesaturationThreshold->setValue(schema::channel[OXI_SPO2].lowerThreshold()); ui->flagPulseAbove->setValue(schema::channel[OXI_Pulse].upperThreshold()); ui->flagPulseBelow->setValue(schema::channel[OXI_Pulse].lowerThreshold()); ui->spo2Drop->setValue(profile->oxi->spO2DropPercentage()); ui->spo2DropTime->setValue(profile->oxi->spO2DropDuration()); ui->pulseChange->setValue(profile->oxi->pulseChangeBPM()); ui->pulseChangeTime->setValue(profile->oxi->pulseChangeDuration()); ui->oxiDiscardThreshold->setValue(profile->oxi->oxiDiscardThreshold()); ui->eventIndexCombo->setCurrentIndex(profile->general->calculateRDI() ? 1 : 0); ui->automaticImport->setChecked(profile->cpap->autoImport()); ui->timeEdit->setTime(profile->session->daySplitTime()); int val = profile->session->combineCloseSessions(); ui->combineSlider->setValue(val); if (val > 0) { ui->combineLCD->display(val); } else { ui->combineLCD->display(STR_TR_Off); } val = profile->session->ignoreShortSessions(); ui->IgnoreSlider->setValue(val); if (val > 0) { ui->IgnoreLCD->display(val); } else { ui->IgnoreLCD->display(STR_TR_Off); } ui->LockSummarySessionSplitting->setChecked(profile->session->lockSummarySessions()); ui->applicationFont->setCurrentFont(QApplication::font()); //ui->applicationFont->setFont(QApplication::font()); ui->applicationFontSize->setValue(QApplication::font().pointSize()); ui->applicationFontBold->setChecked(QApplication::font().weight() == QFont::Bold); ui->applicationFontItalic->setChecked(QApplication::font().italic()); ui->graphFont->setCurrentFont(*defaultfont); //ui->graphFont->setFont(*defaultfont); ui->graphFontSize->setValue(defaultfont->pointSize()); ui->graphFontBold->setChecked(defaultfont->weight() == QFont::Bold); ui->graphFontItalic->setChecked(defaultfont->italic()); ui->titleFont->setCurrentFont(*mediumfont); //ui->titleFont->setFont(*mediumfont); ui->titleFontSize->setValue(mediumfont->pointSize()); ui->titleFontBold->setChecked(mediumfont->weight() == QFont::Bold); ui->titleFontItalic->setChecked(mediumfont->italic()); ui->bigFont->setCurrentFont(*bigfont); //ui->bigFont->setFont(*bigfont); ui->bigFontSize->setValue(bigfont->pointSize()); ui->bigFontBold->setChecked(bigfont->weight() == QFont::Bold); ui->bigFontItalic->setChecked(bigfont->italic()); ui->lineThicknessSlider->setValue(profile->appearance->lineThickness()*2); ui->resyncMachineDetectedEvents->setChecked(profile->cpap->resyncFromUserFlagging()); ui->useAntiAliasing->setChecked(profile->appearance->antiAliasing()); ui->usePixmapCaching->setChecked(profile->appearance->usePixmapCaching()); ui->useSquareWavePlots->setChecked(profile->appearance->squareWavePlots()); ui->enableGraphSnapshots->setChecked(profile->appearance->graphSnapshots()); ui->graphTooltips->setChecked(profile->appearance->graphTooltips()); ui->allowYAxisScaling->setChecked(profile->appearance->allowYAxisScaling()); ui->skipLoginScreen->setChecked(PREF[STR_GEN_SkipLogin].toBool()); ui->allowEarlyUpdates->setChecked(PREF[STR_PREF_AllowEarlyUpdates].toBool()); int s = profile->cpap->clockDrift(); int m = (s / 60) % 60; int h = (s / 3600); s %= 60; ui->clockDriftHours->setValue(h); ui->clockDriftMinutes->setValue(m); ui->clockDriftSeconds->setValue(s); ui->skipEmptyDays->setChecked(profile->general->skipEmptyDays()); ui->showUnknownFlags->setChecked(profile->general->showUnknownFlags()); ui->enableMultithreading->setChecked(profile->session->multithreading()); ui->cacheSessionData->setChecked(profile->session->cacheSessions()); ui->preloadSummaries->setChecked(profile->session->preloadSummaries()); ui->animationsAndTransitionsCheckbox->setChecked(profile->appearance->animations()); ui->complianceCheckBox->setChecked(profile->cpap->showComplianceInfo()); ui->complianceHours->setValue(profile->cpap->complianceHours()); ui->prefCalcMiddle->setCurrentIndex(profile->general->prefCalcMiddle()); ui->prefCalcMax->setCurrentIndex(profile->general->prefCalcMax()); float f = profile->general->prefCalcPercentile(); ui->prefCalcPercentile->setValue(f); ui->tooltipTimeoutSlider->setValue(profile->general->tooltipTimeout() / 50); ui->tooltipMS->display(profile->general->tooltipTimeout()); ui->scrollDampeningSlider->setValue(profile->general->scrollDampening() / 10); if (profile->general->scrollDampening() > 0) { ui->scrollDampDisplay->display(profile->general->scrollDampening()); } else { ui->scrollDampDisplay->display(STR_TR_Off); } bool bcd = profile->session->backupCardData(); ui->createSDBackups->setChecked(bcd); ui->compressSDBackups->setEnabled(bcd); ui->compressSDBackups->setChecked(profile->session->compressBackupData()); ui->compressSessionData->setChecked(profile->session->compressSessionData()); ui->ignoreOlderSessionsCheck->setChecked(profile->session->ignoreOlderSessions()); ui->ignoreOlderSessionsDate->setDate(profile->session->ignoreOlderSessionsDate().date()); ui->graphHeight->setValue(profile->appearance->graphHeight()); ui->automaticallyCheckUpdates->setChecked(PREF[STR_GEN_UpdatesAutoCheck].toBool()); ui->updateCheckEvery->setValue(PREF[STR_GEN_UpdateCheckFrequency].toInt()); if (PREF.contains(STR_GEN_UpdatesLastChecked)) { RefreshLastChecked(); } else { ui->updateLastChecked->setText("Never"); } ui->allowEventRenaming->setChecked(PREF[STR_PREF_AllowEventRenaming].toBool()); ui->overlayFlagsCombo->setCurrentIndex(profile->appearance->overlayType()); ui->overviewLinecharts->setCurrentIndex(profile->appearance->overviewLinechartMode()); ui->ahiGraphWindowSize->setEnabled(false); ui->ahiGraphWindowSize->setValue(profile->cpap->AHIWindow()); ui->ahiGraphZeroReset->setChecked(profile->cpap->AHIReset()); ui->customEventGroupbox->setChecked(profile->cpap->userEventFlagging()); ui->apneaDuration->setValue(profile->cpap->userEventDuration()); ui->apneaFlowRestriction->setValue(profile->cpap->userFlowRestriction()); ui->apneaDuration2->setValue(profile->cpap->userEventDuration2()); ui->apneaFlowRestriction2->setValue(profile->cpap->userFlowRestriction2()); ui->userEventDuplicates->setChecked(profile->cpap->userEventDuplicates()); ui->userEventDuplicates->setVisible(false); ui->showUserFlagsInPie->setChecked(profile->cpap->userEventPieChart()); bool b; ui->calculateUnintentionalLeaks->setChecked(b=profile->cpap->calculateUnintentionalLeaks()); ui->maskLeaks4Slider->setValue(profile->cpap->custom4cmH2OLeaks()*10.0); ui->maskLeaks20Slider->setValue(profile->cpap->custom20cmH2OLeaks()*10.0); ui->maskLeaks4Label->setText(tr("%1 %2").arg(profile->cpap->custom4cmH2OLeaks(), 5, 'f', 1).arg(STR_UNIT_LPM)); ui->maskLeaks20Label->setText(tr("%1 %2").arg(profile->cpap->custom20cmH2OLeaks(), 5, 'f', 1).arg(STR_UNIT_LPM)); /* QLocale locale=QLocale::system(); QString shortformat=locale.dateFormat(QLocale::ShortFormat); if (!shortformat.toLower().contains("yyyy")) { shortformat.replace("yy","yyyy"); }*/ chanFilterModel = new MySortFilterProxyModel(this); chanModel = new QStandardItemModel(this); chanFilterModel->setSourceModel(chanModel); chanFilterModel->setFilterCaseSensitivity(Qt::CaseInsensitive); chanFilterModel->setFilterKeyColumn(0); ui->chanView->setModel(chanFilterModel); InitChanInfo(); waveFilterModel = new MySortFilterProxyModel(this); waveModel = new QStandardItemModel(this); waveFilterModel->setSourceModel(waveModel); waveFilterModel->setFilterCaseSensitivity(Qt::CaseInsensitive); waveFilterModel->setFilterKeyColumn(0); ui->waveView->setModel(waveFilterModel); InitWaveInfo(); ui->waveView->setSortingEnabled(true); ui->chanView->setSortingEnabled(true); ui->waveView->sortByColumn(0, Qt::AscendingOrder); ui->chanView->sortByColumn(0, Qt::AscendingOrder); }
QVariant LocaleModel::data(const QModelIndex &index, int role) const { if (!index.isValid() || role != Qt::DisplayRole && role != Qt::EditRole && role != Qt::ToolTipRole || index.column() >= g_model_cols || index.row() >= g_locale_list_count + 2) return QVariant(); QVariant data; if (index.column() < g_model_cols - 1) data = m_data_list.at(index.column()); if (index.row() == 0) { if (role == Qt::ToolTipRole) return QVariant(); switch (index.column()) { case 0: return data.toDouble(); case 1: return data.toDate(); case 2: return data.toDate(); case 3: return data.toTime(); case 4: return data.toTime(); case 5: return QVariant(); default: break; } } else { QLocale locale; if (index.row() == 1) { locale = QLocale::system(); } else { LocaleListItem item = g_locale_list[index.row() - 2]; locale = QLocale((QLocale::Language)item.language, (QLocale::Country)item.country); } switch (index.column()) { case 0: if (role == Qt::ToolTipRole) return QVariant(); return locale.toString(data.toDouble()); case 1: if (role == Qt::ToolTipRole) return locale.dateFormat(QLocale::LongFormat); return locale.toString(data.toDate(), QLocale::LongFormat); case 2: if (role == Qt::ToolTipRole) return locale.dateFormat(QLocale::ShortFormat); return locale.toString(data.toDate(), QLocale::ShortFormat); case 3: if (role == Qt::ToolTipRole) return locale.timeFormat(QLocale::LongFormat); return locale.toString(data.toTime(), QLocale::LongFormat); case 4: if (role == Qt::ToolTipRole) return locale.timeFormat(QLocale::ShortFormat); return locale.toString(data.toTime(), QLocale::ShortFormat); case 5: if (role == Qt::ToolTipRole) return QVariant(); return locale.name(); default: break; } } return QVariant(); }
void DateFormatsWidget::localeChanged(QLocale locale) { setLocale(locale); QDateTime now = QDateTime::currentDateTime(); shortDateFormat->setText(locale.toString(now.date(), QLocale::ShortFormat)); shortDateFormat->setToolTip(locale.dateFormat(QLocale::ShortFormat)); longDateFormat->setText(locale.toString(now.date(), QLocale::LongFormat)); longDateFormat->setToolTip(locale.dateFormat(QLocale::LongFormat)); shortTimeFormat->setText(locale.toString(now.time(), QLocale::ShortFormat)); shortTimeFormat->setToolTip(locale.timeFormat(QLocale::ShortFormat)); longTimeFormat->setText(locale.toString(now.time(), QLocale::LongFormat)); longTimeFormat->setToolTip(locale.timeFormat(QLocale::LongFormat)); shortDateTimeFormat->setText(locale.toString(now, QLocale::ShortFormat)); shortDateTimeFormat->setToolTip(locale.dateTimeFormat(QLocale::ShortFormat)); longDateTimeFormat->setText(locale.toString(now, QLocale::LongFormat)); longDateTimeFormat->setToolTip(locale.dateTimeFormat(QLocale::LongFormat)); amText->setText(locale.amText()); pmText->setText(locale.pmText()); firstDayOfWeek->setText(toString(locale.firstDayOfWeek())); int mns = monthNamesShort->currentIndex(); int mnl = monthNamesLong->currentIndex(); int smns = standaloneMonthNamesShort->currentIndex(); int smnl = standaloneMonthNamesLong->currentIndex(); int dnl = dayNamesLong->currentIndex(); int dns = dayNamesShort->currentIndex(); int sdnl = standaloneDayNamesLong->currentIndex(); int sdns = standaloneDayNamesShort->currentIndex(); monthNamesShort->clear(); monthNamesLong->clear(); standaloneMonthNamesShort->clear(); standaloneMonthNamesLong->clear(); dayNamesLong->clear(); dayNamesShort->clear(); standaloneDayNamesLong->clear(); standaloneDayNamesShort->clear(); for (int i = 1; i <= 12; ++i) monthNamesShort->addItem(locale.monthName(i, QLocale::ShortFormat)); monthNamesShort->setCurrentIndex(mns >= 0 ? mns : 0); for (int i = 1; i <= 12; ++i) monthNamesLong->addItem(locale.monthName(i, QLocale::LongFormat)); monthNamesLong->setCurrentIndex(mnl >= 0 ? mnl : 0); for (int i = 1; i <= 12; ++i) standaloneMonthNamesShort->addItem(locale.standaloneMonthName(i, QLocale::ShortFormat)); standaloneMonthNamesShort->setCurrentIndex(smns >= 0 ? smns : 0); for (int i = 1; i <= 12; ++i) standaloneMonthNamesLong->addItem(locale.standaloneMonthName(i, QLocale::LongFormat)); standaloneMonthNamesLong->setCurrentIndex(smnl >= 0 ? smnl : 0); for (int i = 1; i <= 7; ++i) dayNamesLong->addItem(locale.dayName(i, QLocale::LongFormat)); dayNamesLong->setCurrentIndex(dnl >= 0 ? dnl : 0); for (int i = 1; i <= 7; ++i) dayNamesShort->addItem(locale.dayName(i, QLocale::ShortFormat)); dayNamesShort->setCurrentIndex(dns >= 0 ? dns : 0); for (int i = 1; i <= 7; ++i) standaloneDayNamesLong->addItem(locale.standaloneDayName(i, QLocale::LongFormat)); standaloneDayNamesLong->setCurrentIndex(sdnl >= 0 ? sdnl : 0); for (int i = 1; i <= 7; ++i) standaloneDayNamesShort->addItem(locale.standaloneDayName(i, QLocale::ShortFormat)); standaloneDayNamesShort->setCurrentIndex(sdns >= 0 ? sdns : 0); }
void sysLocale::sSave() { if (_code->text().trimmed().length() == 0) { QMessageBox::critical( this, tr("Cannot Save Locale"), tr("<p>You must enter a Code for this Locale before " "you may save it.") ); _code->setFocus(); return; } q.prepare( "SELECT locale_id " "FROM locale " "WHERE ( (locale_id<>:locale_id)" " AND (UPPER(locale_code)=UPPER(:locale_code)) );"); q.bindValue(":locale_id", _localeid); q.bindValue(":locale_code", _code->text().trimmed()); q.exec(); if (q.first()) { QMessageBox::critical( this, tr("Cannot Create Locale"), tr( "A Locale with the entered code already exists." "You may not create a Locale with this code." ) ); _code->setFocus(); return; } else if (q.lastError().type() != QSqlError::NoError) { systemError(this, q.lastError().databaseText(), __FILE__, __LINE__); return; } QLocale sampleLocale = generateLocale(); if (_mode == cNew) { q.prepare( "INSERT INTO locale " "( locale_id, locale_code, locale_descrip," " locale_lang_id, locale_country_id, " " locale_dateformat, locale_timeformat, locale_timestampformat," " locale_intervalformat, locale_qtyformat," " locale_curr_scale," " locale_salesprice_scale, locale_purchprice_scale," " locale_extprice_scale, locale_cost_scale," " locale_qty_scale, locale_qtyper_scale," " locale_uomratio_scale, locale_percent_scale, " " locale_comments, " " locale_error_color, locale_warning_color," " locale_emphasis_color, locale_altemphasis_color," " locale_expired_color, locale_future_color) " "VALUES " "( :locale_id, :locale_code, :locale_descrip," " :locale_lang_id, :locale_country_id," " :locale_dateformat, :locale_timeformat, :locale_timestampformat," " :locale_intervalformat, :locale_qtyformat," " :locale_curr_scale," " :locale_salesprice_scale, :locale_purchprice_scale," " :locale_extprice_scale, :locale_cost_scale," " :locale_qty_scale, :locale_qtyper_scale," " :locale_uomratio_scale, :local_percent_scale, " " :locale_comments," " :locale_error_color, :locale_warning_color," " :locale_emphasis_color, :locale_altemphasis_color," " :locale_expired_color, :locale_future_color);" ); } else if ( (_mode == cEdit) || (_mode == cCopy) ) q.prepare( "UPDATE locale " "SET locale_code=:locale_code," " locale_descrip=:locale_descrip," " locale_lang_id=:locale_lang_id," " locale_country_id=:locale_country_id," " locale_dateformat=:locale_dateformat," " locale_timeformat=:locale_timeformat," " locale_timestampformat=:locale_timestampformat," " locale_intervalformat=:locale_intervalformat," " locale_qtyformat=:locale_qtyformat," " locale_curr_scale=:locale_curr_scale," " locale_salesprice_scale=:locale_salesprice_scale," " locale_purchprice_scale=:locale_purchprice_scale," " locale_extprice_scale=:locale_extprice_scale," " locale_cost_scale=:locale_cost_scale," " locale_qty_scale=:locale_qty_scale," " locale_qtyper_scale=:locale_qtyper_scale," " locale_uomratio_scale=:locale_uomratio_scale," " locale_percent_scale=:locale_percent_scale," " locale_comments=:locale_comments," " locale_error_color=:locale_error_color," " locale_warning_color=:locale_warning_color," " locale_emphasis_color=:locale_emphasis_color," " locale_altemphasis_color=:locale_altemphasis_color," " locale_expired_color=:locale_expired_color," " locale_future_color=:locale_future_color " "WHERE (locale_id=:locale_id);" ); q.bindValue(":locale_id", _localeid); q.bindValue(":locale_code", _code->text()); q.bindValue(":locale_descrip", _description->text()); q.bindValue(":locale_lang_id", _language->id()); q.bindValue(":locale_country_id", _country->id()); q.bindValue(":locale_curr_scale", _currencyScale->text()); q.bindValue(":locale_salesprice_scale", _salesPriceScale->text()); q.bindValue(":locale_purchprice_scale", _purchPriceScale->text()); q.bindValue(":locale_extprice_scale", _extPriceScale->text()); q.bindValue(":locale_cost_scale", _costScale->text()); q.bindValue(":locale_qty_scale", _qtyScale->text()); q.bindValue(":locale_qtyper_scale", _qtyPerScale->text()); q.bindValue(":locale_uomratio_scale", _uomRatioScale->text()); q.bindValue(":locale_percent_scale", _percentScale->text()); q.bindValue(":locale_comments", _comments->toPlainText()); q.bindValue(":locale_error_color", _error->text()); q.bindValue(":locale_warning_color", _warning->text()); q.bindValue(":locale_emphasis_color", _emphasis->text()); q.bindValue(":locale_altemphasis_color", _alternate->text()); q.bindValue(":locale_expired_color", _expired->text()); q.bindValue(":locale_future_color", _future->text()); q.bindValue(":locale_dateformat", convert(sampleLocale.dateFormat(QLocale::ShortFormat))); q.bindValue(":locale_timeformat", convert(sampleLocale.timeFormat(QLocale::ShortFormat))); q.bindValue(":locale_timestampformat",convert(sampleLocale.dateFormat(QLocale::ShortFormat)) + " " + convert(sampleLocale.timeFormat(QLocale::ShortFormat))); q.bindValue(":locale_intervalformat", convert(sampleLocale.timeFormat(QLocale::ShortFormat).remove("ap", Qt::CaseInsensitive))); q.bindValue(":locale_qtyformat", QString(sampleLocale.decimalPoint()) + QString(sampleLocale.negativeSign()) + QString(sampleLocale.groupSeparator())); q.exec(); if (q.lastError().type() != QSqlError::NoError) { systemError(this, q.lastError().databaseText(), __FILE__, __LINE__); return; } done(_localeid); }
QString DateRenderer::localeFormat() { QLocale locale; return locale.dateFormat(QLocale::ShortFormat); }