diff options
author | Timothy Pearson <[email protected]> | 2013-01-08 20:18:50 -0600 |
---|---|---|
committer | Timothy Pearson <[email protected]> | 2013-01-08 20:18:50 -0600 |
commit | 477e956a04dfb244814f274e98a8d6f4beb84f3f (patch) | |
tree | 8ce70dbbd93389354327fd1c063c0a94ff30be87 | |
parent | c24b096e62d6137acdcb71e5ed5b08d43ecbb928 (diff) | |
download | tdebase-477e956a04dfb244814f274e98a8d6f4beb84f3f.tar.gz tdebase-477e956a04dfb244814f274e98a8d6f4beb84f3f.zip |
Add per-user display settings
This partially resolves Bug 1264
Fix displayconfig crashes and warnings
Slightly clean up iccconfig and hwmanager
-rw-r--r-- | kcontrol/displayconfig/displayconfig.cpp | 91 | ||||
-rw-r--r-- | kcontrol/displayconfig/displayconfig.h | 1 | ||||
-rw-r--r-- | kcontrol/displayconfig/displayconfigbase.ui | 73 | ||||
-rw-r--r-- | kcontrol/hwmanager/devicepropsdlgbase.ui | 8 | ||||
-rw-r--r-- | kcontrol/hwmanager/hwmanager.cpp | 2 | ||||
-rw-r--r-- | kcontrol/hwmanager/hwmanager.h | 3 | ||||
-rw-r--r-- | kcontrol/hwmanager/hwmanagerbase.ui | 8 | ||||
-rw-r--r-- | kcontrol/iccconfig/iccconfig.cpp | 160 | ||||
-rw-r--r-- | kcontrol/iccconfig/iccconfig.h | 1 | ||||
-rw-r--r-- | kcontrol/iccconfig/iccconfigbase.ui | 8 | ||||
-rw-r--r-- | starttde | 4 | ||||
-rw-r--r-- | tdeinit/CMakeLists.txt | 13 | ||||
-rw-r--r-- | tdeinit/displayconfig.cpp | 72 | ||||
-rw-r--r-- | tdeinit/phase1.cpp | 2 |
14 files changed, 273 insertions, 173 deletions
diff --git a/kcontrol/displayconfig/displayconfig.cpp b/kcontrol/displayconfig/displayconfig.cpp index 7d610b6c5..faeffa1f5 100644 --- a/kcontrol/displayconfig/displayconfig.cpp +++ b/kcontrol/displayconfig/displayconfig.cpp @@ -302,11 +302,11 @@ TQPoint moveTQRectOutsideMonitorRegion(TQRect rect, MonitorRegion region) { // Next, find which rectangle is closest to the center of the TQRect int closest = 0; long distance = 16384*16384; - int fallback_mode; + int fallback_mode = 0; long test_distance; long test_center_x; long test_center_y; - for ( int i = 0; i < rectangles.size(); i++ ) { + for ( unsigned int i = 0; i < rectangles.size(); i++ ) { test_center_x = rectangles[i].x() + (rectangles[i].width()/2); test_center_y = rectangles[i].y() + (rectangles[i].height()/2); test_distance = pow(test_center_x-rect_center_x,2) + pow(test_center_y-rect_center_y,2); @@ -381,7 +381,7 @@ TQPoint compressTQRectTouchingMonitorRegion(TQRect rect, MonitorRegion region, T long test_distance; long test_center_x; long test_center_y; - for ( int i = 0; i < rectangles.size(); i++ ) { + for ( unsigned int i = 0; i < rectangles.size(); i++ ) { test_center_x = rectangles[i].x() + (rectangles[i].width()/2); test_center_y = rectangles[i].y() + (rectangles[i].height()/2); test_distance = pow(test_center_x-rect_center_x,2) + pow(test_center_y-rect_center_y,2); @@ -422,10 +422,10 @@ void KDisplayConfig::updateDraggableMonitorInformation (int monitor_id) { void KDisplayConfig::updateDraggableMonitorInformationInternal (int monitor_id, bool recurse) { int i; - int j; - DraggableMonitor *primary_monitor; - DraggableMonitor *moved_monitor; - SingleScreenData *screendata; + int j=0; + DraggableMonitor *primary_monitor = NULL; + DraggableMonitor *moved_monitor = NULL; + SingleScreenData *screendata = NULL; TQObjectList monitors; // Find the moved draggable monitor object @@ -442,6 +442,10 @@ void KDisplayConfig::updateDraggableMonitorInformationInternal (int monitor_id, } } + if (!screendata) { + return; + } + TQString rotationDesired = *screendata->rotations.at(screendata->current_rotation_index); bool isvisiblyrotated = ((rotationDesired == "Rotate 90 degrees") || (rotationDesired == "Rotate 270 degrees")); @@ -453,10 +457,12 @@ void KDisplayConfig::updateDraggableMonitorInformationInternal (int monitor_id, } // Handle resizing - if (isvisiblyrotated) + if (isvisiblyrotated) { moved_monitor->setFixedSize(screendata->current_y_pixel_count*base->monitorPhyArrange->resize_factor, screendata->current_x_pixel_count*base->monitorPhyArrange->resize_factor); - else + } + else { moved_monitor->setFixedSize(screendata->current_x_pixel_count*base->monitorPhyArrange->resize_factor, screendata->current_y_pixel_count*base->monitorPhyArrange->resize_factor); + } // Find the primary monitor for (i=0;i<numberOfScreens;i++) { @@ -525,9 +531,7 @@ bool KDisplayConfig::applyMonitorLayoutRules() { bool KDisplayConfig::applyMonitorLayoutRules(DraggableMonitor* monitor_to_move) { int i; - int j; bool monitor_was_moved; - SingleScreenData *screendata; TQObjectList monitors; // Ensure that the monitors: @@ -618,7 +622,7 @@ bool KDisplayConfig::applyMonitorLayoutRules(DraggableMonitor* monitor_to_move) void KDisplayConfig::moveMonitor(DraggableMonitor* monitor, int realx, int realy) { int i; - int j; + int j=0; bool primary_found; DraggableMonitor *primary_monitor; SingleScreenData *screendata; @@ -669,7 +673,6 @@ void KDisplayConfig::moveMonitor(DraggableMonitor* monitor, int realx, int realy // } TQStringList sortResolutions(TQStringList unsorted) { - int i; int xres; int largest; TQStringList sorted; @@ -697,8 +700,8 @@ TQStringList sortResolutions(TQStringList unsorted) { } int KDisplayConfig::realResolutionSliderValue() { - int i; - int j; + unsigned int i; + unsigned int j; SingleScreenData *screendata; screendata = m_screenInfoArray.at(base->monitorDisplaySelectDD->currentItem()); @@ -716,8 +719,8 @@ int KDisplayConfig::realResolutionSliderValue() { } void KDisplayConfig::setRealResolutionSliderValue(int index) { - int i; - int j; + unsigned int i; + unsigned int j; SingleScreenData *screendata; screendata = m_screenInfoArray.at(base->monitorDisplaySelectDD->currentItem()); @@ -742,9 +745,15 @@ KDisplayConfig::KDisplayConfig(TQWidget *parent, const char *name, const TQStrin m_randrsimple = new KRandrSimpleAPI(); - TQVBoxLayout *layout = new TQVBoxLayout(this, KDialog::marginHint(), KDialog::spacingHint()); - systemconfig = new KSimpleConfig( TQString::fromLatin1( KDE_CONFDIR "/kdisplay/kdisplayconfigrc" )); - systemconfig->setFileWriteMode(0644); + TQVBoxLayout *layout = new TQVBoxLayout(this, 0, KDialog::spacingHint()); + if (getuid() != 0) { + systemconfig = new KSimpleConfig( locateLocal("config", "kdisplay/", true) + "kdisplayconfigrc" ); + systemconfig->setFileWriteMode(0600); + } + else { + systemconfig = new KSimpleConfig( TQString::fromLatin1( KDE_CONFDIR "/kdisplay/kdisplayconfigrc" )); + systemconfig->setFileWriteMode(0644); + } KAboutData *about = new KAboutData(I18N_NOOP("kcmdisplayconfig"), I18N_NOOP("TDE Display Profile Control Module"), @@ -758,10 +767,14 @@ KDisplayConfig::KDisplayConfig(TQWidget *parent, const char *name, const TQStrin connect(m_gammaApplyTimer, SIGNAL(timeout()), this, SLOT(applyGamma())); base = new DisplayConfigBase(this); - layout->add(base); + layout->addWidget(base); + + if (getuid() != 0) { + base->systemEnableSupport->setText(i18n("&Enable local display control for this session")); + } - setRootOnlyMsg(i18n("<b>The global display configuration is a system wide setting, and requires administrator access</b><br>To alter the system's global display configuration, click on the \"Administrator Mode\" button below.")); - setUseRootOnlyMsg(true); + setRootOnlyMsg(i18n("<b>The global display configuration is a system wide setting, and requires administrator access</b><br>To alter the system's global display configuration, click on the \"Administrator Mode\" button below.<br>Otherwise, you may change your session-specific display configuration below.")); +// setUseRootOnlyMsg(true); // Setting this hides the Apply button! connect(base->systemEnableSupport, TQT_SIGNAL(clicked()), TQT_SLOT(changed())); connect(base->systemEnableSupport, TQT_SIGNAL(clicked()), TQT_SLOT(processLockoutControls())); @@ -840,32 +853,34 @@ void KDisplayConfig::rescanHardware (void) { void KDisplayConfig::reloadProfile (void) { // FIXME m_randrsimple->destroyScreenInformationObject(m_screenInfoArray); - m_screenInfoArray = m_randrsimple->loadSystemwideDisplayConfiguration("", KDE_CONFDIR); + if (getuid() != 0) { + m_screenInfoArray = m_randrsimple->loadSystemwideDisplayConfiguration("", locateLocal("config", "/", true)); + } + else { + m_screenInfoArray = m_randrsimple->loadSystemwideDisplayConfiguration("", KDE_CONFDIR); + } m_randrsimple->ensureMonitorDataConsistency(m_screenInfoArray); numberOfScreens = m_screenInfoArray.count(); refreshDisplayedInformation(); } void KDisplayConfig::identifyMonitors () { - int i; + unsigned int i; TQLabel* idWidget; TQPtrList<TQWidget> widgetList; Display *randr_display; ScreenInfo *randr_screen_info; - XRROutputInfo *output_info; randr_display = tqt_xdisplay(); randr_screen_info = m_randrsimple->read_screen_info(randr_display); for (i = 0; i < m_screenInfoArray.count(); i++) { - output_info = randr_screen_info->outputs[i]->info; // Look for ON outputs... if (!randr_screen_info->outputs[i]->cur_crtc) { continue; } - SingleScreenData *screendata = m_screenInfoArray.at(i); idWidget = new TQLabel(TQString("Screen\n%1").arg(i+1), (TQWidget*)0, "", Qt::WStyle_Customize | Qt::WStyle_NoBorder | Qt::WStyle_StaysOnTop | Qt::WX11BypassWM | Qt::WDestructiveClose); widgetList.append(idWidget); idWidget->resize(150, 100); @@ -923,7 +938,7 @@ void KDisplayConfig::updateArray (void) { void KDisplayConfig::updateDisplayedInformation () { // Insert data into the GUI - int i; + unsigned int i; SingleScreenData *screendata; ensureMonitorDataConsistency(); @@ -1056,8 +1071,6 @@ void KDisplayConfig::updateDragDropDisplay() { // Insert data into the GUI int i; int j; - int largest_x_pixels; - int largest_y_pixels; TQObjectList monitors; SingleScreenData *screendata; @@ -1074,8 +1087,6 @@ void KDisplayConfig::updateDragDropDisplay() { } } - int currentScreenIndex = base->monitorDisplaySelectDD->currentItem(); - ensureMonitorDataConsistency(); // Add the screens to the workspace @@ -1109,8 +1120,6 @@ void KDisplayConfig::updateDragDropDisplay() { void KDisplayConfig::layoutDragDropDisplay() { int i; - int largest_x_pixels; - int largest_y_pixels; TQObjectList monitors; SingleScreenData *screendata; @@ -1400,7 +1409,7 @@ void KDisplayConfig::processDPMSControls() { } void KDisplayConfig::processLockoutControls() { - if (getuid() != 0 || !systemconfig->checkConfigFilesWritable( true )) { + if (!systemconfig->checkConfigFilesWritable( true )) { base->globalTab->setEnabled(false); base->resolutionTab->setEnabled(false); base->gammaTab->setEnabled(false); @@ -1450,9 +1459,6 @@ KCModule* KDisplayConfig::addTab( const TQString name, const TQString label ) void KDisplayConfig::load(bool useDefaults ) { // Update the toggle buttons with the current configuration - int i; - int j; - updateArray(); systemconfig->setGroup(NULL); @@ -1477,7 +1483,12 @@ void KDisplayConfig::load(bool useDefaults ) void KDisplayConfig::save() { if (m_randrsimple->applySystemwideDisplayConfiguration(m_screenInfoArray, TRUE)) { - m_randrsimple->saveSystemwideDisplayConfiguration(base->systemEnableSupport->isChecked(), "", KDE_CONFDIR, m_screenInfoArray); + if (getuid() != 0) { + m_randrsimple->saveSystemwideDisplayConfiguration(base->systemEnableSupport->isChecked(), "", locateLocal("config", "/", true), m_screenInfoArray); + } + else { + m_randrsimple->saveSystemwideDisplayConfiguration(base->systemEnableSupport->isChecked(), "", KDE_CONFDIR, m_screenInfoArray); + } // Write system configuration systemconfig->setGroup(NULL); diff --git a/kcontrol/displayconfig/displayconfig.h b/kcontrol/displayconfig/displayconfig.h index 6c283e308..53541d8f8 100644 --- a/kcontrol/displayconfig/displayconfig.h +++ b/kcontrol/displayconfig/displayconfig.h @@ -61,7 +61,6 @@ public: void save(); void defaults(); - int buttons(); TQString quickHelp() const; k_dcop: diff --git a/kcontrol/displayconfig/displayconfigbase.ui b/kcontrol/displayconfig/displayconfigbase.ui index 05289e9b9..3ea1c57e7 100644 --- a/kcontrol/displayconfig/displayconfigbase.ui +++ b/kcontrol/displayconfig/displayconfigbase.ui @@ -4,14 +4,6 @@ <property name="name"> <cstring>DisplayConfigBase</cstring> </property> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>519</width> - <height>356</height> - </rect> - </property> <grid> <property name="name"> <cstring>unnamed</cstring> @@ -111,15 +103,21 @@ <property name="sizePolicy"> <sizepolicy> <hsizetype>7</hsizetype> - <vsizetype>1</vsizetype> + <vsizetype>7</vsizetype> <horstretch>1</horstretch> <verstretch>0</verstretch> </sizepolicy> </property> + <property name="minimumSize"> + <size> + <width>150</width> + <height>150</height> + </size> + </property> <property name="maximumSize"> <size> <width>32767</width> - <height>200</height> + <height>400</height> </size> </property> </widget> @@ -193,7 +191,7 @@ </widget> </grid> </widget> - <widget class="TQGroupBox" row="4" column="2" colspan="2"> + <widget class="TQGroupBox" row="4" column="2" colspan="1"> <property name="name"> <cstring>groupColorDepth</cstring> </property> @@ -216,7 +214,7 @@ </widget> </grid> </widget> - <widget class="TQGroupBox" row="5" column="0" colspan="4"> + <widget class="TQGroupBox" row="4" column="3" colspan="1"> <property name="name"> <cstring>groupOrientation</cstring> </property> @@ -240,7 +238,7 @@ <string>&Mirror screen horizontally</string> </property> </widget> - <widget class="TQCheckBox" row="0" column="2" colspan="1"> + <widget class="TQCheckBox" row="1" column="1" colspan="1"> <property name="name"> <cstring>orientationVFlip</cstring> </property> @@ -363,6 +361,9 @@ <string>Visual Calibration Aid</string> </property> <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> <widget class="TQWidget" row="0" column="0" colspan="2"> <property name="name"> <cstring>gammaTestImage</cstring> @@ -405,10 +406,10 @@ </property> <property name="sizeHint"> <size> - <width>20</width> - <height>20</height> - </size> - </property> + <width>20</width> + <height>20</height> + </size> + </property> </spacer> <spacer row="1" column="2"> <property name="name" stdset="0"> @@ -427,8 +428,8 @@ </size> </property> </spacer> - </grid> - </widget> + </grid> + </widget> <widget class="TQGroupBox" row="1" column="0" colspan="1"> <property name="name"> <cstring>groupHardware</cstring> @@ -587,25 +588,25 @@ <string>Tip: Most computer software expects a gamma of 2.2.<br>Additionally, any ICC settings for the selected screen will override the gamma controls available on this tab.</string> </property> </widget> - <spacer row="4" column="0"> - <property name="name" stdset="0"> - <cstring>Spacer4</cstring> - </property> - <property name="orientation"> - <enum>Vertical</enum> - </property> - <property name="sizeType"> - <enum>Expanding</enum> - </property> - <property name="sizeHint"> - <size> - <width>20</width> - <height>20</height> - </size> - </property> - </spacer> </grid> </widget> + <spacer row="3" column="0"> + <property name="name" stdset="0"> + <cstring>Spacer5</cstring> + </property> + <property name="orientation"> + <enum>Vertical</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> </grid> </grid> </widget> diff --git a/kcontrol/hwmanager/devicepropsdlgbase.ui b/kcontrol/hwmanager/devicepropsdlgbase.ui index bd3688402..5f6c2c166 100644 --- a/kcontrol/hwmanager/devicepropsdlgbase.ui +++ b/kcontrol/hwmanager/devicepropsdlgbase.ui @@ -4,14 +4,6 @@ <property name="name"> <cstring>DevicePropertiesDialogBase</cstring> </property> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>519</width> - <height>356</height> - </rect> - </property> <grid> <property name="name"> <cstring>unnamed</cstring> diff --git a/kcontrol/hwmanager/hwmanager.cpp b/kcontrol/hwmanager/hwmanager.cpp index 96001349d..36dc89b3e 100644 --- a/kcontrol/hwmanager/hwmanager.cpp +++ b/kcontrol/hwmanager/hwmanager.cpp @@ -80,7 +80,7 @@ TDEHWManager::TDEHWManager(TQWidget *parent, const char *name, const TQStringLis base->deviceFilter->setListView(base->deviceTree); - setRootOnlyMsg(i18n("<b>Hardware settings are system wide, and requires administrator access</b><br>To alter the system's hardware settings, click on the \"Administrator Mode\" button below.")); + setRootOnlyMsg(i18n("<b>Hardware settings are system wide, and therefore require administrator access</b><br>To alter the system's hardware settings, click on the \"Administrator Mode\" button below.")); setUseRootOnlyMsg(true); TDEHardwareDevices *hwdevices = KGlobal::hardwareDevices(); diff --git a/kcontrol/hwmanager/hwmanager.h b/kcontrol/hwmanager/hwmanager.h index 89652cd32..a7c9749a7 100644 --- a/kcontrol/hwmanager/hwmanager.h +++ b/kcontrol/hwmanager/hwmanager.h @@ -52,8 +52,7 @@ public: void load( bool useDefaults); void save(); void defaults(); - - int buttons(); + TQString quickHelp() const; k_dcop: diff --git a/kcontrol/hwmanager/hwmanagerbase.ui b/kcontrol/hwmanager/hwmanagerbase.ui index 4b14ff428..632ec2259 100644 --- a/kcontrol/hwmanager/hwmanagerbase.ui +++ b/kcontrol/hwmanager/hwmanagerbase.ui @@ -4,14 +4,6 @@ <property name="name"> <cstring>TDEHWManagerBase</cstring> </property> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>519</width> - <height>356</height> - </rect> - </property> <grid> <property name="name"> <cstring>unnamed</cstring> diff --git a/kcontrol/iccconfig/iccconfig.cpp b/kcontrol/iccconfig/iccconfig.cpp index a2285dd49..28296dd5e 100644 --- a/kcontrol/iccconfig/iccconfig.cpp +++ b/kcontrol/iccconfig/iccconfig.cpp @@ -61,11 +61,16 @@ KSimpleConfig *systemconfig; /**** KICCConfig ****/ KICCConfig::KICCConfig(TQWidget *parent, const char *name, const TQStringList &) - : KCModule(KICCCFactory::instance(), parent, name) + : KCModule(KICCCFactory::instance(), parent, name), iccFileArray(NULL) { TQVBoxLayout *layout = new TQVBoxLayout(this, KDialog::marginHint(), KDialog::spacingHint()); - config = new KSimpleConfig( TQString::fromLatin1( "kiccconfigrc" )); + if (getuid() != 0) { + config = new KSimpleConfig( TQString::fromLatin1( "kiccconfigrc" )); + } + else { + config = NULL; + } systemconfig = new KSimpleConfig( TQString::fromLatin1( KDE_CONFDIR "/kicc/kiccconfigrc" )); KAboutData *about = @@ -80,7 +85,7 @@ KICCConfig::KICCConfig(TQWidget *parent, const char *name, const TQStringList &) layout->add(base); setRootOnlyMsg(i18n("<b>The global ICC color profile is a system wide setting, and requires administrator access</b><br>To alter the system's global ICC profile, click on the \"Administrator Mode\" button below.")); - setUseRootOnlyMsg(true); +// setUseRootOnlyMsg(true); // Setting this hides the Apply button! connect(base->systemEnableSupport, TQT_SIGNAL(clicked()), TQT_SLOT(changed())); connect(base->systemEnableSupport, TQT_SIGNAL(toggled(bool)), base->systemIccFile, TQT_SLOT(setEnabled(bool))); @@ -102,7 +107,7 @@ KICCConfig::KICCConfig(TQWidget *parent, const char *name, const TQStringList &) load(); - if (!config->checkConfigFilesWritable( true )) { + if (!config || !config->checkConfigFilesWritable( true )) { base->enableSupport->setEnabled(false); base->randrScreenList->setEnabled(false); base->iccProfileList->setEnabled(false); @@ -120,8 +125,12 @@ KICCConfig::KICCConfig(TQWidget *parent, const char *name, const TQStringList &) KICCConfig::~KICCConfig() { - delete [] iccFileArray; - delete config; + if (iccFileArray) { + delete [] iccFileArray; + } + if (config) { + delete config; + } delete systemconfig; } @@ -130,7 +139,7 @@ void KICCConfig::deleteProfile () { TQString *iccFileArrayNew; // Delete the profile - config->deleteGroup(base->iccProfileList->currentText()); + if (config) config->deleteGroup(base->iccProfileList->currentText()); base->iccProfileList->removeItem(base->iccProfileList->currentItem()); base->iccProfileList->setCurrentItem(base->iccProfileList->count()-1); @@ -171,7 +180,7 @@ void KICCConfig::renameProfile () { } // Rename the profile - config->deleteGroup(base->iccProfileList->currentText()); + if (config) config->deleteGroup(base->iccProfileList->currentText()); base->iccProfileList->changeItem(_new, base->iccProfileList->currentItem()); updateDisplayedInformation(); @@ -240,9 +249,11 @@ void KICCConfig::selectScreen (int slotNumber) { void KICCConfig::updateArray (void) { iccFileArray[((base->iccProfileList->currentItem())*(base->randrScreenList->count()))+(base->randrScreenList->currentItem())] = base->iccFile->url(); - config->setGroup(base->iccProfileList->currentText()); - if (config->readEntry(base->randrScreenList->currentText()) != iccFileArray[((base->iccProfileList->currentItem())*(base->randrScreenList->count()))+(base->randrScreenList->currentItem())]) { - emit changed(); + if (config) { + config->setGroup(base->iccProfileList->currentText()); + if (config->readEntry(base->randrScreenList->currentText()) != iccFileArray[((base->iccProfileList->currentItem())*(base->randrScreenList->count()))+(base->randrScreenList->currentItem())]) { + emit changed(); + } } } @@ -288,58 +299,69 @@ void KICCConfig::load(bool useDefaults ) XRROutputInfo *output_info; KRandrSimpleAPI *randrsimple = new KRandrSimpleAPI(); - config->setReadDefaults( useDefaults ); - - config->setGroup(NULL); - base->enableSupport->setChecked(config->readBoolEntry("EnableICC", false)); - base->randrScreenList->setEnabled(config->readBoolEntry("EnableICC", false)); - base->iccProfileList->setEnabled(config->readBoolEntry("EnableICC", false)); - base->iccFile->setEnabled(config->readBoolEntry("EnableICC", false)); - base->addProfileButton->setEnabled(config->readBoolEntry("EnableICC", false)); - base->renameProfileButton->setEnabled(config->readBoolEntry("EnableICC", false)); - base->deleteProfileButton->setEnabled(config->readBoolEntry("EnableICC", false)); - - numberOfScreens = 0; - if (randrsimple->isValid() == true) { - randr_display = XOpenDisplay(NULL); - randr_screen_info = randrsimple->read_screen_info(randr_display); - for (i = 0; i < randr_screen_info->n_output; i++) { - output_info = randr_screen_info->outputs[i]->info; - base->randrScreenList->insertItem(output_info->name, -1); + if (config) { + config->setReadDefaults( useDefaults ); + + config->setGroup(NULL); + base->enableSupport->setChecked(config->readBoolEntry("EnableICC", false)); + base->randrScreenList->setEnabled(config->readBoolEntry("EnableICC", false)); + base->iccProfileList->setEnabled(config->readBoolEntry("EnableICC", false)); + base->iccFile->setEnabled(config->readBoolEntry("EnableICC", false)); + base->addProfileButton->setEnabled(config->readBoolEntry("EnableICC", false)); + base->renameProfileButton->setEnabled(config->readBoolEntry("EnableICC", false)); + base->deleteProfileButton->setEnabled(config->readBoolEntry("EnableICC", false)); + + numberOfScreens = 0; + if (randrsimple->isValid() == true) { + randr_display = XOpenDisplay(NULL); + randr_screen_info = randrsimple->read_screen_info(randr_display); + for (i = 0; i < randr_screen_info->n_output; i++) { + output_info = randr_screen_info->outputs[i]->info; + base->randrScreenList->insertItem(output_info->name, -1); + numberOfScreens++; + } + } + else { + base->randrScreenList->insertItem("Default", -1); numberOfScreens++; } - } - else { - base->randrScreenList->insertItem("Default", -1); - numberOfScreens++; - } - // Find all profile names - numberOfProfiles = 0; - cfgProfiles = config->groupList(); - for (TQStringList::Iterator i(cfgProfiles.begin()); i != cfgProfiles.end(); ++i) { - base->iccProfileList->insertItem((*i), -1); - numberOfProfiles++; - } - if (numberOfProfiles == 0) { - base->iccProfileList->insertItem("<default>", -1); - numberOfProfiles++; - } + // Find all profile names + numberOfProfiles = 0; + cfgProfiles = config->groupList(); + for (TQStringList::Iterator i(cfgProfiles.begin()); i != cfgProfiles.end(); ++i) { + base->iccProfileList->insertItem((*i), -1); + numberOfProfiles++; + } + if (numberOfProfiles == 0) { + base->iccProfileList->insertItem("<default>", -1); + numberOfProfiles++; + } - // Load all profiles into memory - iccFileArray = new TQString[numberOfProfiles*numberOfScreens]; - for (i=0;i<(base->iccProfileList->count());i++) { - config->setGroup(base->iccProfileList->text(i)); - for (j=0;j<(base->randrScreenList->count());j++) { - iccFileArray[(i*(base->randrScreenList->count()))+j] = config->readEntry(base->randrScreenList->text(j)); + // Load all profiles into memory + iccFileArray = new TQString[numberOfProfiles*numberOfScreens]; + for (i=0;i<(base->iccProfileList->count());i++) { + config->setGroup(base->iccProfileList->text(i)); + for (j=0;j<(base->randrScreenList->count());j++) { + iccFileArray[(i*(base->randrScreenList->count()))+j] = config->readEntry(base->randrScreenList->text(j)); + } } - } - if ((findProfileIndex(base->iccProfileList->currentText()) >= 0) && (findScreenIndex(base->randrScreenList->currentText()) >= 0)) { - base->iccFile->setURL(iccFileArray[(findProfileIndex(base->iccProfileList->currentText())*base->randrScreenList->count())+findScreenIndex(base->randrScreenList->currentText())]); + if ((findProfileIndex(base->iccProfileList->currentText()) >= 0) && (findScreenIndex(base->randrScreenList->currentText()) >= 0)) { + base->iccFile->setURL(iccFileArray[(findProfileIndex(base->iccProfileList->currentText())*base->randrScreenList->count())+findScreenIndex(base->randrScreenList->currentText())]); + } + else { + base->iccFile->setURL(""); + } } else { - base->iccFile->setURL(""); + base->enableSupport->setChecked(false); + base->randrScreenList->setEnabled(false); + base->iccProfileList->setEnabled(false); + base->iccFile->setEnabled(false); + base->addProfileButton->setEnabled(false); + base->renameProfileButton->setEnabled(false); + base->deleteProfileButton->setEnabled(false); } systemconfig->setGroup(NULL); @@ -362,23 +384,25 @@ void KICCConfig::save() systemconfig->setGroup(NULL); systemconfig->writeEntry("EnableICC", base->systemEnableSupport->isChecked()); systemconfig->writeEntry("ICCFile", base->systemIccFile->url()); + systemconfig->sync(); - // Write user configuration - config->setGroup(NULL); - config->writeEntry("DefaultProfile", m_defaultProfile); - config->writeEntry("EnableICC", base->enableSupport->isChecked()); - - // Save all profiles to disk - for (i=0;i<(base->iccProfileList->count());i++) { - config->setGroup(base->iccProfileList->text(i)); - for (j=0;j<(base->randrScreenList->count());j++) { - config->writeEntry(base->randrScreenList->text(j), iccFileArray[(i*(base->randrScreenList->count()))+j]); + if (config) { + // Write user configuration + config->setGroup(NULL); + config->writeEntry("DefaultProfile", m_defaultProfile); + config->writeEntry("EnableICC", base->enableSupport->isChecked()); + + // Save all profiles to disk + for (i=0;i<(base->iccProfileList->count());i++) { + config->setGroup(base->iccProfileList->text(i)); + for (j=0;j<(base->randrScreenList->count());j++) { + config->writeEntry(base->randrScreenList->text(j), iccFileArray[(i*(base->randrScreenList->count()))+j]); + } } + + config->sync(); } - config->sync(); - systemconfig->sync(); - TQString errorstr; if (base->enableSupport->isChecked() == true) { errorstr = randrsimple->applyIccConfiguration(base->iccProfileList->currentText(), KDE_CONFDIR); diff --git a/kcontrol/iccconfig/iccconfig.h b/kcontrol/iccconfig/iccconfig.h index e3b91e34d..d113e5d84 100644 --- a/kcontrol/iccconfig/iccconfig.h +++ b/kcontrol/iccconfig/iccconfig.h @@ -53,7 +53,6 @@ public: void save(); void defaults(); - int buttons(); TQString quickHelp() const; k_dcop: diff --git a/kcontrol/iccconfig/iccconfigbase.ui b/kcontrol/iccconfig/iccconfigbase.ui index 9716563cb..0666c6e9f 100644 --- a/kcontrol/iccconfig/iccconfigbase.ui +++ b/kcontrol/iccconfig/iccconfigbase.ui @@ -4,14 +4,6 @@ <property name="name"> <cstring>ICCConfigBase</cstring> </property> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>519</width> - <height>356</height> - </rect> - </property> <grid> <property name="name"> <cstring>unnamed</cstring> @@ -598,6 +598,10 @@ if test "$kpersonalizerrc_general_firstlogin" = "true"; then fi fi +# Apply any user-specific display configuration settings +$TDEDIR/bin/tdeinit_displayconfig +EXIT_CODE="$?" + # Remove moodin cache if we have a new wallpaper installed, jriddell. Distro-specific. if [ -d "$tdehome/share/apps/ksplash/cache/Moodin/kubuntu" ]; then if [ /usr/share/wallpapers/kubuntu-wallpaper.png -nt "$tdehome/share/apps/ksplash/cache/Moodin/kubuntu/" ]; then diff --git a/tdeinit/CMakeLists.txt b/tdeinit/CMakeLists.txt index 6f1f7ba96..3fd7d934e 100644 --- a/tdeinit/CMakeLists.txt +++ b/tdeinit/CMakeLists.txt @@ -12,6 +12,7 @@ include_directories( ${TDE_INCLUDE_DIR} ${TQT_INCLUDE_DIRS} + ${CMAKE_BINARY_DIR} ) link_directories( @@ -26,3 +27,15 @@ tde_add_executable( tdeinit_phase1 LINK tdecore-shared DESTINATION ${BIN_INSTALL_DIR} ) + + +##### tdeinit_displayconfig (executable) ####################### +if( WITH_XRANDR ) + set( TDEINIT_DISPLAYCONFIG_OPTIONAL_LINK "krandr-shared" ) +endif ( ) + +tde_add_executable( tdeinit_displayconfig + SOURCES displayconfig.cpp + LINK tdecore-shared ${TDEINIT_DISPLAYCONFIG_OPTIONAL_LINK} + DESTINATION ${BIN_INSTALL_DIR} +)
\ No newline at end of file diff --git a/tdeinit/displayconfig.cpp b/tdeinit/displayconfig.cpp new file mode 100644 index 000000000..75445a98c --- /dev/null +++ b/tdeinit/displayconfig.cpp @@ -0,0 +1,72 @@ +/*************************************************************************** + * Copyright (C) 2012 Timothy Pearson <[email protected]> * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * + ***************************************************************************/ + +#include <config.h> + +#include <unistd.h> +#include <stdio.h> +#include <stdlib.h> + +#include <kapplication.h> +#include <kaboutdata.h> +#include <kcmdlineargs.h> +#include <kstandarddirs.h> +#include <klocale.h> +#include <kdebug.h> +#include <kconfig.h> + +#include <pwd.h> +#include <signal.h> + +#ifdef WITH_XRANDR +#include <libkrandr/libkrandr.h> +#endif + +static const char description[] = I18N_NOOP("TDE Initialization Display Configuration"); + +static const char version[] = "0.1"; + +static KCmdLineOptions options[] = +{ + KCmdLineLastOption +}; + +int main(int argc, char **argv) +{ + int return_code = -1; + + KAboutData about("tdeinit_displayconfig", I18N_NOOP("tdeinit_displayconfig"), version, description, + KAboutData::License_GPL, "(C) 2013 Timothy Pearson", 0, 0, "[email protected]"); + about.addAuthor( "Timothy Pearson", 0, "[email protected]" ); + KCmdLineArgs::init(argc, argv, &about); + KCmdLineArgs::addCmdLineOptions( options ); + + KApplication::disableAutoDcopRegistration(); + KApplication app; + +#ifdef WITH_XRANDR + // Load up user specific display settings + KRandrSimpleAPI *randrsimple = new KRandrSimpleAPI(); + randrsimple->applySystemwideDisplayConfiguration("", locateLocal("config", "/", true)); + delete randrsimple; +#endif + + return return_code = 0; +} + diff --git a/tdeinit/phase1.cpp b/tdeinit/phase1.cpp index e667503c2..32f5249ac 100644 --- a/tdeinit/phase1.cpp +++ b/tdeinit/phase1.cpp @@ -17,6 +17,8 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ +#include <config.h> + #include <unistd.h> #include <stdio.h> #include <stdlib.h> |