Added the foundation for the new displayconfig module that will allow full XRandR 1.2 functionality from a Trinity control center GUI
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdebase@1245566 283d02a7-25f6-0310-bc7c-ecb5cbfe19dav3.5.13-sru
parent
35cf72fe7f
commit
486c5bfc26
@ -0,0 +1,39 @@
|
||||
#################################################
|
||||
#
|
||||
# (C) 2010-2011 Serghei Amelian
|
||||
# serghei (DOT) amelian (AT) gmail.com
|
||||
#
|
||||
# Improvements and feedback are welcome
|
||||
#
|
||||
# This file is released under GPL >= 2
|
||||
#
|
||||
#################################################
|
||||
|
||||
include_directories(
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
${CMAKE_BINARY_DIR}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
${TDE_INCLUDE_DIR}
|
||||
${TQT_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
link_directories(
|
||||
${TQT_LIBRARY_DIRS}
|
||||
)
|
||||
|
||||
|
||||
##### other data ################################
|
||||
|
||||
install( FILES displayconfig.desktop DESTINATION ${XDG_APPS_INSTALL_DIR} )
|
||||
|
||||
|
||||
##### kcm_displayconfig (module) ####################
|
||||
|
||||
set_source_files_properties( displayconfig.cpp PROPERTIES COMPILE_FLAGS -DKDE_CONFDIR=\\"${TDE_CONFIG_DIR}\\" )
|
||||
|
||||
tde_add_kpart( kcm_displayconfig AUTOMOC
|
||||
SOURCES
|
||||
monitorworkspace.cpp displayconfig.cpp displayconfigbase.ui displayconfig.skel
|
||||
LINK kio-shared krandr-shared kutils-shared
|
||||
DESTINATION ${PLUGIN_INSTALL_DIR}
|
||||
)
|
@ -0,0 +1,17 @@
|
||||
AM_CPPFLAGS = $(all_includes)
|
||||
kde_module_LTLIBRARIES = kcm_displayconfig.la
|
||||
|
||||
kcm_displayconfig_la_SOURCES = displayconfig.cpp displayconfigbase.ui displayconfig.skel
|
||||
|
||||
kcm_displayconfig_la_LDFLAGS = $(all_libraries) -lkrandr -module -avoid-version -no-undefined
|
||||
|
||||
kcm_displayconfig_la_LIBADD = -lkdeui $(LIB_KIO) $(LIB_XRANDR)
|
||||
|
||||
METASOURCES = AUTO
|
||||
|
||||
noinst_HEADERS = displayconfig.h
|
||||
|
||||
messages: rc.cpp
|
||||
$(XGETTEXT) *.cpp -o $(podir)/kcmdisplayconfig.pot
|
||||
|
||||
xdg_apps_DATA = displayconfig.desktop
|
@ -0,0 +1,7 @@
|
||||
**************** THIS IS NOT YET COMPLETE ****************
|
||||
AS SUCH IT SHOULD REMAIN DISABLED UNTIL IT IS COMPLETE
|
||||
**********************************************************
|
||||
|
||||
NOTES:
|
||||
1.) This loads the monitor settings quite well and even lets the user play with them, but it cannot save. or even apply the settings to hardware yet.
|
||||
2.) Profile support should probably be added. Imagine having multiple display profiles--a portable device could plug into a docking station and be set up in seconds! The same idea applies for presentations, etc.
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,23 @@
|
||||
[Desktop Entry]
|
||||
Exec=kcmshell displayconfig
|
||||
Icon=background
|
||||
Type=Application
|
||||
DocPath=kcontrol/displayconfig/index.html
|
||||
|
||||
X-KDE-Library=displayconfig
|
||||
X-KDE-ParentApp=kcontrol
|
||||
X-KDE-RootOnly=true
|
||||
X-KDE-SubstituteUID=true
|
||||
|
||||
Categories=Qt;KDE;X-KDE-settings-peripherals;
|
||||
Comment=Configure display
|
||||
Comment[en_US]=Configure display
|
||||
DocPath=kcontrol/displayconfig.html
|
||||
GenericName=
|
||||
GenericName[en_US]=
|
||||
Keywords=monitor,resolution,display
|
||||
MimeType=
|
||||
Name=Monitor and Display
|
||||
Name[en_US]=Monitor and Display
|
||||
|
||||
NoDisplay=true
|
@ -0,0 +1,144 @@
|
||||
/**
|
||||
* displayconfig.h
|
||||
*
|
||||
* Copyright (c) 2009-2010 Timothy Pearson <kb9vqf@pearsoncomputing.net>
|
||||
*
|
||||
* 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 _KCM_DisplayCONFIG_H
|
||||
#define _KCM_DisplayCONFIG_H
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <tqptrlist.h>
|
||||
#include <tqslider.h>
|
||||
#include <tqworkspace.h>
|
||||
#include <tqobjectlist.h>
|
||||
#include <tqwidgetlist.h>
|
||||
|
||||
#include <dcopobject.h>
|
||||
|
||||
#include <libkrandr/libkrandr.h>
|
||||
|
||||
#include "monitorworkspace.h"
|
||||
#include "displayconfigbase.h"
|
||||
|
||||
class KConfig;
|
||||
class KPopupMenu;
|
||||
class KListViewItem;
|
||||
|
||||
struct SingleScreenData {
|
||||
TQString screenFriendlyName;
|
||||
bool generic_screen_detected;
|
||||
bool screen_connected;
|
||||
|
||||
TQStringList resolutions;
|
||||
TQStringList refresh_rates;
|
||||
TQStringList color_depths;
|
||||
TQStringList rotations;
|
||||
|
||||
int current_resolution_index;
|
||||
int current_refresh_rate_index;
|
||||
int current_color_depth_index;
|
||||
|
||||
int current_rotation_index;
|
||||
int current_orientation_mask;
|
||||
bool has_x_flip;
|
||||
bool has_y_flip;
|
||||
bool supports_transformations;
|
||||
|
||||
bool is_primary;
|
||||
bool is_extended;
|
||||
int absolute_x_position;
|
||||
int absolute_y_position;
|
||||
int current_x_pixel_count;
|
||||
int current_y_pixel_count;
|
||||
};
|
||||
|
||||
class KDisplayConfig : public KCModule, public DCOPObject
|
||||
{
|
||||
K_DCOP
|
||||
Q_OBJECT
|
||||
|
||||
|
||||
public:
|
||||
//KDisplayConfig(TQWidget *parent = 0L, const char *name = 0L);
|
||||
KDisplayConfig(TQWidget *parent, const char *name, const TQStringList &);
|
||||
virtual ~KDisplayConfig();
|
||||
|
||||
DisplayConfigBase *base;
|
||||
|
||||
void load();
|
||||
void load( bool useDefaults);
|
||||
void save();
|
||||
void defaults();
|
||||
|
||||
int buttons();
|
||||
TQString quickHelp() const;
|
||||
|
||||
k_dcop:
|
||||
|
||||
private:
|
||||
|
||||
KConfig *config;
|
||||
bool _ok;
|
||||
Display *randr_display;
|
||||
ScreenInfo *randr_screen_info;
|
||||
int numberOfProfiles;
|
||||
int numberOfScreens;
|
||||
TQStringList cfgScreenInfo;
|
||||
TQStringList cfgProfiles;
|
||||
void refreshDisplayedInformation ();
|
||||
void updateDisplayedInformation ();
|
||||
TQString extractFileName(TQString displayName, TQString profileName);
|
||||
TQString *displayFileArray;
|
||||
int findProfileIndex(TQString profileName);
|
||||
int findScreenIndex(TQString screenName);
|
||||
TQString m_defaultProfile;
|
||||
KRandrSimpleAPI *m_randrsimple;
|
||||
TQPtrList<SingleScreenData> m_screenInfoArray;
|
||||
int realResolutionSliderValue();
|
||||
void setRealResolutionSliderValue(int index);
|
||||
void addTab( const TQString name, const TQString label );
|
||||
void moveMonitor(DraggableMonitor* monitor, int realx, int realy);
|
||||
bool applyMonitorLayoutRules(void);
|
||||
bool applyMonitorLayoutRules(DraggableMonitor* primary_monitor);
|
||||
void updateDraggableMonitorInformationInternal (int, bool);
|
||||
TQByteArray getEDID(int, TQString);
|
||||
TQString getEDIDMonitorName(int, TQString);
|
||||
|
||||
private slots:
|
||||
void selectProfile (int slotNumber);
|
||||
void selectScreen (int slotNumber);
|
||||
void resolutionSliderChanged(int index);
|
||||
void resolutionSliderTextUpdate(int index);
|
||||
void updateArray (void);
|
||||
void addProfile (void);
|
||||
void renameProfile (void);
|
||||
void deleteProfile (void);
|
||||
void ensurePrimaryMonitorIsAvailable (void);
|
||||
void updateDragDropDisplay (void);
|
||||
void layoutDragDropDisplay (void);
|
||||
void ensureMonitorDataConsistency (void);
|
||||
void updateDraggableMonitorInformation (int);
|
||||
void updateExtendedMonitorInformation (void);
|
||||
void processLockoutControls (void);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -0,0 +1,299 @@
|
||||
<!DOCTYPE UI><UI version="3.0" stdsetdef="1">
|
||||
<class>DisplayConfigBase</class>
|
||||
<widget class="TQWidget">
|
||||
<property name="name">
|
||||
<cstring>DisplayConfigBase</cstring>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>519</width>
|
||||
<height>356</height>
|
||||
</rect>
|
||||
</property>
|
||||
<grid>
|
||||
<property name="name">
|
||||
<cstring>unnamed</cstring>
|
||||
</property>
|
||||
<widget class="TQTabWidget" row="0" column="0">
|
||||
<property name="name">
|
||||
<cstring>mainTabContainerWidget</cstring>
|
||||
</property>
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<widget class="TQWidget">
|
||||
<property name="name">
|
||||
<cstring>globalTab</cstring>
|
||||
</property>
|
||||
<attribute name="title">
|
||||
<string>Global Settings</string>
|
||||
</attribute>
|
||||
<grid>
|
||||
<property name="name">
|
||||
<cstring>unnamed</cstring>
|
||||
</property>
|
||||
<widget class="TQGroupBox" row="0" column="0">
|
||||
<property name="name">
|
||||
<cstring>groupSystemSettings</cstring>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Global</string>
|
||||
</property>
|
||||
<grid>
|
||||
<property name="name">
|
||||
<cstring>unnamed</cstring>
|
||||
</property>
|
||||
<widget class="TQCheckBox" row="0" column="0" colspan="4">
|
||||
<property name="name">
|
||||
<cstring>systemEnableSupport</cstring>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Enable global display control</string>
|
||||
</property>
|
||||
</widget>
|
||||
</grid>
|
||||
</widget>
|
||||
</grid>
|
||||
</widget>
|
||||
<widget class="TQWidget">
|
||||
<property name="name">
|
||||
<cstring>resolutionTab</cstring>
|
||||
</property>
|
||||
<attribute name="title">
|
||||
<string>Resolution and Layout</string>
|
||||
</attribute>
|
||||
<grid>
|
||||
<property name="name">
|
||||
<cstring>unnamed</cstring>
|
||||
</property>
|
||||
<widget class="TQGroupBox" row="1" column="0">
|
||||
<property name="name">
|
||||
<cstring>groupMonitorSettings</cstring>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Monitors</string>
|
||||
</property>
|
||||
<grid>
|
||||
<property name="name">
|
||||
<cstring>unnamed</cstring>
|
||||
</property>
|
||||
<widget class="TQLabel" row="0" column="0" colspan="4">
|
||||
<property name="name">
|
||||
<cstring>textLabel4_3</cstring>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Drag the monitor icons to match the physical arrangement of your monitors.</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="MonitorWorkspace" row="1" column="0" colspan="4">
|
||||
<property name="name">
|
||||
<cstring>monitorPhyArrange</cstring>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy>
|
||||
<hsizetype>7</hsizetype>
|
||||
<vsizetype>1</vsizetype>
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>32767</width>
|
||||
<height>200</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="TQLabel" row="2" column="0" colspan="4">
|
||||
<property name="name">
|
||||
<cstring>textLabel4_4</cstring>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Display:</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="KComboBox" row="3" column="0" colspan="4">
|
||||
<property name="name">
|
||||
<cstring>monitorDisplaySelectDD</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="TQGroupBox" row="4" column="0" colspan="2">
|
||||
<property name="name">
|
||||
<cstring>groupResolution</cstring>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>&Screen resolution</string>
|
||||
</property>
|
||||
<grid>
|
||||
<property name="name">
|
||||
<cstring>unnamed</cstring>
|
||||
</property>
|
||||
<widget class="TQLabel" row="0" column="0">
|
||||
<property name="name">
|
||||
<cstring>textLabel4_5</cstring>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Less</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="TQSlider" row="0" column="1">
|
||||
<property name="name">
|
||||
<cstring>resolutionSlider</cstring>
|
||||
</property>
|
||||
<property name="maxValue">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Horizontal</enum>
|
||||
</property>
|
||||
<property name="tickmarks">
|
||||
<enum>Below</enum>
|
||||
</property>
|
||||
<property name="tickInterval">
|
||||
<number>1</number>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="TQLabel" row="0" column="2">
|
||||
<property name="name">
|
||||
<cstring>textLabel4_6</cstring>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>More</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="TQLabel" row="1" column="1">
|
||||
<property name="name">
|
||||
<cstring>resolutionLabel</cstring>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>unset</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</grid>
|
||||
</widget>
|
||||
<widget class="TQGroupBox" row="4" column="2" colspan="2">
|
||||
<property name="name">
|
||||
<cstring>groupColorDepth</cstring>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>&Refresh rate</string>
|
||||
</property>
|
||||
<grid>
|
||||
<property name="name">
|
||||
<cstring>unnamed</cstring>
|
||||
</property>
|
||||
<widget class="KComboBox" row="0" column="0">
|
||||
<property name="name">
|
||||
<cstring>refreshRateDD</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="TQWidget" row="1" column="0">
|
||||
<property name="name">
|
||||
<cstring>colorBarWidget</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</grid>
|
||||
</widget>
|
||||
<widget class="TQGroupBox" row="5" column="0" colspan="4">
|
||||
<property name="name">
|
||||
<cstring>groupOrientation</cstring>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Screen Transformations</string>
|
||||
</property>
|
||||
<grid>
|
||||
<property name="name">
|
||||
<cstring>unnamed</cstring>
|
||||
</property>
|
||||
<widget class="KComboBox" row="0" column="0" colspan="1">
|
||||
<property name="name">
|
||||
<cstring>rotationSelectDD</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="TQCheckBox" row="0" column="1" colspan="1">
|
||||
<property name="name">
|
||||
<cstring>orientationHFlip</cstring>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Mirror screen horizontally</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="TQCheckBox" row="0" column="2" colspan="1">
|
||||
<property name="name">
|
||||
<cstring>orientationVFlip</cstring>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Mirror screen &vertically</string>
|
||||
</property>
|
||||
</widget>
|
||||
</grid>
|
||||
</widget>
|
||||
<widget class="TQCheckBox" row="6" column="0" colspan="4">
|
||||
<property name="name">
|
||||
<cstring>isPrimaryMonitorCB</cstring>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Use this device as the primary monitor.</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="TQCheckBox" row="7" column="0" colspan="4">
|
||||
<property name="name">
|
||||
<cstring>isExtendedMonitorCB</cstring>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Extend my Trinity desktop onto this monitor.</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="KPushButton" row="8" column="3" colspan="4">
|
||||
<property name="name">
|
||||
<cstring>identifyMonitors</cstring>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Identify</string>
|
||||
</property>
|
||||
</widget>
|
||||
</grid>
|
||||
</widget>
|
||||
<spacer row="4" column="0">
|
||||
<property name="name" stdset="0">
|
||||
<cstring>Spacer4</cstring>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>Expanding</enum>
|
||||
</property>
|
||||
<property name="tqsizeHint">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</grid>
|
||||
</widget>
|
||||
</widget>
|
||||
</grid>
|
||||
</widget>
|
||||
<includes>
|
||||
<include location="local" impldecl="in implementation">DisplayConfigBase.ui.h</include>
|
||||
</includes>
|
||||
<Q_SLOTS>
|
||||
<slot>enableSupport_toggled(bool)</slot>
|
||||
</Q_SLOTS>
|
||||
<includes>
|
||||
<include location="local" impldecl="in implementation">kdialog.h</include>
|
||||
<include location="local" impldecl="in implementation">kcombobox.h</include>
|
||||
<include location="local" impldecl="in implementation">kpushbutton.h</include>
|
||||
<include location="local" impldecl="in implementation">tqworkspace.h</include>
|
||||
<include location="global" impldecl="in implementation">monitorworkspace.h</include>
|
||||
</includes>
|
||||
<layoutdefaults spacing="3" margin="6"/>
|
||||
<layoutfunctions spacing="KDialog::spacingHint" margin="KDialog::marginHint"/>
|
||||
</UI>
|
@ -0,0 +1,151 @@
|
||||
/**
|
||||
* monitorworkspace.cpp
|
||||
*
|
||||
* Copyright (c) 2011 Timothy Pearson <kb9vqf@pearsoncomputing.net>
|
||||
*
|
||||
* 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 <tqcheckbox.h>
|
||||
#include <tqlabel.h>
|
||||
#include <tqlayout.h>
|
||||
#include <tqlineedit.h>
|
||||
#include <tqpushbutton.h>
|
||||
|
||||
#include <unistd.h>
|
||||
#include <string>
|
||||
#include <stdio.h>
|
||||
#include <tqstring.h>
|
||||
|
||||
#include "monitorworkspace.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
/**** Monitor Region ****/
|
||||
|
||||
MonitorRegion::MonitorRegion()
|
||||
{
|
||||
}
|
||||
|
||||
MonitorRegion::MonitorRegion(TQRect rect)
|
||||
{
|
||||
rectangles.resize(1);
|
||||
rectangles[0] = rect;
|
||||
}
|
||||
|
||||
MonitorRegion::MonitorRegion(TQMemArray<TQRect> newrects)
|
||||
{
|
||||
rectangles = newrects;
|
||||
}
|
||||
|
||||
MonitorRegion::~MonitorRegion()
|
||||
{
|
||||
}
|
||||
|
||||
TQMemArray<TQRect> MonitorRegion::rects()
|
||||
{
|
||||
return rectangles;
|
||||
}
|
||||
|
||||
MonitorRegion MonitorRegion::unite(MonitorRegion rect)
|
||||
{
|
||||
int i;
|
||||
int j;
|
||||
TQMemArray<TQRect> newrectangles = rectangles.copy(); // This MUST be a copy, otherwise Bad Things will happen VERY quickly!
|
||||
newrectangles.resize(rectangles.count() + rect.rects().count());
|
||||
j=0;
|
||||
for (i=rectangles.count();i<newrectangles.count();i++) {
|
||||
newrectangles[i] = rect.rects()[j];
|
||||
j++;
|
||||
}
|
||||
MonitorRegion newregion(newrectangles);
|
||||
return newregion;
|
||||
}
|
||||
|
||||
bool MonitorRegion::contains(TQRect rect)
|
||||
{
|
||||
int i;
|
||||
for (i=0;i<rectangles.count();i++) {
|
||||
if (rectangles[i].intersects(rect))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**** Draggable Monitor Widget ****/
|
||||
DraggableMonitor::DraggableMonitor( TQWidget* parent, const char* name, int wflags )
|
||||
: TQLabel( parent, name, wflags )
|
||||
{
|
||||
setAlignment(AlignHCenter | AlignVCenter);
|
||||
setFrameShape(Box);
|
||||
setFrameShadow(Plain);
|
||||
setLineWidth(4);
|
||||
setMidLineWidth(4);
|
||||
}
|
||||
|
||||
DraggableMonitor::~DraggableMonitor()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void DraggableMonitor::mousePressEvent(TQMouseEvent *event)
|
||||
{
|
||||
lastMousePosition = event->pos();
|
||||
emit(monitorSelected(screen_id));
|
||||
}
|
||||
|
||||
void DraggableMonitor::mouseMoveEvent(TQMouseEvent *event)
|
||||
{
|
||||
TQPoint mousePos = event->pos();
|
||||
TQPoint mouseMove = TQPoint(mousePos.x() - lastMousePosition.x(), mousePos.y() - lastMousePosition.y());
|
||||
|
||||
int moveToX = x()+mouseMove.x();
|
||||
int moveToY = y()+mouseMove.y();
|
||||
|
||||
int maxX = parentWidget()->width() - width() - 1;
|
||||
int maxY = parentWidget()->height() - height() - 1;
|
||||
|
||||
if (moveToX < 1) moveToX = 1;
|
||||
if (moveToY < 1) moveToY = 1;
|
||||
if (moveToX > maxX) moveToX = maxX;
|
||||
if (moveToY > maxY) moveToY = maxY;
|
||||
|
||||
move(moveToX, moveToY);
|
||||
}
|
||||
|
||||
void DraggableMonitor::mouseReleaseEvent(TQMouseEvent *event)
|
||||
{
|
||||
emit(monitorDragComplete(screen_id));
|
||||
}
|
||||
|
||||
/**** Draggable Monitor Container ****/
|
||||
MonitorWorkspace::MonitorWorkspace( TQWidget* parent, const char* name )
|
||||
: TQWorkspace( parent, name )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
MonitorWorkspace::~MonitorWorkspace()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void MonitorWorkspace::resizeEvent( TQResizeEvent* re )
|
||||
{
|
||||
TQWorkspace::resizeEvent(re);
|
||||
emit(workspaceRelayoutNeeded());
|
||||
}
|
||||
|
||||
#include "monitorworkspace.moc"
|
@ -0,0 +1,96 @@
|
||||
/**
|
||||
* monitorworkspace.h
|
||||
*
|
||||
* Copyright (c) 2011 Timothy Pearson <kb9vqf@pearsoncomputing.net>
|
||||
*
|
||||
* 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 MONITORWORKSPACE_H
|
||||
#define MONITORWORKSPACE_H
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <tqlabel.h>
|
||||
#include <tqptrlist.h>
|
||||
#include <tqslider.h>
|
||||
#include <tqworkspace.h>
|
||||
#include <tqobjectlist.h>
|
||||
#include <tqwidgetlist.h>
|
||||
|
||||
class MonitorRegion: public TQt
|
||||
{
|
||||
public:
|
||||
MonitorRegion();
|
||||
MonitorRegion(TQRect rect);
|
||||
MonitorRegion(TQMemArray<TQRect> newrects);
|
||||
~MonitorRegion();
|
||||
|
||||
TQMemArray<TQRect> rects();
|
||||
MonitorRegion unite(MonitorRegion region);
|
||||
bool contains(TQRect);
|
||||
|
||||
private:
|
||||
TQMemArray<TQRect> rectangles;
|
||||
};
|
||||
|
||||
class DraggableMonitor: public TQLabel
|
||||
{
|
||||
Q_OBJECT
|
||||
TQ_OBJECT
|
||||
public:
|
||||
DraggableMonitor( TQWidget* parent, const char* name, int wflags );
|
||||
~DraggableMonitor();
|
||||
|
||||
protected:
|
||||
// void closeEvent( TQCloseEvent * );
|
||||
void mousePressEvent(TQMouseEvent *event);
|
||||
void mouseReleaseEvent(TQMouseEvent *event);
|
||||
void mouseMoveEvent(TQMouseEvent *event);
|
||||
|
||||
signals:
|
||||
void workspaceRelayoutNeeded();
|
||||
void monitorDragComplete(int);
|
||||
void monitorSelected(int);
|
||||
|
||||
public:
|
||||
int screen_id;
|
||||
|
||||
private:
|
||||
TQPoint lastMousePosition;
|
||||
};
|
||||
|
||||
class MonitorWorkspace : public TQWorkspace
|
||||
{
|
||||
Q_OBJECT
|
||||
TQ_OBJECT
|
||||
public:
|
||||
MonitorWorkspace( TQWidget* parent, const char* name );
|
||||
~MonitorWorkspace();
|
||||
|
||||
protected:
|
||||
virtual void resizeEvent( TQResizeEvent* re );
|
||||
|
||||
signals:
|
||||
void workspaceRelayoutNeeded();
|
||||
|
||||
public:
|
||||
float resize_factor;
|
||||
};
|
||||
|
||||
#endif // MONITORWORKSPACE_H
|
||||
|
Loading…
Reference in new issue