forked from openkylin/quarkai
beautify propertiesdialog and mydialog
This commit is contained in:
parent
1f2a5b8428
commit
ea8dd62555
|
@ -204,34 +204,34 @@ class Daemon(PolicyKitService):
|
||||||
|
|
||||||
@dbus.service.method(INTERFACE, in_signature='s', out_signature='')
|
@dbus.service.method(INTERFACE, in_signature='s', out_signature='')
|
||||||
def adjust_cpufreq_scaling_governer(self, value):
|
def adjust_cpufreq_scaling_governer(self, value):
|
||||||
cpufreq_file = "/etc/init.d/cpufrequtils"
|
# cpufreq_file = "/etc/init.d/cpufrequtils"
|
||||||
oldvalue = ''
|
# oldvalue = ''
|
||||||
if os.path.exists(cpufreq_file):
|
# if os.path.exists(cpufreq_file):
|
||||||
fp = open(cpufreq_file, "rw+")
|
# fp = open(cpufreq_file, "rw+")
|
||||||
line = fp.readline()
|
# line = fp.readline()
|
||||||
while line:
|
# while line:
|
||||||
if line.startswith("GOVERNOR="):
|
# if line.startswith("GOVERNOR="):
|
||||||
if value not in line:
|
# if value not in line:
|
||||||
oldvalue = line.split("=")[1].replace('"', '').replace('\n', '')
|
# oldvalue = line.split("=")[1].replace('"', '').replace('\n', '')
|
||||||
break
|
# break
|
||||||
line = fp.readline()
|
# line = fp.readline()
|
||||||
fp.close()
|
# fp.close()
|
||||||
if oldvalue not in ['', None] and value not in ['', None]:
|
# if oldvalue not in ['', None] and value not in ['', None]:
|
||||||
cmd = "sed -i 's/%s/%s/g' %s" % (oldvalue, value, cpufreq_file)
|
# cmd = "sed -i 's/%s/%s/g' %s" % (oldvalue, value, cpufreq_file)
|
||||||
os.system(cmd)
|
# os.system(cmd)
|
||||||
os.system('service cpufrequtils restart')
|
# os.system('service cpufrequtils restart')
|
||||||
else:
|
# else:
|
||||||
fpath = os.path.expanduser("/sys/devices/system/cpu/")
|
fpath = os.path.expanduser("/sys/devices/system/cpu/")
|
||||||
for line in os.listdir(fpath):
|
for line in os.listdir(fpath):
|
||||||
line = line.strip('\n')
|
line = line.strip('\n')
|
||||||
#pattern = re.compile(r'cpu.*[0-9]$')
|
#pattern = re.compile(r'cpu.*[0-9]$')
|
||||||
pattern = re.compile(r'cpu.*\d\Z')
|
pattern = re.compile(r'cpu.*\d\Z')
|
||||||
m = pattern.match(line)
|
m = pattern.match(line)
|
||||||
if m:
|
if m:
|
||||||
filepath = "/sys/devices/system/cpu/%s/cpufreq/scaling_governor" % line
|
filepath = "/sys/devices/system/cpu/%s/cpufreq/scaling_governor" % line
|
||||||
if os.path.exists(filepath):
|
if os.path.exists(filepath):
|
||||||
cmd = 'echo %s > %s' % (value, filepath)
|
cmd = 'echo %s > %s' % (value, filepath)
|
||||||
os.system(cmd)
|
os.system(cmd)
|
||||||
|
|
||||||
@dbus.service.method(INTERFACE, in_signature='', out_signature='as')
|
@dbus.service.method(INTERFACE, in_signature='', out_signature='as')
|
||||||
def get_cpufreq_scaling_governer_list(self):
|
def get_cpufreq_scaling_governer_list(self):
|
||||||
|
|
|
@ -25,6 +25,12 @@
|
||||||
#include <QImageReader>
|
#include <QImageReader>
|
||||||
#include <QGraphicsDropShadowEffect>
|
#include <QGraphicsDropShadowEffect>
|
||||||
|
|
||||||
|
#include <QtMath>
|
||||||
|
qreal gradientDistance(qreal x)
|
||||||
|
{
|
||||||
|
return (1 - qCos(M_PI * x)) / 2;
|
||||||
|
}
|
||||||
|
|
||||||
CpuBallWidget::CpuBallWidget(QWidget *parent) : QWidget(parent)
|
CpuBallWidget::CpuBallWidget(QWidget *parent) : QWidget(parent)
|
||||||
{
|
{
|
||||||
this->setFixedSize(210, 210);
|
this->setFixedSize(210, 210);
|
||||||
|
@ -34,6 +40,7 @@ CpuBallWidget::CpuBallWidget(QWidget *parent) : QWidget(parent)
|
||||||
|
|
||||||
m_xFrontOffset = 0;
|
m_xFrontOffset = 0;
|
||||||
m_xBackOffset = this->width();
|
m_xBackOffset = this->width();
|
||||||
|
m_prevPercentValue = 0.0;
|
||||||
m_percentValue = 0.0;
|
m_percentValue = 0.0;
|
||||||
m_progressText = QString("%1%").arg(QString::number(m_percentValue, 'f', 1));
|
m_progressText = QString("%1%").arg(QString::number(m_percentValue, 'f', 1));
|
||||||
|
|
||||||
|
@ -47,7 +54,10 @@ CpuBallWidget::CpuBallWidget(QWidget *parent) : QWidget(parent)
|
||||||
|
|
||||||
m_waveTimer = new QTimer(this);
|
m_waveTimer = new QTimer(this);
|
||||||
connect(m_waveTimer, SIGNAL(timeout()), this, SLOT(onRepaintWaveImage()));
|
connect(m_waveTimer, SIGNAL(timeout()), this, SLOT(onRepaintWaveImage()));
|
||||||
m_waveTimer->setInterval(60);
|
m_waveTimer->setInterval(200);
|
||||||
|
|
||||||
|
m_animationIndex = 0;
|
||||||
|
m_animationCounts = 2000/200;//2000为数据更新的时间间隔,200为波浪更新的时间间隔
|
||||||
}
|
}
|
||||||
|
|
||||||
CpuBallWidget::~CpuBallWidget()
|
CpuBallWidget::~CpuBallWidget()
|
||||||
|
@ -110,7 +120,14 @@ void CpuBallWidget::onRepaintWaveImage()
|
||||||
if (m_xBackOffset > m_backImage.width()) {//保留整个显示直径的大小不做处理,避免出现断层
|
if (m_xBackOffset > m_backImage.width()) {//保留整个显示直径的大小不做处理,避免出现断层
|
||||||
m_xBackOffset = 0;
|
m_xBackOffset = 0;
|
||||||
}
|
}
|
||||||
this->update();//this->repaint();
|
|
||||||
|
if (m_animationIndex < m_animationCounts) {
|
||||||
|
m_animationIndex++;
|
||||||
|
repaint();
|
||||||
|
} else {
|
||||||
|
m_waveTimer->stop();
|
||||||
|
}
|
||||||
|
// this->update();//this->repaint();
|
||||||
}
|
}
|
||||||
|
|
||||||
//value:0 ~ 100
|
//value:0 ~ 100
|
||||||
|
@ -119,21 +136,24 @@ void CpuBallWidget::updateCpuPercent(double value)
|
||||||
if (this->m_percentValue == value || value > 100 || value < 0) {
|
if (this->m_percentValue == value || value > 100 || value < 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
m_prevPercentValue = m_percentValue;
|
||||||
m_percentValue = value;
|
m_percentValue = value;
|
||||||
m_progressText = QString("%1%").arg(QString::number(value, 'f', 1));
|
m_progressText = QString("%1%").arg(QString::number(value, 'f', 1));
|
||||||
|
|
||||||
|
m_animationIndex = 0;
|
||||||
|
m_waveTimer->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CpuBallWidget::startTimer()
|
void CpuBallWidget::startTimer()
|
||||||
{
|
{
|
||||||
if (this->m_waveTimer && !this->m_waveTimer->isActive())
|
// if (this->m_waveTimer && !this->m_waveTimer->isActive())
|
||||||
this->m_waveTimer->start();
|
// this->m_waveTimer->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CpuBallWidget::stopTimer()
|
void CpuBallWidget::stopTimer()
|
||||||
{
|
{
|
||||||
if (this->m_waveTimer && this->m_waveTimer->isActive())
|
// if (this->m_waveTimer && this->m_waveTimer->isActive())
|
||||||
this->m_waveTimer->stop();
|
// this->m_waveTimer->stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
//在不同的平台上得到一样的效果,但绘制的文字除外
|
//在不同的平台上得到一样的效果,但绘制的文字除外
|
||||||
|
@ -145,7 +165,9 @@ void CpuBallWidget::paintEvent(QPaintEvent *)
|
||||||
QRectF rect = QRectF(0, 0, this->width(), this->height());
|
QRectF rect = QRectF(0, 0, this->width(), this->height());
|
||||||
QSize waveSize = this->size();
|
QSize waveSize = this->size();
|
||||||
|
|
||||||
int currentPercent = static_cast<int>(m_percentValue);
|
// int currentPercent = static_cast<int>(m_percentValue);
|
||||||
|
double percent = m_prevPercentValue + gradientDistance(m_animationIndex / m_animationCounts) * (m_percentValue - m_prevPercentValue);
|
||||||
|
int currentPercent = static_cast<int>(percent);
|
||||||
|
|
||||||
//Step1:整个矩形背景
|
//Step1:整个矩形背景
|
||||||
QImage waveRectImage = QImage(waveSize, QImage::Format_ARGB32_Premultiplied);//创建一个Format_ARGB32_Premultiplied 格式的QIamge,大小和控件相同
|
QImage waveRectImage = QImage(waveSize, QImage::Format_ARGB32_Premultiplied);//创建一个Format_ARGB32_Premultiplied 格式的QIamge,大小和控件相同
|
||||||
|
|
|
@ -56,9 +56,13 @@ private:
|
||||||
|
|
||||||
QString m_progressText;
|
QString m_progressText;
|
||||||
|
|
||||||
|
double m_prevPercentValue;
|
||||||
double m_percentValue;
|
double m_percentValue;
|
||||||
double m_xFrontOffset;
|
double m_xFrontOffset;
|
||||||
double m_xBackOffset;
|
double m_xBackOffset;
|
||||||
|
|
||||||
|
double m_animationCounts;
|
||||||
|
int m_animationIndex;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CPUBALLWIDGET_H
|
#endif // CPUBALLWIDGET_H
|
||||||
|
|
|
@ -308,6 +308,8 @@ void CpuRateWidget::initWidgets()
|
||||||
cpuIdleTimeLayout->addWidget(m_cpuIdleTimeTitle);
|
cpuIdleTimeLayout->addWidget(m_cpuIdleTimeTitle);
|
||||||
cpuIdleTimeLayout->addWidget(m_cpuIdleTimeText);
|
cpuIdleTimeLayout->addWidget(m_cpuIdleTimeText);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
m_labelLayout->setContentsMargins(0, 0, 0, 0);
|
m_labelLayout->setContentsMargins(0, 0, 0, 0);
|
||||||
m_labelLayout->setSpacing(10);
|
m_labelLayout->setSpacing(10);
|
||||||
m_labelLayout->addWidget(m_title);
|
m_labelLayout->addWidget(m_title);
|
||||||
|
|
|
@ -156,26 +156,29 @@ void FileSystemListItem::drawForeground(QRect rect, QPainter *painter, int colum
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (column == 6) {
|
else if (column == 6) {
|
||||||
if (!m_data->usedCapactiy().isEmpty()) {
|
|
||||||
int maxWidth = 60;
|
|
||||||
QFont font = painter->font();
|
|
||||||
QFontMetrics fm(font);
|
|
||||||
QString uCapacity = fm.elidedText(m_data->usedCapactiy(), Qt::ElideRight, maxWidth);
|
|
||||||
painter->drawText(QRect(rect.x(), rect.y(), maxWidth - textPadding, rect.height()), Qt::AlignLeft | Qt::AlignVCenter, uCapacity);
|
|
||||||
}
|
|
||||||
int leftPadding = 10;
|
int leftPadding = 10;
|
||||||
int topPadding = 5;
|
int topPadding = 5;
|
||||||
int pWidth = rect.width() - 60 - 2 * leftPadding - textPadding;
|
int progressWidth = 100;
|
||||||
int pHeight = rect.height() - 2 * topPadding;
|
int progressHeight = rect.height() - 2 * topPadding;
|
||||||
|
int textMaxWidth = rect.width() - progressWidth - 2 * leftPadding;
|
||||||
|
if (!m_data->usedCapactiy().isEmpty()) {
|
||||||
|
QFont font = painter->font();
|
||||||
|
QFontMetrics fm(font);
|
||||||
|
QString uCapacity = fm.elidedText(m_data->usedCapactiy(), Qt::ElideRight, textMaxWidth - textPadding);
|
||||||
|
painter->drawText(QRect(rect.x() + textPadding, rect.y(), textMaxWidth - textPadding, rect.height()), Qt::AlignLeft | Qt::AlignVCenter, uCapacity);
|
||||||
|
}
|
||||||
QPainterPath bgPath;
|
QPainterPath bgPath;
|
||||||
bgPath.addRect(QRectF(rect.x() + 60, rect.y() + topPadding, pWidth, pHeight));
|
bgPath.addRect(QRectF(rect.x() + textMaxWidth + leftPadding, rect.y() + topPadding, progressWidth, progressHeight));
|
||||||
painter->fillPath(bgPath, QColor("#eeeeee"));
|
painter->fillPath(bgPath, QColor("#eeeeee"));
|
||||||
QPainterPath fillPath;
|
QPainterPath fillPath;
|
||||||
fillPath.addRect(QRectF(rect.x() + 60, rect.y() + topPadding, pWidth - m_data->usedPercentage(), pHeight));
|
fillPath.addRect(QRectF(rect.x() + textMaxWidth + leftPadding, rect.y() + topPadding, m_data->usedPercentage(), progressHeight));
|
||||||
painter->setOpacity(0.5);
|
painter->setOpacity(0.5);
|
||||||
painter->fillPath(fillPath, QColor("#0288d1"));
|
if (m_data->usedPercentage() < 75)
|
||||||
|
painter->fillPath(fillPath, QColor("#0288d1"));
|
||||||
|
else
|
||||||
|
painter->fillPath(fillPath, QColor("#f8b551"));
|
||||||
painter->setOpacity(1);
|
painter->setOpacity(1);
|
||||||
painter->drawText(QRect(rect.x() + 60, rect.y() + topPadding, pWidth, pHeight), Qt::AlignHCenter | Qt::AlignVCenter, QString::number(m_data->usedPercentage()).append("%"));
|
painter->drawText(QRect(rect.x() + textMaxWidth + leftPadding, rect.y() + topPadding, progressWidth, progressHeight), Qt::AlignHCenter | Qt::AlignVCenter, QString::number(m_data->usedPercentage()).append("%"));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
QStyleOptionProgressBar progressBarStyle;//progressBarStyle.initFrom(this);
|
QStyleOptionProgressBar progressBarStyle;//progressBarStyle.initFrom(this);
|
||||||
|
|
|
@ -136,7 +136,7 @@ bool MonitorTitleWidget::eventFilter(QObject *obj, QEvent *event)
|
||||||
|
|
||||||
void MonitorTitleWidget::setSearchEditFocus()
|
void MonitorTitleWidget::setSearchEditFocus()
|
||||||
{
|
{
|
||||||
if (m_searchEdit->text() != "") {
|
if (m_searchEdit->searchedText() != "") {
|
||||||
m_searchEdit->getLineEdit()->setFocus();
|
m_searchEdit->getLineEdit()->setFocus();
|
||||||
} else {
|
} else {
|
||||||
m_searchEdit->setFocus();
|
m_searchEdit->setFocus();
|
||||||
|
@ -145,14 +145,14 @@ void MonitorTitleWidget::setSearchEditFocus()
|
||||||
|
|
||||||
void MonitorTitleWidget::onRefreshSearchResult()
|
void MonitorTitleWidget::onRefreshSearchResult()
|
||||||
{
|
{
|
||||||
if (m_searchEdit->text() == searchTextCache) {
|
if (m_searchEdit->searchedText() == searchTextCache) {
|
||||||
emit this->searchSignal(searchTextCache);
|
emit this->searchSignal(searchTextCache);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MonitorTitleWidget::handleSearchTextChanged()
|
void MonitorTitleWidget::handleSearchTextChanged()
|
||||||
{
|
{
|
||||||
searchTextCache = m_searchEdit->text();
|
searchTextCache = m_searchEdit->searchedText();
|
||||||
|
|
||||||
this->m_cancelSearchBtn->setVisible(!searchTextCache.isEmpty());
|
this->m_cancelSearchBtn->setVisible(!searchTextCache.isEmpty());
|
||||||
|
|
||||||
|
@ -165,7 +165,7 @@ void MonitorTitleWidget::handleSearchTextChanged()
|
||||||
void MonitorTitleWidget::onCancelSearchBtnClicked(bool b)
|
void MonitorTitleWidget::onCancelSearchBtnClicked(bool b)
|
||||||
{
|
{
|
||||||
this->m_cancelSearchBtn->setVisible(false);
|
this->m_cancelSearchBtn->setVisible(false);
|
||||||
m_searchEdit->clearEdit();
|
m_searchEdit->clearAndFocusEdit();
|
||||||
emit canelSearchEditFocus();
|
emit canelSearchEditFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -116,7 +116,7 @@ void NetworkIndicator::updateBgColor()
|
||||||
this->m_bgColor = QColor("#f6fcfe");
|
this->m_bgColor = QColor("#f6fcfe");
|
||||||
break;
|
break;
|
||||||
case Checked:
|
case Checked:
|
||||||
this->m_outsideBorderColor = QColor("#0973b4");
|
this->m_outsideBorderColor = QColor("#009944");
|
||||||
this->m_bgColor = QColor("#e9f8fd");
|
this->m_bgColor = QColor("#e9f8fd");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -243,15 +243,14 @@ void NetworkIndicator::paintEvent(QPaintEvent *event)
|
||||||
path.addRect(QRectF(1, 1, width()-2, height()-2));
|
path.addRect(QRectF(1, 1, width()-2, height()-2));
|
||||||
painter.fillPath(path, this->m_bgColor);
|
painter.fillPath(path, this->m_bgColor);
|
||||||
|
|
||||||
|
|
||||||
painter.translate((rect().width() - m_pointsCount * m_pointSpace) / 2 + 2, 40);//将坐标第原点移动到该点
|
painter.translate((rect().width() - m_pointsCount * m_pointSpace) / 2 + 2, 40);//将坐标第原点移动到该点
|
||||||
painter.scale(1, -1);//将横坐标扩大1倍,将纵坐标缩小1倍
|
painter.scale(1, -1);//将横坐标扩大1倍,将纵坐标缩小1倍
|
||||||
//使用QPainterPath画贝塞尔曲线
|
//使用QPainterPath画贝塞尔曲线
|
||||||
painter.setPen(QPen(QColor("#1E90FF"), 1));
|
painter.setPen(QPen(QColor("#009944"), 1));
|
||||||
painter.setBrush(QBrush());
|
painter.setBrush(QBrush());
|
||||||
painter.drawPath(m_downloadPath);//绘制前面创建的path:m_downloadPath
|
painter.drawPath(m_downloadPath);//绘制前面创建的path:m_downloadPath
|
||||||
painter.translate(0, -8);//将点(0,-8)设为原点
|
painter.translate(0, -8);//将点(0,-8)设为原点
|
||||||
painter.setPen(QPen(QColor("#FF0000"), 1));
|
painter.setPen(QPen(QColor("#e60012"), 1));
|
||||||
painter.setBrush(QBrush());
|
painter.setBrush(QBrush());
|
||||||
painter.drawPath(m_uploadPath);
|
painter.drawPath(m_uploadPath);
|
||||||
|
|
||||||
|
|
|
@ -622,7 +622,7 @@ void ProcessDialog::refreshProcessList()
|
||||||
----------------------------------------------------------*/
|
----------------------------------------------------------*/
|
||||||
|
|
||||||
std::string desktopFile;
|
std::string desktopFile;
|
||||||
desktopFile = getDesktopFileFromName(pid, name, "");
|
desktopFile = getDesktopFileAccordProcName(name, "");
|
||||||
// qDebug() << "****************"<< QString::fromStdString(desktopFile);
|
// qDebug() << "****************"<< QString::fromStdString(desktopFile);
|
||||||
|
|
||||||
QPixmap icon_pixmap;
|
QPixmap icon_pixmap;
|
||||||
|
@ -632,14 +632,14 @@ void ProcessDialog::refreshProcessList()
|
||||||
icon_pixmap = defaultPixmap;
|
icon_pixmap = defaultPixmap;
|
||||||
icon_pixmap.setDevicePixelRatio(qApp->devicePixelRatio());
|
icon_pixmap.setDevicePixelRatio(qApp->devicePixelRatio());
|
||||||
} else {
|
} else {
|
||||||
icon_pixmap = getDesktopFileIcon(desktopFile, 24);
|
icon_pixmap = getAppIconFromDesktopFile(desktopFile, 24);
|
||||||
if (icon_pixmap.isNull()) {
|
if (icon_pixmap.isNull()) {
|
||||||
icon_pixmap = defaultPixmap;
|
icon_pixmap = defaultPixmap;
|
||||||
icon_pixmap.setDevicePixelRatio(qApp->devicePixelRatio());
|
icon_pixmap.setDevicePixelRatio(qApp->devicePixelRatio());
|
||||||
}
|
}
|
||||||
//QPixmap pixmap = QPixmap::fromImage(img).scaled(iconSize, iconSize, Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
//QPixmap pixmap = QPixmap::fromImage(img).scaled(iconSize, iconSize, Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
||||||
}
|
}
|
||||||
QString title = getDisplayNameFromName(name, desktopFile);
|
QString title = getDisplayNameAccordProcName(name, desktopFile);
|
||||||
QString displayName;
|
QString displayName;
|
||||||
if (whose_processes == "all") {
|
if (whose_processes == "all") {
|
||||||
displayName = QString("[%1] %2").arg(username).arg(title);
|
displayName = QString("[%1] %2").arg(username).arg(title);
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
|
#include <QPushButton>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QMouseEvent>
|
#include <QMouseEvent>
|
||||||
|
@ -33,23 +34,35 @@
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include <QIcon>
|
#include <QIcon>
|
||||||
|
|
||||||
|
const int spacing = 8;
|
||||||
|
|
||||||
PropertiesDialog::PropertiesDialog(QWidget *parent, pid_t processId) : QDialog(parent)
|
PropertiesDialog::PropertiesDialog(QWidget *parent, pid_t processId) : QDialog(parent)
|
||||||
, mousePressed(false)
|
, mousePressed(false)
|
||||||
{
|
{
|
||||||
this->setWindowFlags(this->windowFlags() | Qt::FramelessWindowHint | Qt::WindowCloseButtonHint);
|
this->setWindowFlags(this->windowFlags() | Qt::FramelessWindowHint | Qt::WindowCloseButtonHint| Qt::WindowStaysOnTopHint);
|
||||||
|
|
||||||
this->setAttribute(Qt::WA_TranslucentBackground);
|
this->setAttribute(Qt::WA_TranslucentBackground);
|
||||||
this->setAttribute(Qt::WA_Resized, false);
|
this->setAttribute(Qt::WA_Resized, false);
|
||||||
|
// this->setMaximumSize(480, 600);
|
||||||
|
// this->setMinimumWidth(320);
|
||||||
|
|
||||||
this->setMaximumSize(480, 600);
|
this->setFixedWidth(380);
|
||||||
this->setMinimumWidth(320);
|
|
||||||
|
|
||||||
pid = processId;
|
pid = processId;
|
||||||
|
|
||||||
layout = new QVBoxLayout(this);
|
m_layout = new QVBoxLayout(this);
|
||||||
layout->setContentsMargins(0, 0, 0, 0);
|
m_layout->setContentsMargins(0, 0, 0, 5);
|
||||||
|
m_topLayout = new QHBoxLayout;
|
||||||
|
m_topLeftLayout = new QHBoxLayout;
|
||||||
|
m_topLeftLayout->setContentsMargins(20, 20, 0, 0);
|
||||||
|
m_topLeftLayout->setSpacing(10);
|
||||||
|
m_topRightLayout = new QHBoxLayout;
|
||||||
|
m_topRightLayout->setMargin(0);
|
||||||
|
m_topRightLayout->setSpacing(5);
|
||||||
|
m_topLayout->addLayout(m_topLeftLayout);
|
||||||
|
m_topLayout->addStretch();
|
||||||
|
m_topLayout->addLayout(m_topRightLayout);
|
||||||
|
|
||||||
userLayout = new QHBoxLayout();
|
/*userLayout = new QHBoxLayout();
|
||||||
userLayout->setContentsMargins(0, 0, 0, 0);
|
userLayout->setContentsMargins(0, 0, 0, 0);
|
||||||
nameLayout = new QHBoxLayout();
|
nameLayout = new QHBoxLayout();
|
||||||
nameLayout->setContentsMargins(0, 0, 0, 0);
|
nameLayout->setContentsMargins(0, 0, 0, 0);
|
||||||
|
@ -58,7 +71,13 @@ PropertiesDialog::PropertiesDialog(QWidget *parent, pid_t processId) : QDialog(p
|
||||||
cpuDurationLayout = new QHBoxLayout();
|
cpuDurationLayout = new QHBoxLayout();
|
||||||
cpuDurationLayout->setContentsMargins(0, 0, 0, 0);
|
cpuDurationLayout->setContentsMargins(0, 0, 0, 0);
|
||||||
startTimeLayout = new QHBoxLayout();
|
startTimeLayout = new QHBoxLayout();
|
||||||
startTimeLayout->setContentsMargins(0, 0, 0, 0);
|
startTimeLayout->setContentsMargins(0, 0, 0, 0);*/
|
||||||
|
|
||||||
|
m_logoLabel = new QLabel();
|
||||||
|
m_logoLabel->setStyleSheet("QLabel{background:transparent;border:none;}");
|
||||||
|
m_logoLabel->setFixedSize(44, 58);
|
||||||
|
m_logoLabel->setContentsMargins(0, 0, 0, 0);
|
||||||
|
m_logoLabel->setPixmap(QPixmap(":/res/sub_logo.png"));
|
||||||
|
|
||||||
closeButton = new MyTristateButton();
|
closeButton = new MyTristateButton();
|
||||||
closeButton->setObjectName("CloseButton");
|
closeButton->setObjectName("CloseButton");
|
||||||
|
@ -66,13 +85,89 @@ PropertiesDialog::PropertiesDialog(QWidget *parent, pid_t processId) : QDialog(p
|
||||||
this->close();
|
this->close();
|
||||||
});
|
});
|
||||||
|
|
||||||
iconLabel = new QLabel();
|
m_iconLabel = new QLabel();
|
||||||
iconLabel->setFixedSize(96, 96);
|
m_iconLabel->setStyleSheet("QLabel{background:transparent;border:none;}");
|
||||||
|
m_iconLabel->setFixedSize(48, 48);
|
||||||
|
m_iconLabel->setContentsMargins(0, 0, 0, 0);
|
||||||
|
|
||||||
titleLabel = new QLabel();
|
m_titleLabel = new QLabel();
|
||||||
titleLabel->setStyleSheet("QLabel { background-color : transparent; font-size: 14px; font-weight: 500; color : #303030; }");
|
m_titleLabel->setStyleSheet("QLabel{background-color:transparent;font-size:18px;color:#000000;}");
|
||||||
|
m_titleLabel->setFixedWidth(230);
|
||||||
|
m_titleLabel->setWordWrap(true);
|
||||||
|
|
||||||
userTitleLabel = new QLabel(QString("%1:").arg(tr("User name")));
|
m_topLeftLayout->addWidget(m_iconLabel, 0, Qt::AlignLeft | Qt::AlignVCenter);
|
||||||
|
m_topLeftLayout->addWidget(m_titleLabel, 0, Qt::AlignLeft | Qt::AlignVCenter);
|
||||||
|
|
||||||
|
m_topRightLayout->addWidget(m_logoLabel, 0, Qt::AlignTop | Qt::AlignRight);
|
||||||
|
m_topRightLayout->addWidget(closeButton, 0, Qt::AlignTop | Qt::AlignRight);
|
||||||
|
|
||||||
|
QLabel *topSplit = new QLabel();
|
||||||
|
topSplit->setStyleSheet("QLabel{background: qlineargradient(x1:0, y1:0, x2:0, y2:1,stop:0 #f1f1f1, stop:1 #e0e0e0);}");
|
||||||
|
// topSplit->setStyleSheet("QLabel{background: qlineargradient(x1:0, y1:0, x2:1, y2:0,stop:0 #f1f1f1, stop:1 #e0e0e0);}");
|
||||||
|
topSplit->setFixedSize(320, 1);
|
||||||
|
|
||||||
|
QLabel *bottomSplit = new QLabel();
|
||||||
|
bottomSplit->setStyleSheet("QLabel{background: qlineargradient(x1:0, y1:0, x2:0, y2:1,stop:0 #f1f1f1, stop:1 #e0e0e0);}");
|
||||||
|
// bottomSplit->setStyleSheet("QLabel{background: qlineargradient(x1:0, y1:0, x2:1, y2:0,stop:0 #f1f1f1, stop:1 #e0e0e0);}");
|
||||||
|
bottomSplit->setFixedSize(320, 1);
|
||||||
|
|
||||||
|
m_infoFrame = new QFrame;
|
||||||
|
m_infoFrame->setMaximumWidth(320);
|
||||||
|
m_infoFrame->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||||
|
|
||||||
|
m_bottomLayout = new QHBoxLayout;
|
||||||
|
m_bottomLayout->setContentsMargins(0,0,20,0);
|
||||||
|
m_bottomLayout->setSpacing(0);
|
||||||
|
m_okBtn = new QPushButton;
|
||||||
|
m_okBtn->setFixedSize(91, 25);
|
||||||
|
m_okBtn->setObjectName("blackButton");
|
||||||
|
m_okBtn->setFocusPolicy(Qt::NoFocus);
|
||||||
|
m_okBtn->setText(tr("OK"));
|
||||||
|
connect(m_okBtn, &QPushButton::clicked, this, [=] {
|
||||||
|
this->close();
|
||||||
|
});
|
||||||
|
m_bottomLayout->addWidget(m_okBtn, 0, Qt::AlignBottom | Qt::AlignRight);
|
||||||
|
|
||||||
|
m_layout->addLayout(m_topLayout);
|
||||||
|
m_layout->addSpacing(10);
|
||||||
|
m_layout->addWidget(topSplit, 0, Qt::AlignCenter);
|
||||||
|
m_layout->addSpacing(10);
|
||||||
|
m_layout->addWidget(m_infoFrame, 0, Qt::AlignCenter);
|
||||||
|
m_layout->addSpacing(5);
|
||||||
|
m_layout->addWidget(bottomSplit, 0, Qt::AlignCenter);
|
||||||
|
m_layout->addSpacing(5);
|
||||||
|
m_layout->addLayout(m_bottomLayout);
|
||||||
|
m_layout->addSpacing(10);
|
||||||
|
m_layout->addStretch();
|
||||||
|
|
||||||
|
QGridLayout *infoGrid = new QGridLayout(m_infoFrame);
|
||||||
|
infoGrid->setMargin(0);
|
||||||
|
infoGrid->setHorizontalSpacing(spacing);
|
||||||
|
infoGrid->setVerticalSpacing(spacing);
|
||||||
|
infoGrid->setColumnStretch(0, 10);
|
||||||
|
infoGrid->setColumnStretch(1, 100);
|
||||||
|
|
||||||
|
QStringList titleList;
|
||||||
|
titleList << QObject::tr("User name:") << QObject::tr("Process name:") << QObject::tr("Command line:") << QObject::tr("CPU Time:") << QObject::tr("Started Time:");
|
||||||
|
for (int i = 0; i < titleList.length(); ++i) {
|
||||||
|
QLabel *titleLabel = new QLabel(titleList.value(i));
|
||||||
|
titleLabel->setStyleSheet("QLabel{background-color:transparent;font-size:12px;color:#999999;}");
|
||||||
|
titleLabel->setMinimumHeight(20);
|
||||||
|
|
||||||
|
QLabel *infoLabel = new QLabel();
|
||||||
|
infoLabel->setStyleSheet("QLabel{background-color:transparent;font-size:12px;color:#000000;}");
|
||||||
|
infoLabel->setWordWrap(true);
|
||||||
|
infoLabel->setMinimumHeight(28);
|
||||||
|
infoLabel->setMinimumWidth(220);
|
||||||
|
infoLabel->setMaximumWidth(240);
|
||||||
|
infoLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||||
|
infoLabel->adjustSize();
|
||||||
|
m_labelList << infoLabel;
|
||||||
|
infoGrid->addWidget(titleLabel);
|
||||||
|
infoGrid->addWidget(infoLabel);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*userTitleLabel = new QLabel(QString("%1:").arg(tr("User name")));
|
||||||
userTitleLabel->setStyleSheet("QLabel { background-color : transparent; color : #666666; }");
|
userTitleLabel->setStyleSheet("QLabel { background-color : transparent; color : #666666; }");
|
||||||
userTitleLabel->setFixedWidth(100);
|
userTitleLabel->setFixedWidth(100);
|
||||||
userTitleLabel->setAlignment(Qt::AlignRight);
|
userTitleLabel->setAlignment(Qt::AlignRight);
|
||||||
|
@ -138,18 +233,18 @@ PropertiesDialog::PropertiesDialog(QWidget *parent, pid_t processId) : QDialog(p
|
||||||
startTimeLayout->addWidget(startTimeLabel);
|
startTimeLayout->addWidget(startTimeLabel);
|
||||||
startTimeLayout->addSpacing(20);
|
startTimeLayout->addSpacing(20);
|
||||||
|
|
||||||
layout->addWidget(closeButton, 0, Qt::AlignTop | Qt::AlignRight);
|
m_layout->addWidget(closeButton, 0, Qt::AlignTop | Qt::AlignRight);
|
||||||
layout->addSpacing(20);
|
m_layout->addSpacing(20);
|
||||||
layout->addWidget(iconLabel, 0, Qt::AlignHCenter);
|
m_layout->addWidget(m_iconLabel, 0, Qt::AlignHCenter);
|
||||||
layout->addSpacing(14);
|
m_layout->addSpacing(14);
|
||||||
layout->addWidget(titleLabel, 0, Qt::AlignHCenter);
|
m_layout->addWidget(m_titleLabel, 0, Qt::AlignHCenter);
|
||||||
layout->addSpacing(20);
|
m_layout->addSpacing(20);
|
||||||
layout->addLayout(userLayout);
|
m_layout->addLayout(userLayout);
|
||||||
layout->addLayout(nameLayout);
|
m_layout->addLayout(nameLayout);
|
||||||
layout->addLayout(cmdlineLayout);
|
m_layout->addLayout(cmdlineLayout);
|
||||||
layout->addLayout(cpuDurationLayout);
|
m_layout->addLayout(cpuDurationLayout);
|
||||||
layout->addLayout(startTimeLayout);
|
m_layout->addLayout(startTimeLayout);
|
||||||
layout->addSpacing(20);
|
m_layout->addSpacing(20);*/
|
||||||
|
|
||||||
this->moveToCenter();
|
this->moveToCenter();
|
||||||
|
|
||||||
|
@ -172,12 +267,37 @@ PropertiesDialog::~PropertiesDialog()
|
||||||
}
|
}
|
||||||
|
|
||||||
delete closeButton;
|
delete closeButton;
|
||||||
delete iconLabel;
|
delete m_iconLabel;
|
||||||
delete userTitleLabel;
|
delete m_titleLabel;
|
||||||
|
delete m_okBtn;
|
||||||
|
|
||||||
|
QLayoutItem *child;
|
||||||
|
while ((child = m_topLeftLayout->takeAt(0)) != 0) {
|
||||||
|
if (child->widget())
|
||||||
|
child->widget()->deleteLater();
|
||||||
|
delete child;
|
||||||
|
}
|
||||||
|
while ((child = m_topRightLayout->takeAt(0)) != 0) {
|
||||||
|
if (child->widget())
|
||||||
|
child->widget()->deleteLater();
|
||||||
|
delete child;
|
||||||
|
}
|
||||||
|
while ((child = m_topLayout->takeAt(0)) != 0) {
|
||||||
|
if (child->widget())
|
||||||
|
child->widget()->deleteLater();
|
||||||
|
delete child;
|
||||||
|
}
|
||||||
|
while ((child = m_bottomLayout->takeAt(0)) != 0) {
|
||||||
|
if (child->widget())
|
||||||
|
child->widget()->deleteLater();
|
||||||
|
delete child;
|
||||||
|
}
|
||||||
|
|
||||||
|
delete m_infoFrame;
|
||||||
|
/*delete userTitleLabel;
|
||||||
delete userLabel;
|
delete userLabel;
|
||||||
delete nameTitleLabel;
|
delete nameTitleLabel;
|
||||||
delete m_appNameLabel;
|
delete m_appNameLabel;
|
||||||
delete titleLabel;
|
|
||||||
delete cmdlineTitleLabel;
|
delete cmdlineTitleLabel;
|
||||||
delete cpuDurationLabel;
|
delete cpuDurationLabel;
|
||||||
delete cpuDurationTitleLabel;
|
delete cpuDurationTitleLabel;
|
||||||
|
@ -188,8 +308,20 @@ PropertiesDialog::~PropertiesDialog()
|
||||||
delete nameLayout;
|
delete nameLayout;
|
||||||
delete cmdlineLayout;
|
delete cmdlineLayout;
|
||||||
delete cpuDurationLayout;
|
delete cpuDurationLayout;
|
||||||
delete startTimeLayout;
|
delete startTimeLayout;*/
|
||||||
delete layout;
|
delete m_layout;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PropertiesDialog::updateLabelFrameHeight()
|
||||||
|
{
|
||||||
|
int labelTotalHeight = 0;
|
||||||
|
foreach (QLabel *label, m_labelList) {
|
||||||
|
label->adjustSize();
|
||||||
|
labelTotalHeight += label->size().height() + spacing;
|
||||||
|
}
|
||||||
|
m_infoFrame->setFixedHeight(labelTotalHeight);
|
||||||
|
m_infoFrame->adjustSize();
|
||||||
|
this->adjustSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PropertiesDialog::initProcproperties()
|
void PropertiesDialog::initProcproperties()
|
||||||
|
@ -205,31 +337,41 @@ void PropertiesDialog::initProcproperties()
|
||||||
// long memory = info->mem;
|
// long memory = info->mem;
|
||||||
|
|
||||||
std::string desktopFile;
|
std::string desktopFile;
|
||||||
desktopFile = getDesktopFileFromName(pid, name, "");
|
desktopFile = getDesktopFileAccordProcName(name, "");
|
||||||
|
|
||||||
QPixmap icon_pixmap;
|
QPixmap icon_pixmap;
|
||||||
int iconSize = 96 * qApp->devicePixelRatio();
|
int iconSize = 48 * qApp->devicePixelRatio();
|
||||||
QPixmap defaultPixmap = QIcon::fromTheme("application-x-executable").pixmap(iconSize, iconSize);
|
QPixmap defaultPixmap = QIcon::fromTheme("application-x-executable").pixmap(iconSize, iconSize);
|
||||||
if (desktopFile.size() == 0) {
|
if (desktopFile.size() == 0) {
|
||||||
icon_pixmap = defaultPixmap;
|
icon_pixmap = defaultPixmap;
|
||||||
icon_pixmap.setDevicePixelRatio(qApp->devicePixelRatio());
|
icon_pixmap.setDevicePixelRatio(qApp->devicePixelRatio());
|
||||||
} else {
|
} else {
|
||||||
icon_pixmap = getDesktopFileIcon(desktopFile, 96);
|
icon_pixmap = getAppIconFromDesktopFile(desktopFile, 48);
|
||||||
if (icon_pixmap.isNull()) {
|
if (icon_pixmap.isNull()) {
|
||||||
icon_pixmap = defaultPixmap;
|
icon_pixmap = defaultPixmap;
|
||||||
icon_pixmap.setDevicePixelRatio(qApp->devicePixelRatio());
|
icon_pixmap.setDevicePixelRatio(qApp->devicePixelRatio());
|
||||||
}
|
}
|
||||||
//QPixmap pixmap = QPixmap::fromImage(img).scaled(iconSize, iconSize, Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
//QPixmap pixmap = QPixmap::fromImage(img).scaled(iconSize, iconSize, Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
||||||
}
|
}
|
||||||
QString displayName = getDisplayNameFromName(name, desktopFile);
|
QString displayName = getDisplayNameAccordProcName(name, desktopFile);
|
||||||
iconLabel->setPixmap(icon_pixmap);
|
m_iconLabel->setPixmap(icon_pixmap);
|
||||||
titleLabel->setText(displayName);
|
m_titleLabel->setText(displayName);
|
||||||
userLabel->setText(username);
|
/*userLabel->setText(username);
|
||||||
m_appNameLabel->setText(QString(info->name));
|
m_appNameLabel->setText(QString(info->name));
|
||||||
cmdlineLabel->setText(QString(info->arguments));
|
cmdlineLabel->setText(QString(info->arguments));
|
||||||
startTimeLabel->setText(QFileInfo(QString("/proc/%1").arg(pid)).created().toString("yyyy-MM-dd hh:mm:ss"));
|
startTimeLabel->setText(QFileInfo(QString("/proc/%1").arg(pid)).created().toString("yyyy-MM-dd hh:mm:ss"));
|
||||||
cpuDurationLabel->setText(formatDurationForDisplay(100 * info->cpu_time / info->frequency));
|
cpuDurationLabel->setText(formatDurationForDisplay(100 * info->cpu_time / info->frequency));*/
|
||||||
|
|
||||||
|
QStringList valueList;
|
||||||
|
valueList << username << QString(info->name) << QString(info->arguments)
|
||||||
|
<< QFileInfo(QString("/proc/%1").arg(pid)).created().toString("yyyy-MM-dd hh:mm:ss")
|
||||||
|
<< formatDurationForDisplay(100 * info->cpu_time / info->frequency);
|
||||||
|
|
||||||
|
for (int i = 0; i < this->m_labelList.length(); ++i) {
|
||||||
|
this->m_labelList.value(i)->setText(valueList.value(i));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
this->updateLabelFrameHeight();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PropertiesDialog::refreshProcproperties()
|
void PropertiesDialog::refreshProcproperties()
|
||||||
|
@ -237,8 +379,14 @@ void PropertiesDialog::refreshProcproperties()
|
||||||
ProcessWorker *info;
|
ProcessWorker *info;
|
||||||
info = ProcessWorker::find(pid);
|
info = ProcessWorker::find(pid);
|
||||||
if (info) {
|
if (info) {
|
||||||
startTimeLabel->setText(QFileInfo(QString("/proc/%1").arg(pid)).created().toString("yyyy-MM-dd hh:mm:ss"));
|
for (int i = 0; i < this->m_labelList.length(); ++i) {
|
||||||
cpuDurationLabel->setText(formatDurationForDisplay(100 * info->cpu_time / info->frequency));
|
if (i == 3)
|
||||||
|
this->m_labelList.value(i)->setText(QFileInfo(QString("/proc/%1").arg(pid)).created().toString("yyyy-MM-dd hh:mm:ss"));
|
||||||
|
if (i == 4)
|
||||||
|
this->m_labelList.value(i)->setText(formatDurationForDisplay(100 * info->cpu_time / info->frequency));
|
||||||
|
}
|
||||||
|
//startTimeLabel->setText(QFileInfo(QString("/proc/%1").arg(pid)).created().toString("yyyy-MM-dd hh:mm:ss"));
|
||||||
|
//cpuDurationLabel->setText(formatDurationForDisplay(100 * info->cpu_time / info->frequency));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -302,8 +450,8 @@ void PropertiesDialog::paintEvent(QPaintEvent *event)
|
||||||
QPainter painter(this);
|
QPainter painter(this);
|
||||||
|
|
||||||
//绘制圆角矩形
|
//绘制圆角矩形
|
||||||
painter.setPen(QPen(QColor("#0d87ca"), 0));//边框颜色 QColor(255, 255, 255, 153)
|
painter.setPen(QPen(QColor("#0d87ca"), 0));//边框颜色 #3f96e4
|
||||||
painter.setBrush(QColor("#e9eef0"));//背景色 #0d87ca
|
painter.setBrush(QColor("#e9eef0"));//背景色
|
||||||
painter.setRenderHint(QPainter::Antialiasing, true);
|
painter.setRenderHint(QPainter::Antialiasing, true);
|
||||||
painter.setOpacity(1);
|
painter.setOpacity(1);
|
||||||
QRectF r(0 / 2.0, 0 / 2.0, width() - 0, height() - 0);//左边 上边 右边 下边
|
QRectF r(0 / 2.0, 0 / 2.0, width() - 0, height() - 0);//左边 上边 右边 下边
|
||||||
|
|
|
@ -45,6 +45,7 @@ public:
|
||||||
pid_t getPid();
|
pid_t getPid();
|
||||||
QRect getParentGeometry() const;
|
QRect getParentGeometry() const;
|
||||||
void moveToCenter();
|
void moveToCenter();
|
||||||
|
void updateLabelFrameHeight();
|
||||||
void initProcproperties();
|
void initProcproperties();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
@ -58,8 +59,9 @@ protected:
|
||||||
// void resizeEvent(QResizeEvent *event) Q_DECL_OVERRIDE;
|
// void resizeEvent(QResizeEvent *event) Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
MyTristateButton *closeButton;
|
MyTristateButton *closeButton = nullptr;
|
||||||
QHBoxLayout *cmdlineLayout;
|
QLabel *m_logoLabel = nullptr;
|
||||||
|
/*QHBoxLayout *cmdlineLayout;
|
||||||
QHBoxLayout *userLayout;
|
QHBoxLayout *userLayout;
|
||||||
QHBoxLayout *nameLayout;
|
QHBoxLayout *nameLayout;
|
||||||
QHBoxLayout *cpuDurationLayout;
|
QHBoxLayout *cpuDurationLayout;
|
||||||
|
@ -68,19 +70,29 @@ private:
|
||||||
QLabel *cmdlineTitleLabel;
|
QLabel *cmdlineTitleLabel;
|
||||||
QLabel *userLabel;
|
QLabel *userLabel;
|
||||||
QLabel *userTitleLabel;
|
QLabel *userTitleLabel;
|
||||||
QLabel *iconLabel;
|
|
||||||
QLabel *m_appNameLabel;
|
QLabel *m_appNameLabel;
|
||||||
QLabel *nameTitleLabel;
|
QLabel *nameTitleLabel;
|
||||||
QLabel *cpuDurationLabel;
|
QLabel *cpuDurationLabel;
|
||||||
QLabel *cpuDurationTitleLabel;
|
QLabel *cpuDurationTitleLabel;
|
||||||
QLabel *startTimeLabel;
|
QLabel *startTimeLabel;
|
||||||
QLabel *startTimeTitleLabel;
|
QLabel *startTimeTitleLabel;*/
|
||||||
QLabel *titleLabel;
|
|
||||||
QVBoxLayout *layout;
|
QVBoxLayout *m_layout = nullptr;
|
||||||
|
QHBoxLayout *m_topLayout = nullptr;
|
||||||
|
QHBoxLayout *m_topLeftLayout = nullptr;
|
||||||
|
QHBoxLayout *m_topRightLayout = nullptr;
|
||||||
|
QHBoxLayout *m_bottomLayout = nullptr;
|
||||||
|
QLabel *m_iconLabel = nullptr;
|
||||||
|
QLabel *m_titleLabel = nullptr;
|
||||||
|
QPushButton *m_okBtn = nullptr;
|
||||||
|
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
QPoint dragPosition;
|
QPoint dragPosition;
|
||||||
bool mousePressed;
|
bool mousePressed;
|
||||||
QTimer *timer;
|
QTimer *timer = nullptr;
|
||||||
|
|
||||||
|
QFrame *m_infoFrame = nullptr;
|
||||||
|
QList<QLabel *> m_labelList;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // PROPERTIESSDIALOG_H
|
#endif // PROPERTIESSDIALOG_H
|
||||||
|
|
|
@ -17,16 +17,15 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "util.h"
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QIcon>
|
#include <QIcon>
|
||||||
#include <glib/gi18n.h>
|
|
||||||
#include <glib.h>
|
|
||||||
#include <glibtop/procstate.h>
|
|
||||||
#include "util.h"
|
|
||||||
#include <QDirIterator>
|
#include <QDirIterator>
|
||||||
|
|
||||||
|
#include <glibtop/procstate.h>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <qdiriterator.h>
|
|
||||||
|
|
||||||
std::string make_string(char *c_str)
|
std::string make_string(char *c_str)
|
||||||
{
|
{
|
||||||
|
@ -59,7 +58,6 @@ QString formatDurationForDisplay(unsigned centiseconds)
|
||||||
gchar *duration = NULL;
|
gchar *duration = NULL;
|
||||||
|
|
||||||
if (weeks) {
|
if (weeks) {
|
||||||
/* xgettext: weeks, days */
|
|
||||||
duration = g_strdup_printf("%uw%ud", weeks, days);
|
duration = g_strdup_printf("%uw%ud", weeks, days);
|
||||||
formatTime = QString(QLatin1String(duration));
|
formatTime = QString(QLatin1String(duration));
|
||||||
if (duration) {
|
if (duration) {
|
||||||
|
@ -70,7 +68,6 @@ QString formatDurationForDisplay(unsigned centiseconds)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (days) {
|
if (days) {
|
||||||
/* xgettext: days, hours (0 -> 23) */
|
|
||||||
duration = g_strdup_printf("%ud%02uh", days, hours);
|
duration = g_strdup_printf("%ud%02uh", days, hours);
|
||||||
formatTime = QString(QLatin1String(duration));
|
formatTime = QString(QLatin1String(duration));
|
||||||
if (duration) {
|
if (duration) {
|
||||||
|
@ -81,7 +78,6 @@ QString formatDurationForDisplay(unsigned centiseconds)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hours) {
|
if (hours) {
|
||||||
/* xgettext: hours (0 -> 23), minutes, seconds */
|
|
||||||
duration = g_strdup_printf("%u:%02u:%02u", hours, minutes, seconds);
|
duration = g_strdup_printf("%u:%02u:%02u", hours, minutes, seconds);
|
||||||
formatTime = QString(QLatin1String(duration));
|
formatTime = QString(QLatin1String(duration));
|
||||||
if (duration) {
|
if (duration) {
|
||||||
|
@ -91,7 +87,6 @@ QString formatDurationForDisplay(unsigned centiseconds)
|
||||||
return formatTime;
|
return formatTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* xgettext: minutes, seconds, centiseconds */
|
|
||||||
duration = g_strdup_printf("%u:%02u.%02u", minutes, seconds, centiseconds);
|
duration = g_strdup_printf("%u:%02u.%02u", minutes, seconds, centiseconds);
|
||||||
formatTime = QString(QLatin1String(duration));
|
formatTime = QString(QLatin1String(duration));
|
||||||
if (duration) {
|
if (duration) {
|
||||||
|
@ -101,18 +96,12 @@ QString formatDurationForDisplay(unsigned centiseconds)
|
||||||
return formatTime;
|
return formatTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string getDesktopFileFromName(int pid, QString procName, QString cmdline)
|
std::string getDesktopFileAccordProcName(QString procName, QString cmdline)
|
||||||
{
|
{
|
||||||
QDirIterator dir("/usr/share/applications", QDirIterator::Subdirectories);
|
QDirIterator dir("/usr/share/applications", QDirIterator::Subdirectories);
|
||||||
std::string desktopFile;
|
std::string desktopFile;
|
||||||
|
|
||||||
// Convert to lower characters.
|
|
||||||
QString procname = procName.toLower();
|
QString procname = procName.toLower();
|
||||||
|
|
||||||
// Replace "_" instead "-", avoid some applications desktop file can't found, such as, sublime text.
|
|
||||||
procname.replace("_", "-");
|
procname.replace("_", "-");
|
||||||
|
|
||||||
// Concat desktop file.
|
|
||||||
QString processFilename = procname + ".desktop";
|
QString processFilename = procname + ".desktop";
|
||||||
|
|
||||||
while(dir.hasNext()) {
|
while(dir.hasNext()) {
|
||||||
|
@ -128,7 +117,7 @@ std::string getDesktopFileFromName(int pid, QString procName, QString cmdline)
|
||||||
return desktopFile;
|
return desktopFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
QPixmap getDesktopFileIcon(std::string desktopFile, int iconSize)
|
QPixmap getAppIconFromDesktopFile(std::string desktopFile, int iconSize)
|
||||||
{
|
{
|
||||||
std::ifstream in;
|
std::ifstream in;
|
||||||
in.open(desktopFile);
|
in.open(desktopFile);
|
||||||
|
@ -141,13 +130,11 @@ QPixmap getDesktopFileIcon(std::string desktopFile, int iconSize)
|
||||||
iconName = QString::fromStdString(line);
|
iconName = QString::fromStdString(line);
|
||||||
|
|
||||||
if (iconName.startsWith("Icon=")) {
|
if (iconName.startsWith("Icon=")) {
|
||||||
iconName.remove(0,5); // remove the first 5 chars
|
iconName.remove(0,5);
|
||||||
} else {
|
} else {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (iconName.contains("/")) {
|
if (iconName.contains("/")) {
|
||||||
// this is probably a path to the file, use that instead of the theme icon name
|
|
||||||
icon = QIcon(iconName);
|
icon = QIcon(iconName);
|
||||||
} else {
|
} else {
|
||||||
icon = QIcon::fromTheme(iconName, defaultExecutableIcon);
|
icon = QIcon::fromTheme(iconName, defaultExecutableIcon);
|
||||||
|
@ -164,39 +151,35 @@ QPixmap getDesktopFileIcon(std::string desktopFile, int iconSize)
|
||||||
return pixmap;
|
return pixmap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString getDisplayNameAccordProcName(QString procName, std::string desktopFile)
|
||||||
QString getDisplayNameFromName(QString procName, std::string desktopFile)
|
|
||||||
{
|
{
|
||||||
if (desktopFile.size() == 0) {
|
if (desktopFile.size() == 0) {
|
||||||
return procName;
|
return procName;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::ifstream in;
|
std::ifstream in;
|
||||||
in.open(desktopFile);
|
in.open(desktopFile);
|
||||||
QString displayName = procName;
|
QString displayName = procName;
|
||||||
while(!in.eof()) {
|
while(!in.eof()) {
|
||||||
std::string line;
|
std::string line;
|
||||||
std::getline(in,line);
|
std::getline(in,line);
|
||||||
|
|
||||||
QString lineContent = QString::fromStdString(line);
|
QString lineContent = QString::fromStdString(line);
|
||||||
|
|
||||||
QString localNameFlag = QString("Name[%1]=").arg(QLocale::system().name());
|
QString localNameFlag = QString("Name[%1]=").arg(QLocale::system().name());
|
||||||
QString nameFlag = "Name=";
|
QString nameFlag = "Name=";
|
||||||
QString genericNameFlag = QString("GenericName[%1]=").arg(QLocale::system().name());
|
QString genericNameFlag = QString("GenericName[%1]=").arg(QLocale::system().name());
|
||||||
|
|
||||||
if (lineContent.startsWith(localNameFlag)) {
|
if (lineContent.startsWith(localNameFlag)) {
|
||||||
displayName = lineContent.remove(0, localNameFlag.size());
|
displayName = lineContent.remove(0, localNameFlag.size());
|
||||||
|
|
||||||
break;
|
break;
|
||||||
} else if (lineContent.startsWith(genericNameFlag)) {
|
}
|
||||||
|
else if (lineContent.startsWith(genericNameFlag)) {
|
||||||
displayName = lineContent.remove(0, genericNameFlag.size());
|
displayName = lineContent.remove(0, genericNameFlag.size());
|
||||||
|
|
||||||
break;
|
break;
|
||||||
} else if (lineContent.startsWith(nameFlag)) {
|
}
|
||||||
|
else if (lineContent.startsWith(nameFlag)) {
|
||||||
displayName = lineContent.remove(0, nameFlag.size());
|
displayName = lineContent.remove(0, nameFlag.size());
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -205,15 +188,6 @@ QString getDisplayNameFromName(QString procName, std::string desktopFile)
|
||||||
return displayName;
|
return displayName;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString getImagePath(QString imageName)
|
|
||||||
{
|
|
||||||
QDir dir(qApp->applicationDirPath());
|
|
||||||
dir.cdUp();
|
|
||||||
|
|
||||||
return QDir(dir.filePath("image")).filePath(imageName);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
QString formatProcessState(guint state)
|
QString formatProcessState(guint state)
|
||||||
{
|
{
|
||||||
QString status;
|
QString status;
|
||||||
|
@ -281,7 +255,6 @@ QString formatUnitSize(double v, const char** orders, int nb_orders)
|
||||||
QString formatByteCount(double v)
|
QString formatByteCount(double v)
|
||||||
{
|
{
|
||||||
static const char* orders[] = { "B", "KB", "MB", "GB", "TB" };
|
static const char* orders[] = { "B", "KB", "MB", "GB", "TB" };
|
||||||
|
|
||||||
return formatUnitSize(v, orders, sizeof(orders)/sizeof(orders[0]));
|
return formatUnitSize(v, orders, sizeof(orders)/sizeof(orders[0]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,10 +29,9 @@
|
||||||
|
|
||||||
using std::string;
|
using std::string;
|
||||||
|
|
||||||
std::string getDesktopFileFromName(int pid, QString procName, QString cmdline);
|
std::string getDesktopFileAccordProcName(QString procName, QString cmdline);
|
||||||
QPixmap getDesktopFileIcon(std::string desktopFile, int iconSize = 24);
|
QPixmap getAppIconFromDesktopFile(std::string desktopFile, int iconSize = 24);
|
||||||
QString getDisplayNameFromName(QString procName, std::string desktopFile);
|
QString getDisplayNameAccordProcName(QString procName, std::string desktopFile);
|
||||||
QString getImagePath(QString imageName);
|
|
||||||
std::string make_string(char *c_str);
|
std::string make_string(char *c_str);
|
||||||
QString formatProcessState(guint state);
|
QString formatProcessState(guint state);
|
||||||
QString getNiceLevel(int nice);
|
QString getNiceLevel(int nice);
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
#include "mytristatebutton.h"
|
#include "mytristatebutton.h"
|
||||||
|
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QButtonGroup>
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QCloseEvent>
|
#include <QCloseEvent>
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
|
@ -18,70 +17,57 @@ MyDialog::MyDialog(const QString &title, const QString &message, QWidget *parent
|
||||||
, mousePressed(false)
|
, mousePressed(false)
|
||||||
{
|
{
|
||||||
this->setWindowFlags(this->windowFlags() | Qt::FramelessWindowHint | Qt::WindowCloseButtonHint);
|
this->setWindowFlags(this->windowFlags() | Qt::FramelessWindowHint | Qt::WindowCloseButtonHint);
|
||||||
|
|
||||||
this->setAttribute(Qt::WA_TranslucentBackground);
|
this->setAttribute(Qt::WA_TranslucentBackground);
|
||||||
// this->setAttribute(Qt::WA_DeleteOnClose, false);
|
// this->setAttribute(Qt::WA_DeleteOnClose, false);
|
||||||
this->setAttribute(Qt::WA_Resized, false);
|
this->setAttribute(Qt::WA_Resized, false);
|
||||||
|
|
||||||
topLayout = new QHBoxLayout;
|
m_topLayout = new QHBoxLayout;
|
||||||
topLayout->setContentsMargins(20, 14, 20, 14);
|
m_topLayout->setContentsMargins(20, 14, 20, 14);
|
||||||
topLayout->setSpacing(20);
|
m_topLayout->setSpacing(20);
|
||||||
|
|
||||||
titleLabel = new QLabel;
|
m_titleLabel = new QLabel;
|
||||||
titleLabel->setStyleSheet("QLabel{padding-top: 2px;padding-bottom: 2px;font-size: 12px;color: #000000;}");
|
m_titleLabel->setStyleSheet("QLabel{padding-top:3px;padding-bottom:3px;font-size:18px;color:#000000;}");
|
||||||
titleLabel->hide();
|
m_titleLabel->hide();
|
||||||
titleLabel->setAttribute(Qt::WA_TransparentForMouseEvents);
|
m_titleLabel->setAttribute(Qt::WA_TransparentForMouseEvents);
|
||||||
|
|
||||||
messageLabel = new QLabel;
|
m_messageLabel = new QLabel;
|
||||||
messageLabel->setStyleSheet("QLabel{padding-top: 2px;padding-bottom: 2px;font-size: 11px;color: #444444;}");
|
m_messageLabel->setStyleSheet("QLabel{padding-top:3px;padding-bottom:3px;font-size:12px;color:#000000;}");
|
||||||
messageLabel->hide();
|
m_messageLabel->hide();
|
||||||
messageLabel->setAttribute(Qt::WA_TransparentForMouseEvents);
|
m_messageLabel->setAttribute(Qt::WA_TransparentForMouseEvents);
|
||||||
|
|
||||||
QVBoxLayout *textLayout = new QVBoxLayout;
|
QVBoxLayout *textLayout = new QVBoxLayout;
|
||||||
textLayout->setContentsMargins(0, 0, 0, 0);
|
textLayout->setContentsMargins(0, 0, 0, 0);
|
||||||
textLayout->setSpacing(5);
|
textLayout->setSpacing(5);
|
||||||
textLayout->addStretch();
|
textLayout->addWidget(m_titleLabel, 0, Qt::AlignLeft);
|
||||||
textLayout->addWidget(titleLabel, 0, Qt::AlignLeft);
|
textLayout->addWidget(m_messageLabel, 0, Qt::AlignLeft);
|
||||||
textLayout->addWidget(messageLabel, 0, Qt::AlignLeft);
|
|
||||||
textLayout->addStretch();
|
textLayout->addStretch();
|
||||||
|
|
||||||
contentLayout = new QVBoxLayout;
|
m_topLayout->addLayout(textLayout);
|
||||||
contentLayout->setContentsMargins(0, 0, 0, 0);
|
|
||||||
contentLayout->setSpacing(0);
|
|
||||||
contentLayout->addLayout(textLayout);
|
|
||||||
|
|
||||||
topLayout->addLayout(contentLayout);
|
|
||||||
|
|
||||||
|
|
||||||
closeButton = new MyTristateButton(this);
|
closeButton = new MyTristateButton(this);
|
||||||
closeButton->setObjectName("CloseButton");
|
closeButton->setObjectName("CloseButton");
|
||||||
// closeButton->setNormalPic(":/res/tool/close_normal.png");
|
|
||||||
// closeButton->setHoverPic(":/res/tool/close_hover.png");
|
|
||||||
// closeButton->setPressPic(":/res/tool/close_press.png");
|
|
||||||
connect(closeButton, &MyTristateButton::clicked, this, [=] {
|
connect(closeButton, &MyTristateButton::clicked, this, [=] {
|
||||||
this->close();
|
this->close();
|
||||||
});
|
});
|
||||||
closeButton->setAttribute(Qt::WA_NoMousePropagation);
|
closeButton->setAttribute(Qt::WA_NoMousePropagation);
|
||||||
|
|
||||||
|
m_buttonLayout = new QHBoxLayout;
|
||||||
|
m_buttonLayout->setMargin(0);
|
||||||
|
m_buttonLayout->setSpacing(0);
|
||||||
|
m_buttonLayout->setContentsMargins(20, 14, 20, 14);
|
||||||
|
|
||||||
QVBoxLayout *mainLayout = new QVBoxLayout;
|
QVBoxLayout *mainLayout = new QVBoxLayout;
|
||||||
mainLayout->setContentsMargins(0, 0, 0, 0);
|
mainLayout->setContentsMargins(0, 0, 0, 0);
|
||||||
mainLayout->setSpacing(0);
|
mainLayout->setSpacing(10);
|
||||||
|
|
||||||
mainLayout->addWidget(closeButton, 0, Qt::AlignTop | Qt::AlignRight);
|
mainLayout->addWidget(closeButton, 0, Qt::AlignTop | Qt::AlignRight);
|
||||||
mainLayout->addLayout(topLayout);
|
mainLayout->addLayout(m_topLayout);
|
||||||
|
mainLayout->addLayout(m_buttonLayout);
|
||||||
buttonLayout = new QHBoxLayout;
|
|
||||||
buttonLayout->setMargin(0);
|
|
||||||
buttonLayout->setSpacing(0);
|
|
||||||
buttonLayout->setContentsMargins(20, 14, 20, 14);
|
|
||||||
mainLayout->addLayout(buttonLayout);
|
|
||||||
|
|
||||||
QAction *button_action = new QAction(this);
|
QAction *button_action = new QAction(this);
|
||||||
|
|
||||||
button_action->setShortcuts(QKeySequence::InsertParagraphSeparator);
|
button_action->setShortcuts(QKeySequence::InsertParagraphSeparator);
|
||||||
button_action->setAutoRepeat(false);
|
button_action->setAutoRepeat(false);
|
||||||
|
connect(button_action, SIGNAL(triggered(bool)), this, SLOT(onDefaultButtonTriggered()));
|
||||||
QObject::connect(button_action, SIGNAL(triggered(bool)), this, SLOT(onDefaultButtonTriggered()));
|
|
||||||
|
|
||||||
this->setLayout(mainLayout);
|
this->setLayout(mainLayout);
|
||||||
this->addAction(button_action);
|
this->addAction(button_action);
|
||||||
|
@ -96,17 +82,36 @@ MyDialog::MyDialog(const QString &title, const QString &message, QWidget *parent
|
||||||
|
|
||||||
MyDialog::~MyDialog()
|
MyDialog::~MyDialog()
|
||||||
{
|
{
|
||||||
this->clearButtons();
|
delete m_messageLabel;
|
||||||
|
delete m_titleLabel;
|
||||||
|
delete closeButton;
|
||||||
|
|
||||||
|
QLayoutItem *child;
|
||||||
|
while ((child = m_topLayout->takeAt(0)) != 0) {
|
||||||
|
if (child->widget())
|
||||||
|
child->widget()->deleteLater();
|
||||||
|
delete child;
|
||||||
|
}
|
||||||
|
|
||||||
|
this->buttonList.clear();
|
||||||
|
while ((child = m_buttonLayout->takeAt(0)) != 0) {
|
||||||
|
if (child->widget())
|
||||||
|
child->widget()->deleteLater();
|
||||||
|
delete child;
|
||||||
|
}
|
||||||
|
// while(this->m_buttonLayout->count()) {
|
||||||
|
// QLayoutItem *item = this->m_buttonLayout->takeAt(0);
|
||||||
|
// item->widget()->deleteLater();
|
||||||
|
// delete item;
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
void MyDialog::updateSize()
|
void MyDialog::updateSize()
|
||||||
{
|
{
|
||||||
if (!this->testAttribute(Qt::WA_Resized)) {
|
if (!this->testAttribute(Qt::WA_Resized)) {
|
||||||
QSize size = this->sizeHint();
|
QSize size = this->sizeHint();
|
||||||
|
size.setWidth(qMax(size.width(), 234));
|
||||||
size.setWidth(qMax(size.width(), 440));
|
size.setHeight(qMax(size.height(), 196));
|
||||||
size.setHeight(qMax(size.height(), 200));
|
|
||||||
|
|
||||||
this->resize(size);
|
this->resize(size);
|
||||||
this->setAttribute(Qt::WA_Resized, false);
|
this->setAttribute(Qt::WA_Resized, false);
|
||||||
}
|
}
|
||||||
|
@ -115,7 +120,6 @@ void MyDialog::updateSize()
|
||||||
void MyDialog::onButtonClicked()
|
void MyDialog::onButtonClicked()
|
||||||
{
|
{
|
||||||
QAbstractButton *button = qobject_cast<QAbstractButton*>(this->sender());
|
QAbstractButton *button = qobject_cast<QAbstractButton*>(this->sender());
|
||||||
|
|
||||||
if(button) {
|
if(button) {
|
||||||
clickedButtonIndex = buttonList.indexOf(button);
|
clickedButtonIndex = buttonList.indexOf(button);
|
||||||
emit this->buttonClicked(clickedButtonIndex, button->text());
|
emit this->buttonClicked(clickedButtonIndex, button->text());
|
||||||
|
@ -138,51 +142,25 @@ int MyDialog::buttonCount() const
|
||||||
return this->buttonList.count();
|
return this->buttonList.count();
|
||||||
}
|
}
|
||||||
|
|
||||||
int MyDialog::addButton(const QString &text, bool isDefault/*, ButtonType type*/)
|
int MyDialog::addButton(const QString &text, bool isDefault)
|
||||||
{
|
{
|
||||||
int index = buttonCount();
|
int index = buttonCount();
|
||||||
|
|
||||||
QAbstractButton *button = new QPushButton(text);
|
QAbstractButton *button = new QPushButton(text);
|
||||||
|
button->setFocusPolicy(Qt::NoFocus);
|
||||||
button->setStyleSheet("QPushButton{font-size:12px;background:#ffffff;border:1px solid #bebebe;color:#000000;}QPushButton:hover{background-color:#ffffff;border:1px solid #3f96e4;color:#000000;}QPushButton:pressed{background-color:#ffffff;border:1px solid #3f96e4;color:#000000;}");
|
button->setStyleSheet("QPushButton{font-size:12px;background:#ffffff;border:1px solid #bebebe;color:#000000;}QPushButton:hover{background-color:#ffffff;border:1px solid #3f96e4;color:#000000;}QPushButton:pressed{background-color:#ffffff;border:1px solid #3f96e4;color:#000000;}");
|
||||||
button->setAttribute(Qt::WA_NoMousePropagation);
|
button->setAttribute(Qt::WA_NoMousePropagation);
|
||||||
button->setFixedHeight(24);
|
button->setFixedSize(91, 25);
|
||||||
|
|
||||||
QLabel* label = new QLabel;
|
this->m_buttonLayout->insertWidget(index+1, button);
|
||||||
label->setStyleSheet("QLabel{background-color:rgba(0, 0, 0, 0.1);}");
|
|
||||||
label->setFixedWidth(1);
|
|
||||||
label->hide();
|
|
||||||
|
|
||||||
if(index > 0 && index >= buttonCount()) {
|
|
||||||
QLabel *label = qobject_cast<QLabel*>(this->buttonLayout->itemAt(this->buttonLayout->count() - 1)->widget());
|
|
||||||
if(label)
|
|
||||||
label->show();
|
|
||||||
}
|
|
||||||
|
|
||||||
this->buttonLayout->insertWidget(index * 2, button);
|
|
||||||
this->buttonList << button;
|
this->buttonList << button;
|
||||||
this->buttonLayout->insertWidget(index * 2 + 1, label);
|
|
||||||
|
|
||||||
connect(button, SIGNAL(clicked(bool)), this, SLOT(onButtonClicked()));
|
connect(button, SIGNAL(clicked(bool)), this, SLOT(onButtonClicked()));
|
||||||
|
|
||||||
if(isDefault) {
|
if(isDefault) {
|
||||||
setDefaultButton(button);
|
setDefaultButton(button);
|
||||||
}
|
}
|
||||||
|
|
||||||
return index;
|
return index;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MyDialog::clearButtons()
|
|
||||||
{
|
|
||||||
this->buttonList.clear();
|
|
||||||
|
|
||||||
while(this->buttonLayout->count()) {
|
|
||||||
QLayoutItem *item = this->buttonLayout->takeAt(0);
|
|
||||||
|
|
||||||
item->widget()->deleteLater();
|
|
||||||
delete item;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void MyDialog::setDefaultButton(QAbstractButton *button)
|
void MyDialog::setDefaultButton(QAbstractButton *button)
|
||||||
{
|
{
|
||||||
this->defaultButton = button;
|
this->defaultButton = button;
|
||||||
|
@ -194,27 +172,25 @@ void MyDialog::setTitle(const QString &title)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
this->m_title = title;
|
this->m_title = title;
|
||||||
this->titleLabel->setText(title);
|
this->m_titleLabel->setText(title);
|
||||||
this->titleLabel->setHidden(title.isEmpty());
|
this->m_titleLabel->setHidden(title.isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
void MyDialog::setMessage(const QString &message)
|
void MyDialog::setMessage(const QString &message)
|
||||||
{
|
{
|
||||||
if (this->m_message == message)
|
if (this->m_message == message)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
this->m_message = message;
|
this->m_message = message;
|
||||||
this->messageLabel->setText(message);
|
this->m_messageLabel->setText(message);
|
||||||
this->messageLabel->setHidden(message.isEmpty());
|
this->m_messageLabel->setHidden(message.isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
int MyDialog::exec()
|
int MyDialog::exec()
|
||||||
{
|
{
|
||||||
this->clickedButtonIndex = -1;
|
this->clickedButtonIndex = -1;
|
||||||
|
int ret = QDialog::exec();
|
||||||
|
|
||||||
int code = QDialog::exec();
|
return this->clickedButtonIndex >= 0 ? this->clickedButtonIndex : ret;
|
||||||
|
|
||||||
return this->clickedButtonIndex >= 0 ? this->clickedButtonIndex : code;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MyDialog::showEvent(QShowEvent *event)
|
void MyDialog::showEvent(QShowEvent *event)
|
||||||
|
@ -227,14 +203,12 @@ void MyDialog::showEvent(QShowEvent *event)
|
||||||
void MyDialog::hideEvent(QHideEvent *event)
|
void MyDialog::hideEvent(QHideEvent *event)
|
||||||
{
|
{
|
||||||
QDialog::hideEvent(event);
|
QDialog::hideEvent(event);
|
||||||
|
|
||||||
done(-1);
|
done(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MyDialog::childEvent(QChildEvent *event)
|
void MyDialog::childEvent(QChildEvent *event)
|
||||||
{
|
{
|
||||||
QDialog::childEvent(event);
|
QDialog::childEvent(event);
|
||||||
|
|
||||||
if (event->added()) {
|
if (event->added()) {
|
||||||
if (this->closeButton) {
|
if (this->closeButton) {
|
||||||
this->closeButton->raise();
|
this->closeButton->raise();
|
||||||
|
@ -246,16 +220,15 @@ QRect MyDialog::getParentGeometry() const
|
||||||
{
|
{
|
||||||
if (this->parentWidget()) {
|
if (this->parentWidget()) {
|
||||||
return this->parentWidget()->window()->geometry();
|
return this->parentWidget()->window()->geometry();
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
QPoint pos = QCursor::pos();
|
QPoint pos = QCursor::pos();
|
||||||
|
|
||||||
for (QScreen *screen : qApp->screens()) {
|
for (QScreen *screen : qApp->screens()) {
|
||||||
if (screen->geometry().contains(pos)) {
|
if (screen->geometry().contains(pos)) {
|
||||||
return screen->geometry();
|
return screen->geometry();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return qApp->primaryScreen()->geometry();
|
return qApp->primaryScreen()->geometry();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -272,14 +245,12 @@ void MyDialog::mousePressEvent(QMouseEvent *event)
|
||||||
this->dragPosition = event->globalPos() - frameGeometry().topLeft();
|
this->dragPosition = event->globalPos() - frameGeometry().topLeft();
|
||||||
this->mousePressed = true;
|
this->mousePressed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
QDialog::mousePressEvent(event);
|
QDialog::mousePressEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MyDialog::mouseReleaseEvent(QMouseEvent *event)
|
void MyDialog::mouseReleaseEvent(QMouseEvent *event)
|
||||||
{
|
{
|
||||||
this->mousePressed = false;
|
this->mousePressed = false;
|
||||||
|
|
||||||
QDialog::mouseReleaseEvent(event);
|
QDialog::mouseReleaseEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -288,7 +259,6 @@ void MyDialog::mouseMoveEvent(QMouseEvent *event)
|
||||||
if (this->mousePressed) {
|
if (this->mousePressed) {
|
||||||
move(event->globalPos() - this->dragPosition);
|
move(event->globalPos() - this->dragPosition);
|
||||||
}
|
}
|
||||||
|
|
||||||
QDialog::mouseMoveEvent(event);
|
QDialog::mouseMoveEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -297,7 +267,7 @@ void MyDialog::paintEvent(QPaintEvent *event)
|
||||||
QPainter painter(this);
|
QPainter painter(this);
|
||||||
|
|
||||||
//绘制圆角矩形
|
//绘制圆角矩形
|
||||||
painter.setPen(QPen(QColor("#0d87ca"), 0));//边框颜色 QColor(255, 255, 255, 153)
|
painter.setPen(QPen(QColor("#0d87ca"), 0));//边框颜色
|
||||||
painter.setBrush(QColor("#e9eef0"));//背景色 #0d87ca
|
painter.setBrush(QColor("#e9eef0"));//背景色 #0d87ca
|
||||||
painter.setRenderHint(QPainter::Antialiasing, true);
|
painter.setRenderHint(QPainter::Antialiasing, true);
|
||||||
painter.setOpacity(1);
|
painter.setOpacity(1);
|
||||||
|
@ -318,21 +288,21 @@ void MyDialog::resizeEvent(QResizeEvent *event)
|
||||||
{
|
{
|
||||||
QDialog::resizeEvent(event);
|
QDialog::resizeEvent(event);
|
||||||
|
|
||||||
this->titleLabel->setWordWrap(false);
|
this->m_titleLabel->setWordWrap(false);
|
||||||
int labelMaxWidth = maximumWidth() - this->closeButton->width() - this->titleLabel->x();
|
int labelMaxWidth = maximumWidth() - this->closeButton->width() - this->m_titleLabel->x();
|
||||||
|
|
||||||
if (this->titleLabel->sizeHint().width() > labelMaxWidth) {
|
if (this->m_titleLabel->sizeHint().width() > labelMaxWidth) {
|
||||||
this->titleLabel->setFixedWidth(labelMaxWidth);
|
this->m_titleLabel->setFixedWidth(labelMaxWidth);
|
||||||
this->titleLabel->setWordWrap(true);
|
this->m_titleLabel->setWordWrap(true);
|
||||||
this->titleLabel->setFixedHeight(this->titleLabel->sizeHint().height());
|
this->m_titleLabel->setFixedHeight(this->m_titleLabel->sizeHint().height());
|
||||||
}
|
}
|
||||||
|
|
||||||
this->messageLabel->setWordWrap(false);
|
this->m_messageLabel->setWordWrap(false);
|
||||||
labelMaxWidth = maximumWidth() - this->closeButton->width() - this->messageLabel->x();
|
labelMaxWidth = maximumWidth() - this->closeButton->width() - this->m_messageLabel->x();
|
||||||
|
|
||||||
if (this->messageLabel->sizeHint().width() > labelMaxWidth) {
|
if (this->m_messageLabel->sizeHint().width() > labelMaxWidth) {
|
||||||
this->messageLabel->setFixedWidth(labelMaxWidth);
|
this->m_messageLabel->setFixedWidth(labelMaxWidth);
|
||||||
this->messageLabel->setWordWrap(true);
|
this->m_messageLabel->setWordWrap(true);
|
||||||
this->messageLabel->setFixedHeight(this->messageLabel->sizeHint().height());
|
this->m_messageLabel->setFixedHeight(this->m_messageLabel->sizeHint().height());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,7 @@ public:
|
||||||
explicit MyDialog(const QString &title, const QString& message, QWidget *parent = 0);
|
explicit MyDialog(const QString &title, const QString& message, QWidget *parent = 0);
|
||||||
~MyDialog();
|
~MyDialog();
|
||||||
|
|
||||||
|
void updateSize();
|
||||||
int buttonCount() const;
|
int buttonCount() const;
|
||||||
QRect getParentGeometry() const;
|
QRect getParentGeometry() const;
|
||||||
void moveToCenter();
|
void moveToCenter();
|
||||||
|
@ -32,11 +33,9 @@ signals:
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
int addButton(const QString &text, bool isDefault = false);
|
int addButton(const QString &text, bool isDefault = false);
|
||||||
void clearButtons();
|
|
||||||
void setDefaultButton(QAbstractButton *button);
|
void setDefaultButton(QAbstractButton *button);
|
||||||
void setTitle(const QString &title);
|
void setTitle(const QString &title);
|
||||||
void setMessage(const QString& message);
|
void setMessage(const QString& message);
|
||||||
|
|
||||||
int exec() Q_DECL_OVERRIDE;
|
int exec() Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
@ -54,22 +53,21 @@ protected:
|
||||||
void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE;
|
void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString m_title;
|
QLabel *m_messageLabel = nullptr;
|
||||||
QString m_message;
|
QLabel *m_titleLabel = nullptr;
|
||||||
QLabel* messageLabel;
|
MyTristateButton *closeButton = nullptr;
|
||||||
QLabel* titleLabel;
|
// QVBoxLayout *contentLayout = nullptr;
|
||||||
|
QHBoxLayout *m_buttonLayout = nullptr;
|
||||||
MyTristateButton* closeButton = nullptr;
|
QHBoxLayout *m_topLayout = nullptr;
|
||||||
QHBoxLayout *iconLayout;
|
|
||||||
QVBoxLayout *contentLayout;
|
|
||||||
QHBoxLayout *buttonLayout;
|
|
||||||
QHBoxLayout *topLayout;
|
|
||||||
QList<QAbstractButton*> buttonList;
|
QList<QAbstractButton*> buttonList;
|
||||||
QList<QWidget*> contentList;
|
QList<QWidget*> contentList;
|
||||||
|
|
||||||
QPointer<QAbstractButton> defaultButton;
|
QPointer<QAbstractButton> defaultButton;
|
||||||
int clickedButtonIndex;
|
int clickedButtonIndex;
|
||||||
void updateSize();
|
|
||||||
|
QString m_title;
|
||||||
|
QString m_message;
|
||||||
|
|
||||||
QPoint dragPosition;
|
QPoint dragPosition;
|
||||||
bool mousePressed;
|
bool mousePressed;
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,19 +1,17 @@
|
||||||
#include "mysearchedit.h"
|
#include "mysearchedit.h"
|
||||||
|
|
||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
#include <QSpacerItem>
|
|
||||||
#include <QPropertyAnimation>
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QEvent>
|
#include <QEvent>
|
||||||
#include <QFocusEvent>
|
#include <QFocusEvent>
|
||||||
#include <QResizeEvent>
|
#include <QResizeEvent>
|
||||||
#include <QTimer>
|
|
||||||
|
|
||||||
MySearchEdit::MySearchEdit(QWidget *parent)
|
MySearchEdit::MySearchEdit(QWidget *parent)
|
||||||
: QFrame(parent)
|
: QFrame(parent)
|
||||||
|
,m_showCurve(QEasingCurve::OutCubic)
|
||||||
|
,m_hideCurve(QEasingCurve::InCubic)
|
||||||
{
|
{
|
||||||
// this->setStyleSheet("QFrame{background-color:#00376a;border-radius:0px;}");
|
this->setStyleSheet("QFrame{background-color:#00376a;border-radius:0px;}");
|
||||||
this->setStyleSheet("QFrame{background-color:rgb(0, 55, 106, 127);border-radius:0px;}");
|
|
||||||
|
|
||||||
m_searchBtn = new QLabel;
|
m_searchBtn = new QLabel;
|
||||||
m_searchBtn->setStyleSheet("QLabel{background-color:transparent;border:none;background-image:url(:/res/search.png);}");
|
m_searchBtn->setStyleSheet("QLabel{background-color:transparent;border:none;background-image:url(:/res/search.png);}");
|
||||||
|
@ -45,42 +43,45 @@ MySearchEdit::MySearchEdit(QWidget *parent)
|
||||||
layout->setAlignment(m_placeHolder, Qt::AlignCenter);
|
layout->setAlignment(m_placeHolder, Qt::AlignCenter);
|
||||||
layout->addWidget(m_edit);
|
layout->addWidget(m_edit);
|
||||||
layout->setAlignment(m_edit, Qt::AlignCenter);
|
layout->setAlignment(m_edit, Qt::AlignCenter);
|
||||||
// layout->addStretch();
|
|
||||||
// layout->addWidget(m_searchBtn);
|
|
||||||
// layout->setAlignment(m_searchBtn, Qt::AlignCenter);
|
|
||||||
layout->addStretch();
|
layout->addStretch();
|
||||||
layout->addWidget(m_clearBtn);
|
layout->addWidget(m_clearBtn);
|
||||||
layout->setAlignment(m_clearBtn, Qt::AlignCenter);
|
layout->setAlignment(m_clearBtn, Qt::AlignCenter);
|
||||||
layout->setSpacing(0);
|
layout->setSpacing(0);
|
||||||
layout->setContentsMargins(0, 0, 0, 0);
|
layout->setContentsMargins(0, 0, 0, 0);
|
||||||
|
|
||||||
// setAutoFillBackground(true);
|
|
||||||
setFocusPolicy(Qt::StrongFocus);
|
setFocusPolicy(Qt::StrongFocus);
|
||||||
|
|
||||||
connect(m_clearBtn, &MyTristateButton::clicked, m_edit, static_cast<void (QLineEdit::*)()>(&QLineEdit::setFocus));
|
|
||||||
connect(m_clearBtn, &MyTristateButton::clicked, this, &MySearchEdit::clearEdit);
|
|
||||||
connect(m_edit, &QLineEdit::textChanged, [this] {m_clearBtn->setVisible(!m_edit->text().isEmpty());});
|
connect(m_edit, &QLineEdit::textChanged, [this] {m_clearBtn->setVisible(!m_edit->text().isEmpty());});
|
||||||
connect(m_edit, &QLineEdit::textChanged, this, &MySearchEdit::textChanged, Qt::DirectConnection);
|
connect(m_edit, &QLineEdit::textChanged, this, &MySearchEdit::textChanged, Qt::DirectConnection);
|
||||||
// connect(m_edit, &QLineEdit::textChanged, this, [=] {
|
connect(m_clearBtn, &MyTristateButton::clicked, this, [=] {
|
||||||
// emit this->textChanged();
|
this->clearAndFocusEdit();
|
||||||
// });
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
MySearchEdit::~MySearchEdit()
|
MySearchEdit::~MySearchEdit()
|
||||||
{
|
{
|
||||||
m_animation->deleteLater();
|
m_animation->deleteLater();
|
||||||
|
delete m_edit;
|
||||||
|
delete m_searchBtn;
|
||||||
|
delete m_placeHolder;
|
||||||
|
delete m_clearBtn;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString MySearchEdit::text() const
|
const QString MySearchEdit::searchedText() const
|
||||||
{
|
{
|
||||||
return m_edit->text();
|
return m_edit->text();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MySearchEdit::clearAndFocusEdit()
|
||||||
|
{
|
||||||
|
this->clearEdit();
|
||||||
|
this->m_edit->setFocus();
|
||||||
|
}
|
||||||
|
|
||||||
void MySearchEdit::clearEdit()
|
void MySearchEdit::clearEdit()
|
||||||
{
|
{
|
||||||
m_edit->clear();
|
m_edit->clear();
|
||||||
// this->setStyleSheet("QFrame{background-color:#00376a;border-radius:0px;}");
|
this->setStyleSheet("QFrame{background-color:#00376a;border-radius:0px;}");
|
||||||
this->setStyleSheet("QFrame{background-color:rgb(0, 55, 106, 127);border-radius:0px;}");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MySearchEdit::mousePressEvent(QMouseEvent *event)
|
void MySearchEdit::mousePressEvent(QMouseEvent *event)
|
||||||
|
@ -102,6 +103,7 @@ bool MySearchEdit::eventFilter(QObject *object, QEvent *event)
|
||||||
if (object == m_edit && event->type() == QEvent::FocusOut && m_edit->text().isEmpty()) {
|
if (object == m_edit && event->type() == QEvent::FocusOut && m_edit->text().isEmpty()) {
|
||||||
auto focusEvent = dynamic_cast<QFocusEvent *>(event);
|
auto focusEvent = dynamic_cast<QFocusEvent *>(event);
|
||||||
if (focusEvent && focusEvent->reason() != Qt::PopupFocusReason) {
|
if (focusEvent && focusEvent->reason() != Qt::PopupFocusReason) {
|
||||||
|
// m_placeHolder->show();
|
||||||
m_animation->stop();
|
m_animation->stop();
|
||||||
m_animation->setStartValue(m_edit->width());
|
m_animation->setStartValue(m_edit->width());
|
||||||
m_animation->setEndValue(0);
|
m_animation->setEndValue(0);
|
||||||
|
@ -110,7 +112,6 @@ bool MySearchEdit::eventFilter(QObject *object, QEvent *event)
|
||||||
connect(m_animation, &QPropertyAnimation::finished, m_placeHolder, &QLabel::show);
|
connect(m_animation, &QPropertyAnimation::finished, m_placeHolder, &QLabel::show);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return QFrame::eventFilter(object, event);
|
return QFrame::eventFilter(object, event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -127,10 +128,20 @@ void MySearchEdit::setEditFocus()
|
||||||
m_animation->start();
|
m_animation->start();
|
||||||
m_placeHolder->hide();
|
m_placeHolder->hide();
|
||||||
m_edit->setFocus();
|
m_edit->setFocus();
|
||||||
// this->setStyleSheet("QFrame{background-color:#00376a;border:1px solid #47ccf3;border-radius:0px;}");
|
this->setStyleSheet("QFrame{background-color:#00376a;border:1px solid #47ccf3;border-radius:0px;}");
|
||||||
this->setStyleSheet("QFrame{background-color:rgb(0, 55, 106, 127);border:1px solid #47ccf3;border-radius:0px;}");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MySearchEdit::setPlaceHolder(const QString &text)
|
||||||
|
{
|
||||||
|
m_placeHolder->setText(text);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MySearchEdit::setText(const QString & text)
|
||||||
|
{
|
||||||
|
if (m_edit) {
|
||||||
|
m_edit->setText(text);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
QLineEdit *MySearchEdit::getLineEdit() const
|
QLineEdit *MySearchEdit::getLineEdit() const
|
||||||
{
|
{
|
||||||
|
@ -148,13 +159,9 @@ bool MySearchEdit::event(QEvent *event)
|
||||||
if (event->type() == QEvent::FocusIn) {
|
if (event->type() == QEvent::FocusIn) {
|
||||||
const QFocusEvent *ev = static_cast<QFocusEvent*>(event);
|
const QFocusEvent *ev = static_cast<QFocusEvent*>(event);
|
||||||
|
|
||||||
if (ev->reason() == Qt::TabFocusReason
|
if (ev->reason() == Qt::TabFocusReason || ev->reason() == Qt::BacktabFocusReason || ev->reason() == Qt::OtherFocusReason || ev->reason() == Qt::ShortcutFocusReason) {
|
||||||
|| ev->reason() == Qt::BacktabFocusReason
|
|
||||||
|| ev->reason() == Qt::OtherFocusReason
|
|
||||||
|| ev->reason() == Qt::ShortcutFocusReason) {
|
|
||||||
setEditFocus();
|
setEditFocus();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return QFrame::event(event);
|
return QFrame::event(event);
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,16 +16,15 @@ public:
|
||||||
explicit MySearchEdit(QWidget *parent = 0);
|
explicit MySearchEdit(QWidget *parent = 0);
|
||||||
~MySearchEdit();
|
~MySearchEdit();
|
||||||
|
|
||||||
void setPlaceHolder(const QString &text) {m_placeHolder->setText(text);}
|
void clearAndFocusEdit();
|
||||||
QSize sizeHint() const {return m_size;}
|
void setPlaceHolder(const QString &text);
|
||||||
QSize minimumSizeHint() const {return m_size;}
|
const QString searchedText() const;
|
||||||
const QString text() const;
|
|
||||||
QLineEdit *getLineEdit() const;
|
QLineEdit *getLineEdit() const;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void setEditFocus();
|
|
||||||
void setText(const QString & text) {if (m_edit) m_edit->setText(text);}
|
|
||||||
void clearEdit();
|
void clearEdit();
|
||||||
|
void setEditFocus();
|
||||||
|
void setText(const QString & text);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void textChanged();
|
void textChanged();
|
||||||
|
@ -38,14 +37,14 @@ protected:
|
||||||
bool eventFilter(QObject *object, QEvent *event);
|
bool eventFilter(QObject *object, QEvent *event);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
QPropertyAnimation *m_animation = nullptr;
|
||||||
|
QEasingCurve m_showCurve;
|
||||||
|
QEasingCurve m_hideCurve;
|
||||||
QSize m_size;
|
QSize m_size;
|
||||||
QLineEdit *m_edit;
|
QLineEdit *m_edit = nullptr;
|
||||||
QLabel *m_searchBtn;
|
QLabel *m_searchBtn = nullptr;
|
||||||
QLabel *m_placeHolder;
|
QLabel *m_placeHolder = nullptr;
|
||||||
MyTristateButton *m_clearBtn;
|
MyTristateButton *m_clearBtn = nullptr;
|
||||||
QPropertyAnimation *m_animation;
|
|
||||||
QEasingCurve m_showCurve = QEasingCurve::OutCubic;
|
|
||||||
QEasingCurve m_hideCurve = QEasingCurve::InCubic;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MYSEARCHEDIT_H
|
#endif // MYSEARCHEDIT_H
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
#include <QSlider>
|
#include <QSlider>
|
||||||
#include <QButtonGroup>
|
#include <QButtonGroup>
|
||||||
|
|
||||||
EnergyWidget::EnergyWidget(QWidget *parent, /*SessionDispatcher *proxy, */QString cur_desktop, bool has_battery) :
|
EnergyWidget::EnergyWidget(QStringList cpulist, QString cpu, QString cur_desktop, bool has_battery, QWidget *parent) :
|
||||||
SettingModulePage(parent),desktop(cur_desktop)
|
SettingModulePage(parent),desktop(cur_desktop)
|
||||||
{
|
{
|
||||||
gamma_label = new QLabel();
|
gamma_label = new QLabel();
|
||||||
|
@ -50,7 +50,6 @@ EnergyWidget::EnergyWidget(QWidget *parent, /*SessionDispatcher *proxy, */QStrin
|
||||||
lock_delay_label = new QLabel();
|
lock_delay_label = new QLabel();
|
||||||
lock_delay_combo = new QComboBox();
|
lock_delay_combo = new QComboBox();
|
||||||
|
|
||||||
|
|
||||||
critical_low_label = new QLabel();
|
critical_low_label = new QLabel();
|
||||||
suspend_low_radio = new QRadioButton();
|
suspend_low_radio = new QRadioButton();
|
||||||
shutdown_radio = new QRadioButton();
|
shutdown_radio = new QRadioButton();
|
||||||
|
@ -90,7 +89,6 @@ EnergyWidget::EnergyWidget(QWidget *parent, /*SessionDispatcher *proxy, */QStrin
|
||||||
sleep_ac_display_label = new QLabel();
|
sleep_ac_display_label = new QLabel();
|
||||||
sleep_ac_display_combo = new QComboBox();
|
sleep_ac_display_combo = new QComboBox();
|
||||||
|
|
||||||
|
|
||||||
if (this->desktop == "mate" || this->desktop == "MATE" || this->desktop == "UKUI" || this->desktop == "ukui") {
|
if (this->desktop == "mate" || this->desktop == "MATE" || this->desktop == "UKUI" || this->desktop == "ukui") {
|
||||||
brightness_label->hide();
|
brightness_label->hide();
|
||||||
brightness_value_label->hide();
|
brightness_value_label->hide();
|
||||||
|
@ -134,6 +132,8 @@ EnergyWidget::EnergyWidget(QWidget *parent, /*SessionDispatcher *proxy, */QStrin
|
||||||
sleep_battery_display_label->setFixedWidth(260);
|
sleep_battery_display_label->setFixedWidth(260);
|
||||||
sleep_ac_display_label->setFixedWidth(260);
|
sleep_ac_display_label->setFixedWidth(260);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
QHBoxLayout *layout0 = new QHBoxLayout();
|
QHBoxLayout *layout0 = new QHBoxLayout();
|
||||||
layout0->setSpacing(10);
|
layout0->setSpacing(10);
|
||||||
layout0->addWidget(gamma_label);
|
layout0->addWidget(gamma_label);
|
||||||
|
@ -200,28 +200,108 @@ EnergyWidget::EnergyWidget(QWidget *parent, /*SessionDispatcher *proxy, */QStrin
|
||||||
layout11->addWidget(sleep_ac_display_combo);
|
layout11->addWidget(sleep_ac_display_combo);
|
||||||
layout11->addStretch();
|
layout11->addStretch();
|
||||||
|
|
||||||
QVBoxLayout *layout = new QVBoxLayout();
|
m_layout = new QVBoxLayout(this);
|
||||||
layout->addLayout(layout0);
|
m_layout->setSpacing(10);
|
||||||
layout->addLayout(layout1);
|
m_layout->setContentsMargins(20, 20, 0, 0);
|
||||||
layout->addLayout(layout2);
|
|
||||||
layout->addLayout(layout3);
|
m_layout->addLayout(layout0);
|
||||||
layout->addLayout(layout4);
|
m_layout->addLayout(layout1);
|
||||||
layout->addLayout(layout5);
|
m_layout->addLayout(layout2);
|
||||||
layout->addLayout(layout6);
|
m_layout->addLayout(layout3);
|
||||||
layout->addLayout(layout7);
|
m_layout->addLayout(layout4);
|
||||||
layout->addLayout(layout8);
|
m_layout->addLayout(layout5);
|
||||||
layout->addLayout(layout9);
|
m_layout->addLayout(layout6);
|
||||||
layout->addLayout(layout10);
|
m_layout->addLayout(layout7);
|
||||||
layout->addLayout(layout11);
|
m_layout->addLayout(layout8);
|
||||||
layout->addStretch();
|
m_layout->addLayout(layout9);
|
||||||
setLayout(layout);
|
m_layout->addLayout(layout10);
|
||||||
layout->setSpacing(10);
|
m_layout->addLayout(layout11);
|
||||||
layout->setContentsMargins(20, 20, 0, 0);
|
|
||||||
|
//kobe reset cpu mode
|
||||||
|
if (!cpulist.isEmpty()) {
|
||||||
|
// qDebug() << cpulist;
|
||||||
|
// qDebug() << cpu;
|
||||||
|
QLabel *cpu_label = new QLabel();
|
||||||
|
cpu_label->setText(tr("CPU FM mode:"));
|
||||||
|
QHBoxLayout *cpu_layout = new QHBoxLayout();
|
||||||
|
cpu_layout->setSpacing(10);
|
||||||
|
cpu_layout->addWidget(cpu_label);
|
||||||
|
QButtonGroup *cpuGroup = new QButtonGroup();
|
||||||
|
|
||||||
|
QList<QString>::Iterator it = cpulist.begin(), itend = cpulist.end();
|
||||||
|
for(;it != itend; it++) {
|
||||||
|
if(*it == "ondemand") {
|
||||||
|
QRadioButton *ondemand_radio = new QRadioButton();
|
||||||
|
ondemand_radio->setFocusPolicy(Qt::NoFocus);
|
||||||
|
ondemand_radio->setText(tr("Ondemand"));
|
||||||
|
ondemand_radio->setObjectName("ondemandradio");
|
||||||
|
ondemand_radio->setChecked(false);
|
||||||
|
cpuGroup->addButton(ondemand_radio);
|
||||||
|
cpu_layout->addWidget(ondemand_radio);
|
||||||
|
connect(ondemand_radio, SIGNAL(clicked()), this, SLOT(onCpuRadioButtonClicked()));
|
||||||
|
}
|
||||||
|
else if(*it == "powersave") {
|
||||||
|
QRadioButton *powersave_radio = new QRadioButton();
|
||||||
|
powersave_radio->setFocusPolicy(Qt::NoFocus);
|
||||||
|
powersave_radio->setText(tr("Powersave"));
|
||||||
|
powersave_radio->setObjectName("powersaveradio");
|
||||||
|
powersave_radio->setChecked(false);
|
||||||
|
cpuGroup->addButton(powersave_radio);
|
||||||
|
cpu_layout->addWidget(powersave_radio);
|
||||||
|
connect(powersave_radio, SIGNAL(clicked()), this, SLOT(onCpuRadioButtonClicked()));
|
||||||
|
}
|
||||||
|
else if(*it == "performance") {
|
||||||
|
QRadioButton *performance_radio = new QRadioButton();
|
||||||
|
performance_radio->setFocusPolicy(Qt::NoFocus);
|
||||||
|
performance_radio->setText(tr("Performance"));
|
||||||
|
performance_radio->setObjectName("performanceradio");
|
||||||
|
performance_radio->setChecked(false);
|
||||||
|
cpuGroup->addButton(performance_radio);
|
||||||
|
cpu_layout->addWidget(performance_radio);
|
||||||
|
connect(performance_radio, SIGNAL(clicked()), this, SLOT(onCpuRadioButtonClicked()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cpu_layout->addStretch();
|
||||||
|
m_layout->addLayout(cpu_layout);
|
||||||
|
|
||||||
|
// for (auto cpuMode : cpulist)
|
||||||
|
foreach (QAbstractButton *absbutton, cpuGroup->buttons()) {
|
||||||
|
QRadioButton *radio = qobject_cast<QRadioButton*>(absbutton);
|
||||||
|
if (radio) {
|
||||||
|
QString obj_name = radio->objectName();
|
||||||
|
if(obj_name == "ondemandradio") {
|
||||||
|
if(cpu == "ondemand") {
|
||||||
|
radio->setChecked(true);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
radio->setChecked(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(obj_name == "powersaveradio") {
|
||||||
|
if(cpu == "powersave") {
|
||||||
|
radio->setChecked(true);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
radio->setChecked(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(obj_name == "performanceradio") {
|
||||||
|
if(cpu == "performance") {
|
||||||
|
radio->setChecked(true);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
radio->setChecked(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
m_layout->addStretch();
|
||||||
|
|
||||||
// this->initSettingData();
|
// this->initSettingData();
|
||||||
this->setLanguage();
|
this->setLanguage();
|
||||||
|
|
||||||
|
|
||||||
// iface = new QDBusInterface("org.gnome.SettingsDaemon",
|
// iface = new QDBusInterface("org.gnome.SettingsDaemon",
|
||||||
// "/org/gnome/SettingsDaemon/Power",
|
// "/org/gnome/SettingsDaemon/Power",
|
||||||
// "org.gnome.SettingsDaemon.Power.Screen",
|
// "org.gnome.SettingsDaemon.Power.Screen",
|
||||||
|
@ -346,6 +426,13 @@ EnergyWidget::~EnergyWidget()
|
||||||
delete sleep_ac_display_combo;
|
delete sleep_ac_display_combo;
|
||||||
sleep_ac_display_combo = NULL;
|
sleep_ac_display_combo = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QLayoutItem *child;
|
||||||
|
while ((child = m_layout->takeAt(0)) != 0) {
|
||||||
|
if (child->widget())
|
||||||
|
child->widget()->deleteLater();
|
||||||
|
delete child;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QString EnergyWidget::settingModuleName()
|
QString EnergyWidget::settingModuleName()
|
||||||
|
@ -775,7 +862,8 @@ void EnergyWidget::onSendLockAndSleepData(bool lockEnabled, const QString &lock_
|
||||||
sleep_ac_combo->setCurrentIndex(initIndex4);
|
sleep_ac_combo->setCurrentIndex(initIndex4);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EnergyWidget::initConnect() {
|
void EnergyWidget::initConnect()
|
||||||
|
{
|
||||||
connect(gamma_slider, SIGNAL(valueChanged(double)), this, SLOT(setScreenGammaValue(double)));
|
connect(gamma_slider, SIGNAL(valueChanged(double)), this, SLOT(setScreenGammaValue(double)));
|
||||||
connect(brightness_slider, SIGNAL(valueChanged(int)), this, SLOT(setBrightnessValue(int)));
|
connect(brightness_slider, SIGNAL(valueChanged(int)), this, SLOT(setBrightnessValue(int)));
|
||||||
// connect(idle_delay_combo, SIGNAL(currentIndexChanged(QString)), this, SLOT(setIdleDelay(QString)));
|
// connect(idle_delay_combo, SIGNAL(currentIndexChanged(QString)), this, SLOT(setIdleDelay(QString)));
|
||||||
|
@ -910,6 +998,15 @@ void EnergyWidget::setLockDelay(int index)
|
||||||
//// sessionproxy->set_current_lock_delay_qt(value.toInt());
|
//// sessionproxy->set_current_lock_delay_qt(value.toInt());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EnergyWidget::onCpuRadioButtonClicked()
|
||||||
|
{
|
||||||
|
QRadioButton *button = qobject_cast<QRadioButton*>(this->sender());
|
||||||
|
if (button) {
|
||||||
|
QString obj_name = button->objectName();
|
||||||
|
emit setCurrentCpuMode(obj_name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void EnergyWidget::setRadioButtonRowStatus()
|
void EnergyWidget::setRadioButtonRowStatus()
|
||||||
{
|
{
|
||||||
QObject *obj = sender(); //返回发出信号的对象,用QObject类型接收
|
QObject *obj = sender(); //返回发出信号的对象,用QObject类型接收
|
||||||
|
|
|
@ -32,6 +32,7 @@ class QComboBox;
|
||||||
class QDoubleSpinBox;
|
class QDoubleSpinBox;
|
||||||
class QSlider;
|
class QSlider;
|
||||||
class QRadioButton;
|
class QRadioButton;
|
||||||
|
class QVBoxLayout;
|
||||||
|
|
||||||
#include "settingmodulelpage.h"
|
#include "settingmodulelpage.h"
|
||||||
|
|
||||||
|
@ -39,7 +40,7 @@ class EnergyWidget : public SettingModulePage
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit EnergyWidget(QWidget *parent = 0, /*SessionDispatcher *proxy = 0,*/ QString cur_desktop = "", bool has_battery = false);
|
explicit EnergyWidget(QStringList cpulist, QString cpu, QString cur_desktop, bool has_battery = false, QWidget *parent = 0);
|
||||||
~EnergyWidget();
|
~EnergyWidget();
|
||||||
void setLanguage();
|
void setLanguage();
|
||||||
void initConnect();
|
void initConnect();
|
||||||
|
@ -54,6 +55,7 @@ public slots:
|
||||||
void setLockEnabled();
|
void setLockEnabled();
|
||||||
// void setLockDelay(QString value);
|
// void setLockDelay(QString value);
|
||||||
void setLockDelay(int index);
|
void setLockDelay(int index);
|
||||||
|
void onCpuRadioButtonClicked();
|
||||||
void setRadioButtonRowStatus();
|
void setRadioButtonRowStatus();
|
||||||
void setSleepTimeoutBattery(int index);
|
void setSleepTimeoutBattery(int index);
|
||||||
void setSleepTimeoutAC(int index);
|
void setSleepTimeoutAC(int index);
|
||||||
|
@ -63,8 +65,6 @@ public slots:
|
||||||
void onSendIdleAndGammaData(double gamma, const QStringList &aclist, int brightnessValue, const QString &sleepTimeoutDisplayBattery, const QString &sleepTimeoutFisplayAC, const QString &idle_delay, const QStringList &idledelaylist);
|
void onSendIdleAndGammaData(double gamma, const QStringList &aclist, int brightnessValue, const QString &sleepTimeoutDisplayBattery, const QString &sleepTimeoutFisplayAC, const QString &idle_delay, const QStringList &idledelaylist);
|
||||||
void onSendLockAndSleepData(bool lockEnabled, const QString &lock_delay, const QStringList &lockdelaylist, const QString &critical_low, const QString &laptop_battery, const QString &laptop_ac, const QString &sleepTimeoutBattery, const QStringList &batterylist, const QString &sleepTimeoutAc);
|
void onSendLockAndSleepData(bool lockEnabled, const QString &lock_delay, const QStringList &lockdelaylist, const QString &critical_low, const QString &laptop_battery, const QString &laptop_ac, const QString &sleepTimeoutBattery, const QStringList &batterylist, const QString &sleepTimeoutAc);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void requestPowerAndBatteryData();
|
void requestPowerAndBatteryData();
|
||||||
void resetScreenGammaValue(double value);
|
void resetScreenGammaValue(double value);
|
||||||
|
@ -79,6 +79,7 @@ signals:
|
||||||
void resetSleepTimeoutAC(int index, int value);
|
void resetSleepTimeoutAC(int index, int value);
|
||||||
void resetSleepTimeoutDisplayBattery(int index, int value);
|
void resetSleepTimeoutDisplayBattery(int index, int value);
|
||||||
void resetSleepTimeoutDisplayAC(int index, int value);
|
void resetSleepTimeoutDisplayAC(int index, int value);
|
||||||
|
void setCurrentCpuMode(const QString &mode);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString desktop;
|
QString desktop;
|
||||||
|
@ -119,6 +120,7 @@ private:
|
||||||
QComboBox *sleep_ac_display_combo;
|
QComboBox *sleep_ac_display_combo;
|
||||||
|
|
||||||
QStringList m_aclist;
|
QStringList m_aclist;
|
||||||
|
QVBoxLayout *m_layout = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // ENERGYWIDGET_H
|
#endif // ENERGYWIDGET_H
|
||||||
|
|
|
@ -399,7 +399,6 @@ void MenuWidget::onSendMatePanelIconValue(int topIconSize, int bottomIconSize, b
|
||||||
|
|
||||||
void MenuWidget::onSendUnityIconValue(int iconSize, bool iconHide, bool desktopIconShowed, double launcherTransparency, int iconColourIndex, const QStringList &colourlist)
|
void MenuWidget::onSendUnityIconValue(int iconSize, bool iconHide, bool desktopIconShowed, double launcherTransparency, int iconColourIndex, const QStringList &colourlist)
|
||||||
{
|
{
|
||||||
qDebug() << "MenuWidget::onSendUnityIconValue============";
|
|
||||||
size_slider->setValue(iconSize);
|
size_slider->setValue(iconSize);
|
||||||
size_value_label->setText(QString::number(iconSize));
|
size_value_label->setText(QString::number(iconSize));
|
||||||
hide_switcher->switchedOn = iconHide;
|
hide_switcher->switchedOn = iconHide;
|
||||||
|
|
|
@ -64,6 +64,7 @@ void DataWorker::initDataWorker()
|
||||||
sessioninterface = new SessionDispatcher;
|
sessioninterface = new SessionDispatcher;
|
||||||
ThreadPool::Instance()->moveToNewThread(sessioninterface);
|
ThreadPool::Instance()->moveToNewThread(sessioninterface);
|
||||||
this->m_existBattery = sessioninterface->judge_power_is_exists_qt();
|
this->m_existBattery = sessioninterface->judge_power_is_exists_qt();
|
||||||
|
|
||||||
connect(sessioninterface, SIGNAL(string_value_notify(QString,QString)), this, SIGNAL(string_value_notify(QString,QString)));
|
connect(sessioninterface, SIGNAL(string_value_notify(QString,QString)), this, SIGNAL(string_value_notify(QString,QString)));
|
||||||
connect(sessioninterface, SIGNAL(bool_value_notify(QString,bool)), this, SIGNAL(bool_value_notify(QString,bool)));
|
connect(sessioninterface, SIGNAL(bool_value_notify(QString,bool)), this, SIGNAL(bool_value_notify(QString,bool)));
|
||||||
connect(sessioninterface, SIGNAL(int_value_notify(QString,int)), this, SIGNAL(int_value_notify(QString,int)));
|
connect(sessioninterface, SIGNAL(int_value_notify(QString,int)), this, SIGNAL(int_value_notify(QString,int)));
|
||||||
|
@ -85,6 +86,8 @@ void DataWorker::initDataWorker()
|
||||||
systemThread->start();*/
|
systemThread->start();*/
|
||||||
|
|
||||||
this->m_existSensor = systeminterface->judge_sensors_exists_qt();
|
this->m_existSensor = systeminterface->judge_sensors_exists_qt();
|
||||||
|
this->m_cpulist = systeminterface->get_cpufreq_scaling_governer_list_qt();
|
||||||
|
this->m_currentCpuMode = systeminterface->get_current_cpufreq_scaling_governer_qt();
|
||||||
|
|
||||||
connect(systeminterface, SIGNAL(finishCleanWorkMain(QString)), this, SIGNAL(finishCleanWorkMain(QString)));
|
connect(systeminterface, SIGNAL(finishCleanWorkMain(QString)), this, SIGNAL(finishCleanWorkMain(QString)));
|
||||||
connect(systeminterface, SIGNAL(finishCleanWorkMainError(QString)), this, SIGNAL(finishCleanWorkMainError(QString)));
|
connect(systeminterface, SIGNAL(finishCleanWorkMainError(QString)), this, SIGNAL(finishCleanWorkMainError(QString)));
|
||||||
|
@ -103,6 +106,16 @@ void DataWorker::doWork()
|
||||||
emit dataLoadFinished();
|
emit dataLoadFinished();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const QStringList DataWorker::cpuModeList() const
|
||||||
|
{
|
||||||
|
return this->m_cpulist;
|
||||||
|
}
|
||||||
|
|
||||||
|
const QString DataWorker::cpuCurrentMode() const
|
||||||
|
{
|
||||||
|
return this->m_currentCpuMode;
|
||||||
|
}
|
||||||
|
|
||||||
bool DataWorker::deleteAppointedFile(QString filename)
|
bool DataWorker::deleteAppointedFile(QString filename)
|
||||||
{
|
{
|
||||||
bool result = systeminterface->delete_file_qt(filename);
|
bool result = systeminterface->delete_file_qt(filename);
|
||||||
|
@ -1063,6 +1076,19 @@ void DataWorker::onResetSleepTimeoutDisplayAC(int index, int value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DataWorker::onSetCurrentCpuMode(const QString &mode)
|
||||||
|
{
|
||||||
|
// qDebug() << "set cpu mode="<<mode;
|
||||||
|
if(mode == "ondemandradio") {
|
||||||
|
systeminterface->adjust_cpufreq_scaling_governer_qt("ondemand");
|
||||||
|
}
|
||||||
|
else if(mode == "powersaveradio") {
|
||||||
|
systeminterface->adjust_cpufreq_scaling_governer_qt("powersave");
|
||||||
|
}
|
||||||
|
else if(mode == "performanceradio") {
|
||||||
|
systeminterface->adjust_cpufreq_scaling_governer_qt("performance");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//-------------------file manager
|
//-------------------file manager
|
||||||
|
|
|
@ -40,6 +40,9 @@ public:
|
||||||
bool isBatteryExist() { return m_existBattery; }
|
bool isBatteryExist() { return m_existBattery; }
|
||||||
bool isSensorExist() { return m_existSensor; }
|
bool isSensorExist() { return m_existSensor; }
|
||||||
|
|
||||||
|
const QStringList cpuModeList() const;
|
||||||
|
const QString cpuCurrentMode() const;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void doWork();
|
void doWork();
|
||||||
void updateSensorValue();
|
void updateSensorValue();
|
||||||
|
@ -190,6 +193,7 @@ public slots:
|
||||||
void onResetSleepTimeoutAC(int index, int value);
|
void onResetSleepTimeoutAC(int index, int value);
|
||||||
void onResetSleepTimeoutDisplayBattery(int index, int value);
|
void onResetSleepTimeoutDisplayBattery(int index, int value);
|
||||||
void onResetSleepTimeoutDisplayAC(int index, int value);
|
void onResetSleepTimeoutDisplayAC(int index, int value);
|
||||||
|
void onSetCurrentCpuMode(const QString &mode);
|
||||||
|
|
||||||
//file manager
|
//file manager
|
||||||
void onRequestFileManagerData();
|
void onRequestFileManagerData();
|
||||||
|
@ -331,6 +335,8 @@ private:
|
||||||
|
|
||||||
bool m_existBattery;
|
bool m_existBattery;
|
||||||
bool m_existSensor;
|
bool m_existSensor;
|
||||||
|
QStringList m_cpulist;
|
||||||
|
QString m_currentCpuMode;
|
||||||
|
|
||||||
QTimer *m_sensorTimer = nullptr;
|
QTimer *m_sensorTimer = nullptr;
|
||||||
};
|
};
|
||||||
|
|
|
@ -326,6 +326,8 @@ void MainWindow::onInitDataFinished()
|
||||||
{
|
{
|
||||||
this->battery = m_dataWorker->isBatteryExist();
|
this->battery = m_dataWorker->isBatteryExist();
|
||||||
this->sensor = m_dataWorker->isSensorExist();
|
this->sensor = m_dataWorker->isSensorExist();
|
||||||
|
this->m_cpulist = m_dataWorker->cpuModeList();
|
||||||
|
this->m_currentCpuMode = m_dataWorker->cpuCurrentMode();
|
||||||
|
|
||||||
this->displayMainWindow();
|
this->displayMainWindow();
|
||||||
|
|
||||||
|
@ -350,8 +352,6 @@ void MainWindow::onInitDataFinished()
|
||||||
connect(m_dataWorker, SIGNAL(finishCleanWorkMainError(QString)), home_action_widget, SLOT(finishCleanError(QString)));
|
connect(m_dataWorker, SIGNAL(finishCleanWorkMainError(QString)), home_action_widget, SLOT(finishCleanError(QString)));
|
||||||
connect(m_dataWorker, SIGNAL(quickCleanProcess(QString,QString)), home_action_widget, SLOT(getCleaningMessage(QString,QString)));
|
connect(m_dataWorker, SIGNAL(quickCleanProcess(QString,QString)), home_action_widget, SLOT(getCleaningMessage(QString,QString)));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//theme
|
//theme
|
||||||
connect(setting_widget, SIGNAL(changeSystemTheme(QString)), m_dataWorker, SLOT(onChangeSystemTheme(QString)));
|
connect(setting_widget, SIGNAL(changeSystemTheme(QString)), m_dataWorker, SLOT(onChangeSystemTheme(QString)));
|
||||||
connect(setting_widget, SIGNAL(requestThemeData()), m_dataWorker, SLOT(onRequestThemeData()));
|
connect(setting_widget, SIGNAL(requestThemeData()), m_dataWorker, SLOT(onRequestThemeData()));
|
||||||
|
@ -368,7 +368,6 @@ void MainWindow::onInitDataFinished()
|
||||||
connect(setting_widget, SIGNAL(displayRecycleBinIcon(bool)), m_dataWorker, SLOT(onDisplayRecycleBinIcon(bool)));
|
connect(setting_widget, SIGNAL(displayRecycleBinIcon(bool)), m_dataWorker, SLOT(onDisplayRecycleBinIcon(bool)));
|
||||||
connect(setting_widget, SIGNAL(displayDiskIcon(bool)), m_dataWorker, SLOT(onDisplayDiskIcon(bool)));
|
connect(setting_widget, SIGNAL(displayDiskIcon(bool)), m_dataWorker, SLOT(onDisplayDiskIcon(bool)));
|
||||||
|
|
||||||
|
|
||||||
//mouse
|
//mouse
|
||||||
connect(setting_widget, SIGNAL(requestMouseData()), m_dataWorker, SLOT(onRequestMouseData()));
|
connect(setting_widget, SIGNAL(requestMouseData()), m_dataWorker, SLOT(onRequestMouseData()));
|
||||||
connect(m_dataWorker, SIGNAL(sendMouseThemeAndCusorSize(QString,QStringList,int)), setting_widget, SIGNAL(sendMouseThemeAndCusorSize(QString,QStringList,int)));
|
connect(m_dataWorker, SIGNAL(sendMouseThemeAndCusorSize(QString,QStringList,int)), setting_widget, SIGNAL(sendMouseThemeAndCusorSize(QString,QStringList,int)));
|
||||||
|
@ -404,7 +403,6 @@ void MainWindow::onInitDataFinished()
|
||||||
connect(setting_widget, SIGNAL(resetShowIcon(bool)), m_dataWorker, SLOT(onResetShowIcon(bool)));
|
connect(setting_widget, SIGNAL(resetShowIcon(bool)), m_dataWorker, SLOT(onResetShowIcon(bool)));
|
||||||
connect(setting_widget, SIGNAL(resetShowPlaces(bool)), m_dataWorker, SLOT(onResetShowPlaces(bool)));
|
connect(setting_widget, SIGNAL(resetShowPlaces(bool)), m_dataWorker, SLOT(onResetShowPlaces(bool)));
|
||||||
|
|
||||||
|
|
||||||
//launcher menu
|
//launcher menu
|
||||||
connect(setting_widget, SIGNAL(requestMateOrUnityMenuData(bool)), m_dataWorker, SLOT(onRequestMateOrUnityMenuData(bool)));
|
connect(setting_widget, SIGNAL(requestMateOrUnityMenuData(bool)), m_dataWorker, SLOT(onRequestMateOrUnityMenuData(bool)));
|
||||||
connect(m_dataWorker, SIGNAL(sendMatePanelIconValue(int,int,bool,bool)), setting_widget, SIGNAL(sendMatePanelIconValue(int,int,bool,bool)));
|
connect(m_dataWorker, SIGNAL(sendMatePanelIconValue(int,int,bool,bool)), setting_widget, SIGNAL(sendMatePanelIconValue(int,int,bool,bool)));
|
||||||
|
@ -438,7 +436,6 @@ void MainWindow::onInitDataFinished()
|
||||||
connect(setting_widget, SIGNAL(resetMouseRightClick(QString)), m_dataWorker, SLOT(onResetMouseRightClick(QString)));
|
connect(setting_widget, SIGNAL(resetMouseRightClick(QString)), m_dataWorker, SLOT(onResetMouseRightClick(QString)));
|
||||||
connect(setting_widget, SIGNAL(resetWindowButtonLeftOrRightAlign(bool)), m_dataWorker, SLOT(onResetWindowButtonLeftOrRightAlign(bool)));
|
connect(setting_widget, SIGNAL(resetWindowButtonLeftOrRightAlign(bool)), m_dataWorker, SLOT(onResetWindowButtonLeftOrRightAlign(bool)));
|
||||||
|
|
||||||
|
|
||||||
//font
|
//font
|
||||||
connect(setting_widget, SIGNAL(requestFontData()), m_dataWorker, SLOT(onRequestFontData()));
|
connect(setting_widget, SIGNAL(requestFontData()), m_dataWorker, SLOT(onRequestFontData()));
|
||||||
connect(m_dataWorker, SIGNAL(sendFontValue(QString)), setting_widget, SIGNAL(sendFontValue(QString)));
|
connect(m_dataWorker, SIGNAL(sendFontValue(QString)), setting_widget, SIGNAL(sendFontValue(QString)));
|
||||||
|
@ -462,7 +459,6 @@ void MainWindow::onInitDataFinished()
|
||||||
connect(setting_widget, SIGNAL(restoreDocumentDefaultFont(bool)), m_dataWorker, SLOT(onRestoreDocumentDefaultFont(bool)));
|
connect(setting_widget, SIGNAL(restoreDocumentDefaultFont(bool)), m_dataWorker, SLOT(onRestoreDocumentDefaultFont(bool)));
|
||||||
connect(setting_widget, SIGNAL(restoreTitlebarDefaultFont(bool)), m_dataWorker, SLOT(onRestoreTitlebarDefaultFont(bool)));
|
connect(setting_widget, SIGNAL(restoreTitlebarDefaultFont(bool)), m_dataWorker, SLOT(onRestoreTitlebarDefaultFont(bool)));
|
||||||
|
|
||||||
|
|
||||||
//touchpad
|
//touchpad
|
||||||
connect(setting_widget, SIGNAL(requestMateOrUnityTouchpadData(bool)), m_dataWorker, SLOT(onRequestMateOrUnityTouchpadData(bool)));
|
connect(setting_widget, SIGNAL(requestMateOrUnityTouchpadData(bool)), m_dataWorker, SLOT(onRequestMateOrUnityTouchpadData(bool)));
|
||||||
connect(m_dataWorker, SIGNAL(sendTouchPadValue(bool,bool,QString,int,QString)), setting_widget, SIGNAL(sendTouchPadValue(bool,bool,QString,int,QString)));
|
connect(m_dataWorker, SIGNAL(sendTouchPadValue(bool,bool,QString,int,QString)), setting_widget, SIGNAL(sendTouchPadValue(bool,bool,QString,int,QString)));
|
||||||
|
@ -472,8 +468,6 @@ void MainWindow::onInitDataFinished()
|
||||||
connect(setting_widget, SIGNAL(setMateTouchscrollingMode(int)), m_dataWorker, SLOT(onSetMateTouchscrollingMode(int)));
|
connect(setting_widget, SIGNAL(setMateTouchscrollingMode(int)), m_dataWorker, SLOT(onSetMateTouchscrollingMode(int)));
|
||||||
connect(setting_widget, SIGNAL(setUnityTouchscrollingMode(int)), m_dataWorker, SLOT(onSetUnityTouchscrollingMode(int)));
|
connect(setting_widget, SIGNAL(setUnityTouchscrollingMode(int)), m_dataWorker, SLOT(onSetUnityTouchscrollingMode(int)));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//ac and battery
|
//ac and battery
|
||||||
connect(setting_widget, SIGNAL(requestPowerAndBatteryData()), m_dataWorker, SLOT(onRequestPowerAndBatteryData()));
|
connect(setting_widget, SIGNAL(requestPowerAndBatteryData()), m_dataWorker, SLOT(onRequestPowerAndBatteryData()));
|
||||||
connect(m_dataWorker, SIGNAL(sendIdleAndGammaData(double,QStringList,int,QString,QString,QString,QStringList)), setting_widget, SIGNAL(sendIdleAndGammaData(double,QStringList,int,QString,QString,QString,QStringList)));
|
connect(m_dataWorker, SIGNAL(sendIdleAndGammaData(double,QStringList,int,QString,QString,QString,QStringList)), setting_widget, SIGNAL(sendIdleAndGammaData(double,QStringList,int,QString,QString,QString,QStringList)));
|
||||||
|
@ -491,7 +485,7 @@ void MainWindow::onInitDataFinished()
|
||||||
connect(setting_widget, SIGNAL(resetSleepTimeoutAC(int,int)), m_dataWorker, SLOT(onResetSleepTimeoutAC(int,int)));
|
connect(setting_widget, SIGNAL(resetSleepTimeoutAC(int,int)), m_dataWorker, SLOT(onResetSleepTimeoutAC(int,int)));
|
||||||
connect(setting_widget, SIGNAL(resetSleepTimeoutDisplayBattery(int,int)), m_dataWorker, SLOT(onResetSleepTimeoutDisplayBattery(int,int)));
|
connect(setting_widget, SIGNAL(resetSleepTimeoutDisplayBattery(int,int)), m_dataWorker, SLOT(onResetSleepTimeoutDisplayBattery(int,int)));
|
||||||
connect(setting_widget, SIGNAL(resetSleepTimeoutDisplayAC(int,int)), m_dataWorker, SLOT(onResetSleepTimeoutDisplayAC(int,int)));
|
connect(setting_widget, SIGNAL(resetSleepTimeoutDisplayAC(int,int)), m_dataWorker, SLOT(onResetSleepTimeoutDisplayAC(int,int)));
|
||||||
|
connect(setting_widget, SIGNAL(setCurrentCpuMode(QString)), m_dataWorker, SLOT(onSetCurrentCpuMode(QString)));
|
||||||
|
|
||||||
//file manager
|
//file manager
|
||||||
connect(setting_widget, SIGNAL(requestFileManagerData()), m_dataWorker, SLOT(onRequestFileManagerData()));
|
connect(setting_widget, SIGNAL(requestFileManagerData()), m_dataWorker, SLOT(onRequestFileManagerData()));
|
||||||
|
@ -994,7 +988,6 @@ void MainWindow::initOtherPages()
|
||||||
connect(m_dataWorker, SIGNAL(tellCleanerMainStatus(QString, QString)), cleaner_action_widget, SLOT(showCleanerStatus(QString, QString)));
|
connect(m_dataWorker, SIGNAL(tellCleanerMainStatus(QString, QString)), cleaner_action_widget, SLOT(showCleanerStatus(QString, QString)));
|
||||||
connect(m_dataWorker, SIGNAL(sendCleanErrorSignal(QString)), cleaner_action_widget, SLOT(showCleanerError(QString)));
|
connect(m_dataWorker, SIGNAL(sendCleanErrorSignal(QString)), cleaner_action_widget, SLOT(showCleanerError(QString)));
|
||||||
|
|
||||||
|
|
||||||
connect(cleaner_widget, SIGNAL(startScanSystem(QMap<QString,QVariant>)), m_dataWorker, SLOT(onStartScanSystem(QMap<QString,QVariant>)));
|
connect(cleaner_widget, SIGNAL(startScanSystem(QMap<QString,QVariant>)), m_dataWorker, SLOT(onStartScanSystem(QMap<QString,QVariant>)));
|
||||||
connect(cleaner_widget, SIGNAL(startCleanSystem(QMap<QString,QVariant>)), m_dataWorker, SLOT(onStartCleanSystem(QMap<QString,QVariant>)));
|
connect(cleaner_widget, SIGNAL(startCleanSystem(QMap<QString,QVariant>)), m_dataWorker, SLOT(onStartCleanSystem(QMap<QString,QVariant>)));
|
||||||
|
|
||||||
|
@ -1013,7 +1006,6 @@ void MainWindow::initOtherPages()
|
||||||
// connect(sessioninterface, SIGNAL(tellCleanerDetailStatus(QString)), cleaner_action_widget, SLOT(showCleanReciveStatus(QString)));
|
// connect(sessioninterface, SIGNAL(tellCleanerDetailStatus(QString)), cleaner_action_widget, SLOT(showCleanReciveStatus(QString)));
|
||||||
// connect(sessioninterface, SIGNAL(tellCleanerDetailError(QString)), cleaner_action_widget, SLOT(showCleanReciveError(QString)));
|
// connect(sessioninterface, SIGNAL(tellCleanerDetailError(QString)), cleaner_action_widget, SLOT(showCleanReciveError(QString)));
|
||||||
|
|
||||||
|
|
||||||
connect(cleaner_action_widget, SIGNAL(sendScanSignal()),cleaner_widget, SIGNAL(transScanSignal()));
|
connect(cleaner_action_widget, SIGNAL(sendScanSignal()),cleaner_widget, SIGNAL(transScanSignal()));
|
||||||
connect(cleaner_widget, SIGNAL(tranActionAnimaitonSignal()),cleaner_action_widget, SLOT(displayAnimation()));
|
connect(cleaner_widget, SIGNAL(tranActionAnimaitonSignal()),cleaner_action_widget, SLOT(displayAnimation()));
|
||||||
connect(cleaner_widget, SIGNAL(tranScanOverSignal(bool)),cleaner_action_widget, SLOT(accordScanOverStatusToChange(bool)));
|
connect(cleaner_widget, SIGNAL(tranScanOverSignal(bool)),cleaner_action_widget, SLOT(accordScanOverStatusToChange(bool)));
|
||||||
|
@ -1090,7 +1082,7 @@ void MainWindow::initOtherPages()
|
||||||
|
|
||||||
|
|
||||||
if(setting_widget == NULL)
|
if(setting_widget == NULL)
|
||||||
setting_widget = new SettingWidget(this->desktop, this->battery);//20180101
|
setting_widget = new SettingWidget(this->m_cpulist, this->m_currentCpuMode, this->desktop, this->battery);//20180101
|
||||||
setting_widget->setParentWindow(this);
|
setting_widget->setParentWindow(this);
|
||||||
// setting_widget->setSessionDbusProxy(sessioninterface);
|
// setting_widget->setSessionDbusProxy(sessioninterface);
|
||||||
// setting_widget->setSystemDbusProxy(systeminterface);
|
// setting_widget->setSystemDbusProxy(systeminterface);
|
||||||
|
|
|
@ -159,6 +159,8 @@ private:
|
||||||
QString arch;
|
QString arch;
|
||||||
bool battery;
|
bool battery;
|
||||||
bool sensor;
|
bool sensor;
|
||||||
|
QStringList m_cpulist;
|
||||||
|
QString m_currentCpuMode;
|
||||||
QParallelAnimationGroup *spreadGroup;
|
QParallelAnimationGroup *spreadGroup;
|
||||||
QParallelAnimationGroup *gatherGroup;
|
QParallelAnimationGroup *gatherGroup;
|
||||||
PAGESTATUS status;
|
PAGESTATUS status;
|
||||||
|
|
|
@ -25,8 +25,12 @@
|
||||||
#include "../setting/settingmodel.h"
|
#include "../setting/settingmodel.h"
|
||||||
#include "../setting/settingdelegate.h"
|
#include "../setting/settingdelegate.h"
|
||||||
|
|
||||||
SettingWidget::SettingWidget(QString cur_desktop, bool has_battery, QWidget *parent) :
|
SettingWidget::SettingWidget(QStringList cpulist, QString cpu, QString cur_desktop, bool has_battery, QWidget *parent) :
|
||||||
QWidget(parent), desktop(cur_desktop), battery(has_battery)
|
QWidget(parent)
|
||||||
|
,m_cpuList(cpulist)
|
||||||
|
,m_currentCpu(cpu)
|
||||||
|
,desktop(cur_desktop)
|
||||||
|
,battery(has_battery)
|
||||||
{
|
{
|
||||||
this->setFixedSize(900, 403);
|
this->setFixedSize(900, 403);
|
||||||
// setStyleSheet("background-color: rgba(155, 255, 255, .238);");
|
// setStyleSheet("background-color: rgba(155, 255, 255, .238);");
|
||||||
|
@ -140,7 +144,7 @@ void SettingWidget::initUI(/*QString skin*/)
|
||||||
font_widget = new FontWidget(this, p_mainwindow, desktop, "");//TODO:read skin from ini file
|
font_widget = new FontWidget(this, p_mainwindow, desktop, "");//TODO:read skin from ini file
|
||||||
touchpad_widget = new TouchpadWidget(this, desktop);
|
touchpad_widget = new TouchpadWidget(this, desktop);
|
||||||
// deadpixel_widget = new DeadpixelWidget(this);
|
// deadpixel_widget = new DeadpixelWidget(this);
|
||||||
conserve_widget = new EnergyWidget(this, desktop, battery);
|
conserve_widget = new EnergyWidget(m_cpuList, m_currentCpu, desktop, battery, this);
|
||||||
nautilus_widget = new FileManagerWidget(this);
|
nautilus_widget = new FileManagerWidget(this);
|
||||||
stacked_widget->addWidget(theme_widget);
|
stacked_widget->addWidget(theme_widget);
|
||||||
stacked_widget->addWidget(icon_widget);
|
stacked_widget->addWidget(icon_widget);
|
||||||
|
@ -306,7 +310,7 @@ void SettingWidget::initUI(/*QString skin*/)
|
||||||
connect(conserve_widget, SIGNAL(resetSleepTimeoutAC(int,int)), this, SIGNAL(resetSleepTimeoutAC(int,int)));
|
connect(conserve_widget, SIGNAL(resetSleepTimeoutAC(int,int)), this, SIGNAL(resetSleepTimeoutAC(int,int)));
|
||||||
connect(conserve_widget, SIGNAL(resetSleepTimeoutDisplayBattery(int,int)), this, SIGNAL(resetSleepTimeoutDisplayBattery(int,int)));
|
connect(conserve_widget, SIGNAL(resetSleepTimeoutDisplayBattery(int,int)), this, SIGNAL(resetSleepTimeoutDisplayBattery(int,int)));
|
||||||
connect(conserve_widget, SIGNAL(resetSleepTimeoutDisplayAC(int,int)), this, SIGNAL(resetSleepTimeoutDisplayAC(int,int)));
|
connect(conserve_widget, SIGNAL(resetSleepTimeoutDisplayAC(int,int)), this, SIGNAL(resetSleepTimeoutDisplayAC(int,int)));
|
||||||
|
connect(conserve_widget, SIGNAL(setCurrentCpuMode(QString)), this, SIGNAL(setCurrentCpuMode(QString)));
|
||||||
|
|
||||||
//file manager
|
//file manager
|
||||||
connect(nautilus_widget, SIGNAL(requestFileManagerData()), this, SIGNAL(requestFileManagerData()));
|
connect(nautilus_widget, SIGNAL(requestFileManagerData()), this, SIGNAL(requestFileManagerData()));
|
||||||
|
|
|
@ -55,7 +55,7 @@ class SettingWidget : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit SettingWidget(QString cur_desktop = "", bool has_battery = false, QWidget *parent = 0);
|
explicit SettingWidget(QStringList cpulist, QString cpu, QString cur_desktop, bool has_battery = false, QWidget *parent = 0);
|
||||||
~SettingWidget();
|
~SettingWidget();
|
||||||
void setParentWindow(MainWindow* window) { p_mainwindow = window;}
|
void setParentWindow(MainWindow* window) { p_mainwindow = window;}
|
||||||
void initUI(/*QString skin*/);
|
void initUI(/*QString skin*/);
|
||||||
|
@ -199,6 +199,7 @@ signals:
|
||||||
void resetSleepTimeoutAC(int index, int value);
|
void resetSleepTimeoutAC(int index, int value);
|
||||||
void resetSleepTimeoutDisplayBattery(int index, int value);
|
void resetSleepTimeoutDisplayBattery(int index, int value);
|
||||||
void resetSleepTimeoutDisplayAC(int index, int value);
|
void resetSleepTimeoutDisplayAC(int index, int value);
|
||||||
|
void setCurrentCpuMode(const QString &mode);
|
||||||
|
|
||||||
//file manager
|
//file manager
|
||||||
void requestFileManagerData();
|
void requestFileManagerData();
|
||||||
|
@ -231,6 +232,8 @@ private:
|
||||||
MainWindow *p_mainwindow;
|
MainWindow *p_mainwindow;
|
||||||
QString desktop;
|
QString desktop;
|
||||||
bool battery;
|
bool battery;
|
||||||
|
QStringList m_cpuList;
|
||||||
|
QString m_currentCpu;
|
||||||
|
|
||||||
QStackedWidget *stacked_widget;
|
QStackedWidget *stacked_widget;
|
||||||
ThemeWidget *theme_widget;
|
ThemeWidget *theme_widget;
|
||||||
|
|
Loading…
Reference in New Issue