• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdegraphics API Reference
  • KDE Home
  • Contact Us
 

libs/libksane/libksane

  • sources
  • kde-4.14
  • kdegraphics
  • libs
  • libksane
  • libksane
  • widgets
ksane_option_widget.cpp
Go to the documentation of this file.
1 /* ============================================================
2  *
3  * This file is part of the KDE project
4  *
5  * Description : Base class for option widgets
6  *
7  * Copyright (C) 2011 by Kare Sars <kare.sars@iki.fi>
8  *
9  * This library is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License as published by the Free Software Foundation; either
12  * version 2.1 of the License, or (at your option) version 3, or any
13  * later version accepted by the membership of KDE e.V. (or its
14  * successor approved by the membership of KDE e.V.), which shall
15  * act as a proxy defined in Section 6 of version 3 of the license.
16  *
17  * This library is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20  * Lesser General Public License for more details.
21  *
22  * You should have received a copy of the GNU Lesser General Public
23  * License along with this program. If not, see <http://www.gnu.org/licenses/>.
24  *
25  * ============================================================ */
26 
27 // Local includes
28 #include "ksane_option_widget.h"
29 #include "ksane_option_widget.moc"
30 
31 // Qt includes
32 #include <KDebug>
33 #include <KLocale>
34 
35 namespace KSaneIface
36 {
37 
38 KSaneOptionWidget::KSaneOptionWidget(QWidget *parent, const QString& labelText)
39 : QWidget(parent)
40 {
41  m_label = new QLabel;
42  setLabelText(labelText);
43 
44  m_layout = new QGridLayout(this);
45  m_layout->addWidget(m_label, 0, 0, Qt::AlignRight);
46  m_layout->setColumnStretch(0, 0);
47  m_layout->setContentsMargins(0,0,0,0);
48 }
49 
50 KSaneOptionWidget::~KSaneOptionWidget()
51 {
52 }
53 
54 void KSaneOptionWidget::setLabelText(const QString &text)
55 {
56  if (text.isEmpty()) {
57  m_label->setText(QString());
58  } else {
59  m_label->setText(i18nc("Label for a scanner option", "%1:", text));
60  }
61 }
62 
63 
64 int KSaneOptionWidget::labelWidthHint()
65 {
66  return m_label->sizeHint().width();
67 }
68 
69 void KSaneOptionWidget::setLabelWidth(int labelWidth)
70 {
71  m_layout->setColumnMinimumWidth(0, labelWidth);
72 }
73 
74 } // NameSpace KSaneIface
QWidget
QLayout::setContentsMargins
void setContentsMargins(int left, int top, int right, int bottom)
KSaneIface::KSaneOptionWidget::setLabelText
void setLabelText(const QString &text)
Definition: ksane_option_widget.cpp:54
QSize::width
int width() const
QGridLayout::addWidget
void addWidget(QWidget *widget, int row, int column, QFlags< Qt::AlignmentFlag > alignment)
QGridLayout
KSaneIface::KSaneOptionWidget::m_label
QLabel * m_label
Definition: ksane_option_widget.h:64
KSaneIface::KSaneOptionWidget::labelWidthHint
int labelWidthHint()
Definition: ksane_option_widget.cpp:64
KSaneIface::KSaneOptionWidget::m_layout
QGridLayout * m_layout
Definition: ksane_option_widget.h:65
KSaneIface::KSaneOptionWidget::~KSaneOptionWidget
~KSaneOptionWidget()
Definition: ksane_option_widget.cpp:50
QString::isEmpty
bool isEmpty() const
QLabel::setText
void setText(const QString &)
ksane_option_widget.h
QString
QGridLayout::setColumnStretch
void setColumnStretch(int column, int stretch)
KSaneIface::KSaneOptionWidget::setLabelWidth
void setLabelWidth(int labelWidth)
Definition: ksane_option_widget.cpp:69
QGridLayout::setColumnMinimumWidth
void setColumnMinimumWidth(int column, int minSize)
QLabel::sizeHint
virtual QSize sizeHint() const
KSaneIface::KSaneOptionWidget::KSaneOptionWidget
KSaneOptionWidget(QWidget *parent, const QString &labelText)
Create the Wodget.
Definition: ksane_option_widget.cpp:38
QLabel
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:19:47 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

libs/libksane/libksane

Skip menu "libs/libksane/libksane"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdegraphics API Reference

Skip menu "kdegraphics API Reference"
  •     libkdcraw
  •     libkexiv2
  •     libkipi
  •     libksane
  • okular

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal