diff --git a/gui/HostConnector.cpp b/gui/HostConnector.cpp index 7854698e..7d6897f0 100644 --- a/gui/HostConnector.cpp +++ b/gui/HostConnector.cpp @@ -1,232 +1,232 @@ /* KSysGuard, the KDE System Guard Copyright (c) 1999, 2000 Chris Schlaeger 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) version 3 or any later version accepted by the membership of KDE e.V. (or its successor approved by the membership of KDE e.V.), which shall act as a proxy defined in Section 14 of version 3 of the license. 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, see . */ #include #include #include #include #include #include #include #include #include #include #include #include #include "HostConnector.h" HostConnector::HostConnector(QWidget *parent, const QString &name ) : QDialog( parent ) { setObjectName( name ); setModal( true ); setWindowTitle( i18n( "Connect Host" ) ); QFrame *page = new QFrame( this ); QVBoxLayout *vlayout = new QVBoxLayout(this); mButtonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel | QDialogButtonBox::Help, this); vlayout->addWidget(page); vlayout->addWidget(mButtonBox); setLayout(vlayout); QGridLayout *layout = new QGridLayout( page ); - layout->setMargin( 0 ); + layout->setContentsMargins( 0, 0, 0, 0 ); layout->setColumnStretch( 1, 1 ); QLabel *label = new QLabel( i18n( "Host:" ), page ); layout->addWidget( label, 0, 0 ); mHostNames = new KComboBox( true, page ); mHostNames->setMaxCount( 20 ); mHostNames->setInsertPolicy( QComboBox::InsertAtTop ); mHostNames->setAutoCompletion( true ); mHostNames->setDuplicatesEnabled( false ); layout->addWidget( mHostNames, 0, 1 ); label->setBuddy( mHostNames ); mHostNames->setWhatsThis( i18n( "Enter the name of the host you want to connect to." ) ); mHostNameLabel = new QLabel( page ); mHostNameLabel->hide(); layout->addWidget( mHostNameLabel, 0, 1 ); QGroupBox *group = new QGroupBox(i18n( "Connection Type" ), page ); QGridLayout *groupLayout = new QGridLayout(); group->setLayout(groupLayout); groupLayout->setAlignment( Qt::AlignTop ); mUseSsh = new QRadioButton( i18n( "ssh" )); mUseSsh->setEnabled( true ); mUseSsh->setChecked( true ); mUseSsh->setWhatsThis( i18n( "Select this to use the secure shell to login to the remote host." ) ); groupLayout->addWidget( mUseSsh, 0, 0 ); mUseRsh = new QRadioButton( i18n( "rsh" )); mUseRsh->setWhatsThis( i18n( "Select this to use the remote shell to login to the remote host." ) ); groupLayout->addWidget( mUseRsh, 0, 1 ); mUseDaemon = new QRadioButton( i18n( "Daemon" )); mUseDaemon->setWhatsThis( i18n( "Select this if you want to connect to a ksysguard daemon that is running on the machine you want to connect to, and is listening for client requests." ) ); groupLayout->addWidget( mUseDaemon, 0, 2 ); mUseCustom = new QRadioButton( i18n( "Custom command" )); mUseCustom->setWhatsThis( i18n( "Select this to use the command you entered below to start ksysguardd on the remote host." ) ); groupLayout->addWidget( mUseCustom, 0, 3 ); label = new QLabel( i18n( "Port:" )); groupLayout->addWidget( label, 1, 0 ); mPort = new QSpinBox(); mPort->setRange( 1, 65535 ); mPort->setEnabled( false ); mPort->setValue( 3112 ); mPort->setToolTip( i18n( "Enter the port number on which the ksysguard daemon is listening for connections." ) ); groupLayout->addWidget( mPort, 1, 2 ); label = new QLabel( i18n( "e.g. 3112" )); groupLayout->addWidget( label, 1, 3 ); label = new QLabel( i18n( "Command:" ) ); groupLayout->addWidget( label, 2, 0 ); mCommands = new KComboBox( true ); mCommands->setEnabled( false ); mCommands->setMaxCount( 20 ); mCommands->setInsertPolicy( QComboBox::InsertAtTop ); mCommands->setAutoCompletion( true ); mCommands->setDuplicatesEnabled( false ); mCommands->setWhatsThis( i18n( "Enter the command that runs ksysguardd on the host you want to monitor." ) ); groupLayout->addWidget( mCommands, 2, 2, 1, 2 ); label->setBuddy( mCommands ); label = new QLabel( i18n( "e.g. ssh -l root remote.host.org ksysguardd" ) ); groupLayout->addWidget( label, 3, 2, 1, 2 ); layout->addWidget( group, 1, 0, 1, 2 ); connect(mButtonBox, &QDialogButtonBox::accepted, this, &QDialog::accept); connect(mButtonBox, &QDialogButtonBox::rejected, this, &QDialog::reject); connect(mButtonBox, &QDialogButtonBox::helpRequested, this, &HostConnector::slotHelp); connect(mUseCustom, &QRadioButton::toggled, mCommands, &KComboBox::setEnabled); connect(mUseDaemon, &QRadioButton::toggled, mPort, &QSpinBox::setEnabled); connect( mHostNames->lineEdit(), &QLineEdit::textChanged, this, &HostConnector::slotHostNameChanged ); mButtonBox->button(QDialogButtonBox::Ok)->setEnabled( !mHostNames->lineEdit()->text().isEmpty() ); KAcceleratorManager::manage( this ); } HostConnector::~HostConnector() { } void HostConnector::slotHostNameChanged( const QString &_text ) { mButtonBox->button(QDialogButtonBox::Ok)->setEnabled( !_text.isEmpty() ); } void HostConnector::setHostNames( const QStringList &list ) { mHostNames->addItems( list ); } QStringList HostConnector::hostNames() const { QStringList list; for ( int i = 0; i < mHostNames->count(); ++i ) list.append( mHostNames->itemText( i ) ); return list; } void HostConnector::setCommands( const QStringList &list ) { mCommands->addItems( list ); } QStringList HostConnector::commands() const { QStringList list; for ( int i = 0; i < mCommands->count(); ++i ) list.append( mCommands->itemText( i ) ); return list; } void HostConnector::setCurrentHostName( const QString &hostName ) { if ( !hostName.isEmpty() ) { mHostNames->hide(); mHostNameLabel->setText( hostName ); mHostNameLabel->show(); mButtonBox->button(QDialogButtonBox::Ok)->setEnabled( true );//enable true when mHostNames is empty and hidden fix #66955 } else { mHostNameLabel->hide(); mHostNames->show(); mHostNames->setFocus(); } } QString HostConnector::currentHostName() const { return mHostNames->currentText(); } QString HostConnector::currentCommand() const { return mCommands->currentText(); } int HostConnector::port() const { return mPort->value(); } bool HostConnector::useSsh() const { return mUseSsh->isChecked(); } bool HostConnector::useRsh() const { return mUseRsh->isChecked(); } bool HostConnector::useDaemon() const { return mUseDaemon->isChecked(); } bool HostConnector::useCustom() const { return mUseCustom->isChecked(); } void HostConnector::slotHelp() { KHelpClient::invokeHelp( QStringLiteral("connectingtootherhosts"), QStringLiteral("ksysguard") ); } diff --git a/gui/SensorDisplayLib/DancingBarsSettings.cpp b/gui/SensorDisplayLib/DancingBarsSettings.cpp index 009e5673..8a78e5ba 100644 --- a/gui/SensorDisplayLib/DancingBarsSettings.cpp +++ b/gui/SensorDisplayLib/DancingBarsSettings.cpp @@ -1,405 +1,405 @@ /* KSysGuard, the KDE System Guard Copyright (c) 2003 Tobias Koenig 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 "DancingBarsSettings.h" DancingBarsSettings::DancingBarsSettings(QWidget* parent, const QString &name ) : KPageDialog( parent ), mModel( new SensorModel( this ) ) { setFaceType( Tabbed ); setWindowTitle( i18n( "Edit BarGraph Preferences" ) ); setStandardButtons(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); setObjectName( name ); setModal( false ); mModel->setHasLabel( true ); // Range page QFrame *page = new QFrame( this ); addPage( page, i18n( "Range" ) ); QGridLayout *pageLayout = new QGridLayout( page ); - pageLayout->setMargin( 0 ); + pageLayout->setContentsMargins( 0, 0, 0, 0 ); QGroupBox *groupBox = new QGroupBox( i18n( "Title" ), page ); QGridLayout *boxLayout = new QGridLayout; groupBox->setLayout( boxLayout ); mTitle = new QLineEdit( groupBox ); mTitle->setWhatsThis( i18n( "Enter the title of the display here." ) ); boxLayout->addWidget( mTitle, 0, 0 ); pageLayout->addWidget( groupBox, 0, 0 ); groupBox = new QGroupBox( i18n( "Display Range" ), page ); boxLayout = new QGridLayout; groupBox->setLayout( boxLayout ); boxLayout->setColumnStretch( 2, 1 ); QLabel *label = new QLabel( i18n( "Minimum value:" ), groupBox ); boxLayout->addWidget( label, 0, 0 ); mMinValue = new QDoubleSpinBox(groupBox); mMinValue->setRange(0, 10000); mMinValue->setSingleStep(0.5); mMinValue->setValue(0); mMinValue->setDecimals(2); mMinValue->setWhatsThis( i18n( "Enter the minimum value for the display here. If both values are 0, automatic range detection is enabled." ) ); boxLayout->addWidget( mMinValue, 0, 1 ); label->setBuddy( mMinValue ); label = new QLabel( i18n( "Maximum value:" ), groupBox ); boxLayout->addWidget( label, 0, 3 ); mMaxValue = new QDoubleSpinBox( groupBox); mMaxValue->setRange(0, 100); mMaxValue->setSingleStep(0.5); mMaxValue->setValue(100); mMaxValue->setDecimals(2); mMaxValue->setWhatsThis( i18n( "Enter the maximum value for the display here. If both values are 0, automatic range detection is enabled." ) ); boxLayout->addWidget( mMaxValue, 0, 4 ); label->setBuddy( mMaxValue ); pageLayout->addWidget( groupBox, 1, 0 ); pageLayout->setRowStretch( 2, 1 ); // Alarm page page = new QFrame( this ); addPage( page, i18n( "Alarms" ) ); pageLayout = new QGridLayout( page ); - pageLayout->setMargin( 0 ); + pageLayout->setContentsMargins( 0, 0, 0, 0 ); groupBox = new QGroupBox( i18n( "Alarm for Minimum Value" ), page ); boxLayout = new QGridLayout; groupBox->setLayout( boxLayout ); boxLayout->setColumnStretch( 1, 1 ); mUseLowerLimit = new QCheckBox( i18n( "Enable alarm" ), groupBox ); mUseLowerLimit->setWhatsThis( i18n( "Enable the minimum value alarm." ) ); boxLayout->addWidget( mUseLowerLimit, 0, 0 ); label = new QLabel( i18n( "Lower limit:" ), groupBox ); boxLayout->addWidget( label, 0, 2 ); mLowerLimit = new QDoubleSpinBox(groupBox); mLowerLimit->setRange(0, 100); mLowerLimit->setSingleStep(0.5); mLowerLimit->setValue(0); mLowerLimit->setDecimals(2); mLowerLimit->setEnabled( false ); boxLayout->addWidget( mLowerLimit, 0, 3 ); label->setBuddy( mLowerLimit ); pageLayout->addWidget( groupBox, 0, 0 ); groupBox = new QGroupBox( i18n( "Alarm for Maximum Value" ), page ); boxLayout = new QGridLayout; groupBox->setLayout( boxLayout ); boxLayout->setColumnStretch( 1, 1 ); mUseUpperLimit = new QCheckBox( i18n( "Enable alarm" ), groupBox ); mUseUpperLimit->setWhatsThis( i18n( "Enable the maximum value alarm." ) ); boxLayout->addWidget( mUseUpperLimit, 0, 0 ); label = new QLabel( i18n( "Upper limit:" ), groupBox ); boxLayout->addWidget( label, 0, 2 ); mUpperLimit = new QDoubleSpinBox( groupBox); mUpperLimit->setRange(0, 1000); mUpperLimit->setSingleStep(0.5); mUpperLimit->setDecimals(2); mUpperLimit->setEnabled( false ); boxLayout->addWidget( mUpperLimit, 0, 3 ); label->setBuddy( mUpperLimit ); pageLayout->addWidget( groupBox, 1, 0 ); pageLayout->setRowStretch( 2, 1 ); // Look page page = new QFrame( this ); addPage( page, i18nc( "@title:tab Appearance of the bar graph", "Look" ) ); pageLayout = new QGridLayout( page ); - pageLayout->setMargin( 0 ); + pageLayout->setContentsMargins( 0, 0, 0, 0 ); label = new QLabel( i18n( "Normal bar color:" ), page ); pageLayout->addWidget( label, 0, 0 ); mForegroundColor = new KColorButton( page ); pageLayout->addWidget( mForegroundColor, 0, 1 ); label->setBuddy( mForegroundColor ); label = new QLabel( i18n( "Out-of-range color:" ), page ); pageLayout->addWidget( label, 1, 0 ); mAlarmColor = new KColorButton( page ); pageLayout->addWidget( mAlarmColor, 1, 1 ); label->setBuddy( mAlarmColor ); label = new QLabel( i18n( "Background color:" ), page ); pageLayout->addWidget( label, 2, 0 ); mBackgroundColor = new KColorButton( page ); pageLayout->addWidget( mBackgroundColor, 2, 1 ); label->setBuddy( mBackgroundColor ); label = new QLabel( i18n( "Font size:" ), page ); pageLayout->addWidget( label, 3, 0 ); mFontSize = new QSpinBox( page ); mFontSize->setValue( 9 ); mFontSize->setWhatsThis( i18n( "This determines the size of the font used to print a label underneath the bars. Bars are automatically suppressed if text becomes too large, so it is advisable to use a small font size here." ) ); pageLayout->addWidget( mFontSize, 3, 1 ); label->setBuddy( mFontSize ); pageLayout->setRowStretch( 4, 1 ); // Sensor page page = new QFrame( this ); addPage( page, i18n( "Sensors" ) ); pageLayout = new QGridLayout( page ); - pageLayout->setMargin( 0 ); + pageLayout->setContentsMargins( 0, 0, 0, 0 ); pageLayout->setRowStretch( 2, 1 ); mView = new QTreeView( page ); mView->header()->setStretchLastSection( true ); mView->setRootIsDecorated( false ); mView->setItemsExpandable( false ); mView->setModel( mModel ); pageLayout->addWidget( mView, 0, 0, 3, 1); mEditButton = new QPushButton( i18n( "Edit..." ), page ); mEditButton->setWhatsThis( i18n( "Push this button to configure the label." ) ); pageLayout->addWidget( mEditButton, 0, 1 ); mRemoveButton = new QPushButton( i18n( "Delete" ), page ); mRemoveButton->setWhatsThis( i18n( "Push this button to delete the sensor." ) ); pageLayout->addWidget( mRemoveButton, 1, 1 ); connect(mUseLowerLimit, &QCheckBox::toggled, mLowerLimit, &QDoubleSpinBox::setEnabled); connect(mUseUpperLimit, &QCheckBox::toggled, mUpperLimit, &QDoubleSpinBox::setEnabled); connect(mEditButton, &QPushButton::clicked, this, &DancingBarsSettings::editSensor); connect(mRemoveButton, &QPushButton::clicked, this, &DancingBarsSettings::removeSensor); KAcceleratorManager::manage( this ); mTitle->setFocus(); } DancingBarsSettings::~DancingBarsSettings() { } void DancingBarsSettings::setTitle( const QString& title ) { mTitle->setText( title ); } QString DancingBarsSettings::title() const { return mTitle->text(); } void DancingBarsSettings::setMinValue( double min ) { mMinValue->setValue( min ); } double DancingBarsSettings::minValue() const { return mMinValue->value(); } void DancingBarsSettings::setMaxValue( double max ) { mMaxValue->setValue( max ); } double DancingBarsSettings::maxValue() const { return mMaxValue->value(); } void DancingBarsSettings::setUseLowerLimit( bool value ) { mUseLowerLimit->setChecked( value ); } bool DancingBarsSettings::useLowerLimit() const { return mUseLowerLimit->isChecked(); } void DancingBarsSettings::setLowerLimit( double limit ) { mLowerLimit->setValue( limit ); } double DancingBarsSettings::lowerLimit() const { return mLowerLimit->value(); } void DancingBarsSettings::setUseUpperLimit( bool value ) { mUseUpperLimit->setChecked( value ); } bool DancingBarsSettings::useUpperLimit() const { return mUseUpperLimit->isChecked(); } void DancingBarsSettings::setUpperLimit( double limit ) { mUpperLimit->setValue( limit ); } double DancingBarsSettings::upperLimit() const { return mUpperLimit->value(); } void DancingBarsSettings::setForegroundColor( const QColor &color ) { mForegroundColor->setColor( color ); } QColor DancingBarsSettings::foregroundColor() const { return mForegroundColor->color(); } void DancingBarsSettings::setAlarmColor( const QColor &color ) { mAlarmColor->setColor( color ); } QColor DancingBarsSettings::alarmColor() const { return mAlarmColor->color(); } void DancingBarsSettings::setBackgroundColor( const QColor &color ) { mBackgroundColor->setColor( color ); } QColor DancingBarsSettings::backgroundColor() const { return mBackgroundColor->color(); } void DancingBarsSettings::setFontSize( int size ) { mFontSize->setValue( size ); } int DancingBarsSettings::fontSize() const { return mFontSize->value(); } void DancingBarsSettings::setSensors( const SensorModelEntry::List &list ) { mModel->setSensors( list ); mView->selectionModel()->setCurrentIndex( mModel->index( 0, 0 ), QItemSelectionModel::SelectCurrent | QItemSelectionModel::Rows ); } SensorModelEntry::List DancingBarsSettings::sensors() const { return mModel->sensors(); } void DancingBarsSettings::editSensor() { if ( !mView->selectionModel() ) return; const QModelIndex index = mView->selectionModel()->currentIndex(); if ( !index.isValid() ) return; SensorModelEntry sensor = mModel->sensor( index ); bool ok; const QString name = QInputDialog::getText( this, i18n( "Label of Bar Graph" ), i18n( "Enter new label:" ), QLineEdit::Normal, sensor.label(), &ok); if ( ok ) { sensor.setLabel( name ); mModel->setSensor( sensor, index ); } } void DancingBarsSettings::removeSensor() { if ( !mView->selectionModel() ) return; const QModelIndex index = mView->selectionModel()->currentIndex(); if ( !index.isValid() ) return; deletedIds.append(index.row()); mModel->removeSensor( index ); } /* * returns a list of IDs, which have to removed from the sensors list, * perform this in the same order as the IDs are stored in this list, * otherwise you have to consider, that the IDs are changing each time you removeSensor is called * * example: * Sensor indexes: [0,1,2,3,4] * * deletedIds can be create like this: * [0] --> user has deleted row 0 --> [1,2,3,4] * [0,1] --> user has deleted row 1 --> [1,3,4] * [0,1,1] --> user has deleted row 1 --> [1,4] * * using the deletedIds list by a simple iteration through the list * [1,2,3,4] --> removed pos 0 * [1,3,4] --> removed pos 1 * [1,4] --> removed pos 1 * */ QList DancingBarsSettings::getDeletedIds() { return deletedIds; } diff --git a/gui/SensorDisplayLib/FancyPlotterSettings.cpp b/gui/SensorDisplayLib/FancyPlotterSettings.cpp index 9dac3167..4bf13ec6 100644 --- a/gui/SensorDisplayLib/FancyPlotterSettings.cpp +++ b/gui/SensorDisplayLib/FancyPlotterSettings.cpp @@ -1,503 +1,503 @@ /* KSysGuard, the KDE System Guard Copyright (c) 2003 Tobias Koenig 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 "FancyPlotterSettings.h" FancyPlotterSettings::FancyPlotterSettings( QWidget* parent, bool locked ) : KPageDialog( parent ), mModel( new SensorModel( this ) ) { setFaceType( Tabbed ); setWindowTitle( i18n( "Plotter Settings" ) ); setStandardButtons(QDialogButtonBox::Ok | QDialogButtonBox::Apply | QDialogButtonBox::Cancel); setObjectName( QStringLiteral("FancyPlotterSettings") ); setModal( false ); connect(buttonBox()->button(QDialogButtonBox::Ok), &QAbstractButton::clicked, this, &FancyPlotterSettings::okClicked); connect(buttonBox()->button(QDialogButtonBox::Apply), &QAbstractButton::clicked, this, &FancyPlotterSettings::applyClicked); QFrame *page = nullptr; QGridLayout *pageLayout = nullptr; QGridLayout *boxLayout = nullptr; QGroupBox *groupBox = nullptr; QLabel *label = nullptr; // Style page page = new QFrame(); addPage( page, i18n( "General" ) ); pageLayout = new QGridLayout( page ); - pageLayout->setMargin( 0 ); + pageLayout->setContentsMargins( 0, 0, 0, 0 ); label = new QLabel( i18n( "Title:" ), page ); pageLayout->addWidget( label, 0, 0 ); mTitle = new QLineEdit( page ); mTitle->setWhatsThis( i18n( "Enter the title of the display here." ) ); pageLayout->addWidget( mTitle, 0, 1 ); label->setBuddy( mTitle ); mStackBeams = new QCheckBox( i18n("Stack the beams on top of each other"), page); mStackBeams->setWhatsThis( i18n("The beams are stacked on top of each other, and the area is drawn filled in. So if one beam has a value of 2 and another beam has a value of 3, the first beam will be drawn at value 2 and the other beam drawn at 2+3=5.") ); pageLayout->addWidget( mStackBeams, 1, 0,1,2); pageLayout->setRowStretch( 2, 1 ); // Scales page page = new QFrame(); addPage( page, i18n( "Scales" ) ); pageLayout = new QGridLayout( page ); - pageLayout->setMargin( 0 ); + pageLayout->setContentsMargins( 0, 0, 0, 0 ); groupBox = new QGroupBox( i18n( "Vertical scale" ), page ); boxLayout = new QGridLayout; groupBox->setLayout( boxLayout ); boxLayout->setColumnStretch( 2, 1 ); mManualRange = new QCheckBox( i18n( "Specify graph range:" ), groupBox ); mManualRange->setWhatsThis( i18n( "Check this box if you want the display range to adapt dynamically to the currently displayed values; if you do not check this, you have to specify the range you want in the fields below." ) ); mManualRange->setChecked(true); boxLayout->addWidget( mManualRange, 0, 0, 1, 5 ); mMinValueLabel = new QLabel( i18n( "Minimum value:" ), groupBox ); boxLayout->addWidget( mMinValueLabel, 1, 0 ); mMinValue = new QDoubleSpinBox( groupBox ); mMinValue->setMaximum( std::numeric_limits::max()); mMinValue->setMinimum( std::numeric_limits::min()); mMinValue->setWhatsThis( i18n( "Enter the minimum value for the display here." ) ); mMinValue->setSingleStep(10); boxLayout->addWidget( mMinValue, 1, 1 ); mMinValueLabel->setBuddy( mMinValue ); mMaxValueLabel = new QLabel( i18n( "Maximum value:" ), groupBox ); boxLayout->addWidget( mMaxValueLabel, 1, 3 ); mMaxValue = new QDoubleSpinBox( groupBox); mMaxValue->setMaximum( std::numeric_limits::max()); mMaxValue->setMinimum( std::numeric_limits::min()); mMaxValue->setWhatsThis( i18n( "Enter the soft maximum value for the display here. The upper range will not be reduced below this value, but will still go above this number for values above this value." ) ); mMaxValue->setSingleStep(10); boxLayout->addWidget( mMaxValue, 1, 4 ); mMaxValueLabel->setBuddy( mMaxValue ); pageLayout->addWidget( groupBox, 0, 0 ); groupBox = new QGroupBox( i18n( "Horizontal scale" ), page ); QFormLayout *formLayout = new QFormLayout(groupBox); mHorizontalScale = new QSpinBox( groupBox ); mHorizontalScale->setValue( 1 ); mHorizontalScale->setMinimum( 1 ); mHorizontalScale->setMaximum( 50 ); formLayout->addRow( i18n("Pixels per time period:"), mHorizontalScale ); pageLayout->addWidget( groupBox, 1, 0 ); // Grid page page = new QFrame( ); addPage( page, i18n( "Grid" ) ); pageLayout = new QGridLayout( page ); - pageLayout->setMargin( 0 ); + pageLayout->setContentsMargins( 0, 0, 0, 0 ); groupBox = new QGroupBox( i18n( "Lines" ), page ); boxLayout = new QGridLayout; groupBox->setLayout( boxLayout ); boxLayout->setColumnStretch( 1, 1 ); mShowVerticalLines = new QCheckBox( i18n( "Vertical lines" ), groupBox ); mShowVerticalLines->setWhatsThis( i18n( "Check this to activate the vertical lines if display is large enough." ) ); boxLayout->addWidget( mShowVerticalLines, 0, 0 ); label = new QLabel( i18n( "Distance:" ), groupBox ); boxLayout->addWidget( label, 0, 2 ); mVerticalLinesDistance = new QSpinBox( groupBox ); mVerticalLinesDistance->setValue( 0 ); mVerticalLinesDistance->setMinimum( 10 ); mVerticalLinesDistance->setMaximum( 120 ); mVerticalLinesDistance->setWhatsThis( i18n( "Enter the distance between two vertical lines here." ) ); boxLayout->addWidget( mVerticalLinesDistance , 0, 3 ); label->setBuddy( mVerticalLinesDistance ); mVerticalLinesScroll = new QCheckBox( i18n( "Vertical lines scroll" ), groupBox ); boxLayout->addWidget( mVerticalLinesScroll, 1, 0, 1, -1 ); mShowHorizontalLines = new QCheckBox( i18n( "Horizontal lines" ), groupBox ); mShowHorizontalLines->setWhatsThis( i18n( "Check this to enable horizontal lines if display is large enough." ) ); boxLayout->addWidget( mShowHorizontalLines, 2, 0, 1, -1 ); pageLayout->addWidget( groupBox, 0, 0, 1, 2 ); groupBox = new QGroupBox( i18n( "Text" ), page ); boxLayout = new QGridLayout; groupBox->setLayout( boxLayout ); boxLayout->setColumnStretch( 1, 1 ); mShowAxis = new QCheckBox( i18n( "Show axis labels" ), groupBox ); mShowAxis->setWhatsThis( i18n( "Check this box if horizontal lines should be decorated with the values they mark." ) ); boxLayout->addWidget( mShowAxis, 0, 0, 1, -1 ); label = new QLabel( i18n( "Font size:" ), groupBox ); boxLayout->addWidget( label, 1, 0 ); mFontSize = new QSpinBox( groupBox ); mFontSize->setValue( 8 ); mFontSize->setMinimum( 1 ); mFontSize->setMaximum( 1000 ); boxLayout->addWidget( mFontSize, 1, 1 ); label->setBuddy( mFontSize ); pageLayout->addWidget( groupBox, 1, 0 ); pageLayout->setRowStretch( 2, 1 ); // Sensors page page = new QFrame( ); addPage( page, i18n( "Sensors" ) ); pageLayout = new QGridLayout( page ); - pageLayout->setMargin( 0 ); + pageLayout->setContentsMargins( 0, 0, 0, 0 ); pageLayout->setRowStretch( 2, 1 ); pageLayout->setRowStretch( 5, 1 ); mView = new QTreeView( page ); mView->header()->setStretchLastSection( false ); mView->setRootIsDecorated( false ); mView->setItemsExpandable( false ); mView->setModel( mModel ); mView->header()->setSectionResizeMode(QHeaderView::ResizeToContents); bool hideFirstColumn = true; for(int i = 0; i < mModel->rowCount(); i++) if(mModel->data(mModel->index(i, 0)) != QLatin1String("localhost")) { hideFirstColumn = false; break; } if(hideFirstColumn) mView->hideColumn(0); pageLayout->addWidget( mView, 0, 0, 6, 1 ); connect(mView, &QTreeView::doubleClicked, this, &FancyPlotterSettings::editSensor); mEditButton = new QPushButton( i18n( "Set Color..." ), page ); mEditButton->setWhatsThis( i18n( "Push this button to configure the color of the sensor in the diagram." ) ); pageLayout->addWidget( mEditButton, 0, 1 ); mRemoveButton = nullptr; mMoveUpButton = nullptr; mMoveDownButton = nullptr; if ( !locked ) { mRemoveButton = new QPushButton( i18n( "Delete" ), page ); mRemoveButton->setWhatsThis( i18n( "Push this button to delete the sensor." ) ); pageLayout->addWidget( mRemoveButton, 1, 1 ); connect(mRemoveButton, &QPushButton::clicked, this, &FancyPlotterSettings::removeSensor); mMoveUpButton = new QPushButton( i18n( "Move Up" ), page ); mMoveUpButton->setEnabled( false ); pageLayout->addWidget( mMoveUpButton, 2, 1 ); connect(mMoveUpButton, &QPushButton::clicked, this, &FancyPlotterSettings::moveUpSensor); mMoveDownButton = new QPushButton( i18n( "Move Down" ), page ); mMoveDownButton->setEnabled( false ); pageLayout->addWidget( mMoveDownButton, 3, 1 ); connect(mMoveDownButton, &QPushButton::clicked, this, &FancyPlotterSettings::moveDownSensor); connect(mView->selectionModel(), &QItemSelectionModel::currentRowChanged, this, &FancyPlotterSettings::selectionChanged); } connect(mManualRange, &QCheckBox::toggled, mMinValue, &QDoubleSpinBox::setEnabled); connect(mManualRange, &QCheckBox::toggled, mMaxValue, &QDoubleSpinBox::setEnabled); connect(mManualRange, &QCheckBox::toggled, mMinValueLabel, &QLabel::setEnabled); connect(mManualRange, &QCheckBox::toggled, mMaxValueLabel, &QLabel::setEnabled); connect(mShowVerticalLines, &QCheckBox::toggled, mVerticalLinesDistance, &QSpinBox::setEnabled); connect(mShowVerticalLines, &QCheckBox::toggled, mVerticalLinesScroll, &QCheckBox::setEnabled); connect(mEditButton, &QPushButton::clicked, this, &FancyPlotterSettings::editSensor); KAcceleratorManager::manage( this ); } FancyPlotterSettings::~FancyPlotterSettings() { } void FancyPlotterSettings::setStackBeams( bool stack ) { mStackBeams->setChecked(stack); } bool FancyPlotterSettings::stackBeams() const { return mStackBeams->isChecked(); } void FancyPlotterSettings::moveUpSensor() { mModel->moveUpSensor(mView->selectionModel()->currentIndex()); selectionChanged(mView->selectionModel()->currentIndex()); } void FancyPlotterSettings::moveDownSensor() { mModel->moveDownSensor(mView->selectionModel()->currentIndex()); selectionChanged(mView->selectionModel()->currentIndex()); } void FancyPlotterSettings::selectionChanged(const QModelIndex &newCurrent) { mMoveUpButton->setEnabled(newCurrent.isValid() && newCurrent.row() > 0); mMoveDownButton->setEnabled(newCurrent.isValid() && newCurrent.row() < mModel->rowCount() -1 ); mEditButton->setEnabled(newCurrent.isValid()); mRemoveButton->setEnabled(newCurrent.isValid()); } void FancyPlotterSettings::setTitle( const QString &title ) { mTitle->setText( title ); } QString FancyPlotterSettings::title() const { return mTitle->text(); } void FancyPlotterSettings::setRangeUnits( const QString & units ) { mMinValue->setSuffix(QLatin1Char(' ') + units); mMaxValue->setSuffix(QLatin1Char(' ') + units); } void FancyPlotterSettings::setUseManualRange( bool value ) { mManualRange->setChecked( value ); } bool FancyPlotterSettings::useManualRange() const { return mManualRange->isChecked(); } void FancyPlotterSettings::setMinValue( double min ) { mMinValue->setValue( min ); } double FancyPlotterSettings::minValue() const { return mMinValue->value(); } void FancyPlotterSettings::setMaxValue( double max ) { mMaxValue->setValue( max ); } void FancyPlotterSettings::setHasIntegerRange( bool hasIntegerRange ) { mMaxValue->setDecimals( hasIntegerRange?0:2 ); mMinValue->setDecimals( hasIntegerRange?0:2 ); } double FancyPlotterSettings::maxValue() const { return mMaxValue->value(); } void FancyPlotterSettings::setHorizontalScale( int scale ) { mHorizontalScale->setValue( scale ); } int FancyPlotterSettings::horizontalScale() const { return mHorizontalScale->value(); } void FancyPlotterSettings::setShowVerticalLines( bool value ) { mShowVerticalLines->setChecked( value ); mVerticalLinesDistance->setEnabled( value ); mVerticalLinesScroll->setEnabled( value ); } bool FancyPlotterSettings::showVerticalLines() const { return mShowVerticalLines->isChecked(); } void FancyPlotterSettings::setVerticalLinesDistance( int distance ) { mVerticalLinesDistance->setValue( distance ); } int FancyPlotterSettings::verticalLinesDistance() const { return mVerticalLinesDistance->value(); } void FancyPlotterSettings::setVerticalLinesScroll( bool value ) { mVerticalLinesScroll->setChecked( value ); } bool FancyPlotterSettings::verticalLinesScroll() const { return mVerticalLinesScroll->isChecked(); } void FancyPlotterSettings::setShowHorizontalLines( bool value ) { mShowHorizontalLines->setChecked( value ); } bool FancyPlotterSettings::showHorizontalLines() const { return mShowHorizontalLines->isChecked(); } void FancyPlotterSettings::setShowAxis( bool value ) { mShowAxis->setChecked( value ); } bool FancyPlotterSettings::showAxis() const { return mShowAxis->isChecked(); } void FancyPlotterSettings::setShowTopBar( bool value ) { mShowTopBar->setChecked( value ); } bool FancyPlotterSettings::showTopBar() const { return mShowTopBar->isChecked(); } void FancyPlotterSettings::setFontSize( int size ) { mFontSize->setValue( size ); } int FancyPlotterSettings::fontSize() const { return mFontSize->value(); } void FancyPlotterSettings::setSensors( const SensorModelEntry::List &list ) { mModel->setSensors( list ); mView->selectionModel()->setCurrentIndex( mModel->index( 0, 0 ), QItemSelectionModel::SelectCurrent | QItemSelectionModel::Rows ); } SensorModelEntry::List FancyPlotterSettings::sensors() const { return mModel->sensors(); } void FancyPlotterSettings::editSensor() { if ( !mView->selectionModel() ) return; const QModelIndex index = mView->selectionModel()->currentIndex(); if ( !index.isValid() ) return; SensorModelEntry sensor = mModel->sensor( index ); QColorDialog dialog( this ); dialog.setModal( true ); connect( &dialog, &QColorDialog::colorSelected, this, &FancyPlotterSettings::setColorForSelectedItem ); QColor color = sensor.color(); dialog.setCurrentColor( color ); int result = dialog.exec(); if ( result == QColorDialog::Accepted ) sensor.setColor( dialog.currentColor() ); //If it's not accepted, make sure we set the color back to how it was mModel->setSensor( sensor, index ); } void FancyPlotterSettings::setColorForSelectedItem(const QColor &color) { const QModelIndex index = mView->selectionModel()->currentIndex(); if ( !index.isValid() ) return; SensorModelEntry sensor = mModel->sensor( index ); sensor.setColor( color ); mModel->setSensor( sensor, index ); } void FancyPlotterSettings::removeSensor() { if ( !mView->selectionModel() ) return; const QModelIndex index = mView->selectionModel()->currentIndex(); if ( !index.isValid() ) return; mModel->removeSensor( index ); selectionChanged( mView->selectionModel()->currentIndex() ); } void FancyPlotterSettings::clearDeleted() { mModel->clearDeleted(); } QList FancyPlotterSettings::deleted() const { return mModel->deleted(); } QList FancyPlotterSettings::order() const { return mModel->order(); } void FancyPlotterSettings::resetOrder() { mModel->resetOrder(); } diff --git a/gui/WorkSheetSettings.cpp b/gui/WorkSheetSettings.cpp index 0a73b895..d657ccd5 100644 --- a/gui/WorkSheetSettings.cpp +++ b/gui/WorkSheetSettings.cpp @@ -1,170 +1,170 @@ /* KSysGuard, the KDE System Guard Copyright (c) 1999 - 2002 Chris Schlaeger 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) version 3 or any later version accepted by the membership of KDE e.V. (or its successor approved by the membership of KDE e.V.), which shall act as a proxy defined in Section 14 of version 3 of the license. 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, see . */ #include #include #include #include #include #include #include #include #include #include #include #include "WorkSheetSettings.h" WorkSheetSettings::WorkSheetSettings( QWidget* parent, bool locked ) : QDialog( parent ) { setObjectName( QStringLiteral("WorkSheetSettings") ); setModal( true ); setWindowTitle( i18n( "Tab Properties" ) ); QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok|QDialogButtonBox::Cancel); QVBoxLayout *mainLayout = new QVBoxLayout; setLayout(mainLayout); QPushButton *okButton = buttonBox->button(QDialogButtonBox::Ok); okButton->setDefault(true); okButton->setShortcut(Qt::CTRL | Qt::Key_Return); connect(buttonBox, &QDialogButtonBox::accepted, this, &WorkSheetSettings::accept); connect(buttonBox, &QDialogButtonBox::rejected, this, &WorkSheetSettings::reject); QWidget *page = new QWidget( this ); mainLayout->addWidget(page); mainLayout->addWidget(buttonBox); QVBoxLayout *topLayout = new QVBoxLayout( page ); - topLayout->setMargin( 0 ); + topLayout->setContentsMargins( 0, 0, 0, 0 ); //PORT QT5 topLayout->setSpacing( spacingHint() ); QGroupBox *group = new QGroupBox( i18n( "Title" ), page ); QGridLayout *groupLayout = new QGridLayout; group->setLayout( groupLayout ); groupLayout->setAlignment( Qt::AlignTop ); mSheetTitle = new QLineEdit( group ); groupLayout->addWidget( mSheetTitle, 0, 0 ); topLayout->addWidget( group ); group = new QGroupBox( i18n( "Properties" ), page ); groupLayout = new QGridLayout; group->setLayout( groupLayout ); groupLayout->setAlignment( Qt::AlignTop ); int row_num = -1; QLabel *label; if ( !locked ) { label = new QLabel( i18n( "Rows:" ), group ); groupLayout->addWidget( label, ++row_num, 0 ); mRows = new QSpinBox( group ); mRows->setValue( 3 ); mRows->setMaximum( 42 ); mRows->setMinimum( 1 ); groupLayout->addWidget( mRows, row_num, 1 ); label->setBuddy( mRows ); label = new QLabel( i18n( "Columns:" ), group ); groupLayout->addWidget( label, ++row_num, 0 ); mColumns = new QSpinBox( group ); mColumns->setValue( 1 ); mColumns->setMaximum( 42 ); mColumns->setMinimum( 1 ); groupLayout->addWidget( mColumns, 1, 1 ); label->setBuddy( mColumns ); mRows->setWhatsThis( i18n( "Enter the number of rows the sheet should have." ) ); mColumns->setWhatsThis( i18n( "Enter the number of columns the sheet should have." ) ); } label = new QLabel( i18n( "Update interval:" ), group ); groupLayout->addWidget( label, ++row_num, 0 ); mInterval = new QDoubleSpinBox(group); mInterval->setMaximum(1000); mInterval->setSingleStep(0.5); mInterval->setValue(0.5); mInterval->setSuffix( i18n( " sec" ) ); groupLayout->addWidget( mInterval, row_num, 1 ); label->setBuddy( mInterval ); topLayout->addWidget( group ); mInterval->setWhatsThis( i18n( "All displays of the sheet are updated at the rate specified here." ) ); mSheetTitle->setToolTip( i18n( "Enter the title of the worksheet here." ) ); KAcceleratorManager::manage( page ); mSheetTitle->setFocus(); // resize( QSize( 250, 230 ).expandedTo( minimumSizeHint() ) ); } WorkSheetSettings::~WorkSheetSettings() { } void WorkSheetSettings::setRows( int rows ) { mRows->setValue( rows ); } int WorkSheetSettings::rows() const { return mRows->value(); } void WorkSheetSettings::setColumns( int columns ) { mColumns->setValue( columns ); } int WorkSheetSettings::columns() const { return mColumns->value(); } void WorkSheetSettings::setInterval( float interval ) { mInterval->setValue( interval ); } float WorkSheetSettings::interval() const { return mInterval->value(); } void WorkSheetSettings::setSheetTitle( const QString &title ) { mSheetTitle->setText( title ); } QString WorkSheetSettings::sheetTitle() const { return mSheetTitle->text(); }