From 23341d63d06d6484ff9576513cca0aa4c236096d Mon Sep 17 00:00:00 2001 From: malte_langkabel Date: Mon, 10 Apr 2017 18:45:32 +0200 Subject: [PATCH] ui: reset window layout option in view menu --- CMakeLists.txt | 4 ++++ bin/app/data/fallback/window_settings.ini | 8 ++++---- cmake/LinuxPackage.cmake | 12 ------------ setup/MacOSX/bundle_install.sh.in | 7 +------ src/lib/utility/ResourcePaths.cpp | 5 +++++ src/lib/utility/ResourcePaths.h | 1 + src/lib_gui/platform_includes/includesLinux.h | 2 ++ src/lib_gui/platform_includes/includesMac.h | 3 ++- src/lib_gui/platform_includes/includesWindows.h | 5 +++-- src/lib_gui/qt/window/QtMainWindow.cpp | 14 ++++++++++++++ src/lib_gui/qt/window/QtMainWindow.h | 4 ++++ 11 files changed, 40 insertions(+), 25 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 880aa47c..2065fa47 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -635,6 +635,10 @@ if(UNIX AND NOT APPLE) "-E" "create_symlink" "${CMAKE_SOURCE_DIR}/bin/app/data" "${CMAKE_BINARY_DIR}/app/data" + COMMAND "${CMAKE_COMMAND}" + "-E" "create_symlink" + "${CMAKE_SOURCE_DIR}/bin/app/user" + "${CMAKE_BINARY_DIR}/app/user" ) # Linux package include(cmake/LinuxPackage.cmake) diff --git a/bin/app/data/fallback/window_settings.ini b/bin/app/data/fallback/window_settings.ini index 28a44347..29388441 100644 --- a/bin/app/data/fallback/window_settings.ini +++ b/bin/app/data/fallback/window_settings.ini @@ -1,8 +1,8 @@ [General] -DOCK_LOCATIONS=@ByteArray(\0\0\0\xff\0\0\0\0\xfd\0\0\0\x1\0\0\0\x2\0\0\a\x80\0\0\x3\xcd\xfc\x1\0\0\0\x2\xfc\0\0\0\0\0\0\x4\x90\0\0\0\0\0\xff\xff\xff\xfc\x2\0\0\0\x1\xfb\0\0\0\xe\0\x44\0o\0\x63\0k\0L\0o\0g\0\0\0\x2\xc6\0\0\0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0\0\0\x2\xfb\0\0\0\x14\0\x44\0o\0\x63\0k\0S\0\x65\0\x61\0r\0\x63\0h\x1\0\0\0\x16\0\0\0M\0\0\0\x44\0\xff\xff\xff\xfb\0\0\0\x12\0\x44\0o\0\x63\0k\0G\0r\0\x61\0p\0h\x1\0\0\0g\0\0\x2\x62\0\0\0[\0\xff\xff\xff\xfb\0\0\0\x10\0\x44\0o\0\x63\0k\0\x43\0o\0\x64\0\x65\x1\0\0\x2T\0\0\x2/\0\0\0\xdd\0\xff\xff\xff\xfb\0\0\0\x14\0\x44\0o\0\x63\0k\0S\0t\0\x61\0t\0u\0s\0\0\0\x2I\0\0\0\xcb\0\0\0\xcb\0\xff\xff\xff\0\0\x4\x83\0\0\0\0\0\0\0\x4\0\0\0\x4\0\0\0\b\0\0\0\b\xfc\0\0\0\0) [MainWindow] -maximized=true -size=@Size(1287 811) -position=@Point(259 117) +maximized=false +size=@Size(1200 800) +position=@Point(80 50) showTitleBars=true diff --git a/cmake/LinuxPackage.cmake b/cmake/LinuxPackage.cmake index ef4ae133..92f91c25 100644 --- a/cmake/LinuxPackage.cmake +++ b/cmake/LinuxPackage.cmake @@ -103,18 +103,6 @@ function(AddSharedToComponent componentName) COMPONENT ${componentName} ) - INSTALL(FILES - ${CMAKE_SOURCE_DIR}/bin/app/data/fallback/ApplicationSettings.xml - COMPONENT ${componentName} - DESTINATION Sourcetrail/user - ) - - INSTALL(FILES - ${CMAKE_SOURCE_DIR}/bin/app/data/fallback/window_settings.ini - COMPONENT ${componentName} - DESTINATION Sourcetrail/user - ) - INSTALL(DIRECTORY ${CMAKE_SOURCE_DIR}/bin/app/user DESTINATION Sourcetrail COMPONENT ${componentName} diff --git a/setup/MacOSX/bundle_install.sh.in b/setup/MacOSX/bundle_install.sh.in index 38fa326e..4e0b4441 100755 --- a/setup/MacOSX/bundle_install.sh.in +++ b/setup/MacOSX/bundle_install.sh.in @@ -82,14 +82,9 @@ cp -R ../../../bin/app/data/color_schemes $RES_DIR/data/color_schemes cp -R ../../../bin/app/data/fonts $RES_DIR/data/fonts cp -R ../../../bin/app/data/gui $RES_DIR/data/gui cp -R ../../../bin/app/data/java $RES_DIR/data/java +cp -R ../../../bin/app/data/fallback $RES_DIR/data/fallback cp -R ../../../bin/app/user/projects $RES_DIR/data/projects -mkdir -p $RES_DIR/user -mkdir -p $RES_DIR/user/log - -cp ../../../bin/app/user/window_settings.ini $RES_DIR/user/window_settings.ini -cp ../../../bin/app/data/fallback/ApplicationSettings.xml $RES_DIR/user/ApplicationSettings.xml - cp -R ../../../bin/app/data/3rd_party_licenses $BIN_DIR/3rd_party_licenses echo -e $INFO "Copying dynamic libraries." diff --git a/src/lib/utility/ResourcePaths.cpp b/src/lib/utility/ResourcePaths.cpp index 84d7d58c..daf113a5 100644 --- a/src/lib/utility/ResourcePaths.cpp +++ b/src/lib/utility/ResourcePaths.cpp @@ -7,6 +7,11 @@ std::string ResourcePaths::getColorSchemesPath() return AppPath::getAppPath() + "data/color_schemes/"; } +std::string ResourcePaths::getFallbackPath() +{ + return AppPath::getAppPath() + "data/fallback/"; +} + std::string ResourcePaths::getFontsPath() { return AppPath::getAppPath() + "data/fonts/"; diff --git a/src/lib/utility/ResourcePaths.h b/src/lib/utility/ResourcePaths.h index 86e6d5e3..d1943f60 100644 --- a/src/lib/utility/ResourcePaths.h +++ b/src/lib/utility/ResourcePaths.h @@ -7,6 +7,7 @@ class ResourcePaths { public: static std::string getColorSchemesPath(); + static std::string getFallbackPath(); static std::string getFontsPath(); static std::string getGuiPath(); static std::string getJavaPath(); diff --git a/src/lib_gui/platform_includes/includesLinux.h b/src/lib_gui/platform_includes/includesLinux.h index 53401497..5b75737b 100644 --- a/src/lib_gui/platform_includes/includesLinux.h +++ b/src/lib_gui/platform_includes/includesLinux.h @@ -5,6 +5,7 @@ #include #include "utility/AppPath.h" #include "utility/UserPaths.h" +#include "utility/ResourcePaths.h" #include "utility/file/FilePath.h" #include "utility/file/FileSystem.h" #include "qt/utility/utilityQt.h" @@ -40,6 +41,7 @@ void setupApp(int argc, char *argv[]) } } + utility::copyNewFilesFromDirectory(QString::fromStdString(ResourcePaths::getFallbackPath()), userDataPath); utility::copyNewFilesFromDirectory(QString::fromStdString(AppPath::getAppPath() + "/user/" ), userDataPath); } diff --git a/src/lib_gui/platform_includes/includesMac.h b/src/lib_gui/platform_includes/includesMac.h index ecdb4f96..fc775d93 100644 --- a/src/lib_gui/platform_includes/includesMac.h +++ b/src/lib_gui/platform_includes/includesMac.h @@ -8,6 +8,7 @@ #include "qt/utility/utilityQt.h" #include "utility/AppPath.h" +#include "utility/ResourcePaths.h" #include "utility/UserPaths.h" bool appIsMacBundle = false; @@ -55,7 +56,7 @@ void setupPlatform(int argc, char *argv[]) // ---------------------------------------------------------------------------- // Makes the mac bundle copy the user files to the Application Support folder QString dataPath = QStandardPaths::writableLocation(QStandardPaths::DataLocation); - QString oldDataPath = QString::fromStdString(UserPaths::getUserDataPath() + "user/"); + QString oldDataPath = QString::fromStdString(ResourcePaths::getFallbackPath()); QDir dataDir(dataPath); if (!dataDir.exists()) diff --git a/src/lib_gui/platform_includes/includesWindows.h b/src/lib_gui/platform_includes/includesWindows.h index 122cd7de..583d1acc 100644 --- a/src/lib_gui/platform_includes/includesWindows.h +++ b/src/lib_gui/platform_includes/includesWindows.h @@ -7,6 +7,7 @@ #include "vld.h" #include "utility/file/FileSystem.h" +#include "utility/ResourcePaths.h" #include "utility/UserPaths.h" #include "utility/utilityApp.h" @@ -58,8 +59,8 @@ void setupApp(int argc, char *argv[]) #endif // use files in fallback folder if Coati has not been installed and used before - FileSystem::copyFile("data/fallback/ApplicationSettings.xml", UserPaths::getAppSettingsPath()); - FileSystem::copyFile("data/fallback/window_settings.ini", UserPaths::getWindowSettingsPath()); + FileSystem::copyFile(ResourcePaths::getFallbackPath() + "ApplicationSettings.xml", UserPaths::getAppSettingsPath()); + FileSystem::copyFile(ResourcePaths::getFallbackPath() + "window_settings.ini", UserPaths::getWindowSettingsPath()); } #endif // INCLUDES_WINDOWS_H diff --git a/src/lib_gui/qt/window/QtMainWindow.cpp b/src/lib_gui/qt/window/QtMainWindow.cpp index 7443421f..9df706df 100644 --- a/src/lib_gui/qt/window/QtMainWindow.cpp +++ b/src/lib_gui/qt/window/QtMainWindow.cpp @@ -196,13 +196,19 @@ void QtMainWindow::loadLayout() } setShowDockWidgetTitleBars(settings.value("showTitleBars", true).toBool()); settings.endGroup(); + loadDockWidgetLayout(); +} +void QtMainWindow::loadDockWidgetLayout() +{ + QSettings settings(UserPaths::getWindowSettingsPath().c_str(), QSettings::IniFormat); this->restoreState(settings.value("DOCK_LOCATIONS").toByteArray()); for (DockWidget dock : m_dockWidgets) { dock.action->setChecked(!dock.widget->isHidden()); } + } void QtMainWindow::saveLayout() @@ -517,6 +523,13 @@ void QtMainWindow::resetZoom() MessageResetZoom().dispatch(); } +void QtMainWindow::resetWindowLayout() +{ + FileSystem::remove(UserPaths::getWindowSettingsPath()); + FileSystem::copyFile(ResourcePaths::getFallbackPath() + "window_settings.ini", UserPaths::getWindowSettingsPath()); + loadDockWidgetLayout(); +} + void QtMainWindow::openRecentProject() { QAction *action = qobject_cast(sender()); @@ -659,6 +672,7 @@ void QtMainWindow::setupViewMenu() menu->addAction(tr("Larger font"), this, SLOT(zoomIn()), QKeySequence::ZoomIn); menu->addAction(tr("Smaller font"), this, SLOT(zoomOut()), QKeySequence::ZoomOut); menu->addAction(tr("Reset font size"), this, SLOT(resetZoom()), QKeySequence(Qt::CTRL + Qt::Key_0)); + menu->addAction(tr("Reset window layout"), this, SLOT(resetWindowLayout())); m_viewMenu = menu; } diff --git a/src/lib_gui/qt/window/QtMainWindow.h b/src/lib_gui/qt/window/QtMainWindow.h index 30a5d66e..291e9583 100644 --- a/src/lib_gui/qt/window/QtMainWindow.h +++ b/src/lib_gui/qt/window/QtMainWindow.h @@ -65,6 +65,8 @@ public: void loadLayout(); void saveLayout(); + void loadDockWidgetLayout(); + void forceEnterLicense(bool expired); protected: @@ -111,6 +113,8 @@ public slots: void zoomOut(); void resetZoom(); + void resetWindowLayout(); + void openRecentProject(); void updateRecentProjectMenu();