diff options
author | Michele Calgaro <michele.calgaro@yahoo.it> | 2020-08-07 22:05:33 +0900 |
---|---|---|
committer | Michele Calgaro <michele.calgaro@yahoo.it> | 2020-08-08 00:41:23 +0900 |
commit | ce064fcb0190ef4b753668489a62f1e84d93c9a9 (patch) | |
tree | 1111e61b0e74d0fd32cf02dcf2f833474cc1fd1b | |
parent | 40d566dff5ed6c36ddfff3c0193564fc801ae369 (diff) | |
download | tdelibs-ce064fcb0190ef4b753668489a62f1e84d93c9a9.tar.gz tdelibs-ce064fcb0190ef4b753668489a62f1e84d93c9a9.zip |
Improved code for tderandr rotation string to allow translation in tdebase. This relates to issue #96.
Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
-rw-r--r-- | tderandr/libtderandr.cc | 41 | ||||
-rw-r--r-- | tderandr/libtderandr.h | 5 | ||||
-rw-r--r-- | tderandr/randr.cpp | 2 | ||||
-rw-r--r-- | tderandr/randr.h | 5 |
4 files changed, 26 insertions, 27 deletions
diff --git a/tderandr/libtderandr.cc b/tderandr/libtderandr.cc index eb7e96f9a..39e9c5b70 100644 --- a/tderandr/libtderandr.cc +++ b/tderandr/libtderandr.cc @@ -610,17 +610,16 @@ TQPtrList<SingleScreenData> KRandrSimpleAPI::loadDisplayConfiguration(TQString p int KRandrSimpleAPI::getHardwareRotationFlags(SingleScreenData* screendata) { int rotationFlags = 0; - TQString rotationDesired = *screendata->rotations.at(screendata->current_rotation_index); - if (rotationDesired == ROTATION_0_DEGREES_STRING) { + if (screendata->current_rotation_index == ROTATION_0_DEGREES_INDEX) { rotationFlags = rotationFlags | RandRScreen::Rotate0; } - else if (rotationDesired == ROTATION_90_DEGREES_STRING) { + else if (screendata->current_rotation_index == ROTATION_90_DEGREES_INDEX) { rotationFlags = rotationFlags | RandRScreen::Rotate90; } - else if (rotationDesired == ROTATION_180_DEGREES_STRING) { + else if (screendata->current_rotation_index == ROTATION_180_DEGREES_INDEX) { rotationFlags = rotationFlags | RandRScreen::Rotate180; } - else if (rotationDesired == ROTATION_270_DEGREES_STRING) { + else if (screendata->current_rotation_index == ROTATION_270_DEGREES_INDEX) { rotationFlags = rotationFlags | RandRScreen::Rotate270; } if (screendata->has_x_flip) { @@ -667,10 +666,10 @@ bool KRandrSimpleAPI::applyDisplayConfiguration(TQPtrList<SingleScreenData> scre command.append(TQString(" --pos %1x%2").arg(screendata->absolute_x_position).arg(screendata->absolute_y_position)); command.append(TQString(" --refresh %1").arg(atoi((*screendata->refresh_rates.at(screendata->current_refresh_rate_index)).ascii()))); command.append(TQString(" --gamma %1:%2:%3").arg(screendata->gamma_red).arg(screendata->gamma_green).arg(screendata->gamma_blue)); - if (screendata->current_rotation_index == 0) command.append(" --rotate ").append("normal"); - if (screendata->current_rotation_index == 1) command.append(" --rotate ").append("left"); - if (screendata->current_rotation_index == 2) command.append(" --rotate ").append("inverted"); - if (screendata->current_rotation_index == 3) command.append(" --rotate ").append("right"); + if (screendata->current_rotation_index == ROTATION_0_DEGREES_INDEX) command.append(" --rotate ").append("normal"); + if (screendata->current_rotation_index == ROTATION_90_DEGREES_INDEX) command.append(" --rotate ").append("left"); + if (screendata->current_rotation_index == ROTATION_180_DEGREES_INDEX) command.append(" --rotate ").append("inverted"); + if (screendata->current_rotation_index == ROTATION_270_DEGREES_INDEX) command.append(" --rotate ").append("right"); if ((screendata->has_x_flip == 0) && (screendata->has_y_flip == 0)) command.append(" --reflect ").append("normal"); if ((screendata->has_x_flip == 1) && (screendata->has_y_flip == 0)) command.append(" --reflect ").append("x"); if ((screendata->has_x_flip == 0) && (screendata->has_y_flip == 1)) command.append(" --reflect ").append("y"); @@ -1308,30 +1307,30 @@ TQPtrList<SingleScreenData> KRandrSimpleAPI::readCurrentDisplayConfiguration() { // RandRScreen::ReflectX // RandRScreen::ReflectY - screendata->rotations.append(i18n(ROTATION_0_DEGREES_STRING)); - screendata->rotations.append(i18n(ROTATION_90_DEGREES_STRING)); - screendata->rotations.append(i18n(ROTATION_180_DEGREES_STRING)); - screendata->rotations.append(i18n(ROTATION_270_DEGREES_STRING)); + screendata->rotations.append(i18n("0 degrees")); + screendata->rotations.append(i18n("90 degrees")); + screendata->rotations.append(i18n("180 degrees")); + screendata->rotations.append(i18n("270 degrees")); screendata->supports_transformations = (cur_screen->rotations() != RandRScreen::Rotate0); if (screendata->supports_transformations) { screendata->current_orientation_mask = cur_screen->proposedRotation(); switch (screendata->current_orientation_mask & RandRScreen::RotateMask) { case RandRScreen::Rotate0: - screendata->current_rotation_index = 0; + screendata->current_rotation_index = ROTATION_0_DEGREES_INDEX; break; case RandRScreen::Rotate90: - screendata->current_rotation_index = 1; + screendata->current_rotation_index = ROTATION_90_DEGREES_INDEX; break; case RandRScreen::Rotate180: - screendata->current_rotation_index = 2; + screendata->current_rotation_index = ROTATION_180_DEGREES_INDEX; break; case RandRScreen::Rotate270: - screendata->current_rotation_index = 3; + screendata->current_rotation_index = ROTATION_270_DEGREES_INDEX; break; default: // Shouldn't hit this one Q_ASSERT(screendata->current_orientation_mask & RandRScreen::RotateMask); - screendata->current_rotation_index = 0; + screendata->current_rotation_index = ROTATION_0_DEGREES_INDEX; break; } screendata->has_x_flip = (screendata->current_orientation_mask & RandRScreen::ReflectX); @@ -1340,7 +1339,7 @@ TQPtrList<SingleScreenData> KRandrSimpleAPI::readCurrentDisplayConfiguration() { else { screendata->has_x_flip = false; screendata->has_y_flip = false; - screendata->current_rotation_index = 0; + screendata->current_rotation_index = ROTATION_0_DEGREES_INDEX; } // Determine if this display is primary and/or extended @@ -1413,7 +1412,7 @@ TQPtrList<SingleScreenData> KRandrSimpleAPI::readCurrentDisplayConfiguration() { screendata->gamma_green = 2.2; screendata->gamma_blue = 2.2; - screendata->current_rotation_index = 0; + screendata->current_rotation_index = ROTATION_0_DEGREES_INDEX; screendata->current_orientation_mask = 0; screendata->has_x_flip = false; screendata->has_y_flip = false; @@ -1455,7 +1454,7 @@ TQPtrList<SingleScreenData> KRandrSimpleAPI::readCurrentDisplayConfiguration() { screendata->gamma_green = 2.2; screendata->gamma_blue = 2.2; - screendata->current_rotation_index = 0; + screendata->current_rotation_index = ROTATION_0_DEGREES_INDEX; screendata->current_orientation_mask = 0; screendata->has_x_flip = false; screendata->has_y_flip = false; diff --git a/tderandr/libtderandr.h b/tderandr/libtderandr.h index 0e07ad96e..cccce2594 100644 --- a/tderandr/libtderandr.h +++ b/tderandr/libtderandr.h @@ -35,11 +35,6 @@ #include <ksimpleconfig.h> #include <tdelibs_export.h> -#define ROTATION_0_DEGREES_STRING "0 degrees" -#define ROTATION_90_DEGREES_STRING "90 degrees" -#define ROTATION_180_DEGREES_STRING "180 degrees" -#define ROTATION_270_DEGREES_STRING "270 degrees" - /** * Simple API covering most of the uses of libtderandr. * diff --git a/tderandr/randr.cpp b/tderandr/randr.cpp index c72dcd651..d00641154 100644 --- a/tderandr/randr.cpp +++ b/tderandr/randr.cpp @@ -63,7 +63,7 @@ SingleScreenData::SingleScreenData() gamma_green = 0.0; gamma_blue = 0.0; - current_rotation_index = 0; + current_rotation_index = ROTATION_0_DEGREES_INDEX; current_orientation_mask = 0; has_x_flip = false; has_y_flip = false; diff --git a/tderandr/randr.h b/tderandr/randr.h index 9683f6b9b..ee00b2065 100644 --- a/tderandr/randr.h +++ b/tderandr/randr.h @@ -26,6 +26,11 @@ #include <tdecmodule.h> #include <tdeconfig.h> +#define ROTATION_0_DEGREES_INDEX 0 +#define ROTATION_90_DEGREES_INDEX 1 +#define ROTATION_180_DEGREES_INDEX 2 +#define ROTATION_270_DEGREES_INDEX 3 + class KTimerDialog; class RandRScreenPrivate; |