From 34ac37fd56e3be279368a4e403eefc87ed60bf8f Mon Sep 17 00:00:00 2001 From: Martins Mozeiko Date: Mon, 30 Jan 2017 12:47:21 -0800 Subject: [PATCH] support for older Qt5 library and GNU/Linux versions --- .travis.yml | 13 ++++++------- CMakeLists.txt | 2 +- src/item_model.cpp | 7 ++++--- src/main_window.cpp | 45 ++++++++++++++++++++----------------------- src/remote_widget.cpp | 6 ++++-- 5 files changed, 36 insertions(+), 37 deletions(-) diff --git a/.travis.yml b/.travis.yml index c4aacb58..be8dca61 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,15 +7,14 @@ matrix: - os: linux language: cpp dist: trusty - sudo: required - install: - - sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y - - sudo add-apt-repository ppa:beineri/opt-qt58-trusty -y - - sudo apt-get update -q - - sudo apt-get install g++-6 qt58base -y + sudo: false + addons: + apt: + packages: + - qttools5-dev script: - mkdir build && cd build - - cmake -DCMAKE_C_COMPILER=gcc-6 -DCMAKE_CXX_COMPILER=g++-6 -DCMAKE_PREFIX_PATH=/opt/qt58/lib/cmake .. + - cmake .. - cmake --build . - os: osx diff --git a/CMakeLists.txt b/CMakeLists.txt index a0169f09..24a76e69 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ project(rclone-browser) -cmake_minimum_required(VERSION 3.2) +cmake_minimum_required(VERSION 2.8) if(WIN32) # link automatically to qtmain.lib on Windows diff --git a/src/item_model.cpp b/src/item_model.cpp index 4e83b3c3..a6f22b6d 100644 --- a/src/item_model.cpp +++ b/src/item_model.cpp @@ -6,13 +6,14 @@ namespace { static void advanceSpinner(QString& text) { - QChar current = text[text.length() - 2]; + int spinnerPos = (int)((size_t)text.length() - 2); + QChar current = text[spinnerPos]; static const QChar spinner[] = { '-', '\\', '|', '/' }; size_t spinnerCount = sizeof(spinner) / sizeof(*spinner); const QChar* found = qFind(spinner, spinner + spinnerCount, current); size_t idx = found - spinner; size_t next = idx == spinnerCount - 1 ? 0 : idx + 1; - text[text.length() - 2] = spinner[next]; + text[spinnerPos] = spinner[next]; } QString getNiceSize(quint64 size) @@ -549,7 +550,7 @@ void ItemModel::load(const QPersistentModelIndex& parentIndex, Item* parent) { modified = true; emit beginInsertRows(parentIndex, parent->childs.count(), parent->childs.count() + todo.count() - 1); - parent->childs.append(todo); + parent->childs += todo; emit endInsertRows(); } diff --git a/src/main_window.cpp b/src/main_window.cpp index 15607fe9..a4e8c3f7 100644 --- a/src/main_window.cpp +++ b/src/main_window.cpp @@ -112,29 +112,6 @@ MainWindow::MainWindow() ui.tabs->tabBar()->setTabButton(1, QTabBar::LeftSide, nullptr); ui.tabs->setCurrentIndex(0); - QTimer::singleShot(0, ui.remotes, static_cast(&QWidget::setFocus)); - QTimer::singleShot(0, this, [=]() { ui.remotes->currentItemChanged(nullptr, nullptr); }); - QTimer::singleShot(0, this, [=]() - { - QString rclone = GetRclone(); - if (rclone.isEmpty()) - { - rclone = QStandardPaths::findExecutable("rclone"); - QSettings settings; - settings.setValue("Settings/rclone", rclone); - SetRclone(rclone); - } - if (rclone.isEmpty()) - { - QMessageBox::information(this, "Error", "Cannot check rclone verison!\nPlease verify rclone location."); - emit ui.preferences->trigger(); - } - else - { - rcloneGetVersion(); - } - }); - QObject::connect(&mSystemTray, &QSystemTrayIcon::activated, this, [=](QSystemTrayIcon::ActivationReason reason) { if (reason == QSystemTrayIcon::DoubleClick || reason == QSystemTrayIcon::Trigger) @@ -178,6 +155,26 @@ MainWindow::MainWindow() mStatusMessage = new QLabel(); ui.statusBar->addWidget(mStatusMessage); ui.statusBar->setStyleSheet("QStatusBar::item { border: 0; }"); + + QTimer::singleShot(0, ui.remotes, SLOT(setFocus())); + + QString rclone = GetRclone(); + if (rclone.isEmpty()) + { + rclone = QStandardPaths::findExecutable("rclone"); + QSettings settings; + settings.setValue("Settings/rclone", rclone); + SetRclone(rclone); + } + if (rclone.isEmpty()) + { + QMessageBox::information(this, "Error", "Cannot check rclone verison!\nPlease verify rclone location."); + emit ui.preferences->trigger(); + } + else + { + rcloneGetVersion(); + } } MainWindow::~MainWindow() @@ -199,7 +196,7 @@ void MainWindow::rcloneGetVersion() { QString version = p->readAllStandardOutput().trimmed(); mStatusMessage->setText(version + " in " + QDir::toNativeSeparators(GetRclone())); - QTimer::singleShot(0, this, &MainWindow::rcloneListRemotes); + rcloneListRemotes(); } else { diff --git a/src/remote_widget.cpp b/src/remote_widget.cpp index 8bc92147..96e8a26e 100644 --- a/src/remote_widget.cpp +++ b/src/remote_widget.cpp @@ -43,7 +43,7 @@ RemoteWidget::RemoteWidget(IconCache* iconCache, const QString& remote, bool isL ItemModel* model = new ItemModel(iconCache, remote, this); ui.tree->setModel(model); - QTimer::singleShot(0, ui.tree, static_cast(&QWidget::setFocus)); + QTimer::singleShot(0, ui.tree, SLOT(setFocus())); QObject::connect(model, &QAbstractItemModel::layoutChanged, this, [=]() { @@ -305,6 +305,7 @@ RemoteWidget::RemoteWidget(IconCache* iconCache, const QString& remote, bool isL drives.insert(path, index); } +#if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0) QThread* thread = new QThread(this); thread->start(); @@ -334,7 +335,8 @@ RemoteWidget::RemoteWidget(IconCache* iconCache, const QString& remote, bool isL thread->deleteLater(); worker->deleteLater(); }); - +#endif + ui.tree->selectionModel()->selectionChanged(QItemSelection(), QItemSelection()); } else