Skip to content

Commit

Permalink
fixes for compiling with QT6
Browse files Browse the repository at this point in the history
  • Loading branch information
andrew-bibb committed Nov 20, 2022
1 parent 584282f commit 5d032b0
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 13 deletions.
28 changes: 23 additions & 5 deletions apps/cmstapp/code/control_box/controlbox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ DEALINGS IN THE SOFTWARE.
# include <QColorDialog>
# include <QPainter>
# include <QImage>
# include <QDesktopWidget>
# if QT_VERSION < 0x060000
# include <QDesktopWidget>
# endif
# include <QInputDialog>
# include <QDateTime>

Expand Down Expand Up @@ -216,7 +218,11 @@ ControlBox::ControlBox(const QCommandLineParser& parser, QWidget *parent)
}

// Make sure the controlbox will fit onto small screens (& resize to sizeHint() for HiDPI screens)
QSize sz_target = (qApp->desktop()->availableGeometry(this)).size();
# if QT_VERSION < 0x060000
QSize sz_target = (qApp->desktop()->availableGeometry(this)).size();
# else
QSize sz_target = qApp->primaryScreen()->availableGeometry().size();
# endif
QSize sz_source = this->sizeHint();
if (sz_source.width() > sz_target.width() || sz_source.height() > sz_target.height() ) {
sz_source.scale(sz_target.width() - 100, sz_target.height() - 100, Qt::KeepAspectRatio); // keep min. 100 pixels around dialog
Expand Down Expand Up @@ -1752,7 +1758,11 @@ void ControlBox::getServiceDetails(int index)
QMap<QString,QVariant> submap;

// Get a QFileInfo associated with the index and display the connection
QFileInfo fi = services_list.at(index).objpath.path();
# if QT_VERSION < 0x060000
QFileInfo fi = services_list.at(index).objpath.path();
# else
QFileInfo fi(services_list.at(index).objpath.path());
# endif
ui.label_details_connection->setText(tr("<b>Connection:</b> %1").arg(fi.baseName()) );

// Start building the string for the left label
Expand Down Expand Up @@ -2094,7 +2104,11 @@ void ControlBox::assembleTabStatus()
ui.tableWidget_services->setItem(row, 2, qtwi02);

QTableWidgetItem* qtwi03 = new QTableWidgetItem();
QFileInfo fi = services_list.at(row).objpath.path();
# if QT_VERSION < 0x060000
QFileInfo fi = services_list.at(row).objpath.path();
# else
QFileInfo fi(services_list.at(row).objpath.path());
# endif
qtwi03->setText(fi.baseName() );
qtwi03->setTextAlignment(Qt::AlignVCenter|Qt::AlignLeft);
ui.tableWidget_services->setItem(row, 3, qtwi03);
Expand Down Expand Up @@ -2345,7 +2359,11 @@ void ControlBox::assembleTabVPN()
ui.tableWidget_vpn->setCellWidget(rowcount, 3, ql03);

QLabel* ql04 = new QLabel(ui.tableWidget_vpn);
QFileInfo fi = services_list.at(row).objpath.path();
# if QT_VERSION < 0x060000
QFileInfo fi = services_list.at(row).objpath.path();
# else
QFileInfo fi(services_list.at(row).objpath.path());
# endif
ql04->setText(fi.baseName() );
ql04->setAlignment(Qt:: AlignCenter);
ui.tableWidget_vpn->setCellWidget(rowcount, 4, ql04);
Expand Down
16 changes: 10 additions & 6 deletions apps/cmstapp/code/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,10 @@ void signalhandler(int sig) {

int main(int argc, char *argv[])
{
// set core application attributes

# if QT_VERSION < 0x060000
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
// #if QT_VERSION >= 0x050600
// QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
// #endif
# endif

QApplication::setApplicationName(LONG_NAME);
QApplication::setApplicationVersion(VERSION);
Expand Down Expand Up @@ -169,8 +168,13 @@ int main(int argc, char *argv[])

// Setup translations
QTranslator qtTranslator;
qtTranslator.load("qt_" + QLocale::system().name(),
QLibraryInfo::location(QLibraryInfo::TranslationsPath));
# if QT_VERSION < 0x060000
qtTranslator.load("qt_" + QLocale::system().name(),
QLibraryInfo::location(QLibraryInfo::TranslationsPath));
# else
(void) qtTranslator.load("qt_" + QLocale::system().name(),
QLibraryInfo::path(QLibraryInfo::TranslationsPath));
# endif
app.installTranslator(&qtTranslator);

QTranslator cmstTranslator;
Expand Down
4 changes: 3 additions & 1 deletion apps/cmstapp/code/vpn_agent/vpnagent_adaptor.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ class QByteArray;
template<class T> class QList;
template<class Key, class Value> class QMap;
class QString;
class QStringList;
# if QT_VERSION < 0x060000
class QStringList;
# endif
class QVariant;
QT_END_NAMESPACE

Expand Down
2 changes: 1 addition & 1 deletion apps/resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ DEALINGS IN THE SOFTWARE.
///////////////////////////////// Program Values ///////////////////////
//
// Program Info (may be visible, but don't mark for tranalation)
#define VERSION "2022.11.20-1"
#define VERSION "2022.11.20-2"

#define RELEASE_DATE "1 May 2022"
#define COPYRIGHT_DATE "2013-2022"
Expand Down
1 change: 1 addition & 0 deletions text/changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<b><center>Change Log</center></b>
<b> In Progress</b>
<ul>
<li>Changes to allow compile with QT6 (PR #278 from kitsnotes).</li>
<li>Numerous translation updates</li>
<li>All columns can be resized in the Technologies windows in the Status tab.</li>
</ul>
Expand Down

0 comments on commit 5d032b0

Please sign in to comment.