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 /kcontrol/displayconfig | |
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
Diffstat (limited to 'kcontrol/displayconfig')
-rw-r--r-- | kcontrol/displayconfig/displayconfig.cpp | 91 | ||||
-rw-r--r-- | kcontrol/displayconfig/displayconfig.h | 1 | ||||
-rw-r--r-- | kcontrol/displayconfig/displayconfigbase.ui | 73 |
3 files changed, 88 insertions, 77 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> |