From bbb3b3e6f6e3c0f95873f22e6d0a4aaf350f49d9 Mon Sep 17 00:00:00 2001 From: Petr Mrázek Date: Sun, 15 Jul 2018 14:51:05 +0200 Subject: NOISSUE tabs -> spaces --- application/BuildConfig.cpp.in | 84 +- application/BuildConfig.h | 90 +- application/ColorCache.cpp | 30 +- application/ColorCache.h | 178 +- application/ColumnResizer.cpp | 280 +- application/ColumnResizer.h | 20 +- application/GuiUtil.cpp | 192 +- application/HoeDown.h | 94 +- application/InstancePageProvider.h | 98 +- application/InstanceProxyModel.cpp | 36 +- application/InstanceProxyModel.h | 6 +- application/InstanceWindow.cpp | 270 +- application/InstanceWindow.h | 52 +- application/JavaCommon.cpp | 142 +- application/JavaCommon.h | 74 +- application/KonamiCode.cpp | 50 +- application/KonamiCode.h | 10 +- application/LaunchController.cpp | 482 ++-- application/LaunchController.h | 84 +- application/MainWindow.cpp | 2830 ++++++++++---------- application/MainWindow.h | 210 +- application/MultiMC.cpp | 2008 +++++++------- application/MultiMC.h | 266 +- application/SettingsUI.h | 16 +- application/UpdateController.cpp | 736 ++--- application/UpdateController.h | 54 +- application/VersionProxyModel.cpp | 664 ++--- application/VersionProxyModel.h | 78 +- application/dialogs/AboutDialog.cpp | 156 +- application/dialogs/AboutDialog.h | 22 +- application/dialogs/CopyInstanceDialog.cpp | 92 +- application/dialogs/CopyInstanceDialog.h | 30 +- application/dialogs/CustomMessageBox.cpp | 22 +- application/dialogs/CustomMessageBox.h | 6 +- application/dialogs/EditAccountDialog.cpp | 24 +- application/dialogs/EditAccountDialog.h | 34 +- application/dialogs/ExportInstanceDialog.cpp | 810 +++--- application/dialogs/ExportInstanceDialog.h | 24 +- application/dialogs/IconPickerDialog.cpp | 186 +- application/dialogs/IconPickerDialog.h | 26 +- application/dialogs/LoginDialog.cpp | 82 +- application/dialogs/LoginDialog.h | 30 +- application/dialogs/ModEditDialogCommon.cpp | 58 +- application/dialogs/NewComponentDialog.cpp | 86 +- application/dialogs/NewComponentDialog.h | 20 +- application/dialogs/NewInstanceDialog.cpp | 198 +- application/dialogs/NewInstanceDialog.h | 52 +- application/dialogs/NotificationDialog.cpp | 114 +- application/dialogs/NotificationDialog.h | 32 +- application/dialogs/ProfileSelectDialog.cpp | 124 +- application/dialogs/ProfileSelectDialog.h | 98 +- application/dialogs/ProgressDialog.cpp | 208 +- application/dialogs/ProgressDialog.h | 40 +- application/dialogs/SkinUploadDialog.cpp | 180 +- application/dialogs/SkinUploadDialog.h | 18 +- application/dialogs/UpdateDialog.cpp | 258 +- application/dialogs/UpdateDialog.h | 40 +- application/dialogs/VersionSelectDialog.cpp | 100 +- application/dialogs/VersionSelectDialog.h | 48 +- application/groupview/GroupView.cpp | 1474 +++++----- application/groupview/GroupView.h | 184 +- application/groupview/GroupedProxyModel.cpp | 34 +- application/groupview/GroupedProxyModel.h | 8 +- application/groupview/InstanceDelegate.cpp | 550 ++-- application/groupview/InstanceDelegate.h | 8 +- application/groupview/VisualGroup.cpp | 462 ++-- application/groupview/VisualGroup.h | 106 +- application/install_prereqs.cmake.in | 28 +- application/main.cpp | 62 +- application/package/linux/MultiMC | 116 +- application/pagedialog/PageDialog.cpp | 44 +- application/pagedialog/PageDialog.h | 10 +- application/pages/BasePage.h | 54 +- application/pages/BasePageContainer.h | 8 +- application/pages/BasePageProvider.h | 66 +- application/pages/global/AccountListPage.cpp | 140 +- application/pages/global/AccountListPage.h | 72 +- application/pages/global/CustomCommandsPage.cpp | 48 +- application/pages/global/CustomCommandsPage.h | 46 +- application/pages/global/ExternalToolsPage.cpp | 304 +-- application/pages/global/ExternalToolsPage.h | 70 +- application/pages/global/JavaPage.cpp | 164 +- application/pages/global/JavaPage.h | 56 +- application/pages/global/MinecraftPage.cpp | 42 +- application/pages/global/MinecraftPage.h | 50 +- application/pages/global/MultiMCPage.cpp | 774 +++--- application/pages/global/MultiMCPage.h | 98 +- application/pages/global/PackagesPage.cpp | 286 +- application/pages/global/PackagesPage.h | 38 +- application/pages/global/PasteEEPage.cpp | 60 +- application/pages/global/PasteEEPage.h | 50 +- application/pages/global/ProxyPage.cpp | 88 +- application/pages/global/ProxyPage.h | 50 +- .../pages/instance/InstanceSettingsPage.cpp | 388 +-- application/pages/instance/InstanceSettingsPage.h | 62 +- application/pages/instance/LegacyUpgradePage.cpp | 42 +- application/pages/instance/LegacyUpgradePage.h | 48 +- application/pages/instance/LogPage.cpp | 442 +-- application/pages/instance/LogPage.h | 80 +- application/pages/instance/ModFolderPage.cpp | 220 +- application/pages/instance/ModFolderPage.h | 110 +- application/pages/instance/NewModFolderPage.cpp | 168 +- application/pages/instance/NewModFolderPage.h | 96 +- application/pages/instance/NotesPage.cpp | 14 +- application/pages/instance/NotesPage.h | 50 +- application/pages/instance/OtherLogsPage.cpp | 418 +-- application/pages/instance/OtherLogsPage.h | 76 +- application/pages/instance/ResourcePackPage.h | 24 +- application/pages/instance/ScreenshotsPage.cpp | 538 ++-- application/pages/instance/ScreenshotsPage.h | 80 +- application/pages/instance/ServersPage.cpp | 1278 ++++----- application/pages/instance/ServersPage.h | 78 +- application/pages/instance/TexturePackPage.h | 22 +- application/pages/instance/VersionPage.cpp | 788 +++--- application/pages/instance/VersionPage.h | 96 +- application/pages/instance/WorldListPage.cpp | 396 +-- application/pages/instance/WorldListPage.h | 98 +- application/pages/modplatform/FTBPage.cpp | 292 +- application/pages/modplatform/FTBPage.h | 80 +- application/pages/modplatform/FtbListModel.cpp | 208 +- application/pages/modplatform/FtbListModel.h | 62 +- application/pages/modplatform/ImportPage.cpp | 152 +- application/pages/modplatform/ImportPage.h | 54 +- application/pages/modplatform/TechnicPage.cpp | 10 +- application/pages/modplatform/TechnicPage.h | 48 +- application/pages/modplatform/TwitchPage.cpp | 10 +- application/pages/modplatform/TwitchPage.h | 48 +- application/pages/modplatform/VanillaPage.cpp | 88 +- application/pages/modplatform/VanillaPage.h | 62 +- application/resources/OSX/OSX.qrc | 66 +- application/resources/assets/assets.qrc | 2 +- application/resources/documents/documents.qrc | 6 +- application/resources/flat/flat.qrc | 82 +- application/resources/iOS/iOS.qrc | 68 +- application/resources/multimc/multimc.qrc | 556 ++-- application/resources/pe_blue/pe_blue.qrc | 68 +- application/resources/pe_colored/pe_colored.qrc | 68 +- application/resources/pe_dark/pe_dark.qrc | 68 +- application/resources/pe_light/pe_light.qrc | 68 +- application/setupwizard/AnalyticsWizardPage.cpp | 74 +- application/setupwizard/AnalyticsWizardPage.h | 16 +- application/setupwizard/BaseWizardPage.h | 42 +- application/setupwizard/JavaWizardPage.cpp | 90 +- application/setupwizard/JavaWizardPage.h | 24 +- application/setupwizard/LanguageWizardPage.cpp | 62 +- application/setupwizard/LanguageWizardPage.h | 20 +- application/setupwizard/SetupWizard.cpp | 90 +- application/setupwizard/SetupWizard.h | 16 +- application/themes/BrightTheme.cpp | 44 +- application/themes/BrightTheme.h | 18 +- application/themes/CustomTheme.cpp | 368 +-- application/themes/CustomTheme.h | 38 +- application/themes/DarkTheme.cpp | 44 +- application/themes/DarkTheme.h | 18 +- application/themes/FusionTheme.cpp | 2 +- application/themes/FusionTheme.h | 4 +- application/themes/ITheme.cpp | 68 +- application/themes/ITheme.h | 32 +- application/themes/SystemTheme.cpp | 62 +- application/themes/SystemTheme.h | 28 +- application/widgets/Common.cpp | 42 +- application/widgets/Common.h | 2 +- application/widgets/CustomCommands.cpp | 34 +- application/widgets/CustomCommands.h | 18 +- application/widgets/FocusLineEdit.cpp | 22 +- application/widgets/FocusLineEdit.h | 16 +- application/widgets/IconLabel.cpp | 40 +- application/widgets/IconLabel.h | 16 +- application/widgets/JavaSettingsWidget.cpp | 654 ++--- application/widgets/JavaSettingsWidget.h | 122 +- application/widgets/LabeledToolButton.cpp | 102 +- application/widgets/LabeledToolButton.h | 20 +- application/widgets/LineSeparator.cpp | 30 +- application/widgets/LineSeparator.h | 14 +- application/widgets/LogView.cpp | 186 +- application/widgets/LogView.h | 38 +- application/widgets/MCModInfoFrame.cpp | 210 +- application/widgets/MCModInfoFrame.h | 26 +- application/widgets/ModListView.cpp | 74 +- application/widgets/ModListView.h | 6 +- application/widgets/PageContainer.cpp | 310 +-- application/widgets/PageContainer.h | 80 +- application/widgets/PageContainer_p.h | 156 +- application/widgets/ProgressWidget.cpp | 80 +- application/widgets/ProgressWidget.h | 22 +- application/widgets/ServerStatus.cpp | 214 +- application/widgets/ServerStatus.h | 34 +- application/widgets/VersionListView.cpp | 162 +- application/widgets/VersionListView.h | 44 +- application/widgets/VersionSelectWidget.cpp | 212 +- application/widgets/VersionSelectWidget.h | 68 +- 191 files changed, 14997 insertions(+), 14997 deletions(-) (limited to 'application') diff --git a/application/BuildConfig.cpp.in b/application/BuildConfig.cpp.in index 99551867..a1d236b2 100644 --- a/application/BuildConfig.cpp.in +++ b/application/BuildConfig.cpp.in @@ -5,50 +5,50 @@ Config BuildConfig; Config::Config() { - // Version information - VERSION_MAJOR = @MultiMC_VERSION_MAJOR@; - VERSION_MINOR = @MultiMC_VERSION_MINOR@; - VERSION_HOTFIX = @MultiMC_VERSION_HOTFIX@; - VERSION_BUILD = @MultiMC_VERSION_BUILD@; - - BUILD_PLATFORM = "@MultiMC_BUILD_PLATFORM@"; - CHANLIST_URL = "@MultiMC_CHANLIST_URL@"; - ANALYTICS_ID = "@MultiMC_ANALYTICS_ID@"; - NOTIFICATION_URL = "@MultiMC_NOTIFICATION_URL@"; - FULL_VERSION_STR = "@MultiMC_VERSION_MAJOR@.@MultiMC_VERSION_MINOR@.@MultiMC_VERSION_BUILD@"; - - GIT_COMMIT = "@MultiMC_GIT_COMMIT@"; - GIT_REFSPEC = "@MultiMC_GIT_REFSPEC@"; - if(GIT_REFSPEC.startsWith("refs/heads/") && !CHANLIST_URL.isEmpty() && VERSION_BUILD >= 0) - { - VERSION_CHANNEL = GIT_REFSPEC; - VERSION_CHANNEL.remove("refs/heads/"); - UPDATER_ENABLED = true; - } - else - { - VERSION_CHANNEL = QObject::tr("custom"); - } - - VERSION_STR = "@MultiMC_VERSION_STRING@"; - NEWS_RSS_URL = "@MultiMC_NEWS_RSS_URL@"; - PASTE_EE_KEY = "@MultiMC_PASTE_EE_API_KEY@"; + // Version information + VERSION_MAJOR = @MultiMC_VERSION_MAJOR@; + VERSION_MINOR = @MultiMC_VERSION_MINOR@; + VERSION_HOTFIX = @MultiMC_VERSION_HOTFIX@; + VERSION_BUILD = @MultiMC_VERSION_BUILD@; + + BUILD_PLATFORM = "@MultiMC_BUILD_PLATFORM@"; + CHANLIST_URL = "@MultiMC_CHANLIST_URL@"; + ANALYTICS_ID = "@MultiMC_ANALYTICS_ID@"; + NOTIFICATION_URL = "@MultiMC_NOTIFICATION_URL@"; + FULL_VERSION_STR = "@MultiMC_VERSION_MAJOR@.@MultiMC_VERSION_MINOR@.@MultiMC_VERSION_BUILD@"; + + GIT_COMMIT = "@MultiMC_GIT_COMMIT@"; + GIT_REFSPEC = "@MultiMC_GIT_REFSPEC@"; + if(GIT_REFSPEC.startsWith("refs/heads/") && !CHANLIST_URL.isEmpty() && VERSION_BUILD >= 0) + { + VERSION_CHANNEL = GIT_REFSPEC; + VERSION_CHANNEL.remove("refs/heads/"); + UPDATER_ENABLED = true; + } + else + { + VERSION_CHANNEL = QObject::tr("custom"); + } + + VERSION_STR = "@MultiMC_VERSION_STRING@"; + NEWS_RSS_URL = "@MultiMC_NEWS_RSS_URL@"; + PASTE_EE_KEY = "@MultiMC_PASTE_EE_API_KEY@"; } QString Config::printableVersionString() const { - QString vstr = QString("%1.%2.%3").arg(QString::number(VERSION_MAJOR), QString::number(VERSION_MINOR), QString::number(VERSION_HOTFIX)); - - // If the build is not a main release, append the channel - if(VERSION_CHANNEL != "stable") - { - vstr += "-" + VERSION_CHANNEL; - } - - // if a build number is set, also add it to the end - if(VERSION_BUILD >= 0) - { - vstr += "-" + QString::number(VERSION_BUILD); - } - return vstr; + QString vstr = QString("%1.%2.%3").arg(QString::number(VERSION_MAJOR), QString::number(VERSION_MINOR), QString::number(VERSION_HOTFIX)); + + // If the build is not a main release, append the channel + if(VERSION_CHANNEL != "stable") + { + vstr += "-" + VERSION_CHANNEL; + } + + // if a build number is set, also add it to the end + if(VERSION_BUILD >= 0) + { + vstr += "-" + QString::number(VERSION_BUILD); + } + return vstr; } diff --git a/application/BuildConfig.h b/application/BuildConfig.h index 1c9466ba..05fff490 100644 --- a/application/BuildConfig.h +++ b/application/BuildConfig.h @@ -7,64 +7,64 @@ class Config { public: - Config(); - /// The major version number. - int VERSION_MAJOR; - /// The minor version number. - int VERSION_MINOR; - /// The hotfix number. - int VERSION_HOTFIX; - /// The build number. - int VERSION_BUILD; + Config(); + /// The major version number. + int VERSION_MAJOR; + /// The minor version number. + int VERSION_MINOR; + /// The hotfix number. + int VERSION_HOTFIX; + /// The build number. + int VERSION_BUILD; - /** - * The version channel - * This is used by the updater to determine what channel the current version came from. - */ - QString VERSION_CHANNEL; + /** + * The version channel + * This is used by the updater to determine what channel the current version came from. + */ + QString VERSION_CHANNEL; - bool UPDATER_ENABLED = false; + bool UPDATER_ENABLED = false; - /// A short string identifying this build's platform. For example, "lin64" or "win32". - QString BUILD_PLATFORM; + /// A short string identifying this build's platform. For example, "lin64" or "win32". + QString BUILD_PLATFORM; - /// URL for the updater's channel - QString CHANLIST_URL; + /// URL for the updater's channel + QString CHANLIST_URL; - /// Google analytics ID - QString ANALYTICS_ID; + /// Google analytics ID + QString ANALYTICS_ID; - /// URL for notifications - QString NOTIFICATION_URL; + /// URL for notifications + QString NOTIFICATION_URL; - /// Used for matching notifications - QString FULL_VERSION_STR; + /// Used for matching notifications + QString FULL_VERSION_STR; - /// The git commit hash of this build - QString GIT_COMMIT; + /// The git commit hash of this build + QString GIT_COMMIT; - /// The git refspec of this build - QString GIT_REFSPEC; + /// The git refspec of this build + QString GIT_REFSPEC; - /// This is printed on start to standard output - QString VERSION_STR; + /// This is printed on start to standard output + QString VERSION_STR; - /** - * This is used to fetch the news RSS feed. - * It defaults in CMakeLists.txt to "http://multimc.org/rss.xml" - */ - QString NEWS_RSS_URL; + /** + * This is used to fetch the news RSS feed. + * It defaults in CMakeLists.txt to "http://multimc.org/rss.xml" + */ + QString NEWS_RSS_URL; - /** - * API key you can get from paste.ee when you register an account - */ - QString PASTE_EE_KEY; + /** + * API key you can get from paste.ee when you register an account + */ + QString PASTE_EE_KEY; - /** - * \brief Converts the Version to a string. - * \return The version number in string format (major.minor.revision.build). - */ - QString printableVersionString() const; + /** + * \brief Converts the Version to a string. + * \return The version number in string format (major.minor.revision.build). + */ + QString printableVersionString() const; }; extern Config BuildConfig; diff --git a/application/ColorCache.cpp b/application/ColorCache.cpp index e216b597..ef268dd2 100644 --- a/application/ColorCache.cpp +++ b/application/ColorCache.cpp @@ -6,13 +6,13 @@ */ QColor ColorCache::blend(QColor color) { - if (Rainbow::luma(m_front) > Rainbow::luma(m_back)) - { - // for dark color schemes, produce a fitting color first - color = Rainbow::tint(m_front, color, 0.5); - } - // adapt contrast - return Rainbow::mix(m_front, color, m_bias); + if (Rainbow::luma(m_front) > Rainbow::luma(m_back)) + { + // for dark color schemes, produce a fitting color first + color = Rainbow::tint(m_front, color, 0.5); + } + // adapt contrast + return Rainbow::mix(m_front, color, m_bias); } /** @@ -20,16 +20,16 @@ QColor ColorCache::blend(QColor color) */ QColor ColorCache::blendBackground(QColor color) { - // adapt contrast - return Rainbow::mix(m_back, color, m_bias); + // adapt contrast + return Rainbow::mix(m_back, color, m_bias); } void ColorCache::recolorAll() { - auto iter = m_colors.begin(); - while(iter != m_colors.end()) - { - iter->front = blend(iter->original); - iter->back = blendBackground(iter->original); - } + auto iter = m_colors.begin(); + while(iter != m_colors.end()) + { + iter->front = blend(iter->original); + iter->back = blendBackground(iter->original); + } } diff --git a/application/ColorCache.h b/application/ColorCache.h index 1ce1c211..6ae633b9 100644 --- a/application/ColorCache.h +++ b/application/ColorCache.h @@ -7,113 +7,113 @@ class ColorCache { public: - ColorCache(QColor front, QColor back, qreal bias) - { - m_front = front; - m_back = back; - m_bias = bias; - }; + ColorCache(QColor front, QColor back, qreal bias) + { + m_front = front; + m_back = back; + m_bias = bias; + }; - void addColor(int key, QColor color) - { - m_colors[key] = {color, blend(color), blendBackground(color)}; - } + void addColor(int key, QColor color) + { + m_colors[key] = {color, blend(color), blendBackground(color)}; + } - void setForeground(QColor front) - { - if(m_front != front) - { - m_front = front; - recolorAll(); - } - } + void setForeground(QColor front) + { + if(m_front != front) + { + m_front = front; + recolorAll(); + } + } - void setBackground(QColor back) - { - if(m_back != back) - { - m_back = back; - recolorAll(); - } - } + void setBackground(QColor back) + { + if(m_back != back) + { + m_back = back; + recolorAll(); + } + } - QColor getFront(int key) - { - auto iter = m_colors.find(key); - if(iter == m_colors.end()) - { - return QColor(); - } - return (*iter).front; - } + QColor getFront(int key) + { + auto iter = m_colors.find(key); + if(iter == m_colors.end()) + { + return QColor(); + } + return (*iter).front; + } - QColor getBack(int key) - { - auto iter = m_colors.find(key); - if(iter == m_colors.end()) - { - return QColor(); - } - return (*iter).back; - } + QColor getBack(int key) + { + auto iter = m_colors.find(key); + if(iter == m_colors.end()) + { + return QColor(); + } + return (*iter).back; + } - /** - * Blend the color with the front color, adapting to the back color - */ - QColor blend(QColor color); + /** + * Blend the color with the front color, adapting to the back color + */ + QColor blend(QColor color); - /** - * Blend the color with the back color - */ - QColor blendBackground(QColor color); + /** + * Blend the color with the back color + */ + QColor blendBackground(QColor color); protected: - void recolorAll(); + void recolorAll(); protected: - struct ColorEntry - { - QColor original; - QColor front; - QColor back; - }; + struct ColorEntry + { + QColor original; + QColor front; + QColor back; + }; protected: - qreal m_bias; - QColor m_front; - QColor m_back; - QMap m_colors; + qreal m_bias; + QColor m_front; + QColor m_back; + QMap m_colors; }; class LogColorCache : public ColorCache { public: - LogColorCache(QColor front, QColor back) - : ColorCache(front, back, 1.0) - { - addColor((int)MessageLevel::MultiMC, QColor("purple")); - addColor((int)MessageLevel::Debug, QColor("green")); - addColor((int)MessageLevel::Warning, QColor("orange")); - addColor((int)MessageLevel::Error, QColor("red")); - addColor((int)MessageLevel::Fatal, QColor("red")); - addColor((int)MessageLevel::Message, front); - } + LogColorCache(QColor front, QColor back) + : ColorCache(front, back, 1.0) + { + addColor((int)MessageLevel::MultiMC, QColor("purple")); + addColor((int)MessageLevel::Debug, QColor("green")); + addColor((int)MessageLevel::Warning, QColor("orange")); + addColor((int)MessageLevel::Error, QColor("red")); + addColor((int)MessageLevel::Fatal, QColor("red")); + addColor((int)MessageLevel::Message, front); + } - QColor getFront(MessageLevel::Enum level) - { - if(!m_colors.contains((int) level)) - { - return ColorCache::getFront((int)MessageLevel::Message); - } - return ColorCache::getFront((int)level); - } + QColor getFront(MessageLevel::Enum level) + { + if(!m_colors.contains((int) level)) + { + return ColorCache::getFront((int)MessageLevel::Message); + } + return ColorCache::getFront((int)level); + } - QColor getBack(MessageLevel::Enum level) - { - if(level == MessageLevel::Fatal) - { - return QColor(Qt::black); - } - return QColor(Qt::transparent); - } + QColor getBack(MessageLevel::Enum level) + { + if(level == MessageLevel::Fatal) + { + return QColor(Qt::black); + } + return QColor(Qt::transparent); + } }; diff --git a/application/ColumnResizer.cpp b/application/ColumnResizer.cpp index ee99bf40..fe415067 100644 --- a/application/ColumnResizer.cpp +++ b/application/ColumnResizer.cpp @@ -14,67 +14,67 @@ class FormLayoutWidgetItem : public QWidgetItem { public: - FormLayoutWidgetItem(QWidget* widget, QFormLayout* formLayout, QFormLayout::ItemRole itemRole) - : QWidgetItem(widget) - , m_width(-1) - , m_formLayout(formLayout) - , m_itemRole(itemRole) - {} - - QSize sizeHint() const - { - QSize size = QWidgetItem::sizeHint(); - if (m_width != -1) { - size.setWidth(m_width); - } - return size; - } - - QSize minimumSize() const - { - QSize size = QWidgetItem::minimumSize(); - if (m_width != -1) { - size.setWidth(m_width); - } - return size; - } - - QSize maximumSize() const - { - QSize size = QWidgetItem::maximumSize(); - if (m_width != -1) { - size.setWidth(m_width); - } - return size; - } - - void setWidth(int width) - { - if (width != m_width) { - m_width = width; - invalidate(); - } - } - - void setGeometry(const QRect& _rect) - { - QRect rect = _rect; - int width = widget()->sizeHint().width(); - if (m_itemRole == QFormLayout::LabelRole && m_formLayout->labelAlignment() & Qt::AlignRight) { - rect.setLeft(rect.right() - width); - } - QWidgetItem::setGeometry(rect); - } - - QFormLayout* formLayout() const - { - return m_formLayout; - } + FormLayoutWidgetItem(QWidget* widget, QFormLayout* formLayout, QFormLayout::ItemRole itemRole) + : QWidgetItem(widget) + , m_width(-1) + , m_formLayout(formLayout) + , m_itemRole(itemRole) + {} + + QSize sizeHint() const + { + QSize size = QWidgetItem::sizeHint(); + if (m_width != -1) { + size.setWidth(m_width); + } + return size; + } + + QSize minimumSize() const + { + QSize size = QWidgetItem::minimumSize(); + if (m_width != -1) { + size.setWidth(m_width); + } + return size; + } + + QSize maximumSize() const + { + QSize size = QWidgetItem::maximumSize(); + if (m_width != -1) { + size.setWidth(m_width); + } + return size; + } + + void setWidth(int width) + { + if (width != m_width) { + m_width = width; + invalidate(); + } + } + + void setGeometry(const QRect& _rect) + { + QRect rect = _rect; + int width = widget()->sizeHint().width(); + if (m_itemRole == QFormLayout::LabelRole && m_formLayout->labelAlignment() & Qt::AlignRight) { + rect.setLeft(rect.right() - width); + } + QWidgetItem::setGeometry(rect); + } + + QFormLayout* formLayout() const + { + return m_formLayout; + } private: - int m_width; - QFormLayout* m_formLayout; - QFormLayout::ItemRole m_itemRole; + int m_width; + QFormLayout* m_formLayout; + QFormLayout::ItemRole m_itemRole; }; typedef QPair GridColumnInfo; @@ -82,25 +82,25 @@ typedef QPair GridColumnInfo; class ColumnResizerPrivate { public: - ColumnResizerPrivate(ColumnResizer* q_ptr) - : q(q_ptr) - , m_updateTimer(new QTimer(q)) - { - m_updateTimer->setSingleShot(true); - m_updateTimer->setInterval(0); - QObject::connect(m_updateTimer, SIGNAL(timeout()), q, SLOT(updateWidth())); - } - - void scheduleWidthUpdate() - { - m_updateTimer->start(); - } - - ColumnResizer* q; - QTimer* m_updateTimer; - QList m_widgets; - QList m_wrWidgetItemList; - QList m_gridColumnInfoList; + ColumnResizerPrivate(ColumnResizer* q_ptr) + : q(q_ptr) + , m_updateTimer(new QTimer(q)) + { + m_updateTimer->setSingleShot(true); + m_updateTimer->setInterval(0); + QObject::connect(m_updateTimer, SIGNAL(timeout()), q, SLOT(updateWidth())); + } + + void scheduleWidthUpdate() + { + m_updateTimer->start(); + } + + ColumnResizer* q; + QTimer* m_updateTimer; + QList m_widgets; + QList m_wrWidgetItemList; + QList m_gridColumnInfoList; }; ColumnResizer::ColumnResizer(QObject* parent) @@ -110,90 +110,90 @@ ColumnResizer::ColumnResizer(QObject* parent) ColumnResizer::~ColumnResizer() { - delete d; + delete d; } void ColumnResizer::addWidget(QWidget* widget) { - d->m_widgets.append(widget); - widget->installEventFilter(this); - d->scheduleWidthUpdate(); + d->m_widgets.append(widget); + widget->installEventFilter(this); + d->scheduleWidthUpdate(); } void ColumnResizer::updateWidth() { - int width = 0; - Q_FOREACH(QWidget* widget, d->m_widgets) { - width = qMax(widget->sizeHint().width(), width); - } - Q_FOREACH(FormLayoutWidgetItem* item, d->m_wrWidgetItemList) { - item->setWidth(width); - item->formLayout()->update(); - } - Q_FOREACH(GridColumnInfo info, d->m_gridColumnInfoList) { - info.first->setColumnMinimumWidth(info.second, width); - } + int width = 0; + Q_FOREACH(QWidget* widget, d->m_widgets) { + width = qMax(widget->sizeHint().width(), width); + } + Q_FOREACH(FormLayoutWidgetItem* item, d->m_wrWidgetItemList) { + item->setWidth(width); + item->formLayout()->update(); + } + Q_FOREACH(GridColumnInfo info, d->m_gridColumnInfoList) { + info.first->setColumnMinimumWidth(info.second, width); + } } bool ColumnResizer::eventFilter(QObject*, QEvent* event) { - if (event->type() == QEvent::Resize) { - d->scheduleWidthUpdate(); - } - return false; + if (event->type() == QEvent::Resize) { + d->scheduleWidthUpdate(); + } + return false; } void ColumnResizer::addWidgetsFromLayout(QLayout* layout, int column) { - Q_ASSERT(column >= 0); - QGridLayout* gridLayout = qobject_cast(layout); - QFormLayout* formLayout = qobject_cast(layout); - if (gridLayout) { - addWidgetsFromGridLayout(gridLayout, column); - } else if (formLayout) { - if (column > QFormLayout::SpanningRole) { - qCritical() << "column should not be more than" << QFormLayout::SpanningRole << "for QFormLayout"; - return; - } - QFormLayout::ItemRole role = static_cast(column); - addWidgetsFromFormLayout(formLayout, role); - } else { - qCritical() << "Don't know how to handle layout" << layout; - } + Q_ASSERT(column >= 0); + QGridLayout* gridLayout = qobject_cast(layout); + QFormLayout* formLayout = qobject_cast(layout); + if (gridLayout) { + addWidgetsFromGridLayout(gridLayout, column); + } else if (formLayout) { + if (column > QFormLayout::SpanningRole) { + qCritical() << "column should not be more than" << QFormLayout::SpanningRole << "for QFormLayout"; + return; + } + QFormLayout::ItemRole role = static_cast(column); + addWidgetsFromFormLayout(formLayout, role); + } else { + qCritical() << "Don't know how to handle layout" << layout; + } } void ColumnResizer::addWidgetsFromGridLayout(QGridLayout* layout, int column) { - for (int row = 0; row < layout->rowCount(); ++row) { - QLayoutItem* item = layout->itemAtPosition(row, column); - if (!item) { - continue; - } - QWidget* widget = item->widget(); - if (!widget) { - continue; - } - addWidget(widget); - } - d->m_gridColumnInfoList << GridColumnInfo(layout, column); + for (int row = 0; row < layout->rowCount(); ++row) { + QLayoutItem* item = layout->itemAtPosition(row, column); + if (!item) { + continue; + } + QWidget* widget = item->widget(); + if (!widget) { + continue; + } + addWidget(widget); + } + d->m_gridColumnInfoList << GridColumnInfo(layout, column); } void ColumnResizer::addWidgetsFromFormLayout(QFormLayout* layout, QFormLayout::ItemRole role) { - for (int row = 0; row < layout->rowCount(); ++row) { - QLayoutItem* item = layout->itemAt(row, role); - if (!item) { - continue; - } - QWidget* widget = item->widget(); - if (!widget) { - continue; - } - layout->removeItem(item); - delete item; - FormLayoutWidgetItem* newItem = new FormLayoutWidgetItem(widget, layout, role); - layout->setItem(row, role, newItem); - addWidget(widget); - d->m_wrWidgetItemList << newItem; - } + for (int row = 0; row < layout->rowCount(); ++row) { + QLayoutItem* item = layout->itemAt(row, role); + if (!item) { + continue; + } + QWidget* widget = item->widget(); + if (!widget) { + continue; + } + layout->removeItem(item); + delete item; + FormLayoutWidgetItem* newItem = new FormLayoutWidgetItem(widget, layout, role); + layout->setItem(row, role, newItem); + addWidget(widget); + d->m_wrWidgetItemList << newItem; + } } diff --git a/application/ColumnResizer.h b/application/ColumnResizer.h index 78966a7e..8c920f01 100644 --- a/application/ColumnResizer.h +++ b/application/ColumnResizer.h @@ -18,24 +18,24 @@ class QWidget; class ColumnResizerPrivate; class ColumnResizer : public QObject { - Q_OBJECT + Q_OBJECT public: - ColumnResizer(QObject* parent = 0); - ~ColumnResizer(); + ColumnResizer(QObject* parent = 0); + ~ColumnResizer(); - void addWidget(QWidget* widget); - void addWidgetsFromLayout(QLayout*, int column); - void addWidgetsFromGridLayout(QGridLayout*, int column); - void addWidgetsFromFormLayout(QFormLayout*, QFormLayout::ItemRole role); + void addWidget(QWidget* widget); + void addWidgetsFromLayout(QLayout*, int column); + void addWidgetsFromGridLayout(QGridLayout*, int column); + void addWidgetsFromFormLayout(QFormLayout*, QFormLayout::ItemRole role); private Q_SLOTS: - void updateWidth(); + void updateWidth(); protected: - bool eventFilter(QObject*, QEvent* event); + bool eventFilter(QObject*, QEvent* event); private: - ColumnResizerPrivate* const d; + ColumnResizerPrivate* const d; }; #endif /* COLUMNRESIZER_H */ diff --git a/application/GuiUtil.cpp b/application/GuiUtil.cpp index b05fc57c..302206f5 100644 --- a/application/GuiUtil.cpp +++ b/application/GuiUtil.cpp @@ -15,117 +15,117 @@ QString GuiUtil::uploadPaste(const QString &text, QWidget *parentWidget) { - ProgressDialog dialog(parentWidget); - auto APIKeySetting = MMC->settings()->get("PasteEEAPIKey").toString(); - if(APIKeySetting == "multimc") - { - APIKeySetting = BuildConfig.PASTE_EE_KEY; - } - std::unique_ptr paste(new PasteUpload(parentWidget, text, APIKeySetting)); - - if (!paste->validateText()) - { - CustomMessageBox::selectable( - parentWidget, QObject::tr("Upload failed"), - QObject::tr("The log file is too big. You'll have to upload it manually."), - QMessageBox::Warning)->exec(); - return QString(); - } - - dialog.execWithTask(paste.get()); - if (!paste->wasSuccessful()) - { - CustomMessageBox::selectable(parentWidget, QObject::tr("Upload failed"), - paste->failReason(), QMessageBox::Critical)->exec(); - return QString(); - } - else - { - const QString link = paste->pasteLink(); - setClipboardText(link); - CustomMessageBox::selectable( - parentWidget, QObject::tr("Upload finished"), - QObject::tr("The link to the uploaded log has been placed in your clipboard.").arg(link), - QMessageBox::Information)->exec(); - return link; - } + ProgressDialog dialog(parentWidget); + auto APIKeySetting = MMC->settings()->get("PasteEEAPIKey").toString(); + if(APIKeySetting == "multimc") + { + APIKeySetting = BuildConfig.PASTE_EE_KEY; + } + std::unique_ptr paste(new PasteUpload(parentWidget, text, APIKeySetting)); + + if (!paste->validateText()) + { + CustomMessageBox::selectable( + parentWidget, QObject::tr("Upload failed"), + QObject::tr("The log file is too big. You'll have to upload it manually."), + QMessageBox::Warning)->exec(); + return QString(); + } + + dialog.execWithTask(paste.get()); + if (!paste->wasSuccessful()) + { + CustomMessageBox::selectable(parentWidget, QObject::tr("Upload failed"), + paste->failReason(), QMessageBox::Critical)->exec(); + return QString(); + } + else + { + const QString link = paste->pasteLink(); + setClipboardText(link); + CustomMessageBox::selectable( + parentWidget, QObject::tr("Upload finished"), + QObject::tr("The link to the uploaded log has been placed in your clipboard.").arg(link), + QMessageBox::Information)->exec(); + return link; + } } void GuiUtil::setClipboardText(const QString &text) { - QApplication::clipboard()->setText(text); + QApplication::clipboard()->setText(text); } static QStringList BrowseForFileInternal(QString context, QString caption, QString filter, QString defaultPath, QWidget *parentWidget, bool single) { - static QMap savedPaths; - - QFileDialog w(parentWidget, caption); - QSet locations; - auto f = [&](QStandardPaths::StandardLocation l) - { - QString location = QStandardPaths::writableLocation(l); - QFileInfo finfo(location); - if (!finfo.exists()) - return; - locations.insert(location); - }; - f(QStandardPaths::DesktopLocation); - f(QStandardPaths::DocumentsLocation); - f(QStandardPaths::DownloadLocation); - f(QStandardPaths::HomeLocation); - QList urls; - for (auto location : locations) - { - urls.append(QUrl::fromLocalFile(location)); - } - urls.append(QUrl::fromLocalFile(defaultPath)); - - w.setFileMode(single ? QFileDialog::ExistingFile : QFileDialog::ExistingFiles); - w.setAcceptMode(QFileDialog::AcceptOpen); - w.setNameFilter(filter); - - QString pathToOpen; - if(savedPaths.contains(context)) - { - pathToOpen = savedPaths[context]; - } - else - { - pathToOpen = defaultPath; - } - if(!pathToOpen.isEmpty()) - { - QFileInfo finfo(pathToOpen); - if(finfo.exists() && finfo.isDir()) - { - w.setDirectory(finfo.absoluteFilePath()); - } - } - - w.setSidebarUrls(urls); - - if (w.exec()) - { - savedPaths[context] = w.directory().absolutePath(); - return w.selectedFiles(); - } - savedPaths[context] = w.directory().absolutePath(); - return {}; + static QMap savedPaths; + + QFileDialog w(parentWidget, caption); + QSet locations; + auto f = [&](QStandardPaths::StandardLocation l) + { + QString location = QStandardPaths::writableLocation(l); + QFileInfo finfo(location); + if (!finfo.exists()) + return; + locations.insert(location); + }; + f(QStandardPaths::DesktopLocation); + f(QStandardPaths::DocumentsLocation); + f(QStandardPaths::DownloadLocation); + f(QStandardPaths::HomeLocation); + QList urls; + for (auto location : locations) + { + urls.append(QUrl::fromLocalFile(location)); + } + urls.append(QUrl::fromLocalFile(defaultPath)); + + w.setFileMode(single ? QFileDialog::ExistingFile : QFileDialog::ExistingFiles); + w.setAcceptMode(QFileDialog::AcceptOpen); + w.setNameFilter(filter); + + QString pathToOpen; + if(savedPaths.contains(context)) + { + pathToOpen = savedPaths[context]; + } + else + { + pathToOpen = defaultPath; + } + if(!pathToOpen.isEmpty()) + { + QFileInfo finfo(pathToOpen); + if(finfo.exists() && finfo.isDir()) + { + w.setDirectory(finfo.absoluteFilePath()); + } + } + + w.setSidebarUrls(urls); + + if (w.exec()) + { + savedPaths[context] = w.directory().absolutePath(); + return w.selectedFiles(); + } + savedPaths[context] = w.directory().absolutePath(); + return {}; } QString GuiUtil::BrowseForFile(QString context, QString caption, QString filter, QString defaultPath, QWidget *parentWidget) { - auto resultList = BrowseForFileInternal(context, caption, filter, defaultPath, parentWidget, true); - if(resultList.size()) - { - return resultList[0]; - } - return QString(); + auto resultList = BrowseForFileInternal(context, caption, filter, defaultPath, parentWidget, true); + if(resultList.size()) + { + return resultList[0]; + } + return QString(); } QStringList GuiUtil::BrowseForFiles(QString context, QString caption, QString filter, QString defaultPath, QWidget *parentWidget) { - return BrowseForFileInternal(context, caption, filter, defaultPath, parentWidget, false); + return BrowseForFileInternal(context, caption, filter, defaultPath, parentWidget, false); } diff --git a/application/HoeDown.h b/application/HoeDown.h index 18c315c6..ba94da8c 100644 --- a/application/HoeDown.h +++ b/application/HoeDown.h @@ -25,52 +25,52 @@ class HoeDown { public: - class buffer - { - public: - buffer(size_t unit = 4096) - { - buf = hoedown_buffer_new(unit); - } - ~buffer() - { - hoedown_buffer_free(buf); - } - const char * cstr() - { - return hoedown_buffer_cstr(buf); - } - void put(QByteArray input) - { - hoedown_buffer_put(buf, (uint8_t *) input.data(), input.size()); - } - const uint8_t * data() const - { - return buf->data; - } - size_t size() const - { - return buf->size; - } - hoedown_buffer * buf; - } ib, ob; - HoeDown() - { - renderer = hoedown_html_renderer_new((hoedown_html_flags) 0,0); - document = hoedown_document_new(renderer, (hoedown_extensions) 0, 8); - } - ~HoeDown() - { - hoedown_document_free(document); - hoedown_html_renderer_free(renderer); - } - QString process(QByteArray input) - { - ib.put(input); - hoedown_document_render(document, ob.buf, ib.data(), ib.size()); - return ob.cstr(); - } + class buffer + { + public: + buffer(size_t unit = 4096) + { + buf = hoedown_buffer_new(unit); + } + ~buffer() + { + hoedown_buffer_free(buf); + } + const char * cstr() + { + return hoedown_buffer_cstr(buf); + } + void put(QByteArray input) + { + hoedown_buffer_put(buf, (uint8_t *) input.data(), input.size()); + } + const uint8_t * data() const + { + return buf->data; + } + size_t size() const + { + return buf->size; + } + hoedown_buffer * buf; + } ib, ob; + HoeDown() + { + renderer = hoedown_html_renderer_new((hoedown_html_flags) 0,0); + document = hoedown_document_new(renderer, (hoedown_extensions) 0, 8); + } + ~HoeDown() + { + hoedown_document_free(document); + hoedown_html_renderer_free(renderer); + } + QString process(QByteArray input) + { + ib.put(input); + hoedown_document_render(document, ob.buf, ib.data(), ib.size()); + return ob.cstr(); + } private: - hoedown_document * document; - hoedown_renderer * renderer; + hoedown_document * document; + hoedown_renderer * renderer; }; diff --git a/application/InstancePageProvider.h b/application/InstancePageProvider.h index ab0f9a72..d07b2ac2 100644 --- a/application/InstancePageProvider.h +++ b/application/InstancePageProvider.h @@ -21,57 +21,57 @@ class InstancePageProvider : public QObject, public BasePageProvider { - Q_OBJECT + Q_OBJECT public: - explicit InstancePageProvider(InstancePtr parent) - { - inst = parent; - } + explicit InstancePageProvider(InstancePtr parent) + { + inst = parent; + } - virtual ~InstancePageProvider() {}; - virtual QList getPages() override - { - QList values; - values.append(new LogPage(inst)); - std::shared_ptr onesix = std::dynamic_pointer_cast(inst); - if(onesix) - { - values.append(new VersionPage(onesix.get())); - auto modsPage = new ModFolderPage(onesix.get(), onesix->loaderModList(), "mods", "loadermods", tr("Loader mods"), "Loader-mods"); - modsPage->setFilter("%1 (*.zip *.jar *.litemod)"); - values.append(modsPage); - auto modsPage2 = new NewModFolderPage(onesix.get(), onesix->modsModel(), "newmods", "newloadermods", tr("New loader mods"), "New-loader-mods"); - modsPage2->setFilter("%1 (*.zip *.jar *.litemod)"); - values.append(modsPage2); - values.append(new CoreModFolderPage(onesix.get(), onesix->coreModList(), "coremods", "coremods", tr("Core mods"), "Core-mods")); - values.append(new ResourcePackPage(onesix.get())); - values.append(new TexturePackPage(onesix.get())); - values.append(new NotesPage(onesix.get())); - values.append(new WorldListPage(onesix.get(), onesix->worldList(), "worlds", "worlds", tr("Worlds"), "Worlds")); - values.append(new ServersPage(onesix.get())); - values.append(new ScreenshotsPage(FS::PathCombine(onesix->minecraftRoot(), "screenshots"))); - values.append(new InstanceSettingsPage(onesix.get())); - } - std::shared_ptr legacy = std::dynamic_pointer_cast(inst); - if(legacy) - { - values.append(new LegacyUpgradePage(legacy)); - values.append(new NotesPage(legacy.get())); - values.append(new WorldListPage(legacy.get(), legacy->worldList(), "worlds", "worlds", tr("Worlds"), "Worlds")); - values.append(new ScreenshotsPage(FS::PathCombine(legacy->minecraftRoot(), "screenshots"))); - } - auto logMatcher = inst->getLogFileMatcher(); - if(logMatcher) - { - values.append(new OtherLogsPage(inst->getLogFileRoot(), logMatcher)); - } - return values; - } + virtual ~InstancePageProvider() {}; + virtual QList getPages() override + { + QList values; + values.append(new LogPage(inst)); + std::shared_ptr onesix = std::dynamic_pointer_cast(inst); + if(onesix) + { + values.append(new VersionPage(onesix.get())); + auto modsPage = new ModFolderPage(onesix.get(), onesix->loaderModList(), "mods", "loadermods", tr("Loader mods"), "Loader-mods"); + modsPage->setFilter("%1 (*.zip *.jar *.litemod)"); + values.append(modsPage); + auto modsPage2 = new NewModFolderPage(onesix.get(), onesix->modsModel(), "newmods", "newloadermods", tr("New loader mods"), "New-loader-mods"); + modsPage2->setFilter("%1 (*.zip *.jar *.litemod)"); + values.append(modsPage2); + values.append(new CoreModFolderPage(onesix.get(), onesix->coreModList(), "coremods", "coremods", tr("Core mods"), "Core-mods")); + values.append(new ResourcePackPage(onesix.get())); + values.append(new TexturePackPage(onesix.get())); + values.append(new NotesPage(onesix.get())); + values.append(new WorldListPage(onesix.get(), onesix->worldList(), "worlds", "worlds", tr("Worlds"), "Worlds")); + values.append(new ServersPage(onesix.get())); + values.append(new ScreenshotsPage(FS::PathCombine(onesix->minecraftRoot(), "screenshots"))); + values.append(new InstanceSettingsPage(onesix.get())); + } + std::shared_ptr legacy = std::dynamic_pointer_cast(inst); + if(legacy) + { + values.append(new LegacyUpgradePage(legacy)); + values.append(new NotesPage(legacy.get())); + values.append(new WorldListPage(legacy.get(), legacy->worldList(), "worlds", "worlds", tr("Worlds"), "Worlds")); + values.append(new ScreenshotsPage(FS::PathCombine(legacy->minecraftRoot(), "screenshots"))); + } + auto logMatcher = inst->getLogFileMatcher(); + if(logMatcher) + { + values.append(new OtherLogsPage(inst->getLogFileRoot(), logMatcher)); + } + return values; + } - virtual QString dialogTitle() override - { - return tr("Edit Instance (%1)").arg(inst->name()); - } + virtual QString dialogTitle() override + { + return tr("Edit Instance (%1)").arg(inst->name()); + } protected: - InstancePtr inst; + InstancePtr inst; }; diff --git a/application/InstanceProxyModel.cpp b/application/InstanceProxyModel.cpp index d0e9e10d..5317f60c 100644 --- a/application/InstanceProxyModel.cpp +++ b/application/InstanceProxyModel.cpp @@ -9,26 +9,26 @@ InstanceProxyModel::InstanceProxyModel(QObject *parent) : GroupedProxyModel(pare QVariant InstanceProxyModel::data(const QModelIndex & index, int role) const { - QVariant data = QSortFilterProxyModel::data(index, role); - if(role == Qt::DecorationRole) - { - return QVariant(MMC->icons()->getIcon(data.toString())); - } - return data; + QVariant data = QSortFilterProxyModel::data(index, role); + if(role == Qt::DecorationRole) + { + return QVariant(MMC->icons()->getIcon(data.toString())); + } + return data; } bool InstanceProxyModel::subSortLessThan(const QModelIndex &left, - const QModelIndex &right) const + const QModelIndex &right) const { - BaseInstance *pdataLeft = static_cast(left.internalPointer()); - BaseInstance *pdataRight = static_cast(right.internalPointer()); - QString sortMode = MMC->settings()->get("InstSortMode").toString(); - if (sortMode == "LastLaunch") - { - return pdataLeft->lastLaunch() > pdataRight->lastLaunch(); - } - else - { - return QString::localeAwareCompare(pdataLeft->name(), pdataRight->name()) < 0; - } + BaseInstance *pdataLeft = static_cast(left.internalPointer()); + BaseInstance *pdataRight = static_cast(right.internalPointer()); + QString sortMode = MMC->settings()->get("InstSortMode").toString(); + if (sortMode == "LastLaunch") + { + return pdataLeft->lastLaunch() > pdataRight->lastLaunch(); + } + else + { + return QString::localeAwareCompare(pdataLeft->name(), pdataRight->name()) < 0; + } } diff --git a/application/InstanceProxyModel.h b/application/InstanceProxyModel.h index c063f526..fab6f834 100644 --- a/application/InstanceProxyModel.h +++ b/application/InstanceProxyModel.h @@ -8,9 +8,9 @@ class InstanceProxyModel : public GroupedProxyModel { public: - explicit InstanceProxyModel(QObject *parent = 0); - QVariant data(const QModelIndex & index, int role) const override; + explicit InstanceProxyModel(QObject *parent = 0); + QVariant data(const QModelIndex & index, int role) const override; protected: - virtual bool subSortLessThan(const QModelIndex &left, const QModelIndex &right) const override; + virtual bool subSortLessThan(const QModelIndex &left, const QModelIndex &right) const override; }; diff --git a/application/InstanceWindow.cpp b/application/InstanceWindow.cpp index b36781a7..711141f2 100644 --- a/application/InstanceWindow.cpp +++ b/application/InstanceWindow.cpp @@ -31,184 +31,184 @@ #include "icons/IconList.h" InstanceWindow::InstanceWindow(InstancePtr instance, QWidget *parent) - : QMainWindow(parent), m_instance(instance) + : QMainWindow(parent), m_instance(instance) { - setAttribute(Qt::WA_DeleteOnClose); - - auto icon = MMC->icons()->getIcon(m_instance->iconKey()); - QString windowTitle = tr("Console window for ") + m_instance->name(); - - // Set window properties - { - setWindowIcon(icon); - setWindowTitle(windowTitle); - } - - // Add page container - { - auto provider = std::make_shared(m_instance); - m_container = new PageContainer(provider.get(), "console", this); - m_container->setParentContainer(this); - setCentralWidget(m_container); - } - - // Add custom buttons to the page container layout. - { - auto horizontalLayout = new QHBoxLayout(); - horizontalLayout->setObjectName(QStringLiteral("horizontalLayout")); - horizontalLayout->setContentsMargins(6, -1, 6, -1); - - auto btnHelp = new QPushButton(); - btnHelp->setText(tr("Help")); - horizontalLayout->addWidget(btnHelp); - connect(btnHelp, SIGNAL(clicked(bool)), m_container, SLOT(help())); - - auto spacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); - horizontalLayout->addSpacerItem(spacer); - - m_killButton = new QPushButton(); - horizontalLayout->addWidget(m_killButton); - connect(m_killButton, SIGNAL(clicked(bool)), SLOT(on_btnKillMinecraft_clicked())); - - m_launchOfflineButton = new QPushButton(); - horizontalLayout->addWidget(m_launchOfflineButton); - m_launchOfflineButton->setText(tr("Launch Offline")); - updateLaunchButtons(); - connect(m_launchOfflineButton, SIGNAL(clicked(bool)), SLOT(on_btnLaunchMinecraftOffline_clicked())); - - m_closeButton = new QPushButton(); - m_closeButton->setText(tr("Close")); - horizontalLayout->addWidget(m_closeButton); - connect(m_closeButton, SIGNAL(clicked(bool)), SLOT(on_closeButton_clicked())); - - m_container->addButtons(horizontalLayout); - } - - // restore window state - { - auto base64State = MMC->settings()->get("ConsoleWindowState").toByteArray(); - restoreState(QByteArray::fromBase64(base64State)); - auto base64Geometry = MMC->settings()->get("ConsoleWindowGeometry").toByteArray(); - restoreGeometry(QByteArray::fromBase64(base64Geometry)); - } - - // set up instance and launch process recognition - { - auto launchTask = m_instance->getLaunchTask(); - on_InstanceLaunchTask_changed(launchTask); - connect(m_instance.get(), &BaseInstance::launchTaskChanged, this, &InstanceWindow::on_InstanceLaunchTask_changed); - connect(m_instance.get(), &BaseInstance::runningStatusChanged, this, &InstanceWindow::on_RunningState_changed); - } - - // set up instance destruction detection - { - connect(m_instance.get(), &BaseInstance::statusChanged, this, &InstanceWindow::on_instanceStatusChanged); - } - show(); + setAttribute(Qt::WA_DeleteOnClose); + + auto icon = MMC->icons()->getIcon(m_instance->iconKey()); + QString windowTitle = tr("Console window for ") + m_instance->name(); + + // Set window properties + { + setWindowIcon(icon); + setWindowTitle(windowTitle); + } + + // Add page container + { + auto provider = std::make_shared(m_instance); + m_container = new PageContainer(provider.get(), "console", this); + m_container->setParentContainer(this); + setCentralWidget(m_container); + } + + // Add custom buttons to the page container layout. + { + auto horizontalLayout = new QHBoxLayout(); + horizontalLayout->setObjectName(QStringLiteral("horizontalLayout")); + horizontalLayout->setContentsMargins(6, -1, 6, -1); + + auto btnHelp = new QPushButton(); + btnHelp->setText(tr("Help")); + horizontalLayout->addWidget(btnHelp); + connect(btnHelp, SIGNAL(clicked(bool)), m_container, SLOT(help())); + + auto spacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); + horizontalLayout->addSpacerItem(spacer); + + m_killButton = new QPushButton(); + horizontalLayout->addWidget(m_killButton); + connect(m_killButton, SIGNAL(clicked(bool)), SLOT(on_btnKillMinecraft_clicked())); + + m_launchOfflineButton = new QPushButton(); + horizontalLayout->addWidget(m_launchOfflineButton); + m_launchOfflineButton->setText(tr("Launch Offline")); + updateLaunchButtons(); + connect(m_launchOfflineButton, SIGNAL(clicked(bool)), SLOT(on_btnLaunchMinecraftOffline_clicked())); + + m_closeButton = new QPushButton(); + m_closeButton->setText(tr("Close")); + horizontalLayout->addWidget(m_closeButton); + connect(m_closeButton, SIGNAL(clicked(bool)), SLOT(on_closeButton_clicked())); + + m_container->addButtons(horizontalLayout); + } + + // restore window state + { + auto base64State = MMC->settings()->get("ConsoleWindowState").toByteArray(); + restoreState(QByteArray::fromBase64(base64State)); + auto base64Geometry = MMC->settings()->get("ConsoleWindowGeometry").toByteArray(); + restoreGeometry(QByteArray::fromBase64(base64Geometry)); + } + + // set up instance and launch process recognition + { + auto launchTask = m_instance->getLaunchTask(); + on_InstanceLaunchTask_changed(launchTask); + connect(m_instance.get(), &BaseInstance::launchTaskChanged, this, &InstanceWindow::on_InstanceLaunchTask_changed); + connect(m_instance.get(), &BaseInstance::runningStatusChanged, this, &InstanceWindow::on_RunningState_changed); + } + + // set up instance destruction detection + { + connect(m_instance.get(), &BaseInstance::statusChanged, this, &InstanceWindow::on_instanceStatusChanged); + } + show(); } void InstanceWindow::on_instanceStatusChanged(BaseInstance::Status, BaseInstance::Status newStatus) { - if(newStatus == BaseInstance::Status::Gone) - { - m_doNotSave = true; - close(); - } + if(newStatus == BaseInstance::Status::Gone) + { + m_doNotSave = true; + close(); + } } void InstanceWindow::updateLaunchButtons() { - if(m_instance->isRunning()) - { - m_launchOfflineButton->setEnabled(false); - m_killButton->setText(tr("Kill")); - m_killButton->setToolTip(tr("Kill the running instance")); - } - else if(!m_instance->canLaunch()) - { - m_launchOfflineButton->setEnabled(false); - m_killButton->setText(tr("Launch")); - m_killButton->setToolTip(tr("Launch the instance")); - m_killButton->setEnabled(false); - } - else - { - m_launchOfflineButton->setEnabled(true); - m_killButton->setText(tr("Launch")); - m_killButton->setToolTip(tr("Launch the instance")); - } + if(m_instance->isRunning()) + { + m_launchOfflineButton->setEnabled(false); + m_killButton->setText(tr("Kill")); + m_killButton->setToolTip(tr("Kill the running instance")); + } + else if(!m_instance->canLaunch()) + { + m_launchOfflineButton->setEnabled(false); + m_killButton->setText(tr("Launch")); + m_killButton->setToolTip(tr("Launch the instance")); + m_killButton->setEnabled(false); + } + else + { + m_launchOfflineButton->setEnabled(true); + m_killButton->setText(tr("Launch")); + m_killButton->setToolTip(tr("Launch the instance")); + } } void InstanceWindow::on_btnLaunchMinecraftOffline_clicked() { - MMC->launch(m_instance, false, nullptr); + MMC->launch(m_instance, false, nullptr); } void InstanceWindow::on_InstanceLaunchTask_changed(std::shared_ptr proc) { - m_proc = proc; + m_proc = proc; } void InstanceWindow::on_RunningState_changed(bool) { - updateLaunchButtons(); - m_container->refreshContainer(); + updateLaunchButtons(); + m_container->refreshContainer(); } void InstanceWindow::on_closeButton_clicked() { - close(); + close(); } void InstanceWindow::closeEvent(QCloseEvent *event) { - bool proceed = true; - if(!m_doNotSave) - { - proceed &= m_container->prepareToClose(); - } - - if(!proceed) - { - return; - } - - MMC->settings()->set("ConsoleWindowState", saveState().toBase64()); - MMC->settings()->set("ConsoleWindowGeometry", saveGeometry().toBase64()); - emit isClosing(); - event->accept(); + bool proceed = true; + if(!m_doNotSave) + { + proceed &= m_container->prepareToClose(); + } + + if(!proceed) + { + return; + } + + MMC->settings()->set("ConsoleWindowState", saveState().toBase64()); + MMC->settings()->set("ConsoleWindowGeometry", saveGeometry().toBase64()); + emit isClosing(); + event->accept(); } bool InstanceWindow::saveAll() { - return m_container->saveAll(); + return m_container->saveAll(); } void InstanceWindow::on_btnKillMinecraft_clicked() { - if(m_instance->isRunning()) - { - MMC->kill(m_instance); - } - else - { - MMC->launch(m_instance, true, nullptr); - } + if(m_instance->isRunning()) + { + MMC->kill(m_instance); + } + else + { + MMC->launch(m_instance, true, nullptr); + } } QString InstanceWindow::instanceId() { - return m_instance->id(); + return m_instance->id(); } bool InstanceWindow::selectPage(QString pageId) { - return m_container->selectPage(pageId); + return m_container->selectPage(pageId); } void InstanceWindow::refreshContainer() { - m_container->refreshContainer(); + m_container->refreshContainer(); } InstanceWindow::~InstanceWindow() @@ -217,10 +217,10 @@ InstanceWindow::~InstanceWindow() bool InstanceWindow::requestClose() { - if(m_container->prepareToClose()) - { - close(); - return true; - } - return false; + if(m_container->prepareToClose()) + { + close(); + return true; + } + return false; } diff --git a/application/InstanceWindow.h b/application/InstanceWindow.h index 2b08644e..c1d56143 100644 --- a/application/InstanceWindow.h +++ b/application/InstanceWindow.h @@ -26,48 +26,48 @@ class QPushButton; class PageContainer; class InstanceWindow : public QMainWindow, public BasePageContainer { - Q_OBJECT + Q_OBJECT public: - explicit InstanceWindow(InstancePtr proc, QWidget *parent = 0); - virtual ~InstanceWindow(); + explicit InstanceWindow(InstancePtr proc, QWidget *parent = 0); + virtual ~InstanceWindow(); - bool selectPage(QString pageId) override; - void refreshContainer() override; + bool selectPage(QString pageId) override; + void refreshContainer() override; - QString instanceId(); + QString instanceId(); - // save all settings and changes (prepare for launch) - bool saveAll(); + // save all settings and changes (prepare for launch) + bool saveAll(); - // request closing the window (from a page) - bool requestClose() override; + // request closing the window (from a page) + bool requestClose() override; signals: - void isClosing(); + void isClosing(); private slots: - void on_closeButton_clicked(); - void on_btnKillMinecraft_clicked(); - void on_btnLaunchMinecraftOffline_clicked(); + void on_closeButton_clicked(); + void on_btnKillMinecraft_clicked(); + void on_btnLaunchMinecraftOffline_clicked(); - void on_InstanceLaunchTask_changed(std::shared_ptr proc); - void on_RunningState_changed(bool running); - void on_instanceStatusChanged(BaseInstance::Status, BaseInstance::Status newStatus); + void on_InstanceLaunchTask_changed(std::shared_ptr proc); + void on_RunningState_changed(bool running); + void on_instanceStatusChanged(BaseInstance::Status, BaseInstance::Status newStatus); protected: - void closeEvent(QCloseEvent *) override; + void closeEvent(QCloseEvent *) override; private: - void updateLaunchButtons(); + void updateLaunchButtons(); private: - std::shared_ptr m_proc; - InstancePtr m_instance; - bool m_doNotSave = false; - PageContainer *m_container = nullptr; - QPushButton *m_closeButton = nullptr; - QPushButton *m_killButton = nullptr; - QPushButton *m_launchOfflineButton = nullptr; + std::shared_ptr m_proc; + InstancePtr m_instance; + bool m_doNotSave = false; + PageContainer *m_container = nullptr; + QPushButton *m_closeButton = nullptr; + QPushButton *m_killButton = nullptr; + QPushButton *m_launchOfflineButton = nullptr; }; diff --git a/application/JavaCommon.cpp b/application/JavaCommon.cpp index 0008fc04..563dfb35 100644 --- a/application/JavaCommon.cpp +++ b/application/JavaCommon.cpp @@ -4,100 +4,100 @@ bool JavaCommon::checkJVMArgs(QString jvmargs, QWidget *parent) { - if (jvmargs.contains("-XX:PermSize=") || jvmargs.contains(QRegExp("-Xm[sx]")) - || jvmargs.contains("-XX-MaxHeapSize") || jvmargs.contains("-XX:InitialHeapSize")) - { - auto warnStr = QObject::tr( - "You tried to manually set a JVM memory option (using \"-XX:PermSize\", \"-XX-MaxHeapSize\", \"-XX:InitialHeapSize\", \"-Xmx\" or \"-Xms\").\n" - "There are dedicated boxes for these in the settings (Java tab, in the Memory group at the top).\n" - "This message will be displayed until you remove them from the JVM arguments."); - CustomMessageBox::selectable( - parent, QObject::tr("JVM arguments warning"), - warnStr, - QMessageBox::Warning)->exec(); - return false; - } - return true; + if (jvmargs.contains("-XX:PermSize=") || jvmargs.contains(QRegExp("-Xm[sx]")) + || jvmargs.contains("-XX-MaxHeapSize") || jvmargs.contains("-XX:InitialHeapSize")) + { + auto warnStr = QObject::tr( + "You tried to manually se