Skip to content

Commit

Permalink
Merge pull request #571 from Tarsnap/tasidelabel
Browse files Browse the repository at this point in the history
TAsideLabel
  • Loading branch information
gperciva authored Nov 20, 2023
2 parents 9c0fb97 + e603a8b commit 896662e
Show file tree
Hide file tree
Showing 13 changed files with 181 additions and 48 deletions.
2 changes: 2 additions & 0 deletions Tarsnap.pro
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ SOURCES += \
lib/core/TSettings.cpp \
lib/util/optparse.c \
lib/util/optparse_helper.c \
lib/widgets/TAsideLabel.cpp \
lib/widgets/TBusyLabel.cpp \
lib/widgets/TElidedLabel.cpp \
lib/widgets/TOkLabel.cpp \
Expand Down Expand Up @@ -111,6 +112,7 @@ HEADERS += \
lib/core/warnings-disable.h \
lib/util/optparse.h \
lib/util/optparse_helper.h \
lib/widgets/TAsideLabel.h \
lib/widgets/TBusyLabel.h \
lib/widgets/TElidedLabel.h \
lib/widgets/TOkLabel.h \
Expand Down
30 changes: 6 additions & 24 deletions forms/setupwizard_intro.ui
Original file line number Diff line number Diff line change
Expand Up @@ -82,33 +82,10 @@
</spacer>
</item>
<item>
<widget class="QLabel" name="asideLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<italic>true</italic>
</font>
</property>
<property name="styleSheet">
<string notr="true">QLabel {
margin-left: 0.125em;
border-width: 0 0 0 0.1em;
border-style: solid;
border-color: &quot;#999&quot;;
padding-left: 0.25em;
}</string>
</property>
<widget class="TAsideLabel" name="tasidelabel">
<property name="text">
<string>You can also skip this wizard and set up everything inside the application.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
Expand Down Expand Up @@ -154,6 +131,11 @@
</layout>
</widget>
<customwidgets>
<customwidget>
<class>TAsideLabel</class>
<extends>QLabel</extends>
<header>TAsideLabel.h</header>
</customwidget>
<customwidget>
<class>TWizardPage</class>
<extends>QWidget</extends>
Expand Down
30 changes: 6 additions & 24 deletions forms/setupwizard_register.ui
Original file line number Diff line number Diff line change
Expand Up @@ -57,33 +57,10 @@
</widget>
</item>
<item>
<widget class="QLabel" name="registerPageInfoLabelAside">
<property name="minimumSize">
<size>
<width>0</width>
<height>17</height>
</size>
</property>
<property name="font">
<font>
<italic>true</italic>
</font>
</property>
<property name="styleSheet">
<string notr="true">QLabel {
margin-left: 0.125em;
border-width: 0 0 0 0.1em;
border-style: solid;
border-color: &quot;#999&quot;;
padding-left: 0.25em;
}</string>
</property>
<widget class="TAsideLabel" name="tasidelabel">
<property name="text">
<string>Don't have an account? Register on &lt;a href=&quot;http://tarsnap.com&quot;&gt;tarsnap.com&lt;/a&gt;.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
Expand Down Expand Up @@ -418,6 +395,11 @@
</layout>
</widget>
<customwidgets>
<customwidget>
<class>TAsideLabel</class>
<extends>QLabel</extends>
<header>TAsideLabel.h</header>
</customwidget>
<customwidget>
<class>TBusyLabel</class>
<extends>QLabel</extends>
Expand Down
53 changes: 53 additions & 0 deletions lib/plugins/TAsideLabelPlugin.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#include "TAsideLabelPlugin.h"

WARNINGS_DISABLE
#include <QStringLiteral>
WARNINGS_ENABLE

class QWidget;

#include "TAsideLabel.h"

TAsideLabelPlugin::TAsideLabelPlugin(QObject *parent) : QObject(parent)
{
}

QIcon TAsideLabelPlugin::icon() const
{
return (QIcon());
}

QString TAsideLabelPlugin::group() const
{
return (QStringLiteral("Display Widgets"));
}

QString TAsideLabelPlugin::includeFile() const
{
return (QStringLiteral("TAsideLabel.h"));
}

QString TAsideLabelPlugin::name() const
{
return (QStringLiteral("TAsideLabel"));
}

QString TAsideLabelPlugin::toolTip() const
{
return (QString());
}

QString TAsideLabelPlugin::whatsThis() const
{
return (QString());
}

QWidget *TAsideLabelPlugin::createWidget(QWidget *parent)
{
return (new TAsideLabel(parent));
}

bool TAsideLabelPlugin::isContainer() const
{
return (false);
}
34 changes: 34 additions & 0 deletions lib/plugins/TAsideLabelPlugin.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#ifndef TASIDELABELPLUGIN_H
#define TASIDELABELPLUGIN_H

#include "warnings-disable.h"

WARNINGS_DISABLE
#include <QDesignerCustomWidgetInterface>
#include <QIcon>
#include <QObject>
#include <QString>
WARNINGS_ENABLE

/* Forward declaration(s). */
class QWidget;

class TAsideLabelPlugin : public QObject, public QDesignerCustomWidgetInterface
{
Q_OBJECT
Q_INTERFACES(QDesignerCustomWidgetInterface)

public:
explicit TAsideLabelPlugin(QObject *parent = nullptr);

QIcon icon() const override;
QString group() const override;
QString includeFile() const override;
QString name() const override;
QString toolTip() const override;
QString whatsThis() const override;
QWidget *createWidget(QWidget *parent) override;
bool isContainer() const override;
};

#endif /* !TASIDELABELPLUGIN_H */
2 changes: 2 additions & 0 deletions lib/plugins/plugins.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "plugins.h"

#include "TAsideLabelPlugin.h"
#include "TBusyLabelPlugin.h"
#include "TElidedLabelPlugin.h"
#include "TOkLabelPlugin.h"
Expand All @@ -12,6 +13,7 @@

TarsnapPlugins::TarsnapPlugins(QObject *parent) : QObject(parent)
{
widgets.append(new TAsideLabelPlugin(this));
widgets.append(new TBusyLabelPlugin(this));
widgets.append(new TElidedLabelPlugin(this));
widgets.append(new TOkLabelPlugin(this));
Expand Down
4 changes: 4 additions & 0 deletions lib/plugins/plugins.pro
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ QT += widgets uiplugin

HEADERS = plugins.h \
../core/warnings-disable.h \
../widgets/TAsideLabel.h \
../widgets/TBusyLabel.h \
../widgets/TElidedLabel.h \
../widgets/TOkLabel.h \
Expand All @@ -14,6 +15,7 @@ HEADERS = plugins.h \
../widgets/TTabWidget.h \
../widgets/TTextView.h \
../widgets/TWizardPage.h \
TAsideLabelPlugin.h \
TBusyLabelPlugin.h \
TElidedLabelPlugin.h \
TOkLabelPlugin.h \
Expand All @@ -25,6 +27,7 @@ HEADERS = plugins.h \
TWizardPagePlugin.h

SOURCES = plugins.cpp \
../widgets/TAsideLabel.cpp \
../widgets/TBusyLabel.cpp \
../widgets/TElidedLabel.cpp \
../widgets/TOkLabel.cpp \
Expand All @@ -34,6 +37,7 @@ SOURCES = plugins.cpp \
../widgets/TTabWidget.cpp \
../widgets/TTextView.cpp \
../widgets/TWizardPage.cpp \
TAsideLabelPlugin.cpp \
TBusyLabelPlugin.cpp \
TElidedLabelPlugin.cpp \
TOkLabelPlugin.cpp \
Expand Down
26 changes: 26 additions & 0 deletions lib/widgets/TAsideLabel.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#include "TAsideLabel.h"

WARNINGS_DISABLE
#include <QFont>
WARNINGS_ENABLE

#define SHEET_ASIDE \
"margin-left: 0.125em;" \
"border-width: 0 0 0 0.1em;" \
"border-style: solid;" \
"border-color: palette(mid);" \
"padding-left: 0.25em;"

TAsideLabel::TAsideLabel(QWidget *parent) : QLabel(parent)
{
// Make it italic.
QFont font = this->font();
font.setStyle(QFont::StyleItalic);
setFont(font);

// Add the border and padding.
setStyleSheet(SHEET_ASIDE);

// Word wrap.
setWordWrap(true);
}
27 changes: 27 additions & 0 deletions lib/widgets/TAsideLabel.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#ifndef TASIDELABEL_H
#define TASIDELABEL_H

#include "warnings-disable.h"

WARNINGS_DISABLE
#include <QLabel>
#include <QObject>
WARNINGS_ENABLE

/* Forward declaration(s). */
class QWidget;

/*!
* \ingroup lib-widgets
* \brief The TAsideLabel widget is a QLabel which is similar to \<aside\>.
*/
class TAsideLabel : public QLabel
{
Q_OBJECT

public:
//! Constructor.
explicit TAsideLabel(QWidget *parent = nullptr);
};

#endif // TASIDELABEL_H
2 changes: 2 additions & 0 deletions tests/app-setup/test-app-setup.pro
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ SOURCES += test-app-setup.cpp \
../../lib/core/TSettings.cpp \
../../lib/util/optparse.c \
../../lib/util/optparse_helper.c \
../../lib/widgets/TAsideLabel.cpp \
../../lib/widgets/TBusyLabel.cpp \
../../lib/widgets/TElidedLabel.cpp \
../../lib/widgets/TOkLabel.cpp \
Expand Down Expand Up @@ -68,6 +69,7 @@ HEADERS += \
../../lib/core/TSettings.h \
../../lib/util/optparse.h \
../../lib/util/optparse_helper.h \
../../lib/widgets/TAsideLabel.h \
../../lib/widgets/TBusyLabel.h \
../../lib/widgets/TElidedLabel.h \
../../lib/widgets/TOkLabel.h \
Expand Down
15 changes: 15 additions & 0 deletions tests/lib-widgets/test-lib-widgets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ WARNINGS_ENABLE
#include "../qtest-platform.h"

#include "LogEntry.h"
#include "TAsideLabel.h"
#include "TBusyLabel.h"
#include "TElidedLabel.h"
#include "TOkLabel.h"
Expand All @@ -43,6 +44,7 @@ private slots:
void okLabel();
void busylabel();
void busylabel_on_off();
void tasidelabel();
void pathlinebrowse();
void pathcombobrowse();
void ttabwidget_basic();
Expand Down Expand Up @@ -161,6 +163,19 @@ void TestLibWidgets::busylabel_on_off()
delete bw;
}

void TestLibWidgets::tasidelabel()
{
TAsideLabel *lab = new TAsideLabel();
lab->setMinimumWidth(200);

VISUAL_INIT(lab);

lab->setText("message");
VISUAL_WAIT;

delete lab;
}

void TestLibWidgets::pathlinebrowse()
{
TPathLineBrowse *plb = new TPathLineBrowse();
Expand Down
2 changes: 2 additions & 0 deletions tests/lib-widgets/test-lib-widgets.pro
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ RESOURCES += ../../lib/resources/lib-resources.qrc \
../../resources/resources.qrc

HEADERS += \
../../lib/widgets/TAsideLabel.h \
../../lib/widgets/TBusyLabel.h \
../../lib/widgets/TElidedLabel.h \
../../lib/widgets/TOkLabel.h \
Expand All @@ -26,6 +27,7 @@ HEADERS += \

SOURCES += test-lib-widgets.cpp \
../../lib/core/TSettings.cpp \
../../lib/widgets/TAsideLabel.cpp \
../../lib/widgets/TBusyLabel.cpp \
../../lib/widgets/TElidedLabel.cpp \
../../lib/widgets/TOkLabel.cpp \
Expand Down
2 changes: 2 additions & 0 deletions tests/setupwizard/test-setupwizard.pro
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ FORMS += \
HEADERS += \
compare-settings.h \
../../lib/core/TSettings.h \
../../lib/widgets/TAsideLabel.h \
../../lib/widgets/TBusyLabel.h \
../../lib/widgets/TElidedLabel.h \
../../lib/widgets/TOkLabel.h \
Expand All @@ -35,6 +36,7 @@ HEADERS += \
SOURCES += test-setupwizard.cpp \
compare-settings.cpp \
../../lib/core/TSettings.cpp \
../../lib/widgets/TAsideLabel.cpp \
../../lib/widgets/TBusyLabel.cpp \
../../lib/widgets/TElidedLabel.cpp \
../../lib/widgets/TOkLabel.cpp \
Expand Down

0 comments on commit 896662e

Please sign in to comment.