Skip to content

Commit

Permalink
fix(Proxy): Proxy
Browse files Browse the repository at this point in the history
Description: Proxy

Log: 【系统设置-网络】默认窗口大小下,代理页面开关“开启手动代理”功能引起详情内容跳动 #2
Task: http://172.17.66.192/biz/story-view-6381.html
  • Loading branch information
shilixiaoguai authored and Z-bin committed Aug 12, 2021
1 parent fccdf66 commit 06cf232
Show file tree
Hide file tree
Showing 11 changed files with 299 additions and 288 deletions.
39 changes: 0 additions & 39 deletions plugins/system/autoboot/addautoboot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,37 +59,6 @@ void AddAutoBoot::resetBeforeClose()
close();
}

bool AddAutoBoot::getFilename(GDir *dir,const char *Name)
{
QString filedir = QString(g_build_filename(g_get_user_config_dir(), "autostart", NULL))+"/";
const char *desktopName;
if (dir) {
while ((desktopName = g_dir_read_name(dir))) {
QString filePath = filedir + QString::fromUtf8(desktopName);
QByteArray ba;
ba = filePath.toUtf8();
GKeyFile *keyfile;
char *name;
keyfile = g_key_file_new();
if (!g_key_file_load_from_file(keyfile, ba.data(), G_KEY_FILE_NONE, NULL)) {
g_key_file_free(keyfile);
g_dir_close(mdir);
return false;
}
name = g_key_file_get_string(keyfile, G_KEY_FILE_DESKTOP_GROUP,
G_KEY_FILE_DESKTOP_KEY_NAME, NULL);
g_key_file_free(keyfile);
qDebug()<<Name<< " "<<name;
if (QString::fromUtf8(name) == QString::fromUtf8(Name)) {
g_dir_close(mdir);
return true;
}
}
}
g_dir_close(mdir);
return false;
}

void AddAutoBoot::paintEvent(QPaintEvent *event)
{
Q_UNUSED(event);
Expand Down Expand Up @@ -250,20 +219,12 @@ void AddAutoBoot::open_desktop_dir_slots()

emit ui->execLineEdit->textEdited(QString(selectedfile));

mdir = g_dir_open(g_build_filename(g_get_user_config_dir(), "autostart", NULL), 0, NULL);

if (no_display) {
ui->hintLabel->setText(tr("desktop file not allowed add"));
ui->hintLabel->setAlignment(Qt::AlignCenter);
ui->hintLabel->setStyleSheet("color:red;");
ui->certainBtn->setEnabled(false);
} else if (getFilename(mdir,name)) {
ui->hintLabel->setText(tr("desktop file already exist"));
ui->hintLabel->setAlignment(Qt::AlignCenter);
ui->hintLabel->setStyleSheet("color:red;");
ui->certainBtn->setEnabled(false);
}

g_key_file_free(keyfile);
}

Expand Down
3 changes: 0 additions & 3 deletions plugins/system/autoboot/addautoboot.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ class AddAutoBoot : public QDialog

void resetBeforeClose();

bool getFilename(GDir *dir,const char *Name);

protected:
void paintEvent(QPaintEvent *);

Expand All @@ -65,7 +63,6 @@ class AddAutoBoot : public QDialog
QString mDesktopIcon;
bool userEditNameFlag = false;
bool userEditCommentFlag = false;
GDir *mdir;

private:
void initStyle();
Expand Down
9 changes: 9 additions & 0 deletions plugins/system/autoboot/autoboot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -783,6 +783,15 @@ void AutoBoot::add_autoboot_realize_slot(QString path, QString name, QString exe
if (path.isEmpty())
return;

// 判断是否有重复项,重复则不加入对应列表
QMap<QString, AutoApp>::iterator it = statusMaps.begin();
for (int index = 0; it != statusMaps.end(); it++, index++) {
if (it.value().name == name) {
return;
}
}


char *filename, *filepath;
QByteArray ba = path.section("/", -1, -1).toUtf8();

Expand Down
32 changes: 0 additions & 32 deletions plugins/system/display/controlpanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,6 @@ void ControlPanel::setConfig(const KScreen::ConfigPtr &config)
connect(mConfig.data(), &KScreen::Config::outputRemoved,
this, &ControlPanel::removeOutput);

for (const KScreen::OutputPtr &output : mConfig->outputs()) {
if (output->isConnected()) {
changescalemax(output);
}
}

for (const KScreen::OutputPtr &output : mConfig->outputs()) {
addOutput(output, false);
}
Expand Down Expand Up @@ -135,19 +129,6 @@ void ControlPanel::activateOutputNoParam()
}
}

void ControlPanel::changescalemax(const KScreen::OutputPtr &output)
{
QSize sizescale = QSize();
Q_FOREACH (const KScreen::ModePtr &mode, output->modes()) {
if (sizescale.width() <= mode->size().width()) {
sizescale = mode->size();
}
}
if (mScaleSize == QSize() || mScaleSize.width() > sizescale.width()) {
mScaleSize = sizescale;
}
}

void ControlPanel::isWayland()
{
QString sessionType = getenv("XDG_SESSION_TYPE");
Expand Down Expand Up @@ -189,21 +170,8 @@ void ControlPanel::slotOutputConnectedChanged()
});

if (output->isConnected()) {
changescalemax(output);
addOutput(output, true);
for (OutputConfig *outputCfg : mOutputConfigs) {
outputCfg->slotScaleIndex(mScaleSize);
}
} else {
removeOutput(output->id());
mScaleSize = QSize();
for (const KScreen::OutputPtr &output : mConfig->outputs()) {
if (output->isConnected()) {
changescalemax(output);
}
}
for (OutputConfig *outputCfg : mOutputConfigs) {
outputCfg->slotScaleIndex(mScaleSize);
}
}
}
1 change: 0 additions & 1 deletion plugins/system/display/controlpanel.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ class ControlPanel : public QFrame
void setConfig(const KScreen::ConfigPtr &config);
void setUnifiedOutput(const KScreen::OutputPtr &output);
void activateOutputNoParam();
void changescalemax(const KScreen::OutputPtr &output);

private:
void isWayland();
Expand Down
58 changes: 57 additions & 1 deletion plugins/system/display/display.ui
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>945</width>
<height>1136</height>
<height>1183</height>
</rect>
</property>
<property name="windowTitle">
Expand Down Expand Up @@ -199,6 +199,62 @@
</property>
</layout>
</item>
<item>
<widget class="QFrame" name="frame">
<property name="minimumSize">
<size>
<width>550</width>
<height>50</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>960</width>
<height>50</height>
</size>
</property>
<property name="frameShape">
<enum>QFrame::Box</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QLabel" name="scaleLabel">
<property name="minimumSize">
<size>
<width>118</width>
<height>30</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>118</width>
<height>30</height>
</size>
</property>
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="text">
<string>screen zoom</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="scaleCombo">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>30</height>
</size>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QFrame" name="showMonitorframe">
<property name="enabled">
Expand Down
114 changes: 2 additions & 112 deletions plugins/system/display/outputconfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,12 @@ OutputConfig::OutputConfig(QWidget *parent) :
QWidget(parent),
mOutput(nullptr)
{
initDpiConnection();

}

OutputConfig::OutputConfig(const KScreen::OutputPtr &output, QWidget *parent) :
QWidget(parent)
{
initDpiConnection();
setOutput(output);
}

Expand Down Expand Up @@ -159,19 +158,6 @@ void OutputConfig::initUi()
mScaleCombox = new QComboBox(this);
mScaleCombox->setObjectName("scaleCombox");

double scale = getScreenScale();

slotScaleIndex(mResolution->currentResolution());

mScaleCombox->setCurrentText(scaleToString(scale));

if (mScaleCombox->findData(scale) == -1) {
mScaleCombox->addItem(scaleToString(scale), scale);
mScaleCombox->setCurrentText(scaleToString(scale));
}

connect(mScaleCombox, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
this, &OutputConfig::slotScaleChanged);

QLabel *scaleLabel = new QLabel(this);
//~ contents_path /display/screen zoom
Expand All @@ -183,21 +169,11 @@ void OutputConfig::initUi()
scaleLayout->addWidget(mScaleCombox);

vbox->addWidget(scaleFrame);
scaleFrame->hide();

initConnection();
}

double OutputConfig::getScreenScale()
{
double scale = 1.0;
if (QGSettings::isSchemaInstalled(SCALE_SCHEMAS)) {
if (mDpiSettings->keys().contains("scalingFactor")) {
scale = mDpiSettings->get(SCALE_KEY).toDouble();
}
}
return scale;
}

void OutputConfig::initConnection()
{
connect(mOutput.data(), &KScreen::Output::isConnectedChanged,
Expand All @@ -224,29 +200,10 @@ void OutputConfig::initConnection()
mRefreshRate->blockSignals(false);
}

if (mScaleCombox) {
mScaleCombox->blockSignals(true);
slotScaleIndex(mOutput->currentMode()->size());
mScaleCombox->blockSignals(false);
}
}
});
}

void OutputConfig::initDpiConnection()
{
QByteArray id(SCALE_SCHEMAS);
if (QGSettings::isSchemaInstalled(SCALE_SCHEMAS)) {
mDpiSettings = new QGSettings(id, QByteArray(), this);
connect(mDpiSettings, &QGSettings::changed, this, [=](QString key) {
if (!key.compare("scalingFactor", Qt::CaseSensitive)) {
slotDPIChanged(key);
}

});
}
}

QString OutputConfig::scaleToString(double scale)
{
return QString::number(scale * 100) + "%";
Expand Down Expand Up @@ -354,73 +311,6 @@ void OutputConfig::slotScaleChanged(int index)
Q_EMIT scaleChanged(mScaleCombox->itemData(index).toDouble());
}

void OutputConfig::slotDPIChanged(QString key)
{
double scale = mDpiSettings->get(key).toDouble();
if (mScaleCombox) {
if (mScaleCombox->findData(scale) == -1) {
mScaleCombox->addItem(scaleToString(scale), scale);
}
mScaleCombox->blockSignals(true);
mScaleCombox->setCurrentText(scaleToString(scale));
mScaleCombox->blockSignals(false);

}
}

void OutputConfig::slotScaleIndex(const QSize &size)
{
QSize msize;
if (mScaleSize != QSize()) {
msize = size.width() > mScaleSize.width()?mScaleSize:size;
} else {
msize = size;
}
if (!msize.isValid()) {
return;
}

mScaleCombox->blockSignals(true);
mScaleCombox->clear();
mScaleCombox->addItem("100%", 1.0);

if (msize.width() >= 1024 ) {
mScaleCombox->addItem("125%", 1.25);
}
if (msize.width() >= 1920 ) {
mScaleCombox->addItem("150%", 1.5);
}
if (msize.width() >= 2560) {
mScaleCombox->addItem("175%", 1.75);
mScaleCombox->addItem("200%", 2.0);
}
if (msize.width() >= 3072) {
mScaleCombox->addItem("225%", 2.25);
mScaleCombox->addItem("250%", 2.5);
}
if (msize.width() >= 3840) {
mScaleCombox->addItem("275%", 2.75);
}

double scale = getScreenScale();

if (mScaleCombox->findData(scale) == -1) {
//该变量保存改变前的缩放率,当用户点击恢复时,恢复对应的缩放率
mScaleres = scale;

scale = 1.0;
if (QGSettings::isSchemaInstalled(SCALE_SCHEMAS)) {
if (mDpiSettings->keys().contains("scalingFactor")) {
mDpiSettings->set(SCALE_KEY,scale);
}
}
QMessageBox::information(this, tr("Information"),
tr("Some applications need to be logouted to take effect"));
}
mScaleCombox->setCurrentText(scaleToString(scale));
mScaleCombox->blockSignals(false);
}

void OutputConfig::setShowScaleOption(bool showScaleOption)
{
mShowScaleOption = showScaleOption;
Expand Down
Loading

0 comments on commit 06cf232

Please sign in to comment.