C++98 compatibility.
This commit is contained in:
@@ -9,27 +9,27 @@
|
||||
IconTitleWidget::IconTitleWidget(const QIcon& icon, const QString& title, QWidget *parent) :
|
||||
QFrame(parent)
|
||||
{
|
||||
auto l = new QBoxLayout(QBoxLayout::LeftToRight);
|
||||
QBoxLayout* l = new QBoxLayout(QBoxLayout::LeftToRight);
|
||||
l->setContentsMargins(0, 0, 0, 0);
|
||||
setLayout(l);
|
||||
|
||||
// Icon label
|
||||
if (icon.isNull())
|
||||
{
|
||||
// auto titleIcon = new QLabel();
|
||||
// QLabel* titleIcon = new QLabel();
|
||||
// titleIcon->setPixmap(style()->standardIcon(QStyle::SP_MessageBoxInformation).pixmap(16, 16));
|
||||
// l->addWidget(titleIcon);
|
||||
}
|
||||
else
|
||||
{
|
||||
auto titleIcon = new QLabel();
|
||||
QLabel* titleIcon = new QLabel();
|
||||
titleIcon->setPixmap(icon.pixmap(16, 16));
|
||||
l->addWidget(titleIcon);
|
||||
}
|
||||
|
||||
// Title label
|
||||
auto titleText = new QLabel(title);
|
||||
auto titleFont = titleText->font();
|
||||
QLabel* titleText = new QLabel(title);
|
||||
QFont titleFont = titleText->font();
|
||||
titleFont.setBold(true);
|
||||
titleText->setFont(titleFont);
|
||||
l->addWidget(titleText, 1);
|
||||
|
||||
@@ -10,10 +10,10 @@ static void centerWidget(QWidget* widget)
|
||||
if (widget)
|
||||
{
|
||||
QDesktopWidget deskWidget;
|
||||
const auto screenIndex = deskWidget.primaryScreen();
|
||||
const auto deskRect = deskWidget.availableGeometry(screenIndex);
|
||||
const auto x = (deskRect.width() - widget->rect().width()) / 2;
|
||||
const auto y = (deskRect.height() - widget->rect().height()) / 2;
|
||||
const int screenIndex = deskWidget.primaryScreen();
|
||||
const QRect deskRect = deskWidget.availableGeometry(screenIndex);
|
||||
const int x = (deskRect.width() - widget->rect().width()) / 2;
|
||||
const int y = (deskRect.height() - widget->rect().height()) / 2;
|
||||
widget->move(x, y);
|
||||
}
|
||||
}
|
||||
@@ -23,10 +23,10 @@ static void resizeWidgetPerCent(QWidget* widget, qreal widthPC, qreal heightPC)
|
||||
if (widget && widthPC >= 0.0 && heightPC >= 0.0)
|
||||
{
|
||||
QDesktopWidget deskWidget;
|
||||
const auto screenIndex = deskWidget.primaryScreen();
|
||||
const auto deskRect = deskWidget.availableGeometry(screenIndex);
|
||||
const auto w = (deskRect.width() / 100) * widthPC;
|
||||
const auto h = (deskRect.height() / 100) * heightPC;
|
||||
const int screenIndex = deskWidget.primaryScreen();
|
||||
const QRect deskRect = deskWidget.availableGeometry(screenIndex);
|
||||
const int w = (deskRect.width() / 100) * widthPC;
|
||||
const int h = (deskRect.height() / 100) * heightPC;
|
||||
widget->resize(w, h);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,14 +88,17 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
section->addContent(createCalendarSC());
|
||||
_container->addSection(section);
|
||||
|
||||
QByteArray ba;
|
||||
QFile f("test.dat");
|
||||
if (f.open(QFile::ReadOnly))
|
||||
if (true)
|
||||
{
|
||||
ba = f.readAll();
|
||||
f.close();
|
||||
QByteArray ba;
|
||||
QFile f("test.dat");
|
||||
if (f.open(QFile::ReadOnly))
|
||||
{
|
||||
ba = f.readAll();
|
||||
f.close();
|
||||
}
|
||||
_container->restoreGeometry(ba);
|
||||
}
|
||||
_container->restoreGeometry(ba);
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
@@ -118,6 +121,7 @@ void MainWindow::onActionAddSectionContentTriggered()
|
||||
|
||||
void MainWindow::contextMenuEvent(QContextMenuEvent* e)
|
||||
{
|
||||
Q_UNUSED(e);
|
||||
QMenu* m = _container->createContextMenu();
|
||||
m->exec(QCursor::pos());
|
||||
delete m;
|
||||
@@ -125,11 +129,15 @@ void MainWindow::contextMenuEvent(QContextMenuEvent* e)
|
||||
|
||||
void MainWindow::closeEvent(QCloseEvent* e)
|
||||
{
|
||||
QByteArray ba = _container->saveGeometry();
|
||||
QFile f("test.dat");
|
||||
if (f.open(QFile::WriteOnly))
|
||||
Q_UNUSED(e);
|
||||
if (true)
|
||||
{
|
||||
f.write(ba);
|
||||
f.close();
|
||||
QByteArray ba = _container->saveGeometry();
|
||||
QFile f("test.dat");
|
||||
if (f.open(QFile::WriteOnly))
|
||||
{
|
||||
f.write(ba);
|
||||
f.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user