Skip to content

Commit

Permalink
help_plg.cpp: updater
Browse files Browse the repository at this point in the history
Added updating support for the application. Remains to be tested in real
life.
  • Loading branch information
diegoiast committed Sep 23, 2024
1 parent 701c5d4 commit 124750d
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 9 deletions.
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ CPMAddPackage("gh:diegoiast/qutepart-cpp#main")
CPMAddPackage("gh:diegoiast/command-palette-widget#main")
CPMAddPackage("gh:palacaze/image-viewer#master")
CPMAddPackage("gh:Dax89/QHexView#5.0")
CPMAddPackage("gh:alex-spataru/QSimpleUpdater#7f4d8c65686d37b3040335b711eecd4bdc3001fe")

download_breeze_icons(6.4.0)

Expand Down Expand Up @@ -92,7 +93,7 @@ target_include_directories(qtedit4 PUBLIC
${qutepart_SOURCE_DIR}/include
src/widgets
)
target_link_libraries(qtedit4 PUBLIC Qt6::Core Qt6::Widgets Qt6::PrintSupport qmdilib qutepart CommandPaletteWidget Pal::ImageViewer QHexView)
target_link_libraries(qtedit4 PUBLIC Qt6::Core Qt6::Widgets Qt6::PrintSupport qmdilib qutepart CommandPaletteWidget Pal::ImageViewer QHexView QSimpleUpdater)

if(MSVC)
# if we don't do this - file will be under Debug/Relase subdir
Expand Down
2 changes: 1 addition & 1 deletion TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ Tasks for v0.0.1
1. ~~Icon for main window~~
1. ~~Hex editor support for binary files, https://github.com/Dax89/QHexView~~
1. ~~Image viewer (used palacaze/image-viewer)~~
1. ~~Updater: https://github.com/alex-spataru/QSimpleUpdater~~
1. First run actions
1. Create kits
1. Windows:
Expand All @@ -132,7 +133,6 @@ Tasks for v0.0.1
1. Project plugin will need a refactor, its getting too ugly.
1. Internal web browser? why not
1. Global hotkeys https://github.com/Skycoder42/QHotkey/blob/master/README.md
1. Updater: https://github.com/alex-spataru/QSimpleUpdater, https://github.com/Skycoder42/QtAutoUpdater
1. Terminal widget: https://github.com/lxqt/qtermwidget (see what Kate did "back then")
1. QtAwesome icon set: https://github.com/gamecreature/QtAwesome
1. Breadcrumb: https://github.com/Qt-Widgets/wwwidgets-breadcrumb-color-combobox-led-spinbox-navigator-ip-etc
Expand Down
5 changes: 4 additions & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ int main(int argc, char *argv[]) {
QCoreApplication::setApplicationName("qtedit4");
QApplication app(argc, argv);

app.setApplicationVersion("0.0.1");
app.setApplicationName("qtedit4");

#if defined(WIN32)
// default style on windows is ugly and unusable.
// lets fallback to something more usable for us
Expand All @@ -41,7 +44,7 @@ int main(int argc, char *argv[]) {
auto iconsPath = "/../share/icons";
#endif

// On bare bones Linux installs, Windows or OSX,we might now have freedesktop
// On bare bones Linux installs, Windows or OSX, we might not have a freedesktop
// icons thus - we use our bundled icons.
if (needsIcons) {
auto base = QDir(QCoreApplication::applicationDirPath() + iconsPath).absolutePath();
Expand Down
27 changes: 24 additions & 3 deletions src/plugins/help/help_plg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,17 @@
#else
#include <QDesktopServices>
#include <QFile>
#include <QSimpleUpdater.h>
#include <unistd.h>
#endif

#if defined(__linux__)
#define TESTING_CHANNEL "linux-testing"
#elif defined(_WIN32)
#define TESTING_CHANNEL "windows-testing"
#else
#endif

auto static createDesktopMenuItem(const std::string &execPath, const std::string &svgIconContent)
-> std::string {
const char *homeDir = std::getenv("HOME");
Expand Down Expand Up @@ -143,8 +151,11 @@ HelpPlugin::HelpPlugin() {
autoEnabled = true;
alwaysEnabled = false;

actionAbout = new QAction(tr("&About"), this);
connect(actionAbout, SIGNAL(triggered()), this, SLOT(actionAbout_triggered()));
auto actionAbout = new QAction(tr("&About"), this);
connect(actionAbout, &QAction::triggered, this, &HelpPlugin::actionAbout_triggered);
auto actionCheckForUpdates = new QAction(tr("&Check for updates"), this);
connect(actionCheckForUpdates, &QAction::triggered, this,
&HelpPlugin::checkForUpdates_triggered);

auto actionVisitHomePage = new QAction(tr("Visit homepage"), this);
connect(actionVisitHomePage, &QAction::triggered, this,
Expand Down Expand Up @@ -172,9 +183,10 @@ HelpPlugin::HelpPlugin() {
refreshSystemMenus();
});
menus["&Help"]->addAction(installDesktopFile);
menus["&Help"]->addSeparator();
}

menus["&Help"]->addAction(actionCheckForUpdates);
menus["&Help"]->addSeparator();
menus["&Help"]->addAction(actionVisitHomePage);
menus["&Help"]->addAction(actionAboutQt);
menus["&Help"]->addAction(actionAbout);
Expand All @@ -191,3 +203,12 @@ void HelpPlugin::actionAbout_triggered() {
QMessageBox::information(dynamic_cast<QMainWindow *>(mdiServer), "About",
"QtEdit4 - a text editor");
}

void HelpPlugin::checkForUpdates_triggered() {
auto url = "https://raw.githubusercontent.com/diegoiast/qtedit4/refs/heads/main/updates.json";
// QSimpleUpdater::getInstance()->setPlatformKey(url, TESTING_CHANNEL);
QSimpleUpdater::getInstance()->setNotifyOnUpdate(url, true);
QSimpleUpdater::getInstance()->setNotifyOnFinish(url, true);
QSimpleUpdater::getInstance()->setDownloaderEnabled(url, true);
QSimpleUpdater::getInstance()->checkForUpdates(url);
}
4 changes: 1 addition & 3 deletions src/plugins/help/help_plg.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,5 @@ class HelpPlugin : public IPlugin {
void showAbout();
public slots:
void actionAbout_triggered();

private:
QAction *actionAbout;
void checkForUpdates_triggered();
};

0 comments on commit 124750d

Please sign in to comment.