mirror of
https://github.com/KDE/latte-dock.git
synced 2025-01-10 21:18:19 +03:00
expose screen Tracker interval value
--different hardware can have different delays in order to inform for screen changes. The tracker (an internal timer that is) informs Latte after a specific interval in order to track these changes and respond accordingly.
This commit is contained in:
parent
6163cecb6b
commit
83bad3374e
@ -117,10 +117,18 @@ DockView::DockView(Plasma::Corona *corona, QScreen *targetScreen, bool dockWindo
|
||||
connect(this->containment(), SIGNAL(statusChanged(Plasma::Types::ItemStatus)), SLOT(statusChanged(Plasma::Types::ItemStatus)));
|
||||
}, Qt::DirectConnection);
|
||||
|
||||
m_screenSyncTimer.setSingleShot(true);
|
||||
m_screenSyncTimer.setInterval(2000);
|
||||
connect(&m_screenSyncTimer, &QTimer::timeout, this, &DockView::reconsiderScreen);
|
||||
|
||||
auto *dockCorona = qobject_cast<DockCorona *>(this->corona());
|
||||
|
||||
if (dockCorona) {
|
||||
m_screenSyncTimer.setInterval(qMax(dockCorona->universalSettings()->screenTrackerInterval() - 500, 1000));
|
||||
connect(dockCorona->universalSettings(), &UniversalSettings::screenTrackerIntervalChanged, this, [this, dockCorona]() {
|
||||
m_screenSyncTimer.setInterval(qMax(dockCorona->universalSettings()->screenTrackerInterval() - 500, 1000));
|
||||
});
|
||||
|
||||
connect(dockCorona, &DockCorona::docksCountChanged, this, &DockView::docksCountChanged);
|
||||
connect(this, &DockView::docksCountChanged, this, &DockView::totalDocksCountChanged);
|
||||
connect(dockCorona, &DockCorona::dockLocationChanged, this, &DockView::dockLocationChanged);
|
||||
@ -132,10 +140,6 @@ DockView::DockView(Plasma::Corona *corona, QScreen *targetScreen, bool dockWindo
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
m_screenSyncTimer.setSingleShot(true);
|
||||
m_screenSyncTimer.setInterval(2000);
|
||||
connect(&m_screenSyncTimer, &QTimer::timeout, this, &DockView::reconsiderScreen);
|
||||
}
|
||||
|
||||
DockView::~DockView()
|
||||
|
@ -116,8 +116,11 @@ DockCorona::DockCorona(bool defaultLayoutOnStartup, QString layoutNameOnStartUp,
|
||||
connect(m_activityConsumer, &KActivities::Consumer::serviceStatusChanged, this, &DockCorona::load);
|
||||
|
||||
m_docksScreenSyncTimer.setSingleShot(true);
|
||||
m_docksScreenSyncTimer.setInterval(2500);
|
||||
m_docksScreenSyncTimer.setInterval(m_universalSettings->screenTrackerInterval());
|
||||
connect(&m_docksScreenSyncTimer, &QTimer::timeout, this, &DockCorona::syncDockViewsToScreens);
|
||||
connect(m_universalSettings, &UniversalSettings::screenTrackerIntervalChanged, this, [this]() {
|
||||
m_docksScreenSyncTimer.setInterval(m_universalSettings->screenTrackerInterval());
|
||||
});
|
||||
|
||||
//! Dbus adaptor initialization
|
||||
new LatteDockAdaptor(this);
|
||||
|
@ -61,6 +61,9 @@ const int COLORCOLUMN = 1;
|
||||
const int NAMECOLUMN = 2;
|
||||
const int MENUCOLUMN = 3;
|
||||
const int ACTIVITYCOLUMN = 4;
|
||||
|
||||
const int SCREENTRACKERDEFAULTVALUE = 2500;
|
||||
|
||||
const QChar CheckMark{0x2714};
|
||||
|
||||
SettingsDialog::SettingsDialog(QWidget *parent, DockCorona *corona)
|
||||
@ -122,6 +125,8 @@ SettingsDialog::SettingsDialog(QWidget *parent, DockCorona *corona)
|
||||
m_mouseSensitivityButtons->addButton(ui->highSensitivityBtn, Latte::Dock::HighSensitivity);
|
||||
m_mouseSensitivityButtons->setExclusive(true);
|
||||
|
||||
ui->screenTrackerSpinBox->setValue(m_corona->universalSettings()->screenTrackerInterval());
|
||||
|
||||
//! About Menu
|
||||
QMenuBar *menuBar = new QMenuBar(this);
|
||||
// QMenuBar *rightAlignedMenuBar = new QMenuBar(menuBar);
|
||||
@ -163,17 +168,13 @@ SettingsDialog::SettingsDialog(QWidget *parent, DockCorona *corona)
|
||||
updateApplyButtonsState();
|
||||
});
|
||||
|
||||
connect(ui->autostartChkBox, &QCheckBox::stateChanged, this, [&]() {
|
||||
connect(ui->screenTrackerSpinBox, QOverload<int>::of(&QSpinBox::valueChanged), [ = ](int i) {
|
||||
updateApplyButtonsState();
|
||||
});
|
||||
|
||||
connect(ui->infoWindowChkBox, &QCheckBox::stateChanged, this, [&]() {
|
||||
updateApplyButtonsState();
|
||||
});
|
||||
|
||||
connect(ui->tabWidget, &QTabWidget::currentChanged, this, [&]() {
|
||||
updateApplyButtonsState();
|
||||
});
|
||||
connect(ui->autostartChkBox, &QCheckBox::stateChanged, this, &SettingsDialog::updateApplyButtonsState);
|
||||
connect(ui->infoWindowChkBox, &QCheckBox::stateChanged, this, &SettingsDialog::updateApplyButtonsState);
|
||||
connect(ui->tabWidget, &QTabWidget::currentChanged, this, &SettingsDialog::updateApplyButtonsState);
|
||||
|
||||
connect(aboutAction, &QAction::triggered, m_corona, &DockCorona::aboutApplication);
|
||||
connect(quitAction, &QAction::triggered, m_corona, &DockCorona::closeApplication);
|
||||
@ -684,6 +685,7 @@ void SettingsDialog::restoreDefaults()
|
||||
ui->autostartChkBox->setChecked(true);
|
||||
ui->infoWindowChkBox->setChecked(true);
|
||||
ui->highSensitivityBtn->setChecked(true);
|
||||
ui->screenTrackerSpinBox->setValue(SCREENTRACKERDEFAULTVALUE);
|
||||
}
|
||||
}
|
||||
|
||||
@ -844,6 +846,7 @@ QList<int> SettingsDialog::currentSettings()
|
||||
settings << (int)ui->autostartChkBox->isChecked();
|
||||
settings << (int)ui->infoWindowChkBox->isChecked();
|
||||
settings << m_mouseSensitivityButtons->checkedId();
|
||||
settings << ui->screenTrackerSpinBox->value();
|
||||
settings << m_model->rowCount();
|
||||
|
||||
return settings;
|
||||
@ -1079,7 +1082,7 @@ void SettingsDialog::updateApplyButtonsState()
|
||||
//! Defaults for general Latte settings
|
||||
|
||||
if (!ui->autostartChkBox->isChecked() || !ui->infoWindowChkBox->isChecked()
|
||||
|| !ui->highSensitivityBtn->isChecked()) {
|
||||
|| !ui->highSensitivityBtn->isChecked() || ui->screenTrackerSpinBox->value() != SCREENTRACKERDEFAULTVALUE) {
|
||||
ui->buttonBox->button(QDialogButtonBox::RestoreDefaults)->setEnabled(true);
|
||||
} else {
|
||||
ui->buttonBox->button(QDialogButtonBox::RestoreDefaults)->setEnabled(false);
|
||||
@ -1196,7 +1199,7 @@ bool SettingsDialog::saveAllChanges()
|
||||
m_corona->universalSettings()->setMouseSensitivity(sensitivity);
|
||||
m_corona->universalSettings()->setAutostart(autostart);
|
||||
m_corona->universalSettings()->setShowInfoWindow(showInfoWindow);
|
||||
|
||||
m_corona->universalSettings()->setScreenTrackerInterval(ui->screenTrackerSpinBox->value());
|
||||
|
||||
//! Update Layouts
|
||||
QStringList knownActivities = activities();
|
||||
|
@ -220,7 +220,7 @@
|
||||
<item>
|
||||
<widget class="QPushButton" name="copyButton">
|
||||
<property name="toolTip">
|
||||
<string>Copy layout</string>
|
||||
<string>Copy selected layout</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string comment="copy layout">Copy</string>
|
||||
@ -237,7 +237,7 @@
|
||||
<item>
|
||||
<widget class="QPushButton" name="removeButton">
|
||||
<property name="toolTip">
|
||||
<string>Remove layout</string>
|
||||
<string>Remove selected layout</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string comment="remove layout">Remove</string>
|
||||
@ -311,7 +311,7 @@
|
||||
<item>
|
||||
<widget class="QPushButton" name="importButton">
|
||||
<property name="toolTip">
|
||||
<string>Import layout or full configuration</string>
|
||||
<string>Import a layout or full configuration file</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string comment="import layout">Import</string>
|
||||
@ -328,7 +328,7 @@
|
||||
<item>
|
||||
<widget class="QPushButton" name="exportButton">
|
||||
<property name="toolTip">
|
||||
<string>Export layout or full configuration</string>
|
||||
<string>Export selected layout or full configuration into a file</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string comment="export layout">Export</string>
|
||||
@ -342,7 +342,7 @@
|
||||
<item>
|
||||
<widget class="QPushButton" name="downloadButton">
|
||||
<property name="toolTip">
|
||||
<string>Download online layouts</string>
|
||||
<string>Download community layouts from the Internet</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string comment="download layout">Download</string>
|
||||
@ -398,7 +398,7 @@
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="verticalScrollBarPolicy">
|
||||
<enum>Qt::ScrollBarAlwaysOn</enum>
|
||||
<enum>Qt::ScrollBarAsNeeded</enum>
|
||||
</property>
|
||||
<property name="horizontalScrollBarPolicy">
|
||||
<enum>Qt::ScrollBarAlwaysOff</enum>
|
||||
@ -411,8 +411,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>785</width>
|
||||
<height>505</height>
|
||||
<width>794</width>
|
||||
<height>496</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_9">
|
||||
@ -491,6 +491,9 @@
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="autostartChkBox">
|
||||
<property name="toolTip">
|
||||
<string>Start the application automaticaly after each relogin</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Enable autostart during startup</string>
|
||||
</property>
|
||||
@ -519,7 +522,7 @@
|
||||
<item>
|
||||
<widget class="QCheckBox" name="infoWindowChkBox">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
<string>Provide visual feedback when layouts are added automatically</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Show informative window for layouts automatic switching</string>
|
||||
@ -665,6 +668,139 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_8">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Fixed</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer_9">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Fixed</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="delayLbl">
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Delay</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_10">
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_7">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Fixed</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="trackScreensDelayLbl">
|
||||
<property name="toolTip">
|
||||
<string>Different hardware can have different delays during screen changes.
|
||||
This tracker is used in order to not lose any screen related update.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Track screen changes after</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="screenTrackerSpinBox">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>200</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Different hardware can have different delays during screen changes.
|
||||
This tracker is used in order to not lose any screen related update.</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="specialValueText">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="suffix">
|
||||
<string> ms.</string>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>1000</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>5000</number>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<number>100</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>2500</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_9">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Fixed</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
|
@ -42,6 +42,7 @@ UniversalSettings::UniversalSettings(KSharedConfig::Ptr config, QObject *parent)
|
||||
connect(this, &UniversalSettings::layoutsMemoryUsageChanged, this, &UniversalSettings::saveConfig);
|
||||
connect(this, &UniversalSettings::layoutsWindowSizeChanged, this, &UniversalSettings::saveConfig);
|
||||
connect(this, &UniversalSettings::mouseSensitivityChanged, this, &UniversalSettings::saveConfig);
|
||||
connect(this, &UniversalSettings::screenTrackerIntervalChanged, this, &UniversalSettings::saveConfig);
|
||||
connect(this, &UniversalSettings::showInfoWindowChanged, this, &UniversalSettings::saveConfig);
|
||||
connect(this, &UniversalSettings::versionChanged, this, &UniversalSettings::saveConfig);
|
||||
}
|
||||
@ -100,6 +101,21 @@ void UniversalSettings::setVersion(int ver)
|
||||
emit versionChanged();
|
||||
}
|
||||
|
||||
int UniversalSettings::screenTrackerInterval() const
|
||||
{
|
||||
return m_screenTrackerInterval;
|
||||
}
|
||||
|
||||
void UniversalSettings::setScreenTrackerInterval(int duration)
|
||||
{
|
||||
if (m_screenTrackerInterval == duration) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_screenTrackerInterval = duration;
|
||||
emit screenTrackerIntervalChanged();
|
||||
}
|
||||
|
||||
QString UniversalSettings::currentLayoutName() const
|
||||
{
|
||||
return m_currentLayoutName;
|
||||
@ -269,6 +285,7 @@ void UniversalSettings::loadConfig()
|
||||
m_layoutsWindowSize = m_universalGroup.readEntry("layoutsWindowSize", QSize(700, 450));
|
||||
m_layoutsColumnWidths = m_universalGroup.readEntry("layoutsColumnWidths", QStringList());
|
||||
m_launchers = m_universalGroup.readEntry("launchers", QStringList());
|
||||
m_screenTrackerInterval = m_universalGroup.readEntry("screenTrackerInterval", 2500);
|
||||
m_showInfoWindow = m_universalGroup.readEntry("showInfoWindow", true);
|
||||
m_memoryUsage = static_cast<Dock::LayoutsMemoryUsage>(m_universalGroup.readEntry("memoryUsage", (int)Dock::SingleLayout));
|
||||
m_mouseSensitivity = static_cast<Dock::MouseSensitivity>(m_universalGroup.readEntry("mouseSensitivity", (int)Dock::HighSensitivity));
|
||||
@ -283,6 +300,7 @@ void UniversalSettings::saveConfig()
|
||||
m_universalGroup.writeEntry("layoutsWindowSize", m_layoutsWindowSize);
|
||||
m_universalGroup.writeEntry("layoutsColumnWidths", m_layoutsColumnWidths);
|
||||
m_universalGroup.writeEntry("launchers", m_launchers);
|
||||
m_universalGroup.writeEntry("screenTrackerInterval", m_screenTrackerInterval);
|
||||
m_universalGroup.writeEntry("showInfoWindow", m_showInfoWindow);
|
||||
m_universalGroup.writeEntry("memoryUsage", (int)m_memoryUsage);
|
||||
m_universalGroup.writeEntry("mouseSensitivity", (int)m_mouseSensitivity);
|
||||
|
@ -64,6 +64,9 @@ public:
|
||||
int version() const;
|
||||
void setVersion(int ver);
|
||||
|
||||
int screenTrackerInterval() const;
|
||||
void setScreenTrackerInterval(int duration);
|
||||
|
||||
QString currentLayoutName() const;
|
||||
void setCurrentLayoutName(QString layoutName);
|
||||
|
||||
@ -107,6 +110,7 @@ signals:
|
||||
void layoutsMemoryUsageChanged();
|
||||
void mouseSensitivityChanged();
|
||||
void runningActivitiesModelChanged();
|
||||
void screenTrackerIntervalChanged();
|
||||
void showInfoWindowChanged();
|
||||
void versionChanged();
|
||||
|
||||
@ -126,6 +130,8 @@ private:
|
||||
//when there isnt a version it is an old universal file
|
||||
int m_version{1};
|
||||
|
||||
int m_screenTrackerInterval{2500};
|
||||
|
||||
QString m_currentLayoutName;
|
||||
QString m_lastNonAssignedLayoutName;
|
||||
QSize m_downloadWindowSize{800, 550};
|
||||
|
Loading…
Reference in New Issue
Block a user