!8 bug fix 136675、128359

Merge pull request !8 from DkAlsace/openkylin/yangtze
This commit is contained in:
DkAlsace 2022-09-01 09:27:08 +00:00 committed by Gitee
commit ad0ba8a19d
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
25 changed files with 454 additions and 172 deletions

View File

@ -75,6 +75,12 @@ About::~About()
{ {
delete ui; delete ui;
} }
void About::showThisWindow()
{
kdk::UkuiStyleHelper::self()->removeHeader(this);
this->show();
}
#define SYSTEM_FONT_EKY "system-font-size" #define SYSTEM_FONT_EKY "system-font-size"
/* /*
* *

View File

@ -46,6 +46,7 @@ class About : public QDialog
public: public:
explicit About(QWidget *parent = nullptr); explicit About(QWidget *parent = nullptr);
~About(); ~About();
void showThisWindow();
protected: protected:
void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE; void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE;

View File

@ -20,6 +20,7 @@
#include <QDebug> #include <QDebug>
#include <QThread> #include <QThread>
#include <QStyleOption> #include <QStyleOption>
#include <QFontMetrics>
#include "theme.h" #include "theme.h"
BaseVerticalScroll::BaseVerticalScroll(int currentValue, int minRange, int maxRange, QWidget *parent) : QWidget(parent), BaseVerticalScroll::BaseVerticalScroll(int currentValue, int minRange, int maxRange, QWidget *parent) : QWidget(parent),
m_currentValue(currentValue), m_currentValue(currentValue),
@ -83,7 +84,7 @@ void BaseVerticalScroll::paintNum(QPainter &painter, int num, int deviation)
{ {
int Width = width() - 1; int Width = width() - 1;
int Height = height() - 1; int Height = height() - 1;
int size = (Height - qAbs(deviation)) / (m_numSize*1.5); //偏移量越大,数字越小 int size = (Height - qAbs(deviation)) / (m_numSize*1.7); //偏移量越大,数字越小
//The larger the offset, the smaller the number //The larger the offset, the smaller the number
int transparency = Utils::handelColorRange(255 - 255 * qAbs(deviation) / Height); int transparency = Utils::handelColorRange(255 - 255 * qAbs(deviation) / Height);
int height = Height / devide; int height = Height / devide;
@ -109,20 +110,28 @@ void BaseVerticalScroll::paintNum(QPainter &painter, int num, int deviation)
Utils::handelColorRange(255-(qAbs(deviation)*2)), Utils::handelColorRange(255-(qAbs(deviation)*2)),
Utils::handelColorRange(255-(qAbs(deviation)*2)),transparency)); Utils::handelColorRange(255-(qAbs(deviation)*2)),transparency));
} }
painter.setRenderHint(QPainter::Antialiasing);
QLinearGradient linearGradient(QPointF(5, 10), QPointF(7, 15)); QLinearGradient linearGradient(QPointF(110, -30), QPointF(110, 114));
linearGradient.setColorAt(0.2, Qt::white); linearGradient.setColorAt(0.5, Qt::white);
linearGradient.setColorAt(0.6, Qt::green); linearGradient.setColorAt(0.8, Qt::gray);
linearGradient.setColorAt(1.0, Qt::black); linearGradient.setColorAt(1.0, Qt::black);
//指定区域外的扩散方式
linearGradient.setSpread(QGradient::ReflectSpread);
if ( y >= 0 && y + height < Height) {
// painter.drawText(QRectF(0, y, Width, height),
// Qt::AlignCenter,
// change_NUM_to_str(num));
QFont font = painter.font();
QFontMetrics fm(font);
QString str = change_NUM_to_str(num);
QRect rect = fm.boundingRect(0, y, Width, height,Qt::AlignCenter,str);
QPainterPath path;
path.addText(rect.x(),rect.y()+ fm.ascent() ,font,str);
painter.fillPath(path, linearGradient);
}
painter.setBrush(QBrush(linearGradient)); painter.setBrush(QBrush(linearGradient));
if ( y >= 0 && y + height < Height) {
painter.drawText(QRectF(0, y, Width, height),
Qt::AlignCenter,
change_NUM_to_str(num));
}
} }
QString BaseVerticalScroll::change_NUM_to_str(int alarmHour) QString BaseVerticalScroll::change_NUM_to_str(int alarmHour)
{ {
QString str; QString str;
@ -201,3 +210,9 @@ void BaseVerticalScroll::mouseMoveEvent(QMouseEvent *e)
repaint(); repaint();
} }
} }
void BaseVerticalScroll::mouseDoubleClickEvent(QMouseEvent *event)
{
emit srcollDoubleClicked();
QWidget::mouseDoubleClickEvent(event);
}

View File

@ -23,6 +23,7 @@
#include "primarymanager.h" #include "primarymanager.h"
#include <QPropertyAnimation> #include <QPropertyAnimation>
#include <QPainter> #include <QPainter>
#include <QLineEdit>
class BaseVerticalScroll : public QWidget class BaseVerticalScroll : public QWidget
{ {
Q_OBJECT Q_OBJECT
@ -55,9 +56,11 @@ public:
signals: signals:
void currentValueChanged(int value); void currentValueChanged(int value);
void deviationChange(int deviation); void deviationChange(int deviation);
void srcollDoubleClicked();
protected: protected:
void wheelEvent(QWheelEvent *) override; void wheelEvent(QWheelEvent *) override;
void mouseMoveEvent(QMouseEvent *) override; void mouseMoveEvent(QMouseEvent *) override;
void mouseDoubleClickEvent(QMouseEvent *event) override;
private: private:

272
clock.cpp
View File

@ -380,12 +380,12 @@ void Clock::settingsStyle()
void Clock::iniWaylandWinId() void Clock::iniWaylandWinId()
{ {
connect(WindowManager::self(),&WindowManager::windowAdded,this,[=](const WindowId& windowId){ connect(WindowManager::self(),&WindowManager::windowAdded,this,[=](const WindowId& windowId){
qDebug()<< "getpid:"<<WindowManager::getPid(windowId);
qDebug()<< "this pid:"<<getpid();
if(getpid() == WindowManager::getPid(windowId)) if(getpid() == WindowManager::getPid(windowId))
{ {
m_pid = windowId.toULongLong(); if(m_first_pid){
m_pid = windowId.toULongLong();
m_first_pid=false;
}
} }
}); });
} }
@ -430,9 +430,9 @@ void Clock::buttonImageInit()
updateCountdownSelectBtnStyle(musicSelectOnCountdownRun,moveWidth,moveHeight); updateCountdownSelectBtnStyle(musicSelectOnCountdownRun,moveWidth,moveHeight);
//闹钟名称 新建闹钟 //闹钟名称 新建闹钟
clockEditOnClockNew = new Btn_new( 0,tr(" name"),Btn_new::LINE_EDIT, ui->editAlarmPage); clockEditOnClockNew = new Btn_new( 0,tr(" name"),Btn_new::LINE_EDIT, ui->editAlarmPage);
updateCountdownSelectBtnStyle(clockEditOnClockNew,moveWidth,180); updateCountdownSelectBtnStyle(clockEditOnClockNew,moveWidth,170);
//重复 新建闹钟 //重复 新建闹钟
int selectHeight = 240; int selectHeight = 230;
int selectGap = 60; int selectGap = 60;
repeatSelectOnClockNew = new Btn_new( 0,tr(" repeat"),Btn_new::SELECT_BTN, ui->addAlarmPage); repeatSelectOnClockNew = new Btn_new( 0,tr(" repeat"),Btn_new::SELECT_BTN, ui->addAlarmPage);
updateClockSelectBtnStyle(repeatSelectOnClockNew,selectHeight); updateClockSelectBtnStyle(repeatSelectOnClockNew,selectHeight);
@ -669,14 +669,14 @@ void Clock::setupInit()
//重复下拉框 //重复下拉框
int moreWidth = 20; int moreWidth = 20;
dialog_repeat = new set_alarm_repeat_Dialog(DIALOG_WIDTH+moreWidth,290,9,ui->editAlarmPage);dialog_repeat->hide(); dialog_repeat = new set_alarm_repeat_Dialog(DIALOG_WIDTH+moreWidth,368,9,ui->editAlarmPage);dialog_repeat->hide();
//铃声下拉框 //铃声下拉框
int bellSize = m_selectBtnUtil->getBellListSize(); int bellSize = m_selectBtnUtil->getBellListSize();
dialog_music = new set_alarm_repeat_Dialog(DIALOG_WIDTH+moreWidth,172,bellSize,ui->editAlarmPage);dialog_music->hide(); dialog_music = new set_alarm_repeat_Dialog(DIALOG_WIDTH+moreWidth,bellSize*36+40,bellSize,ui->editAlarmPage);dialog_music->hide();
//稍后提醒下拉框 //稍后提醒下拉框
dialog_remind_late = new set_alarm_repeat_Dialog(DIALOG_WIDTH+moreWidth,258,6,ui->editAlarmPage);dialog_remind_late->hide(); dialog_remind_late = new set_alarm_repeat_Dialog(DIALOG_WIDTH+moreWidth,258,6,ui->editAlarmPage);dialog_remind_late->hide();
//倒计时铃声选择 //倒计时铃声选择
count_music_sellect = new set_alarm_repeat_Dialog(DIALOG_WIDTH+moreWidth,172,bellSize,ui->countdownPage);count_music_sellect->hide(); count_music_sellect = new set_alarm_repeat_Dialog(DIALOG_WIDTH+moreWidth,bellSize*36+40,bellSize,ui->countdownPage);count_music_sellect->hide();
setMusicSelectDialogListById(bellId,count_music_sellect->listWidget); setMusicSelectDialogListById(bellId,count_music_sellect->listWidget);
//存储重复选择的星期,默认清零 //存储重复选择的星期,默认清零
@ -689,6 +689,22 @@ void Clock::setupInit()
connect(dialog_music->listWidget,SIGNAL(itemClicked(QListWidgetItem*)),this,SLOT(musicListclickslot())); connect(dialog_music->listWidget,SIGNAL(itemClicked(QListWidgetItem*)),this,SLOT(musicListclickslot()));
connect(dialog_remind_late->listWidget,SIGNAL(itemClicked(QListWidgetItem*)),this,SLOT(remindLateListClickSlot())); connect(dialog_remind_late->listWidget,SIGNAL(itemClicked(QListWidgetItem*)),this,SLOT(remindLateListClickSlot()));
connect(count_music_sellect->listWidget,SIGNAL(itemClicked(QListWidgetItem*)),this,SLOT(countMusicListclickslot())); connect(count_music_sellect->listWidget,SIGNAL(itemClicked(QListWidgetItem*)),this,SLOT(countMusicListclickslot()));
connect(dialog_repeat->listWidget,&QListWidget::itemPressed,this,[=](QListWidgetItem *item){
int index = dialog_repeat->listWidget->row(item);
dialog_repeat->setLabelHoverStyle(index);
});
connect(dialog_music->listWidget,&QListWidget::itemPressed,this,[=](QListWidgetItem *item){
int index = dialog_music->listWidget->row(item);
dialog_music->setLabelHoverStyle(index);
});
connect(dialog_remind_late->listWidget,&QListWidget::itemPressed,this,[=](QListWidgetItem *item){
int index = dialog_remind_late->listWidget->row(item);
dialog_remind_late->setLabelHoverStyle(index);
});
connect(count_music_sellect->listWidget,&QListWidget::itemPressed,this,[=](QListWidgetItem *item){
int index = count_music_sellect->listWidget->row(item);
count_music_sellect->setLabelHoverStyle(index);
});
connect(dialog_repeat,&set_alarm_repeat_Dialog::dialogClose,this,[=](){ connect(dialog_repeat,&set_alarm_repeat_Dialog::dialogClose,this,[=](){
repeatSelectOnClockNew->updateIconLabel(0); repeatSelectOnClockNew->updateIconLabel(0);
}); });
@ -1154,6 +1170,10 @@ void Clock::muteAllBell()
if(alarmNoticeDialog->m_musicPlayer->state()!= MMediaPlayer::State::PausedState) if(alarmNoticeDialog->m_musicPlayer->state()!= MMediaPlayer::State::PausedState)
alarmNoticeDialog->m_musicPlayer->pause(); alarmNoticeDialog->m_musicPlayer->pause();
} }
//试听音乐开启静音
if(playController::getInstance().getState() == playController::PlayState::PLAY_STATE){
playController::getInstance().pause();
}
}else{ }else{
model_setup->setData(model_setup->index(0, 0), 0);//静音 Mute model_setup->setData(model_setup->index(0, 0), 0);//静音 Mute
if(countdownNoticeDialog->isVisible() == 1){ if(countdownNoticeDialog->isVisible() == 1){
@ -1162,8 +1182,21 @@ void Clock::muteAllBell()
if(alarmNoticeDialog){ if(alarmNoticeDialog){
ringContinueWhenMute(alarmNoticeDialog); ringContinueWhenMute(alarmNoticeDialog);
} }
} //试听音乐取消静音
model_setup->submitAll(); auto sumtime = playController::getInstance().getPlayer()->duration();
QTime time = QTime::currentTime();
int timeH = time.hour()-musicStartTime.hour();
int timeM = time.minute()-musicStartTime.minute();
int timeS = time.second()-musicStartTime.second();
auto restarttime = (timeH*3600+timeM*60+timeS) * 1000;
if(playController::getInstance().getState() == playController::PlayState::PLAY_STATE){
playController::getInstance().getPlayer()->pause();
}
if(restarttime<sumtime){
playController::getInstance().getPlayer()->setPosition(restarttime);
}
}
model_setup->submitAll();
} }
void Clock::ringContinueWhenMute(Natice_alarm *tempdialog) void Clock::ringContinueWhenMute(Natice_alarm *tempdialog)
@ -1171,7 +1204,7 @@ void Clock::ringContinueWhenMute(Natice_alarm *tempdialog)
auto startpos = tempdialog->timer_value * 1000; auto startpos = tempdialog->timer_value * 1000;
auto starttime = 60000-startpos; auto starttime = 60000-startpos;
auto sumtime = tempdialog->m_musicPlayer->duration(); auto sumtime = tempdialog->m_musicPlayer->duration();
int num; int num = 0;
if(tempdialog == countdownNoticeDialog){ if(tempdialog == countdownNoticeDialog){
num=count_music_sellect->listWidget->currentRow(); num=count_music_sellect->listWidget->currentRow();
}else if(tempdialog == alarmNoticeDialog){ }else if(tempdialog == alarmNoticeDialog){
@ -1461,10 +1494,10 @@ void Clock::menuBtnStyle()
connect(m_aboutAction, &QAction::triggered, this, [=](){ connect(m_aboutAction, &QAction::triggered, this, [=](){
About *dialog = new About(); About *dialog = new About();
QPointF position = this->pos(); QPointF position = this->pos();
// XAtomHelper::setStandardWindowHint(dialog->winId());
kdk::UkuiStyleHelper::self()->removeHeader(dialog); kdk::UkuiStyleHelper::self()->removeHeader(dialog);
dialog->show(); dialog->showThisWindow();
dialog->move(position.x()-15,position.y()+130); QRect aboutRect = QRect(position.x()-15,position.y()+130,dialog->width(),dialog->height());
kdk::WindowManager::setGeometry(dialog->windowHandle(),aboutRect);
dialog->exec(); dialog->exec();
}); });
connect(m_closeAction, SIGNAL(triggered()), this, SLOT(windowClosingClicked())); connect(m_closeAction, SIGNAL(triggered()), this, SLOT(windowClosingClicked()));
@ -1679,14 +1712,15 @@ void Clock::noticeDialogShow(int close_time, int alarm_num, QString id)
QScreen *screen=QGuiApplication::primaryScreen (); QScreen *screen=QGuiApplication::primaryScreen ();
//闹钟弹窗 //闹钟弹窗
alarmNoticeDialog = new Natice_alarm(close_time,alarm_num,nullptr,id); alarmNoticeDialog = new Natice_alarm(close_time,alarm_num,nullptr,id);
alarmNoticeDialog->showThisWindow();
if(countdownNoticeDialog != nullptr) { if(countdownNoticeDialog != nullptr) {
if (countdownNoticeDialog->isVisible() == 0) if (countdownNoticeDialog->isVisible() == 0)
moveUnderMultiScreen(UP_RIGHT,alarmNoticeDialog,1); primaryManager->moveUnderMultiScreen(PrimaryManager::UP_RIGHT,alarmNoticeDialog,1);
else else
moveUnderMultiScreen(UP_RIGHT,alarmNoticeDialog,0); primaryManager->moveUnderMultiScreen(PrimaryManager::UP_RIGHT,alarmNoticeDialog,0);
} }
else else
moveUnderMultiScreen(UP_RIGHT,alarmNoticeDialog,1); primaryManager->moveUnderMultiScreen(PrimaryManager::UP_RIGHT,alarmNoticeDialog,1);
alarmNoticeDialog->screenSaveStyle(); alarmNoticeDialog->screenSaveStyle();
alarmNoticeDialog->playMusic(); alarmNoticeDialog->playMusic();
} }
@ -2481,9 +2515,11 @@ void Clock::countdownMusicSellect()
musicSelectOnCountdownSet->updateIconLabel(1); musicSelectOnCountdownSet->updateIconLabel(1);
musicSelectOnCountdownRun->updateIconLabel(1); musicSelectOnCountdownRun->updateIconLabel(1);
QPointF position = this->pos(); QPointF position = this->pos();
count_music_sellect->move(position.x()+DIALOG_MOVE_WIDTH,position.y()+482); count_music_sellect->move(position.x()+DIALOG_MOVE_WIDTH-10,position.y()+464);
count_music_sellect->setWindowFlags(Qt::Popup); count_music_sellect->setWindowFlags(Qt::Popup);
refreshMusicSelectList(count_music_sellect); refreshMusicSelectList(count_music_sellect);
int num = count_music_sellect->listWidget->currentRow();
count_music_sellect->setLabelHoverStyle(num);
count_music_sellect->show(); count_music_sellect->show();
// connect(count_music_sellect->listWidget,SIGNAL(itemClicked(QListWidgetItem*)),this,SLOT(countMusicListclickslot())); // connect(count_music_sellect->listWidget,SIGNAL(itemClicked(QListWidgetItem*)),this,SLOT(countMusicListclickslot()));
} }
@ -2528,8 +2564,13 @@ void Clock::playMusicFromPath(QString path)
// music->setMedia(QUrl::fromLocalFile(path)); // music->setMedia(QUrl::fromLocalFile(path));
// music->play(); // music->play();
playController::getInstance().playSingleSong(path,0); if(m_muteOn){
playController::getInstance().playSingleSong(path,0);
playController::getInstance().pause();
}else{
playController::getInstance().playSingleSong(path,0);
}
musicStartTime = QTime::currentTime();
} }
void Clock::stopHisPlay() void Clock::stopHisPlay()
@ -2546,18 +2587,21 @@ void Clock::addDivBell(set_alarm_repeat_Dialog *tempDialog, btnType type)
qWarning()<<"dbq-开始复制"<<filePath; qWarning()<<"dbq-开始复制"<<filePath;
//复制文件 //复制文件
QString toPatn = m_selectBtnUtil->copyAudioFile(filePath); QString toPatn = m_selectBtnUtil->copyAudioFile(filePath);
//存储到数据库 if(!toPatn.isEmpty()){
QString bellId = m_selectBtnUtil->saveToBellTable(toPatn); //存储到数据库
QString name = m_selectBtnUtil->getBellNameById(bellId); QString bellId = m_selectBtnUtil->saveToBellTable(toPatn);
QString name = m_selectBtnUtil->getBellNameById(bellId);
if(type==Clock::count_down){ if(type==Clock::count_down){
musicSelectOnCountdownSet->textLabel->setText(name); musicSelectOnCountdownSet->textLabel->setText(name);
musicSelectOnCountdownRun->textLabel->setText(name); musicSelectOnCountdownRun->textLabel->setText(name);
}else{ }else{
musicSelectOnClockNew->textLabel->setText(name); musicSelectOnClockNew->textLabel->setText(name);
}
playMusicFromPath(toPatn);
} }
playMusicFromPath(toPatn);
//刷新窗体 //刷新窗体
// rebuildCountdownMusicDialog(); // rebuildCountdownMusicDialog();
//选中新建的铃声 //选中新建的铃声
@ -2731,14 +2775,15 @@ void Clock::countdownNoticeDialogShow()
countdownNoticeDialog->ui->autoCloseTime->setText(tr("60 Seconds to close")); countdownNoticeDialog->ui->autoCloseTime->setText(tr("60 Seconds to close"));
//左上图标 //左上图标
// countdownNoticeDialog->ui->titleLabel->setText(tr("Alarm")); // countdownNoticeDialog->ui->titleLabel->setText(tr("Alarm"));
countdownNoticeDialog->showThisWindow();
//时间到 //时间到
if (alarmNoticeDialog != nullptr) { if (alarmNoticeDialog != nullptr) {
if (alarmNoticeDialog->isVisible() == 0) if (alarmNoticeDialog->isVisible() == 0)
moveUnderMultiScreen(UP_RIGHT,countdownNoticeDialog,1); primaryManager->moveUnderMultiScreen(PrimaryManager::UP_RIGHT,countdownNoticeDialog,1);
else else
moveUnderMultiScreen(UP_RIGHT,countdownNoticeDialog,0); primaryManager->moveUnderMultiScreen(PrimaryManager::UP_RIGHT,countdownNoticeDialog,0);
} else } else
moveUnderMultiScreen(UP_RIGHT,countdownNoticeDialog,1); primaryManager->moveUnderMultiScreen(PrimaryManager::UP_RIGHT,countdownNoticeDialog,1);
countdownNoticeDialog->screenSaveStyle(); countdownNoticeDialog->screenSaveStyle();
countdownNoticeDialog->playMusic(); countdownNoticeDialog->playMusic();
} }
@ -2815,7 +2860,7 @@ void Clock::startbtnCountdown(){
void Clock::tinyCountdownFinish() void Clock::tinyCountdownFinish()
{ {
tinycountdownDia->hide(); tinycountdownDia->set_dialog_close();
activeWindow(); activeWindow();
startbtnCountdown(); startbtnCountdown();
} }
@ -2947,12 +2992,17 @@ void Clock::onTinyClicked()
//主窗体最小化 //主窗体最小化
// kdk::WindowManager::minimizeWindow(m_pid); // kdk::WindowManager::minimizeWindow(m_pid);
setWindowState(Qt::WindowMinimized); setWindowState(Qt::WindowMinimized);
moveUnderMultiScreen(UP_RIGHT,tinycountdownDia,0); tinycountdownDia->showThisWindow();
primaryManager->moveUnderMultiScreen(PrimaryManager::UP_RIGHT,tinycountdownDia,1);
} }
void Clock::activeWindow() void Clock::activeWindow()
{ {
kdk::WindowManager::activateWindow(m_pid); if(primaryManager->checkWayland()){
kdk::WindowManager::activateWindow(m_pid);
}else{
setWindowState(Qt::WindowActive);
}
} }
void Clock::showThisWindow() void Clock::showThisWindow()
{ {
@ -3083,6 +3133,10 @@ void Clock::countdownSetStartTime()
secondTimeRing = new VerticalScroll_60(ui->countdownSetPage); secondTimeRing = new VerticalScroll_60(ui->countdownSetPage);
QLabel * after_s = new QLabel (ui->countdownSetPage); QLabel * after_s = new QLabel (ui->countdownSetPage);
hourTimerRing->resize(60,228);
minuteTimeRing->resize(60,228);
secondTimeRing->resize(60,228);
h_in_m->resize(50,30); h_in_m->resize(50,30);
h_in_m->setText(tr("hour")); h_in_m->setText(tr("hour"));
@ -3093,8 +3147,8 @@ void Clock::countdownSetStartTime()
after_s->resize(50,30); after_s->resize(50,30);
after_s->setText(tr("sec")); after_s->setText(tr("sec"));
// after_s->setStyleSheet("font: 30pt 'Sans Serif';"); // after_s->setStyleSheet("font: 30pt 'Sans Serif';");
int ringMoveWidth = 73; int ringMoveWidth = 67;
int ringMoveHeight = 45; int ringMoveHeight = 30;
int timeSep = 100; int timeSep = 100;
int labelSep = 55; int labelSep = 55;
int timeLabelMoveHeight = 130; int timeLabelMoveHeight = 130;
@ -3131,6 +3185,34 @@ void Clock::countdownSetStartTime()
connect(timer_count_start, SIGNAL(timeout()), this, SLOT(countStatBtnGray())); connect(timer_count_start, SIGNAL(timeout()), this, SLOT(countStatBtnGray()));
timer_count_start->setInterval(100); timer_count_start->setInterval(100);
timer_count_start->start(); timer_count_start->start();
connect(hourTimerRing,&VerticalScroll_99::BaseVerticalScroll::srcollDoubleClicked,this,[=](){
hourTimerRing->timeEdit_99->show();
});
connect(hourTimerRing->timeEdit_99,&QLineEdit::editingFinished,this,[=](){
int timevalue = hourTimerRing->timeEdit_99->text().toInt();
hourTimerRing->m_currentValue = timevalue;
hourTimerRing->homing();
hourTimerRing->timeEdit_99->hide();
});
connect(minuteTimeRing,&VerticalScroll_99::BaseVerticalScroll::srcollDoubleClicked,this,[=](){
minuteTimeRing->timeEdit_60->show();
});
connect(minuteTimeRing->timeEdit_60,&QLineEdit::editingFinished,this,[=](){
int timevalue = minuteTimeRing->timeEdit_60->text().toInt();
minuteTimeRing->m_currentValue = timevalue;
minuteTimeRing->homing();
minuteTimeRing->timeEdit_60->hide();
});
connect(secondTimeRing,&VerticalScroll_99::BaseVerticalScroll::srcollDoubleClicked,this,[=](){
secondTimeRing->timeEdit_60->show();
});
connect(secondTimeRing->timeEdit_60,&QLineEdit::editingFinished,this,[=](){
int timevalue = secondTimeRing->timeEdit_60->text().toInt();
secondTimeRing->m_currentValue = timevalue;
secondTimeRing->homing();
secondTimeRing->timeEdit_60->hide();
});
} }
/* /*
@ -3245,7 +3327,7 @@ void Clock::updateFront(const int size)
} }
void Clock::updateRepeatStr(QLabel *label){ void Clock::updateRepeatStr(QLabel *label){
if(Utils::checkLocalChina()){ if(Utils::checkLocalChina()){
updateLabelTextByLength(label,16); updateLabelTextByLength(label,15);
} }
if(Utils::checkLocalUs()){ if(Utils::checkLocalUs()){
updateLabelTextByLength(label,25); updateLabelTextByLength(label,25);
@ -3287,8 +3369,8 @@ void Clock::alarmSetStartTime()
//闹钟分钟滚轮 //闹钟分钟滚轮
timer_alarm_start60 = new VerticalScroll_60(ui->editAlarmPage); timer_alarm_start60 = new VerticalScroll_60(ui->editAlarmPage);
timer_alarm_start24->resize(63,220); timer_alarm_start24->resize(63,228);
timer_alarm_start60->resize(63,220); timer_alarm_start60->resize(63,228);
QLabel * hour_ring = new QLabel (ui->editAlarmPage); QLabel * hour_ring = new QLabel (ui->editAlarmPage);
QLabel * min_ring = new QLabel (ui->editAlarmPage); QLabel * min_ring = new QLabel (ui->editAlarmPage);
@ -3310,11 +3392,29 @@ void Clock::alarmSetStartTime()
min_ring->setText(tr("min")); min_ring->setText(tr("min"));
min_ring->setStyleSheet("font: 13pt ;color: rgb(148, 148, 148);"); min_ring->setStyleSheet("font: 13pt ;color: rgb(148, 148, 148);");
int ringMoveHeight = -30; int ringMoveHeight = -30;
timer_alarm_start24->move(124, ringMoveHeight); timer_alarm_start24->move(116, ringMoveHeight);
hour_ring->move(140,7); hour_ring->move(140,7);
h_in_m->move(187,60); h_in_m->move(189,60);
timer_alarm_start60->move(196, ringMoveHeight); timer_alarm_start60->move(206, ringMoveHeight);
min_ring->move(212,7); min_ring->move(212,7);
connect(timer_alarm_start24,&VerticalScroll_24::BaseVerticalScroll::srcollDoubleClicked,this,[=](){
timer_alarm_start24->timeEdit_24->show();
});
connect(timer_alarm_start24->timeEdit_24,&QLineEdit::editingFinished,this,[=](){
int timevalue = timer_alarm_start24->timeEdit_24->text().toInt();
timer_alarm_start24->m_currentValue = timevalue;
timer_alarm_start24->homing();
timer_alarm_start24->timeEdit_24->hide();
});
connect(timer_alarm_start60,&VerticalScroll_99::BaseVerticalScroll::srcollDoubleClicked,this,[=](){
timer_alarm_start60->timeEdit_60->show();
});
connect(timer_alarm_start60->timeEdit_60,&QLineEdit::editingFinished,this,[=](){
int timevalue = timer_alarm_start60->timeEdit_60->text().toInt();
timer_alarm_start60->m_currentValue = timevalue;
timer_alarm_start60->homing();
timer_alarm_start60->timeEdit_60->hide();
});
} }
/* /*
@ -3332,7 +3432,7 @@ void Clock::alarmRepeat()
num= model->rowCount(); num= model->rowCount();
} }
QPointF position = this->pos();//446 QPointF position = this->pos();//446
dialog_repeat->move(position.x()+DIALOG_MOVE_WIDTH,position.y()+420); dialog_repeat->move(position.x()+DIALOG_MOVE_WIDTH-10,position.y()+382);
dialog_repeat->setWindowFlags(Qt::Popup); dialog_repeat->setWindowFlags(Qt::Popup);
dialog_repeat->widget[0]->alarmLabel0->setText(tr("No repetition")); dialog_repeat->widget[0]->alarmLabel0->setText(tr("No repetition"));
dialog_repeat->widget[1]->alarmLabel0->setText(tr("Workingday")); dialog_repeat->widget[1]->alarmLabel0->setText(tr("Workingday"));
@ -3519,23 +3619,24 @@ void Clock::selectAlarmMusic()
{ {
musicSelectOnClockNew->updateIconLabel(1); musicSelectOnClockNew->updateIconLabel(1);
QPointF position = this->pos(); QPointF position = this->pos();
dialog_music->move(position.x()+DIALOG_MOVE_WIDTH,position.y()+482); dialog_music->move(position.x()+DIALOG_MOVE_WIDTH-10,position.y()+442);
dialog_music->setWindowFlags(Qt::Popup); dialog_music->setWindowFlags(Qt::Popup);
refreshMusicSelectList(dialog_music); refreshMusicSelectList(dialog_music);
int num = dialog_music->listWidget->currentRow();
dialog_music->setLabelHoverStyle(num);
dialog_music->show(); dialog_music->show();
} }
void Clock::refreshMusicSelectList(set_alarm_repeat_Dialog *tempDialog) void Clock::refreshMusicSelectList(set_alarm_repeat_Dialog *tempDialog)
{ {
// tempDialog = new
QList<QString> * bellList = m_selectBtnUtil->getAllBellItem(); QList<QString> * bellList = m_selectBtnUtil->getAllBellItem();
int newSize = bellList->size(); int newSize = bellList->size();
int currentSize = tempDialog->rowNum_all; int currentSize = tempDialog->rowNum_all;
if(currentSize<newSize){ if(currentSize<newSize){
for (int i=currentSize;i<newSize;i++) {
tempDialog->set_aItem(i);
}
tempDialog->rowNum_all=newSize; tempDialog->rowNum_all=newSize;
for (int i=currentSize;i<newSize;i++) {
tempDialog->set_aItem(i,1);
}
} }
for (int i=0;i<bellList->size();i++) { for (int i=0;i<bellList->size();i++) {
tempDialog->widget[i]->alarmLabel0->setText(bellList->at(i)); tempDialog->widget[i]->alarmLabel0->setText(bellList->at(i));
@ -3550,7 +3651,7 @@ void Clock::selectRemindLate()
{ {
remindSelectOnClockNew->updateIconLabel(1); remindSelectOnClockNew->updateIconLabel(1);
QPointF position = this->pos(); QPointF position = this->pos();
dialog_remind_late->move(position.x()+DIALOG_MOVE_WIDTH,position.y()+510); dialog_remind_late->move(position.x()+DIALOG_MOVE_WIDTH-10,position.y()+502);
dialog_remind_late->setWindowFlags(Qt::Popup); dialog_remind_late->setWindowFlags(Qt::Popup);
dialog_remind_late->widget[0]->alarmLabel0->setText(tr("none")); dialog_remind_late->widget[0]->alarmLabel0->setText(tr("none"));
dialog_remind_late->widget[1]->alarmLabel0->setText(tr("five mins late")); dialog_remind_late->widget[1]->alarmLabel0->setText(tr("five mins late"));
@ -3558,6 +3659,8 @@ void Clock::selectRemindLate()
dialog_remind_late->widget[3]->alarmLabel0->setText(tr("twenty mins late")); dialog_remind_late->widget[3]->alarmLabel0->setText(tr("twenty mins late"));
dialog_remind_late->widget[4]->alarmLabel0->setText(tr("thirsty mins late")); dialog_remind_late->widget[4]->alarmLabel0->setText(tr("thirsty mins late"));
dialog_remind_late->widget[5]->alarmLabel0->setText(tr("one hour late")); dialog_remind_late->widget[5]->alarmLabel0->setText(tr("one hour late"));
int num = dialog_remind_late->listWidget->currentRow();
dialog_remind_late->setLabelHoverStyle(num);
dialog_remind_late->show(); dialog_remind_late->show();
} }
@ -3731,74 +3834,7 @@ void Clock::showPaint7()
painter.drawPath(painterPath); painter.drawPath(painterPath);
} }
} }
/**
* @brief Natice_alarm移动
* @param spostion SP_LEFT SP_RIGHT SP_CENTER
* @param
*
* @return
*/
void Clock::moveUnderMultiScreen(Clock::ScreenPosition spostion,QWidget * tempDialog,int hiddenFlag)
{
tempDialog->hide();
kdk::UkuiStyleHelper::self()->removeHeader(tempDialog);
tempDialog->show();
QScreen *screen=QGuiApplication::primaryScreen ();
int screen_width = screen->geometry().width();
int screen_height = screen->geometry().height();
int x = primaryManager->getNScreen_x();
int y = primaryManager->getNScreen_y();
qWarning()<<"dbq-screen_width"<<screen_width<<"screen_height"<<screen_height<<"x"<<x<<"y"<<y;
int heightRadio = 20;
int widthRadio = 14;
int moveWidth = 0;
int moveHeight =0;
int diaWidth = tempDialog->width();
int diaHeight = tempDialog->height();
switch (spostion) {
case SP_LEFT:
{
moveWidth = x+round(tempDialog->width()+round(1.0/heightRadio*screen_width));
moveHeight = y+round(screen_height-tempDialog->height()-round(1.0/widthRadio*screen_height));
}break;
case SP_RIGHT:
{
moveWidth = x+round(screen_width-tempDialog->width());
moveHeight = y+round(screen_height-tempDialog->height()-50);
}break;
case SP_CENTER:
{
moveWidth = x+round((screen_width-tempDialog->width())*1.0/2);
moveHeight = y+round((screen_height-tempDialog->height())*1.0/2);
}break;
case UP_LEFT:
{
moveWidth = x+round(tempDialog->width()+round(1.0/heightRadio*screen_width));
moveHeight = y+round(tempDialog->height()+round(1.0/widthRadio*screen_height));
}break;
case UP_RIGHT:
{
moveWidth = x+round(screen_width-tempDialog->width()-round(1.0/heightRadio*screen_width));
moveHeight = y+round(1.0/20*screen_height);
}break;
case UP_CENTER:
{
moveWidth = x+round((screen_width-tempDialog->width())*1.0/2);
moveHeight = y+round((screen_height-tempDialog->height())*1.0/2);
}break;
default:
{}
}
if (hiddenFlag == 1){
kdk::WindowManager::setGeometry(tempDialog->windowHandle(),QRect(moveWidth,moveHeight,diaWidth,diaHeight));
}
else{
kdk::WindowManager::setGeometry(tempDialog->windowHandle(),QRect(moveWidth,moveHeight-tempDialog->height(),diaWidth,diaHeight));
}
}
void Clock::updateTinyBtn() void Clock::updateTinyBtn()

View File

@ -156,7 +156,6 @@ public:
count_down=1, count_down=1,
add_clock=2 add_clock=2
}; };
void moveUnderMultiScreen(Clock::ScreenPosition,QWidget * dialog,int hiddenFlag); //多显示器下,位置移动
QString formatX_h(int x_h); QString formatX_h(int x_h);
Ui::Clock *ui; Ui::Clock *ui;
QString m_timeZone; QString m_timeZone;
@ -531,7 +530,9 @@ private:
void setDefaultTrayIconTooltip(); void setDefaultTrayIconTooltip();
int localeNumBack; int localeNumBack;
quint32 m_pid; quint32 m_pid;
bool m_first_pid = true;
void iniWaylandWinId(); void iniWaylandWinId();
QTime musicStartTime;
}; };
#endif // CLOCK_H #endif // CLOCK_H

View File

@ -1,2 +1,2 @@
[common] [common]
version=3.1.4.0.0k0-0k0.3 version=3.1.4.0.0k0-0k0.4

17
debian/changelog vendored
View File

@ -1,3 +1,20 @@
ukui-clock (3.1.4.0.0k0-0k0.4) v101; urgency=medium
[ BUG 号 ]
* Closes: #
136675 【闹钟】弹出闹钟弹窗后点击"稍后提醒",之后再弹出的弹窗不显示在右上角
128359 【wayland】【闹钟】闹钟时间到弹出的闹铃弹窗不在页面右上方
[ 任务号]
-
[ 需求号]
-
[ 其他改动说明 ]
-
[ 影响域 ]
* 应用本身
-- daiboqi <daiboqi@kylinos.cn> Tue, 30 Aug 2022 19:49:23 +0800
ukui-clock (3.1.4.0.0k0-0k0.3) v101; urgency=medium ukui-clock (3.1.4.0.0k0-0k0.3) v101; urgency=medium
[ BUG 号 ] [ BUG 号 ]

Binary file not shown.

View File

@ -112,8 +112,14 @@ Natice_alarm::Natice_alarm(int close_time, int num, QWidget *parent , QString cl
//初始化使用不锁屏 //初始化使用不锁屏
this->setAttribute(Qt::WA_TranslucentBackground);//设置窗口背景透明 this->setAttribute(Qt::WA_TranslucentBackground);//设置窗口背景透明
installEventFilter(this); installEventFilter(this);
this->setWindowFlags(Qt::FramelessWindowHint|Qt::ToolTip); //设置无边框窗口 // this->setWindowFlags(Qt::FramelessWindowHint|Qt::ToolTip); //设置无边框窗口
this->setAttribute(Qt::WA_AlwaysShowToolTips); // this->setAttribute(Qt::WA_AlwaysShowToolTips);
Qt::WindowFlags m_flags = windowFlags();
this->setWindowFlags(m_flags | Qt::WindowStaysOnTopHint);
// 添加窗管协议
// XAtomHelper::setStandardWindowHint(this->winId());
kdk::UkuiStyleHelper::self()->removeHeader(this);
m_primaryManager = new PrimaryManager();
} }
@ -279,6 +285,7 @@ void Natice_alarm::showThisWindow()
{ {
kdk::UkuiStyleHelper::self()->removeHeader(this); kdk::UkuiStyleHelper::self()->removeHeader(this);
this->show(); this->show();
m_primaryManager->moveUnderMultiScreen(PrimaryManager::UP_RIGHT,this,1);
} }
void Natice_alarm::screenSaveStyle() void Natice_alarm::screenSaveStyle()
{ {
@ -314,13 +321,14 @@ void Natice_alarm::screenSaveStyle()
qDebug()<<"dbq-not lock"; qDebug()<<"dbq-not lock";
} }
}else{ }else{
this->setWindowFlags(Qt::WindowStaysOnTopHint); Qt::WindowFlags m_flags = windowFlags();
this->setWindowFlags(m_flags | Qt::WindowStaysOnTopHint);
// 添加窗管协议 // 添加窗管协议
// XAtomHelper::setStandardWindowHint(this->winId()); // XAtomHelper::setStandardWindowHint(this->winId());
kdk::UkuiStyleHelper::self()->removeHeader(this); kdk::UkuiStyleHelper::self()->removeHeader(this);
} }
update(); update();
this->show(); this->showThisWindow();
} }
} }

View File

@ -33,6 +33,7 @@
#include <QLabel> #include <QLabel>
#include "coreplayer/playcontroller.h" #include "coreplayer/playcontroller.h"
#include <QDBusInterface> #include <QDBusInterface>
#include "primarymanager.h"
namespace Ui { namespace Ui {
class Natice_alarm; class Natice_alarm;
} }
@ -94,6 +95,7 @@ private:
int ring_num; int ring_num;
int timer_value2; int timer_value2;
int full_flag=1; int full_flag=1;
PrimaryManager * m_primaryManager = nullptr;
QSqlTableModel *model_setup; QSqlTableModel *model_setup;
QPoint dragPosition; //拖动坐标 QPoint dragPosition; //拖动坐标
bool mousePressed; //鼠标是否按下 bool mousePressed; //鼠标是否按下

View File

@ -16,8 +16,8 @@
* *
*/ */
#include "primarymanager.h" #include "primarymanager.h"
#include "windowmanager/windowmanager.h"
#include <math.h>
PrimaryManager::PrimaryManager() PrimaryManager::PrimaryManager()
@ -182,6 +182,71 @@ int PrimaryManager::getNScreen_y() const
{ {
return m_nScreen_y; return m_nScreen_y;
} }
/**
* @brief Natice_alarm移动
* @param spostion SP_LEFT SP_RIGHT SP_CENTER
* @param
*
* @return
*/
void PrimaryManager::moveUnderMultiScreen(PrimaryManager::ScreenPosition spostion,QWidget * tempDialog,int hiddenFlag)
{
QScreen *screen=QGuiApplication::primaryScreen ();
int screen_width = screen->geometry().width();
int screen_height = screen->geometry().height();
int x = getNScreen_x();
int y = getNScreen_y();
qWarning()<<"dbq-screen_width"<<screen_width<<"screen_height"<<screen_height<<"x"<<x<<"y"<<y;
int widthRadio = 20;
int heightRadio = 14;
int moveWidth = 0;
int moveHeight =0;
int diaWidth = tempDialog->width();
int diaHeight = tempDialog->height();
switch (spostion) {
case SP_LEFT:
{
moveWidth = x+round(tempDialog->width()+round(1.0/widthRadio*screen_width));
moveHeight = y+round(screen_height-tempDialog->height()-round(1.0/heightRadio*screen_height));
}break;
case SP_RIGHT:
{
moveWidth = x+round(screen_width-tempDialog->width());
moveHeight = y+round(screen_height-tempDialog->height()-50);
}break;
case SP_CENTER:
{
moveWidth = x+round((screen_width-tempDialog->width())*1.0/2);
moveHeight = y+round((screen_height-tempDialog->height())*1.0/2);
}break;
case UP_LEFT:
{
moveWidth = x+round(tempDialog->width()+round(1.0/widthRadio*screen_width));
moveHeight = y+round(tempDialog->height()+round(1.0/heightRadio*screen_height));
}break;
case UP_RIGHT:
{
moveWidth = x+round(screen_width-tempDialog->width()-round(1.0/widthRadio*screen_width));
moveHeight = y+round(1.0/20*screen_height);
}break;
case UP_CENTER:
{
moveWidth = x+round((screen_width-tempDialog->width())*1.0/2);
moveHeight = y+round((screen_height-tempDialog->height())*1.0/2);
}break;
default:
{}
}
QRect finalRect = QRect(moveWidth,moveHeight,diaWidth,diaHeight);
if (hiddenFlag == 0){
finalRect = QRect(moveWidth,moveHeight-tempDialog->height(),diaWidth,diaHeight);
}
qWarning()<<"dbq-finalRect"<<finalRect;
kdk::WindowManager::setGeometry(tempDialog->windowHandle(),finalRect);
}
/** /**
* @brief wayland * @brief wayland
*/ */

View File

@ -50,6 +50,15 @@ public:
int getNScreen_y() const; int getNScreen_y() const;
bool checkWayland(); bool checkWayland();
enum ScreenPosition {
SP_LEFT = 1,
SP_CENTER = 2,
SP_RIGHT=3,
UP_LEFT=4,
UP_CENTER=5,
UP_RIGHT=6
};
void moveUnderMultiScreen(PrimaryManager::ScreenPosition spostion, QWidget *tempDialog, int hiddenFlag);
public slots: public slots:
void priScreenChanged(int x, int y, int width, int height); void priScreenChanged(int x, int y, int width, int height);
private: private:

View File

@ -219,6 +219,9 @@ QString SelectBtnUtil::copyAudioFile(QString from)
QString to = path+fileName; QString to = path+fileName;
bool res = copyFile(from,to); bool res = copyFile(from,to);
qWarning()<<"dbq-复制文件结束"<<res; qWarning()<<"dbq-复制文件结束"<<res;
if(!res){
to = "";
}
return to; return to;
} }

View File

@ -60,7 +60,7 @@ set_alarm_repeat_Dialog::set_alarm_repeat_Dialog(int width, int Length, int rowN
setMask(bmp); setMask(bmp);
for (int i = 0; i < rowNum_all; i++) { for (int i = 0; i < rowNum_all; i++) {
set_aItem(i); set_aItem(i,0);
} }
settingsStyle(); settingsStyle();
@ -114,7 +114,7 @@ void set_alarm_repeat_Dialog::updateLabelFront(QLabel *label, int size)
styleSheet.append("background-color: rgb();}"); styleSheet.append("background-color: rgb();}");
label->setStyleSheet(styleSheet); label->setStyleSheet(styleSheet);
} }
void set_alarm_repeat_Dialog::set_aItem(int rowNum) void set_alarm_repeat_Dialog::set_aItem(int rowNum,int flags)
{ {
aItem[rowNum] =new QListWidgetItem; aItem[rowNum] =new QListWidgetItem;
//将列表项的大小提示设置为大小。如果未设置大小提示则item委托将基于item数据计算大小提示。 //将列表项的大小提示设置为大小。如果未设置大小提示则item委托将基于item数据计算大小提示。
@ -127,6 +127,40 @@ void set_alarm_repeat_Dialog::set_aItem(int rowNum)
listWidget->setItemWidget(aItem[rowNum],widget[rowNum]); listWidget->setItemWidget(aItem[rowNum],widget[rowNum]);
QScroller::grabGesture(listWidget,QScroller::LeftMouseButtonGesture); //设置鼠标左键拖动 QScroller::grabGesture(listWidget,QScroller::LeftMouseButtonGesture); //设置鼠标左键拖动
listWidget -> setVerticalScrollMode(QAbstractItemView::ScrollPerPixel); // 设置像素级滑动 listWidget -> setVerticalScrollMode(QAbstractItemView::ScrollPerPixel); // 设置像素级滑动
if(flags){
Length_num = rowNum_all*36+40;
this->resize(width_num, Length_num);
//增加圆角
QBitmap bmp(this->size());
bmp.fill();
QPainter p(&bmp);
p.setPen(Qt::black);
p.setBrush(Qt::black);
p.setRenderHint(QPainter::Antialiasing);
p.drawRoundedRect(bmp.rect(),10,10);
setMask(bmp);
}
listWidget->setGeometry(QRect(0, 0, width_num-20, Length_num-22));
//消除不使用样式表后直角和圆角重叠影响
listWidget->setFrameShape(QListWidget::NoFrame);
listWidget->move(10,10);
}
void set_alarm_repeat_Dialog::setLabelHoverStyle(int num)
{
for (int i = 0;i<rowNum_all;i++) {
auto item = this->widget[i];
if(i==num){
QPalette ptext;
ptext.setColor(QPalette::Text,Qt::white);
item->alarmLabel0->setPalette(ptext);
}else{
QPalette ptext;
ptext.setColor(QPalette::Text,Qt::black);
item->alarmLabel0->setPalette(ptext);
}
}
} }
void set_alarm_repeat_Dialog::setupUi(QWidget( *set_alarm_repeat_Dialog)) void set_alarm_repeat_Dialog::setupUi(QWidget( *set_alarm_repeat_Dialog))
@ -135,7 +169,9 @@ void set_alarm_repeat_Dialog::setupUi(QWidget( *set_alarm_repeat_Dialog))
set_alarm_repeat_Dialog->setObjectName(QString::fromUtf8("set_alarm_repeat_Dialog")); set_alarm_repeat_Dialog->setObjectName(QString::fromUtf8("set_alarm_repeat_Dialog"));
listWidget = new QListWidget(set_alarm_repeat_Dialog); listWidget = new QListWidget(set_alarm_repeat_Dialog);
listWidget->setObjectName(QString::fromUtf8("listWidget")); listWidget->setObjectName(QString::fromUtf8("listWidget"));
listWidget->setGeometry(QRect(0, 0, width_num-20, Length_num-20)); listWidget->setGeometry(QRect(0, 0, width_num-20, Length_num-22));
//消除不使用样式表后直角和圆角重叠影响
listWidget->setFrameShape(QListWidget::NoFrame);
listWidget->move(10,10); listWidget->move(10,10);
retranslateUi(set_alarm_repeat_Dialog); retranslateUi(set_alarm_repeat_Dialog);
@ -204,21 +240,21 @@ void set_alarm_repeat_Dialog::closeEvent(QCloseEvent *event)
//黑色主题 //黑色主题
void set_alarm_repeat_Dialog::blackStyle() void set_alarm_repeat_Dialog::blackStyle()
{ {
QString itemRadius = QString::number(ITEM_RADIUS); // QString itemRadius = QString::number(ITEM_RADIUS);
listWidget->setStyleSheet("QListWidget{background-color: rgba(0, 0, 0, 0);}\ // listWidget->setStyleSheet("QListWidget{background-color: rgba(0, 0, 0, 0);}\
QListWidget::item::selected{background-color:rgba("+hoverColor+");border-radius:"+itemRadius+"px;border:1px solid rgba(131, 131, 131,0);}\ // QListWidget::item::selected{background-color:rgba("+hoverColor+");border-radius:"+itemRadius+"px;border:1px solid rgba(131, 131, 131,0);}\
QListWidget::item:hover{background-color:rgba("+hoverColor+");border-radius:"+itemRadius+"px;}\ // QListWidget::item:hover{background-color:rgba("+hoverColor+");border-radius:"+itemRadius+"px;}\
"); // ");
} }
//白色主题 //白色主题
void set_alarm_repeat_Dialog::whiteStyle() void set_alarm_repeat_Dialog::whiteStyle()
{ {
QString itemRadius = QString::number(ITEM_RADIUS); // QString itemRadius = QString::number(ITEM_RADIUS);
listWidget->setStyleSheet("QListWidget{background-color: rgba(0, 0, 0, 0);}\ // listWidget->setStyleSheet("QListWidget{background-color: rgba(0, 0, 0, 0);}\
QListWidget::item::selected{background-color:rgba("+hoverColor+");border-radius:"+itemRadius+"px;border:1px solid rgba(131, 131, 131,0);}\ // QListWidget::item::selected{background-color:rgba("+hoverColor+");border-radius:"+itemRadius+"px;border:1px solid rgba(131, 131, 131,0);}\
QListWidget::item:hover{background-color:rgba("+hoverColor+");border-radius:"+itemRadius+"px;}\ // QListWidget::item:hover{background-color:rgba("+hoverColor+");border-radius:"+itemRadius+"px;}\
"); // ");
} }

View File

@ -50,7 +50,8 @@ public:
int rowNum_all ; int rowNum_all ;
int width_num, Length_num; int width_num, Length_num;
QListWidget *listWidget; QListWidget *listWidget;
void set_aItem(int rowNum); void set_aItem(int rowNum,int flags);
void setLabelHoverStyle(int num);
protected: protected:
void closeEvent(QCloseEvent *event) override; void closeEvent(QCloseEvent *event) override;

View File

@ -51,15 +51,20 @@ void tinyCountdown::updateWidgetRadius()
{ {
this->setAttribute(Qt::WA_TranslucentBackground);//设置窗口背景透明 this->setAttribute(Qt::WA_TranslucentBackground);//设置窗口背景透明
#ifdef onTooltip
this->setWindowFlags(Qt::FramelessWindowHint|Qt::ToolTip); //设置无边框窗口 this->setWindowFlags(Qt::FramelessWindowHint|Qt::ToolTip); //设置无边框窗口
this->setAttribute(Qt::WA_AlwaysShowToolTips); this->setAttribute(Qt::WA_AlwaysShowToolTips);
// Qt::WindowFlags m_flags = windowFlags(); #else
// this->setWindowFlags(m_flags | Qt::WindowStaysOnTopHint); Qt::WindowFlags m_flags = windowFlags();
this->setWindowFlags(m_flags | Qt::WindowStaysOnTopHint);
#endif
// 添加窗管协议 // 添加窗管协议
// XAtomHelper::setStandardWindowHint(this->winId()); // XAtomHelper::setStandardWindowHint(this->winId());
kdk::UkuiStyleHelper::self()->removeHeader(this); // kdk::UkuiStyleHelper::self()->removeHeader(this);
//圆角 //圆角
#ifdef onTooltip
QBitmap bmp(this->size()); QBitmap bmp(this->size());
bmp.fill(); bmp.fill();
QPainter p(&bmp); QPainter p(&bmp);
@ -68,6 +73,13 @@ void tinyCountdown::updateWidgetRadius()
p.setBrush(palette().color(QPalette::Base)); p.setBrush(palette().color(QPalette::Base));
p.drawRoundedRect(bmp.rect(),WINDOWN_RADIUS,WINDOWN_RADIUS); p.drawRoundedRect(bmp.rect(),WINDOWN_RADIUS,WINDOWN_RADIUS);
setMask(bmp); setMask(bmp);
#endif
}
void tinyCountdown::showThisWindow()
{
kdk::UkuiStyleHelper::self()->removeHeader(this);
this->show();
} }
tinyCountdown::~tinyCountdown() tinyCountdown::~tinyCountdown()
@ -95,6 +107,7 @@ void tinyCountdown::focusInEvent(QFocusEvent *event)
qDebug()<<"dbq-"<<"focusInEvent"; qDebug()<<"dbq-"<<"focusInEvent";
} }
*/ */
#ifdef onTooltip
// 在鼠标光标在小部件内部时按下鼠标按钮时调用或者当小部件使用grabMouse ()抓住鼠标时调用。按下鼠标而不释放它实际上与调用grabMouse ()相同。 // 在鼠标光标在小部件内部时按下鼠标按钮时调用或者当小部件使用grabMouse ()抓住鼠标时调用。按下鼠标而不释放它实际上与调用grabMouse ()相同。
void tinyCountdown::mousePressEvent(QMouseEvent *event) void tinyCountdown::mousePressEvent(QMouseEvent *event)
{ {
@ -118,26 +131,24 @@ void tinyCountdown::mouseReleaseEvent(QMouseEvent *event)
//每当鼠标移动而按住鼠标按钮时调用。这在拖放操作期间很有用。 //每当鼠标移动而按住鼠标按钮时调用。这在拖放操作期间很有用。
void tinyCountdown::mouseMoveEvent(QMouseEvent *event) void tinyCountdown::mouseMoveEvent(QMouseEvent *event)
{ {
if (this->mousePressed) { if (this->mousePressed) {
move(event->globalPos() - this->dragPosition); move(event->globalPos() - this->dragPosition);
this->setCursor(Qt::ClosedHandCursor); this->setCursor(Qt::ClosedHandCursor);
} }
QWidget::mouseMoveEvent(event); QWidget::mouseMoveEvent(event);
} }
#endif
void tinyCountdown::closeEvent(QCloseEvent *event) void tinyCountdown::closeEvent(QCloseEvent *event)
{ {
event->ignore();//忽视 event->ignore();//忽视
this->hide(); this->set_dialog_close();
} }
void tinyCountdown::paintEvent(QPaintEvent * event) void tinyCountdown::paintEvent(QPaintEvent * event)
{ {
#ifdef onTooltip
Q_UNUSED(event); Q_UNUSED(event);
QPainter p(this); QPainter p(this);
p.setRenderHint(QPainter::Antialiasing); p.setRenderHint(QPainter::Antialiasing);
@ -179,6 +190,15 @@ void tinyCountdown::paintEvent(QPaintEvent * event)
p.setBrush(palette().color(QPalette::Base)); p.setBrush(palette().color(QPalette::Base));
p.drawPath(rectPath); p.drawPath(rectPath);
p.restore(); p.restore();
#else
Q_UNUSED(event);
QPainter p(this);
p.setRenderHint(QPainter::Antialiasing); // 反锯齿;
//绘制器路径
QPainterPath rectPath;
rectPath.addRect(this->rect());
p.fillPath(rectPath,palette().color(QPalette::Base));
#endif
} }
@ -190,7 +210,7 @@ void tinyCountdown::paintEvent(QPaintEvent * event)
void tinyCountdown::clearData() void tinyCountdown::clearData()
{ {
ui->timeLabel->setText("00:00:00"); ui->timeLabel->setText("00:00:00");
this->hide(); this->set_dialog_close();
updateOnRunState(true); updateOnRunState(true);
} }
@ -203,7 +223,7 @@ void tinyCountdown::set_dialog_close()
void tinyCountdown::showMainWindow() void tinyCountdown::showMainWindow()
{ {
this->hide(); this->set_dialog_close();
emit mainWindowClick(); emit mainWindowClick();
} }
@ -211,7 +231,7 @@ void tinyCountdown::showMainWindow()
void tinyCountdown::showTop() void tinyCountdown::showTop()
{ {
this->hide(); this->set_dialog_close();
this->update(); this->update();
this->show(); this->show();
} }

View File

@ -38,16 +38,16 @@ class tinyCountdown;
class tinyCountdown : public QWidget class tinyCountdown : public QWidget
{ {
Q_OBJECT Q_OBJECT
//#define onTooltip
public: public:
explicit tinyCountdown(QWidget *parent = nullptr); explicit tinyCountdown(QWidget *parent = nullptr);
~tinyCountdown(); ~tinyCountdown();
void updateTimeInfo(QString str); void updateTimeInfo(QString str);
#ifdef onTooltip
void mousePressEvent(QMouseEvent *event) override; void mousePressEvent(QMouseEvent *event) override;
void mouseReleaseEvent(QMouseEvent *event) override; void mouseReleaseEvent(QMouseEvent *event) override;
void mouseMoveEvent(QMouseEvent *event) override; void mouseMoveEvent(QMouseEvent *event) override;
#endif
/* /*
void focusOutEvent ( QFocusEvent * event ) override; void focusOutEvent ( QFocusEvent * event ) override;
void focusInEvent ( QFocusEvent * event ) override; void focusInEvent ( QFocusEvent * event ) override;
@ -56,7 +56,7 @@ public:
void closeEvent(QCloseEvent *event) override; void closeEvent(QCloseEvent *event) override;
void paintEvent(QPaintEvent * event) override; void paintEvent(QPaintEvent * event) override;
void updateWidgetRadius(); void updateWidgetRadius();
void showThisWindow();
void clearData(); void clearData();
protected: protected:
//绘制背景 //绘制背景

View File

@ -6,20 +6,20 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>336</width> <width>320</width>
<height>62</height> <height>50</height>
</rect> </rect>
</property> </property>
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>336</width> <width>320</width>
<height>62</height> <height>46</height>
</size> </size>
</property> </property>
<property name="maximumSize"> <property name="maximumSize">
<size> <size>
<width>336</width> <width>320</width>
<height>62</height> <height>50</height>
</size> </size>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">

View File

@ -30,11 +30,13 @@ VerticalScroll_24::VerticalScroll_24(QWidget *parent, Clock *clock) :
homingAni = new QPropertyAnimation(this, "deviation"); homingAni = new QPropertyAnimation(this, "deviation");
homingAni->setDuration(300); homingAni->setDuration(300);
homingAni->setEasingCurve(QEasingCurve::OutQuad); homingAni->setEasingCurve(QEasingCurve::OutQuad);
timeEditStyle_24();
} }
VerticalScroll_24::~VerticalScroll_24() VerticalScroll_24::~VerticalScroll_24()
{ {
delete homingAni; delete homingAni;
delete timeEdit_24;
qDebug()<<"-------VerticalScroll_24---------"; qDebug()<<"-------VerticalScroll_24---------";
//delete ui; //delete ui;
@ -61,6 +63,20 @@ int VerticalScroll_24::readValue()
return m_currentValue; return m_currentValue;
} }
void VerticalScroll_24::timeEditStyle_24()
{
timeEdit_24 = new QLineEdit(this);
timeEdit_24->resize(52,54);
timeEdit_24->move(3,height()/2-15);
QRegExp rx = QRegExp("^(((0|1)[0-9])|20|21|22|23|[0-9]|"")$");
QRegExpValidator* validator = new QRegExpValidator(rx);
timeEdit_24->setValidator(validator);
QFont font;
font.setPixelSize(34);
timeEdit_24->setFont(font);
timeEdit_24->hide();
}
//鼠标按压选择当前值 //鼠标按压选择当前值
// Press the mouse to select the current value // Press the mouse to select the current value
void VerticalScroll_24::mousePressEvent(QMouseEvent *e) void VerticalScroll_24::mousePressEvent(QMouseEvent *e)
@ -87,6 +103,7 @@ void VerticalScroll_24::mouseReleaseEvent(QMouseEvent *)
//绘制当前数值轮画面 //绘制当前数值轮画面
// Draw the current numerical wheel screen // Draw the current numerical wheel screen
void VerticalScroll_24::paintEvent(QPaintEvent *) void VerticalScroll_24::paintEvent(QPaintEvent *)

View File

@ -22,6 +22,7 @@
#include <QPropertyAnimation> #include <QPropertyAnimation>
#include <QPainter> #include <QPainter>
#include <QStyleOption> #include <QStyleOption>
#include <QLineEdit>
#include "baseverticalscroll.h" #include "baseverticalscroll.h"
namespace Ui { namespace Ui {
@ -48,6 +49,8 @@ public:
//获取当前值 //获取当前值
// Get current value // Get current value
int readValue(); int readValue();
QLineEdit *timeEdit_24;
void timeEditStyle_24();
Clock *m_Pclock; Clock *m_Pclock;
protected: protected:

View File

@ -30,11 +30,13 @@ VerticalScroll_60::VerticalScroll_60(QWidget *parent) :
homingAni = new QPropertyAnimation(this, "deviation"); homingAni = new QPropertyAnimation(this, "deviation");
homingAni->setDuration(300); homingAni->setDuration(300);
homingAni->setEasingCurve(QEasingCurve::OutQuad); homingAni->setEasingCurve(QEasingCurve::OutQuad);
timeEditStyle_60();
} }
VerticalScroll_60::~VerticalScroll_60() VerticalScroll_60::~VerticalScroll_60()
{ {
delete homingAni; delete homingAni;
delete timeEdit_60;
qDebug()<<"-------VerticalScroll_60---------"; qDebug()<<"-------VerticalScroll_60---------";
//delete ui; //delete ui;
@ -62,6 +64,20 @@ int VerticalScroll_60::readValue()
return m_currentValue; return m_currentValue;
} }
void VerticalScroll_60::timeEditStyle_60()
{
timeEdit_60 = new QLineEdit(this);
timeEdit_60->resize(52,54);
timeEdit_60->move(3,height()/2-15);
QRegExp rx = QRegExp("^(([0-5][0-9])|[0-9]|"")$");
QRegExpValidator* validator = new QRegExpValidator(rx);
timeEdit_60->setValidator(validator);
QFont font;
font.setPixelSize(34);
timeEdit_60->setFont(font);
timeEdit_60->hide();
}
void VerticalScroll_60::mousePressEvent(QMouseEvent *e) void VerticalScroll_60::mousePressEvent(QMouseEvent *e)
{ {
qDebug()<<"mouse pressed on vertical scroll"; qDebug()<<"mouse pressed on vertical scroll";

View File

@ -50,6 +50,9 @@ public:
// Get current value // Get current value
int readValue(); int readValue();
QLineEdit *timeEdit_60;
void timeEditStyle_60();
void setupUi(QWidget *VerticalScroll_60); void setupUi(QWidget *VerticalScroll_60);
void retranslateUi(QWidget *VerticalScroll_60); void retranslateUi(QWidget *VerticalScroll_60);

View File

@ -33,6 +33,7 @@ VerticalScroll_99::VerticalScroll_99(QWidget *parent) :
timer_21111 = new QTimer(); timer_21111 = new QTimer();
connect(timer_21111, SIGNAL(timeout()), this, SLOT(listClickslot())); connect(timer_21111, SIGNAL(timeout()), this, SLOT(listClickslot()));
timer_21111->setInterval(1000); timer_21111->setInterval(1000);
timeEditStyle_99();
qDebug() << m_currentValue; qDebug() << m_currentValue;
} }
@ -40,6 +41,7 @@ VerticalScroll_99::~VerticalScroll_99()
{ {
delete timer_21111; delete timer_21111;
delete homingAni; delete homingAni;
delete timeEdit_99;
qDebug()<<"-------VerticalScroll_99---------"; qDebug()<<"-------VerticalScroll_99---------";
} }
@ -66,6 +68,20 @@ int VerticalScroll_99::readValue()
return m_currentValue; return m_currentValue;
} }
void VerticalScroll_99::timeEditStyle_99()
{
timeEdit_99 = new QLineEdit(this);
timeEdit_99->resize(52,54);
timeEdit_99->move(3,height()/2-15);
QRegExp rx = QRegExp("^(((0|1)[0-9])|20|21|22|23|[0-9]|"")$");
QRegExpValidator* validator = new QRegExpValidator(rx);
timeEdit_99->setValidator(validator);
QFont font;
font.setPixelSize(34);
timeEdit_99->setFont(font);
timeEdit_99->hide();
}
void VerticalScroll_99::listClickslot() void VerticalScroll_99::listClickslot()
{ {
qDebug() << m_currentValue; qDebug() << m_currentValue;

View File

@ -23,6 +23,7 @@
#include <QPainter> #include <QPainter>
#include <QTimer> #include <QTimer>
#include <QStyleOption> #include <QStyleOption>
#include <QLineEdit>
#include "baseverticalscroll.h" #include "baseverticalscroll.h"
namespace Ui { namespace Ui {
@ -51,6 +52,9 @@ public:
// Get current value // Get current value
int readValue(); int readValue();
QLineEdit *timeEdit_99;
void timeEditStyle_99();
void setupUi(QWidget *VerticalScroll_99); void setupUi(QWidget *VerticalScroll_99);
void retranslateUi(QWidget *VerticalScroll_99); void retranslateUi(QWidget *VerticalScroll_99);