void StatusBarClock::setTimeText(const char *time, bool doUpdate) { if(G_LIKELY(!Settings::LunaSettings()->demoMode)) setTimeText(QString(time)); else setTimeText(QString(DEMO_MODE_TIME)); }
void StatusBarClock::tick() { if(Settings::LunaSettings()->demoMode) return; time_t rawTime; struct tm* timeinfo = 0; ::time(&rawTime); timeinfo = ::localtime(&rawTime); // get current local time (or date) if(!m_displayDate) { // If local time matches we don't need to update anything if (timeinfo->tm_hour == m_lastUpdateTime.hour && timeinfo->tm_min == m_lastUpdateTime.min) { return; } m_lastUpdateTime.hour = timeinfo->tm_hour; m_lastUpdateTime.min = timeinfo->tm_min; if (m_twelveHour) { ::strftime(m_timeBuf, kMaxTimeChars, LOCALIZED("%I:%M").c_str(), timeinfo); if (m_timeBuf[0] == '0') { m_curTimeStr = m_timeBuf + 1; } else { m_curTimeStr = m_timeBuf; } } else { ::strftime(m_timeBuf, kMaxTimeChars, LOCALIZED("%H:%M").c_str(), timeinfo); m_curTimeStr = m_timeBuf; } setTimeText(m_curTimeStr); } else{ // If local time matches we don't need to update anything if (timeinfo->tm_year == m_lastUpdateTime.year && timeinfo->tm_mon == m_lastUpdateTime.month && timeinfo->tm_mday == m_lastUpdateTime.day) { return; } m_lastUpdateTime.year = timeinfo->tm_year; m_lastUpdateTime.month = timeinfo->tm_mon; m_lastUpdateTime.day = timeinfo->tm_mday; setTimeText(QDate::currentDate().toString(Qt::DefaultLocaleShortDate)); } update(); }
StatusBarClock::StatusBarClock(unsigned int padding) : m_clockTimer(new QTimer(this)) , m_font(0) , m_twelveHour(true) , m_displayDate(false) , m_curTimeStr(0) , m_textPadding(padding) { connect(m_clockTimer, SIGNAL(timeout()), this, SLOT(tick())); m_clockTimer->start(1000); StatusBarServicesConnector* svcConnector = StatusBarServicesConnector::instance(); if(svcConnector) { connect(svcConnector,SIGNAL(signalSystemTimeChanged()), this, SLOT(slotSystemTimeChanged())); } // Set up text const char* fontName = Settings::LunaSettings()->fontStatusBar.c_str(); m_font = new QFont(fontName, 15); m_font->setPixelSize(15); if (m_font) { m_font->setBold(true); } ::memset(m_timeBuf, 0, sizeof(m_timeBuf)); ::memset(&m_lastUpdateTime, 0, sizeof(m_lastUpdateTime)); setDisplayDate(false); // this will set the correct bounding rect and update the time if(Settings::LunaSettings()->demoMode) setTimeText(QString(DEMO_MODE_TIME)); }
void LXQtWorldClock::wheelScrolled(int delta) { if (mTimeZones.count() > 1) { mActiveTimeZone = mTimeZones[(mTimeZones.indexOf(mActiveTimeZone) + ((delta > 0) ? -1 : 1) + mTimeZones.size()) % mTimeZones.size()]; setTimeText(); } }
void StatusBarItemClock::paintEvent(QPaintEvent *pe) { QPainter painter(this); painter.setPen(Qt::white); setTimeText(); painter.drawText(rect(), Qt::AlignCenter, time_text_); }
void LXQtWorldClock::restartTimer() { mTimer->stop(); mTimer->setInterval(mUpdateInterval); int delay = static_cast<int>((mUpdateInterval - (static_cast<long long>(QTime::currentTime().msecsSinceStartOfDay()) % mUpdateInterval)) % mUpdateInterval); QTimer::singleShot(delay, Qt::PreciseTimer, [this] { setTimeText(); }); QTimer::singleShot(delay, Qt::PreciseTimer, mTimer, SLOT(start())); }
DateWidget::DateWidget(QWidget *parent) : QWidget(parent) { p = new DateWidgetPrivate; p->dateVisible = true; p->timeVisible = true; p->year_spin = new QSpinBox(); p->month_spin = new QSpinBox(); p->day_spin = new QSpinBox(); p->hour_spin = new QSpinBox(); p->minute_spin = new QSpinBox(); p->date_label = new QLabel(); p->time_label = new QLabel(); p->date_items_layout = new QHBoxLayout(); p->date_items_layout->addWidget(p->year_spin); p->date_items_layout->addWidget(p->month_spin); p->date_items_layout->addWidget(p->day_spin); p->date_items_layout->setContentsMargins(0,0,0,0); p->date_items_layout->setSpacing(1); p->time_items_layout = new QHBoxLayout(); p->time_items_layout->addWidget(p->hour_spin); p->time_items_layout->addWidget(p->minute_spin); p->time_items_layout->setContentsMargins(0,0,0,0); p->time_items_layout->setSpacing(1); p->date_layout = new QVBoxLayout(); p->date_layout->addWidget(p->date_label); p->date_layout->addLayout(p->date_items_layout); p->date_layout->setContentsMargins(0,0,0,0); p->date_layout->setSpacing(1); p->time_layout = new QVBoxLayout(); p->time_layout->addWidget(p->time_label); p->time_layout->addLayout(p->time_items_layout); p->time_layout->setContentsMargins(0,0,0,0); p->time_layout->setSpacing(1); p->main_layout = new QHBoxLayout(this); p->main_layout->addLayout(p->date_layout); p->main_layout->addLayout(p->time_layout); p->main_layout->setContentsMargins(0,0,0,0); p->main_layout->setSpacing(15); setDateTime( QDateTime::currentDateTime() ); connect( p->year_spin , SIGNAL(valueChanged(int)), SLOT(refresh_days()) ); connect( p->month_spin, SIGNAL(valueChanged(int)), SLOT(refresh_days()) ); setDateText( tr("Date") ); setTimeText( tr("Time") ); }
void StatusBarClock::setDisplayDate(bool date) { m_displayDate = date; m_clockTimer->stop(); // Calculate the max width if(!m_displayDate) { setTimeText("00:00", false); m_clockTimer->start (1000); } else { setTimeText("00/00/00", false); m_clockTimer->start (60000); } prepareGeometryChange(); m_bounds = QRect(-m_textRect.width()/2 - m_textPadding, -m_textRect.height()/2, m_textRect.width() + m_textPadding * 2, m_textRect.height()); Q_EMIT signalBoundingRectChanged(); ::memset(&m_lastUpdateTime, 0, sizeof(m_lastUpdateTime)); tick(); }
void StatusBarItemClock::mouseReleaseEvent(QMouseEvent *me) { me->accept(); bool update = setTimeText(); if (update) { onyx::screen::instance().enableUpdate(false); repaint(); onyx::screen::instance().updateWidget(this, onyx::screen::ScreenProxy::GU); onyx::screen::instance().enableUpdate(true); } emit clicked(); }
StatusBarItemClock::StatusBarItemClock(QWidget *parent) : StatusBarItem(CLOCK, parent) , start_(QDateTime::currentDateTime()) { QFont font; font.setPointSize(20); if(ui::isHD() && sys::isIRTouch()) { font.setPointSize(28); } font.setBold(true); setFont(font); metrics_.reset(new QFontMetrics(font)); setTimeText(); createLayout(); }
void squeezeLiteGui::setupInterfaceConnections(void) { DEBUGF("Initialize Interface Connections"); QQuickItem *v = rootObject(); // interface signals to application connect(v,SIGNAL(play(int)), this,SLOT(playState(int))); connect(v,SIGNAL(nextTrack()), this,SLOT(nextTrackClicked())); connect(v,SIGNAL(prevTrack()), this,SLOT(prevTrackClicked())); connect(v,SIGNAL(volUp()), this,SLOT(volUp())); connect(v,SIGNAL(volDown()), this,SLOT(volDown())); connect(v,SIGNAL(setVolume(int)), this,SLOT(setVolume(int))); connect(v,SIGNAL(controlClicked(QString)), this,SLOT(controlViewClicked(QString))); connect(v,SIGNAL(shuffle(int)), this,SLOT(shuffleState(int))); connect(v,SIGNAL(repeat(int)), this,SLOT(repeatState(int))); // connect(v,SIGNAL(playButtonClicked()),this,SLOT(playPauseToggle())); // application signals to interface connect(this,SIGNAL(playlistIndexChange(QVariant)), v, SLOT(setControlViewListIndex(QVariant))); connect(this,SIGNAL(updateAlbumCover(QVariant)), v,SLOT(updateAlbumCover(QVariant))); connect(this,SIGNAL(playStatus(QVariant)), v, SLOT(updatePlayMode(QVariant))); connect(this,SIGNAL(VolumeChange(QVariant)), v,SLOT(setMainVolume(QVariant))); connect(this,SIGNAL(songDuration(QVariant)), v,SLOT(setSongDuration(QVariant))); connect(this,SIGNAL(progress(QVariant)), v,SLOT(updateProgress(QVariant))); connect(m_playerInfo,SIGNAL(PlayingTime(QVariant,QVariant)), v,SLOT(setupSongTimes(QVariant,QVariant))); connect(m_playerInfo,SIGNAL(TimeText(QVariant)),v,SLOT(setTimeText(QVariant))); connect(m_playerInfo,SIGNAL(NewSong()),this,SLOT(NewSong())); connect(&m_tick,SIGNAL(timeout()),m_playerInfo,SLOT(tick())); m_tick.start(1000); /* * messages from device that need to be connected to slots void playlistIndexChange(QVariant newidx); void NewSong(int newPlayListIndex); void NewPlaylist(void); void Mute(bool); void VolumeChange(int); void ModeChange(QString); */ }
GameScreen::GameScreen(QWidget *parent) : QMainWindow(parent), ui(new Ui::GameScreen) { ui->setupUi(this); tmp = new QMainWindow(this); paddleIcon = new QPixmap("C:/Users/TAYLOR/Documents/C++ Files/BrickBreak/paddle.png"); ballIcon = new QPixmap("C:/Users/TAYLOR/Documents/C++ Files/BrickBreak/white_ball.png"); gameOverIcon = new QPixmap("C:/Users/TAYLOR/Documents/C++ Files/BrickBreak/gameover.png"); gameOverlay = new QPixmap("C:/Users/TAYLOR/Documents/C++ Files/BrickBreak/background.jpg"); gameWonIcon = new QPixmap("C:/Users/TAYLOR/Documents/C++ Files/BrickBreak/youwin.jpg"); overlayLbl = new QLabel(this); overlayLbl->setPixmap(*gameOverlay); overlayLbl->setGeometry(0, ui->menuBar->height(), this->width() - (this->width() - ui->rightLine->pos().x()), this->height() - (this->height() - ui->bottomLine->pos().y())); connect(this, SIGNAL(eventTriggered(QString)), this, SLOT(writeEvent(QString))); connect(this, SIGNAL(gameEnded()), this, SLOT(gameOver())); diff = EASY; level = 1; newLevel(level); createActions(); createMenus(); createPaddle(); createBall(); numLives = 3; time = new Timer(this, "time"); connect(time, SIGNAL(timeout()), this, SLOT(decrementTimer())); cheatModeActive = false; spacePressed = false; score = 0; createBlocks(); eventLogFullSizePos = new QPoint(310, 10); eventLogHalfSizePos = new QPoint(310, 200); hideCheatMode(); setLivesText(numLives); setTimeText(timeLeft); setLevelText(level); setScoreText(score); }
void GameScreen::newLevel(int newLevel) { timeLeft = 300; blocksPerRow = 1; // level 1 block-per-row count will be 2 rowCount = 3; if (newLevel == 1 && diff == EASY) diff = EASY; else if (newLevel == 2 && diff != HARD) diff = MEDIUM; else if (newLevel == 3) diff = HARD; if (diff == EASY) { ballSpeed = 10; paddleSpeed = 10; } else if (diff == MEDIUM) { ballSpeed = 7; paddleSpeed = 7; } else if (diff == HARD) { ballSpeed = 5; paddleSpeed = 5; } for (int i = 0; i < newLevel; i++) { blocksPerRow++; rowCount++; } setTimeText(timeLeft); setLevelText(newLevel); restartLevel(newLevel); spacePressed = false; }
void MyType::updateTimerText() { const QTime t = QTime::currentTime(); setTimeText(t.toString(QLatin1String("HH:mm:ss"))); }
void LXQtWorldClock::timeout() { if (QDateTime{}.time().msec() > 500) restartTimer(); setTimeText(); }
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(); }