summaryrefslogtreecommitdiffstats
path: root/krandr
diff options
context:
space:
mode:
authorTimothy Pearson <kb9vqf@pearsoncomputing.net>2013-01-12 04:26:39 -0600
committerTimothy Pearson <kb9vqf@pearsoncomputing.net>2013-01-12 04:26:39 -0600
commit4c9ff70f806c4e8f2f6197b94db39b5bef8c71f2 (patch)
treec06c18c8f425eb94f12f60a33a68f19d4f27a913 /krandr
parent4d5797b479479c1e540b7068a3dea1a43e6d3b39 (diff)
downloadtdelibs-4c9ff70f806c4e8f2f6197b94db39b5bef8c71f2.tar.gz
tdelibs-4c9ff70f806c4e8f2f6197b94db39b5bef8c71f2.zip
Fix libkrandr configuration options
Diffstat (limited to 'krandr')
-rw-r--r--krandr/libkrandr.cc66
-rw-r--r--krandr/libkrandr.h23
2 files changed, 78 insertions, 11 deletions
diff --git a/krandr/libkrandr.cc b/krandr/libkrandr.cc
index f2aa38c7d..04dd01be6 100644
--- a/krandr/libkrandr.cc
+++ b/krandr/libkrandr.cc
@@ -461,7 +461,7 @@ bool KRandrSimpleAPI::renameDisplayConfiguration(TQString profilename, TQString
return (d.rename(fileName, newFileName));
}
-void KRandrSimpleAPI::saveDisplayConfiguration(bool enable, TQString profilename, TQString defaultprofilename, TQString kde_confdir, TQPtrList<SingleScreenData> screenInfoArray) {
+void KRandrSimpleAPI::saveDisplayConfiguration(bool enable, bool applyonstart, TQString profilename, TQString defaultprofilename, TQString kde_confdir, TQPtrList<SingleScreenData> screenInfoArray) {
int i;
TQString filename;
@@ -470,14 +470,16 @@ void KRandrSimpleAPI::saveDisplayConfiguration(bool enable, TQString profilename
filename.prepend(kde_confdir.append("/"));
KSimpleConfig* display_config = new KSimpleConfig( filename );
display_config->setGroup("General");
- display_config->writeEntry("ApplySettingsOnStart", enable);
+ display_config->writeEntry("EnableDisplayControl", enable);
+ display_config->writeEntry("ApplySettingsOnStart", applyonstart);
display_config->writeEntry("StartupProfileName", defaultprofilename);
display_config->sync();
delete display_config;
filename = profilename;
- if (filename == "")
+ if (filename == "") {
filename = "default";
+ }
filename.prepend(kde_confdir.append("/displayconfig/"));
display_config = new KSimpleConfig( filename );
@@ -523,18 +525,24 @@ void KRandrSimpleAPI::saveDisplayConfiguration(bool enable, TQString profilename
delete display_config;
}
+TQPoint KRandrSimpleAPI::applyStartupDisplayConfiguration(TQString kde_confdir) {
+ bool applyonstart = getDisplayConfigurationStartupAutoApplyEnabled(kde_confdir);
+ if (applyonstart) {
+ TQString profilename = getDisplayConfigurationStartupAutoApplyName(kde_confdir);
+ return applyDisplayConfiguration(profilename, kde_confdir);
+ }
+ else {
+ return TQPoint();
+ }
+}
+
TQPoint KRandrSimpleAPI::applyDisplayConfiguration(TQString profilename, TQString kde_confdir) {
TQPoint ret;
- TQString filename = "displayglobals";
- filename.prepend(kde_confdir.append("/"));
- KSimpleConfig* display_config = new KSimpleConfig( filename );
- display_config->setGroup("General");
- bool enabled = display_config->readBoolEntry("ApplySettingsOnStart", false);
+ bool enabled = getDisplayConfigurationEnabled(kde_confdir);
if (profilename == "") {
- profilename = display_config->readEntry("StartupProfileName", "");
+ profilename = "default";
}
- delete display_config;
if (enabled) {
TQPtrList<SingleScreenData> screenInfoArray;
@@ -1001,7 +1009,45 @@ void KRandrSimpleAPI::saveHotplugRules(HotPlugRulesList rules, TQString kde_conf
delete display_config;
}
+bool KRandrSimpleAPI::getDisplayConfigurationEnabled(TQString kde_confdir) {
+ TQString filename = "displayglobals";
+ filename.prepend(kde_confdir.append("/"));
+ KSimpleConfig* display_config = new KSimpleConfig( filename );
+ display_config->setGroup("General");
+ bool enabled = display_config->readBoolEntry("EnableDisplayControl", false);
+ delete display_config;
+
+ return enabled;
+}
+
+bool KRandrSimpleAPI::getDisplayConfigurationStartupAutoApplyEnabled(TQString kde_confdir) {
+ TQString filename = "displayglobals";
+ filename.prepend(kde_confdir.append("/"));
+ KSimpleConfig* display_config = new KSimpleConfig( filename );
+ display_config->setGroup("General");
+ bool applyonstart = display_config->readBoolEntry("ApplySettingsOnStart", false);
+ delete display_config;
+
+ return applyonstart;
+}
+
+TQString KRandrSimpleAPI::getDisplayConfigurationStartupAutoApplyName(TQString kde_confdir) {
+ TQString filename = "displayglobals";
+ filename.prepend(kde_confdir.append("/"));
+ KSimpleConfig* display_config = new KSimpleConfig( filename );
+ display_config->setGroup("General");
+ TQString profilename = display_config->readEntry("StartupProfileName", "");
+ delete display_config;
+
+ return profilename;
+}
+
void KRandrSimpleAPI::applyHotplugRules(TQString kde_confdir) {
+ bool enabled = getDisplayConfigurationEnabled(kde_confdir);
+ if (!enabled) {
+ return;
+ }
+
HotPlugRulesList rules = getHotplugRules(kde_confdir);
TQPtrList<SingleScreenData> screenInfoArray = readCurrentDisplayConfiguration();
diff --git a/krandr/libkrandr.h b/krandr/libkrandr.h
index 201517900..3e00d73f7 100644
--- a/krandr/libkrandr.h
+++ b/krandr/libkrandr.h
@@ -179,6 +179,21 @@ class KRANDR_EXPORT KRandrSimpleAPI : public RandRDisplay
TQString getEDIDMonitorName(int card, TQString displayname);
/**
+ * Returns true if the specified configuration directory has enabled display configuration
+ */
+ bool getDisplayConfigurationEnabled(TQString kde_confdir);
+
+ /**
+ * Returns true if the specified configuration directory has enabled automatic profile application on startup
+ */
+ bool getDisplayConfigurationStartupAutoApplyEnabled(TQString kde_confdir);
+
+ /**
+ * Returns the name of the automatically applied startup profile in the specified configuration directory
+ */
+ TQString getDisplayConfigurationStartupAutoApplyName(TQString kde_confdir);
+
+ /**
* Returns a HotPlugRulesList containing all hotplug rules from the specified configuration directory
*/
HotPlugRulesList getHotplugRules(TQString kde_confdir);
@@ -216,7 +231,7 @@ class KRANDR_EXPORT KRandrSimpleAPI : public RandRDisplay
* If profilename is empty, the default profile is utilized
* If enable is set to true, the default profile will be applied at system startup
*/
- void saveDisplayConfiguration(bool enable, TQString profilename, TQString defaultprofilename, TQString kde_confdir, TQPtrList<SingleScreenData> screenInfoArray);
+ void saveDisplayConfiguration(bool enable, bool applyonstart, TQString profilename, TQString defaultprofilename, TQString kde_confdir, TQPtrList<SingleScreenData> screenInfoArray);
/**
* Reads the systemwide display configuration screenInfoArray from the specified profile
@@ -226,6 +241,12 @@ class KRANDR_EXPORT KRandrSimpleAPI : public RandRDisplay
TQPtrList<SingleScreenData> loadDisplayConfiguration(TQString profilename, TQString kde_confdir);
/**
+ * Applies the startup display configuration profile if enabled
+ * Returns the offset of the primary screen's top left corner
+ */
+ TQPoint applyStartupDisplayConfiguration(TQString kde_confdir);
+
+ /**
* Applies the systemwide display configuration screenInfoArray from the specified profile
* If profilename is empty, the default profile is utilized
* Returns the offset of the primary screen's top left corner