From dc6b76cac424bdf8b3cffb4ae82f3954d8acdba5 Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Sat, 26 Jan 2013 13:16:20 -0600 Subject: Rename a number of libraries and executables to avoid conflicts with KDE4 --- kcontrol/randr/CMakeLists.txt | 18 +- kcontrol/randr/Makefile.am | 26 +- kcontrol/randr/configdialog.cpp | 4 +- kcontrol/randr/krandrapp.cpp | 47 -- kcontrol/randr/krandrapp.h | 44 -- kcontrol/randr/krandrbindings.cpp | 34 - kcontrol/randr/krandrinithack.cpp | 0 kcontrol/randr/krandrmodule.cpp | 365 ----------- kcontrol/randr/krandrmodule.h | 68 -- kcontrol/randr/krandrpassivepopup.cpp | 118 ---- kcontrol/randr/krandrpassivepopup.h | 47 -- kcontrol/randr/krandrtray-autostart.desktop | 144 ----- kcontrol/randr/krandrtray.cpp | 884 -------------------------- kcontrol/randr/krandrtray.desktop | 141 ---- kcontrol/randr/krandrtray.h | 94 --- kcontrol/randr/main.cpp | 10 +- kcontrol/randr/tderandrapp.cpp | 47 ++ kcontrol/randr/tderandrapp.h | 44 ++ kcontrol/randr/tderandrbindings.cpp | 34 + kcontrol/randr/tderandrinithack.cpp | 0 kcontrol/randr/tderandrmodule.cpp | 365 +++++++++++ kcontrol/randr/tderandrmodule.h | 68 ++ kcontrol/randr/tderandrpassivepopup.cpp | 118 ++++ kcontrol/randr/tderandrpassivepopup.h | 47 ++ kcontrol/randr/tderandrtray-autostart.desktop | 144 +++++ kcontrol/randr/tderandrtray.cpp | 884 ++++++++++++++++++++++++++ kcontrol/randr/tderandrtray.desktop | 141 ++++ kcontrol/randr/tderandrtray.h | 94 +++ 28 files changed, 2015 insertions(+), 2015 deletions(-) delete mode 100644 kcontrol/randr/krandrapp.cpp delete mode 100644 kcontrol/randr/krandrapp.h delete mode 100644 kcontrol/randr/krandrbindings.cpp delete mode 100644 kcontrol/randr/krandrinithack.cpp delete mode 100644 kcontrol/randr/krandrmodule.cpp delete mode 100644 kcontrol/randr/krandrmodule.h delete mode 100644 kcontrol/randr/krandrpassivepopup.cpp delete mode 100644 kcontrol/randr/krandrpassivepopup.h delete mode 100644 kcontrol/randr/krandrtray-autostart.desktop delete mode 100644 kcontrol/randr/krandrtray.cpp delete mode 100644 kcontrol/randr/krandrtray.desktop delete mode 100644 kcontrol/randr/krandrtray.h create mode 100644 kcontrol/randr/tderandrapp.cpp create mode 100644 kcontrol/randr/tderandrapp.h create mode 100644 kcontrol/randr/tderandrbindings.cpp create mode 100644 kcontrol/randr/tderandrinithack.cpp create mode 100644 kcontrol/randr/tderandrmodule.cpp create mode 100644 kcontrol/randr/tderandrmodule.h create mode 100644 kcontrol/randr/tderandrpassivepopup.cpp create mode 100644 kcontrol/randr/tderandrpassivepopup.h create mode 100644 kcontrol/randr/tderandrtray-autostart.desktop create mode 100644 kcontrol/randr/tderandrtray.cpp create mode 100644 kcontrol/randr/tderandrtray.desktop create mode 100644 kcontrol/randr/tderandrtray.h (limited to 'kcontrol/randr') diff --git a/kcontrol/randr/CMakeLists.txt b/kcontrol/randr/CMakeLists.txt index 3e816f2fb..d1f31af8c 100644 --- a/kcontrol/randr/CMakeLists.txt +++ b/kcontrol/randr/CMakeLists.txt @@ -22,26 +22,26 @@ link_directories( ##### other data ################################ -install( FILES krandrtray.desktop DESTINATION ${XDG_APPS_INSTALL_DIR} ) +install( FILES tderandrtray.desktop DESTINATION ${XDG_APPS_INSTALL_DIR} ) install( FILES randr.desktop DESTINATION ${APPS_INSTALL_DIR}/.hidden ) -install( FILES krandrtray-autostart.desktop DESTINATION ${AUTOSTART_INSTALL_DIR} ) +install( FILES tderandrtray-autostart.desktop DESTINATION ${AUTOSTART_INSTALL_DIR} ) ##### kcm_randr (module) ######################## tde_add_kpart( kcm_randr AUTOMOC - SOURCES krandrmodule.cpp - LINK tdeui-shared krandr-shared + SOURCES tderandrmodule.cpp + LINK tdeui-shared tderandr-shared DESTINATION ${PLUGIN_INSTALL_DIR} ) -##### krandrtray (executable) ################### +##### tderandrtray (executable) ################### -tde_add_executable( krandrtray AUTOMOC +tde_add_executable( tderandrtray AUTOMOC SOURCES - main.cpp krandrtray.cpp krandrapp.cpp - krandrpassivepopup.cpp configdialog.cpp - LINK kutils-shared krandr-shared + main.cpp tderandrtray.cpp tderandrapp.cpp + tderandrpassivepopup.cpp configdialog.cpp + LINK tdeutils-shared tderandr-shared DESTINATION ${BIN_INSTALL_DIR} ) diff --git a/kcontrol/randr/Makefile.am b/kcontrol/randr/Makefile.am index fb55f8da7..d1f137140 100644 --- a/kcontrol/randr/Makefile.am +++ b/kcontrol/randr/Makefile.am @@ -5,32 +5,32 @@ kde_module_LTLIBRARIES = kcm_randr.la METASOURCES = AUTO -kcm_randr_la_SOURCES = krandrmodule.cpp +kcm_randr_la_SOURCES = tderandrmodule.cpp kcm_randr_la_LDFLAGS = -module -avoid-version $(all_libraries) -no-undefined kcm_randr_la_LIBADD = $(LIB_TDEUI) $(LIB_XRANDR) -noinst_HEADERS = krandrmodule.h krandrtray.h krandrapp.h \ - krandrpassivepopup.h configdialog.h +noinst_HEADERS = tderandrmodule.h tderandrtray.h tderandrapp.h \ + tderandrpassivepopup.h configdialog.h -xdg_apps_DATA = krandrtray.desktop +xdg_apps_DATA = tderandrtray.desktop -krandr_data_DATA = randr.desktop -krandr_datadir = $(kde_appsdir)/.hidden +tderandr_data_DATA = randr.desktop +tderandr_datadir = $(kde_appsdir)/.hidden # Autostart autostartdir = $(prefix)/share/autostart -autostart_DATA = krandrtray-autostart.desktop +autostart_DATA = tderandrtray-autostart.desktop #install-data-local: uninstall.desktop # $(mkinstalldirs) $(DESTDIR)$(kde_appsdir)/Settings/Desktop # $(INSTALL_DATA) $(srcdir)/uninstall.desktop -# $(DESTDIR)$(kde_appsdir)/Settings/Desktop/krandrmodule.desktop +# $(DESTDIR)$(kde_appsdir)/Settings/Desktop/tderandrmodule.desktop -bin_PROGRAMS = krandrtray +bin_PROGRAMS = tderandrtray -krandrtray_SOURCES = main.cpp krandrtray.cpp krandrapp.cpp krandrpassivepopup.cpp configdialog.cpp -krandrtray_LDFLAGS = $(all_libraries) $(KDE_RPATH) -lkrandr -krandrtray_LDADD = $(LIB_KFILE) $(LIB_KUTILS) $(LIB_XRANDR) +tderandrtray_SOURCES = main.cpp tderandrtray.cpp tderandrapp.cpp tderandrpassivepopup.cpp configdialog.cpp +tderandrtray_LDFLAGS = $(all_libraries) $(KDE_RPATH) -ltderandr +tderandrtray_LDADD = $(LIB_KFILE) $(LIB_KUTILS) $(LIB_XRANDR) messages: rc.cpp - $(XGETTEXT) *.cpp -o $(podir)/krandr.pot + $(XGETTEXT) *.cpp -o $(podir)/tderandr.pot diff --git a/kcontrol/randr/configdialog.cpp b/kcontrol/randr/configdialog.cpp index 708587527..f2344f1c0 100644 --- a/kcontrol/randr/configdialog.cpp +++ b/kcontrol/randr/configdialog.cpp @@ -31,7 +31,7 @@ #include #include #include -#include +#include #include "configdialog.h" @@ -42,7 +42,7 @@ ConfigDialog::ConfigDialog(TDEGlobalAccel *accel, Ok, 0L, "config dialog" ) { if ( isApplet ) - setHelp( TQString::null, "krandrtray" ); + setHelp( TQString::null, "tderandrtray" ); TQFrame *w = 0L; // the parent for the widgets diff --git a/kcontrol/randr/krandrapp.cpp b/kcontrol/randr/krandrapp.cpp deleted file mode 100644 index f5cfbbde1..000000000 --- a/kcontrol/randr/krandrapp.cpp +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2002,2003 Hamish Rodda - * - * 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 - -#include "krandrapp.h" -#include "krandrapp.moc" - -#include "krandrtray.h" - -#include - -KRandRApp::KRandRApp() - : m_tray(new KRandRSystemTray(0L, "RANDRTray")) -{ - connect(&m_eventMergingTimer, TQT_SIGNAL(timeout()), this, TQT_SLOT(handleX11ConfigChangeEvent())); - m_tray->show(); -} - -void KRandRApp::handleX11ConfigChangeEvent() -{ - m_eventMergingTimer.stop(); - m_tray->configChanged(); -} - -bool KRandRApp::x11EventFilter(XEvent* e) -{ - if (e->type == m_tray->screenChangeNotifyEvent()) { - m_eventMergingTimer.start(1000, TRUE); - } - return TDEApplication::x11EventFilter( e ); -} diff --git a/kcontrol/randr/krandrapp.h b/kcontrol/randr/krandrapp.h deleted file mode 100644 index 766b0056c..000000000 --- a/kcontrol/randr/krandrapp.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2002 Hamish Rodda - * - * 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. - */ - -#ifndef KRANDRAPP_H -#define KRANDRAPP_H - -#include -#include - -class KRandRSystemTray; - -class KRandRApp : public KUniqueApplication -{ - Q_OBJECT - -public: - KRandRApp(); - - virtual bool x11EventFilter(XEvent * e); - -private slots: - void handleX11ConfigChangeEvent(); - -private: - KRandRSystemTray* m_tray; - TQTimer m_eventMergingTimer; -}; - -#endif diff --git a/kcontrol/randr/krandrbindings.cpp b/kcontrol/randr/krandrbindings.cpp deleted file mode 100644 index d71057748..000000000 --- a/kcontrol/randr/krandrbindings.cpp +++ /dev/null @@ -1,34 +0,0 @@ -// -*- Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 8; -*- -/* This file is part of the KDE project - Copyright (C) by Andrew Stanley-Jones - - 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; see the file COPYING. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ -#ifndef NOSLOTS -# define DEF( name, key3, key4, fnSlot ) \ - keys->insert( name, i18n(name), TQString(), key3, key4, TQT_TQOBJECT(this), TQT_SLOT(fnSlot) ) -#else -# define DEF( name, key3, key4, fnSlot ) \ - keys->insert( name, i18n(name), TQString(), key3, key4 ) -#endif -#define WIN KKey::QtWIN - - keys->insert( "Program:krandrtray", i18n("Display Control") ); - - DEF( I18N_NOOP("Switch Displays"), KShortcut(TQString("XF86Display")), KShortcut(TQString("XF86Display")), slotCycleDisplays() ); - -#undef DEF -#undef WIN diff --git a/kcontrol/randr/krandrinithack.cpp b/kcontrol/randr/krandrinithack.cpp deleted file mode 100644 index e69de29bb..000000000 diff --git a/kcontrol/randr/krandrmodule.cpp b/kcontrol/randr/krandrmodule.cpp deleted file mode 100644 index 3eaf46f8b..000000000 --- a/kcontrol/randr/krandrmodule.cpp +++ /dev/null @@ -1,365 +0,0 @@ -/* - * Copyright (c) 2002,2003 Hamish Rodda - * - * 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include "krandrmodule.h" -#include "krandrmodule.moc" - -#include -#include - -// DLL Interface for kcontrol -typedef KGenericFactory KSSFactory; -K_EXPORT_COMPONENT_FACTORY (kcm_randr, KSSFactory("krandr") ) -extern "C" - -{ - KDE_EXPORT void init_randr() - { - KRandRModule::performApplyOnStartup(); - } - - KDE_EXPORT bool test_randr() - { - int eventBase, errorBase; - if( XRRQueryExtension(tqt_xdisplay(), &eventBase, &errorBase ) ) - return true; - return false; - } -} - -void KRandRModule::performApplyOnStartup() -{ - TDEConfig config("kcmrandrrc", true); - if (RandRDisplay::applyOnStartup(config)) - { - // Load settings and apply appropriate config - RandRDisplay display; - if (display.isValid() && display.loadDisplay(config)) - display.applyProposed(false); - } -} - -KRandRModule::KRandRModule(TQWidget *parent, const char *name, const TQStringList&) - : TDECModule(parent, name) - , m_changed(false) -{ - if (!isValid()) { - TQVBoxLayout *topLayout = new TQVBoxLayout(this); - topLayout->addWidget(new TQLabel(i18n("Your X server does not support resizing and rotating the display. Please update to version 4.3 or greater. You need the X Resize And Rotate extension (RANDR) version 1.1 or greater to use this feature."), this)); - kdWarning() << "Error: " << errorCode() << endl; - return; - } - - TQVBoxLayout* topLayout = new TQVBoxLayout(this, 0, KDialog::spacingHint()); - - TQHBox* screenBox = new TQHBox(this); - topLayout->addWidget(screenBox); - TQLabel *screenLabel = new TQLabel(i18n("Settings for screen:"), screenBox); - m_screenSelector = new KComboBox(screenBox); - - for (int s = 0; s < numScreens(); s++) { - m_screenSelector->insertItem(i18n("Screen %1").arg(s+1)); - } - - m_screenSelector->setCurrentItem(currentScreenIndex()); - screenLabel->setBuddy( m_screenSelector ); - TQWhatsThis::add(m_screenSelector, i18n("The screen whose settings you would like to change can be selected using this drop-down list.")); - - connect(m_screenSelector, TQT_SIGNAL(activated(int)), TQT_SLOT(slotScreenChanged(int))); - - if (numScreens() <= 1) - m_screenSelector->setEnabled(false); - - TQHBox* sizeBox = new TQHBox(this); - topLayout->addWidget(sizeBox); - TQLabel *sizeLabel = new TQLabel(i18n("Screen size:"), sizeBox); - m_sizeCombo = new KComboBox(sizeBox); - TQWhatsThis::add(m_sizeCombo, i18n("The size, otherwise known as the resolution, of your screen can be selected from this drop-down list.")); - connect(m_sizeCombo, TQT_SIGNAL(activated(int)), TQT_SLOT(slotSizeChanged(int))); - sizeLabel->setBuddy( m_sizeCombo ); - - TQHBox* refreshBox = new TQHBox(this); - topLayout->addWidget(refreshBox); - TQLabel *rateLabel = new TQLabel(i18n("Refresh rate:"), refreshBox); - m_refreshRates = new KComboBox(refreshBox); - TQWhatsThis::add(m_refreshRates, i18n("The refresh rate of your screen can be selected from this drop-down list.")); - connect(m_refreshRates, TQT_SIGNAL(activated(int)), TQT_SLOT(slotRefreshChanged(int))); - rateLabel->setBuddy( m_refreshRates ); - - m_rotationGroup = new TQButtonGroup(2, Qt::Horizontal, i18n("Orientation (degrees counterclockwise)"), this); - topLayout->addWidget(m_rotationGroup); - m_rotationGroup->setRadioButtonExclusive(true); - TQWhatsThis::add(m_rotationGroup, i18n("The options in this section allow you to change the rotation of your screen.")); - - m_applyOnStartup = new TQCheckBox(i18n("Apply settings on TDE startup"), this); - topLayout->addWidget(m_applyOnStartup); - TQWhatsThis::add(m_applyOnStartup, i18n("If this option is enabled the size and orientation settings will be used when TDE starts.")); - connect(m_applyOnStartup, TQT_SIGNAL(clicked()), TQT_SLOT(setChanged())); - - TQHBox* syncBox = new TQHBox(this); - syncBox->layout()->addItem(new TQSpacerItem(20, 1, TQSizePolicy::Maximum)); - m_syncTrayApp = new TQCheckBox(i18n("Allow tray application to change startup settings"), syncBox); - topLayout->addWidget(syncBox); - TQWhatsThis::add(m_syncTrayApp, i18n("If this option is enabled, options set by the system tray applet will be saved and loaded when TDE starts instead of being temporary.")); - connect(m_syncTrayApp, TQT_SIGNAL(clicked()), TQT_SLOT(setChanged())); - - topLayout->addStretch(1); - - // just set the "apply settings on startup" box - load(); - m_syncTrayApp->setEnabled(m_applyOnStartup->isChecked()); - - slotScreenChanged(TQApplication::desktop()->primaryScreen()); - - setButtons(TDECModule::Apply); -} - -void KRandRModule::addRotationButton(int thisRotation, bool checkbox) -{ - Q_ASSERT(m_rotationGroup); - if (!checkbox) { - TQRadioButton* thisButton = new TQRadioButton(RandRScreen::rotationName(thisRotation), m_rotationGroup); - thisButton->setEnabled(thisRotation & currentScreen()->rotations()); - connect(thisButton, TQT_SIGNAL(clicked()), TQT_SLOT(slotRotationChanged())); - } else { - TQCheckBox* thisButton = new TQCheckBox(RandRScreen::rotationName(thisRotation), m_rotationGroup); - thisButton->setEnabled(thisRotation & currentScreen()->rotations()); - connect(thisButton, TQT_SIGNAL(clicked()), TQT_SLOT(slotRotationChanged())); - } -} - -void KRandRModule::slotScreenChanged(int screen) -{ - setCurrentScreen(screen); - - // Clear resolutions - m_sizeCombo->clear(); - - // Add new resolutions - for (int i = 0; i < currentScreen()->numSizes(); i++) { - m_sizeCombo->insertItem(i18n("%1 x %2").arg(currentScreen()->pixelSize(i).width()).arg(currentScreen()->pixelSize(i).height())); - - // Aspect ratio - /* , aspect ratio %5)*/ - /*.arg((double)currentScreen()->size(i).mwidth / (double)currentScreen()->size(i).mheight))*/ - } - - // Clear rotations - for (int i = m_rotationGroup->count() - 1; i >= 0; i--) - m_rotationGroup->remove(m_rotationGroup->find(i)); - - // Create rotations - for (int i = 0; i < RandRScreen::OrientationCount; i++) - addRotationButton(1 << i, i > RandRScreen::RotationCount - 1); - - populateRefreshRates(); - - update(); - - setChanged(); -} - -void KRandRModule::slotRotationChanged() -{ - if (m_rotationGroup->find(0)->isOn()) - currentScreen()->proposeRotation(RandRScreen::Rotate0); - else if (m_rotationGroup->find(1)->isOn()) - currentScreen()->proposeRotation(RandRScreen::Rotate90); - else if (m_rotationGroup->find(2)->isOn()) - currentScreen()->proposeRotation(RandRScreen::Rotate180); - else { - Q_ASSERT(m_rotationGroup->find(3)->isOn()); - currentScreen()->proposeRotation(RandRScreen::Rotate270); - } - - if (m_rotationGroup->find(4)->isOn()) - currentScreen()->proposeRotation(currentScreen()->proposedRotation() ^ RandRScreen::ReflectX); - - if (m_rotationGroup->find(5)->isOn()) - currentScreen()->proposeRotation(currentScreen()->proposedRotation() ^ RandRScreen::ReflectY); - - setChanged(); -} - -void KRandRModule::slotSizeChanged(int index) -{ - int oldProposed = currentScreen()->proposedSize(); - - currentScreen()->proposeSize(index); - - if (currentScreen()->proposedSize() != oldProposed) { - currentScreen()->proposeRefreshRate(0); - - populateRefreshRates(); - - // Item with index zero is already selected - } - - setChanged(); -} - -void KRandRModule::slotRefreshChanged(int index) -{ - currentScreen()->proposeRefreshRate(index); - - setChanged(); -} - -void KRandRModule::populateRefreshRates() -{ - m_refreshRates->clear(); - - TQStringList rr = currentScreen()->refreshRates(currentScreen()->proposedSize()); - - m_refreshRates->setEnabled(rr.count()); - - for (TQStringList::Iterator it = rr.begin(); it != rr.end(); ++it) - m_refreshRates->insertItem(*it); -} - - -void KRandRModule::defaults() -{ - load( true ); -} - -void KRandRModule::load() -{ - load( false ); -} - -void KRandRModule::load( bool useDefaults ) -{ - if (!isValid()) - return; - - // Don't load screen configurations: - // It will be correct already if they wanted to retain their settings over TDE restarts, - // and if it isn't correct they have changed a) their X configuration, b) the screen - // with another program, or c) their hardware. - TDEConfig config("kcmrandrrc", true); - - config.setReadDefaults( useDefaults ); - - m_oldApply = loadDisplay(config, false); - m_oldSyncTrayApp = syncTrayApp(config); - - m_applyOnStartup->setChecked(m_oldApply); - m_syncTrayApp->setChecked(m_oldSyncTrayApp); - - emit changed( useDefaults ); -} - -void KRandRModule::save() -{ - if (!isValid()) - return; - - apply(); - - m_oldApply = m_applyOnStartup->isChecked(); - m_oldSyncTrayApp = m_syncTrayApp->isChecked(); - TDEConfig config("kcmrandrrc"); - saveDisplay(config, m_oldApply, m_oldSyncTrayApp); - - setChanged(); -} - -void KRandRModule::setChanged() -{ - bool isChanged = (m_oldApply != m_applyOnStartup->isChecked()) || (m_oldSyncTrayApp != m_syncTrayApp->isChecked()); - m_syncTrayApp->setEnabled(m_applyOnStartup->isChecked()); - - if (!isChanged) - for (int screenIndex = 0; screenIndex < numScreens(); screenIndex++) { - if (screen(screenIndex)->proposedChanged()) { - isChanged = true; - break; - } - } - - if (isChanged != m_changed) { - m_changed = isChanged; - emit changed(m_changed); - } -} - -void KRandRModule::apply() -{ - if (m_changed) { - applyProposed(); - - update(); - } -} - - -void KRandRModule::update() -{ - m_sizeCombo->blockSignals(true); - m_sizeCombo->setCurrentItem(currentScreen()->proposedSize()); - m_sizeCombo->blockSignals(false); - - m_rotationGroup->blockSignals(true); - switch (currentScreen()->proposedRotation() & RandRScreen::RotateMask) { - case RandRScreen::Rotate0: - m_rotationGroup->setButton(0); - break; - case RandRScreen::Rotate90: - m_rotationGroup->setButton(1); - break; - case RandRScreen::Rotate180: - m_rotationGroup->setButton(2); - break; - case RandRScreen::Rotate270: - m_rotationGroup->setButton(3); - break; - default: - // Shouldn't hit this one - Q_ASSERT(currentScreen()->proposedRotation() & RandRScreen::RotateMask); - break; - } - m_rotationGroup->find(4)->setDown(currentScreen()->proposedRotation() & RandRScreen::ReflectX); - m_rotationGroup->find(5)->setDown(currentScreen()->proposedRotation() & RandRScreen::ReflectY); - m_rotationGroup->blockSignals(false); - - m_refreshRates->blockSignals(true); - m_refreshRates->setCurrentItem(currentScreen()->proposedRefreshRate()); - m_refreshRates->blockSignals(false); -} - diff --git a/kcontrol/randr/krandrmodule.h b/kcontrol/randr/krandrmodule.h deleted file mode 100644 index 53d428fe1..000000000 --- a/kcontrol/randr/krandrmodule.h +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (c) 2002 Hamish Rodda - * - * 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. - */ - -#ifndef KRANDRMODULE_H -#define KRANDRMODULE_H - -#include - -class TQButtonGroup; -class KComboBox; -class TQCheckBox; - -class KRandRModule : public TDECModule, public KRandrSimpleAPI -{ - Q_OBJECT - -public: - KRandRModule(TQWidget *parent, const char *name, const TQStringList& _args); - - virtual void load(); - virtual void load(bool useDefaults); - virtual void save(); - virtual void defaults(); - - static void performApplyOnStartup(); - -protected slots: - void slotScreenChanged(int screen); - void slotRotationChanged(); - void slotSizeChanged(int index); - void slotRefreshChanged(int index); - void setChanged(); - -protected: - void apply(); - void update(); - - void addRotationButton(int thisRotation, bool checkbox); - void populateRefreshRates(); - - KComboBox* m_screenSelector; - KComboBox* m_sizeCombo; - TQButtonGroup* m_rotationGroup; - KComboBox* m_refreshRates; - TQCheckBox* m_applyOnStartup; - TQCheckBox* m_syncTrayApp; - bool m_oldApply; - bool m_oldSyncTrayApp; - - bool m_changed; -}; - -#endif diff --git a/kcontrol/randr/krandrpassivepopup.cpp b/kcontrol/randr/krandrpassivepopup.cpp deleted file mode 100644 index 12d9f8a3f..000000000 --- a/kcontrol/randr/krandrpassivepopup.cpp +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Copyright (c) 2003 Lubos Lunak - * - * 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 "krandrpassivepopup.h" - -#include - -// this class is just like KPassivePopup, but it keeps track of the widget -// it's supposed to be positioned next to, and adjust its position if that -// widgets moves (needed because after a resolution switch Kicker will -// reposition itself, causing normal KPassivePopup to stay at weird places) - -KRandrPassivePopup::KRandrPassivePopup( TQWidget *parent, const char *name, WFlags f ) - : KPassivePopup( parent, name, f ) - { - connect( &update_timer, TQT_SIGNAL( timeout()), TQT_SLOT( slotPositionSelf())); - } - -KRandrPassivePopup* KRandrPassivePopup::message( const TQString &caption, const TQString &text, - const TQPixmap &icon, TQWidget *parent, const char *name, int timeout ) - { - KRandrPassivePopup *pop = new KRandrPassivePopup( parent, name ); - pop->setAutoDelete( true ); - pop->setView( caption, text, icon ); - pop->setTimeout( timeout ); - pop->show(); - pop->startWatchingWidget( parent ); - return pop; - } - -void KRandrPassivePopup::startWatchingWidget( TQWidget* widget_P ) - { - static Atom wm_state = XInternAtom( tqt_xdisplay() , "WM_STATE", False ); - Window win = widget_P->winId(); - bool x11_events = false; - for(;;) - { - Window root, parent; - Window* children; - unsigned int nchildren; - XQueryTree( tqt_xdisplay(), win, &root, &parent, &children, &nchildren ); - if( children != NULL ) - XFree( children ); - if( win == root ) // huh? - break; - win = parent; - - TQWidget* widget = TQWidget::find( win ); - if( widget != NULL ) - { - widget->installEventFilter( this ); - watched_widgets.append( widget ); - } - else - { - XWindowAttributes attrs; - XGetWindowAttributes( tqt_xdisplay(), win, &attrs ); - XSelectInput( tqt_xdisplay(), win, attrs.your_event_mask | StructureNotifyMask ); - watched_windows.append( win ); - x11_events = true; - } - Atom type; - int format; - unsigned long nitems, after; - unsigned char* data; - if( XGetWindowProperty( tqt_xdisplay(), win, wm_state, 0, 0, False, AnyPropertyType, - &type, &format, &nitems, &after, &data ) == Success ) - { - if( data != NULL ) - XFree( data ); - if( type != None ) // toplevel window - break; - } - } - if( x11_events ) - kapp->installX11EventFilter( this ); - } - -bool KRandrPassivePopup::eventFilter( TQObject* o, TQEvent* e ) - { - if( e->type() == TQEvent::Move && o->isWidgetType() - && watched_widgets.contains( TQT_TQWIDGET( o ))) - TQTimer::singleShot( 0, this, TQT_SLOT( slotPositionSelf())); - return false; - } - -bool KRandrPassivePopup::x11Event( XEvent* e ) - { - if( e->type == ConfigureNotify && watched_windows.contains( e->xconfigure.window )) - { - if( !update_timer.isActive()) - update_timer.start( 10, true ); - return false; - } - return KPassivePopup::x11Event( e ); - } - -void KRandrPassivePopup::slotPositionSelf() - { - positionSelf(); - } - -#include "krandrpassivepopup.moc" diff --git a/kcontrol/randr/krandrpassivepopup.h b/kcontrol/randr/krandrpassivepopup.h deleted file mode 100644 index 3b1d4b4f6..000000000 --- a/kcontrol/randr/krandrpassivepopup.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2003 Lubos Lunak - * - * 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. - */ - -#ifndef __RANDRPASSIVEPOPUP_H__ -#define __RANDRPASSIVEPOPUP_H__ - -#include -#include -#include -#include - -class KRandrPassivePopup - : public KPassivePopup - { - Q_OBJECT - public: - static KRandrPassivePopup *message( const TQString &caption, const TQString &text, - const TQPixmap &icon, TQWidget *parent, const char *name=0, int timeout = -1 ); - protected: - virtual bool eventFilter( TQObject* o, TQEvent* e ); - virtual bool x11Event( XEvent* e ); - private slots: - void slotPositionSelf(); - private: - KRandrPassivePopup( TQWidget *parent=0, const char *name=0, WFlags f=0 ); - void startWatchingWidget( TQWidget* w ); - TQValueList< TQWidget* > watched_widgets; - TQValueList< Window > watched_windows; - TQTimer update_timer; - }; - -#endif diff --git a/kcontrol/randr/krandrtray-autostart.desktop b/kcontrol/randr/krandrtray-autostart.desktop deleted file mode 100644 index 0273a80cc..000000000 --- a/kcontrol/randr/krandrtray-autostart.desktop +++ /dev/null @@ -1,144 +0,0 @@ -[Desktop Entry] -Name=KRandRTray -Name[be]=Змена параметраў манітора -Name[hu]=Képernyőfelbontás -Name[ne]=KRandR ट्रे -Name[pt_BR]=Ícone do KRandR -Name[sv]=Krandrtray -Name[vi]=Khay KRandR -GenericName=Screen Resize & Rotate -GenericName[af]=Skerm Hervergroot & Roteer -GenericName[be]=Змена памераў экрана і перагортванне -GenericName[bg]=Размер и ротация на екрана -GenericName[bn]=পর্দা মাপবদল ও আবর্তন -GenericName[br]=Adventañ ha treiñ ar skramm -GenericName[bs]=Veličina i rotacija ekrana -GenericName[ca]=Amida i gira la pantalla -GenericName[cs]=Změna velikosti a rotace obrazovky -GenericName[csb]=Òbrócenié ë zjinaka miarë ekranu -GenericName[cy]=Newid Maint a Cylchdroi'r Sgrîn -GenericName[da]=Ændr størrelse på skærm & Rotér -GenericName[de]=Bildschirmgröße & -ausrichtung ändern -GenericName[el]=Αλλαγή μεγέθους & Περιστροφή οθόνης -GenericName[eo]=Regrandigi kaj Turni Ekranon -GenericName[es]=Redimensionar y rotar pantalla -GenericName[et]=Ekraani suuruse muutmine ja pööramine -GenericName[eu]=Pantailaren tamaina aldaketa eta biraketa -GenericName[fa]=تغییر اندازه و چرخش پرده -GenericName[fi]=Näytön kuvan koon muuttaminen ja kuvan kääntäminen -GenericName[fr]=Redimensionnement et rotation de l'écran -GenericName[fy]=Skerm rotearje en grutte wizigje -GenericName[gl]=Rotación e Redimensionamento da Pantallla -GenericName[he]=שינוי גודל המסך וסיבובו -GenericName[hr]=Veličine i orijentacija zaslona -GenericName[hu]=Képernyőbeállító -GenericName[is]=Stærð og snúningur skjáa -GenericName[it]=Ruota e ridimensiona lo schermo -GenericName[ja]=スクリーンのリサイズと回転 -GenericName[ka]=ეკრანის ზომა და ორიენტაცია -GenericName[kk]=Экранды өзгерту және бұрау -GenericName[km]=ប្ដូរ​ទំហំ & បង្វិល​អេក្រង់ -GenericName[ko]=화면 크기 조정 및 회전 -GenericName[lt]=Ekrano dydžio keitimas ir pasukimas -GenericName[mk]=Големина и ротација на екранот -GenericName[ms]=Saiz Semula Skrin & Putar -GenericName[nb]=Endre størrelsen på og rotere skjermbildet -GenericName[nds]=Schirmgrött un -utrichten ännern -GenericName[ne]=पर्दा रिसाइज र परिक्रमण -GenericName[nl]=Scherm roteren en grootte wijzigen -GenericName[nn]=Endra storleiken på og roter skjermbiletet -GenericName[pa]=ਪਰਦਾ ਮੁੜ ਆਕਾਰ ਤੇ ਘੁੰਮਾਓ -GenericName[pl]=Obrót i zmiana rozmiaru ekranu -GenericName[pt]=Mudar o Tamanho e Rodar o Ecrã -GenericName[pt_BR]=Redimensionar Tela & Rotacionar -GenericName[ro]=Redimensionare și rotire ecran -GenericName[ru]=Изменение размера и ориентации экрана -GenericName[rw]=Kuhindura ingano & Kuzengurutsa Mugaragaza -GenericName[se]=Rievdat šearbmagova sturrodaga ja jorat dan -GenericName[sk]=Zmena veľkosti a otočenia obrazovky -GenericName[sl]=Spreminjanje velikosti in obračanje zaslona -GenericName[sr]=Промена величине и ротација екрана -GenericName[sr@Latn]=Promena veličine i rotacija ekrana -GenericName[sv]=Ändra skärmstorlek och rotera -GenericName[ta]=திரை அளவு மாற்று & சுழற்று -GenericName[tg]=Ивази андоза ва мавқеи экран -GenericName[th]=ปรับขนาดและหมุนหน้าจอ -GenericName[tr]=Ekran Boyutlandır ve Döndür -GenericName[tt]=Küräk Ülçäme & Borılışı -GenericName[uk]=Зміна розміру та обертання екрана -GenericName[uz]=Ekraning oʻlchamini oʻzgartirish va burish -GenericName[uz@cyrillic]=Экранинг ўлчамини ўзгартириш ва буриш -GenericName[vi]=Thay đổi cỡ màn hình & Quay -GenericName[wa]=Candjî l' grandeu del waitroûle eyet l' tourner -GenericName[zh_CN]=屏幕大小和旋转 -GenericName[zh_TW]=螢幕調整大小及旋轉 -Comment=Resize and rotate X screens. -Comment[af]=Hervergroot en roteer X skerms. -Comment[ar]=غيير القياس و الدوران للشاشات X. -Comment[be]=Змена памераў і перагортванне экранаў X. -Comment[bg]=Размер и ротация на екрана. -Comment[bn]=আপনার এক্স-স্ক্রীণ-এর আকৃতি এবং দিশা পরিবর্তন করুন -Comment[br]=Adventañ ha treiñ ho diskweloù X. -Comment[bs]=Podesite veličinu i rotirajte vaš ekran. -Comment[ca]=Gira i amida les pantalles X. -Comment[cs]=Změna velikosti a rotace obrazovky. -Comment[csb]=Zjinaka miarë ë pòłożenia ekranów. -Comment[da]=Ændrer størrelse og roterer X-skærme -Comment[de]=Die Größe und Ausrichtung der Anzeige ändern -Comment[el]=Αλλαγή μεγέθους και περιστροφή της οθόνης. -Comment[eo]=Regrandigi kaj turni X ekranojn. -Comment[es]=Ajustar el tamaño y rotar las pantallas X. -Comment[et]=X'i ekraani muutmine ja pööramine -Comment[eu]=Aldatu tamaina eta biratu zure X pantailak. -Comment[fa]=تغییر‌ اندازه و چرخش پرده‌های X. -Comment[fi]=Näytön kuvan koon muuttaminen ja kuvan kääntäminen -Comment[fr]=Redimensionner et retourner votre affichage. -Comment[fy]=Skermgrutte wizigje en rotearje X skermen -Comment[ga]=Athraigh an méid agus rothlaigh scáileáin X. -Comment[gl]=Redimensionar e rotar pantallas -Comment[he]=שנה את גודלה של התצוגה שלך וסובב אותה. -Comment[hr]=Promjena veličine i orijentacije X zaslona -Comment[hu]=A képernyő átméretezése, elforgatása -Comment[is]=Breyta stærð skjásins og snúa honum. -Comment[it]=Ridimensiona e ruota gli schermi di X. -Comment[ja]=X スクリーンのリサイズと回転。 -Comment[ka]=ეკრანის ზომის და ორიენტაციის შეცვლა -Comment[kk]=Экранның өлшемін және бағытын өзгерту -Comment[km]=ប្ដូរ​ទំហំ និង​បង្វិល​អេក្រង់ X ។ -Comment[lt]=Keisti X ekrano dydį ir orientaciją. -Comment[mk]=Сменете ја големината и ротацијата на вашиот екран -Comment[nb]=Endrer størrelsen på og roterer X-skjermbildet -Comment[nds]=Grött un Utrichten vun den X-Schirm ännern -Comment[ne]=X पर्दा रिसाइज गर्नुहोस् र घुमाउनुहोस् -Comment[nl]=Scherm roteren en van grootte veranderen -Comment[nn]=Endra storleiken på og roter X-skjermbiletet. -Comment[pa]=X ਸਕਰੀਨ ਨੂੰ ਮੁੜ-ਅਕਾਰ ਅਤੇ ਘੁੰਮਾਓ। -Comment[pl]=Zmiana rozmiaru i orientacji ekranów. -Comment[pt]=Mudar o tamanho e rodar os ecrãs do X. -Comment[pt_BR]=Redimensiona e rotaciona as tela do X. -Comment[ro]=Redimensionează și rotește ecranele X. -Comment[ru]=Изменение размера и ориентации экранов X. -Comment[se]=Rievdat X-šearpmaid sturrodaga ja joraheami. -Comment[sk]=Zmení veľkosť a otočí obrazovky -Comment[sl]=Spremenite velikost in obrnite zaslon. -Comment[sr]=Промените величину и оријентацију екрана -Comment[sr@Latn]=Promenite veličinu i orijentaciju ekrana -Comment[sv]=Storleksändring och rotation av X-skärmar. -Comment[tg]=Ивази андоза ва мавқеи экранҳои Х. -Comment[th]=ปรับแต่งการแสดงผลของ X -Comment[tr]=Ekranı boyutlandır ve çevir. -Comment[uk]=Зміна розміру та обертання екранів X. -Comment[uz]=Ekraning oʻlchamini oʻzgartirish va burish -Comment[uz@cyrillic]=Экранинг ўлчамини ўзгартириш ва буриш -Comment[vi]=Đổi cỡ và quay màn hình X. -Comment[wa]=Candjî l' grandeu eyet tourner les waitroûles X. -Comment[zh_CN]=更改 X 屏幕的大小和旋转。 -Comment[zh_TW]=調整大小及旋轉 X 螢幕。 -Exec=krandrtray -Icon=randr -X-TDE-autostart-after=panel -X-TDE-StartupNotify=false -X-TDE-UniqueApplet=true -X-TDE-autostart-condition=krandrtrayrc:General:Autostart:true -Categories=System;Applet; - diff --git a/kcontrol/randr/krandrtray.cpp b/kcontrol/randr/krandrtray.cpp deleted file mode 100644 index f30e3102a..000000000 --- a/kcontrol/randr/krandrtray.cpp +++ /dev/null @@ -1,884 +0,0 @@ -/* - * Copyright (c) 2002,2003 Hamish Rodda - * - * 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 -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include "configdialog.h" - -#include "krandrtray.h" -#include "krandrpassivepopup.h" -#include "krandrtray.moc" - -#define OUTPUT_CONNECTED (1 << 0) -#define OUTPUT_UNKNOWN (1 << 1) -#define OUTPUT_DISCONNECTED (1 << 2) -#define OUTPUT_ON (1 << 3) -#define OUTPUT_ALL (0xf) - -KRandRSystemTray::KRandRSystemTray(TQWidget* parent, const char *name) - : KSystemTray(parent, name) - , m_popupUp(false) - , m_help(new KHelpMenu(this, TDEGlobal::instance()->aboutData(), false, actionCollection())) -{ - setPixmap(KSystemTray::loadSizedIcon("randr", width())); - setAlignment(Qt::AlignHCenter | Qt::AlignVCenter); - connect(this, TQT_SIGNAL(quitSelected()), this, TQT_SLOT(_quit())); - TQToolTip::add(this, i18n("Screen resize & rotate")); - my_parent = parent; - - //printf("Reading configuration...\n\r"); - globalKeys = new TDEGlobalAccel(TQT_TQOBJECT(this)); - TDEGlobalAccel* keys = globalKeys; -#include "krandrbindings.cpp" - // the keys need to be read from kdeglobals, not kickerrc - globalKeys->readSettings(); - globalKeys->setEnabled(true); - globalKeys->updateConnections(); - - connect(kapp, TQT_SIGNAL(settingsChanged(int)), TQT_SLOT(slotSettingsChanged(int))); - -#if (TQT_VERSION-0 >= 0x030200) // XRANDR support -// connect(this, TQT_SIGNAL(screenSizeChanged(int, int)), kapp->desktop(), TQT_SLOT( desktopResized())); -#endif - - randr_display = XOpenDisplay(NULL); - - if (isValid() == true) { - last_known_x = currentScreen()->currentPixelWidth(); - last_known_y = currentScreen()->currentPixelHeight(); - } - - t_config = new KSimpleConfig("kiccconfigrc"); - - TQString cur_profile; - cur_profile = getCurrentProfile(); - if (cur_profile != "") { - applyIccConfiguration(cur_profile, NULL); - } - - TDEHardwareDevices *hwdevices = TDEGlobal::hardwareDevices(); - connect(hwdevices, TQT_SIGNAL(hardwareUpdated(TDEGenericDevice*)), this, TQT_SLOT(deviceChanged(TDEGenericDevice*))); -} - -/*! - * \b TQT_SLOT which called if krandrtray is exited by the user. In this case the user - * is asked through a yes/no box if "KRandRTray should start automatically on log in" and the - * result is written to the KDE configfile. - */ -void KRandRSystemTray::_quit (){ - r_config = new KSimpleConfig("krandrtrayrc"); - - TQString tmp1 = i18n ("Start KRandRTray automatically when you log in?"); - int tmp2 = KMessageBox::questionYesNo ( 0, tmp1, i18n("Question"), i18n("Start Automatically"), i18n("Do Not Start")); - r_config->setGroup("General"); - r_config->writeEntry ("Autostart", tmp2 == KMessageBox::Yes); - r_config->sync (); - - exit(0); -} - -void KRandRSystemTray::resizeEvent ( TQResizeEvent * ) -{ - // Honor Free Desktop specifications that allow for arbitrary system tray icon sizes - TQPixmap origpixmap; - TQPixmap scaledpixmap; - TQImage newIcon; - origpixmap = KSystemTray::loadSizedIcon( "randr", width() ); - newIcon = origpixmap; - newIcon = newIcon.smoothScale(width(), height()); - scaledpixmap = newIcon; - setPixmap(scaledpixmap); -} - -void KRandRSystemTray::mousePressEvent(TQMouseEvent* e) -{ - // Popup the context menu with left-click - if (e->button() == Qt::LeftButton) { - contextMenuAboutToShow(contextMenu()); - contextMenu()->popup(e->globalPos()); - e->accept(); - return; - } - - KSystemTray::mousePressEvent(e); -} - -void KRandRSystemTray::reloadDisplayConfiguration() -{ - // Reload the randr configuration... - int i; - int activeOutputs = 0; - int screenDeactivated = 0; - - if (isValid() == true) { - randr_screen_info = read_screen_info(randr_display); - - // Count outputs in the active state - activeOutputs = 0; - for (i = 0; i < randr_screen_info->n_output; i++) { - // Look for ON outputs - if (!randr_screen_info->outputs[i]->cur_crtc) { - continue; - } - // Look for CONNECTED outputs - if (RR_Disconnected == randr_screen_info->outputs[i]->info->connection) { - continue; - } - - activeOutputs++; - } - - if (activeOutputs < 1) { - // Houston, we have a problem! - // There are no active displays! - // Activate the first connected display we come across... - for (i = 0; i < randr_screen_info->n_output; i++) { - // Look for OFF outputs - if (randr_screen_info->outputs[i]->cur_crtc) { - continue; - } - // Look for CONNECTED outputs - if (RR_Disconnected == randr_screen_info->outputs[i]->info->connection) { - continue; - } - - // Activate this output - randr_screen_info->cur_crtc = randr_screen_info->outputs[i]->cur_crtc; - randr_screen_info->cur_output = randr_screen_info->outputs[i]; - randr_screen_info->cur_output->auto_set = 1; - randr_screen_info->cur_output->off_set = 0; - output_auto (randr_screen_info, randr_screen_info->cur_output); - i=main_low_apply(randr_screen_info); - - if (randr_screen_info->outputs[i]->cur_crtc) { - // Output successfully activated! - set_primary_output(randr_screen_info, randr_screen_info->cur_output->id); - break; - } - } - } - - for (i = 0; i < randr_screen_info->n_output; i++) { - // Look for ON outputs - if (!randr_screen_info->outputs[i]->cur_crtc) { - continue; - } - // Look for DISCONNECTED outputs - if (RR_Disconnected != randr_screen_info->outputs[i]->info->connection) { - continue; - } - - // Deactivate this display to avoid a crash! - randr_screen_info->cur_crtc = randr_screen_info->outputs[i]->cur_crtc; - randr_screen_info->cur_output = randr_screen_info->outputs[i]; - randr_screen_info->cur_output->auto_set = 0; - randr_screen_info->cur_output->off_set = 1; - output_off(randr_screen_info, randr_screen_info->cur_output); - main_low_apply(randr_screen_info); - - screenDeactivated = 1; - } - - if (screenDeactivated == 1) { - findPrimaryDisplay(); - refresh(); - - currentScreen()->proposeSize(GetDefaultResolutionParameter()); - currentScreen()->applyProposed(); - } - } -} - -void KRandRSystemTray::contextMenuAboutToShow(KPopupMenu* menu) -{ - int lastIndex = 0; - - reloadDisplayConfiguration(); - - menu->clear(); - menu->setCheckable(true); - - bool valid = isValid(); - - if (!valid) { - lastIndex = menu->insertItem(i18n("Required X Extension Not Available")); - menu->setItemEnabled(lastIndex, false); - - } - else { - m_screenPopups.clear(); - for (int s = 0; s < numScreens() /*&& numScreens() > 1 */; s++) { - setCurrentScreen(s); - if (s == screenIndexOfWidget(this)) { - /*lastIndex = menu->insertItem(i18n("Screen %1").arg(s+1)); - menu->setItemEnabled(lastIndex, false);*/ - } else { - KPopupMenu* subMenu = new KPopupMenu(menu, TQString("screen%1").arg(s+1).latin1()); - m_screenPopups.append(subMenu); - populateMenu(subMenu); - lastIndex = menu->insertItem(i18n("Screen %1").arg(s+1), subMenu); - connect(subMenu, TQT_SIGNAL(activated(int)), TQT_SLOT(slotScreenActivated())); - } - } - - setCurrentScreen(screenIndexOfWidget(this)); - populateMenu(menu); - } - - addOutputMenu(menu); - - // Find any user ICC profiles - TQStringList cfgProfiles; - cfgProfiles = t_config->groupList(); - if (cfgProfiles.isEmpty() == false) { - menu->insertTitle(SmallIcon("kcoloredit"), i18n("Color Profile")); - } - for (TQStringList::Iterator t(cfgProfiles.begin()); t != cfgProfiles.end(); ++t) { - lastIndex = menu->insertItem(*t); - if (t_config->readEntry("CurrentProfile") == (*t)) { - menu->setItemChecked(lastIndex, true); - } - menu->setItemEnabled(lastIndex, t_config->readBoolEntry("EnableICC", false)); - menu->connectItem(lastIndex, this, TQT_SLOT(slotColorProfileChanged(int))); - } - - if (valid) { - // Find any display profiles - TQStringList displayProfiles; - displayProfiles = getDisplayConfigurationProfiles(locateLocal("config", "/", true)); - if (displayProfiles.isEmpty() == false) { - menu->insertTitle(SmallIcon("background"), i18n("Display Profiles")); - } - lastIndex = menu->insertItem(SmallIcon("bookmark"), ""); - menu->connectItem(lastIndex, this, TQT_SLOT(slotDisplayProfileChanged(int))); - for (TQStringList::Iterator t(displayProfiles.begin()); t != displayProfiles.end(); ++t) { - lastIndex = menu->insertItem(SmallIcon("bookmark"), *t); - menu->connectItem(lastIndex, this, TQT_SLOT(slotDisplayProfileChanged(int))); - } - } - - menu->insertTitle(SmallIcon("randr"), i18n("Global Configuation")); - - KAction *actColors = new KAction( i18n( "Configure Displays..." ), - SmallIconSet( "configure" ), KShortcut(), TQT_TQOBJECT(this), TQT_SLOT( slotDisplayConfig() ), - actionCollection() ); - actColors->plug( menu ); - -// KAction *actPrefs = new KAction( i18n( "Configure Display..." ), -// SmallIconSet( "configure" ), KShortcut(), this, TQT_SLOT( slotPrefs() ), -// actionCollection() ); -// actPrefs->plug( menu ); - - KAction *actSKeys = new KAction( i18n( "Configure Shortcut Keys..." ), - SmallIconSet( "configure" ), KShortcut(), TQT_TQOBJECT(this), TQT_SLOT( slotSKeys() ), - actionCollection() ); - actSKeys->plug( menu ); - - menu->insertItem(SmallIcon("help"),KStdGuiItem::help().text(), m_help->menu()); - KAction *quitAction = actionCollection()->action(KStdAction::name(KStdAction::Quit)); - quitAction->plug(menu); - - m_menu = menu; -} - -void KRandRSystemTray::slotScreenActivated() -{ - setCurrentScreen(m_screenPopups.find(static_cast(sender()))); -} - -void KRandRSystemTray::configChanged() -{ - refresh(); - - static bool first = true; - - if ((last_known_x == currentScreen()->currentPixelWidth()) && \ - (last_known_y == currentScreen()->currentPixelHeight())) { - first = true; - } - - last_known_x = currentScreen()->currentPixelWidth(); - last_known_y = currentScreen()->currentPixelHeight(); - - if (!first) { - emit (screenSizeChanged(currentScreen()->currentPixelWidth(), currentScreen()->currentPixelHeight())); - - KRandrPassivePopup::message( - i18n("Screen configuration has changed"), - currentScreen()->changedMessage(), SmallIcon("window_fullscreen"), - this, "ScreenChangeNotification"); - } - - first = false; - - TQString cur_profile; - cur_profile = getCurrentProfile(); - if (cur_profile != "") { - applyIccConfiguration(cur_profile, NULL); - } -} - -int KRandRSystemTray::GetDefaultResolutionParameter() -{ - int returnIndex = 0; - - int numSizes = currentScreen()->numSizes(); - int* sizeSort = new int[numSizes]; - - for (int i = 0; i < numSizes; i++) { - sizeSort[i] = currentScreen()->pixelCount(i); - } - - int highest = -1, highestIndex = -1; - - for (int i = 0; i < numSizes; i++) { - if (sizeSort[i] && sizeSort[i] > highest) { - highest = sizeSort[i]; - highestIndex = i; - } - } - sizeSort[highestIndex] = -1; - Q_ASSERT(highestIndex != -1); - - returnIndex = highestIndex; - - delete [] sizeSort; - sizeSort = 0L; - - return returnIndex; -} - -int KRandRSystemTray::GetHackResolutionParameter() { - int resparm; - - resparm = GetDefaultResolutionParameter(); - resparm++; - - return resparm; -} - -void KRandRSystemTray::populateMenu(KPopupMenu* menu) -{ - int lastIndex = 0; - - menu->insertTitle(SmallIcon("window_fullscreen"), i18n("Screen Size")); - - int numSizes = currentScreen()->numSizes(); - int* sizeSort = new int[numSizes]; - - for (int i = 0; i < numSizes; i++) { - sizeSort[i] = currentScreen()->pixelCount(i); - } - - for (int j = 0; j < numSizes; j++) { - int highest = -1, highestIndex = -1; - - for (int i = 0; i < numSizes; i++) { - if (sizeSort[i] && sizeSort[i] > highest) { - highest = sizeSort[i]; - highestIndex = i; - } - } - sizeSort[highestIndex] = -1; - Q_ASSERT(highestIndex != -1); - - lastIndex = menu->insertItem(i18n("%1 x %2").arg(currentScreen()->pixelSize(highestIndex).width()).arg(currentScreen()->pixelSize(highestIndex).height())); - - if (currentScreen()->proposedSize() == highestIndex) - menu->setItemChecked(lastIndex, true); - - menu->setItemParameter(lastIndex, highestIndex); - menu->connectItem(lastIndex, this, TQT_SLOT(slotResolutionChanged(int))); - } - delete [] sizeSort; - sizeSort = 0L; - - // Don't display the rotation options if there is no point (ie. none are supported) - // XFree86 4.3 does not include rotation support. - if (currentScreen()->rotations() != RandRScreen::Rotate0) { - menu->insertTitle(SmallIcon("reload"), i18n("Orientation")); - - for (int i = 0; i < 6; i++) { - if ((1 << i) & currentScreen()->rotations()) { - lastIndex = menu->insertItem(currentScreen()->rotationIcon(1 << i), RandRScreen::rotationName(1 << i)); - - if (currentScreen()->proposedRotation() & (1 << i)) - menu->setItemChecked(lastIndex, true); - - menu->setItemParameter(lastIndex, 1 << i); - menu->connectItem(lastIndex, this, TQT_SLOT(slotOrientationChanged(int))); - } - } - } - - TQStringList rr = currentScreen()->refreshRates(currentScreen()->proposedSize()); - - if (rr.count()) - menu->insertTitle(SmallIcon("clock"), i18n("Refresh Rate")); - - int i = 0; - for (TQStringList::Iterator it = rr.begin(); it != rr.end(); ++it, i++) { - lastIndex = menu->insertItem(*it); - - if (currentScreen()->proposedRefreshRate() == i) - menu->setItemChecked(lastIndex, true); - - menu->setItemParameter(lastIndex, i); - menu->connectItem(lastIndex, this, TQT_SLOT(slotRefreshRateChanged(int))); - } -} - -void KRandRSystemTray::slotResolutionChanged(int parameter) -{ - if (currentScreen()->currentSize() == parameter) { - //printf("This resolution is already in use; applying again...\n\r"); - currentScreen()->proposeSize(parameter); - currentScreen()->applyProposed(); - return; - } - - currentScreen()->proposeSize(parameter); - - currentScreen()->proposeRefreshRate(-1); - - if (currentScreen()->applyProposedAndConfirm()) { - TDEConfig config("kcmrandrrc"); - if (syncTrayApp(config)) - currentScreen()->save(config); - } -} - -void KRandRSystemTray::slotOrientationChanged(int parameter) -{ - int propose = currentScreen()->currentRotation(); - - if (parameter & RandRScreen::RotateMask) - propose &= RandRScreen::ReflectMask; - - propose ^= parameter; - - if (currentScreen()->currentRotation() == propose) - return; - - currentScreen()->proposeRotation(propose); - - if (currentScreen()->applyProposedAndConfirm()) { - TDEConfig config("kcmrandrrc"); - if (syncTrayApp(config)) - currentScreen()->save(config); - } -} - -void KRandRSystemTray::slotRefreshRateChanged(int parameter) -{ - if (currentScreen()->currentRefreshRate() == parameter) - return; - - currentScreen()->proposeRefreshRate(parameter); - - if (currentScreen()->applyProposedAndConfirm()) { - TDEConfig config("kcmrandrrc"); - if (syncTrayApp(config)) - currentScreen()->save(config); - } -} - -void KRandRSystemTray::slotPrefs() -{ - KCMultiDialog *kcm = new KCMultiDialog( KDialogBase::Plain, i18n( "Configure" ), this ); - - kcm->addModule( "displayconfig" ); - kcm->setPlainCaption( i18n( "Configure Display" ) ); - kcm->exec(); -} - -void KRandRSystemTray::slotDisplayConfig() -{ - KCMultiDialog *kcm = new KCMultiDialog( KDialogBase::Plain, i18n( "Configure" ), this ); - - kcm->addModule( "displayconfig" ); - kcm->setPlainCaption( i18n( "Configure Displays" ) ); - kcm->exec(); -} - -void KRandRSystemTray::slotSettingsChanged(int category) -{ - if ( category == (int) TDEApplication::SETTINGS_SHORTCUTS ) { - globalKeys->readSettings(); - globalKeys->updateConnections(); - } -} - -void KRandRSystemTray::slotSKeys() -{ - ConfigDialog *dlg = new ConfigDialog(globalKeys, true); - - if ( dlg->exec() == TQDialog::Accepted ) { - dlg->commitShortcuts(); - globalKeys->writeSettings(0, true); - globalKeys->updateConnections(); - } - - delete dlg; -} - -void KRandRSystemTray::slotCycleDisplays() -{ - XRROutputInfo *output_info; - char *output_name; - int i; - int current_on_index = -1; - int max_index = -1; - int prev_on_index; - - randr_screen_info = read_screen_info(randr_display); - - for (i = 0; i < randr_screen_info->n_output; i++) { - output_info = randr_screen_info->outputs[i]->info; - // Look for ON outputs... - if (!randr_screen_info->outputs[i]->cur_crtc) { - continue; - } - // ...that are connected - if (RR_Disconnected == randr_screen_info->outputs[i]->info->connection) { - continue; - } - - output_name = output_info->name; - current_on_index = i; - if (i > max_index) { - max_index = i; - } - } - - for (i = 0; i < randr_screen_info->n_output; i++) { - output_info = randr_screen_info->outputs[i]->info; - // Look for CONNECTED outputs.... - if (RR_Disconnected == randr_screen_info->outputs[i]->info->connection) { - continue; - } - // ...that are not ON - if (randr_screen_info->outputs[i]->cur_crtc) { - continue; - } - - output_name = output_info->name; - if (i > max_index) { - max_index = i; - } - } - - for (i = 0; i < randr_screen_info->n_output; i++) { - output_info = randr_screen_info->outputs[i]->info; - // Look for ALL outputs that are not connected.... - if (RR_Disconnected != randr_screen_info->outputs[i]->info->connection) { - continue; - } - // ...or ON - if (randr_screen_info->outputs[i]->cur_crtc) { - continue; - } - - output_name = output_info->name; - if (i > max_index) { - max_index = i; - } - } - - //printf("Active: %d\n\r", current_on_index); - //printf("Max: %d\n\r", max_index); - - if ((current_on_index == -1) && (max_index == -1)) { - // There is no connected display available! ABORT - return; - } - - prev_on_index = current_on_index; - current_on_index = current_on_index + 1; - if (current_on_index > max_index) { - current_on_index = 0; - } - while (RR_Disconnected == randr_screen_info->outputs[current_on_index]->info->connection) { - current_on_index = current_on_index + 1; - if (current_on_index > max_index) { - current_on_index = 0; - } - } - if (prev_on_index != current_on_index) { - randr_screen_info->cur_crtc = randr_screen_info->outputs[current_on_index]->cur_crtc; - randr_screen_info->cur_output = randr_screen_info->outputs[current_on_index]; - randr_screen_info->cur_output->auto_set = 1; - randr_screen_info->cur_output->off_set = 0; - output_auto (randr_screen_info, randr_screen_info->cur_output); - i=main_low_apply(randr_screen_info); - - if (randr_screen_info->outputs[current_on_index]->cur_crtc) { - // Output successfully activated! - set_primary_output(randr_screen_info, randr_screen_info->cur_output->id); - - if (prev_on_index != -1) { - if (randr_screen_info->outputs[prev_on_index]->cur_crtc != NULL) { - if (RR_Disconnected != randr_screen_info->outputs[prev_on_index]->info->connection) { - randr_screen_info->cur_crtc = randr_screen_info->outputs[prev_on_index]->cur_crtc; - randr_screen_info->cur_output = randr_screen_info->outputs[prev_on_index]; - randr_screen_info->cur_output->auto_set = 0; - randr_screen_info->cur_output->off_set = 1; - output_off(randr_screen_info, randr_screen_info->cur_output); - i=main_low_apply(randr_screen_info); - } - } - } - - // Do something about the disconnected outputs - for (i = 0; i < randr_screen_info->n_output; i++) { - output_info = randr_screen_info->outputs[i]->info; - // Look for ON outputs - if (!randr_screen_info->outputs[i]->cur_crtc) { - continue; - } - if (RR_Disconnected != randr_screen_info->outputs[i]->info->connection) { - continue; - } - - output_name = output_info->name; - - // Deactivate this display to avoid a crash! - randr_screen_info->cur_crtc = randr_screen_info->outputs[i]->cur_crtc; - randr_screen_info->cur_output = randr_screen_info->outputs[i]; - randr_screen_info->cur_output->auto_set = 0; - randr_screen_info->cur_output->off_set = 1; - output_off(randr_screen_info, randr_screen_info->cur_output); - main_low_apply(randr_screen_info); - } - - findPrimaryDisplay(); - refresh(); - - currentScreen()->proposeSize(GetDefaultResolutionParameter()); - currentScreen()->applyProposed(); - } - else { - output_name = randr_screen_info->outputs[current_on_index]->info->name; - KMessageBox::sorry(my_parent, i18n("Unable to activate output %1

Either the output is not connected to a display,
or the display configuration is not detectable").arg(output_name), i18n("Output Unavailable")); - } - } -} - -void KRandRSystemTray::findPrimaryDisplay() -{ - int i; - - for (i = 0; i < randr_screen_info->n_output; i++) { - // Look for ON outputs... - if (!randr_screen_info->outputs[i]->cur_crtc) { - continue; - } - - // ...that are connected - if (RR_Disconnected == randr_screen_info->outputs[i]->info->connection) { - continue; - } - - randr_screen_info->cur_crtc = randr_screen_info->outputs[i]->cur_crtc; - randr_screen_info->cur_output = randr_screen_info->outputs[i]; - } -} - -void KRandRSystemTray::addOutputMenu(KPopupMenu* menu) -{ - XRROutputInfo *output_info; - char *output_name; - int i; - int lastIndex = 0; - int connected_displays = 0; - - if (isValid() == true) { - menu->insertTitle(SmallIcon("kcmkwm"), i18n("Output Port")); - - for (i = 0; i < randr_screen_info->n_output; i++) { - output_info = randr_screen_info->outputs[i]->info; - // Look for ON outputs - if (!randr_screen_info->outputs[i]->cur_crtc) { - continue; - } - if (RR_Disconnected == randr_screen_info->outputs[i]->info->connection) { - continue; - } - - output_name = output_info->name; - //printf("ON: Found output %s\n\r", output_name); - - lastIndex = menu->insertItem(i18n("%1 (Active)").arg(output_name)); - menu->setItemChecked(lastIndex, true); - menu->connectItem(lastIndex, this, TQT_SLOT(slotOutputChanged(int))); - menu->setItemParameter(lastIndex, i); - - connected_displays++; - } - - for (i = 0; i < randr_screen_info->n_output; i++) { - output_info = randr_screen_info->outputs[i]->info; - // Look for CONNECTED outputs.... - if (RR_Disconnected == randr_screen_info->outputs[i]->info->connection) { - continue; - } - // ...that are not ON - if (randr_screen_info->outputs[i]->cur_crtc) { - continue; - } - - output_name = output_info->name; - //printf("CONNECTED, NOT ON: Found output %s\n\r", output_name); - - lastIndex = menu->insertItem(i18n("%1 (Connected, Inactive)").arg(output_name)); - menu->setItemChecked(lastIndex, false); - menu->connectItem(lastIndex, this, TQT_SLOT(slotOutputChanged(int))); - menu->setItemParameter(lastIndex, i); - - connected_displays++; - } - - for (i = 0; i < randr_screen_info->n_output; i++) { - output_info = randr_screen_info->outputs[i]->info; - // Look for ALL outputs that are not connected.... - if (RR_Disconnected != randr_screen_info->outputs[i]->info->connection) { - continue; - } - // ...or ON - if (randr_screen_info->outputs[i]->cur_crtc) { - continue; - } - - output_name = output_info->name; - //printf("DISCONNECTED, NOT ON: Found output %s\n\r", output_name); - - lastIndex = menu->insertItem(i18n("%1 (Disconnected, Inactive)").arg(output_name)); - menu->setItemChecked(lastIndex, false); - menu->setItemEnabled(lastIndex, false); - menu->connectItem(lastIndex, this, TQT_SLOT(slotOutputChanged(int))); - menu->setItemParameter(lastIndex, i); - } - - lastIndex = menu->insertItem(SmallIcon("forward"), i18n("Next available output")); - if (connected_displays < 2) { - menu->setItemEnabled(lastIndex, false); - } - menu->connectItem(lastIndex, this, TQT_SLOT(slotCycleDisplays())); - } -} - -void KRandRSystemTray::slotColorProfileChanged(int parameter) -{ - t_config->writeEntry("CurrentProfile", m_menu->text(parameter)); - applyIccConfiguration(m_menu->text(parameter), NULL); -} - -void KRandRSystemTray::slotDisplayProfileChanged(int parameter) -{ - TQString profileName = m_menu->text(parameter); - if (profileName == "") { - profileName = ""; - } - TQPtrList profileData = loadDisplayConfiguration(profileName, locateLocal("config", "/", true)); - applyDisplayConfiguration(profileData, TRUE, locateLocal("config", "/", true)); - destroyScreenInformationObject(profileData); -} - -void KRandRSystemTray::slotOutputChanged(int parameter) -{ - char *output_name; - int i; - int num_outputs_on; - - num_outputs_on = 0; - for (i = 0; i < randr_screen_info->n_output; i++) { - // Look for ON outputs - if (!randr_screen_info->outputs[i]->cur_crtc) { - continue; - } - - num_outputs_on++; - } - - if (!randr_screen_info->outputs[parameter]->cur_crtc) { - //printf("Screen was off, turning it on...\n\r"); - - randr_screen_info->cur_crtc = randr_screen_info->outputs[parameter]->cur_crtc; - randr_screen_info->cur_output = randr_screen_info->outputs[parameter]; - randr_screen_info->cur_output->auto_set = 1; - randr_screen_info->cur_output->off_set = 0; - output_auto (randr_screen_info, randr_screen_info->cur_output); - i=main_low_apply(randr_screen_info); - - if (!randr_screen_info->outputs[parameter]->cur_crtc) { - output_name = randr_screen_info->outputs[parameter]->info->name; - KMessageBox::sorry(my_parent, i18n("Unable to activate output %1

Either the output is not connected to a display,
or the display configuration is not detectable").arg(output_name), i18n("Output Unavailable")); - } - } - else { - if (num_outputs_on > 1) { - //printf("Screen was on, turning it off...\n\r"); - randr_screen_info->cur_crtc = randr_screen_info->outputs[parameter]->cur_crtc; - randr_screen_info->cur_output = randr_screen_info->outputs[parameter]; - randr_screen_info->cur_output->auto_set = 0; - randr_screen_info->cur_output->off_set = 1; - output_off(randr_screen_info, randr_screen_info->cur_output); - i=main_low_apply(randr_screen_info); - - findPrimaryDisplay(); - refresh(); - - currentScreen()->proposeSize(GetDefaultResolutionParameter()); - currentScreen()->applyProposed(); - } - else { - KMessageBox::sorry(my_parent, i18n("You are attempting to deactivate the only active output

You must keep at least one display output active at all times!"), i18n("Invalid Operation Requested")); - } - } -} - -void KRandRSystemTray::deviceChanged (TDEGenericDevice* device) { - if (device->type() == TDEGenericDeviceType::Monitor) { - KRandrPassivePopup::message( - i18n("New display output options are available!"), - i18n("A screen has been added, removed, or changed"), SmallIcon("window_fullscreen"), - this, "ScreenChangeNotification"); - - reloadDisplayConfiguration(); - applyHotplugRules(locateLocal("config", "/", true)); - } -} \ No newline at end of file diff --git a/kcontrol/randr/krandrtray.desktop b/kcontrol/randr/krandrtray.desktop deleted file mode 100644 index a61f8c28c..000000000 --- a/kcontrol/randr/krandrtray.desktop +++ /dev/null @@ -1,141 +0,0 @@ -[Desktop Entry] -Name=KRandRTray -Name[be]=Змена параметраў манітора -Name[hu]=Képernyőfelbontás -Name[ne]=KRandR ट्रे -Name[pt_BR]=Ícone do KRandR -Name[sv]=Krandrtray -Name[vi]=Khay KRandR -GenericName=Screen Resize & Rotate -GenericName[af]=Skerm Hervergroot & Roteer -GenericName[be]=Змена памераў экрана і перагортванне -GenericName[bg]=Размер и ротация на екрана -GenericName[bn]=পর্দা মাপবদল ও আবর্তন -GenericName[br]=Adventañ ha treiñ ar skramm -GenericName[bs]=Veličina i rotacija ekrana -GenericName[ca]=Amida i gira la pantalla -GenericName[cs]=Změna velikosti a rotace obrazovky -GenericName[csb]=Òbrócenié ë zjinaka miarë ekranu -GenericName[cy]=Newid Maint a Cylchdroi'r Sgrîn -GenericName[da]=Ændr størrelse på skærm & Rotér -GenericName[de]=Bildschirmgröße & -ausrichtung ändern -GenericName[el]=Αλλαγή μεγέθους & Περιστροφή οθόνης -GenericName[eo]=Regrandigi kaj Turni Ekranon -GenericName[es]=Redimensionar y rotar pantalla -GenericName[et]=Ekraani suuruse muutmine ja pööramine -GenericName[eu]=Pantailaren tamaina aldaketa eta biraketa -GenericName[fa]=تغییر اندازه و چرخش پرده -GenericName[fi]=Näytön kuvan koon muuttaminen ja kuvan kääntäminen -GenericName[fr]=Redimensionnement et rotation de l'écran -GenericName[fy]=Skerm rotearje en grutte wizigje -GenericName[gl]=Rotación e Redimensionamento da Pantallla -GenericName[he]=שינוי גודל המסך וסיבובו -GenericName[hr]=Veličine i orijentacija zaslona -GenericName[hu]=Képernyőbeállító -GenericName[is]=Stærð og snúningur skjáa -GenericName[it]=Ruota e ridimensiona lo schermo -GenericName[ja]=スクリーンのリサイズと回転 -GenericName[ka]=ეკრანის ზომა და ორიენტაცია -GenericName[kk]=Экранды өзгерту және бұрау -GenericName[km]=ប្ដូរ​ទំហំ & បង្វិល​អេក្រង់ -GenericName[ko]=화면 크기 조정 및 회전 -GenericName[lt]=Ekrano dydžio keitimas ir pasukimas -GenericName[mk]=Големина и ротација на екранот -GenericName[ms]=Saiz Semula Skrin & Putar -GenericName[nb]=Endre størrelsen på og rotere skjermbildet -GenericName[nds]=Schirmgrött un -utrichten ännern -GenericName[ne]=पर्दा रिसाइज र परिक्रमण -GenericName[nl]=Scherm roteren en grootte wijzigen -GenericName[nn]=Endra storleiken på og roter skjermbiletet -GenericName[pa]=ਪਰਦਾ ਮੁੜ ਆਕਾਰ ਤੇ ਘੁੰਮਾਓ -GenericName[pl]=Obrót i zmiana rozmiaru ekranu -GenericName[pt]=Mudar o Tamanho e Rodar o Ecrã -GenericName[pt_BR]=Redimensionar Tela & Rotacionar -GenericName[ro]=Redimensionare și rotire ecran -GenericName[ru]=Изменение размера и ориентации экрана -GenericName[rw]=Kuhindura ingano & Kuzengurutsa Mugaragaza -GenericName[se]=Rievdat šearbmagova sturrodaga ja jorat dan -GenericName[sk]=Zmena veľkosti a otočenia obrazovky -GenericName[sl]=Spreminjanje velikosti in obračanje zaslona -GenericName[sr]=Промена величине и ротација екрана -GenericName[sr@Latn]=Promena veličine i rotacija ekrana -GenericName[sv]=Ändra skärmstorlek och rotera -GenericName[ta]=திரை அளவு மாற்று & சுழற்று -GenericName[tg]=Ивази андоза ва мавқеи экран -GenericName[th]=ปรับขนาดและหมุนหน้าจอ -GenericName[tr]=Ekran Boyutlandır ve Döndür -GenericName[tt]=Küräk Ülçäme & Borılışı -GenericName[uk]=Зміна розміру та обертання екрана -GenericName[uz]=Ekraning oʻlchamini oʻzgartirish va burish -GenericName[uz@cyrillic]=Экранинг ўлчамини ўзгартириш ва буриш -GenericName[vi]=Thay đổi cỡ màn hình & Quay -GenericName[wa]=Candjî l' grandeu del waitroûle eyet l' tourner -GenericName[zh_CN]=屏幕大小和旋转 -GenericName[zh_TW]=螢幕調整大小及旋轉 -Comment=Resize and rotate X screens. -Comment[af]=Hervergroot en roteer X skerms. -Comment[ar]=غيير القياس و الدوران للشاشات X. -Comment[be]=Змена памераў і перагортванне экранаў X. -Comment[bg]=Размер и ротация на екрана. -Comment[bn]=আপনার এক্স-স্ক্রীণ-এর আকৃতি এবং দিশা পরিবর্তন করুন -Comment[br]=Adventañ ha treiñ ho diskweloù X. -Comment[bs]=Podesite veličinu i rotirajte vaš ekran. -Comment[ca]=Gira i amida les pantalles X. -Comment[cs]=Změna velikosti a rotace obrazovky. -Comment[csb]=Zjinaka miarë ë pòłożenia ekranów. -Comment[da]=Ændrer størrelse og roterer X-skærme -Comment[de]=Die Größe und Ausrichtung der Anzeige ändern -Comment[el]=Αλλαγή μεγέθους και περιστροφή της οθόνης. -Comment[eo]=Regrandigi kaj turni X ekranojn. -Comment[es]=Ajustar el tamaño y rotar las pantallas X. -Comment[et]=X'i ekraani muutmine ja pööramine -Comment[eu]=Aldatu tamaina eta biratu zure X pantailak. -Comment[fa]=تغییر‌ اندازه و چرخش پرده‌های X. -Comment[fi]=Näytön kuvan koon muuttaminen ja kuvan kääntäminen -Comment[fr]=Redimensionner et retourner votre affichage. -Comment[fy]=Skermgrutte wizigje en rotearje X skermen -Comment[ga]=Athraigh an méid agus rothlaigh scáileáin X. -Comment[gl]=Redimensionar e rotar pantallas -Comment[he]=שנה את גודלה של התצוגה שלך וסובב אותה. -Comment[hr]=Promjena veličine i orijentacije X zaslona -Comment[hu]=A képernyő átméretezése, elforgatása -Comment[is]=Breyta stærð skjásins og snúa honum. -Comment[it]=Ridimensiona e ruota gli schermi di X. -Comment[ja]=X スクリーンのリサイズと回転。 -Comment[ka]=ეკრანის ზომის და ორიენტაციის შეცვლა -Comment[kk]=Экранның өлшемін және бағытын өзгерту -Comment[km]=ប្ដូរ​ទំហំ និង​បង្វិល​អេក្រង់ X ។ -Comment[lt]=Keisti X ekrano dydį ir orientaciją. -Comment[mk]=Сменете ја големината и ротацијата на вашиот екран -Comment[nb]=Endrer størrelsen på og roterer X-skjermbildet -Comment[nds]=Grött un Utrichten vun den X-Schirm ännern -Comment[ne]=X पर्दा रिसाइज गर्नुहोस् र घुमाउनुहोस् -Comment[nl]=Scherm roteren en van grootte veranderen -Comment[nn]=Endra storleiken på og roter X-skjermbiletet. -Comment[pa]=X ਸਕਰੀਨ ਨੂੰ ਮੁੜ-ਅਕਾਰ ਅਤੇ ਘੁੰਮਾਓ। -Comment[pl]=Zmiana rozmiaru i orientacji ekranów. -Comment[pt]=Mudar o tamanho e rodar os ecrãs do X. -Comment[pt_BR]=Redimensiona e rotaciona as tela do X. -Comment[ro]=Redimensionează și rotește ecranele X. -Comment[ru]=Изменение размера и ориентации экранов X. -Comment[se]=Rievdat X-šearpmaid sturrodaga ja joraheami. -Comment[sk]=Zmení veľkosť a otočí obrazovky -Comment[sl]=Spremenite velikost in obrnite zaslon. -Comment[sr]=Промените величину и оријентацију екрана -Comment[sr@Latn]=Promenite veličinu i orijentaciju ekrana -Comment[sv]=Storleksändring och rotation av X-skärmar. -Comment[tg]=Ивази андоза ва мавқеи экранҳои Х. -Comment[th]=ปรับแต่งการแสดงผลของ X -Comment[tr]=Ekranı boyutlandır ve çevir. -Comment[uk]=Зміна розміру та обертання екранів X. -Comment[uz]=Ekraning oʻlchamini oʻzgartirish va burish -Comment[uz@cyrillic]=Экранинг ўлчамини ўзгартириш ва буриш -Comment[vi]=Đổi cỡ và quay màn hình X. -Comment[wa]=Candjî l' grandeu eyet tourner les waitroûles X. -Comment[zh_CN]=更改 X 屏幕的大小和旋转。 -Comment[zh_TW]=調整大小及旋轉 X 螢幕。 -Exec=krandrtray -Icon=randr -Type=Application -OnlyShowIn=TDE; -Categories=Qt;TDE;System; diff --git a/kcontrol/randr/krandrtray.h b/kcontrol/randr/krandrtray.h deleted file mode 100644 index 8a910f373..000000000 --- a/kcontrol/randr/krandrtray.h +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright (c) 2002 Hamish Rodda - * - * 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. - */ - -#ifndef KRANDRTRAY_H -#define KRANDRTRAY_H - -#include - -#include -#include - -#include -#include - -class KHelpMenu; -class KPopupMenu; - -class KRandRSystemTray : public KSystemTray, public KRandrSimpleAPI -{ - Q_OBJECT - -public: - KRandRSystemTray(TQWidget* parent = 0, const char *name = 0); - TDEGlobalAccel *globalKeys; - - virtual void contextMenuAboutToShow(KPopupMenu* menu); - - void configChanged(); - -signals: - void screenSizeChanged(int x, int y); - -protected slots: - void slotScreenActivated(); - void slotResolutionChanged(int parameter); - void slotOrientationChanged(int parameter); - void slotRefreshRateChanged(int parameter); - void slotPrefs(); - void slotDisplayConfig(); - void slotSKeys(); - void slotSettingsChanged(int category); - void slotCycleDisplays(); - void slotOutputChanged(int parameter); - void slotColorProfileChanged(int parameter); - void slotDisplayProfileChanged(int parameter); - -protected: - void mousePressEvent( TQMouseEvent *e ); - void resizeEvent ( TQResizeEvent * ); - -private: - void populateMenu(KPopupMenu* menu); - void addOutputMenu(KPopupMenu* menu); - int GetDefaultResolutionParameter(); - int GetHackResolutionParameter(); - void findPrimaryDisplay(); - void reloadDisplayConfiguration(); - - bool m_popupUp; - KHelpMenu* m_help; - TQPtrList m_screenPopups; - - Display *randr_display; - ScreenInfo *randr_screen_info; - TQWidget* my_parent; - - int last_known_x; - int last_known_y; - - KPopupMenu* m_menu; - KSimpleConfig *r_config; - KSimpleConfig *t_config; - -private slots: - void _quit(); - void deviceChanged (TDEGenericDevice*); -}; - -#endif diff --git a/kcontrol/randr/main.cpp b/kcontrol/randr/main.cpp index 1e8edc83e..d606940fc 100644 --- a/kcontrol/randr/main.cpp +++ b/kcontrol/randr/main.cpp @@ -24,9 +24,9 @@ #include #include -#include "krandrapp.h" +#include "tderandrapp.h" -static const char krandrtrayVersion[] = "0.5"; +static const char tderandrtrayVersion[] = "0.5"; static const KCmdLineOptions options[] = { { "login", I18N_NOOP("Application is being auto-started at TDE session start"), 0L }, @@ -35,12 +35,12 @@ static const KCmdLineOptions options[] = int main(int argc, char **argv) { - TDEAboutData aboutData("randr", I18N_NOOP("Resize and Rotate"), krandrtrayVersion, I18N_NOOP("Resize and Rotate System Tray App"), TDEAboutData::License_GPL, "(c) 2009,2010 Timothy Pearson", 0L, ""); + TDEAboutData aboutData("randr", I18N_NOOP("Resize and Rotate"), tderandrtrayVersion, I18N_NOOP("Resize and Rotate System Tray App"), TDEAboutData::License_GPL, "(c) 2009,2010 Timothy Pearson", 0L, ""); aboutData.addAuthor("Timothy Pearson",I18N_NOOP("Developer and maintainer"), "kb9vqf@pearsoncomputing.net"); aboutData.addAuthor("Hamish Rodda",I18N_NOOP("Original developer and maintainer"), "rodda@kde.org"); aboutData.addCredit("Lubos Lunak",I18N_NOOP("Many fixes"), "l.lunak@suse.cz"); - aboutData.setProductName("krandr/krandrtray"); - TDEGlobal::locale()->setMainCatalogue("krandr"); + aboutData.setProductName("tderandr/tderandrtray"); + TDEGlobal::locale()->setMainCatalogue("tderandr"); TDECmdLineArgs::init(argc,argv,&aboutData); TDECmdLineArgs::addCmdLineOptions(options); diff --git a/kcontrol/randr/tderandrapp.cpp b/kcontrol/randr/tderandrapp.cpp new file mode 100644 index 000000000..e2a4b46f2 --- /dev/null +++ b/kcontrol/randr/tderandrapp.cpp @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2002,2003 Hamish Rodda + * + * 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 + +#include "tderandrapp.h" +#include "tderandrapp.moc" + +#include "tderandrtray.h" + +#include + +KRandRApp::KRandRApp() + : m_tray(new KRandRSystemTray(0L, "RANDRTray")) +{ + connect(&m_eventMergingTimer, TQT_SIGNAL(timeout()), this, TQT_SLOT(handleX11ConfigChangeEvent())); + m_tray->show(); +} + +void KRandRApp::handleX11ConfigChangeEvent() +{ + m_eventMergingTimer.stop(); + m_tray->configChanged(); +} + +bool KRandRApp::x11EventFilter(XEvent* e) +{ + if (e->type == m_tray->screenChangeNotifyEvent()) { + m_eventMergingTimer.start(1000, TRUE); + } + return TDEApplication::x11EventFilter( e ); +} diff --git a/kcontrol/randr/tderandrapp.h b/kcontrol/randr/tderandrapp.h new file mode 100644 index 000000000..766b0056c --- /dev/null +++ b/kcontrol/randr/tderandrapp.h @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2002 Hamish Rodda + * + * 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. + */ + +#ifndef KRANDRAPP_H +#define KRANDRAPP_H + +#include +#include + +class KRandRSystemTray; + +class KRandRApp : public KUniqueApplication +{ + Q_OBJECT + +public: + KRandRApp(); + + virtual bool x11EventFilter(XEvent * e); + +private slots: + void handleX11ConfigChangeEvent(); + +private: + KRandRSystemTray* m_tray; + TQTimer m_eventMergingTimer; +}; + +#endif diff --git a/kcontrol/randr/tderandrbindings.cpp b/kcontrol/randr/tderandrbindings.cpp new file mode 100644 index 000000000..b7df41602 --- /dev/null +++ b/kcontrol/randr/tderandrbindings.cpp @@ -0,0 +1,34 @@ +// -*- Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 8; -*- +/* This file is part of the KDE project + Copyright (C) by Andrew Stanley-Jones + + 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; see the file COPYING. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ +#ifndef NOSLOTS +# define DEF( name, key3, key4, fnSlot ) \ + keys->insert( name, i18n(name), TQString(), key3, key4, TQT_TQOBJECT(this), TQT_SLOT(fnSlot) ) +#else +# define DEF( name, key3, key4, fnSlot ) \ + keys->insert( name, i18n(name), TQString(), key3, key4 ) +#endif +#define WIN KKey::QtWIN + + keys->insert( "Program:tderandrtray", i18n("Display Control") ); + + DEF( I18N_NOOP("Switch Displays"), KShortcut(TQString("XF86Display")), KShortcut(TQString("XF86Display")), slotCycleDisplays() ); + +#undef DEF +#undef WIN diff --git a/kcontrol/randr/tderandrinithack.cpp b/kcontrol/randr/tderandrinithack.cpp new file mode 100644 index 000000000..e69de29bb diff --git a/kcontrol/randr/tderandrmodule.cpp b/kcontrol/randr/tderandrmodule.cpp new file mode 100644 index 000000000..9da8a569b --- /dev/null +++ b/kcontrol/randr/tderandrmodule.cpp @@ -0,0 +1,365 @@ +/* + * Copyright (c) 2002,2003 Hamish Rodda + * + * 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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include "tderandrmodule.h" +#include "tderandrmodule.moc" + +#include +#include + +// DLL Interface for kcontrol +typedef KGenericFactory KSSFactory; +K_EXPORT_COMPONENT_FACTORY (kcm_randr, KSSFactory("tderandr") ) +extern "C" + +{ + KDE_EXPORT void init_randr() + { + KRandRModule::performApplyOnStartup(); + } + + KDE_EXPORT bool test_randr() + { + int eventBase, errorBase; + if( XRRQueryExtension(tqt_xdisplay(), &eventBase, &errorBase ) ) + return true; + return false; + } +} + +void KRandRModule::performApplyOnStartup() +{ + TDEConfig config("kcmrandrrc", true); + if (RandRDisplay::applyOnStartup(config)) + { + // Load settings and apply appropriate config + RandRDisplay display; + if (display.isValid() && display.loadDisplay(config)) + display.applyProposed(false); + } +} + +KRandRModule::KRandRModule(TQWidget *parent, const char *name, const TQStringList&) + : TDECModule(parent, name) + , m_changed(false) +{ + if (!isValid()) { + TQVBoxLayout *topLayout = new TQVBoxLayout(this); + topLayout->addWidget(new TQLabel(i18n("Your X server does not support resizing and rotating the display. Please update to version 4.3 or greater. You need the X Resize And Rotate extension (RANDR) version 1.1 or greater to use this feature."), this)); + kdWarning() << "Error: " << errorCode() << endl; + return; + } + + TQVBoxLayout* topLayout = new TQVBoxLayout(this, 0, KDialog::spacingHint()); + + TQHBox* screenBox = new TQHBox(this); + topLayout->addWidget(screenBox); + TQLabel *screenLabel = new TQLabel(i18n("Settings for screen:"), screenBox); + m_screenSelector = new KComboBox(screenBox); + + for (int s = 0; s < numScreens(); s++) { + m_screenSelector->insertItem(i18n("Screen %1").arg(s+1)); + } + + m_screenSelector->setCurrentItem(currentScreenIndex()); + screenLabel->setBuddy( m_screenSelector ); + TQWhatsThis::add(m_screenSelector, i18n("The screen whose settings you would like to change can be selected using this drop-down list.")); + + connect(m_screenSelector, TQT_SIGNAL(activated(int)), TQT_SLOT(slotScreenChanged(int))); + + if (numScreens() <= 1) + m_screenSelector->setEnabled(false); + + TQHBox* sizeBox = new TQHBox(this); + topLayout->addWidget(sizeBox); + TQLabel *sizeLabel = new TQLabel(i18n("Screen size:"), sizeBox); + m_sizeCombo = new KComboBox(sizeBox); + TQWhatsThis::add(m_sizeCombo, i18n("The size, otherwise known as the resolution, of your screen can be selected from this drop-down list.")); + connect(m_sizeCombo, TQT_SIGNAL(activated(int)), TQT_SLOT(slotSizeChanged(int))); + sizeLabel->setBuddy( m_sizeCombo ); + + TQHBox* refreshBox = new TQHBox(this); + topLayout->addWidget(refreshBox); + TQLabel *rateLabel = new TQLabel(i18n("Refresh rate:"), refreshBox); + m_refreshRates = new KComboBox(refreshBox); + TQWhatsThis::add(m_refreshRates, i18n("The refresh rate of your screen can be selected from this drop-down list.")); + connect(m_refreshRates, TQT_SIGNAL(activated(int)), TQT_SLOT(slotRefreshChanged(int))); + rateLabel->setBuddy( m_refreshRates ); + + m_rotationGroup = new TQButtonGroup(2, Qt::Horizontal, i18n("Orientation (degrees counterclockwise)"), this); + topLayout->addWidget(m_rotationGroup); + m_rotationGroup->setRadioButtonExclusive(true); + TQWhatsThis::add(m_rotationGroup, i18n("The options in this section allow you to change the rotation of your screen.")); + + m_applyOnStartup = new TQCheckBox(i18n("Apply settings on TDE startup"), this); + topLayout->addWidget(m_applyOnStartup); + TQWhatsThis::add(m_applyOnStartup, i18n("If this option is enabled the size and orientation settings will be used when TDE starts.")); + connect(m_applyOnStartup, TQT_SIGNAL(clicked()), TQT_SLOT(setChanged())); + + TQHBox* syncBox = new TQHBox(this); + syncBox->layout()->addItem(new TQSpacerItem(20, 1, TQSizePolicy::Maximum)); + m_syncTrayApp = new TQCheckBox(i18n("Allow tray application to change startup settings"), syncBox); + topLayout->addWidget(syncBox); + TQWhatsThis::add(m_syncTrayApp, i18n("If this option is enabled, options set by the system tray applet will be saved and loaded when TDE starts instead of being temporary.")); + connect(m_syncTrayApp, TQT_SIGNAL(clicked()), TQT_SLOT(setChanged())); + + topLayout->addStretch(1); + + // just set the "apply settings on startup" box + load(); + m_syncTrayApp->setEnabled(m_applyOnStartup->isChecked()); + + slotScreenChanged(TQApplication::desktop()->primaryScreen()); + + setButtons(TDECModule::Apply); +} + +void KRandRModule::addRotationButton(int thisRotation, bool checkbox) +{ + Q_ASSERT(m_rotationGroup); + if (!checkbox) { + TQRadioButton* thisButton = new TQRadioButton(RandRScreen::rotationName(thisRotation), m_rotationGroup); + thisButton->setEnabled(thisRotation & currentScreen()->rotations()); + connect(thisButton, TQT_SIGNAL(clicked()), TQT_SLOT(slotRotationChanged())); + } else { + TQCheckBox* thisButton = new TQCheckBox(RandRScreen::rotationName(thisRotation), m_rotationGroup); + thisButton->setEnabled(thisRotation & currentScreen()->rotations()); + connect(thisButton, TQT_SIGNAL(clicked()), TQT_SLOT(slotRotationChanged())); + } +} + +void KRandRModule::slotScreenChanged(int screen) +{ + setCurrentScreen(screen); + + // Clear resolutions + m_sizeCombo->clear(); + + // Add new resolutions + for (int i = 0; i < currentScreen()->numSizes(); i++) { + m_sizeCombo->insertItem(i18n("%1 x %2").arg(currentScreen()->pixelSize(i).width()).arg(currentScreen()->pixelSize(i).height())); + + // Aspect ratio + /* , aspect ratio %5)*/ + /*.arg((double)currentScreen()->size(i).mwidth / (double)currentScreen()->size(i).mheight))*/ + } + + // Clear rotations + for (int i = m_rotationGroup->count() - 1; i >= 0; i--) + m_rotationGroup->remove(m_rotationGroup->find(i)); + + // Create rotations + for (int i = 0; i < RandRScreen::OrientationCount; i++) + addRotationButton(1 << i, i > RandRScreen::RotationCount - 1); + + populateRefreshRates(); + + update(); + + setChanged(); +} + +void KRandRModule::slotRotationChanged() +{ + if (m_rotationGroup->find(0)->isOn()) + currentScreen()->proposeRotation(RandRScreen::Rotate0); + else if (m_rotationGroup->find(1)->isOn()) + currentScreen()->proposeRotation(RandRScreen::Rotate90); + else if (m_rotationGroup->find(2)->isOn()) + currentScreen()->proposeRotation(RandRScreen::Rotate180); + else { + Q_ASSERT(m_rotationGroup->find(3)->isOn()); + currentScreen()->proposeRotation(RandRScreen::Rotate270); + } + + if (m_rotationGroup->find(4)->isOn()) + currentScreen()->proposeRotation(currentScreen()->proposedRotation() ^ RandRScreen::ReflectX); + + if (m_rotationGroup->find(5)->isOn()) + currentScreen()->proposeRotation(currentScreen()->proposedRotation() ^ RandRScreen::ReflectY); + + setChanged(); +} + +void KRandRModule::slotSizeChanged(int index) +{ + int oldProposed = currentScreen()->proposedSize(); + + currentScreen()->proposeSize(index); + + if (currentScreen()->proposedSize() != oldProposed) { + currentScreen()->proposeRefreshRate(0); + + populateRefreshRates(); + + // Item with index zero is already selected + } + + setChanged(); +} + +void KRandRModule::slotRefreshChanged(int index) +{ + currentScreen()->proposeRefreshRate(index); + + setChanged(); +} + +void KRandRModule::populateRefreshRates() +{ + m_refreshRates->clear(); + + TQStringList rr = currentScreen()->refreshRates(currentScreen()->proposedSize()); + + m_refreshRates->setEnabled(rr.count()); + + for (TQStringList::Iterator it = rr.begin(); it != rr.end(); ++it) + m_refreshRates->insertItem(*it); +} + + +void KRandRModule::defaults() +{ + load( true ); +} + +void KRandRModule::load() +{ + load( false ); +} + +void KRandRModule::load( bool useDefaults ) +{ + if (!isValid()) + return; + + // Don't load screen configurations: + // It will be correct already if they wanted to retain their settings over TDE restarts, + // and if it isn't correct they have changed a) their X configuration, b) the screen + // with another program, or c) their hardware. + TDEConfig config("kcmrandrrc", true); + + config.setReadDefaults( useDefaults ); + + m_oldApply = loadDisplay(config, false); + m_oldSyncTrayApp = syncTrayApp(config); + + m_applyOnStartup->setChecked(m_oldApply); + m_syncTrayApp->setChecked(m_oldSyncTrayApp); + + emit changed( useDefaults ); +} + +void KRandRModule::save() +{ + if (!isValid()) + return; + + apply(); + + m_oldApply = m_applyOnStartup->isChecked(); + m_oldSyncTrayApp = m_syncTrayApp->isChecked(); + TDEConfig config("kcmrandrrc"); + saveDisplay(config, m_oldApply, m_oldSyncTrayApp); + + setChanged(); +} + +void KRandRModule::setChanged() +{ + bool isChanged = (m_oldApply != m_applyOnStartup->isChecked()) || (m_oldSyncTrayApp != m_syncTrayApp->isChecked()); + m_syncTrayApp->setEnabled(m_applyOnStartup->isChecked()); + + if (!isChanged) + for (int screenIndex = 0; screenIndex < numScreens(); screenIndex++) { + if (screen(screenIndex)->proposedChanged()) { + isChanged = true; + break; + } + } + + if (isChanged != m_changed) { + m_changed = isChanged; + emit changed(m_changed); + } +} + +void KRandRModule::apply() +{ + if (m_changed) { + applyProposed(); + + update(); + } +} + + +void KRandRModule::update() +{ + m_sizeCombo->blockSignals(true); + m_sizeCombo->setCurrentItem(currentScreen()->proposedSize()); + m_sizeCombo->blockSignals(false); + + m_rotationGroup->blockSignals(true); + switch (currentScreen()->proposedRotation() & RandRScreen::RotateMask) { + case RandRScreen::Rotate0: + m_rotationGroup->setButton(0); + break; + case RandRScreen::Rotate90: + m_rotationGroup->setButton(1); + break; + case RandRScreen::Rotate180: + m_rotationGroup->setButton(2); + break; + case RandRScreen::Rotate270: + m_rotationGroup->setButton(3); + break; + default: + // Shouldn't hit this one + Q_ASSERT(currentScreen()->proposedRotation() & RandRScreen::RotateMask); + break; + } + m_rotationGroup->find(4)->setDown(currentScreen()->proposedRotation() & RandRScreen::ReflectX); + m_rotationGroup->find(5)->setDown(currentScreen()->proposedRotation() & RandRScreen::ReflectY); + m_rotationGroup->blockSignals(false); + + m_refreshRates->blockSignals(true); + m_refreshRates->setCurrentItem(currentScreen()->proposedRefreshRate()); + m_refreshRates->blockSignals(false); +} + diff --git a/kcontrol/randr/tderandrmodule.h b/kcontrol/randr/tderandrmodule.h new file mode 100644 index 000000000..188b4ea1d --- /dev/null +++ b/kcontrol/randr/tderandrmodule.h @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2002 Hamish Rodda + * + * 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. + */ + +#ifndef KRANDRMODULE_H +#define KRANDRMODULE_H + +#include + +class TQButtonGroup; +class KComboBox; +class TQCheckBox; + +class KRandRModule : public TDECModule, public KRandrSimpleAPI +{ + Q_OBJECT + +public: + KRandRModule(TQWidget *parent, const char *name, const TQStringList& _args); + + virtual void load(); + virtual void load(bool useDefaults); + virtual void save(); + virtual void defaults(); + + static void performApplyOnStartup(); + +protected slots: + void slotScreenChanged(int screen); + void slotRotationChanged(); + void slotSizeChanged(int index); + void slotRefreshChanged(int index); + void setChanged(); + +protected: + void apply(); + void update(); + + void addRotationButton(int thisRotation, bool checkbox); + void populateRefreshRates(); + + KComboBox* m_screenSelector; + KComboBox* m_sizeCombo; + TQButtonGroup* m_rotationGroup; + KComboBox* m_refreshRates; + TQCheckBox* m_applyOnStartup; + TQCheckBox* m_syncTrayApp; + bool m_oldApply; + bool m_oldSyncTrayApp; + + bool m_changed; +}; + +#endif diff --git a/kcontrol/randr/tderandrpassivepopup.cpp b/kcontrol/randr/tderandrpassivepopup.cpp new file mode 100644 index 000000000..16e3d75ba --- /dev/null +++ b/kcontrol/randr/tderandrpassivepopup.cpp @@ -0,0 +1,118 @@ +/* + * Copyright (c) 2003 Lubos Lunak + * + * 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 "tderandrpassivepopup.h" + +#include + +// this class is just like KPassivePopup, but it keeps track of the widget +// it's supposed to be positioned next to, and adjust its position if that +// widgets moves (needed because after a resolution switch Kicker will +// reposition itself, causing normal KPassivePopup to stay at weird places) + +KRandrPassivePopup::KRandrPassivePopup( TQWidget *parent, const char *name, WFlags f ) + : KPassivePopup( parent, name, f ) + { + connect( &update_timer, TQT_SIGNAL( timeout()), TQT_SLOT( slotPositionSelf())); + } + +KRandrPassivePopup* KRandrPassivePopup::message( const TQString &caption, const TQString &text, + const TQPixmap &icon, TQWidget *parent, const char *name, int timeout ) + { + KRandrPassivePopup *pop = new KRandrPassivePopup( parent, name ); + pop->setAutoDelete( true ); + pop->setView( caption, text, icon ); + pop->setTimeout( timeout ); + pop->show(); + pop->startWatchingWidget( parent ); + return pop; + } + +void KRandrPassivePopup::startWatchingWidget( TQWidget* widget_P ) + { + static Atom wm_state = XInternAtom( tqt_xdisplay() , "WM_STATE", False ); + Window win = widget_P->winId(); + bool x11_events = false; + for(;;) + { + Window root, parent; + Window* children; + unsigned int nchildren; + XQueryTree( tqt_xdisplay(), win, &root, &parent, &children, &nchildren ); + if( children != NULL ) + XFree( children ); + if( win == root ) // huh? + break; + win = parent; + + TQWidget* widget = TQWidget::find( win ); + if( widget != NULL ) + { + widget->installEventFilter( this ); + watched_widgets.append( widget ); + } + else + { + XWindowAttributes attrs; + XGetWindowAttributes( tqt_xdisplay(), win, &attrs ); + XSelectInput( tqt_xdisplay(), win, attrs.your_event_mask | StructureNotifyMask ); + watched_windows.append( win ); + x11_events = true; + } + Atom type; + int format; + unsigned long nitems, after; + unsigned char* data; + if( XGetWindowProperty( tqt_xdisplay(), win, wm_state, 0, 0, False, AnyPropertyType, + &type, &format, &nitems, &after, &data ) == Success ) + { + if( data != NULL ) + XFree( data ); + if( type != None ) // toplevel window + break; + } + } + if( x11_events ) + kapp->installX11EventFilter( this ); + } + +bool KRandrPassivePopup::eventFilter( TQObject* o, TQEvent* e ) + { + if( e->type() == TQEvent::Move && o->isWidgetType() + && watched_widgets.contains( TQT_TQWIDGET( o ))) + TQTimer::singleShot( 0, this, TQT_SLOT( slotPositionSelf())); + return false; + } + +bool KRandrPassivePopup::x11Event( XEvent* e ) + { + if( e->type == ConfigureNotify && watched_windows.contains( e->xconfigure.window )) + { + if( !update_timer.isActive()) + update_timer.start( 10, true ); + return false; + } + return KPassivePopup::x11Event( e ); + } + +void KRandrPassivePopup::slotPositionSelf() + { + positionSelf(); + } + +#include "tderandrpassivepopup.moc" diff --git a/kcontrol/randr/tderandrpassivepopup.h b/kcontrol/randr/tderandrpassivepopup.h new file mode 100644 index 000000000..3b1d4b4f6 --- /dev/null +++ b/kcontrol/randr/tderandrpassivepopup.h @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2003 Lubos Lunak + * + * 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. + */ + +#ifndef __RANDRPASSIVEPOPUP_H__ +#define __RANDRPASSIVEPOPUP_H__ + +#include +#include +#include +#include + +class KRandrPassivePopup + : public KPassivePopup + { + Q_OBJECT + public: + static KRandrPassivePopup *message( const TQString &caption, const TQString &text, + const TQPixmap &icon, TQWidget *parent, const char *name=0, int timeout = -1 ); + protected: + virtual bool eventFilter( TQObject* o, TQEvent* e ); + virtual bool x11Event( XEvent* e ); + private slots: + void slotPositionSelf(); + private: + KRandrPassivePopup( TQWidget *parent=0, const char *name=0, WFlags f=0 ); + void startWatchingWidget( TQWidget* w ); + TQValueList< TQWidget* > watched_widgets; + TQValueList< Window > watched_windows; + TQTimer update_timer; + }; + +#endif diff --git a/kcontrol/randr/tderandrtray-autostart.desktop b/kcontrol/randr/tderandrtray-autostart.desktop new file mode 100644 index 000000000..1c3f20403 --- /dev/null +++ b/kcontrol/randr/tderandrtray-autostart.desktop @@ -0,0 +1,144 @@ +[Desktop Entry] +Name=KRandRTray +Name[be]=Змена параметраў манітора +Name[hu]=Képernyőfelbontás +Name[ne]=KRandR ट्रे +Name[pt_BR]=Ícone do KRandR +Name[sv]=Krandrtray +Name[vi]=Khay KRandR +GenericName=Screen Resize & Rotate +GenericName[af]=Skerm Hervergroot & Roteer +GenericName[be]=Змена памераў экрана і перагортванне +GenericName[bg]=Размер и ротация на екрана +GenericName[bn]=পর্দা মাপবদল ও আবর্তন +GenericName[br]=Adventañ ha treiñ ar skramm +GenericName[bs]=Veličina i rotacija ekrana +GenericName[ca]=Amida i gira la pantalla +GenericName[cs]=Změna velikosti a rotace obrazovky +GenericName[csb]=Òbrócenié ë zjinaka miarë ekranu +GenericName[cy]=Newid Maint a Cylchdroi'r Sgrîn +GenericName[da]=Ændr størrelse på skærm & Rotér +GenericName[de]=Bildschirmgröße & -ausrichtung ändern +GenericName[el]=Αλλαγή μεγέθους & Περιστροφή οθόνης +GenericName[eo]=Regrandigi kaj Turni Ekranon +GenericName[es]=Redimensionar y rotar pantalla +GenericName[et]=Ekraani suuruse muutmine ja pööramine +GenericName[eu]=Pantailaren tamaina aldaketa eta biraketa +GenericName[fa]=تغییر اندازه و چرخش پرده +GenericName[fi]=Näytön kuvan koon muuttaminen ja kuvan kääntäminen +GenericName[fr]=Redimensionnement et rotation de l'écran +GenericName[fy]=Skerm rotearje en grutte wizigje +GenericName[gl]=Rotación e Redimensionamento da Pantallla +GenericName[he]=שינוי גודל המסך וסיבובו +GenericName[hr]=Veličine i orijentacija zaslona +GenericName[hu]=Képernyőbeállító +GenericName[is]=Stærð og snúningur skjáa +GenericName[it]=Ruota e ridimensiona lo schermo +GenericName[ja]=スクリーンのリサイズと回転 +GenericName[ka]=ეკრანის ზომა და ორიენტაცია +GenericName[kk]=Экранды өзгерту және бұрау +GenericName[km]=ប្ដូរ​ទំហំ & បង្វិល​អេក្រង់ +GenericName[ko]=화면 크기 조정 및 회전 +GenericName[lt]=Ekrano dydžio keitimas ir pasukimas +GenericName[mk]=Големина и ротација на екранот +GenericName[ms]=Saiz Semula Skrin & Putar +GenericName[nb]=Endre størrelsen på og rotere skjermbildet +GenericName[nds]=Schirmgrött un -utrichten ännern +GenericName[ne]=पर्दा रिसाइज र परिक्रमण +GenericName[nl]=Scherm roteren en grootte wijzigen +GenericName[nn]=Endra storleiken på og roter skjermbiletet +GenericName[pa]=ਪਰਦਾ ਮੁੜ ਆਕਾਰ ਤੇ ਘੁੰਮਾਓ +GenericName[pl]=Obrót i zmiana rozmiaru ekranu +GenericName[pt]=Mudar o Tamanho e Rodar o Ecrã +GenericName[pt_BR]=Redimensionar Tela & Rotacionar +GenericName[ro]=Redimensionare și rotire ecran +GenericName[ru]=Изменение размера и ориентации экрана +GenericName[rw]=Kuhindura ingano & Kuzengurutsa Mugaragaza +GenericName[se]=Rievdat šearbmagova sturrodaga ja jorat dan +GenericName[sk]=Zmena veľkosti a otočenia obrazovky +GenericName[sl]=Spreminjanje velikosti in obračanje zaslona +GenericName[sr]=Промена величине и ротација екрана +GenericName[sr@Latn]=Promena veličine i rotacija ekrana +GenericName[sv]=Ändra skärmstorlek och rotera +GenericName[ta]=திரை அளவு மாற்று & சுழற்று +GenericName[tg]=Ивази андоза ва мавқеи экран +GenericName[th]=ปรับขนาดและหมุนหน้าจอ +GenericName[tr]=Ekran Boyutlandır ve Döndür +GenericName[tt]=Küräk Ülçäme & Borılışı +GenericName[uk]=Зміна розміру та обертання екрана +GenericName[uz]=Ekraning oʻlchamini oʻzgartirish va burish +GenericName[uz@cyrillic]=Экранинг ўлчамини ўзгартириш ва буриш +GenericName[vi]=Thay đổi cỡ màn hình & Quay +GenericName[wa]=Candjî l' grandeu del waitroûle eyet l' tourner +GenericName[zh_CN]=屏幕大小和旋转 +GenericName[zh_TW]=螢幕調整大小及旋轉 +Comment=Resize and rotate X screens. +Comment[af]=Hervergroot en roteer X skerms. +Comment[ar]=غيير القياس و الدوران للشاشات X. +Comment[be]=Змена памераў і перагортванне экранаў X. +Comment[bg]=Размер и ротация на екрана. +Comment[bn]=আপনার এক্স-স্ক্রীণ-এর আকৃতি এবং দিশা পরিবর্তন করুন +Comment[br]=Adventañ ha treiñ ho diskweloù X. +Comment[bs]=Podesite veličinu i rotirajte vaš ekran. +Comment[ca]=Gira i amida les pantalles X. +Comment[cs]=Změna velikosti a rotace obrazovky. +Comment[csb]=Zjinaka miarë ë pòłożenia ekranów. +Comment[da]=Ændrer størrelse og roterer X-skærme +Comment[de]=Die Größe und Ausrichtung der Anzeige ändern +Comment[el]=Αλλαγή μεγέθους και περιστροφή της οθόνης. +Comment[eo]=Regrandigi kaj turni X ekranojn. +Comment[es]=Ajustar el tamaño y rotar las pantallas X. +Comment[et]=X'i ekraani muutmine ja pööramine +Comment[eu]=Aldatu tamaina eta biratu zure X pantailak. +Comment[fa]=تغییر‌ اندازه و چرخش پرده‌های X. +Comment[fi]=Näytön kuvan koon muuttaminen ja kuvan kääntäminen +Comment[fr]=Redimensionner et retourner votre affichage. +Comment[fy]=Skermgrutte wizigje en rotearje X skermen +Comment[ga]=Athraigh an méid agus rothlaigh scáileáin X. +Comment[gl]=Redimensionar e rotar pantallas +Comment[he]=שנה את גודלה של התצוגה שלך וסובב אותה. +Comment[hr]=Promjena veličine i orijentacije X zaslona +Comment[hu]=A képernyő átméretezése, elforgatása +Comment[is]=Breyta stærð skjásins og snúa honum. +Comment[it]=Ridimensiona e ruota gli schermi di X. +Comment[ja]=X スクリーンのリサイズと回転。 +Comment[ka]=ეკრანის ზომის და ორიენტაციის შეცვლა +Comment[kk]=Экранның өлшемін және бағытын өзгерту +Comment[km]=ប្ដូរ​ទំហំ និង​បង្វិល​អេក្រង់ X ។ +Comment[lt]=Keisti X ekrano dydį ir orientaciją. +Comment[mk]=Сменете ја големината и ротацијата на вашиот екран +Comment[nb]=Endrer størrelsen på og roterer X-skjermbildet +Comment[nds]=Grött un Utrichten vun den X-Schirm ännern +Comment[ne]=X पर्दा रिसाइज गर्नुहोस् र घुमाउनुहोस् +Comment[nl]=Scherm roteren en van grootte veranderen +Comment[nn]=Endra storleiken på og roter X-skjermbiletet. +Comment[pa]=X ਸਕਰੀਨ ਨੂੰ ਮੁੜ-ਅਕਾਰ ਅਤੇ ਘੁੰਮਾਓ। +Comment[pl]=Zmiana rozmiaru i orientacji ekranów. +Comment[pt]=Mudar o tamanho e rodar os ecrãs do X. +Comment[pt_BR]=Redimensiona e rotaciona as tela do X. +Comment[ro]=Redimensionează și rotește ecranele X. +Comment[ru]=Изменение размера и ориентации экранов X. +Comment[se]=Rievdat X-šearpmaid sturrodaga ja joraheami. +Comment[sk]=Zmení veľkosť a otočí obrazovky +Comment[sl]=Spremenite velikost in obrnite zaslon. +Comment[sr]=Промените величину и оријентацију екрана +Comment[sr@Latn]=Promenite veličinu i orijentaciju ekrana +Comment[sv]=Storleksändring och rotation av X-skärmar. +Comment[tg]=Ивази андоза ва мавқеи экранҳои Х. +Comment[th]=ปรับแต่งการแสดงผลของ X +Comment[tr]=Ekranı boyutlandır ve çevir. +Comment[uk]=Зміна розміру та обертання екранів X. +Comment[uz]=Ekraning oʻlchamini oʻzgartirish va burish +Comment[uz@cyrillic]=Экранинг ўлчамини ўзгартириш ва буриш +Comment[vi]=Đổi cỡ và quay màn hình X. +Comment[wa]=Candjî l' grandeu eyet tourner les waitroûles X. +Comment[zh_CN]=更改 X 屏幕的大小和旋转。 +Comment[zh_TW]=調整大小及旋轉 X 螢幕。 +Exec=tderandrtray +Icon=randr +X-TDE-autostart-after=panel +X-TDE-StartupNotify=false +X-TDE-UniqueApplet=true +X-TDE-autostart-condition=tderandrtrayrc:General:Autostart:true +Categories=System;Applet; + diff --git a/kcontrol/randr/tderandrtray.cpp b/kcontrol/randr/tderandrtray.cpp new file mode 100644 index 000000000..42151d87e --- /dev/null +++ b/kcontrol/randr/tderandrtray.cpp @@ -0,0 +1,884 @@ +/* + * Copyright (c) 2002,2003 Hamish Rodda + * + * 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 +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include "configdialog.h" + +#include "tderandrtray.h" +#include "tderandrpassivepopup.h" +#include "tderandrtray.moc" + +#define OUTPUT_CONNECTED (1 << 0) +#define OUTPUT_UNKNOWN (1 << 1) +#define OUTPUT_DISCONNECTED (1 << 2) +#define OUTPUT_ON (1 << 3) +#define OUTPUT_ALL (0xf) + +KRandRSystemTray::KRandRSystemTray(TQWidget* parent, const char *name) + : KSystemTray(parent, name) + , m_popupUp(false) + , m_help(new KHelpMenu(this, TDEGlobal::instance()->aboutData(), false, actionCollection())) +{ + setPixmap(KSystemTray::loadSizedIcon("randr", width())); + setAlignment(Qt::AlignHCenter | Qt::AlignVCenter); + connect(this, TQT_SIGNAL(quitSelected()), this, TQT_SLOT(_quit())); + TQToolTip::add(this, i18n("Screen resize & rotate")); + my_parent = parent; + + //printf("Reading configuration...\n\r"); + globalKeys = new TDEGlobalAccel(TQT_TQOBJECT(this)); + TDEGlobalAccel* keys = globalKeys; +#include "tderandrbindings.cpp" + // the keys need to be read from kdeglobals, not kickerrc + globalKeys->readSettings(); + globalKeys->setEnabled(true); + globalKeys->updateConnections(); + + connect(kapp, TQT_SIGNAL(settingsChanged(int)), TQT_SLOT(slotSettingsChanged(int))); + +#if (TQT_VERSION-0 >= 0x030200) // XRANDR support +// connect(this, TQT_SIGNAL(screenSizeChanged(int, int)), kapp->desktop(), TQT_SLOT( desktopResized())); +#endif + + randr_display = XOpenDisplay(NULL); + + if (isValid() == true) { + last_known_x = currentScreen()->currentPixelWidth(); + last_known_y = currentScreen()->currentPixelHeight(); + } + + t_config = new KSimpleConfig("kiccconfigrc"); + + TQString cur_profile; + cur_profile = getCurrentProfile(); + if (cur_profile != "") { + applyIccConfiguration(cur_profile, NULL); + } + + TDEHardwareDevices *hwdevices = TDEGlobal::hardwareDevices(); + connect(hwdevices, TQT_SIGNAL(hardwareUpdated(TDEGenericDevice*)), this, TQT_SLOT(deviceChanged(TDEGenericDevice*))); +} + +/*! + * \b TQT_SLOT which called if tderandrtray is exited by the user. In this case the user + * is asked through a yes/no box if "KRandRTray should start automatically on log in" and the + * result is written to the KDE configfile. + */ +void KRandRSystemTray::_quit (){ + r_config = new KSimpleConfig("tderandrtrayrc"); + + TQString tmp1 = i18n ("Start KRandRTray automatically when you log in?"); + int tmp2 = KMessageBox::questionYesNo ( 0, tmp1, i18n("Question"), i18n("Start Automatically"), i18n("Do Not Start")); + r_config->setGroup("General"); + r_config->writeEntry ("Autostart", tmp2 == KMessageBox::Yes); + r_config->sync (); + + exit(0); +} + +void KRandRSystemTray::resizeEvent ( TQResizeEvent * ) +{ + // Honor Free Desktop specifications that allow for arbitrary system tray icon sizes + TQPixmap origpixmap; + TQPixmap scaledpixmap; + TQImage newIcon; + origpixmap = KSystemTray::loadSizedIcon( "randr", width() ); + newIcon = origpixmap; + newIcon = newIcon.smoothScale(width(), height()); + scaledpixmap = newIcon; + setPixmap(scaledpixmap); +} + +void KRandRSystemTray::mousePressEvent(TQMouseEvent* e) +{ + // Popup the context menu with left-click + if (e->button() == Qt::LeftButton) { + contextMenuAboutToShow(contextMenu()); + contextMenu()->popup(e->globalPos()); + e->accept(); + return; + } + + KSystemTray::mousePressEvent(e); +} + +void KRandRSystemTray::reloadDisplayConfiguration() +{ + // Reload the randr configuration... + int i; + int activeOutputs = 0; + int screenDeactivated = 0; + + if (isValid() == true) { + randr_screen_info = read_screen_info(randr_display); + + // Count outputs in the active state + activeOutputs = 0; + for (i = 0; i < randr_screen_info->n_output; i++) { + // Look for ON outputs + if (!randr_screen_info->outputs[i]->cur_crtc) { + continue; + } + // Look for CONNECTED outputs + if (RR_Disconnected == randr_screen_info->outputs[i]->info->connection) { + continue; + } + + activeOutputs++; + } + + if (activeOutputs < 1) { + // Houston, we have a problem! + // There are no active displays! + // Activate the first connected display we come across... + for (i = 0; i < randr_screen_info->n_output; i++) { + // Look for OFF outputs + if (randr_screen_info->outputs[i]->cur_crtc) { + continue; + } + // Look for CONNECTED outputs + if (RR_Disconnected == randr_screen_info->outputs[i]->info->connection) { + continue; + } + + // Activate this output + randr_screen_info->cur_crtc = randr_screen_info->outputs[i]->cur_crtc; + randr_screen_info->cur_output = randr_screen_info->outputs[i]; + randr_screen_info->cur_output->auto_set = 1; + randr_screen_info->cur_output->off_set = 0; + output_auto (randr_screen_info, randr_screen_info->cur_output); + i=main_low_apply(randr_screen_info); + + if (randr_screen_info->outputs[i]->cur_crtc) { + // Output successfully activated! + set_primary_output(randr_screen_info, randr_screen_info->cur_output->id); + break; + } + } + } + + for (i = 0; i < randr_screen_info->n_output; i++) { + // Look for ON outputs + if (!randr_screen_info->outputs[i]->cur_crtc) { + continue; + } + // Look for DISCONNECTED outputs + if (RR_Disconnected != randr_screen_info->outputs[i]->info->connection) { + continue; + } + + // Deactivate this display to avoid a crash! + randr_screen_info->cur_crtc = randr_screen_info->outputs[i]->cur_crtc; + randr_screen_info->cur_output = randr_screen_info->outputs[i]; + randr_screen_info->cur_output->auto_set = 0; + randr_screen_info->cur_output->off_set = 1; + output_off(randr_screen_info, randr_screen_info->cur_output); + main_low_apply(randr_screen_info); + + screenDeactivated = 1; + } + + if (screenDeactivated == 1) { + findPrimaryDisplay(); + refresh(); + + currentScreen()->proposeSize(GetDefaultResolutionParameter()); + currentScreen()->applyProposed(); + } + } +} + +void KRandRSystemTray::contextMenuAboutToShow(KPopupMenu* menu) +{ + int lastIndex = 0; + + reloadDisplayConfiguration(); + + menu->clear(); + menu->setCheckable(true); + + bool valid = isValid(); + + if (!valid) { + lastIndex = menu->insertItem(i18n("Required X Extension Not Available")); + menu->setItemEnabled(lastIndex, false); + + } + else { + m_screenPopups.clear(); + for (int s = 0; s < numScreens() /*&& numScreens() > 1 */; s++) { + setCurrentScreen(s); + if (s == screenIndexOfWidget(this)) { + /*lastIndex = menu->insertItem(i18n("Screen %1").arg(s+1)); + menu->setItemEnabled(lastIndex, false);*/ + } else { + KPopupMenu* subMenu = new KPopupMenu(menu, TQString("screen%1").arg(s+1).latin1()); + m_screenPopups.append(subMenu); + populateMenu(subMenu); + lastIndex = menu->insertItem(i18n("Screen %1").arg(s+1), subMenu); + connect(subMenu, TQT_SIGNAL(activated(int)), TQT_SLOT(slotScreenActivated())); + } + } + + setCurrentScreen(screenIndexOfWidget(this)); + populateMenu(menu); + } + + addOutputMenu(menu); + + // Find any user ICC profiles + TQStringList cfgProfiles; + cfgProfiles = t_config->groupList(); + if (cfgProfiles.isEmpty() == false) { + menu->insertTitle(SmallIcon("kcoloredit"), i18n("Color Profile")); + } + for (TQStringList::Iterator t(cfgProfiles.begin()); t != cfgProfiles.end(); ++t) { + lastIndex = menu->insertItem(*t); + if (t_config->readEntry("CurrentProfile") == (*t)) { + menu->setItemChecked(lastIndex, true); + } + menu->setItemEnabled(lastIndex, t_config->readBoolEntry("EnableICC", false)); + menu->connectItem(lastIndex, this, TQT_SLOT(slotColorProfileChanged(int))); + } + + if (valid) { + // Find any display profiles + TQStringList displayProfiles; + displayProfiles = getDisplayConfigurationProfiles(locateLocal("config", "/", true)); + if (displayProfiles.isEmpty() == false) { + menu->insertTitle(SmallIcon("background"), i18n("Display Profiles")); + } + lastIndex = menu->insertItem(SmallIcon("bookmark"), ""); + menu->connectItem(lastIndex, this, TQT_SLOT(slotDisplayProfileChanged(int))); + for (TQStringList::Iterator t(displayProfiles.begin()); t != displayProfiles.end(); ++t) { + lastIndex = menu->insertItem(SmallIcon("bookmark"), *t); + menu->connectItem(lastIndex, this, TQT_SLOT(slotDisplayProfileChanged(int))); + } + } + + menu->insertTitle(SmallIcon("randr"), i18n("Global Configuation")); + + KAction *actColors = new KAction( i18n( "Configure Displays..." ), + SmallIconSet( "configure" ), KShortcut(), TQT_TQOBJECT(this), TQT_SLOT( slotDisplayConfig() ), + actionCollection() ); + actColors->plug( menu ); + +// KAction *actPrefs = new KAction( i18n( "Configure Display..." ), +// SmallIconSet( "configure" ), KShortcut(), this, TQT_SLOT( slotPrefs() ), +// actionCollection() ); +// actPrefs->plug( menu ); + + KAction *actSKeys = new KAction( i18n( "Configure Shortcut Keys..." ), + SmallIconSet( "configure" ), KShortcut(), TQT_TQOBJECT(this), TQT_SLOT( slotSKeys() ), + actionCollection() ); + actSKeys->plug( menu ); + + menu->insertItem(SmallIcon("help"),KStdGuiItem::help().text(), m_help->menu()); + KAction *quitAction = actionCollection()->action(KStdAction::name(KStdAction::Quit)); + quitAction->plug(menu); + + m_menu = menu; +} + +void KRandRSystemTray::slotScreenActivated() +{ + setCurrentScreen(m_screenPopups.find(static_cast(sender()))); +} + +void KRandRSystemTray::configChanged() +{ + refresh(); + + static bool first = true; + + if ((last_known_x == currentScreen()->currentPixelWidth()) && \ + (last_known_y == currentScreen()->currentPixelHeight())) { + first = true; + } + + last_known_x = currentScreen()->currentPixelWidth(); + last_known_y = currentScreen()->currentPixelHeight(); + + if (!first) { + emit (screenSizeChanged(currentScreen()->currentPixelWidth(), currentScreen()->currentPixelHeight())); + + KRandrPassivePopup::message( + i18n("Screen configuration has changed"), + currentScreen()->changedMessage(), SmallIcon("window_fullscreen"), + this, "ScreenChangeNotification"); + } + + first = false; + + TQString cur_profile; + cur_profile = getCurrentProfile(); + if (cur_profile != "") { + applyIccConfiguration(cur_profile, NULL); + } +} + +int KRandRSystemTray::GetDefaultResolutionParameter() +{ + int returnIndex = 0; + + int numSizes = currentScreen()->numSizes(); + int* sizeSort = new int[numSizes]; + + for (int i = 0; i < numSizes; i++) { + sizeSort[i] = currentScreen()->pixelCount(i); + } + + int highest = -1, highestIndex = -1; + + for (int i = 0; i < numSizes; i++) { + if (sizeSort[i] && sizeSort[i] > highest) { + highest = sizeSort[i]; + highestIndex = i; + } + } + sizeSort[highestIndex] = -1; + Q_ASSERT(highestIndex != -1); + + returnIndex = highestIndex; + + delete [] sizeSort; + sizeSort = 0L; + + return returnIndex; +} + +int KRandRSystemTray::GetHackResolutionParameter() { + int resparm; + + resparm = GetDefaultResolutionParameter(); + resparm++; + + return resparm; +} + +void KRandRSystemTray::populateMenu(KPopupMenu* menu) +{ + int lastIndex = 0; + + menu->insertTitle(SmallIcon("window_fullscreen"), i18n("Screen Size")); + + int numSizes = currentScreen()->numSizes(); + int* sizeSort = new int[numSizes]; + + for (int i = 0; i < numSizes; i++) { + sizeSort[i] = currentScreen()->pixelCount(i); + } + + for (int j = 0; j < numSizes; j++) { + int highest = -1, highestIndex = -1; + + for (int i = 0; i < numSizes; i++) { + if (sizeSort[i] && sizeSort[i] > highest) { + highest = sizeSort[i]; + highestIndex = i; + } + } + sizeSort[highestIndex] = -1; + Q_ASSERT(highestIndex != -1); + + lastIndex = menu->insertItem(i18n("%1 x %2").arg(currentScreen()->pixelSize(highestIndex).width()).arg(currentScreen()->pixelSize(highestIndex).height())); + + if (currentScreen()->proposedSize() == highestIndex) + menu->setItemChecked(lastIndex, true); + + menu->setItemParameter(lastIndex, highestIndex); + menu->connectItem(lastIndex, this, TQT_SLOT(slotResolutionChanged(int))); + } + delete [] sizeSort; + sizeSort = 0L; + + // Don't display the rotation options if there is no point (ie. none are supported) + // XFree86 4.3 does not include rotation support. + if (currentScreen()->rotations() != RandRScreen::Rotate0) { + menu->insertTitle(SmallIcon("reload"), i18n("Orientation")); + + for (int i = 0; i < 6; i++) { + if ((1 << i) & currentScreen()->rotations()) { + lastIndex = menu->insertItem(currentScreen()->rotationIcon(1 << i), RandRScreen::rotationName(1 << i)); + + if (currentScreen()->proposedRotation() & (1 << i)) + menu->setItemChecked(lastIndex, true); + + menu->setItemParameter(lastIndex, 1 << i); + menu->connectItem(lastIndex, this, TQT_SLOT(slotOrientationChanged(int))); + } + } + } + + TQStringList rr = currentScreen()->refreshRates(currentScreen()->proposedSize()); + + if (rr.count()) + menu->insertTitle(SmallIcon("clock"), i18n("Refresh Rate")); + + int i = 0; + for (TQStringList::Iterator it = rr.begin(); it != rr.end(); ++it, i++) { + lastIndex = menu->insertItem(*it); + + if (currentScreen()->proposedRefreshRate() == i) + menu->setItemChecked(lastIndex, true); + + menu->setItemParameter(lastIndex, i); + menu->connectItem(lastIndex, this, TQT_SLOT(slotRefreshRateChanged(int))); + } +} + +void KRandRSystemTray::slotResolutionChanged(int parameter) +{ + if (currentScreen()->currentSize() == parameter) { + //printf("This resolution is already in use; applying again...\n\r"); + currentScreen()->proposeSize(parameter); + currentScreen()->applyProposed(); + return; + } + + currentScreen()->proposeSize(parameter); + + currentScreen()->proposeRefreshRate(-1); + + if (currentScreen()->applyProposedAndConfirm()) { + TDEConfig config("kcmrandrrc"); + if (syncTrayApp(config)) + currentScreen()->save(config); + } +} + +void KRandRSystemTray::slotOrientationChanged(int parameter) +{ + int propose = currentScreen()->currentRotation(); + + if (parameter & RandRScreen::RotateMask) + propose &= RandRScreen::ReflectMask; + + propose ^= parameter; + + if (currentScreen()->currentRotation() == propose) + return; + + currentScreen()->proposeRotation(propose); + + if (currentScreen()->applyProposedAndConfirm()) { + TDEConfig config("kcmrandrrc"); + if (syncTrayApp(config)) + currentScreen()->save(config); + } +} + +void KRandRSystemTray::slotRefreshRateChanged(int parameter) +{ + if (currentScreen()->currentRefreshRate() == parameter) + return; + + currentScreen()->proposeRefreshRate(parameter); + + if (currentScreen()->applyProposedAndConfirm()) { + TDEConfig config("kcmrandrrc"); + if (syncTrayApp(config)) + currentScreen()->save(config); + } +} + +void KRandRSystemTray::slotPrefs() +{ + KCMultiDialog *kcm = new KCMultiDialog( KDialogBase::Plain, i18n( "Configure" ), this ); + + kcm->addModule( "displayconfig" ); + kcm->setPlainCaption( i18n( "Configure Display" ) ); + kcm->exec(); +} + +void KRandRSystemTray::slotDisplayConfig() +{ + KCMultiDialog *kcm = new KCMultiDialog( KDialogBase::Plain, i18n( "Configure" ), this ); + + kcm->addModule( "displayconfig" ); + kcm->setPlainCaption( i18n( "Configure Displays" ) ); + kcm->exec(); +} + +void KRandRSystemTray::slotSettingsChanged(int category) +{ + if ( category == (int) TDEApplication::SETTINGS_SHORTCUTS ) { + globalKeys->readSettings(); + globalKeys->updateConnections(); + } +} + +void KRandRSystemTray::slotSKeys() +{ + ConfigDialog *dlg = new ConfigDialog(globalKeys, true); + + if ( dlg->exec() == TQDialog::Accepted ) { + dlg->commitShortcuts(); + globalKeys->writeSettings(0, true); + globalKeys->updateConnections(); + } + + delete dlg; +} + +void KRandRSystemTray::slotCycleDisplays() +{ + XRROutputInfo *output_info; + char *output_name; + int i; + int current_on_index = -1; + int max_index = -1; + int prev_on_index; + + randr_screen_info = read_screen_info(randr_display); + + for (i = 0; i < randr_screen_info->n_output; i++) { + output_info = randr_screen_info->outputs[i]->info; + // Look for ON outputs... + if (!randr_screen_info->outputs[i]->cur_crtc) { + continue; + } + // ...that are connected + if (RR_Disconnected == randr_screen_info->outputs[i]->info->connection) { + continue; + } + + output_name = output_info->name; + current_on_index = i; + if (i > max_index) { + max_index = i; + } + } + + for (i = 0; i < randr_screen_info->n_output; i++) { + output_info = randr_screen_info->outputs[i]->info; + // Look for CONNECTED outputs.... + if (RR_Disconnected == randr_screen_info->outputs[i]->info->connection) { + continue; + } + // ...that are not ON + if (randr_screen_info->outputs[i]->cur_crtc) { + continue; + } + + output_name = output_info->name; + if (i > max_index) { + max_index = i; + } + } + + for (i = 0; i < randr_screen_info->n_output; i++) { + output_info = randr_screen_info->outputs[i]->info; + // Look for ALL outputs that are not connected.... + if (RR_Disconnected != randr_screen_info->outputs[i]->info->connection) { + continue; + } + // ...or ON + if (randr_screen_info->outputs[i]->cur_crtc) { + continue; + } + + output_name = output_info->name; + if (i > max_index) { + max_index = i; + } + } + + //printf("Active: %d\n\r", current_on_index); + //printf("Max: %d\n\r", max_index); + + if ((current_on_index == -1) && (max_index == -1)) { + // There is no connected display available! ABORT + return; + } + + prev_on_index = current_on_index; + current_on_index = current_on_index + 1; + if (current_on_index > max_index) { + current_on_index = 0; + } + while (RR_Disconnected == randr_screen_info->outputs[current_on_index]->info->connection) { + current_on_index = current_on_index + 1; + if (current_on_index > max_index) { + current_on_index = 0; + } + } + if (prev_on_index != current_on_index) { + randr_screen_info->cur_crtc = randr_screen_info->outputs[current_on_index]->cur_crtc; + randr_screen_info->cur_output = randr_screen_info->outputs[current_on_index]; + randr_screen_info->cur_output->auto_set = 1; + randr_screen_info->cur_output->off_set = 0; + output_auto (randr_screen_info, randr_screen_info->cur_output); + i=main_low_apply(randr_screen_info); + + if (randr_screen_info->outputs[current_on_index]->cur_crtc) { + // Output successfully activated! + set_primary_output(randr_screen_info, randr_screen_info->cur_output->id); + + if (prev_on_index != -1) { + if (randr_screen_info->outputs[prev_on_index]->cur_crtc != NULL) { + if (RR_Disconnected != randr_screen_info->outputs[prev_on_index]->info->connection) { + randr_screen_info->cur_crtc = randr_screen_info->outputs[prev_on_index]->cur_crtc; + randr_screen_info->cur_output = randr_screen_info->outputs[prev_on_index]; + randr_screen_info->cur_output->auto_set = 0; + randr_screen_info->cur_output->off_set = 1; + output_off(randr_screen_info, randr_screen_info->cur_output); + i=main_low_apply(randr_screen_info); + } + } + } + + // Do something about the disconnected outputs + for (i = 0; i < randr_screen_info->n_output; i++) { + output_info = randr_screen_info->outputs[i]->info; + // Look for ON outputs + if (!randr_screen_info->outputs[i]->cur_crtc) { + continue; + } + if (RR_Disconnected != randr_screen_info->outputs[i]->info->connection) { + continue; + } + + output_name = output_info->name; + + // Deactivate this display to avoid a crash! + randr_screen_info->cur_crtc = randr_screen_info->outputs[i]->cur_crtc; + randr_screen_info->cur_output = randr_screen_info->outputs[i]; + randr_screen_info->cur_output->auto_set = 0; + randr_screen_info->cur_output->off_set = 1; + output_off(randr_screen_info, randr_screen_info->cur_output); + main_low_apply(randr_screen_info); + } + + findPrimaryDisplay(); + refresh(); + + currentScreen()->proposeSize(GetDefaultResolutionParameter()); + currentScreen()->applyProposed(); + } + else { + output_name = randr_screen_info->outputs[current_on_index]->info->name; + KMessageBox::sorry(my_parent, i18n("Unable to activate output %1

Either the output is not connected to a display,
or the display configuration is not detectable").arg(output_name), i18n("Output Unavailable")); + } + } +} + +void KRandRSystemTray::findPrimaryDisplay() +{ + int i; + + for (i = 0; i < randr_screen_info->n_output; i++) { + // Look for ON outputs... + if (!randr_screen_info->outputs[i]->cur_crtc) { + continue; + } + + // ...that are connected + if (RR_Disconnected == randr_screen_info->outputs[i]->info->connection) { + continue; + } + + randr_screen_info->cur_crtc = randr_screen_info->outputs[i]->cur_crtc; + randr_screen_info->cur_output = randr_screen_info->outputs[i]; + } +} + +void KRandRSystemTray::addOutputMenu(KPopupMenu* menu) +{ + XRROutputInfo *output_info; + char *output_name; + int i; + int lastIndex = 0; + int connected_displays = 0; + + if (isValid() == true) { + menu->insertTitle(SmallIcon("kcmkwm"), i18n("Output Port")); + + for (i = 0; i < randr_screen_info->n_output; i++) { + output_info = randr_screen_info->outputs[i]->info; + // Look for ON outputs + if (!randr_screen_info->outputs[i]->cur_crtc) { + continue; + } + if (RR_Disconnected == randr_screen_info->outputs[i]->info->connection) { + continue; + } + + output_name = output_info->name; + //printf("ON: Found output %s\n\r", output_name); + + lastIndex = menu->insertItem(i18n("%1 (Active)").arg(output_name)); + menu->setItemChecked(lastIndex, true); + menu->connectItem(lastIndex, this, TQT_SLOT(slotOutputChanged(int))); + menu->setItemParameter(lastIndex, i); + + connected_displays++; + } + + for (i = 0; i < randr_screen_info->n_output; i++) { + output_info = randr_screen_info->outputs[i]->info; + // Look for CONNECTED outputs.... + if (RR_Disconnected == randr_screen_info->outputs[i]->info->connection) { + continue; + } + // ...that are not ON + if (randr_screen_info->outputs[i]->cur_crtc) { + continue; + } + + output_name = output_info->name; + //printf("CONNECTED, NOT ON: Found output %s\n\r", output_name); + + lastIndex = menu->insertItem(i18n("%1 (Connected, Inactive)").arg(output_name)); + menu->setItemChecked(lastIndex, false); + menu->connectItem(lastIndex, this, TQT_SLOT(slotOutputChanged(int))); + menu->setItemParameter(lastIndex, i); + + connected_displays++; + } + + for (i = 0; i < randr_screen_info->n_output; i++) { + output_info = randr_screen_info->outputs[i]->info; + // Look for ALL outputs that are not connected.... + if (RR_Disconnected != randr_screen_info->outputs[i]->info->connection) { + continue; + } + // ...or ON + if (randr_screen_info->outputs[i]->cur_crtc) { + continue; + } + + output_name = output_info->name; + //printf("DISCONNECTED, NOT ON: Found output %s\n\r", output_name); + + lastIndex = menu->insertItem(i18n("%1 (Disconnected, Inactive)").arg(output_name)); + menu->setItemChecked(lastIndex, false); + menu->setItemEnabled(lastIndex, false); + menu->connectItem(lastIndex, this, TQT_SLOT(slotOutputChanged(int))); + menu->setItemParameter(lastIndex, i); + } + + lastIndex = menu->insertItem(SmallIcon("forward"), i18n("Next available output")); + if (connected_displays < 2) { + menu->setItemEnabled(lastIndex, false); + } + menu->connectItem(lastIndex, this, TQT_SLOT(slotCycleDisplays())); + } +} + +void KRandRSystemTray::slotColorProfileChanged(int parameter) +{ + t_config->writeEntry("CurrentProfile", m_menu->text(parameter)); + applyIccConfiguration(m_menu->text(parameter), NULL); +} + +void KRandRSystemTray::slotDisplayProfileChanged(int parameter) +{ + TQString profileName = m_menu->text(parameter); + if (profileName == "") { + profileName = ""; + } + TQPtrList profileData = loadDisplayConfiguration(profileName, locateLocal("config", "/", true)); + applyDisplayConfiguration(profileData, TRUE, locateLocal("config", "/", true)); + destroyScreenInformationObject(profileData); +} + +void KRandRSystemTray::slotOutputChanged(int parameter) +{ + char *output_name; + int i; + int num_outputs_on; + + num_outputs_on = 0; + for (i = 0; i < randr_screen_info->n_output; i++) { + // Look for ON outputs + if (!randr_screen_info->outputs[i]->cur_crtc) { + continue; + } + + num_outputs_on++; + } + + if (!randr_screen_info->outputs[parameter]->cur_crtc) { + //printf("Screen was off, turning it on...\n\r"); + + randr_screen_info->cur_crtc = randr_screen_info->outputs[parameter]->cur_crtc; + randr_screen_info->cur_output = randr_screen_info->outputs[parameter]; + randr_screen_info->cur_output->auto_set = 1; + randr_screen_info->cur_output->off_set = 0; + output_auto (randr_screen_info, randr_screen_info->cur_output); + i=main_low_apply(randr_screen_info); + + if (!randr_screen_info->outputs[parameter]->cur_crtc) { + output_name = randr_screen_info->outputs[parameter]->info->name; + KMessageBox::sorry(my_parent, i18n("Unable to activate output %1

Either the output is not connected to a display,
or the display configuration is not detectable").arg(output_name), i18n("Output Unavailable")); + } + } + else { + if (num_outputs_on > 1) { + //printf("Screen was on, turning it off...\n\r"); + randr_screen_info->cur_crtc = randr_screen_info->outputs[parameter]->cur_crtc; + randr_screen_info->cur_output = randr_screen_info->outputs[parameter]; + randr_screen_info->cur_output->auto_set = 0; + randr_screen_info->cur_output->off_set = 1; + output_off(randr_screen_info, randr_screen_info->cur_output); + i=main_low_apply(randr_screen_info); + + findPrimaryDisplay(); + refresh(); + + currentScreen()->proposeSize(GetDefaultResolutionParameter()); + currentScreen()->applyProposed(); + } + else { + KMessageBox::sorry(my_parent, i18n("You are attempting to deactivate the only active output

You must keep at least one display output active at all times!"), i18n("Invalid Operation Requested")); + } + } +} + +void KRandRSystemTray::deviceChanged (TDEGenericDevice* device) { + if (device->type() == TDEGenericDeviceType::Monitor) { + KRandrPassivePopup::message( + i18n("New display output options are available!"), + i18n("A screen has been added, removed, or changed"), SmallIcon("window_fullscreen"), + this, "ScreenChangeNotification"); + + reloadDisplayConfiguration(); + applyHotplugRules(locateLocal("config", "/", true)); + } +} \ No newline at end of file diff --git a/kcontrol/randr/tderandrtray.desktop b/kcontrol/randr/tderandrtray.desktop new file mode 100644 index 000000000..5479287b4 --- /dev/null +++ b/kcontrol/randr/tderandrtray.desktop @@ -0,0 +1,141 @@ +[Desktop Entry] +Name=KRandRTray +Name[be]=Змена параметраў манітора +Name[hu]=Képernyőfelbontás +Name[ne]=KRandR ट्रे +Name[pt_BR]=Ícone do KRandR +Name[sv]=Krandrtray +Name[vi]=Khay KRandR +GenericName=Screen Resize & Rotate +GenericName[af]=Skerm Hervergroot & Roteer +GenericName[be]=Змена памераў экрана і перагортванне +GenericName[bg]=Размер и ротация на екрана +GenericName[bn]=পর্দা মাপবদল ও আবর্তন +GenericName[br]=Adventañ ha treiñ ar skramm +GenericName[bs]=Veličina i rotacija ekrana +GenericName[ca]=Amida i gira la pantalla +GenericName[cs]=Změna velikosti a rotace obrazovky +GenericName[csb]=Òbrócenié ë zjinaka miarë ekranu +GenericName[cy]=Newid Maint a Cylchdroi'r Sgrîn +GenericName[da]=Ændr størrelse på skærm & Rotér +GenericName[de]=Bildschirmgröße & -ausrichtung ändern +GenericName[el]=Αλλαγή μεγέθους & Περιστροφή οθόνης +GenericName[eo]=Regrandigi kaj Turni Ekranon +GenericName[es]=Redimensionar y rotar pantalla +GenericName[et]=Ekraani suuruse muutmine ja pööramine +GenericName[eu]=Pantailaren tamaina aldaketa eta biraketa +GenericName[fa]=تغییر اندازه و چرخش پرده +GenericName[fi]=Näytön kuvan koon muuttaminen ja kuvan kääntäminen +GenericName[fr]=Redimensionnement et rotation de l'écran +GenericName[fy]=Skerm rotearje en grutte wizigje +GenericName[gl]=Rotación e Redimensionamento da Pantallla +GenericName[he]=שינוי גודל המסך וסיבובו +GenericName[hr]=Veličine i orijentacija zaslona +GenericName[hu]=Képernyőbeállító +GenericName[is]=Stærð og snúningur skjáa +GenericName[it]=Ruota e ridimensiona lo schermo +GenericName[ja]=スクリーンのリサイズと回転 +GenericName[ka]=ეკრანის ზომა და ორიენტაცია +GenericName[kk]=Экранды өзгерту және бұрау +GenericName[km]=ប្ដូរ​ទំហំ & បង្វិល​អេក្រង់ +GenericName[ko]=화면 크기 조정 및 회전 +GenericName[lt]=Ekrano dydžio keitimas ir pasukimas +GenericName[mk]=Големина и ротација на екранот +GenericName[ms]=Saiz Semula Skrin & Putar +GenericName[nb]=Endre størrelsen på og rotere skjermbildet +GenericName[nds]=Schirmgrött un -utrichten ännern +GenericName[ne]=पर्दा रिसाइज र परिक्रमण +GenericName[nl]=Scherm roteren en grootte wijzigen +GenericName[nn]=Endra storleiken på og roter skjermbiletet +GenericName[pa]=ਪਰਦਾ ਮੁੜ ਆਕਾਰ ਤੇ ਘੁੰਮਾਓ +GenericName[pl]=Obrót i zmiana rozmiaru ekranu +GenericName[pt]=Mudar o Tamanho e Rodar o Ecrã +GenericName[pt_BR]=Redimensionar Tela & Rotacionar +GenericName[ro]=Redimensionare și rotire ecran +GenericName[ru]=Изменение размера и ориентации экрана +GenericName[rw]=Kuhindura ingano & Kuzengurutsa Mugaragaza +GenericName[se]=Rievdat šearbmagova sturrodaga ja jorat dan +GenericName[sk]=Zmena veľkosti a otočenia obrazovky +GenericName[sl]=Spreminjanje velikosti in obračanje zaslona +GenericName[sr]=Промена величине и ротација екрана +GenericName[sr@Latn]=Promena veličine i rotacija ekrana +GenericName[sv]=Ändra skärmstorlek och rotera +GenericName[ta]=திரை அளவு மாற்று & சுழற்று +GenericName[tg]=Ивази андоза ва мавқеи экран +GenericName[th]=ปรับขนาดและหมุนหน้าจอ +GenericName[tr]=Ekran Boyutlandır ve Döndür +GenericName[tt]=Küräk Ülçäme & Borılışı +GenericName[uk]=Зміна розміру та обертання екрана +GenericName[uz]=Ekraning oʻlchamini oʻzgartirish va burish +GenericName[uz@cyrillic]=Экранинг ўлчамини ўзгартириш ва буриш +GenericName[vi]=Thay đổi cỡ màn hình & Quay +GenericName[wa]=Candjî l' grandeu del waitroûle eyet l' tourner +GenericName[zh_CN]=屏幕大小和旋转 +GenericName[zh_TW]=螢幕調整大小及旋轉 +Comment=Resize and rotate X screens. +Comment[af]=Hervergroot en roteer X skerms. +Comment[ar]=غيير القياس و الدوران للشاشات X. +Comment[be]=Змена памераў і перагортванне экранаў X. +Comment[bg]=Размер и ротация на екрана. +Comment[bn]=আপনার এক্স-স্ক্রীণ-এর আকৃতি এবং দিশা পরিবর্তন করুন +Comment[br]=Adventañ ha treiñ ho diskweloù X. +Comment[bs]=Podesite veličinu i rotirajte vaš ekran. +Comment[ca]=Gira i amida les pantalles X. +Comment[cs]=Změna velikosti a rotace obrazovky. +Comment[csb]=Zjinaka miarë ë pòłożenia ekranów. +Comment[da]=Ændrer størrelse og roterer X-skærme +Comment[de]=Die Größe und Ausrichtung der Anzeige ändern +Comment[el]=Αλλαγή μεγέθους και περιστροφή της οθόνης. +Comment[eo]=Regrandigi kaj turni X ekranojn. +Comment[es]=Ajustar el tamaño y rotar las pantallas X. +Comment[et]=X'i ekraani muutmine ja pööramine +Comment[eu]=Aldatu tamaina eta biratu zure X pantailak. +Comment[fa]=تغییر‌ اندازه و چرخش پرده‌های X. +Comment[fi]=Näytön kuvan koon muuttaminen ja kuvan kääntäminen +Comment[fr]=Redimensionner et retourner votre affichage. +Comment[fy]=Skermgrutte wizigje en rotearje X skermen +Comment[ga]=Athraigh an méid agus rothlaigh scáileáin X. +Comment[gl]=Redimensionar e rotar pantallas +Comment[he]=שנה את גודלה של התצוגה שלך וסובב אותה. +Comment[hr]=Promjena veličine i orijentacije X zaslona +Comment[hu]=A képernyő átméretezése, elforgatása +Comment[is]=Breyta stærð skjásins og snúa honum. +Comment[it]=Ridimensiona e ruota gli schermi di X. +Comment[ja]=X スクリーンのリサイズと回転。 +Comment[ka]=ეკრანის ზომის და ორიენტაციის შეცვლა +Comment[kk]=Экранның өлшемін және бағытын өзгерту +Comment[km]=ប្ដូរ​ទំហំ និង​បង្វិល​អេក្រង់ X ។ +Comment[lt]=Keisti X ekrano dydį ir orientaciją. +Comment[mk]=Сменете ја големината и ротацијата на вашиот екран +Comment[nb]=Endrer størrelsen på og roterer X-skjermbildet +Comment[nds]=Grött un Utrichten vun den X-Schirm ännern +Comment[ne]=X पर्दा रिसाइज गर्नुहोस् र घुमाउनुहोस् +Comment[nl]=Scherm roteren en van grootte veranderen +Comment[nn]=Endra storleiken på og roter X-skjermbiletet. +Comment[pa]=X ਸਕਰੀਨ ਨੂੰ ਮੁੜ-ਅਕਾਰ ਅਤੇ ਘੁੰਮਾਓ। +Comment[pl]=Zmiana rozmiaru i orientacji ekranów. +Comment[pt]=Mudar o tamanho e rodar os ecrãs do X. +Comment[pt_BR]=Redimensiona e rotaciona as tela do X. +Comment[ro]=Redimensionează și rotește ecranele X. +Comment[ru]=Изменение размера и ориентации экранов X. +Comment[se]=Rievdat X-šearpmaid sturrodaga ja joraheami. +Comment[sk]=Zmení veľkosť a otočí obrazovky +Comment[sl]=Spremenite velikost in obrnite zaslon. +Comment[sr]=Промените величину и оријентацију екрана +Comment[sr@Latn]=Promenite veličinu i orijentaciju ekrana +Comment[sv]=Storleksändring och rotation av X-skärmar. +Comment[tg]=Ивази андоза ва мавқеи экранҳои Х. +Comment[th]=ปรับแต่งการแสดงผลของ X +Comment[tr]=Ekranı boyutlandır ve çevir. +Comment[uk]=Зміна розміру та обертання екранів X. +Comment[uz]=Ekraning oʻlchamini oʻzgartirish va burish +Comment[uz@cyrillic]=Экранинг ўлчамини ўзгартириш ва буриш +Comment[vi]=Đổi cỡ và quay màn hình X. +Comment[wa]=Candjî l' grandeu eyet tourner les waitroûles X. +Comment[zh_CN]=更改 X 屏幕的大小和旋转。 +Comment[zh_TW]=調整大小及旋轉 X 螢幕。 +Exec=tderandrtray +Icon=randr +Type=Application +OnlyShowIn=TDE; +Categories=Qt;TDE;System; diff --git a/kcontrol/randr/tderandrtray.h b/kcontrol/randr/tderandrtray.h new file mode 100644 index 000000000..320f0cb1c --- /dev/null +++ b/kcontrol/randr/tderandrtray.h @@ -0,0 +1,94 @@ +/* + * Copyright (c) 2002 Hamish Rodda + * + * 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. + */ + +#ifndef KRANDRTRAY_H +#define KRANDRTRAY_H + +#include + +#include +#include + +#include +#include + +class KHelpMenu; +class KPopupMenu; + +class KRandRSystemTray : public KSystemTray, public KRandrSimpleAPI +{ + Q_OBJECT + +public: + KRandRSystemTray(TQWidget* parent = 0, const char *name = 0); + TDEGlobalAccel *globalKeys; + + virtual void contextMenuAboutToShow(KPopupMenu* menu); + + void configChanged(); + +signals: + void screenSizeChanged(int x, int y); + +protected slots: + void slotScreenActivated(); + void slotResolutionChanged(int parameter); + void slotOrientationChanged(int parameter); + void slotRefreshRateChanged(int parameter); + void slotPrefs(); + void slotDisplayConfig(); + void slotSKeys(); + void slotSettingsChanged(int category); + void slotCycleDisplays(); + void slotOutputChanged(int parameter); + void slotColorProfileChanged(int parameter); + void slotDisplayProfileChanged(int parameter); + +protected: + void mousePressEvent( TQMouseEvent *e ); + void resizeEvent ( TQResizeEvent * ); + +private: + void populateMenu(KPopupMenu* menu); + void addOutputMenu(KPopupMenu* menu); + int GetDefaultResolutionParameter(); + int GetHackResolutionParameter(); + void findPrimaryDisplay(); + void reloadDisplayConfiguration(); + + bool m_popupUp; + KHelpMenu* m_help; + TQPtrList m_screenPopups; + + Display *randr_display; + ScreenInfo *randr_screen_info; + TQWidget* my_parent; + + int last_known_x; + int last_known_y; + + KPopupMenu* m_menu; + KSimpleConfig *r_config; + KSimpleConfig *t_config; + +private slots: + void _quit(); + void deviceChanged (TDEGenericDevice*); +}; + +#endif -- cgit v1.2.1